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");
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
);
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 "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest",
1902 "OSPF area parameters\n"
1903 "OSPF area ID in IP address format\n"
1904 "OSPF area ID as a decimal value\n"
1905 "Enable authentication\n"
1906 "Use message-digest authentication\n")
1908 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1909 int idx_ipv4_number
= 1;
1910 struct ospf_area
*area
;
1911 struct in_addr area_id
;
1914 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1916 area
= ospf_area_get(ospf
, area_id
);
1917 ospf_area_display_format_set(ospf
, area
, format
);
1918 area
->auth_type
= strmatch(argv
[0]->text
, "no") ? OSPF_AUTH_NULL
: OSPF_AUTH_CRYPTOGRAPHIC
;
1923 DEFUN (ospf_area_authentication
,
1924 ospf_area_authentication_cmd
,
1925 "area <A.B.C.D|(0-4294967295)> authentication",
1926 "OSPF area parameters\n"
1927 "OSPF area ID in IP address format\n"
1928 "OSPF area ID as a decimal value\n"
1929 "Enable authentication\n")
1931 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1932 int idx_ipv4_number
= 1;
1933 struct ospf_area
*area
;
1934 struct in_addr area_id
;
1937 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1939 area
= ospf_area_get(ospf
, area_id
);
1940 ospf_area_display_format_set(ospf
, area
, format
);
1941 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1946 DEFUN (no_ospf_area_authentication
,
1947 no_ospf_area_authentication_cmd
,
1948 "no area <A.B.C.D|(0-4294967295)> authentication",
1950 "OSPF area parameters\n"
1951 "OSPF area ID in IP address format\n"
1952 "OSPF area ID as a decimal value\n"
1953 "Enable authentication\n")
1955 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1956 int idx_ipv4_number
= 2;
1957 struct ospf_area
*area
;
1958 struct in_addr area_id
;
1961 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1963 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1967 area
->auth_type
= OSPF_AUTH_NULL
;
1969 ospf_area_check_free(ospf
, area_id
);
1975 DEFUN (ospf_abr_type
,
1977 "ospf abr-type <cisco|ibm|shortcut|standard>",
1978 "OSPF specific commands\n"
1979 "Set OSPF ABR type\n"
1980 "Alternative ABR, cisco implementation\n"
1981 "Alternative ABR, IBM implementation\n"
1983 "Standard behavior (RFC2328)\n")
1985 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1987 u_char abr_type
= OSPF_ABR_UNKNOWN
;
1989 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
1990 abr_type
= OSPF_ABR_CISCO
;
1991 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
1992 abr_type
= OSPF_ABR_IBM
;
1993 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
1994 abr_type
= OSPF_ABR_SHORTCUT
;
1995 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
1996 abr_type
= OSPF_ABR_STAND
;
1998 return CMD_WARNING_CONFIG_FAILED
;
2000 /* If ABR type value is changed, schedule ABR task. */
2001 if (ospf
->abr_type
!= abr_type
) {
2002 ospf
->abr_type
= abr_type
;
2003 ospf_schedule_abr_task(ospf
);
2009 DEFUN (no_ospf_abr_type
,
2010 no_ospf_abr_type_cmd
,
2011 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2013 "OSPF specific commands\n"
2014 "Set OSPF ABR type\n"
2015 "Alternative ABR, cisco implementation\n"
2016 "Alternative ABR, IBM implementation\n"
2020 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2022 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2024 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2025 abr_type
= OSPF_ABR_CISCO
;
2026 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2027 abr_type
= OSPF_ABR_IBM
;
2028 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2029 abr_type
= OSPF_ABR_SHORTCUT
;
2030 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2031 abr_type
= OSPF_ABR_STAND
;
2033 return CMD_WARNING_CONFIG_FAILED
;
2035 /* If ABR type value is changed, schedule ABR task. */
2036 if (ospf
->abr_type
== abr_type
) {
2037 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2038 ospf_schedule_abr_task(ospf
);
2044 DEFUN (ospf_log_adjacency_changes
,
2045 ospf_log_adjacency_changes_cmd
,
2046 "log-adjacency-changes",
2047 "Log changes in adjacency state\n")
2049 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2051 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2052 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2056 DEFUN (ospf_log_adjacency_changes_detail
,
2057 ospf_log_adjacency_changes_detail_cmd
,
2058 "log-adjacency-changes detail",
2059 "Log changes in adjacency state\n"
2060 "Log all state changes\n")
2062 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2064 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2065 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2069 DEFUN (no_ospf_log_adjacency_changes
,
2070 no_ospf_log_adjacency_changes_cmd
,
2071 "no log-adjacency-changes",
2073 "Log changes in adjacency state\n")
2075 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2077 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2078 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2082 DEFUN (no_ospf_log_adjacency_changes_detail
,
2083 no_ospf_log_adjacency_changes_detail_cmd
,
2084 "no log-adjacency-changes detail",
2086 "Log changes in adjacency state\n"
2087 "Log all state changes\n")
2089 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2091 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2095 DEFUN (ospf_compatible_rfc1583
,
2096 ospf_compatible_rfc1583_cmd
,
2097 "compatible rfc1583",
2098 "OSPF compatibility list\n"
2099 "compatible with RFC 1583\n")
2101 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2103 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2104 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2105 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2110 DEFUN (no_ospf_compatible_rfc1583
,
2111 no_ospf_compatible_rfc1583_cmd
,
2112 "no compatible rfc1583",
2114 "OSPF compatibility list\n"
2115 "compatible with RFC 1583\n")
2117 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2119 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2120 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2121 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2126 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2127 "ospf rfc1583compatibility",
2128 "OSPF specific commands\n"
2129 "Enable the RFC1583Compatibility flag\n")
2131 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2132 "no ospf rfc1583compatibility", NO_STR
2133 "OSPF specific commands\n"
2134 "Disable the RFC1583Compatibility flag\n")
2136 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2137 unsigned int hold
, unsigned int max
)
2139 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2141 ospf
->spf_delay
= delay
;
2142 ospf
->spf_holdtime
= hold
;
2143 ospf
->spf_max_holdtime
= max
;
2148 DEFUN (ospf_timers_min_ls_interval
,
2149 ospf_timers_min_ls_interval_cmd
,
2150 "timers throttle lsa all (0-5000)",
2151 "Adjust routing timers\n"
2152 "Throttling adaptive timer\n"
2153 "LSA delay between transmissions\n"
2155 "Delay (msec) between sending LSAs\n")
2157 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2159 unsigned int interval
;
2162 vty_out(vty
, "Insufficient arguments\n");
2163 return CMD_WARNING_CONFIG_FAILED
;
2166 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2168 ospf
->min_ls_interval
= interval
;
2173 DEFUN (no_ospf_timers_min_ls_interval
,
2174 no_ospf_timers_min_ls_interval_cmd
,
2175 "no timers throttle lsa all [(0-5000)]",
2177 "Adjust routing timers\n"
2178 "Throttling adaptive timer\n"
2179 "LSA delay between transmissions\n"
2181 "Delay (msec) between sending LSAs\n")
2183 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2184 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2189 DEFUN (ospf_timers_throttle_spf
,
2190 ospf_timers_throttle_spf_cmd
,
2191 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2192 "Adjust routing timers\n"
2193 "Throttling adaptive timer\n"
2195 "Delay (msec) from first change received till SPF calculation\n"
2196 "Initial hold time (msec) between consecutive SPF calculations\n"
2197 "Maximum hold time (msec)\n")
2200 int idx_number_2
= 4;
2201 int idx_number_3
= 5;
2202 unsigned int delay
, hold
, max
;
2205 vty_out(vty
, "Insufficient arguments\n");
2206 return CMD_WARNING_CONFIG_FAILED
;
2209 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2210 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2211 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2213 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2216 DEFUN (no_ospf_timers_throttle_spf
,
2217 no_ospf_timers_throttle_spf_cmd
,
2218 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2220 "Adjust routing timers\n"
2221 "Throttling adaptive timer\n"
2223 "Delay (msec) from first change received till SPF calculation\n"
2224 "Initial hold time (msec) between consecutive SPF calculations\n"
2225 "Maximum hold time (msec)\n")
2227 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2228 OSPF_SPF_HOLDTIME_DEFAULT
,
2229 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2233 DEFUN (ospf_timers_lsa_min_arrival
,
2234 ospf_timers_lsa_min_arrival_cmd
,
2235 "timers lsa min-arrival (0-600000)",
2236 "Adjust routing timers\n"
2238 "Minimum delay in receiving new version of a LSA\n"
2239 "Delay in milliseconds\n")
2241 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2242 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2246 DEFUN (no_ospf_timers_lsa_min_arrival
,
2247 no_ospf_timers_lsa_min_arrival_cmd
,
2248 "no timers lsa min-arrival [(0-600000)]",
2250 "Adjust routing timers\n"
2252 "Minimum delay in receiving new version of a LSA\n"
2253 "Delay in milliseconds\n")
2255 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2256 unsigned int minarrival
;
2259 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2261 if (ospf
->min_ls_arrival
!= minarrival
2262 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2266 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2271 /* Deprecated: 08/07/2017 */
2272 ALIAS_HIDDEN (ospf_timers_lsa_min_arrival
,
2273 ospf_timers_lsa_arrival_cmd
,
2274 "timers lsa arrival (0-1000)",
2275 "adjust routing timers\n"
2276 "throttling link state advertisement delays\n"
2277 "ospf minimum arrival interval delay\n"
2278 "delay (msec) between accepted lsas\n");
2280 /* Deprecated: 08/07/2017 */
2281 ALIAS_HIDDEN (no_ospf_timers_lsa_min_arrival
,
2282 no_ospf_timers_lsa_arrival_cmd
,
2283 "no timers lsa arrival (0-1000)",
2285 "adjust routing timers\n"
2286 "throttling link state advertisement delays\n"
2287 "ospf minimum arrival interval delay\n"
2288 "delay (msec) between accepted lsas\n");
2291 DEFUN (ospf_neighbor
,
2293 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2295 "Neighbor IP address\n"
2296 "Neighbor Priority\n"
2298 "Dead Neighbor Polling interval\n"
2301 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2305 struct in_addr nbr_addr
;
2306 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2307 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2309 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2312 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2315 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2317 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2320 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2323 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2328 DEFUN (ospf_neighbor_poll_interval
,
2329 ospf_neighbor_poll_interval_cmd
,
2330 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2332 "Neighbor IP address\n"
2333 "Dead Neighbor Polling interval\n"
2335 "OSPF priority of non-broadcast neighbor\n"
2338 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2342 struct in_addr nbr_addr
;
2343 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2344 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2346 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2348 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2351 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2353 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2354 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2357 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2362 DEFUN (no_ospf_neighbor
,
2363 no_ospf_neighbor_cmd
,
2364 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2367 "Neighbor IP address\n"
2368 "Neighbor Priority\n"
2370 "Dead Neighbor Polling interval\n"
2373 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2375 struct in_addr nbr_addr
;
2377 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2379 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2384 DEFUN (no_ospf_neighbor_poll
,
2385 no_ospf_neighbor_poll_cmd
,
2386 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2389 "Neighbor IP address\n"
2390 "Dead Neighbor Polling interval\n"
2392 "Neighbor Priority\n"
2395 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2397 struct in_addr nbr_addr
;
2399 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2401 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2406 DEFUN (ospf_refresh_timer
,
2407 ospf_refresh_timer_cmd
,
2408 "refresh timer (10-1800)",
2409 "Adjust refresh parameters\n"
2410 "Set refresh timer\n"
2411 "Timer value in seconds\n")
2413 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2415 unsigned int interval
;
2417 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2418 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2419 * OSPF_LSA_REFRESHER_GRANULARITY
;
2421 ospf_timers_refresh_set(ospf
, interval
);
2426 DEFUN (no_ospf_refresh_timer
,
2427 no_ospf_refresh_timer_val_cmd
,
2428 "no refresh timer [(10-1800)]",
2430 "Adjust refresh parameters\n"
2431 "Unset refresh timer\n"
2432 "Timer value in seconds\n")
2434 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2436 unsigned int interval
;
2439 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2441 if (ospf
->lsa_refresh_interval
!= interval
2442 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2446 ospf_timers_refresh_unset(ospf
);
2452 DEFUN (ospf_auto_cost_reference_bandwidth
,
2453 ospf_auto_cost_reference_bandwidth_cmd
,
2454 "auto-cost reference-bandwidth (1-4294967)",
2455 "Calculate OSPF interface cost according to bandwidth\n"
2456 "Use reference bandwidth method to assign OSPF cost\n"
2457 "The reference bandwidth in terms of Mbits per second\n")
2459 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2462 struct listnode
*node
;
2463 struct interface
*ifp
;
2465 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2466 if (refbw
< 1 || refbw
> 4294967) {
2467 vty_out(vty
, "reference-bandwidth value is invalid\n");
2468 return CMD_WARNING_CONFIG_FAILED
;
2471 /* If reference bandwidth is changed. */
2472 if ((refbw
) == ospf
->ref_bandwidth
)
2475 ospf
->ref_bandwidth
= refbw
;
2476 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
2477 ospf_if_recalculate_output_cost(ifp
);
2482 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2483 no_ospf_auto_cost_reference_bandwidth_cmd
,
2484 "no auto-cost reference-bandwidth [(1-4294967)]",
2486 "Calculate OSPF interface cost according to bandwidth\n"
2487 "Use reference bandwidth method to assign OSPF cost\n"
2488 "The reference bandwidth in terms of Mbits per second\n")
2490 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2491 struct listnode
*node
, *nnode
;
2492 struct interface
*ifp
;
2494 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2497 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2498 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2500 " Please ensure reference bandwidth is consistent across all routers\n");
2502 for (ALL_LIST_ELEMENTS(om
->iflist
, node
, nnode
, ifp
))
2503 ospf_if_recalculate_output_cost(ifp
);
2508 DEFUN (ospf_write_multiplier
,
2509 ospf_write_multiplier_cmd
,
2510 "ospf write-multiplier (1-100)",
2511 "OSPF specific commands\n"
2512 "Write multiplier\n"
2513 "Maximum number of interface serviced per write\n")
2515 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2517 u_int32_t write_oi_count
;
2524 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2525 if (write_oi_count
< 1 || write_oi_count
> 100) {
2526 vty_out(vty
, "write-multiplier value is invalid\n");
2527 return CMD_WARNING_CONFIG_FAILED
;
2530 ospf
->write_oi_count
= write_oi_count
;
2534 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2535 "Write multiplier\n"
2536 "Maximum number of interface serviced per write\n")
2538 DEFUN (no_ospf_write_multiplier
,
2539 no_ospf_write_multiplier_cmd
,
2540 "no ospf write-multiplier (1-100)",
2542 "OSPF specific commands\n"
2543 "Write multiplier\n"
2544 "Maximum number of interface serviced per write\n")
2546 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2548 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2552 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2553 "no write-multiplier (1-100)", NO_STR
2554 "Write multiplier\n"
2555 "Maximum number of interface serviced per write\n")
2557 const char *ospf_abr_type_descr_str
[] = {"Unknown", "Standard (RFC2328)",
2558 "Alternative IBM", "Alternative Cisco",
2559 "Alternative Shortcut"};
2561 const char *ospf_shortcut_mode_descr_str
[] = {"Default", "Enabled", "Disabled"};
2563 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2564 json_object
*json_areas
, u_char use_json
)
2566 json_object
*json_area
= NULL
;
2569 json_area
= json_object_new_object();
2573 vty_out(vty
, " Area ID: %s", inet_ntoa(area
->area_id
));
2575 /* Show Area type/mode. */
2576 if (OSPF_IS_AREA_BACKBONE(area
)) {
2578 json_object_boolean_true_add(json_area
, "backbone");
2580 vty_out(vty
, " (Backbone)\n");
2583 if (area
->external_routing
== OSPF_AREA_STUB
) {
2584 if (area
->no_summary
)
2585 json_object_boolean_true_add(
2586 json_area
, "stubNoSummary");
2587 if (area
->shortcut_configured
)
2588 json_object_boolean_true_add(
2589 json_area
, "stubShortcut");
2590 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2591 if (area
->no_summary
)
2592 json_object_boolean_true_add(
2593 json_area
, "nssaNoSummary");
2594 if (area
->shortcut_configured
)
2595 json_object_boolean_true_add(
2596 json_area
, "nssaShortcut");
2599 json_object_string_add(
2600 json_area
, "shortcuttingMode",
2601 ospf_shortcut_mode_descr_str
2602 [area
->shortcut_configured
]);
2603 if (area
->shortcut_capability
)
2604 json_object_boolean_true_add(json_area
,
2607 if (area
->external_routing
== OSPF_AREA_STUB
)
2608 vty_out(vty
, " (Stub%s%s)",
2609 area
->no_summary
? ", no summary" : "",
2610 area
->shortcut_configured
? "; " : "");
2611 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2612 vty_out(vty
, " (NSSA%s%s)",
2613 area
->no_summary
? ", no summary" : "",
2614 area
->shortcut_configured
? "; " : "");
2617 vty_out(vty
, " Shortcutting mode: %s",
2618 ospf_shortcut_mode_descr_str
2619 [area
->shortcut_configured
]);
2620 vty_out(vty
, ", S-bit consensus: %s\n",
2621 area
->shortcut_capability
? "ok" : "no");
2625 /* Show number of interfaces */
2627 json_object_int_add(json_area
, "areaIfTotalCounter",
2628 listcount(area
->oiflist
));
2629 json_object_int_add(json_area
, "areaIfActiveCounter",
2633 " Number of interfaces in this area: Total: %d, "
2635 listcount(area
->oiflist
), area
->act_ints
);
2637 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2639 json_object_boolean_true_add(json_area
, "nssa");
2640 if (!IS_OSPF_ABR(area
->ospf
))
2641 json_object_boolean_false_add(json_area
, "abr");
2642 else if (area
->NSSATranslatorState
) {
2643 json_object_boolean_true_add(json_area
, "abr");
2644 if (area
->NSSATranslatorRole
2645 == OSPF_NSSA_ROLE_CANDIDATE
)
2646 json_object_boolean_true_add(
2648 "nssaTranslatorElected");
2649 else if (area
->NSSATranslatorRole
2650 == OSPF_NSSA_ROLE_ALWAYS
)
2651 json_object_boolean_true_add(
2653 "nssaTranslatorAlways");
2655 json_object_boolean_true_add(json_area
, "abr");
2656 if (area
->NSSATranslatorRole
2657 == OSPF_NSSA_ROLE_CANDIDATE
)
2658 json_object_boolean_false_add(
2660 "nssaTranslatorElected");
2662 json_object_boolean_true_add(
2664 "nssaTranslatorNever");
2668 " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n");
2669 if (!IS_OSPF_ABR(area
->ospf
))
2671 " It is not ABR, therefore not Translator. \n");
2672 else if (area
->NSSATranslatorState
) {
2673 vty_out(vty
, " We are an ABR and ");
2674 if (area
->NSSATranslatorRole
2675 == OSPF_NSSA_ROLE_CANDIDATE
)
2677 "the NSSA Elected Translator. \n");
2678 else if (area
->NSSATranslatorRole
2679 == OSPF_NSSA_ROLE_ALWAYS
)
2681 "always an NSSA Translator. \n");
2683 vty_out(vty
, " We are an ABR, but ");
2684 if (area
->NSSATranslatorRole
2685 == OSPF_NSSA_ROLE_CANDIDATE
)
2687 "not the NSSA Elected Translator. \n");
2690 "never an NSSA Translator. \n");
2695 /* Stub-router state for this area */
2696 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2697 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2700 json_object_boolean_true_add(
2701 json_area
, "originStubMaxDistRouterLsa");
2702 if (CHECK_FLAG(area
->stub_router_state
,
2703 OSPF_AREA_ADMIN_STUB_ROUTED
))
2704 json_object_boolean_true_add(
2705 json_area
, "indefiniteActiveAdmin");
2706 if (area
->t_stub_router
) {
2710 &area
->t_stub_router
->u
.sands
,
2713 json_object_int_add(
2715 "activeStartupRemainderMsecs",
2720 " Originating stub / maximum-distance Router-LSA\n");
2721 if (CHECK_FLAG(area
->stub_router_state
,
2722 OSPF_AREA_ADMIN_STUB_ROUTED
))
2724 " Administratively activated (indefinitely)\n");
2725 if (area
->t_stub_router
)
2727 " Active from startup, %s remaining\n",
2728 ospf_timer_dump(area
->t_stub_router
,
2735 /* Show number of fully adjacent neighbors. */
2736 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2739 /* Show authentication type. */
2740 if (area
->auth_type
== OSPF_AUTH_NULL
)
2741 json_object_string_add(json_area
, "authentication",
2742 "authenticationNone");
2743 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2744 json_object_string_add(json_area
, "authentication",
2745 "authenticationSimplePassword");
2746 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2747 json_object_string_add(json_area
, "authentication",
2748 "authenticationMessageDigest");
2750 if (!OSPF_IS_AREA_BACKBONE(area
))
2751 json_object_int_add(json_area
,
2752 "virtualAdjacenciesPassingCounter",
2755 /* Show SPF calculation times. */
2756 json_object_int_add(json_area
, "spfExecutedCounter",
2757 area
->spf_calculation
);
2758 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2759 json_object_int_add(
2760 json_area
, "lsaRouterNumber",
2761 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2762 json_object_int_add(
2763 json_area
, "lsaRouterChecksum",
2764 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2765 json_object_int_add(
2766 json_area
, "lsaNetworkNumber",
2767 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2768 json_object_int_add(
2769 json_area
, "lsaNetworkChecksum",
2770 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2771 json_object_int_add(
2772 json_area
, "lsaSummaryNumber",
2773 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2774 json_object_int_add(
2775 json_area
, "lsaSummaryChecksum",
2776 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2777 json_object_int_add(
2778 json_area
, "lsaAsbrNumber",
2779 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2780 json_object_int_add(
2781 json_area
, "lsaAsbrChecksum",
2782 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2783 json_object_int_add(
2784 json_area
, "lsaNssaNumber",
2785 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2786 json_object_int_add(
2787 json_area
, "lsaNssaChecksum",
2788 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2790 /* Show number of fully adjacent neighbors. */
2792 " Number of fully adjacent neighbors in this area:"
2796 /* Show authentication type. */
2797 vty_out(vty
, " Area has ");
2798 if (area
->auth_type
== OSPF_AUTH_NULL
)
2799 vty_out(vty
, "no authentication\n");
2800 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2801 vty_out(vty
, "simple password authentication\n");
2802 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2803 vty_out(vty
, "message digest authentication\n");
2805 if (!OSPF_IS_AREA_BACKBONE(area
))
2807 " Number of full virtual adjacencies going through"
2811 /* Show SPF calculation times. */
2812 vty_out(vty
, " SPF algorithm executed %d times\n",
2813 area
->spf_calculation
);
2815 /* Show number of LSA. */
2816 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
2818 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
2819 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
2820 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2822 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
2823 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
2824 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2826 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
2827 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
2828 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2830 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
2831 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2832 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2833 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
2834 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2835 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2839 json_object_int_add(
2840 json_area
, "lsaOpaqueLinkNumber",
2841 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2842 json_object_int_add(
2843 json_area
, "lsaOpaqueLinkChecksum",
2844 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2845 json_object_int_add(
2846 json_area
, "lsaOpaqueAreaNumber",
2847 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2848 json_object_int_add(
2849 json_area
, "lsaOpaqueAreaChecksum",
2850 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2853 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
2854 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2855 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2857 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
2858 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2859 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2863 json_object_object_add(json_areas
, inet_ntoa(area
->area_id
),
2869 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
2872 struct listnode
*node
, *nnode
;
2873 struct ospf_area
*area
;
2874 struct timeval result
;
2875 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2876 json_object
*json
= NULL
;
2877 json_object
*json_areas
= NULL
;
2880 json
= json_object_new_object();
2881 json_areas
= json_object_new_object();
2884 if (ospf
->instance
) {
2886 json_object_int_add(json
, "ospfInstance",
2889 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
2893 /* Show Router ID. */
2895 json_object_string_add(json
, "routerId",
2896 inet_ntoa(ospf
->router_id
));
2898 vty_out(vty
, " OSPF Routing Process, Router ID: %s\n",
2899 inet_ntoa(ospf
->router_id
));
2902 /* Graceful shutdown */
2903 if (ospf
->t_deferred_shutdown
) {
2908 &ospf
->t_deferred_shutdown
->u
.sands
,
2911 json_object_int_add(json
, "deferredShutdownMsecs",
2915 " Deferred shutdown in progress, %s remaining\n",
2916 ospf_timer_dump(ospf
->t_deferred_shutdown
,
2917 timebuf
, sizeof(timebuf
)));
2921 /* Show capability. */
2923 json_object_boolean_true_add(json
, "tosRoutesOnly");
2924 json_object_boolean_true_add(json
, "rfc2328Conform");
2925 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2926 json_object_boolean_true_add(json
,
2927 "rfc1583Compatibility");
2930 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
2931 vty_out(vty
, " This implementation conforms to RFC2328\n");
2932 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
2933 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
2939 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
2940 json_object_boolean_true_add(json
, "opaqueCapable");
2943 vty_out(vty
, " OpaqueCapability flag is %s\n",
2944 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
2949 /* Show stub-router configuration */
2950 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
2951 || ospf
->stub_router_shutdown_time
2952 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
2954 json_object_boolean_true_add(json
, "stubAdvertisement");
2955 if (ospf
->stub_router_startup_time
2956 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2957 json_object_int_add(
2958 json
, "postStartEnabledMsecs",
2959 ospf
->stub_router_startup_time
/ 1000);
2960 if (ospf
->stub_router_shutdown_time
2961 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2962 json_object_int_add(
2963 json
, "preShutdownEnabledMsecs",
2964 ospf
->stub_router_shutdown_time
/ 1000);
2967 " Stub router advertisement is configured\n");
2968 if (ospf
->stub_router_startup_time
2969 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2971 " Enabled for %us after start-up\n",
2972 ospf
->stub_router_startup_time
);
2973 if (ospf
->stub_router_shutdown_time
2974 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2976 " Enabled for %us prior to full shutdown\n",
2977 ospf
->stub_router_shutdown_time
);
2981 /* Show SPF timers. */
2983 json_object_int_add(json
, "spfScheduleDelayMsecs",
2985 json_object_int_add(json
, "holdtimeMinMsecs",
2986 ospf
->spf_holdtime
);
2987 json_object_int_add(json
, "holdtimeMaxMsecs",
2988 ospf
->spf_max_holdtime
);
2989 json_object_int_add(json
, "holdtimeMultplier",
2990 ospf
->spf_hold_multiplier
);
2993 " Initial SPF scheduling delay %d millisec(s)\n"
2994 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
2995 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
2996 " Hold time multiplier is currently %d\n",
2997 ospf
->spf_delay
, ospf
->spf_holdtime
,
2998 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3002 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3003 long time_store
= 0;
3006 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3007 json_object_int_add(json
, "spfLastExecutedMsecs",
3010 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3011 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3012 json_object_int_add(json
, "spfLastDurationMsecs",
3015 json_object_boolean_true_add(json
, "spfHasNotRun");
3017 vty_out(vty
, " SPF algorithm ");
3018 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3019 monotime_since(&ospf
->ts_spf
, &result
);
3020 vty_out(vty
, "last executed %s ago\n",
3021 ospf_timeval_dump(&result
, timebuf
,
3023 vty_out(vty
, " Last SPF duration %s\n",
3024 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3025 timebuf
, sizeof(timebuf
)));
3027 vty_out(vty
, "has not been run\n");
3031 if (ospf
->t_spf_calc
) {
3034 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3036 json_object_int_add(json
, "spfTimerDueInMsecs",
3040 json_object_int_add(json
, "lsaMinIntervalMsecs",
3041 ospf
->min_ls_interval
);
3042 json_object_int_add(json
, "lsaMinArrivalMsecs",
3043 ospf
->min_ls_arrival
);
3044 /* Show write multiplier values */
3045 json_object_int_add(json
, "writeMultiplier",
3046 ospf
->write_oi_count
);
3047 /* Show refresh parameters. */
3048 json_object_int_add(json
, "refreshTimerMsecs",
3049 ospf
->lsa_refresh_interval
* 1000);
3051 vty_out(vty
, " SPF timer %s%s\n",
3052 (ospf
->t_spf_calc
? "due in " : "is "),
3053 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3056 vty_out(vty
, " LSA minimum interval %d msecs\n",
3057 ospf
->min_ls_interval
);
3058 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3059 ospf
->min_ls_arrival
);
3061 /* Show write multiplier values */
3062 vty_out(vty
, " Write Multiplier set to %d \n",
3063 ospf
->write_oi_count
);
3065 /* Show refresh parameters. */
3066 vty_out(vty
, " Refresh timer %d secs\n",
3067 ospf
->lsa_refresh_interval
);
3070 /* Show ABR/ASBR flags. */
3071 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3073 json_object_string_add(
3075 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3078 " This router is an ABR, ABR type is: %s\n",
3079 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3081 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3083 json_object_string_add(
3085 "injectingExternalRoutingInformation");
3088 " This router is an ASBR "
3089 "(injecting external routing information)\n");
3092 /* Show Number of AS-external-LSAs. */
3094 json_object_int_add(
3095 json
, "lsaExternalCounter",
3096 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3097 json_object_int_add(
3098 json
, "lsaExternalChecksum",
3099 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3102 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3103 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3104 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3108 json_object_int_add(
3109 json
, "lsaAsopaqueCounter",
3110 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3111 json_object_int_add(
3112 json
, "lsaAsOpaqueChecksum",
3113 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3116 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3117 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3118 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3121 /* Show number of areas attached. */
3123 json_object_int_add(json
, "attachedAreaCounter",
3124 listcount(ospf
->areas
));
3126 vty_out(vty
, " Number of areas attached to this router: %d\n",
3127 listcount(ospf
->areas
));
3129 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3130 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3132 json_object_boolean_true_add(
3133 json
, "adjacencyChangesLoggedAll");
3136 " All adjacency changes are logged\n");
3139 json_object_boolean_true_add(
3140 json
, "adjacencyChangesLogged");
3142 vty_out(vty
, " Adjacency changes are logged\n");
3145 /* Show each area status. */
3146 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3147 show_ip_ospf_area(vty
, area
, json_areas
, use_json
);
3150 json_object_object_add(json
, "areas", json_areas
);
3151 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3152 json
, JSON_C_TO_STRING_PRETTY
));
3153 json_object_free(json
);
3160 DEFUN (show_ip_ospf
,
3162 "show ip ospf [json]",
3165 "OSPF information\n"
3169 u_char uj
= use_json(argc
, argv
);
3171 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3174 return (show_ip_ospf_common(vty
, ospf
, uj
));
3177 DEFUN (show_ip_ospf_instance
,
3178 show_ip_ospf_instance_cmd
,
3179 "show ip ospf (1-65535) [json]",
3182 "OSPF information\n"
3188 u_short instance
= 0;
3189 u_char uj
= use_json(argc
, argv
);
3191 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3192 ospf
= ospf_lookup_instance(instance
);
3194 return CMD_NOT_MY_INSTANCE
;
3196 if (!ospf
->oi_running
)
3199 return (show_ip_ospf_common(vty
, ospf
, uj
));
3202 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3203 struct interface
*ifp
,
3204 json_object
*json_interface_sub
,
3208 struct ospf_neighbor
*nbr
;
3209 struct route_node
*rn
;
3210 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3212 /* Is interface up? */
3214 is_up
= if_is_operative(ifp
);
3216 json_object_boolean_true_add(json_interface_sub
,
3219 json_object_boolean_false_add(json_interface_sub
,
3222 json_object_int_add(json_interface_sub
, "ifIndex",
3224 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3225 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3227 json_object_string_add(json_interface_sub
, "ifFlags",
3228 if_flag_dump(ifp
->flags
));
3230 vty_out(vty
, "%s is %s\n", ifp
->name
,
3231 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3232 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3233 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3234 if_flag_dump(ifp
->flags
));
3237 /* Is interface OSPF enabled? */
3239 if (ospf_oi_count(ifp
) == 0) {
3240 json_object_boolean_false_add(json_interface_sub
,
3243 } else if (!is_up
) {
3244 json_object_boolean_false_add(json_interface_sub
,
3248 json_object_boolean_true_add(json_interface_sub
,
3251 if (ospf_oi_count(ifp
) == 0) {
3252 vty_out(vty
, " OSPF not enabled on this interface\n");
3254 } else if (!is_up
) {
3256 " OSPF is enabled, but not running on this interface\n");
3261 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3262 struct ospf_interface
*oi
= rn
->info
;
3267 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3269 json_object_boolean_true_add(json_interface_sub
,
3272 vty_out(vty
, " This interface is UNNUMBERED,");
3274 /* Show OSPF interface information. */
3276 json_object_string_add(
3277 json_interface_sub
, "ipAddress",
3278 inet_ntoa(oi
->address
->u
.prefix4
));
3279 json_object_int_add(json_interface_sub
,
3280 "ipAddressPrefixlen",
3281 oi
->address
->prefixlen
);
3283 vty_out(vty
, " Internet Address %s/%d,",
3284 inet_ntoa(oi
->address
->u
.prefix4
),
3285 oi
->address
->prefixlen
);
3287 if (oi
->connected
->destination
3288 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3289 struct in_addr
*dest
;
3292 if (CONNECTED_PEER(oi
->connected
)
3293 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3298 /* For Vlinks, showing the peer address is
3300 * * * * * informative than the local
3301 * interface that is being used
3303 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3304 dest
= &oi
->vl_data
->peer_addr
;
3306 dest
= &oi
->connected
->destination
->u
3310 json_object_string_add(
3312 "ospfIfType", dstr
);
3313 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3314 json_object_string_add(
3319 json_object_string_add(
3324 vty_out(vty
, " %s %s,", dstr
,
3329 json_object_string_add(json_interface_sub
, "area",
3330 ospf_area_desc_string(oi
->area
));
3331 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3332 json_object_boolean_true_add(
3334 "mtuMismatchDetect");
3335 json_object_string_add(json_interface_sub
, "routerId",
3336 inet_ntoa(ospf
->router_id
));
3337 json_object_string_add(json_interface_sub
,
3339 ospf_network_type_str
[oi
->type
]);
3340 json_object_int_add(json_interface_sub
, "cost",
3342 json_object_int_add(
3343 json_interface_sub
, "transmitDelayMsecs",
3344 1000 / OSPF_IF_PARAM(oi
, transmit_delay
));
3345 json_object_string_add(json_interface_sub
, "state",
3346 lookup_msg(ospf_ism_state_msg
,
3348 json_object_int_add(json_interface_sub
, "priority",
3351 vty_out(vty
, " Area %s\n",
3352 ospf_area_desc_string(oi
->area
));
3354 vty_out(vty
, " MTU mismatch detection: %s\n",
3355 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3359 " Router ID %s, Network Type %s, Cost: %d\n",
3360 inet_ntoa(ospf
->router_id
),
3361 ospf_network_type_str
[oi
->type
],
3365 " Transmit Delay is %d sec, State %s, Priority %d\n",
3366 OSPF_IF_PARAM(oi
, transmit_delay
),
3367 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3371 /* Show DR information. */
3372 if (DR(oi
).s_addr
== 0) {
3375 " No backup designated router on this network\n");
3377 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3381 " No backup designated router on this network\n");
3384 json_object_string_add(
3385 json_interface_sub
, "bdrId",
3386 inet_ntoa(nbr
->router_id
));
3387 json_object_string_add(
3390 inet_ntoa(nbr
->address
.u
3394 " Backup Designated Router (ID) %s,",
3395 inet_ntoa(nbr
->router_id
));
3396 vty_out(vty
, " Interface Address %s\n",
3397 inet_ntoa(nbr
->address
.u
3403 /* Next network-LSA sequence number we'll use, if we're elected
3406 && ntohl(oi
->params
->network_lsa_seqnum
)
3407 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3409 json_object_int_add(
3411 "networkLsaSequence",
3412 ntohl(oi
->params
->network_lsa_seqnum
));
3415 " Saved Network-LSA sequence number 0x%x\n",
3416 ntohl(oi
->params
->network_lsa_seqnum
));
3420 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3421 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3422 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3423 json_object_boolean_true_add(
3425 "mcastMemberOspfAllRouters");
3426 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3427 json_object_boolean_true_add(
3429 "mcastMemberOspfDesignatedRouters");
3432 vty_out(vty
, " Multicast group memberships:");
3433 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3434 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3435 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3436 vty_out(vty
, " OSPFAllRouters");
3437 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3438 vty_out(vty
, " OSPFDesignatedRouters");
3440 vty_out(vty
, " <None>");
3445 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3446 json_object_int_add(
3447 json_interface_sub
, "timerMsecs",
3448 1000 / OSPF_IF_PARAM(oi
, v_hello
));
3450 json_object_int_add(
3451 json_interface_sub
, "timerMsecs",
3452 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3453 json_object_int_add(json_interface_sub
,
3455 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3456 json_object_int_add(json_interface_sub
,
3458 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3459 json_object_int_add(
3460 json_interface_sub
, "timerRetransmit",
3461 1000 / OSPF_IF_PARAM(oi
, retransmit_interval
));
3463 vty_out(vty
, " Timer intervals configured,");
3464 vty_out(vty
, " Hello ");
3465 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3466 vty_out(vty
, "%ds,",
3467 OSPF_IF_PARAM(oi
, v_hello
));
3469 vty_out(vty
, "%dms,",
3470 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3471 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3472 OSPF_IF_PARAM(oi
, v_wait
),
3473 OSPF_IF_PARAM(oi
, v_wait
),
3474 OSPF_IF_PARAM(oi
, retransmit_interval
));
3477 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3478 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3480 long time_store
= 0;
3484 &oi
->t_hello
->u
.sands
,
3487 json_object_int_add(json_interface_sub
,
3488 "timerHelloInMsecs",
3491 vty_out(vty
, " Hello due in %s\n",
3492 ospf_timer_dump(oi
->t_hello
, timebuf
,
3494 } else /* passive-interface is set */
3497 json_object_boolean_true_add(
3499 "timerPassiveIface");
3502 " No Hellos (Passive interface)\n");
3506 json_object_int_add(json_interface_sub
, "nbrCount",
3507 ospf_nbr_count(oi
, 0));
3508 json_object_int_add(json_interface_sub
,
3510 ospf_nbr_count(oi
, NSM_Full
));
3513 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3514 ospf_nbr_count(oi
, 0),
3515 ospf_nbr_count(oi
, NSM_Full
));
3516 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3520 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3521 int argc
, struct cmd_token
**argv
,
3522 int iface_argv
, u_char use_json
)
3524 struct interface
*ifp
;
3525 struct listnode
*node
;
3526 json_object
*json
= NULL
;
3527 json_object
*json_interface_sub
= NULL
;
3530 json
= json_object_new_object();
3533 if (ospf
->instance
) {
3535 json_object_int_add(json
, "ospfInstance",
3538 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3541 if (argc
== iface_argv
) {
3542 /* Show All Interfaces.*/
3543 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
)) {
3544 if (ospf_oi_count(ifp
)) {
3546 json_interface_sub
=
3547 json_object_new_object();
3549 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3554 json_object_object_add(
3556 json_interface_sub
);
3560 /* Interface name is specified. */
3561 if ((ifp
= if_lookup_by_name(argv
[iface_argv
]->arg
,
3565 json_object_boolean_true_add(json
,
3568 vty_out(vty
, "No such interface name\n");
3571 json_interface_sub
= json_object_new_object();
3573 show_ip_ospf_interface_sub(
3574 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3577 json_object_object_add(json
, ifp
->name
,
3578 json_interface_sub
);
3583 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3584 json
, JSON_C_TO_STRING_PRETTY
));
3585 json_object_free(json
);
3592 DEFUN (show_ip_ospf_interface
,
3593 show_ip_ospf_interface_cmd
,
3594 "show ip ospf interface [INTERFACE] [json]",
3597 "OSPF information\n"
3598 "Interface information\n"
3603 u_char uj
= use_json(argc
, argv
);
3605 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3611 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3614 DEFUN (show_ip_ospf_instance_interface
,
3615 show_ip_ospf_instance_interface_cmd
,
3616 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3619 "OSPF information\n"
3621 "Interface information\n"
3627 u_short instance
= 0;
3628 u_char uj
= use_json(argc
, argv
);
3630 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3631 ospf
= ospf_lookup_instance(instance
);
3633 return CMD_NOT_MY_INSTANCE
;
3635 if (!ospf
->oi_running
)
3641 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3644 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
3646 vty_out(vty
, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n",
3647 "Neighbor ID", "Pri", "State", "Dead Time", "Address",
3648 "Interface", "RXmtL", "RqstL", "DBsmL");
3651 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
3652 struct ospf_interface
*oi
,
3653 json_object
*json
, u_char use_json
)
3655 struct route_node
*rn
;
3656 struct ospf_neighbor
*nbr
;
3658 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3659 json_object
*json_neighbor
= NULL
;
3661 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
3662 if ((nbr
= rn
->info
)) {
3663 /* Do not show myself. */
3664 if (nbr
!= oi
->nbr_self
) {
3665 /* Down state is not shown. */
3666 if (nbr
->state
!= NSM_Down
) {
3669 json_object_new_object();
3670 ospf_nbr_state_message(
3683 json_object_int_add(
3687 json_object_string_add(
3688 json_neighbor
, "state",
3690 json_object_int_add(
3694 json_object_string_add(
3697 inet_ntoa(nbr
->src
));
3698 json_object_string_add(
3702 json_object_int_add(
3704 "retransmitCounter",
3705 ospf_ls_retransmit_count(
3707 json_object_int_add(
3710 ospf_ls_request_count(
3712 json_object_int_add(
3715 ospf_db_summary_count(
3717 if (nbr
->state
== NSM_Attempt
3718 && nbr
->router_id
.s_addr
3720 json_object_object_add(
3725 json_object_object_add(
3731 ospf_nbr_state_message(
3734 if (nbr
->state
== NSM_Attempt
3735 && nbr
->router_id
.s_addr
3750 vty_out(vty
, "%9s ",
3755 vty_out(vty
, "%-15s ",
3756 inet_ntoa(nbr
->src
));
3758 "%-20s %5ld %5ld %5d\n",
3760 ospf_ls_retransmit_count(
3762 ospf_ls_request_count(
3764 ospf_db_summary_count(
3773 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
3776 struct ospf_interface
*oi
;
3777 struct listnode
*node
;
3778 json_object
*json
= NULL
;
3781 json
= json_object_new_object();
3783 show_ip_ospf_neighbour_header(vty
);
3785 if (ospf
->instance
) {
3787 json_object_int_add(json
, "ospfInstance",
3790 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3793 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
3794 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3797 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3798 json
, JSON_C_TO_STRING_PRETTY
));
3799 json_object_free(json
);
3806 DEFUN (show_ip_ospf_neighbor
,
3807 show_ip_ospf_neighbor_cmd
,
3808 "show ip ospf neighbor [json]",
3811 "OSPF information\n"
3816 u_char uj
= use_json(argc
, argv
);
3818 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3821 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3825 DEFUN (show_ip_ospf_instance_neighbor
,
3826 show_ip_ospf_instance_neighbor_cmd
,
3827 "show ip ospf (1-65535) neighbor [json]",
3830 "OSPF information\n"
3837 u_short instance
= 0;
3838 u_char uj
= use_json(argc
, argv
);
3840 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3841 ospf
= ospf_lookup_instance(instance
);
3843 return CMD_NOT_MY_INSTANCE
;
3845 if (!ospf
->oi_running
)
3848 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3851 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
3854 struct listnode
*node
;
3855 struct ospf_interface
*oi
;
3856 json_object
*json
= NULL
;
3857 json_object
*json_neighbor_sub
= NULL
;
3860 json
= json_object_new_object();
3861 json_neighbor_sub
= json_object_new_object();
3863 show_ip_ospf_neighbour_header(vty
);
3865 if (ospf
->instance
) {
3867 json_object_int_add(json
, "ospfInstance",
3870 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3873 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
3874 struct listnode
*nbr_node
;
3875 struct ospf_nbr_nbma
*nbr_nbma
;
3877 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3879 /* print Down neighbor status */
3880 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
3881 if (nbr_nbma
->nbr
== NULL
3882 || nbr_nbma
->nbr
->state
== NSM_Down
) {
3884 json_object_int_add(json_neighbor_sub
,
3886 nbr_nbma
->priority
);
3887 json_object_boolean_true_add(
3890 json_object_string_add(
3894 json_object_int_add(
3896 "nbrNbmaRetransmitCounter", 0);
3897 json_object_int_add(
3899 "nbrNbmaRequestCounter", 0);
3900 json_object_int_add(
3902 "nbrNbmaDbSummaryCounter", 0);
3903 json_object_object_add(
3904 json
, inet_ntoa(nbr_nbma
->addr
),
3907 vty_out(vty
, "%-15s %3d %-15s %9s ",
3908 "-", nbr_nbma
->priority
, "Down",
3911 "%-15s %-20s %5d %5d %5d\n",
3912 inet_ntoa(nbr_nbma
->addr
),
3913 IF_NAME(oi
), 0, 0, 0);
3920 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3921 json
, JSON_C_TO_STRING_PRETTY
));
3922 json_object_free(json
);
3929 DEFUN (show_ip_ospf_neighbor_all
,
3930 show_ip_ospf_neighbor_all_cmd
,
3931 "show ip ospf neighbor all [json]",
3934 "OSPF information\n"
3936 "include down status neighbor\n"
3940 u_char uj
= use_json(argc
, argv
);
3942 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3945 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3948 DEFUN (show_ip_ospf_instance_neighbor_all
,
3949 show_ip_ospf_instance_neighbor_all_cmd
,
3950 "show ip ospf (1-65535) neighbor all [json]",
3953 "OSPF information\n"
3956 "include down status neighbor\n"
3961 u_short instance
= 0;
3962 u_char uj
= use_json(argc
, argv
);
3964 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3965 ospf
= ospf_lookup_instance(instance
);
3967 return CMD_NOT_MY_INSTANCE
;
3969 if (!ospf
->oi_running
)
3972 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3975 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
3977 struct cmd_token
**argv
,
3980 struct interface
*ifp
;
3981 struct route_node
*rn
;
3982 json_object
*json
= NULL
;
3985 json
= json_object_new_object();
3987 show_ip_ospf_neighbour_header(vty
);
3989 if (ospf
->instance
) {
3991 json_object_int_add(json
, "ospfInstance",
3994 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3997 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
4000 json_object_boolean_true_add(json
, "noSuchIface");
4002 vty_out(vty
, "No such interface.\n");
4006 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4007 struct ospf_interface
*oi
= rn
->info
;
4012 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4016 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4017 json
, JSON_C_TO_STRING_PRETTY
));
4018 json_object_free(json
);
4025 DEFUN (show_ip_ospf_neighbor_int
,
4026 show_ip_ospf_neighbor_int_cmd
,
4027 "show ip ospf neighbor IFNAME [json]",
4030 "OSPF information\n"
4037 u_char uj
= use_json(argc
, argv
);
4039 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4042 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
, argv
, uj
);
4045 DEFUN (show_ip_ospf_instance_neighbor_int
,
4046 show_ip_ospf_instance_neighbor_int_cmd
,
4047 "show ip ospf (1-65535) neighbor IFNAME [json]",
4050 "OSPF information\n"
4059 u_short instance
= 0;
4060 u_char uj
= use_json(argc
, argv
);
4062 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4063 ospf
= ospf_lookup_instance(instance
);
4065 return CMD_NOT_MY_INSTANCE
;
4067 if (!ospf
->oi_running
)
4070 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
, argv
, uj
);
4073 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4074 struct ospf_interface
*oi
,
4075 struct ospf_nbr_nbma
*nbr_nbma
,
4076 u_char use_json
, json_object
*json
)
4078 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4079 json_object
*json_sub
= NULL
;
4082 json_sub
= json_object_new_object();
4083 else /* Show neighbor ID. */
4084 vty_out(vty
, " Neighbor %s,", "-");
4086 /* Show interface address. */
4088 json_object_string_add(json_sub
, "ifaceAddress",
4089 inet_ntoa(nbr_nbma
->addr
));
4091 vty_out(vty
, " interface address %s\n",
4092 inet_ntoa(nbr_nbma
->addr
));
4096 json_object_string_add(json_sub
, "areaId",
4097 ospf_area_desc_string(oi
->area
));
4098 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
4100 vty_out(vty
, " In the area %s via interface %s\n",
4101 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
4103 /* Show neighbor priority and state. */
4105 json_object_int_add(json_sub
, "nbrPriority",
4106 nbr_nbma
->priority
);
4107 json_object_string_add(json_sub
, "nbrState", "down");
4109 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4110 nbr_nbma
->priority
, "Down");
4112 /* Show state changes. */
4114 json_object_int_add(json_sub
, "stateChangeCounter",
4115 nbr_nbma
->state_change
);
4117 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
4119 /* Show PollInterval */
4121 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4123 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
4125 /* Show poll-interval timer. */
4128 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
)
4130 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec",
4133 vty_out(vty
, " Poll timer due in %s\n",
4134 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
4137 /* Show poll-interval timer thread. */
4139 if (nbr_nbma
->t_poll
!= NULL
)
4140 json_object_string_add(json_sub
,
4141 "pollIntervalTimerThread", "on");
4143 vty_out(vty
, " Thread Poll Timer %s\n",
4144 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
4147 json_object_object_add(json
, "noNbrId", json_sub
);
4150 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
4151 struct ospf_interface
*oi
,
4152 struct ospf_neighbor
*nbr
,
4153 u_char use_json
, json_object
*json
)
4155 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4156 json_object
*json_sub
= NULL
;
4159 json_sub
= json_object_new_object();
4161 /* Show neighbor ID. */
4162 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4163 vty_out(vty
, " Neighbor %s,", "-");
4165 vty_out(vty
, " Neighbor %s,",
4166 inet_ntoa(nbr
->router_id
));
4169 /* Show interface address. */
4171 json_object_string_add(json_sub
, "ifaceAddress",
4172 inet_ntoa(nbr
->address
.u
.prefix4
));
4174 vty_out(vty
, " interface address %s\n",
4175 inet_ntoa(nbr
->address
.u
.prefix4
));
4179 json_object_string_add(json_sub
, "areaId",
4180 ospf_area_desc_string(oi
->area
));
4181 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4183 vty_out(vty
, " In the area %s via interface %s\n",
4184 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
4186 /* Show neighbor priority and state. */
4188 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4189 json_object_string_add(
4190 json_sub
, "nbrState",
4191 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4193 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4195 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4197 /* Show state changes. */
4199 json_object_int_add(json_sub
, "stateChangeCounter",
4202 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
4204 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
4209 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4211 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec",
4215 " Most recent state change statistics:\n");
4216 vty_out(vty
, " Progressive change %s ago\n",
4217 ospf_timeval_dump(&res
, timebuf
,
4222 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
4227 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4229 json_object_int_add(json_sub
,
4230 "lastRegressiveChangeMsec",
4232 if (nbr
->last_regress_str
)
4233 json_object_string_add(
4234 json_sub
, "lastRegressiveChangeReason",
4235 nbr
->last_regress_str
);
4238 " Regressive change %s ago, due to %s\n",
4239 ospf_timeval_dump(&res
, timebuf
,
4241 (nbr
->last_regress_str
? nbr
->last_regress_str
4246 /* Show Designated Rotuer ID. */
4248 json_object_string_add(json_sub
, "routerDesignatedId",
4249 inet_ntoa(nbr
->d_router
));
4251 vty_out(vty
, " DR is %s,", inet_ntoa(nbr
->d_router
));
4253 /* Show Backup Designated Rotuer ID. */
4255 json_object_string_add(json_sub
, "routerDesignatedBackupId",
4256 inet_ntoa(nbr
->bd_router
));
4258 vty_out(vty
, " BDR is %s\n", inet_ntoa(nbr
->bd_router
));
4262 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4263 json_object_string_add(json_sub
, "optionsList",
4264 ospf_options_dump(nbr
->options
));
4266 vty_out(vty
, " Options %d %s\n", nbr
->options
,
4267 ospf_options_dump(nbr
->options
));
4269 /* Show Router Dead interval timer. */
4271 if (nbr
->t_inactivity
) {
4273 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
4276 json_object_int_add(json_sub
,
4277 "routerDeadIntervalTimerDueMsec",
4280 json_object_int_add(
4281 json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4283 vty_out(vty
, " Dead timer due in %s\n",
4284 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
4287 /* Show Database Summary list. */
4289 json_object_int_add(json_sub
, "databaseSummaryListCounter",
4290 ospf_db_summary_count(nbr
));
4292 vty_out(vty
, " Database Summary List %d\n",
4293 ospf_db_summary_count(nbr
));
4295 /* Show Link State Request list. */
4297 json_object_int_add(json_sub
, "linkStateRequestListCounter",
4298 ospf_ls_request_count(nbr
));
4300 vty_out(vty
, " Link State Request List %ld\n",
4301 ospf_ls_request_count(nbr
));
4303 /* Show Link State Retransmission list. */
4305 json_object_int_add(json_sub
,
4306 "linkStateRetransmissionListCounter",
4307 ospf_ls_retransmit_count(nbr
));
4309 vty_out(vty
, " Link State Retransmission List %ld\n",
4310 ospf_ls_retransmit_count(nbr
));
4312 /* Show inactivity timer thread. */
4314 if (nbr
->t_inactivity
!= NULL
)
4315 json_object_string_add(json_sub
,
4316 "threadInactivityTimer", "on");
4318 vty_out(vty
, " Thread Inactivity Timer %s\n",
4319 nbr
->t_inactivity
!= NULL
? "on" : "off");
4321 /* Show Database Description retransmission thread. */
4323 if (nbr
->t_db_desc
!= NULL
)
4324 json_object_string_add(
4326 "threadDatabaseDescriptionRetransmission",
4330 " Thread Database Description Retransmision %s\n",
4331 nbr
->t_db_desc
!= NULL
? "on" : "off");
4333 /* Show Link State Request Retransmission thread. */
4335 if (nbr
->t_ls_req
!= NULL
)
4336 json_object_string_add(
4338 "threadLinkStateRequestRetransmission", "on");
4341 " Thread Link State Request Retransmission %s\n",
4342 nbr
->t_ls_req
!= NULL
? "on" : "off");
4344 /* Show Link State Update Retransmission thread. */
4346 if (nbr
->t_ls_upd
!= NULL
)
4347 json_object_string_add(
4348 json_sub
, "threadLinkStateUpdateRetransmission",
4352 " Thread Link State Update Retransmission %s\n\n",
4353 nbr
->t_ls_upd
!= NULL
? "on" : "off");
4356 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4357 json_object_object_add(json
, "noNbrId", json_sub
);
4359 json_object_object_add(json
, inet_ntoa(nbr
->router_id
),
4363 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4366 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
4368 struct cmd_token
**argv
,
4371 struct listnode
*node
;
4372 struct ospf_neighbor
*nbr
;
4373 struct ospf_interface
*oi
;
4374 struct in_addr router_id
;
4376 json_object
*json
= NULL
;
4379 json
= json_object_new_object();
4381 if (ospf
->instance
) {
4383 json_object_int_add(json
, "ospfInstance",
4386 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4389 ret
= inet_aton(argv
[arg_base
]->arg
, &router_id
);
4392 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
4394 vty_out(vty
, "{}\n");
4395 json_object_free(json
);
4400 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4401 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, &router_id
))) {
4402 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, use_json
,
4408 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4409 json
, JSON_C_TO_STRING_PRETTY
));
4410 json_object_free(json
);
4417 DEFUN (show_ip_ospf_neighbor_id
,
4418 show_ip_ospf_neighbor_id_cmd
,
4419 "show ip ospf neighbor A.B.C.D [json]",
4422 "OSPF information\n"
4428 int idx_router_id
= 4;
4429 u_char uj
= use_json(argc
, argv
);
4431 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4434 return show_ip_ospf_neighbor_id_common(vty
, ospf
, idx_router_id
, argv
, uj
);
4437 DEFUN (show_ip_ospf_instance_neighbor_id
,
4438 show_ip_ospf_instance_neighbor_id_cmd
,
4439 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4442 "OSPF information\n"
4449 int idx_router_id
= 5;
4451 u_short instance
= 0;
4452 u_char uj
= use_json(argc
, argv
);
4454 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4455 ospf
= ospf_lookup_instance(instance
);
4457 return CMD_NOT_MY_INSTANCE
;
4459 if (!ospf
->oi_running
)
4462 return show_ip_ospf_neighbor_id_common(vty
, ospf
, idx_router_id
, argv
, uj
);
4465 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
4469 struct ospf_interface
*oi
;
4470 struct listnode
*node
;
4471 json_object
*json
= NULL
;
4474 json
= json_object_new_object();
4476 if (ospf
->instance
) {
4478 json_object_int_add(json
, "ospfInstance",
4481 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4484 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4485 struct route_node
*rn
;
4486 struct ospf_neighbor
*nbr
;
4488 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4489 if ((nbr
= rn
->info
)) {
4490 if (nbr
!= oi
->nbr_self
) {
4491 if (nbr
->state
!= NSM_Down
) {
4492 show_ip_ospf_neighbor_detail_sub(
4493 vty
, oi
, nbr
, use_json
,
4502 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4503 json
, JSON_C_TO_STRING_PRETTY
));
4504 json_object_free(json
);
4511 DEFUN (show_ip_ospf_neighbor_detail
,
4512 show_ip_ospf_neighbor_detail_cmd
,
4513 "show ip ospf neighbor detail [json]",
4516 "OSPF information\n"
4518 "detail of all neighbors\n"
4522 u_char uj
= use_json(argc
, argv
);
4524 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4527 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4530 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4531 show_ip_ospf_instance_neighbor_detail_cmd
,
4532 "show ip ospf (1-65535) neighbor detail [json]",
4535 "OSPF information\n"
4538 "detail of all neighbors\n"
4543 u_short instance
= 0;
4544 u_char uj
= use_json(argc
, argv
);
4546 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4547 ospf
= ospf_lookup_instance(instance
);
4549 return CMD_NOT_MY_INSTANCE
;
4551 if (!ospf
->oi_running
)
4554 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4557 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
4561 struct listnode
*node
;
4562 struct ospf_interface
*oi
;
4563 json_object
*json
= NULL
;
4566 json
= json_object_new_object();
4568 if (ospf
->instance
) {
4570 json_object_int_add(json
, "ospfInstance",
4573 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4576 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4577 struct route_node
*rn
;
4578 struct ospf_neighbor
*nbr
;
4579 struct ospf_nbr_nbma
*nbr_nbma
;
4581 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
4582 if ((nbr
= rn
->info
))
4583 if (nbr
!= oi
->nbr_self
)
4584 if (nbr
->state
!= NSM_Down
)
4585 show_ip_ospf_neighbor_detail_sub(
4589 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
4590 struct listnode
*nd
;
4592 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
4593 if (nbr_nbma
->nbr
== NULL
4594 || nbr_nbma
->nbr
->state
== NSM_Down
)
4595 show_ip_ospf_nbr_nbma_detail_sub(
4596 vty
, oi
, nbr_nbma
, use_json
,
4603 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4604 json
, JSON_C_TO_STRING_PRETTY
));
4605 json_object_free(json
);
4613 DEFUN (show_ip_ospf_neighbor_detail_all
,
4614 show_ip_ospf_neighbor_detail_all_cmd
,
4615 "show ip ospf neighbor detail all [json]",
4618 "OSPF information\n"
4620 "detail of all neighbors\n"
4621 "include down status neighbor\n"
4625 u_char uj
= use_json(argc
, argv
);
4627 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4630 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4633 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4634 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4635 "show ip ospf (1-65535) neighbor detail all [json]",
4638 "OSPF information\n"
4641 "detail of all neighbors\n"
4642 "include down status neighbor\n"
4647 u_short instance
= 0;
4648 u_char uj
= use_json(argc
, argv
);
4650 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4651 ospf
= ospf_lookup_instance(instance
);
4653 return CMD_NOT_MY_INSTANCE
;
4655 if (!ospf
->oi_running
)
4658 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4661 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
4664 struct cmd_token
**argv
,
4667 struct ospf_interface
*oi
;
4668 struct interface
*ifp
;
4669 struct route_node
*rn
, *nrn
;
4670 struct ospf_neighbor
*nbr
;
4671 json_object
*json
= NULL
;
4674 json
= json_object_new_object();
4676 if (ospf
->instance
) {
4678 json_object_int_add(json
, "ospfInstance",
4681 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4684 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
4687 vty_out(vty
, "No such interface.\n");
4689 vty_out(vty
, "{}\n");
4690 json_object_free(json
);
4695 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4696 if ((oi
= rn
->info
)) {
4697 for (nrn
= route_top(oi
->nbrs
); nrn
;
4698 nrn
= route_next(nrn
)) {
4699 if ((nbr
= nrn
->info
)) {
4700 if (nbr
!= oi
->nbr_self
) {
4701 if (nbr
->state
!= NSM_Down
)
4702 show_ip_ospf_neighbor_detail_sub(
4712 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4713 json
, JSON_C_TO_STRING_PRETTY
));
4714 json_object_free(json
);
4721 DEFUN (show_ip_ospf_neighbor_int_detail
,
4722 show_ip_ospf_neighbor_int_detail_cmd
,
4723 "show ip ospf neighbor IFNAME detail [json]",
4726 "OSPF information\n"
4729 "detail of all neighbors\n"
4734 u_char uj
= use_json(argc
, argv
);
4736 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4739 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
, argv
, uj
);
4742 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4743 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4744 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4747 "OSPF information\n"
4751 "detail of all neighbors\n"
4757 u_short instance
= 0;
4758 u_char uj
= use_json(argc
, argv
);
4760 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4761 ospf
= ospf_lookup_instance(instance
);
4763 return CMD_NOT_MY_INSTANCE
;
4765 if (!ospf
->oi_running
)
4768 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
, argv
, uj
);
4771 /* Show functions */
4772 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4774 struct router_lsa
*rl
;
4775 struct summary_lsa
*sl
;
4776 struct as_external_lsa
*asel
;
4777 struct prefix_ipv4 p
;
4780 /* If self option is set, check LSA self flag. */
4781 if (self
== 0 || IS_LSA_SELF(lsa
)) {
4782 /* LSA common part show. */
4783 vty_out(vty
, "%-15s ", inet_ntoa(lsa
->data
->id
));
4784 vty_out(vty
, "%-15s %4d 0x%08lx 0x%04x",
4785 inet_ntoa(lsa
->data
->adv_router
), LS_AGE(lsa
),
4786 (u_long
)ntohl(lsa
->data
->ls_seqnum
),
4787 ntohs(lsa
->data
->checksum
));
4788 /* LSA specific part show. */
4789 switch (lsa
->data
->type
) {
4790 case OSPF_ROUTER_LSA
:
4791 rl
= (struct router_lsa
*)lsa
->data
;
4792 vty_out(vty
, " %-d", ntohs(rl
->links
));
4794 case OSPF_SUMMARY_LSA
:
4795 sl
= (struct summary_lsa
*)lsa
->data
;
4798 p
.prefix
= sl
->header
.id
;
4799 p
.prefixlen
= ip_masklen(sl
->mask
);
4800 apply_mask_ipv4(&p
);
4802 vty_out(vty
, " %s/%d", inet_ntoa(p
.prefix
),
4805 case OSPF_AS_EXTERNAL_LSA
:
4806 case OSPF_AS_NSSA_LSA
:
4807 asel
= (struct as_external_lsa
*)lsa
->data
;
4810 p
.prefix
= asel
->header
.id
;
4811 p
.prefixlen
= ip_masklen(asel
->mask
);
4812 apply_mask_ipv4(&p
);
4814 vty_out(vty
, " %s %s/%d [0x%lx]",
4815 IS_EXTERNAL_METRIC(asel
->e
[0].tos
)
4818 inet_ntoa(p
.prefix
), p
.prefixlen
,
4819 (u_long
)ntohl(asel
->e
[0].route_tag
));
4821 case OSPF_NETWORK_LSA
:
4822 case OSPF_ASBR_SUMMARY_LSA
:
4823 case OSPF_OPAQUE_LINK_LSA
:
4824 case OSPF_OPAQUE_AREA_LSA
:
4825 case OSPF_OPAQUE_AS_LSA
:
4835 static const char *show_database_desc
[] = {
4837 "Router Link States",
4839 "Summary Link States",
4840 "ASBR-Summary Link States",
4841 "AS External Link States",
4842 "Group Membership LSA",
4843 "NSSA-external Link States",
4845 "Link-Local Opaque-LSA",
4846 "Area-Local Opaque-LSA",
4847 "AS-external Opaque-LSA",
4850 static const char *show_database_header
[] = {
4852 "Link ID ADV Router Age Seq# CkSum Link count",
4853 "Link ID ADV Router Age Seq# CkSum",
4854 "Link ID ADV Router Age Seq# CkSum Route",
4855 "Link ID ADV Router Age Seq# CkSum",
4856 "Link ID ADV Router Age Seq# CkSum Route",
4857 " --- header for Group Member ----",
4858 "Link ID ADV Router Age Seq# CkSum Route",
4860 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4861 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4862 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4865 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
)
4867 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
4869 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
4870 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
4871 ospf_options_dump(lsa
->data
->options
));
4872 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
4873 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)"
4876 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
4877 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
4880 vty_out(vty
, " :%s%s%s%s",
4881 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR" : "",
4882 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR" : "",
4883 IS_ROUTER_LSA_VIRTUAL(rlsa
) ? " VL-endpoint"
4885 IS_ROUTER_LSA_SHORTCUT(rlsa
) ? " Shortcut"
4890 vty_out(vty
, " LS Type: %s\n",
4891 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
4892 vty_out(vty
, " Link State ID: %s %s\n", inet_ntoa(lsa
->data
->id
),
4893 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
));
4894 vty_out(vty
, " Advertising Router: %s\n",
4895 inet_ntoa(lsa
->data
->adv_router
));
4896 vty_out(vty
, " LS Seq Number: %08lx\n",
4897 (u_long
)ntohl(lsa
->data
->ls_seqnum
));
4898 vty_out(vty
, " Checksum: 0x%04x\n", ntohs(lsa
->data
->checksum
));
4899 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
4902 const char *link_type_desc
[] = {
4904 "another Router (point-to-point)",
4905 "a Transit Network",
4910 const char *link_id_desc
[] = {
4911 "(null)", "Neighboring Router ID", "Designated Router address",
4912 "Net", "Neighboring Router ID",
4915 const char *link_data_desc
[] = {
4916 "(null)", "Router Interface address", "Router Interface address",
4917 "Network Mask", "Router Interface address",
4920 /* Show router-LSA each Link information. */
4921 static void show_ip_ospf_database_router_links(struct vty
*vty
,
4922 struct router_lsa
*rl
)
4927 len
= ntohs(rl
->header
.length
) - 4;
4928 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
4929 type
= rl
->link
[i
].type
;
4931 vty_out(vty
, " Link connected to: %s\n",
4932 link_type_desc
[type
]);
4933 vty_out(vty
, " (Link ID) %s: %s\n", link_id_desc
[type
],
4934 inet_ntoa(rl
->link
[i
].link_id
));
4935 vty_out(vty
, " (Link Data) %s: %s\n", link_data_desc
[type
],
4936 inet_ntoa(rl
->link
[i
].link_data
));
4937 vty_out(vty
, " Number of TOS metrics: 0\n");
4938 vty_out(vty
, " TOS 0 Metric: %d\n",
4939 ntohs(rl
->link
[i
].metric
));
4944 /* Show router-LSA detail information. */
4945 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4948 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
4950 show_ip_ospf_database_header(vty
, lsa
);
4952 vty_out(vty
, " Number of Links: %d\n\n", ntohs(rl
->links
));
4954 show_ip_ospf_database_router_links(vty
, rl
);
4961 /* Show network-LSA detail information. */
4962 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4967 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
4969 show_ip_ospf_database_header(vty
, lsa
);
4971 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(nl
->mask
));
4973 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4975 for (i
= 0; length
> 0; i
++, length
-= 4)
4976 vty_out(vty
, " Attached Router: %s\n",
4977 inet_ntoa(nl
->routers
[i
]));
4985 /* Show summary-LSA detail information. */
4986 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4989 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
4991 show_ip_ospf_database_header(vty
, lsa
);
4993 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
4994 vty_out(vty
, " TOS: 0 Metric: %d\n",
4995 GET_METRIC(sl
->metric
));
5002 /* Show summary-ASBR-LSA detail information. */
5003 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5006 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5008 show_ip_ospf_database_header(vty
, lsa
);
5010 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5011 vty_out(vty
, " TOS: 0 Metric: %d\n",
5012 GET_METRIC(sl
->metric
));
5019 /* Show AS-external-LSA detail information. */
5020 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5023 struct as_external_lsa
*al
=
5024 (struct as_external_lsa
*)lsa
->data
;
5026 show_ip_ospf_database_header(vty
, lsa
);
5028 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5029 vty_out(vty
, " Metric Type: %s\n",
5030 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5031 ? "2 (Larger than any link state path)"
5033 vty_out(vty
, " TOS: 0\n");
5034 vty_out(vty
, " Metric: %d\n",
5035 GET_METRIC(al
->e
[0].metric
));
5036 vty_out(vty
, " Forward Address: %s\n",
5037 inet_ntoa(al
->e
[0].fwd_addr
));
5040 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5041 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5048 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5050 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5052 /* show_ip_ospf_database_header (vty, lsa); */
5054 zlog_debug( " Network Mask: /%d%s",
5055 ip_masklen (al
->mask
), "\n");
5056 zlog_debug( " Metric Type: %s%s",
5057 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5058 "2 (Larger than any link state path)" : "1", "\n");
5059 zlog_debug( " TOS: 0%s", "\n");
5060 zlog_debug( " Metric: %d%s",
5061 GET_METRIC (al
->e
[0].metric
), "\n");
5062 zlog_debug( " Forward Address: %s%s",
5063 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5065 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5066 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5071 /* Show AS-NSSA-LSA detail information. */
5072 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5075 struct as_external_lsa
*al
=
5076 (struct as_external_lsa
*)lsa
->data
;
5078 show_ip_ospf_database_header(vty
, lsa
);
5080 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5081 vty_out(vty
, " Metric Type: %s\n",
5082 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5083 ? "2 (Larger than any link state path)"
5085 vty_out(vty
, " TOS: 0\n");
5086 vty_out(vty
, " Metric: %d\n",
5087 GET_METRIC(al
->e
[0].metric
));
5088 vty_out(vty
, " NSSA: Forward Address: %s\n",
5089 inet_ntoa(al
->e
[0].fwd_addr
));
5092 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5093 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5099 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
)
5104 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5107 show_ip_ospf_database_header(vty
, lsa
);
5108 show_opaque_info_detail(vty
, lsa
);
5115 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) = {
5117 show_router_lsa_detail
,
5118 show_network_lsa_detail
,
5119 show_summary_lsa_detail
,
5120 show_summary_asbr_lsa_detail
,
5121 show_as_external_lsa_detail
,
5123 show_as_nssa_lsa_detail
, /* almost same as external */
5125 show_opaque_lsa_detail
,
5126 show_opaque_lsa_detail
,
5127 show_opaque_lsa_detail
,
5130 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
5131 struct in_addr
*id
, struct in_addr
*adv_router
)
5133 memset(lp
, 0, sizeof(struct prefix_ls
));
5137 else if (adv_router
== NULL
) {
5143 lp
->adv_router
= *adv_router
;
5147 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
5148 struct in_addr
*id
, struct in_addr
*adv_router
)
5150 struct prefix_ls lp
;
5151 struct route_node
*rn
, *start
;
5152 struct ospf_lsa
*lsa
;
5154 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
5155 start
= route_node_get(rt
, (struct prefix
*)&lp
);
5157 route_lock_node(start
);
5158 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
5159 if ((lsa
= rn
->info
)) {
5160 if (show_function
[lsa
->data
->type
] != NULL
)
5161 show_function
[lsa
->data
->type
](vty
,
5164 route_unlock_node(start
);
5168 /* Show detail LSA information
5169 -- if id is NULL then show all LSAs. */
5170 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
5171 struct in_addr
*id
, struct in_addr
*adv_router
)
5173 struct listnode
*node
;
5174 struct ospf_area
*area
;
5177 case OSPF_AS_EXTERNAL_LSA
:
5178 case OSPF_OPAQUE_AS_LSA
:
5179 vty_out(vty
, " %s \n\n",
5180 show_database_desc
[type
]);
5181 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
);
5184 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5185 vty_out(vty
, "\n %s (Area %s)\n\n",
5186 show_database_desc
[type
],
5187 ospf_area_desc_string(area
));
5188 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
5195 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
5196 struct route_table
*rt
,
5197 struct in_addr
*adv_router
)
5199 struct route_node
*rn
;
5200 struct ospf_lsa
*lsa
;
5202 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
5203 if ((lsa
= rn
->info
))
5204 if (IPV4_ADDR_SAME(adv_router
,
5205 &lsa
->data
->adv_router
)) {
5206 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5208 if (show_function
[lsa
->data
->type
] != NULL
)
5209 show_function
[lsa
->data
->type
](vty
,
5214 /* Show detail LSA information. */
5215 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
5216 int type
, struct in_addr
*adv_router
)
5218 struct listnode
*node
;
5219 struct ospf_area
*area
;
5222 case OSPF_AS_EXTERNAL_LSA
:
5223 case OSPF_OPAQUE_AS_LSA
:
5224 vty_out(vty
, " %s \n\n",
5225 show_database_desc
[type
]);
5226 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
5230 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5231 vty_out(vty
, "\n %s (Area %s)\n\n",
5232 show_database_desc
[type
],
5233 ospf_area_desc_string(area
));
5234 show_lsa_detail_adv_router_proc(
5235 vty
, AREA_LSDB(area
, type
), adv_router
);
5241 static void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
,
5244 struct ospf_lsa
*lsa
;
5245 struct route_node
*rn
;
5246 struct ospf_area
*area
;
5247 struct listnode
*node
;
5250 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5251 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5253 case OSPF_AS_EXTERNAL_LSA
:
5254 case OSPF_OPAQUE_AS_LSA
:
5259 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
5261 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
5262 vty_out(vty
, " %s (Area %s)\n\n",
5263 show_database_desc
[type
],
5264 ospf_area_desc_string(area
));
5265 vty_out(vty
, "%s\n",
5266 show_database_header
[type
]);
5268 LSDB_LOOP(AREA_LSDB(area
, type
), rn
, lsa
)
5269 show_lsa_summary(vty
, lsa
, self
);
5276 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5278 case OSPF_AS_EXTERNAL_LSA
:
5279 case OSPF_OPAQUE_AS_LSA
:
5284 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
5285 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
5286 vty_out(vty
, " %s\n\n",
5287 show_database_desc
[type
]);
5288 vty_out(vty
, "%s\n", show_database_header
[type
]);
5290 LSDB_LOOP(AS_LSDB(ospf
, type
), rn
, lsa
)
5291 show_lsa_summary(vty
, lsa
, self
);
5300 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
)
5302 struct route_node
*rn
;
5304 vty_out(vty
, "\n MaxAge Link States:\n\n");
5306 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
5307 struct ospf_lsa
*lsa
;
5309 if ((lsa
= rn
->info
) != NULL
) {
5310 vty_out(vty
, "Link type: %d\n", lsa
->data
->type
);
5311 vty_out(vty
, "Link State ID: %s\n",
5312 inet_ntoa(lsa
->data
->id
));
5313 vty_out(vty
, "Advertising Router: %s\n",
5314 inet_ntoa(lsa
->data
->adv_router
));
5315 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
5321 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5322 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5324 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5325 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5326 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5327 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5329 #define OSPF_LSA_TYPES_DESC \
5330 "ASBR summary link states\n" \
5331 "External link states\n" \
5332 "Network link states\n" \
5333 "Router link states\n" \
5334 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
5335 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5336 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5338 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
5339 int arg_base
, int argc
,
5340 struct cmd_token
**argv
)
5344 struct in_addr id
, adv_router
;
5347 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5349 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5350 inet_ntoa(ospf
->router_id
));
5353 if (argc
== arg_base
+ 4) {
5354 show_ip_ospf_database_summary(vty
, ospf
, 0);
5358 /* Set database type to show. */
5359 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5360 type
= OSPF_ROUTER_LSA
;
5361 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5362 type
= OSPF_NETWORK_LSA
;
5363 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5364 type
= OSPF_AS_NSSA_LSA
;
5365 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5366 type
= OSPF_SUMMARY_LSA
;
5367 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5368 type
= OSPF_ASBR_SUMMARY_LSA
;
5369 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5370 type
= OSPF_AS_EXTERNAL_LSA
;
5371 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
5372 show_ip_ospf_database_summary(vty
, ospf
, 1);
5374 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
5375 show_ip_ospf_database_maxage(vty
, ospf
);
5377 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5378 type
= OSPF_OPAQUE_LINK_LSA
;
5379 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5380 type
= OSPF_OPAQUE_AREA_LSA
;
5381 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5382 type
= OSPF_OPAQUE_AS_LSA
;
5386 /* `show ip ospf database LSA'. */
5387 if (argc
== arg_base
+ 5)
5388 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
);
5389 else if (argc
>= arg_base
+ 6) {
5390 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
5394 /* `show ip ospf database LSA ID'. */
5395 if (argc
== arg_base
+ 6)
5396 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
);
5397 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5398 else if (argc
== arg_base
+ 7) {
5399 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5400 adv_router
= ospf
->router_id
;
5402 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
5407 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
);
5414 DEFUN (show_ip_ospf_database_max
,
5415 show_ip_ospf_database_max_cmd
,
5416 "show ip ospf database <max-age|self-originate>",
5419 "OSPF information\n"
5420 "Database summary\n"
5421 "LSAs in MaxAge list\n"
5422 "Self-originated link states\n")
5426 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5429 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5432 DEFUN (show_ip_ospf_instance_database
,
5433 show_ip_ospf_instance_database_cmd
,
5434 "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>]]]",
5437 "OSPF information\n"
5439 "Database summary\n"
5441 "Link State ID (as an IP address)\n"
5442 "Self-originated link states\n"
5443 "Advertising Router link states\n"
5444 "Advertising Router (as an IP address)\n")
5447 u_short instance
= 0;
5450 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5451 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5452 ospf
= ospf_lookup_instance(instance
);
5454 return CMD_NOT_MY_INSTANCE
;
5456 ospf
= ospf_lookup();
5459 if (!ospf
|| !ospf
->oi_running
)
5462 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
,
5466 DEFUN (show_ip_ospf_instance_database_max
,
5467 show_ip_ospf_instance_database_max_cmd
,
5468 "show ip ospf (1-65535) database <max-age|self-originate>",
5471 "OSPF information\n"
5473 "Database summary\n"
5474 "LSAs in MaxAge list\n"
5475 "Self-originated link states\n")
5479 u_short instance
= 0;
5481 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5483 ospf
= ospf_lookup_instance(instance
);
5485 return CMD_NOT_MY_INSTANCE
;
5487 if (!ospf
->oi_running
)
5490 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5494 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
5496 int arg_base
, int argc
,
5497 struct cmd_token
**argv
)
5501 struct in_addr adv_router
;
5504 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5506 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5507 inet_ntoa(ospf
->router_id
));
5509 /* Set database type to show. */
5510 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5511 type
= OSPF_ROUTER_LSA
;
5512 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5513 type
= OSPF_NETWORK_LSA
;
5514 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5515 type
= OSPF_AS_NSSA_LSA
;
5516 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5517 type
= OSPF_SUMMARY_LSA
;
5518 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5519 type
= OSPF_ASBR_SUMMARY_LSA
;
5520 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5521 type
= OSPF_AS_EXTERNAL_LSA
;
5522 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5523 type
= OSPF_OPAQUE_LINK_LSA
;
5524 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5525 type
= OSPF_OPAQUE_AREA_LSA
;
5526 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5527 type
= OSPF_OPAQUE_AS_LSA
;
5531 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5532 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5533 adv_router
= ospf
->router_id
;
5535 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
5540 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
);
5545 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5546 show_ip_ospf_instance_database_type_adv_router_cmd
,
5547 "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>",
5550 "OSPF information\n"
5552 "Database summary\n"
5554 "Advertising Router link states\n"
5555 "Advertising Router (as an IP address)\n"
5556 "Self-originated link states\n")
5559 u_short instance
= 0;
5562 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5563 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5564 ospf
= ospf_lookup_instance(instance
);
5566 return CMD_NOT_MY_INSTANCE
;
5568 ospf
= ospf_lookup();
5570 if (!ospf
|| !ospf
->oi_running
)
5573 return (show_ip_ospf_database_type_adv_router_common(
5574 vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5577 DEFUN (ip_ospf_authentication_args
,
5578 ip_ospf_authentication_args_addr_cmd
,
5579 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5581 "OSPF interface commands\n"
5582 "Enable authentication on this interface\n"
5583 "Use null authentication\n"
5584 "Use message-digest authentication\n"
5585 "Address of interface\n")
5587 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5588 int idx_encryption
= 3;
5590 struct in_addr addr
;
5592 struct ospf_if_params
*params
;
5594 params
= IF_DEF_PARAMS(ifp
);
5597 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5600 "Please specify interface address by A.B.C.D\n");
5601 return CMD_WARNING_CONFIG_FAILED
;
5604 params
= ospf_get_if_params(ifp
, addr
);
5605 ospf_if_update_params(ifp
, addr
);
5608 /* Handle null authentication */
5609 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5610 SET_IF_PARAM(params
, auth_type
);
5611 params
->auth_type
= OSPF_AUTH_NULL
;
5615 /* Handle message-digest authentication */
5616 if (argv
[idx_encryption
]->arg
[0] == 'm') {
5617 SET_IF_PARAM(params
, auth_type
);
5618 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5622 vty_out(vty
, "You shouldn't get here!\n");
5623 return CMD_WARNING_CONFIG_FAILED
;
5626 DEFUN (ip_ospf_authentication
,
5627 ip_ospf_authentication_addr_cmd
,
5628 "ip ospf authentication [A.B.C.D]",
5630 "OSPF interface commands\n"
5631 "Enable authentication on this interface\n"
5632 "Address of interface")
5634 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5636 struct in_addr addr
;
5638 struct ospf_if_params
*params
;
5640 params
= IF_DEF_PARAMS(ifp
);
5643 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5646 "Please specify interface address by A.B.C.D\n");
5647 return CMD_WARNING_CONFIG_FAILED
;
5650 params
= ospf_get_if_params(ifp
, addr
);
5651 ospf_if_update_params(ifp
, addr
);
5654 SET_IF_PARAM(params
, auth_type
);
5655 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5660 DEFUN (no_ip_ospf_authentication_args
,
5661 no_ip_ospf_authentication_args_addr_cmd
,
5662 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5665 "OSPF interface commands\n"
5666 "Enable authentication on this interface\n"
5667 "Use null authentication\n"
5668 "Use message-digest authentication\n"
5669 "Address of interface")
5671 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5672 int idx_encryption
= 4;
5674 struct in_addr addr
;
5676 struct ospf_if_params
*params
;
5677 struct route_node
*rn
;
5680 params
= IF_DEF_PARAMS(ifp
);
5683 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5686 "Please specify interface address by A.B.C.D\n");
5687 return CMD_WARNING_CONFIG_FAILED
;
5690 params
= ospf_lookup_if_params(ifp
, addr
);
5691 if (params
== NULL
) {
5692 vty_out(vty
, "Ip Address specified is unknown\n");
5693 return CMD_WARNING_CONFIG_FAILED
;
5695 params
->auth_type
= OSPF_AUTH_NOTSET
;
5696 UNSET_IF_PARAM(params
, auth_type
);
5697 if (params
!= IF_DEF_PARAMS(ifp
)) {
5698 ospf_free_if_params(ifp
, addr
);
5699 ospf_if_update_params(ifp
, addr
);
5702 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5703 auth_type
= OSPF_AUTH_NULL
;
5704 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
5705 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5707 vty_out(vty
, "Unexpected input encountered\n");
5708 return CMD_WARNING_CONFIG_FAILED
;
5711 * Here we have a case where the user has entered
5712 * 'no ip ospf authentication (null | message_digest )'
5713 * we need to find if we have any ip addresses underneath it
5715 * correspond to the associated type.
5717 if (params
->auth_type
== auth_type
) {
5718 params
->auth_type
= OSPF_AUTH_NOTSET
;
5719 UNSET_IF_PARAM(params
, auth_type
);
5722 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5723 rn
= route_next(rn
)) {
5724 if ((params
= rn
->info
)) {
5725 if (params
->auth_type
== auth_type
) {
5726 params
->auth_type
= OSPF_AUTH_NOTSET
;
5727 UNSET_IF_PARAM(params
, auth_type
);
5728 if (params
!= IF_DEF_PARAMS(ifp
)) {
5729 ospf_free_if_params(
5730 ifp
, rn
->p
.u
.prefix4
);
5731 ospf_if_update_params(
5732 ifp
, rn
->p
.u
.prefix4
);
5742 DEFUN (no_ip_ospf_authentication
,
5743 no_ip_ospf_authentication_addr_cmd
,
5744 "no ip ospf authentication [A.B.C.D]",
5747 "OSPF interface commands\n"
5748 "Enable authentication on this interface\n"
5749 "Address of interface")
5751 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5753 struct in_addr addr
;
5755 struct ospf_if_params
*params
;
5756 struct route_node
*rn
;
5758 params
= IF_DEF_PARAMS(ifp
);
5761 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5764 "Please specify interface address by A.B.C.D\n");
5765 return CMD_WARNING_CONFIG_FAILED
;
5768 params
= ospf_lookup_if_params(ifp
, addr
);
5769 if (params
== NULL
) {
5770 vty_out(vty
, "Ip Address specified is unknown\n");
5771 return CMD_WARNING_CONFIG_FAILED
;
5774 params
->auth_type
= OSPF_AUTH_NOTSET
;
5775 UNSET_IF_PARAM(params
, auth_type
);
5776 if (params
!= IF_DEF_PARAMS(ifp
)) {
5777 ospf_free_if_params(ifp
, addr
);
5778 ospf_if_update_params(ifp
, addr
);
5782 * When a user enters 'no ip ospf authentication'
5783 * We should remove all authentication types from
5786 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5787 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
5788 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
5789 params
->auth_type
= OSPF_AUTH_NOTSET
;
5790 UNSET_IF_PARAM(params
, auth_type
);
5793 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5794 rn
= route_next(rn
)) {
5795 if ((params
= rn
->info
)) {
5797 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5798 || (params
->auth_type
5799 == OSPF_AUTH_CRYPTOGRAPHIC
)
5800 || (params
->auth_type
5801 == OSPF_AUTH_SIMPLE
)) {
5802 params
->auth_type
= OSPF_AUTH_NOTSET
;
5803 UNSET_IF_PARAM(params
, auth_type
);
5804 if (params
!= IF_DEF_PARAMS(ifp
)) {
5805 ospf_free_if_params(
5806 ifp
, rn
->p
.u
.prefix4
);
5807 ospf_if_update_params(
5808 ifp
, rn
->p
.u
.prefix4
);
5819 DEFUN (ip_ospf_authentication_key
,
5820 ip_ospf_authentication_key_addr_cmd
,
5821 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5823 "OSPF interface commands\n"
5824 "Authentication password (key)\n"
5825 "The OSPF password (key)\n"
5826 "Address of interface")
5828 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5830 struct in_addr addr
;
5831 struct ospf_if_params
*params
;
5833 params
= IF_DEF_PARAMS(ifp
);
5835 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5836 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5838 "Please specify interface address by A.B.C.D\n");
5839 return CMD_WARNING_CONFIG_FAILED
;
5842 params
= ospf_get_if_params(ifp
, addr
);
5843 ospf_if_update_params(ifp
, addr
);
5846 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5847 strncpy((char *)params
->auth_simple
, argv
[3]->arg
,
5848 OSPF_AUTH_SIMPLE_SIZE
);
5849 SET_IF_PARAM(params
, auth_simple
);
5854 DEFUN_HIDDEN (ospf_authentication_key
,
5855 ospf_authentication_key_cmd
,
5856 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5857 "OSPF interface commands\n"
5858 "Authentication password (key)\n"
5859 "The OSPF password (key)\n"
5860 "Address of interface\n")
5862 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
5865 DEFUN (no_ip_ospf_authentication_key
,
5866 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5867 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5870 "OSPF interface commands\n"
5871 "Authentication password (key)\n"
5872 "The OSPF password (key)")
5874 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5876 struct in_addr addr
;
5877 struct ospf_if_params
*params
;
5878 params
= IF_DEF_PARAMS(ifp
);
5880 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5881 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5883 "Please specify interface address by A.B.C.D\n");
5884 return CMD_WARNING_CONFIG_FAILED
;
5887 params
= ospf_lookup_if_params(ifp
, addr
);
5892 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5893 UNSET_IF_PARAM(params
, auth_simple
);
5895 if (params
!= IF_DEF_PARAMS(ifp
)) {
5896 ospf_free_if_params(ifp
, addr
);
5897 ospf_if_update_params(ifp
, addr
);
5903 DEFUN_HIDDEN (no_ospf_authentication_key
,
5904 no_ospf_authentication_key_authkey_addr_cmd
,
5905 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5907 "OSPF interface commands\n"
5908 "Authentication password (key)\n"
5909 "The OSPF password (key)")
5911 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
5914 DEFUN (ip_ospf_message_digest_key
,
5915 ip_ospf_message_digest_key_cmd
,
5916 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5918 "OSPF interface commands\n"
5919 "Message digest authentication password (key)\n"
5921 "Use MD5 algorithm\n"
5922 "The OSPF password (key)\n"
5923 "Address of interface\n")
5925 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5926 struct crypt_key
*ck
;
5928 struct in_addr addr
;
5929 struct ospf_if_params
*params
;
5931 params
= IF_DEF_PARAMS(ifp
);
5934 argv_find(argv
, argc
, "(1-255)", &idx
);
5935 char *keyid
= argv
[idx
]->arg
;
5936 argv_find(argv
, argc
, "KEY", &idx
);
5937 char *cryptkey
= argv
[idx
]->arg
;
5939 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5940 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5942 "Please specify interface address by A.B.C.D\n");
5943 return CMD_WARNING_CONFIG_FAILED
;
5946 params
= ospf_get_if_params(ifp
, addr
);
5947 ospf_if_update_params(ifp
, addr
);
5950 key_id
= strtol(keyid
, NULL
, 10);
5951 if (ospf_crypt_key_lookup(params
->auth_crypt
, key_id
) != NULL
) {
5952 vty_out(vty
, "OSPF: Key %d already exists\n", key_id
);
5956 ck
= ospf_crypt_key_new();
5957 ck
->key_id
= (u_char
)key_id
;
5958 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
5959 strncpy((char *)ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5961 ospf_crypt_key_add(params
->auth_crypt
, ck
);
5962 SET_IF_PARAM(params
, auth_crypt
);
5967 DEFUN_HIDDEN (ospf_message_digest_key
,
5968 ospf_message_digest_key_cmd
,
5969 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5970 "OSPF interface commands\n"
5971 "Message digest authentication password (key)\n"
5973 "Use MD5 algorithm\n"
5974 "The OSPF password (key)\n"
5975 "Address of interface\n")
5977 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
5980 DEFUN (no_ip_ospf_message_digest_key
,
5981 no_ip_ospf_message_digest_key_cmd
,
5982 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
5985 "OSPF interface commands\n"
5986 "Message digest authentication password (key)\n"
5988 "Use MD5 algorithm\n"
5989 "The OSPF password (key)\n"
5990 "Address of interface\n")
5992 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5994 struct crypt_key
*ck
;
5996 struct in_addr addr
;
5997 struct ospf_if_params
*params
;
5998 params
= IF_DEF_PARAMS(ifp
);
6000 argv_find(argv
, argc
, "(1-255)", &idx
);
6001 char *keyid
= argv
[idx
]->arg
;
6003 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6004 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6006 "Please specify interface address by A.B.C.D\n");
6007 return CMD_WARNING_CONFIG_FAILED
;
6010 params
= ospf_lookup_if_params(ifp
, addr
);
6015 key_id
= strtol(keyid
, NULL
, 10);
6016 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
6018 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
6019 return CMD_WARNING_CONFIG_FAILED
;
6022 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
6024 if (params
!= IF_DEF_PARAMS(ifp
)) {
6025 ospf_free_if_params(ifp
, addr
);
6026 ospf_if_update_params(ifp
, addr
);
6032 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6033 no_ospf_message_digest_key_cmd
,
6034 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6036 "OSPF interface commands\n"
6037 "Message digest authentication password (key)\n"
6039 "Address of interface")
6041 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6044 DEFUN (ip_ospf_cost
,
6046 "ip ospf cost (1-65535) [A.B.C.D]",
6048 "OSPF interface commands\n"
6051 "Address of interface\n")
6053 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6056 struct in_addr addr
;
6057 struct ospf_if_params
*params
;
6058 params
= IF_DEF_PARAMS(ifp
);
6061 char *coststr
= NULL
, *ifaddr
= NULL
;
6062 coststr
= argv_find(argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
6064 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6066 cost
= strtol(coststr
, NULL
, 10);
6069 if (!inet_aton(ifaddr
, &addr
)) {
6071 "Please specify interface address by A.B.C.D\n");
6072 return CMD_WARNING_CONFIG_FAILED
;
6075 params
= ospf_get_if_params(ifp
, addr
);
6076 ospf_if_update_params(ifp
, addr
);
6079 SET_IF_PARAM(params
, output_cost_cmd
);
6080 params
->output_cost_cmd
= cost
;
6082 ospf_if_recalculate_output_cost(ifp
);
6087 DEFUN_HIDDEN (ospf_cost
,
6089 "ospf cost (1-65535) [A.B.C.D]",
6090 "OSPF interface commands\n"
6093 "Address of interface\n")
6095 return ip_ospf_cost(self
, vty
, argc
, argv
);
6098 DEFUN (no_ip_ospf_cost
,
6099 no_ip_ospf_cost_cmd
,
6100 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6102 "OSPF interface commands\n"
6104 "Address of interface")
6106 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6108 struct in_addr addr
;
6109 struct ospf_if_params
*params
;
6111 params
= IF_DEF_PARAMS(ifp
);
6114 char *ifaddr
= NULL
;
6115 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6117 /* According to the semantics we are mimicking "no ip ospf cost N" is
6118 * always treated as "no ip ospf cost" regardless of the actual value
6119 * of N already configured for the interface. Thus ignore cost. */
6122 if (!inet_aton(ifaddr
, &addr
)) {
6124 "Please specify interface address by A.B.C.D\n");
6125 return CMD_WARNING_CONFIG_FAILED
;
6128 params
= ospf_lookup_if_params(ifp
, addr
);
6133 UNSET_IF_PARAM(params
, output_cost_cmd
);
6135 if (params
!= IF_DEF_PARAMS(ifp
)) {
6136 ospf_free_if_params(ifp
, addr
);
6137 ospf_if_update_params(ifp
, addr
);
6140 ospf_if_recalculate_output_cost(ifp
);
6145 DEFUN_HIDDEN (no_ospf_cost
,
6147 "no ospf cost [(1-65535)] [A.B.C.D]",
6149 "OSPF interface commands\n"
6152 "Address of interface\n")
6154 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
6157 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
6159 struct route_node
*rn
;
6160 struct ospf_neighbor
*nbr
;
6162 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
6163 if ((nbr
= rn
->info
)) {
6164 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
6165 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6166 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6167 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6171 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
6172 const char *nbr_str
,
6173 const char *fast_hello_str
)
6175 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6178 struct in_addr addr
;
6180 struct ospf_if_params
*params
;
6181 struct ospf_interface
*oi
;
6182 struct route_node
*rn
;
6184 params
= IF_DEF_PARAMS(ifp
);
6187 ret
= inet_aton(nbr_str
, &addr
);
6190 "Please specify interface address by A.B.C.D\n");
6191 return CMD_WARNING_CONFIG_FAILED
;
6194 params
= ospf_get_if_params(ifp
, addr
);
6195 ospf_if_update_params(ifp
, addr
);
6199 seconds
= strtoul(interval_str
, NULL
, 10);
6201 /* reset fast_hello too, just to be sure */
6202 UNSET_IF_PARAM(params
, fast_hello
);
6203 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6204 } else if (fast_hello_str
) {
6205 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
6206 /* 1s dead-interval with sub-second hellos desired */
6207 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6208 SET_IF_PARAM(params
, fast_hello
);
6209 params
->fast_hello
= hellomult
;
6212 "Please specify dead-interval or hello-multiplier\n");
6213 return CMD_WARNING_CONFIG_FAILED
;
6216 SET_IF_PARAM(params
, v_wait
);
6217 params
->v_wait
= seconds
;
6219 /* Update timer values in neighbor structure. */
6222 if ((ospf
= ospf_lookup())) {
6223 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6225 ospf_nbr_timer_update(oi
);
6228 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6229 if ((oi
= rn
->info
))
6230 ospf_nbr_timer_update(oi
);
6236 DEFUN (ip_ospf_dead_interval
,
6237 ip_ospf_dead_interval_cmd
,
6238 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6240 "OSPF interface commands\n"
6241 "Interval time after which a neighbor is declared down\n"
6243 "Address of interface\n")
6246 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
6250 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6251 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
6255 DEFUN_HIDDEN (ospf_dead_interval
,
6256 ospf_dead_interval_cmd
,
6257 "ospf dead-interval (1-65535) [A.B.C.D]",
6258 "OSPF interface commands\n"
6259 "Interval time after which a neighbor is declared down\n"
6261 "Address of interface\n")
6263 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6266 DEFUN (ip_ospf_dead_interval_minimal
,
6267 ip_ospf_dead_interval_minimal_addr_cmd
,
6268 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6270 "OSPF interface commands\n"
6271 "Interval time after which a neighbor is declared down\n"
6272 "Minimal 1s dead-interval with fast sub-second hellos\n"
6273 "Hello multiplier factor\n"
6274 "Number of Hellos to send each second\n"
6275 "Address of interface\n")
6280 return ospf_vty_dead_interval_set(
6281 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6283 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
6284 argv
[idx_number
]->arg
);
6287 DEFUN (no_ip_ospf_dead_interval
,
6288 no_ip_ospf_dead_interval_cmd
,
6289 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6292 "OSPF interface commands\n"
6293 "Interval time after which a neighbor is declared down\n"
6295 "Address of interface")
6297 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6298 int idx_ipv4
= argc
- 1;
6299 struct in_addr addr
= {.s_addr
= 0L};
6301 struct ospf_if_params
*params
;
6302 struct ospf_interface
*oi
;
6303 struct route_node
*rn
;
6305 params
= IF_DEF_PARAMS(ifp
);
6307 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
6308 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6311 "Please specify interface address by A.B.C.D\n");
6312 return CMD_WARNING_CONFIG_FAILED
;
6315 params
= ospf_lookup_if_params(ifp
, addr
);
6320 UNSET_IF_PARAM(params
, v_wait
);
6321 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6323 UNSET_IF_PARAM(params
, fast_hello
);
6324 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6326 if (params
!= IF_DEF_PARAMS(ifp
)) {
6327 ospf_free_if_params(ifp
, addr
);
6328 ospf_if_update_params(ifp
, addr
);
6331 /* Update timer values in neighbor structure. */
6335 if ((ospf
= ospf_lookup())) {
6336 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6338 ospf_nbr_timer_update(oi
);
6341 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6342 if ((oi
= rn
->info
))
6343 ospf_nbr_timer_update(oi
);
6349 DEFUN_HIDDEN (no_ospf_dead_interval
,
6350 no_ospf_dead_interval_cmd
,
6351 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6353 "OSPF interface commands\n"
6354 "Interval time after which a neighbor is declared down\n"
6356 "Address of interface")
6358 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6361 DEFUN (ip_ospf_hello_interval
,
6362 ip_ospf_hello_interval_cmd
,
6363 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6365 "OSPF interface commands\n"
6366 "Time between HELLO packets\n"
6368 "Address of interface\n")
6370 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6372 struct in_addr addr
;
6373 struct ospf_if_params
*params
;
6374 params
= IF_DEF_PARAMS(ifp
);
6375 u_int32_t seconds
= 0;
6377 argv_find(argv
, argc
, "(1-65535)", &idx
);
6378 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6380 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6381 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6383 "Please specify interface address by A.B.C.D\n");
6384 return CMD_WARNING_CONFIG_FAILED
;
6387 params
= ospf_get_if_params(ifp
, addr
);
6388 ospf_if_update_params(ifp
, addr
);
6391 SET_IF_PARAM(params
, v_hello
);
6392 params
->v_hello
= seconds
;
6397 DEFUN_HIDDEN (ospf_hello_interval
,
6398 ospf_hello_interval_cmd
,
6399 "ospf hello-interval (1-65535) [A.B.C.D]",
6400 "OSPF interface commands\n"
6401 "Time between HELLO packets\n"
6403 "Address of interface\n")
6405 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6408 DEFUN (no_ip_ospf_hello_interval
,
6409 no_ip_ospf_hello_interval_cmd
,
6410 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6413 "OSPF interface commands\n"
6414 "Time between HELLO packets\n" // ignored
6416 "Address of interface\n")
6418 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6420 struct in_addr addr
;
6421 struct ospf_if_params
*params
;
6423 params
= IF_DEF_PARAMS(ifp
);
6425 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6426 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6428 "Please specify interface address by A.B.C.D\n");
6429 return CMD_WARNING_CONFIG_FAILED
;
6432 params
= ospf_lookup_if_params(ifp
, addr
);
6437 UNSET_IF_PARAM(params
, v_hello
);
6438 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6440 if (params
!= IF_DEF_PARAMS(ifp
)) {
6441 ospf_free_if_params(ifp
, addr
);
6442 ospf_if_update_params(ifp
, addr
);
6448 DEFUN_HIDDEN (no_ospf_hello_interval
,
6449 no_ospf_hello_interval_cmd
,
6450 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6452 "OSPF interface commands\n"
6453 "Time between HELLO packets\n" // ignored
6455 "Address of interface\n")
6457 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6460 DEFUN (ip_ospf_network
,
6461 ip_ospf_network_cmd
,
6462 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6464 "OSPF interface commands\n"
6466 "Specify OSPF broadcast multi-access network\n"
6467 "Specify OSPF NBMA network\n"
6468 "Specify OSPF point-to-multipoint network\n"
6469 "Specify OSPF point-to-point network\n")
6471 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6473 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6474 struct route_node
*rn
;
6476 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
6478 "This is a loopback interface. Can't set network type.\n");
6479 return CMD_WARNING_CONFIG_FAILED
;
6482 if (argv_find(argv
, argc
, "broadcast", &idx
))
6483 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6484 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
6485 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
6486 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
6487 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6488 else if (argv_find(argv
, argc
, "point-to-point", &idx
))
6489 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6491 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6494 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
6496 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6497 struct ospf_interface
*oi
= rn
->info
;
6502 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6504 if (oi
->state
> ISM_Down
) {
6505 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6506 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6513 DEFUN_HIDDEN (ospf_network
,
6515 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6516 "OSPF interface commands\n"
6518 "Specify OSPF broadcast multi-access network\n"
6519 "Specify OSPF NBMA network\n"
6520 "Specify OSPF point-to-multipoint network\n"
6521 "Specify OSPF point-to-point network\n")
6523 return ip_ospf_network(self
, vty
, argc
, argv
);
6526 DEFUN (no_ip_ospf_network
,
6527 no_ip_ospf_network_cmd
,
6528 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6531 "OSPF interface commands\n"
6533 "Specify OSPF broadcast multi-access network\n"
6534 "Specify OSPF NBMA network\n"
6535 "Specify OSPF point-to-multipoint network\n"
6536 "Specify OSPF point-to-point network\n")
6538 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6539 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6540 struct route_node
*rn
;
6542 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
6544 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6547 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6548 struct ospf_interface
*oi
= rn
->info
;
6553 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6555 if (oi
->state
> ISM_Down
) {
6556 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6557 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6564 DEFUN_HIDDEN (no_ospf_network
,
6565 no_ospf_network_cmd
,
6566 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6568 "OSPF interface commands\n"
6570 "Specify OSPF broadcast multi-access network\n"
6571 "Specify OSPF NBMA network\n"
6572 "Specify OSPF point-to-multipoint network\n"
6573 "Specify OSPF point-to-point network\n")
6575 return no_ip_ospf_network(self
, vty
, argc
, argv
);
6578 DEFUN (ip_ospf_priority
,
6579 ip_ospf_priority_cmd
,
6580 "ip ospf priority (0-255) [A.B.C.D]",
6582 "OSPF interface commands\n"
6585 "Address of interface")
6587 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6590 struct route_node
*rn
;
6591 struct in_addr addr
;
6592 struct ospf_if_params
*params
;
6593 params
= IF_DEF_PARAMS(ifp
);
6595 argv_find(argv
, argc
, "(0-255)", &idx
);
6596 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
6598 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6599 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6601 "Please specify interface address by A.B.C.D\n");
6602 return CMD_WARNING_CONFIG_FAILED
;
6605 params
= ospf_get_if_params(ifp
, addr
);
6606 ospf_if_update_params(ifp
, addr
);
6609 SET_IF_PARAM(params
, priority
);
6610 params
->priority
= priority
;
6612 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6613 struct ospf_interface
*oi
= rn
->info
;
6618 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6619 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6620 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6627 DEFUN_HIDDEN (ospf_priority
,
6629 "ospf priority (0-255) [A.B.C.D]",
6630 "OSPF interface commands\n"
6633 "Address of interface")
6635 return ip_ospf_priority(self
, vty
, argc
, argv
);
6638 DEFUN (no_ip_ospf_priority
,
6639 no_ip_ospf_priority_cmd
,
6640 "no ip ospf priority [(0-255) [A.B.C.D]]",
6643 "OSPF interface commands\n"
6644 "Router priority\n" // ignored
6646 "Address of interface")
6648 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6650 struct route_node
*rn
;
6651 struct in_addr addr
;
6652 struct ospf_if_params
*params
;
6654 params
= IF_DEF_PARAMS(ifp
);
6656 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6657 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6659 "Please specify interface address by A.B.C.D\n");
6660 return CMD_WARNING_CONFIG_FAILED
;
6663 params
= ospf_lookup_if_params(ifp
, addr
);
6668 UNSET_IF_PARAM(params
, priority
);
6669 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6671 if (params
!= IF_DEF_PARAMS(ifp
)) {
6672 ospf_free_if_params(ifp
, addr
);
6673 ospf_if_update_params(ifp
, addr
);
6676 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6677 struct ospf_interface
*oi
= rn
->info
;
6682 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6683 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6684 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6691 DEFUN_HIDDEN (no_ospf_priority
,
6692 no_ospf_priority_cmd
,
6693 "no ospf priority [(0-255) [A.B.C.D]]",
6695 "OSPF interface commands\n"
6698 "Address of interface")
6700 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
6703 DEFUN (ip_ospf_retransmit_interval
,
6704 ip_ospf_retransmit_interval_addr_cmd
,
6705 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6707 "OSPF interface commands\n"
6708 "Time between retransmitting lost link state advertisements\n"
6710 "Address of interface")
6712 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6715 struct in_addr addr
;
6716 struct ospf_if_params
*params
;
6717 params
= IF_DEF_PARAMS(ifp
);
6719 argv_find(argv
, argc
, "(3-65535)", &idx
);
6720 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6722 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6723 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6725 "Please specify interface address by A.B.C.D\n");
6726 return CMD_WARNING_CONFIG_FAILED
;
6729 params
= ospf_get_if_params(ifp
, addr
);
6730 ospf_if_update_params(ifp
, addr
);
6733 SET_IF_PARAM(params
, retransmit_interval
);
6734 params
->retransmit_interval
= seconds
;
6739 DEFUN_HIDDEN (ospf_retransmit_interval
,
6740 ospf_retransmit_interval_cmd
,
6741 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6742 "OSPF interface commands\n"
6743 "Time between retransmitting lost link state advertisements\n"
6745 "Address of interface")
6747 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6750 DEFUN (no_ip_ospf_retransmit_interval
,
6751 no_ip_ospf_retransmit_interval_addr_cmd
,
6752 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6755 "OSPF interface commands\n"
6756 "Time between retransmitting lost link state advertisements\n"
6758 "Address of interface\n")
6760 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6762 struct in_addr addr
;
6763 struct ospf_if_params
*params
;
6765 params
= IF_DEF_PARAMS(ifp
);
6767 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6768 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6770 "Please specify interface address by A.B.C.D\n");
6771 return CMD_WARNING_CONFIG_FAILED
;
6774 params
= ospf_lookup_if_params(ifp
, addr
);
6779 UNSET_IF_PARAM(params
, retransmit_interval
);
6780 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6782 if (params
!= IF_DEF_PARAMS(ifp
)) {
6783 ospf_free_if_params(ifp
, addr
);
6784 ospf_if_update_params(ifp
, addr
);
6790 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6791 no_ospf_retransmit_interval_cmd
,
6792 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6794 "OSPF interface commands\n"
6795 "Time between retransmitting lost link state advertisements\n"
6797 "Address of interface\n")
6799 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6802 DEFUN (ip_ospf_transmit_delay
,
6803 ip_ospf_transmit_delay_addr_cmd
,
6804 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6806 "OSPF interface commands\n"
6807 "Link state transmit delay\n"
6809 "Address of interface")
6811 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6814 struct in_addr addr
;
6815 struct ospf_if_params
*params
;
6817 params
= IF_DEF_PARAMS(ifp
);
6818 argv_find(argv
, argc
, "(1-65535)", &idx
);
6819 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6821 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6822 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6824 "Please specify interface address by A.B.C.D\n");
6825 return CMD_WARNING_CONFIG_FAILED
;
6828 params
= ospf_get_if_params(ifp
, addr
);
6829 ospf_if_update_params(ifp
, addr
);
6832 SET_IF_PARAM(params
, transmit_delay
);
6833 params
->transmit_delay
= seconds
;
6838 DEFUN_HIDDEN (ospf_transmit_delay
,
6839 ospf_transmit_delay_cmd
,
6840 "ospf transmit-delay (1-65535) [A.B.C.D]",
6841 "OSPF interface commands\n"
6842 "Link state transmit delay\n"
6844 "Address of interface")
6846 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
6849 DEFUN (no_ip_ospf_transmit_delay
,
6850 no_ip_ospf_transmit_delay_addr_cmd
,
6851 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6854 "OSPF interface commands\n"
6855 "Link state transmit delay\n"
6856 "Address of interface")
6858 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6860 struct in_addr addr
;
6861 struct ospf_if_params
*params
;
6863 params
= IF_DEF_PARAMS(ifp
);
6865 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6866 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6868 "Please specify interface address by A.B.C.D\n");
6869 return CMD_WARNING_CONFIG_FAILED
;
6872 params
= ospf_lookup_if_params(ifp
, addr
);
6877 UNSET_IF_PARAM(params
, transmit_delay
);
6878 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6880 if (params
!= IF_DEF_PARAMS(ifp
)) {
6881 ospf_free_if_params(ifp
, addr
);
6882 ospf_if_update_params(ifp
, addr
);
6889 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6890 no_ospf_transmit_delay_cmd
,
6891 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
6893 "OSPF interface commands\n"
6894 "Link state transmit delay\n"
6896 "Address of interface")
6898 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
6901 DEFUN (ip_ospf_area
,
6903 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
6905 "OSPF interface commands\n"
6907 "Enable OSPF on this interface\n"
6908 "OSPF area ID in IP address format\n"
6909 "OSPF area ID as a decimal value\n"
6910 "Address of interface\n")
6912 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6915 struct in_addr area_id
;
6916 struct in_addr addr
;
6917 struct ospf_if_params
*params
;
6918 struct route_node
*rn
;
6920 u_short instance
= 0;
6923 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
6924 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
6926 argv_find(argv
, argc
, "area", &idx
);
6927 areaid
= argv
[idx
+ 1]->arg
;
6929 ospf
= ospf_lookup_instance(instance
);
6931 params
= IF_DEF_PARAMS(ifp
);
6932 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
6933 UNSET_IF_PARAM(params
, if_area
);
6934 ospf_interface_area_unset(ifp
);
6935 ospf
= ospf_lookup();
6936 ospf
->if_ospf_cli_count
--;
6938 return CMD_NOT_MY_INSTANCE
;
6941 ret
= str2area_id(areaid
, &area_id
, &format
);
6943 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
6944 return CMD_WARNING_CONFIG_FAILED
;
6946 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
6947 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
6948 return CMD_WARNING_CONFIG_FAILED
;
6951 params
= IF_DEF_PARAMS(ifp
);
6952 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
6953 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
6955 "Must remove previous area config before changing ospf area \n");
6956 return CMD_WARNING_CONFIG_FAILED
;
6959 // Check if we have an address arg and proccess it
6960 if (argc
== idx
+ 3) {
6961 inet_aton(argv
[idx
+ 2]->arg
, &addr
);
6962 // update/create address-level params
6963 params
= ospf_get_if_params((ifp
), (addr
));
6964 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
6966 "Must remove previous area/address config before changing ospf area");
6967 return CMD_WARNING_CONFIG_FAILED
;
6969 ospf_if_update_params((ifp
), (addr
));
6972 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
6973 if (rn
->info
!= NULL
) {
6975 "Please remove all network commands first.\n");
6976 return CMD_WARNING_CONFIG_FAILED
;
6980 /* enable ospf on this interface with area_id */
6981 SET_IF_PARAM(params
, if_area
);
6982 params
->if_area
= area_id
;
6983 params
->if_area_id_fmt
= format
;
6984 ospf_interface_area_set(ifp
);
6985 ospf
->if_ospf_cli_count
++;
6990 DEFUN (no_ip_ospf_area
,
6991 no_ip_ospf_area_cmd
,
6992 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
6995 "OSPF interface commands\n"
6997 "Disable OSPF on this interface\n"
6998 "OSPF area ID in IP address format\n"
6999 "OSPF area ID as a decimal value\n"
7000 "Address of interface\n")
7002 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7005 struct ospf_if_params
*params
;
7006 u_short instance
= 0;
7007 struct in_addr addr
;
7009 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7010 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7012 ospf
= ospf_lookup_instance(instance
);
7014 return CMD_NOT_MY_INSTANCE
;
7016 argv_find(argv
, argc
, "area", &idx
);
7018 // Check if we have an address arg and proccess it
7019 if (argc
== idx
+ 3) {
7020 inet_aton(argv
[idx
+ 2]->arg
, &addr
);
7021 params
= ospf_lookup_if_params(ifp
, addr
);
7022 if ((params
) == NULL
)
7025 params
= IF_DEF_PARAMS(ifp
);
7027 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7029 "Can't find specified interface area configuration.\n");
7030 return CMD_WARNING_CONFIG_FAILED
;
7033 UNSET_IF_PARAM(params
, if_area
);
7034 if (params
!= IF_DEF_PARAMS((ifp
))) {
7035 ospf_free_if_params((ifp
), (addr
));
7036 ospf_if_update_params((ifp
), (addr
));
7039 ospf_interface_area_unset(ifp
);
7040 ospf
->if_ospf_cli_count
--;
7044 DEFUN (ospf_redistribute_source
,
7045 ospf_redistribute_source_cmd
,
7046 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7048 FRR_REDIST_HELP_STR_OSPFD
7049 "Metric for redistributed routes\n"
7050 "OSPF default metric\n"
7051 "OSPF exterior metric type for redistributed routes\n"
7052 "Set OSPF External Type 1/2 metrics\n"
7053 "Route map reference\n"
7054 "Pointer to route-map entries\n")
7056 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7057 int idx_protocol
= 1;
7061 struct ospf_redist
*red
;
7067 /* Get distribute source. */
7068 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7070 return CMD_WARNING_CONFIG_FAILED
;
7072 red
= ospf_redist_add(ospf
, source
, 0);
7074 /* Get metric value. */
7075 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7076 if (!str2metric(argv
[idx
]->arg
, &metric
))
7077 return CMD_WARNING_CONFIG_FAILED
;
7079 /* Get metric type. */
7080 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7081 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7082 return CMD_WARNING_CONFIG_FAILED
;
7085 else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7086 ospf_routemap_set(red
, argv
[idx
]->arg
);
7088 ospf_routemap_unset(red
);
7090 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
7093 DEFUN (no_ospf_redistribute_source
,
7094 no_ospf_redistribute_source_cmd
,
7095 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7098 FRR_REDIST_HELP_STR_OSPFD
7099 "Metric for redistributed routes\n"
7100 "OSPF default metric\n"
7101 "OSPF exterior metric type for redistributed routes\n"
7102 "Set OSPF External Type 1/2 metrics\n"
7103 "Route map reference\n"
7104 "Pointer to route-map entries\n")
7106 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7107 int idx_protocol
= 2;
7109 struct ospf_redist
*red
;
7111 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7113 return CMD_WARNING_CONFIG_FAILED
;
7115 red
= ospf_redist_lookup(ospf
, source
, 0);
7119 ospf_routemap_unset(red
);
7120 return ospf_redistribute_unset(ospf
, source
, 0);
7123 DEFUN (ospf_redistribute_instance_source
,
7124 ospf_redistribute_instance_source_cmd
,
7125 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7127 "Open Shortest Path First\n"
7128 "Non-main Kernel Routing Table\n"
7129 "Instance ID/Table ID\n"
7130 "Metric for redistributed routes\n"
7131 "OSPF default metric\n"
7132 "OSPF exterior metric type for redistributed routes\n"
7133 "Set OSPF External Type 1/2 metrics\n"
7134 "Route map reference\n"
7135 "Pointer to route-map entries\n")
7137 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7138 int idx_ospf_table
= 1;
7145 struct ospf_redist
*red
;
7150 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
7152 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7157 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7159 "Instance redistribution in non-instanced OSPF not allowed\n");
7160 return CMD_WARNING_CONFIG_FAILED
;
7163 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7164 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7165 return CMD_WARNING_CONFIG_FAILED
;
7168 /* Get metric value. */
7169 if (argv_find(argv
, argc
, "metric", &idx
))
7170 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
7171 return CMD_WARNING_CONFIG_FAILED
;
7174 /* Get metric type. */
7175 if (argv_find(argv
, argc
, "metric-type", &idx
))
7176 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
7177 return CMD_WARNING_CONFIG_FAILED
;
7179 red
= ospf_redist_add(ospf
, source
, instance
);
7182 if (argv_find(argv
, argc
, "route-map", &idx
))
7183 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
7185 ospf_routemap_unset(red
);
7187 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
7190 DEFUN (no_ospf_redistribute_instance_source
,
7191 no_ospf_redistribute_instance_source_cmd
,
7192 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7195 "Open Shortest Path First\n"
7196 "Non-main Kernel Routing Table\n"
7197 "Instance ID/Table Id\n"
7198 "Metric for redistributed routes\n"
7199 "OSPF default metric\n"
7200 "OSPF exterior metric type for redistributed routes\n"
7201 "Set OSPF External Type 1/2 metrics\n"
7202 "Route map reference\n"
7203 "Pointer to route-map entries\n")
7205 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7206 int idx_ospf_table
= 2;
7209 struct ospf_redist
*red
;
7212 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7213 source
= ZEBRA_ROUTE_OSPF
;
7215 source
= ZEBRA_ROUTE_TABLE
;
7217 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7219 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7221 "Instance redistribution in non-instanced OSPF not allowed\n");
7222 return CMD_WARNING_CONFIG_FAILED
;
7225 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7226 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7227 return CMD_WARNING_CONFIG_FAILED
;
7230 red
= ospf_redist_lookup(ospf
, source
, instance
);
7234 ospf_routemap_unset(red
);
7235 return ospf_redistribute_unset(ospf
, source
, instance
);
7238 DEFUN (ospf_distribute_list_out
,
7239 ospf_distribute_list_out_cmd
,
7240 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7241 "Filter networks in routing updates\n"
7242 "Access-list name\n"
7244 FRR_REDIST_HELP_STR_OSPFD
)
7246 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7250 char *proto
= argv
[argc
- 1]->text
;
7252 /* Get distribute source. */
7253 source
= proto_redistnum(AFI_IP
, proto
);
7255 return CMD_WARNING_CONFIG_FAILED
;
7257 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
7260 DEFUN (no_ospf_distribute_list_out
,
7261 no_ospf_distribute_list_out_cmd
,
7262 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7264 "Filter networks in routing updates\n"
7265 "Access-list name\n"
7267 FRR_REDIST_HELP_STR_OSPFD
)
7269 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7273 char *proto
= argv
[argc
- 1]->text
;
7274 source
= proto_redistnum(AFI_IP
, proto
);
7276 return CMD_WARNING_CONFIG_FAILED
;
7278 return ospf_distribute_list_out_unset(ospf
, source
,
7279 argv
[idx_word
]->arg
);
7282 /* Default information originate. */
7283 DEFUN (ospf_default_information_originate
,
7284 ospf_default_information_originate_cmd
,
7285 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7286 "Control distribution of default information\n"
7287 "Distribute a default route\n"
7288 "Always advertise default route\n"
7289 "OSPF default metric\n"
7291 "OSPF metric type for default routes\n"
7292 "Set OSPF External Type 1/2 metrics\n"
7293 "Route map reference\n"
7294 "Pointer to route-map entries\n")
7296 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7297 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7300 struct ospf_redist
*red
;
7303 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7305 /* Check whether "always" was specified */
7306 if (argv_find(argv
, argc
, "always", &idx
))
7307 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7308 /* Get metric value */
7309 else if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7310 if (!str2metric(argv
[idx
]->arg
, &metric
))
7311 return CMD_WARNING_CONFIG_FAILED
;
7313 /* Get metric type. */
7314 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7315 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7316 return CMD_WARNING_CONFIG_FAILED
;
7319 else if (argv_find(argv
, argc
, "WORD", &idx
))
7320 ospf_routemap_set(red
, argv
[idx
]->arg
);
7322 ospf_routemap_unset(red
);
7324 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
7328 DEFUN (no_ospf_default_information_originate
,
7329 no_ospf_default_information_originate_cmd
,
7330 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7332 "Control distribution of default information\n"
7333 "Distribute a default route\n"
7334 "Always advertise default route\n"
7335 "OSPF default metric\n"
7337 "OSPF metric type for default routes\n"
7338 "Set OSPF External Type 1/2 metrics\n"
7339 "Route map reference\n"
7340 "Pointer to route-map entries\n")
7342 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7343 struct prefix_ipv4 p
;
7344 struct ospf_external
*ext
;
7345 struct ospf_redist
*red
;
7348 p
.prefix
.s_addr
= 0;
7351 ospf_external_lsa_flush(ospf
, DEFAULT_ROUTE
, &p
, 0);
7353 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0))
7354 && EXTERNAL_INFO(ext
)) {
7355 ospf_external_info_delete(DEFAULT_ROUTE
, 0, p
);
7356 ospf_external_del(DEFAULT_ROUTE
, 0);
7359 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7363 ospf_routemap_unset(red
);
7364 return ospf_redistribute_default_unset(ospf
);
7367 DEFUN (ospf_default_metric
,
7368 ospf_default_metric_cmd
,
7369 "default-metric (0-16777214)",
7370 "Set metric of redistributed routes\n"
7373 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7377 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
7378 return CMD_WARNING_CONFIG_FAILED
;
7380 ospf
->default_metric
= metric
;
7385 DEFUN (no_ospf_default_metric
,
7386 no_ospf_default_metric_cmd
,
7387 "no default-metric [(0-16777214)]",
7389 "Set metric of redistributed routes\n"
7392 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7394 ospf
->default_metric
= -1;
7400 DEFUN (ospf_distance
,
7403 "Administrative distance\n"
7404 "OSPF Administrative distance\n")
7406 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7409 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
7414 DEFUN (no_ospf_distance
,
7415 no_ospf_distance_cmd
,
7416 "no distance (1-255)",
7418 "Administrative distance\n"
7419 "OSPF Administrative distance\n")
7421 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7423 ospf
->distance_all
= 0;
7428 DEFUN (no_ospf_distance_ospf
,
7429 no_ospf_distance_ospf_cmd
,
7430 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7432 "Administrative distance\n"
7433 "OSPF administrative distance\n"
7434 "Intra-area routes\n"
7435 "Distance for intra-area routes\n"
7436 "Inter-area routes\n"
7437 "Distance for inter-area routes\n"
7439 "Distance for external routes\n")
7441 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7447 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
7448 idx
= ospf
->distance_intra
= 0;
7449 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
7450 idx
= ospf
->distance_inter
= 0;
7451 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
7452 ospf
->distance_external
= 0;
7457 DEFUN (ospf_distance_ospf
,
7458 ospf_distance_ospf_cmd
,
7459 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7460 "Administrative distance\n"
7461 "OSPF administrative distance\n"
7462 "Intra-area routes\n"
7463 "Distance for intra-area routes\n"
7464 "Inter-area routes\n"
7465 "Distance for inter-area routes\n"
7467 "Distance for external routes\n")
7469 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7472 if (argv_find(argv
, argc
, "intra-area", &idx
))
7473 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7475 if (argv_find(argv
, argc
, "inter-area", &idx
))
7476 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7478 if (argv_find(argv
, argc
, "external", &idx
))
7479 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7485 DEFUN (ospf_distance_source
,
7486 ospf_distance_source_cmd
,
7487 "distance (1-255) A.B.C.D/M",
7488 "Administrative distance\n"
7490 "IP source prefix\n")
7492 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7494 int idx_ipv4_prefixlen
= 2;
7499 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7504 DEFUN (no_ospf_distance_source
,
7505 no_ospf_distance_source_cmd
,
7506 "no distance (1-255) A.B.C.D/M",
7508 "Administrative distance\n"
7510 "IP source prefix\n")
7512 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7514 int idx_ipv4_prefixlen
= 3;
7519 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7524 DEFUN (ospf_distance_source_access_list
,
7525 ospf_distance_source_access_list_cmd
,
7526 "distance (1-255) A.B.C.D/M WORD",
7527 "Administrative distance\n"
7529 "IP source prefix\n"
7530 "Access list name\n")
7532 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7534 int idx_ipv4_prefixlen
= 2;
7540 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7545 DEFUN (no_ospf_distance_source_access_list
,
7546 no_ospf_distance_source_access_list_cmd
,
7547 "no distance (1-255) A.B.C.D/M WORD",
7549 "Administrative distance\n"
7551 "IP source prefix\n"
7552 "Access list name\n")
7554 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7556 int idx_ipv4_prefixlen
= 3;
7562 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7568 DEFUN (ip_ospf_mtu_ignore
,
7569 ip_ospf_mtu_ignore_addr_cmd
,
7570 "ip ospf mtu-ignore [A.B.C.D]",
7572 "OSPF interface commands\n"
7573 "Disable MTU mismatch detection on this interface\n"
7574 "Address of interface")
7576 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7578 struct in_addr addr
;
7581 struct ospf_if_params
*params
;
7582 params
= IF_DEF_PARAMS(ifp
);
7585 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7588 "Please specify interface address by A.B.C.D\n");
7589 return CMD_WARNING_CONFIG_FAILED
;
7591 params
= ospf_get_if_params(ifp
, addr
);
7592 ospf_if_update_params(ifp
, addr
);
7594 params
->mtu_ignore
= 1;
7595 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7596 SET_IF_PARAM(params
, mtu_ignore
);
7598 UNSET_IF_PARAM(params
, mtu_ignore
);
7599 if (params
!= IF_DEF_PARAMS(ifp
)) {
7600 ospf_free_if_params(ifp
, addr
);
7601 ospf_if_update_params(ifp
, addr
);
7607 DEFUN (no_ip_ospf_mtu_ignore
,
7608 no_ip_ospf_mtu_ignore_addr_cmd
,
7609 "no ip ospf mtu-ignore [A.B.C.D]",
7611 "OSPF interface commands\n"
7612 "Disable MTU mismatch detection on this interface\n"
7613 "Address of interface")
7615 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7617 struct in_addr addr
;
7620 struct ospf_if_params
*params
;
7621 params
= IF_DEF_PARAMS(ifp
);
7624 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7627 "Please specify interface address by A.B.C.D\n");
7628 return CMD_WARNING_CONFIG_FAILED
;
7630 params
= ospf_get_if_params(ifp
, addr
);
7631 ospf_if_update_params(ifp
, addr
);
7633 params
->mtu_ignore
= 0;
7634 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7635 SET_IF_PARAM(params
, mtu_ignore
);
7637 UNSET_IF_PARAM(params
, mtu_ignore
);
7638 if (params
!= IF_DEF_PARAMS(ifp
)) {
7639 ospf_free_if_params(ifp
, addr
);
7640 ospf_if_update_params(ifp
, addr
);
7647 DEFUN (ospf_max_metric_router_lsa_admin
,
7648 ospf_max_metric_router_lsa_admin_cmd
,
7649 "max-metric router-lsa administrative",
7650 "OSPF maximum / infinite-distance metric\n"
7651 "Advertise own Router-LSA with infinite distance (stub router)\n"
7652 "Administratively applied, for an indefinite period\n")
7654 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7655 struct listnode
*ln
;
7656 struct ospf_area
*area
;
7658 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7659 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7661 if (!CHECK_FLAG(area
->stub_router_state
,
7662 OSPF_AREA_IS_STUB_ROUTED
))
7663 ospf_router_lsa_update_area(area
);
7666 /* Allows for areas configured later to get the property */
7667 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7672 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7673 no_ospf_max_metric_router_lsa_admin_cmd
,
7674 "no max-metric router-lsa administrative",
7676 "OSPF maximum / infinite-distance metric\n"
7677 "Advertise own Router-LSA with infinite distance (stub router)\n"
7678 "Administratively applied, for an indefinite period\n")
7680 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7681 struct listnode
*ln
;
7682 struct ospf_area
*area
;
7684 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7685 UNSET_FLAG(area
->stub_router_state
,
7686 OSPF_AREA_ADMIN_STUB_ROUTED
);
7688 /* Don't trample on the start-up stub timer */
7689 if (CHECK_FLAG(area
->stub_router_state
,
7690 OSPF_AREA_IS_STUB_ROUTED
)
7691 && !area
->t_stub_router
) {
7692 UNSET_FLAG(area
->stub_router_state
,
7693 OSPF_AREA_IS_STUB_ROUTED
);
7694 ospf_router_lsa_update_area(area
);
7697 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7701 DEFUN (ospf_max_metric_router_lsa_startup
,
7702 ospf_max_metric_router_lsa_startup_cmd
,
7703 "max-metric router-lsa on-startup (5-86400)",
7704 "OSPF maximum / infinite-distance metric\n"
7705 "Advertise own Router-LSA with infinite distance (stub router)\n"
7706 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7707 "Time (seconds) to advertise self as stub-router\n")
7709 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7711 unsigned int seconds
;
7714 vty_out(vty
, "%% Must supply stub-router period");
7715 return CMD_WARNING_CONFIG_FAILED
;
7718 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7720 ospf
->stub_router_startup_time
= seconds
;
7725 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7726 no_ospf_max_metric_router_lsa_startup_cmd
,
7727 "no max-metric router-lsa on-startup [(5-86400)]",
7729 "OSPF maximum / infinite-distance metric\n"
7730 "Advertise own Router-LSA with infinite distance (stub router)\n"
7731 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7732 "Time (seconds) to advertise self as stub-router\n")
7734 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7735 struct listnode
*ln
;
7736 struct ospf_area
*area
;
7738 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7740 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7741 SET_FLAG(area
->stub_router_state
,
7742 OSPF_AREA_WAS_START_STUB_ROUTED
);
7743 OSPF_TIMER_OFF(area
->t_stub_router
);
7745 /* Don't trample on admin stub routed */
7746 if (!CHECK_FLAG(area
->stub_router_state
,
7747 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7748 UNSET_FLAG(area
->stub_router_state
,
7749 OSPF_AREA_IS_STUB_ROUTED
);
7750 ospf_router_lsa_update_area(area
);
7757 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7758 ospf_max_metric_router_lsa_shutdown_cmd
,
7759 "max-metric router-lsa on-shutdown (5-100)",
7760 "OSPF maximum / infinite-distance metric\n"
7761 "Advertise own Router-LSA with infinite distance (stub router)\n"
7762 "Advertise stub-router prior to full shutdown of OSPF\n"
7763 "Time (seconds) to wait till full shutdown\n")
7765 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7767 unsigned int seconds
;
7770 vty_out(vty
, "%% Must supply stub-router shutdown period");
7771 return CMD_WARNING_CONFIG_FAILED
;
7774 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7776 ospf
->stub_router_shutdown_time
= seconds
;
7781 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7782 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7783 "no max-metric router-lsa on-shutdown [(5-100)]",
7785 "OSPF maximum / infinite-distance metric\n"
7786 "Advertise own Router-LSA with infinite distance (stub router)\n"
7787 "Advertise stub-router prior to full shutdown of OSPF\n"
7788 "Time (seconds) to wait till full shutdown\n")
7790 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7792 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7797 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
7799 struct listnode
*ln
;
7800 struct ospf_area
*area
;
7802 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7803 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
7804 ospf
->stub_router_startup_time
);
7805 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7806 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
7807 ospf
->stub_router_shutdown_time
);
7808 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7809 if (CHECK_FLAG(area
->stub_router_state
,
7810 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7811 vty_out(vty
, " max-metric router-lsa administrative\n");
7818 static void show_ip_ospf_route_network(struct vty
*vty
, struct route_table
*rt
)
7820 struct route_node
*rn
;
7821 struct ospf_route
* or ;
7822 struct listnode
*pnode
, *pnnode
;
7823 struct ospf_path
*path
;
7825 vty_out(vty
, "============ OSPF network routing table ============\n");
7827 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
7828 if ((or = rn
->info
) != NULL
) {
7830 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
7833 switch (or->path_type
) {
7834 case OSPF_PATH_INTER_AREA
:
7835 if (or->type
== OSPF_DESTINATION_NETWORK
)
7837 "N IA %-18s [%d] area: %s\n",
7839 inet_ntoa(or->u
.std
.area_id
));
7840 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7842 "D IA %-18s Discard entry\n",
7845 case OSPF_PATH_INTRA_AREA
:
7846 vty_out(vty
, "N %-18s [%d] area: %s\n",
7848 inet_ntoa(or->u
.std
.area_id
));
7854 if (or->type
== OSPF_DESTINATION_NETWORK
)
7855 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
7857 if (if_lookup_by_index(path
->ifindex
,
7859 if (path
->nexthop
.s_addr
== 0)
7861 "%24s directly attached to %s\n",
7868 "%24s via %s, %s\n",
7881 static void show_ip_ospf_route_router(struct vty
*vty
, struct route_table
*rtrs
)
7883 struct route_node
*rn
;
7884 struct ospf_route
* or ;
7885 struct listnode
*pnode
;
7886 struct listnode
*node
;
7887 struct ospf_path
*path
;
7889 vty_out(vty
, "============ OSPF router routing table =============\n");
7890 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
))
7894 vty_out(vty
, "R %-15s ",
7895 inet_ntoa(rn
->p
.u
.prefix4
));
7897 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
,
7900 vty_out(vty
, "%24s", "");
7903 vty_out(vty
, "%s [%d] area: %s",
7904 (or->path_type
== OSPF_PATH_INTER_AREA
7907 or->cost
, inet_ntoa(or->u
.std
.area_id
));
7909 vty_out(vty
, "%s%s\n",
7910 (or->u
.std
.flags
& ROUTER_LSA_BORDER
7913 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
7917 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
,
7919 if (if_lookup_by_index(path
->ifindex
,
7921 if (path
->nexthop
.s_addr
== 0)
7923 "%24s directly attached to %s\n",
7930 "%24s via %s, %s\n",
7944 static void show_ip_ospf_route_external(struct vty
*vty
, struct route_table
*rt
)
7946 struct route_node
*rn
;
7947 struct ospf_route
*er
;
7948 struct listnode
*pnode
, *pnnode
;
7949 struct ospf_path
*path
;
7951 vty_out(vty
, "============ OSPF external routing table ===========\n");
7952 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
7953 if ((er
= rn
->info
) != NULL
) {
7955 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
7958 switch (er
->path_type
) {
7959 case OSPF_PATH_TYPE1_EXTERNAL
:
7961 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
7963 buf1
, er
->cost
, er
->u
.ext
.tag
);
7965 case OSPF_PATH_TYPE2_EXTERNAL
:
7967 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
7969 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
7974 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
,
7976 if (if_lookup_by_index(path
->ifindex
,
7978 if (path
->nexthop
.s_addr
== 0)
7980 "%24s directly attached to %s\n",
7987 "%24s via %s, %s\n",
8000 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
8004 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
8006 if (ospf
->new_table
== NULL
) {
8007 vty_out(vty
, "No OSPF routing information exist\n");
8011 /* Show Network routes.
8012 show_ip_ospf_route_network (vty, ospf->new_table); */
8014 /* Show Router routes. */
8015 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8022 DEFUN (show_ip_ospf_border_routers
,
8023 show_ip_ospf_border_routers_cmd
,
8024 "show ip ospf border-routers",
8027 "OSPF information\n"
8028 "Show all the ABR's and ASBR's\n")
8032 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8035 return show_ip_ospf_border_routers_common(vty
, ospf
);
8038 DEFUN (show_ip_ospf_instance_border_routers
,
8039 show_ip_ospf_instance_border_routers_cmd
,
8040 "show ip ospf (1-65535) border-routers",
8043 "OSPF information\n"
8045 "Show all the ABR's and ASBR's\n")
8049 u_short instance
= 0;
8051 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8052 ospf
= ospf_lookup_instance(instance
);
8054 return CMD_NOT_MY_INSTANCE
;
8056 if (!ospf
->oi_running
)
8059 return show_ip_ospf_border_routers_common(vty
, ospf
);
8062 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
)
8065 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
8067 if (ospf
->new_table
== NULL
) {
8068 vty_out(vty
, "No OSPF routing information exist\n");
8072 /* Show Network routes. */
8073 show_ip_ospf_route_network(vty
, ospf
->new_table
);
8075 /* Show Router routes. */
8076 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8078 /* Show AS External routes. */
8079 show_ip_ospf_route_external(vty
, ospf
->old_external_route
);
8086 DEFUN (show_ip_ospf_route
,
8087 show_ip_ospf_route_cmd
,
8088 "show ip ospf route",
8091 "OSPF information\n"
8092 "OSPF routing table\n")
8096 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8099 return show_ip_ospf_route_common(vty
, ospf
);
8102 DEFUN (show_ip_ospf_instance_route
,
8103 show_ip_ospf_instance_route_cmd
,
8104 "show ip ospf (1-65535) route",
8107 "OSPF information\n"
8109 "OSPF routing table\n")
8113 u_short instance
= 0;
8115 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8116 ospf
= ospf_lookup_instance(instance
);
8118 return CMD_NOT_MY_INSTANCE
;
8120 if (!ospf
->oi_running
)
8123 return show_ip_ospf_route_common(vty
, ospf
);
8126 const char *ospf_abr_type_str
[] = {"unknown", "standard", "ibm", "cisco",
8129 const char *ospf_shortcut_mode_str
[] = {"default", "enable", "disable"};
8131 const char *ospf_int_type_str
[] = {"unknown", /* should never be used. */
8132 "point-to-point", "broadcast",
8133 "non-broadcast", "point-to-multipoint",
8134 "virtual-link", /* should never be used. */
8137 /* Configuration write function for ospfd. */
8138 static int config_write_interface(struct vty
*vty
)
8140 struct listnode
*n1
, *n2
;
8141 struct interface
*ifp
;
8142 struct crypt_key
*ck
;
8144 struct route_node
*rn
= NULL
;
8145 struct ospf_if_params
*params
;
8146 struct ospf
*ospf
= ospf_lookup();
8148 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), n1
, ifp
)) {
8149 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
8152 if (ifp
->ifindex
== IFINDEX_DELETED
)
8155 vty_out(vty
, "!\n");
8156 vty_out(vty
, "interface %s\n", ifp
->name
);
8158 vty_out(vty
, " description %s\n", ifp
->desc
);
8162 params
= IF_DEF_PARAMS(ifp
);
8165 /* Interface Network print. */
8166 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
8167 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
8168 if (params
->type
!= ospf_default_iftype(ifp
)) {
8169 vty_out(vty
, " ip ospf network %s",
8172 if (params
!= IF_DEF_PARAMS(ifp
))
8180 /* OSPF interface authentication print */
8181 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
8182 && params
->auth_type
!= OSPF_AUTH_NOTSET
) {
8183 const char *auth_str
;
8185 /* Translation tables are not that much help
8187 of the simple option */
8188 switch (params
->auth_type
) {
8190 case OSPF_AUTH_NULL
:
8194 case OSPF_AUTH_SIMPLE
:
8198 case OSPF_AUTH_CRYPTOGRAPHIC
:
8199 auth_str
= " message-digest";
8207 vty_out(vty
, " ip ospf authentication%s",
8209 if (params
!= IF_DEF_PARAMS(ifp
))
8211 inet_ntoa(rn
->p
.u
.prefix4
));
8215 /* Simple Authentication Password print. */
8216 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
8217 && params
->auth_simple
[0] != '\0') {
8218 vty_out(vty
, " ip ospf authentication-key %s",
8219 params
->auth_simple
);
8220 if (params
!= IF_DEF_PARAMS(ifp
))
8222 inet_ntoa(rn
->p
.u
.prefix4
));
8226 /* Cryptographic Authentication Key print. */
8227 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
, n2
, ck
)) {
8229 " ip ospf message-digest-key %d md5 %s",
8230 ck
->key_id
, ck
->auth_key
);
8231 if (params
!= IF_DEF_PARAMS(ifp
))
8233 inet_ntoa(rn
->p
.u
.prefix4
));
8237 /* Interface Output Cost print. */
8238 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
8239 vty_out(vty
, " ip ospf cost %u",
8240 params
->output_cost_cmd
);
8241 if (params
!= IF_DEF_PARAMS(ifp
))
8243 inet_ntoa(rn
->p
.u
.prefix4
));
8247 /* Hello Interval print. */
8248 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
8249 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
8250 vty_out(vty
, " ip ospf hello-interval %u",
8252 if (params
!= IF_DEF_PARAMS(ifp
))
8254 inet_ntoa(rn
->p
.u
.prefix4
));
8259 /* Router Dead Interval print. */
8260 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
8262 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
8263 vty_out(vty
, " ip ospf dead-interval ");
8266 if (OSPF_IF_PARAM_CONFIGURED(params
,
8269 "minimal hello-multiplier %d",
8270 params
->fast_hello
);
8272 vty_out(vty
, "%u", params
->v_wait
);
8274 if (params
!= IF_DEF_PARAMS(ifp
))
8276 inet_ntoa(rn
->p
.u
.prefix4
));
8280 /* Router Priority print. */
8281 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
8283 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
8284 vty_out(vty
, " ip ospf priority %u",
8286 if (params
!= IF_DEF_PARAMS(ifp
))
8288 inet_ntoa(rn
->p
.u
.prefix4
));
8292 /* Retransmit Interval print. */
8293 if (OSPF_IF_PARAM_CONFIGURED(params
,
8294 retransmit_interval
)
8295 && params
->retransmit_interval
8296 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
8297 vty_out(vty
, " ip ospf retransmit-interval %u",
8298 params
->retransmit_interval
);
8299 if (params
!= IF_DEF_PARAMS(ifp
))
8301 inet_ntoa(rn
->p
.u
.prefix4
));
8305 /* Transmit Delay print. */
8306 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
8307 && params
->transmit_delay
8308 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
8309 vty_out(vty
, " ip ospf transmit-delay %u",
8310 params
->transmit_delay
);
8311 if (params
!= IF_DEF_PARAMS(ifp
))
8313 inet_ntoa(rn
->p
.u
.prefix4
));
8318 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8320 vty_out(vty
, " ip ospf %d",
8323 vty_out(vty
, " ip ospf");
8326 size_t buflen
= MAX(strlen("4294967295"),
8327 strlen("255.255.255.255"));
8329 area_id2str(buf
, sizeof(buf
), ¶ms
->if_area
,
8330 params
->if_area_id_fmt
);
8331 vty_out(vty
, " area %s", buf
);
8332 if (params
!= IF_DEF_PARAMS(ifp
))
8334 inet_ntoa(rn
->p
.u
.prefix4
));
8339 ospf_bfd_write_config(vty
, params
);
8341 /* MTU ignore print. */
8342 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
8343 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
8344 if (params
->mtu_ignore
== 0)
8345 vty_out(vty
, " no ip ospf mtu-ignore");
8347 vty_out(vty
, " ip ospf mtu-ignore");
8348 if (params
!= IF_DEF_PARAMS(ifp
))
8350 inet_ntoa(rn
->p
.u
.prefix4
));
8357 rn
= route_top(IF_OIFS_PARAMS(ifp
));
8359 rn
= route_next(rn
);
8369 ospf_opaque_config_write_if(vty
, ifp
);
8375 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
8377 struct route_node
*rn
;
8378 u_char buf
[INET_ADDRSTRLEN
];
8380 /* `network area' print. */
8381 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
8383 struct ospf_network
*n
= rn
->info
;
8385 memset(buf
, 0, INET_ADDRSTRLEN
);
8387 /* Create Area ID string by specified Area ID format. */
8388 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8389 strncpy((char *)buf
, inet_ntoa(n
->area_id
),
8392 sprintf((char *)buf
, "%lu",
8393 (unsigned long int)ntohl(
8394 n
->area_id
.s_addr
));
8396 /* Network print. */
8397 vty_out(vty
, " network %s/%d area %s\n",
8398 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8405 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
8407 struct listnode
*node
;
8408 struct ospf_area
*area
;
8409 u_char buf
[INET_ADDRSTRLEN
];
8411 /* Area configuration print. */
8412 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
8413 struct route_node
*rn1
;
8415 area_id2str((char *)buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8418 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
8419 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8420 vty_out(vty
, " area %s authentication\n", buf
);
8423 " area %s authentication message-digest\n",
8427 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8428 vty_out(vty
, " area %s shortcut %s\n", buf
,
8429 ospf_shortcut_mode_str
8430 [area
->shortcut_configured
]);
8432 if ((area
->external_routing
== OSPF_AREA_STUB
)
8433 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
8434 if (area
->external_routing
== OSPF_AREA_STUB
)
8435 vty_out(vty
, " area %s stub", buf
);
8436 else if (area
->external_routing
== OSPF_AREA_NSSA
) {
8437 vty_out(vty
, " area %s nssa", buf
);
8438 switch (area
->NSSATranslatorRole
) {
8439 case OSPF_NSSA_ROLE_NEVER
:
8440 vty_out(vty
, " translate-never");
8442 case OSPF_NSSA_ROLE_ALWAYS
:
8443 vty_out(vty
, " translate-always");
8445 case OSPF_NSSA_ROLE_CANDIDATE
:
8447 vty_out(vty
, " translate-candidate");
8451 if (area
->no_summary
)
8452 vty_out(vty
, " no-summary");
8456 if (area
->default_cost
!= 1)
8457 vty_out(vty
, " area %s default-cost %d\n", buf
,
8458 area
->default_cost
);
8461 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
8463 struct ospf_area_range
*range
= rn1
->info
;
8465 vty_out(vty
, " area %s range %s/%d", buf
,
8466 inet_ntoa(rn1
->p
.u
.prefix4
),
8469 if (range
->cost_config
8470 != OSPF_AREA_RANGE_COST_UNSPEC
)
8471 vty_out(vty
, " cost %d",
8472 range
->cost_config
);
8474 if (!CHECK_FLAG(range
->flags
,
8475 OSPF_AREA_RANGE_ADVERTISE
))
8476 vty_out(vty
, " not-advertise");
8478 if (CHECK_FLAG(range
->flags
,
8479 OSPF_AREA_RANGE_SUBSTITUTE
))
8480 vty_out(vty
, " substitute %s/%d",
8481 inet_ntoa(range
->subst_addr
),
8482 range
->subst_masklen
);
8487 if (EXPORT_NAME(area
))
8488 vty_out(vty
, " area %s export-list %s\n", buf
,
8491 if (IMPORT_NAME(area
))
8492 vty_out(vty
, " area %s import-list %s\n", buf
,
8495 if (PREFIX_NAME_IN(area
))
8496 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
8497 PREFIX_NAME_IN(area
));
8499 if (PREFIX_NAME_OUT(area
))
8500 vty_out(vty
, " area %s filter-list prefix %s out\n",
8501 buf
, PREFIX_NAME_OUT(area
));
8507 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
8509 struct ospf_nbr_nbma
*nbr_nbma
;
8510 struct route_node
*rn
;
8512 /* Static Neighbor configuration print. */
8513 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
8514 if ((nbr_nbma
= rn
->info
)) {
8515 vty_out(vty
, " neighbor %s", inet_ntoa(nbr_nbma
->addr
));
8517 if (nbr_nbma
->priority
8518 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8519 vty_out(vty
, " priority %d",
8520 nbr_nbma
->priority
);
8522 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8523 vty_out(vty
, " poll-interval %d",
8532 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
8534 struct listnode
*node
;
8535 struct ospf_vl_data
*vl_data
;
8536 char buf
[INET_ADDRSTRLEN
];
8538 /* Virtual-Link print */
8539 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
8540 struct listnode
*n2
;
8541 struct crypt_key
*ck
;
8542 struct ospf_interface
*oi
;
8544 if (vl_data
!= NULL
) {
8545 memset(buf
, 0, INET_ADDRSTRLEN
);
8547 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
8548 vl_data
->vl_area_id_fmt
);
8549 oi
= vl_data
->vl_oi
;
8552 if (OSPF_IF_PARAM(oi
, v_hello
)
8553 != OSPF_HELLO_INTERVAL_DEFAULT
8554 || OSPF_IF_PARAM(oi
, v_wait
)
8555 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
8556 || OSPF_IF_PARAM(oi
, retransmit_interval
)
8557 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
8558 || OSPF_IF_PARAM(oi
, transmit_delay
)
8559 != OSPF_TRANSMIT_DELAY_DEFAULT
)
8561 " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
8562 buf
, inet_ntoa(vl_data
->vl_peer
),
8563 OSPF_IF_PARAM(oi
, v_hello
),
8564 OSPF_IF_PARAM(oi
, retransmit_interval
),
8565 OSPF_IF_PARAM(oi
, transmit_delay
),
8566 OSPF_IF_PARAM(oi
, v_wait
));
8568 vty_out(vty
, " area %s virtual-link %s\n", buf
,
8569 inet_ntoa(vl_data
->vl_peer
));
8571 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
8574 " area %s virtual-link %s authentication-key %s\n",
8575 buf
, inet_ntoa(vl_data
->vl_peer
),
8576 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8579 for (ALL_LIST_ELEMENTS_RO(
8580 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8584 " area %s virtual-link %s"
8585 " message-digest-key %d md5 %s\n",
8586 buf
, inet_ntoa(vl_data
->vl_peer
),
8587 ck
->key_id
, ck
->auth_key
);
8595 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
8599 /* redistribute print. */
8600 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
8601 struct list
*red_list
;
8602 struct listnode
*node
;
8603 struct ospf_redist
*red
;
8605 red_list
= ospf
->redist
[type
];
8609 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
8610 vty_out(vty
, " redistribute %s",
8611 zebra_route_string(type
));
8613 vty_out(vty
, " %d", red
->instance
);
8615 if (red
->dmetric
.value
>= 0)
8616 vty_out(vty
, " metric %d", red
->dmetric
.value
);
8618 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8619 vty_out(vty
, " metric-type 1");
8621 if (ROUTEMAP_NAME(red
))
8622 vty_out(vty
, " route-map %s",
8623 ROUTEMAP_NAME(red
));
8632 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
8634 if (ospf
->default_metric
!= -1)
8635 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
8639 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
8642 struct ospf_redist
*red
;
8645 /* distribute-list print. */
8646 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8647 if (DISTRIBUTE_NAME(ospf
, type
))
8648 vty_out(vty
, " distribute-list %s out %s\n",
8649 DISTRIBUTE_NAME(ospf
, type
),
8650 zebra_route_string(type
));
8652 /* default-information print. */
8653 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
8654 vty_out(vty
, " default-information originate");
8655 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8656 vty_out(vty
, " always");
8658 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8660 if (red
->dmetric
.value
>= 0)
8661 vty_out(vty
, " metric %d",
8662 red
->dmetric
.value
);
8663 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8664 vty_out(vty
, " metric-type 1");
8666 if (ROUTEMAP_NAME(red
))
8667 vty_out(vty
, " route-map %s",
8668 ROUTEMAP_NAME(red
));
8678 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
8680 struct route_node
*rn
;
8681 struct ospf_distance
*odistance
;
8683 if (ospf
->distance_all
)
8684 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
8686 if (ospf
->distance_intra
|| ospf
->distance_inter
8687 || ospf
->distance_external
) {
8688 vty_out(vty
, " distance ospf");
8690 if (ospf
->distance_intra
)
8691 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
8692 if (ospf
->distance_inter
)
8693 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
8694 if (ospf
->distance_external
)
8695 vty_out(vty
, " external %d", ospf
->distance_external
);
8700 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
8701 if ((odistance
= rn
->info
) != NULL
) {
8702 vty_out(vty
, " distance %d %s/%d %s\n",
8703 odistance
->distance
, inet_ntoa(rn
->p
.u
.prefix4
),
8705 odistance
->access_list
? odistance
->access_list
8711 /* OSPF configuration write function. */
8712 static int ospf_config_write(struct vty
*vty
)
8715 struct interface
*ifp
;
8716 struct ospf_interface
*oi
;
8717 struct listnode
*node
;
8720 ospf
= ospf_lookup();
8721 if (ospf
!= NULL
&& ospf
->oi_running
) {
8722 /* `router ospf' print. */
8724 vty_out(vty
, "router ospf %d\n", ospf
->instance
);
8726 vty_out(vty
, "router ospf\n");
8730 if (!ospf
->networks
)
8733 /* Router ID print. */
8734 if (ospf
->router_id_static
.s_addr
!= 0)
8735 vty_out(vty
, " ospf router-id %s\n",
8736 inet_ntoa(ospf
->router_id_static
));
8738 /* ABR type print. */
8739 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8740 vty_out(vty
, " ospf abr-type %s\n",
8741 ospf_abr_type_str
[ospf
->abr_type
]);
8743 /* log-adjacency-changes flag print. */
8744 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
8745 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8746 vty_out(vty
, " log-adjacency-changes detail\n");
8747 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8748 vty_out(vty
, " log-adjacency-changes\n");
8749 } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
) {
8750 vty_out(vty
, " no log-adjacency-changes\n");
8753 /* RFC1583 compatibility flag print -- Compatible with CISCO
8755 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8756 vty_out(vty
, " compatible rfc1583\n");
8758 /* auto-cost reference-bandwidth configuration. */
8759 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
8761 "! Important: ensure reference bandwidth "
8762 "is consistent across all routers\n");
8763 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
8764 ospf
->ref_bandwidth
);
8767 /* SPF timers print. */
8768 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
8769 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
8770 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8771 vty_out(vty
, " timers throttle spf %d %d %d\n",
8772 ospf
->spf_delay
, ospf
->spf_holdtime
,
8773 ospf
->spf_max_holdtime
);
8775 /* LSA timers print. */
8776 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8777 vty_out(vty
, " timers throttle lsa all %d\n",
8778 ospf
->min_ls_interval
);
8779 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8780 vty_out(vty
, " timers lsa min-arrival %d\n",
8781 ospf
->min_ls_arrival
);
8783 /* Write multiplier print. */
8784 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8785 vty_out(vty
, " ospf write-multiplier %d\n",
8786 ospf
->write_oi_count
);
8788 /* Max-metric router-lsa print */
8789 config_write_stub_router(vty
, ospf
);
8791 /* SPF refresh parameters print. */
8792 if (ospf
->lsa_refresh_interval
8793 != OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8794 vty_out(vty
, " refresh timer %d\n",
8795 ospf
->lsa_refresh_interval
);
8797 /* Redistribute information print. */
8798 config_write_ospf_redistribute(vty
, ospf
);
8800 /* passive-interface print. */
8801 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8802 vty_out(vty
, " passive-interface default\n");
8804 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
8805 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
8807 && IF_DEF_PARAMS(ifp
)->passive_interface
8808 != ospf
->passive_interface_default
) {
8809 vty_out(vty
, " %spassive-interface %s\n",
8810 IF_DEF_PARAMS(ifp
)->passive_interface
8815 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
8816 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
,
8819 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
8820 passive_interface
)) {
8821 if (oi
->params
->passive_interface
8822 == IF_DEF_PARAMS(oi
->ifp
)
8823 ->passive_interface
)
8825 } else if (oi
->params
->passive_interface
8826 == ospf
->passive_interface_default
)
8829 vty_out(vty
, " %spassive-interface %s %s\n",
8830 oi
->params
->passive_interface
? "" : "no ",
8832 inet_ntoa(oi
->address
->u
.prefix4
));
8835 /* Network area print. */
8836 config_write_network_area(vty
, ospf
);
8838 /* Area config print. */
8839 config_write_ospf_area(vty
, ospf
);
8841 /* static neighbor print. */
8842 config_write_ospf_nbr_nbma(vty
, ospf
);
8844 /* Virtual-Link print. */
8845 config_write_virtual_link(vty
, ospf
);
8847 /* Default metric configuration. */
8848 config_write_ospf_default_metric(vty
, ospf
);
8850 /* Distribute-list and default-information print. */
8851 config_write_ospf_distribute(vty
, ospf
);
8853 /* Distance configuration. */
8854 config_write_ospf_distance(vty
, ospf
);
8856 ospf_opaque_config_write_router(vty
, ospf
);
8862 void ospf_vty_show_init(void)
8864 /* "show ip ospf" commands. */
8865 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
8867 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8869 /* "show ip ospf database" commands. */
8870 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8872 install_element(VIEW_NODE
,
8873 &show_ip_ospf_instance_database_type_adv_router_cmd
);
8874 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8875 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8877 /* "show ip ospf interface" commands. */
8878 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8880 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8882 /* "show ip ospf neighbor" commands. */
8883 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8884 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8885 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8886 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8887 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8888 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8889 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8891 install_element(VIEW_NODE
,
8892 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8893 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8894 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8895 install_element(VIEW_NODE
,
8896 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8897 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8898 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8899 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8901 /* "show ip ospf route" commands. */
8902 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
8903 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8905 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8906 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8910 /* ospfd's interface node. */
8911 static struct cmd_node interface_node
= {INTERFACE_NODE
, "%s(config-if)# ", 1};
8913 /* Initialization of OSPF interface. */
8914 static void ospf_vty_if_init(void)
8916 /* Install interface node. */
8917 install_node(&interface_node
, config_write_interface
);
8920 /* "ip ospf authentication" commands. */
8921 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8922 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8923 install_element(INTERFACE_NODE
,
8924 &no_ip_ospf_authentication_args_addr_cmd
);
8925 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8926 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8927 install_element(INTERFACE_NODE
,
8928 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8929 install_element(INTERFACE_NODE
,
8930 &no_ospf_authentication_key_authkey_addr_cmd
);
8932 /* "ip ospf message-digest-key" commands. */
8933 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8934 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8936 /* "ip ospf cost" commands. */
8937 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8938 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8940 /* "ip ospf mtu-ignore" commands. */
8941 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8942 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8944 /* "ip ospf dead-interval" commands. */
8945 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8946 install_element(INTERFACE_NODE
,
8947 &ip_ospf_dead_interval_minimal_addr_cmd
);
8948 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8950 /* "ip ospf hello-interval" commands. */
8951 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
8952 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
8954 /* "ip ospf network" commands. */
8955 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
8956 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
8958 /* "ip ospf priority" commands. */
8959 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
8960 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
8962 /* "ip ospf retransmit-interval" commands. */
8963 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
8964 install_element(INTERFACE_NODE
,
8965 &no_ip_ospf_retransmit_interval_addr_cmd
);
8967 /* "ip ospf transmit-delay" commands. */
8968 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
8969 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
8971 /* "ip ospf area" commands. */
8972 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
8973 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
8975 /* These commands are compatibitliy for previous version. */
8976 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
8977 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
8978 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
8979 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
8980 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
8981 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
8982 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
8983 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
8984 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
8985 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
8986 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
8987 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
8988 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
8989 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
8990 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
8991 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
8992 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
8995 static void ospf_vty_zebra_init(void)
8997 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
8998 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
8999 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9000 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9002 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9003 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9005 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
9006 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9008 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
9009 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
9011 install_element(OSPF_NODE
, &ospf_distance_cmd
);
9012 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
9013 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9014 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
9016 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9017 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9018 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9019 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9023 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# ", 1};
9025 static void ospf_interface_clear(struct interface
*ifp
)
9027 if (!if_is_operative(ifp
))
9030 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
9031 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9036 DEFUN (clear_ip_ospf_interface
,
9037 clear_ip_ospf_interface_cmd
,
9038 "clear ip ospf interface [IFNAME]",
9041 "OSPF information\n"
9042 "Interface information\n"
9046 struct interface
*ifp
;
9047 struct listnode
*node
;
9049 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9051 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
))
9052 ospf_interface_clear(ifp
);
9053 } else /* Interface name is specified. */
9055 if ((ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
,
9058 vty_out(vty
, "No such interface name\n");
9060 ospf_interface_clear(ifp
);
9066 void ospf_vty_clear_init(void)
9068 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9072 /* Install OSPF related vty commands. */
9073 void ospf_vty_init(void)
9075 /* Install ospf top node. */
9076 install_node(&ospf_node
, ospf_config_write
);
9078 /* "router ospf" commands. */
9079 install_element(CONFIG_NODE
, &router_ospf_cmd
);
9080 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
9083 install_default(OSPF_NODE
);
9085 /* "ospf router-id" commands. */
9086 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
9087 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
9088 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
9090 /* "passive-interface" commands. */
9091 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9092 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9094 /* "ospf abr-type" commands. */
9095 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
9096 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
9098 /* "ospf log-adjacency-changes" commands. */
9099 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9100 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9101 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9102 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9104 /* "ospf rfc1583-compatible" commands. */
9105 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9106 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9107 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9108 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9110 /* "network area" commands. */
9111 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
9112 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
9114 /* "area authentication" commands. */
9115 install_element(OSPF_NODE
,
9116 &ospf_area_authentication_message_digest_cmd
);
9117 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
9118 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9120 /* "area range" commands. */
9121 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
9122 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
9123 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9124 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
9125 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9126 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9128 /* "area virtual-link" commands. */
9129 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
9130 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9131 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9132 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9135 /* "area stub" commands. */
9136 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9137 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
9138 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9139 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
9141 /* "area nssa" commands. */
9142 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
9143 install_element(OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9144 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9145 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9146 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9148 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
9149 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9151 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
9152 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9154 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
9155 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9157 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
9158 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9160 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
9161 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9163 /* SPF timer commands */
9164 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9165 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9167 /* LSA timers commands */
9168 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9169 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9170 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
9171 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
9172 install_element(OSPF_NODE
, &ospf_timers_lsa_arrival_cmd
);
9173 install_element(OSPF_NODE
, &no_ospf_timers_lsa_arrival_cmd
);
9175 /* refresh timer commands */
9176 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
9177 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9179 /* max-metric commands */
9180 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9181 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9182 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9183 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9184 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9185 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9187 /* reference bandwidth commands */
9188 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9189 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9191 /* "neighbor" commands. */
9192 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
9193 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9194 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
9195 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9197 /* write multiplier commands */
9198 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
9199 install_element(OSPF_NODE
, &write_multiplier_cmd
);
9200 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9201 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
9203 /* Init interface related vty commands. */
9206 /* Init zebra related vty commands. */
9207 ospf_vty_zebra_init();