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;
139 ospf
= ospf_lookup();
141 vty_out(vty
, "There isn't active ospf instance \n");
142 return CMD_WARNING_CONFIG_FAILED
;
146 instance
= strtoul(argv
[2]->arg
, NULL
, 10);
148 /* The following logic to set the vty qobj index is in place to be able
149 to ignore the commands which dont belong to this instance. */
150 if (ospf
->instance
!= instance
)
151 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
153 if (IS_DEBUG_OSPF_EVENT
)
154 zlog_debug("Config command 'router ospf %d' received",
156 ospf
->oi_running
= 1;
157 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
158 ospf_router_id_update(ospf
);
164 DEFUN (no_router_ospf
,
166 "no router ospf [(1-65535)]",
168 "Enable a routing process\n"
169 "Start OSPF configuration\n"
173 u_short instance
= 0;
176 instance
= strtoul(argv
[3]->arg
, NULL
, 10);
178 ospf
= ospf_lookup_instance(instance
);
180 return CMD_NOT_MY_INSTANCE
;
188 DEFUN (ospf_router_id
,
190 "ospf router-id A.B.C.D",
191 "OSPF specific commands\n"
192 "router-id for the OSPF process\n"
193 "OSPF router-id in IP address format\n")
195 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
197 struct listnode
*node
;
198 struct ospf_area
*area
;
199 struct in_addr router_id
;
202 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
204 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
205 return CMD_WARNING_CONFIG_FAILED
;
208 ospf
->router_id_static
= router_id
;
210 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
211 if (area
->full_nbrs
) {
213 "For this router-id change to take effect,"
214 " save config and restart ospfd\n");
218 ospf_router_id_update(ospf
);
223 DEFUN_HIDDEN (ospf_router_id_old
,
224 ospf_router_id_old_cmd
,
226 "router-id for the OSPF process\n"
227 "OSPF router-id in IP address format\n")
229 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
231 struct listnode
*node
;
232 struct ospf_area
*area
;
233 struct in_addr router_id
;
236 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
238 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
239 return CMD_WARNING_CONFIG_FAILED
;
242 ospf
->router_id_static
= router_id
;
244 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
245 if (area
->full_nbrs
) {
247 "For this router-id change to take effect,"
248 " save config and restart ospfd\n");
252 ospf_router_id_update(ospf
);
257 DEFUN (no_ospf_router_id
,
258 no_ospf_router_id_cmd
,
259 "no ospf router-id [A.B.C.D]",
261 "OSPF specific commands\n"
262 "router-id for the OSPF process\n"
263 "OSPF router-id in IP address format\n")
265 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
266 struct listnode
*node
;
267 struct ospf_area
*area
;
269 ospf
->router_id_static
.s_addr
= 0;
271 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
272 if (area
->full_nbrs
) {
274 "For this router-id change to take effect,"
275 " save config and restart ospfd\n");
279 ospf_router_id_update(ospf
);
285 static void ospf_passive_interface_default(struct ospf
*ospf
, u_char newval
)
288 struct interface
*ifp
;
289 struct ospf_interface
*oi
;
291 ospf
->passive_interface_default
= newval
;
293 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, ln
, ifp
)) {
294 if (ifp
&& OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
296 UNSET_IF_PARAM(IF_DEF_PARAMS(ifp
), passive_interface
);
298 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
)) {
299 if (OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
300 UNSET_IF_PARAM(oi
->params
, passive_interface
);
301 /* update multicast memberships */
302 ospf_if_set_multicast(oi
);
306 static void ospf_passive_interface_update_addr(struct ospf
*ospf
,
307 struct interface
*ifp
,
308 struct ospf_if_params
*params
,
314 params
->passive_interface
= value
;
315 if (params
!= IF_DEF_PARAMS(ifp
)) {
316 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
318 dflt
= IF_DEF_PARAMS(ifp
)->passive_interface
;
320 dflt
= ospf
->passive_interface_default
;
323 SET_IF_PARAM(params
, passive_interface
);
325 UNSET_IF_PARAM(params
, passive_interface
);
327 ospf_free_if_params(ifp
, addr
);
328 ospf_if_update_params(ifp
, addr
);
332 static void ospf_passive_interface_update(struct ospf
*ospf
,
333 struct interface
*ifp
,
334 struct ospf_if_params
*params
,
337 params
->passive_interface
= value
;
338 if (params
== IF_DEF_PARAMS(ifp
)) {
339 if (value
!= ospf
->passive_interface_default
)
340 SET_IF_PARAM(params
, passive_interface
);
342 UNSET_IF_PARAM(params
, passive_interface
);
346 DEFUN (ospf_passive_interface
,
347 ospf_passive_interface_addr_cmd
,
348 "passive-interface <IFNAME [A.B.C.D]|default>",
349 "Suppress routing updates on an interface\n"
352 "Suppress routing updates on interfaces by default\n")
354 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
356 struct interface
*ifp
;
357 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
359 struct ospf_if_params
*params
;
360 struct route_node
*rn
;
362 if (strmatch(argv
[1]->text
, "default")) {
363 ospf_passive_interface_default(ospf
, OSPF_IF_PASSIVE
);
367 ifp
= if_get_by_name(argv
[1]->arg
, VRF_DEFAULT
);
369 params
= IF_DEF_PARAMS(ifp
);
372 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
375 "Please specify interface address by A.B.C.D\n");
376 return CMD_WARNING_CONFIG_FAILED
;
379 params
= ospf_get_if_params(ifp
, addr
);
380 ospf_if_update_params(ifp
, addr
);
381 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
382 OSPF_IF_PASSIVE
, addr
);
385 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
387 /* XXX We should call ospf_if_set_multicast on exactly those
388 * interfaces for which the passive property changed. It is too much
389 * work to determine this set, so we do this for every interface.
390 * This is safe and reasonable because ospf_if_set_multicast uses a
391 * record of joined groups to avoid systems calls if the desired
392 * memberships match the current memership.
395 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
396 struct ospf_interface
*oi
= rn
->info
;
398 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
)
400 ospf_if_set_multicast(oi
);
403 * XXX It is not clear what state transitions the interface needs to
404 * undergo when going from active to passive. Fixing this will
405 * require precise identification of interfaces having such a
412 DEFUN (no_ospf_passive_interface
,
413 no_ospf_passive_interface_addr_cmd
,
414 "no passive-interface <IFNAME [A.B.C.D]|default>",
416 "Allow routing updates on an interface\n"
419 "Allow routing updates on interfaces by default\n")
421 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
423 struct interface
*ifp
;
424 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
425 struct ospf_if_params
*params
;
427 struct route_node
*rn
;
429 if (strmatch(argv
[2]->text
, "default")) {
430 ospf_passive_interface_default(ospf
, OSPF_IF_ACTIVE
);
434 ifp
= if_get_by_name(argv
[2]->arg
, VRF_DEFAULT
);
436 params
= IF_DEF_PARAMS(ifp
);
439 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
442 "Please specify interface address by A.B.C.D\n");
443 return CMD_WARNING_CONFIG_FAILED
;
446 params
= ospf_lookup_if_params(ifp
, addr
);
449 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
450 OSPF_IF_ACTIVE
, addr
);
452 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
454 /* XXX We should call ospf_if_set_multicast on exactly those
455 * interfaces for which the passive property changed. It is too much
456 * work to determine this set, so we do this for every interface.
457 * This is safe and reasonable because ospf_if_set_multicast uses a
458 * record of joined groups to avoid systems calls if the desired
459 * memberships match the current memership.
461 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
462 struct ospf_interface
*oi
= rn
->info
;
465 && (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
466 ospf_if_set_multicast(oi
);
473 DEFUN (ospf_network_area
,
474 ospf_network_area_cmd
,
475 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
476 "Enable routing on an IP network\n"
477 "OSPF network prefix\n"
478 "Set the OSPF area ID\n"
479 "OSPF area ID in IP address format\n"
480 "OSPF area ID as a decimal value\n")
482 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
483 int idx_ipv4_prefixlen
= 1;
484 int idx_ipv4_number
= 3;
485 struct prefix_ipv4 p
;
486 struct in_addr area_id
;
489 if (ospf
->instance
) {
491 "The network command is not supported in multi-instance ospf\n");
492 return CMD_WARNING_CONFIG_FAILED
;
495 if (ospf
->if_ospf_cli_count
> 0) {
497 "Please remove all ip ospf area x.x.x.x commands first.\n");
498 return CMD_WARNING_CONFIG_FAILED
;
501 /* Get network prefix and Area ID. */
502 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
503 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
505 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
507 vty_out(vty
, "There is already same network statement.\n");
508 return CMD_WARNING_CONFIG_FAILED
;
514 DEFUN (no_ospf_network_area
,
515 no_ospf_network_area_cmd
,
516 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
518 "Enable routing on an IP network\n"
519 "OSPF network prefix\n"
520 "Set the OSPF area ID\n"
521 "OSPF area ID in IP address format\n"
522 "OSPF area ID as a decimal value\n")
524 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
525 int idx_ipv4_prefixlen
= 2;
526 int idx_ipv4_number
= 4;
527 struct prefix_ipv4 p
;
528 struct in_addr area_id
;
531 if (ospf
->instance
) {
533 "The network command is not supported in multi-instance ospf\n");
534 return CMD_WARNING_CONFIG_FAILED
;
537 /* Get network prefix and Area ID. */
538 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
539 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
541 ret
= ospf_network_unset(ospf
, &p
, area_id
);
544 "Can't find specified network area configuration.\n");
545 return CMD_WARNING_CONFIG_FAILED
;
551 DEFUN (ospf_area_range
,
553 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
554 "OSPF area parameters\n"
555 "OSPF area ID in IP address format\n"
556 "OSPF area ID as a decimal value\n"
557 "Summarize routes matching address/mask (border routers only)\n"
558 "Area range prefix\n"
559 "Advertise this range (default)\n"
560 "User specified metric for this range\n"
561 "Advertised metric for this range\n")
563 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
564 int idx_ipv4_number
= 1;
565 int idx_ipv4_prefixlen
= 3;
567 struct prefix_ipv4 p
;
568 struct in_addr area_id
;
572 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
573 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
575 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
577 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
578 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
584 DEFUN (ospf_area_range_cost
,
585 ospf_area_range_cost_cmd
,
586 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
587 "OSPF area parameters\n"
588 "OSPF area ID in IP address format\n"
589 "OSPF area ID as a decimal value\n"
590 "Summarize routes matching address/mask (border routers only)\n"
591 "Area range prefix\n"
592 "User specified metric for this range\n"
593 "Advertised metric for this range\n")
595 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
596 int idx_ipv4_number
= 1;
597 int idx_ipv4_prefixlen
= 3;
599 struct prefix_ipv4 p
;
600 struct in_addr area_id
;
604 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
605 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
607 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
608 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
611 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
612 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
617 DEFUN (ospf_area_range_not_advertise
,
618 ospf_area_range_not_advertise_cmd
,
619 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
620 "OSPF area parameters\n"
621 "OSPF area ID in IP address format\n"
622 "OSPF area ID as a decimal value\n"
623 "Summarize routes matching address/mask (border routers only)\n"
624 "Area range prefix\n"
625 "DoNotAdvertise this range\n")
627 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
628 int idx_ipv4_number
= 1;
629 int idx_ipv4_prefixlen
= 3;
630 struct prefix_ipv4 p
;
631 struct in_addr area_id
;
634 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
635 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
637 ospf_area_range_set(ospf
, area_id
, &p
, 0);
638 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
644 DEFUN (no_ospf_area_range
,
645 no_ospf_area_range_cmd
,
646 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
648 "OSPF area parameters\n"
649 "OSPF area ID in IP address format\n"
650 "OSPF area ID as a decimal value\n"
651 "Summarize routes matching address/mask (border routers only)\n"
652 "Area range prefix\n"
653 "User specified metric for this range\n"
654 "Advertised metric for this range\n"
655 "Advertise this range (default)\n"
656 "User specified metric for this range\n"
657 "Advertised metric for this range\n"
658 "DoNotAdvertise this range\n")
660 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
661 int idx_ipv4_number
= 2;
662 int idx_ipv4_prefixlen
= 4;
663 struct prefix_ipv4 p
;
664 struct in_addr area_id
;
667 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
668 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
670 ospf_area_range_unset(ospf
, area_id
, &p
);
675 DEFUN (ospf_area_range_substitute
,
676 ospf_area_range_substitute_cmd
,
677 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
678 "OSPF area parameters\n"
679 "OSPF area ID in IP address format\n"
680 "OSPF area ID as a decimal value\n"
681 "Summarize routes matching address/mask (border routers only)\n"
682 "Area range prefix\n"
683 "Announce area range as another prefix\n"
684 "Network prefix to be announced instead of range\n")
686 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
687 int idx_ipv4_number
= 1;
688 int idx_ipv4_prefixlen
= 3;
689 int idx_ipv4_prefixlen_2
= 5;
690 struct prefix_ipv4 p
, s
;
691 struct in_addr area_id
;
694 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
695 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
696 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
698 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
699 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
705 DEFUN (no_ospf_area_range_substitute
,
706 no_ospf_area_range_substitute_cmd
,
707 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
709 "OSPF area parameters\n"
710 "OSPF area ID in IP address format\n"
711 "OSPF area ID as a decimal value\n"
712 "Summarize routes matching address/mask (border routers only)\n"
713 "Area range prefix\n"
714 "Announce area range as another prefix\n"
715 "Network prefix to be announced instead of range\n")
717 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
718 int idx_ipv4_number
= 2;
719 int idx_ipv4_prefixlen
= 4;
720 int idx_ipv4_prefixlen_2
= 6;
721 struct prefix_ipv4 p
, s
;
722 struct in_addr area_id
;
725 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
726 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
727 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
729 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
735 /* Command Handler Logic in VLink stuff is delicate!!
737 ALTER AT YOUR OWN RISK!!!!
739 Various dummy values are used to represent 'NoChange' state for
740 VLink configuration NOT being changed by a VLink command, and
741 special syntax is used within the command strings so that the
742 typed in command verbs can be seen in the configuration command
743 bacckend handler. This is to drastically reduce the verbeage
744 required to coe up with a reasonably compatible Cisco VLink command
746 - Matthew Grant <grantma@anathoth.gen.nz>
747 Wed, 21 Feb 2001 15:13:52 +1300
750 /* Configuration data for virtual links
752 struct ospf_vl_config_data
{
753 struct vty
*vty
; /* vty stuff */
754 struct in_addr area_id
; /* area ID from command line */
755 int area_id_fmt
; /* command line area ID format */
756 struct in_addr vl_peer
; /* command line vl_peer */
757 int auth_type
; /* Authehntication type, if given */
758 char *auth_key
; /* simple password if present */
759 int crypto_key_id
; /* Cryptographic key ID */
760 char *md5_key
; /* MD5 authentication key */
761 int hello_interval
; /* Obvious what these are... */
762 int retransmit_interval
;
767 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
770 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
771 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
772 vl_config
->vty
= vty
;
775 static struct ospf_vl_data
*
776 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
778 struct ospf_area
*area
;
779 struct ospf_vl_data
*vl_data
;
781 struct in_addr area_id
;
783 vty
= vl_config
->vty
;
784 area_id
= vl_config
->area_id
;
786 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
788 "Configuring VLs over the backbone is not allowed\n");
791 area
= ospf_area_get(ospf
, area_id
);
792 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
794 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
795 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
796 vty_out(vty
, "Area %s is %s\n", inet_ntoa(area_id
),
797 area
->external_routing
== OSPF_AREA_NSSA
801 vty_out(vty
, "Area %ld is %s\n",
802 (u_long
)ntohl(area_id
.s_addr
),
803 area
->external_routing
== OSPF_AREA_NSSA
809 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
811 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
812 if (vl_data
->vl_oi
== NULL
) {
813 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
814 ospf_vl_add(ospf
, vl_data
);
815 ospf_spf_calculate_schedule(ospf
,
816 SPF_FLAG_CONFIG_CHANGE
);
823 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
824 struct ospf_vl_config_data
*vl_config
)
826 struct crypt_key
*ck
;
828 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
830 vty
= vl_config
->vty
;
832 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
833 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
834 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
837 if (vl_config
->auth_key
) {
838 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
839 OSPF_AUTH_SIMPLE_SIZE
+ 1);
840 strncpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
841 vl_config
->auth_key
, OSPF_AUTH_SIMPLE_SIZE
);
842 } else if (vl_config
->md5_key
) {
843 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
844 vl_config
->crypto_key_id
)
846 vty_out(vty
, "OSPF: Key %d already exists\n",
847 vl_config
->crypto_key_id
);
848 return CMD_WARNING_CONFIG_FAILED
;
850 ck
= ospf_crypt_key_new();
851 ck
->key_id
= vl_config
->crypto_key_id
;
852 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
853 strncpy((char *)ck
->auth_key
, vl_config
->md5_key
,
856 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
857 } else if (vl_config
->crypto_key_id
!= 0) {
860 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
861 vl_config
->crypto_key_id
)
863 vty_out(vty
, "OSPF: Key %d does not exist\n",
864 vl_config
->crypto_key_id
);
865 return CMD_WARNING_CONFIG_FAILED
;
868 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
869 vl_config
->crypto_key_id
);
875 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
876 struct ospf_vl_config_data
*vl_config
)
878 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
879 /* Virtual Link data initialised to defaults, so only set
881 if (vl_config
->hello_interval
) {
882 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
883 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
886 if (vl_config
->dead_interval
) {
887 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
888 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
891 if (vl_config
->retransmit_interval
) {
892 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
893 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
894 vl_config
->retransmit_interval
;
897 if (vl_config
->transmit_delay
) {
898 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
899 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
906 /* The business end of all of the above */
907 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
909 struct ospf_vl_data
*vl_data
;
912 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
914 return CMD_WARNING_CONFIG_FAILED
;
916 /* Process this one first as it can have a fatal result, which can
917 only logically occur if the virtual link exists already
918 Thus a command error does not result in a change to the
919 running configuration such as unexpectedly altered timer
921 ret
= ospf_vl_set_security(vl_data
, vl_config
);
922 if (ret
!= CMD_SUCCESS
)
925 /* Set any time based parameters, these area already range checked */
927 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
928 if (ret
!= CMD_SUCCESS
)
934 /* This stuff exists to make specifying all the alias commands A LOT simpler
936 #define VLINK_HELPSTR_IPADDR \
937 "OSPF area parameters\n" \
938 "OSPF area ID in IP address format\n" \
939 "OSPF area ID as a decimal value\n" \
940 "Configure a virtual link\n" \
941 "Router ID of the remote ABR\n"
943 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
944 "Enable authentication on this virtual link\n" \
947 #define VLINK_HELPSTR_AUTHTYPE_ALL \
948 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
949 "Use null authentication\n" \
950 "Use message-digest authentication\n"
952 #define VLINK_HELPSTR_TIME_PARAM \
953 "Time between HELLO packets\n" \
955 "Time between retransmitting lost link state advertisements\n" \
957 "Link state transmit delay\n" \
959 "Interval time after which a neighbor is declared down\n" \
962 #define VLINK_HELPSTR_AUTH_SIMPLE \
963 "Authentication password (key)\n" \
964 "The OSPF password (key)"
966 #define VLINK_HELPSTR_AUTH_MD5 \
967 "Message digest authentication password (key)\n" \
970 "Use MD5 algorithm\n" \
971 "The OSPF password (key)"
973 DEFUN (ospf_area_vlink
,
975 "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>]",
977 "Enable authentication on this virtual link\n" \
978 "Use null authentication\n" \
979 "Use message-digest authentication\n"
980 "Message digest authentication password (key)\n" \
982 "Use MD5 algorithm\n" \
983 "The OSPF password (key)")
985 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
986 int idx_ipv4_number
= 1;
988 struct ospf_vl_config_data vl_config
;
989 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
990 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
994 ospf_vl_config_data_init(&vl_config
, vty
);
996 /* Read off first 2 parameters and check them */
997 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
998 &vl_config
.area_id_fmt
);
1000 vty_out(vty
, "OSPF area ID is invalid\n");
1001 return CMD_WARNING_CONFIG_FAILED
;
1004 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1006 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1007 return CMD_WARNING_CONFIG_FAILED
;
1011 /* Thats all folks! - BUGS B. strikes again!!!*/
1013 return ospf_vl_set(ospf
, &vl_config
);
1016 /* Deal with other parameters */
1017 for (i
= 5; i
< argc
; i
++) {
1019 /* vty_out (vty, "argv[%d]->arg - %s\n", i, argv[i]->text); */
1021 switch (argv
[i
]->arg
[0]) {
1025 || strncmp(argv
[i
]->arg
, "authentication-", 15)
1027 /* authentication-key - this option can occur
1029 command line. At start
1032 authentication option. */
1033 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1034 strncpy(auth_key
, argv
[i
+ 1]->text
,
1035 OSPF_AUTH_SIMPLE_SIZE
);
1036 vl_config
.auth_key
= auth_key
;
1038 } else if (strncmp(argv
[i
]->arg
, "authentication", 14)
1040 /* authentication - this option can only occur
1043 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1044 if ((i
+ 1) < argc
) {
1045 if (strncmp(argv
[i
+ 1]->arg
, "n", 1)
1047 /* "authentication null" */
1048 vl_config
.auth_type
=
1052 strncmp(argv
[i
+ 1]->arg
, "m",
1057 "message-digest-")) {
1059 * message-digest" */
1060 vl_config
.auth_type
=
1061 OSPF_AUTH_CRYPTOGRAPHIC
;
1069 /* message-digest-key */
1072 vl_config
.crypto_key_id
=
1073 strtol(argv
[i
]->arg
, NULL
, 10);
1074 if (vl_config
.crypto_key_id
< 0)
1075 return CMD_WARNING_CONFIG_FAILED
;
1079 OSPF_AUTH_MD5_SIZE
+ 1);
1080 strncpy(md5_key
, argv
[i
]->arg
,
1081 OSPF_AUTH_MD5_SIZE
);
1082 vl_config
.md5_key
= md5_key
;
1085 vl_config
.md5_key
= NULL
;
1091 /* Action configuration */
1093 return ospf_vl_set(ospf
, &vl_config
);
1096 DEFUN (no_ospf_area_vlink
,
1097 no_ospf_area_vlink_cmd
,
1098 "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>]",
1100 VLINK_HELPSTR_IPADDR
1101 "Enable authentication on this virtual link\n" \
1102 "Use null authentication\n" \
1103 "Use message-digest authentication\n"
1104 "Message digest authentication password (key)\n" \
1106 "Use MD5 algorithm\n" \
1107 "The OSPF password (key)")
1109 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1110 int idx_ipv4_number
= 2;
1112 struct ospf_area
*area
;
1113 struct ospf_vl_config_data vl_config
;
1114 struct ospf_vl_data
*vl_data
= NULL
;
1115 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1119 ospf_vl_config_data_init(&vl_config
, vty
);
1121 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1124 vty_out(vty
, "OSPF area ID is invalid\n");
1125 return CMD_WARNING_CONFIG_FAILED
;
1128 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1130 vty_out(vty
, "Area does not exist\n");
1131 return CMD_WARNING_CONFIG_FAILED
;
1134 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1136 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1137 return CMD_WARNING_CONFIG_FAILED
;
1141 /* Basic VLink no command */
1142 /* Thats all folks! - BUGS B. strikes again!!!*/
1143 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
)))
1144 ospf_vl_delete(ospf
, vl_data
);
1146 ospf_area_check_free(ospf
, vl_config
.area_id
);
1151 /* If we are down here, we are reseting parameters */
1153 /* Deal with other parameters */
1154 for (i
= 6; i
< argc
; i
++) {
1155 /* vty_out (vty, "argv[%d] - %s\n", i, argv[i]); */
1157 switch (argv
[i
]->arg
[0]) {
1161 || strncmp(argv
[i
]->text
, "authentication-", 15)
1163 /* authentication-key - this option can occur
1165 command line. At start
1168 authentication option. */
1169 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1170 vl_config
.auth_key
= auth_key
;
1171 } else if (strncmp(argv
[i
]->text
, "authentication", 14)
1173 /* authentication - this option can only occur
1176 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1181 /* message-digest-key */
1182 /* Delete one key */
1185 vl_config
.crypto_key_id
=
1186 strtol(argv
[i
]->arg
, NULL
, 10);
1187 if (vl_config
.crypto_key_id
< 0)
1188 return CMD_WARNING_CONFIG_FAILED
;
1189 vl_config
.md5_key
= NULL
;
1191 return CMD_WARNING_CONFIG_FAILED
;
1197 /* Action configuration */
1199 return ospf_vl_set(ospf
, &vl_config
);
1202 DEFUN (ospf_area_vlink_intervals
,
1203 ospf_area_vlink_intervals_cmd
,
1204 "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)}",
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM
)
1208 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1209 struct ospf_vl_config_data vl_config
;
1212 ospf_vl_config_data_init(&vl_config
, vty
);
1214 char *area_id
= argv
[1]->arg
;
1215 char *router_id
= argv
[3]->arg
;
1217 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1219 vty_out(vty
, "OSPF area ID is invalid\n");
1220 return CMD_WARNING_CONFIG_FAILED
;
1223 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1225 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1226 return CMD_WARNING_CONFIG_FAILED
;
1229 for (int idx
= 4; idx
< argc
; idx
++) {
1230 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1231 vl_config
.hello_interval
=
1232 strtol(argv
[++idx
]->arg
, NULL
, 10);
1233 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1234 vl_config
.retransmit_interval
=
1235 strtol(argv
[++idx
]->arg
, NULL
, 10);
1236 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1237 vl_config
.transmit_delay
=
1238 strtol(argv
[++idx
]->arg
, NULL
, 10);
1239 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1240 vl_config
.dead_interval
=
1241 strtol(argv
[++idx
]->arg
, NULL
, 10);
1244 /* Action configuration */
1245 return ospf_vl_set(ospf
, &vl_config
);
1248 DEFUN (no_ospf_area_vlink_intervals
,
1249 no_ospf_area_vlink_intervals_cmd
,
1250 "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)}",
1252 VLINK_HELPSTR_IPADDR
1253 VLINK_HELPSTR_TIME_PARAM
)
1255 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1256 struct ospf_vl_config_data vl_config
;
1259 ospf_vl_config_data_init(&vl_config
, vty
);
1261 char *area_id
= argv
[2]->arg
;
1262 char *router_id
= argv
[4]->arg
;
1264 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1266 vty_out(vty
, "OSPF area ID is invalid\n");
1267 return CMD_WARNING_CONFIG_FAILED
;
1270 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1272 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1273 return CMD_WARNING_CONFIG_FAILED
;
1276 for (int idx
= 5; idx
< argc
; idx
++) {
1277 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1278 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1279 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1280 vl_config
.retransmit_interval
=
1281 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1282 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1283 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1284 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1285 vl_config
.dead_interval
=
1286 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1289 /* Action configuration */
1290 return ospf_vl_set(ospf
, &vl_config
);
1293 DEFUN (ospf_area_shortcut
,
1294 ospf_area_shortcut_cmd
,
1295 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1296 "OSPF area parameters\n"
1297 "OSPF area ID in IP address format\n"
1298 "OSPF area ID as a decimal value\n"
1299 "Configure the area's shortcutting mode\n"
1300 "Set default shortcutting behavior\n"
1301 "Enable shortcutting through the area\n"
1302 "Disable shortcutting through the area\n")
1304 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1305 int idx_ipv4_number
= 1;
1306 int idx_enable_disable
= 3;
1307 struct ospf_area
*area
;
1308 struct in_addr area_id
;
1312 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1313 argv
[idx_ipv4_number
]->arg
);
1315 area
= ospf_area_get(ospf
, area_id
);
1316 ospf_area_display_format_set(ospf
, area
, format
);
1318 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1319 mode
= OSPF_SHORTCUT_DEFAULT
;
1320 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1321 mode
= OSPF_SHORTCUT_DISABLE
;
1322 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1323 mode
= OSPF_SHORTCUT_ENABLE
;
1325 return CMD_WARNING_CONFIG_FAILED
;
1327 ospf_area_shortcut_set(ospf
, area
, mode
);
1329 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1331 "Shortcut area setting will take effect "
1332 "only when the router is configured as Shortcut ABR\n");
1337 DEFUN (no_ospf_area_shortcut
,
1338 no_ospf_area_shortcut_cmd
,
1339 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1341 "OSPF area parameters\n"
1342 "OSPF area ID in IP address format\n"
1343 "OSPF area ID as a decimal value\n"
1344 "Deconfigure the area's shortcutting mode\n"
1345 "Deconfigure enabled shortcutting through the area\n"
1346 "Deconfigure disabled shortcutting through the area\n")
1348 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1349 int idx_ipv4_number
= 2;
1350 struct ospf_area
*area
;
1351 struct in_addr area_id
;
1354 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1355 argv
[idx_ipv4_number
]->arg
);
1357 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1361 ospf_area_shortcut_unset(ospf
, area
);
1367 DEFUN (ospf_area_stub
,
1369 "area <A.B.C.D|(0-4294967295)> stub",
1370 "OSPF area parameters\n"
1371 "OSPF area ID in IP address format\n"
1372 "OSPF area ID as a decimal value\n"
1373 "Configure OSPF area as stub\n")
1375 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1376 int idx_ipv4_number
= 1;
1377 struct in_addr area_id
;
1380 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1381 argv
[idx_ipv4_number
]->arg
);
1383 ret
= ospf_area_stub_set(ospf
, area_id
);
1384 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1388 "First deconfigure all virtual link through this area\n");
1389 return CMD_WARNING_CONFIG_FAILED
;
1392 ospf_area_no_summary_unset(ospf
, area_id
);
1397 DEFUN (ospf_area_stub_no_summary
,
1398 ospf_area_stub_no_summary_cmd
,
1399 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1400 "OSPF stub parameters\n"
1401 "OSPF area ID in IP address format\n"
1402 "OSPF area ID as a decimal value\n"
1403 "Configure OSPF area as stub\n"
1404 "Do not inject inter-area routes into stub\n")
1406 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1407 int idx_ipv4_number
= 1;
1408 struct in_addr area_id
;
1411 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1412 argv
[idx_ipv4_number
]->arg
);
1414 ret
= ospf_area_stub_set(ospf
, area_id
);
1415 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1419 "%% Area cannot be stub as it contains a virtual link\n");
1420 return CMD_WARNING_CONFIG_FAILED
;
1423 ospf_area_no_summary_set(ospf
, area_id
);
1428 DEFUN (no_ospf_area_stub
,
1429 no_ospf_area_stub_cmd
,
1430 "no area <A.B.C.D|(0-4294967295)> stub",
1432 "OSPF area parameters\n"
1433 "OSPF area ID in IP address format\n"
1434 "OSPF area ID as a decimal value\n"
1435 "Configure OSPF area as stub\n")
1437 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1438 int idx_ipv4_number
= 2;
1439 struct in_addr area_id
;
1442 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1443 argv
[idx_ipv4_number
]->arg
);
1445 ospf_area_stub_unset(ospf
, area_id
);
1446 ospf_area_no_summary_unset(ospf
, area_id
);
1451 DEFUN (no_ospf_area_stub_no_summary
,
1452 no_ospf_area_stub_no_summary_cmd
,
1453 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1455 "OSPF area parameters\n"
1456 "OSPF area ID in IP address format\n"
1457 "OSPF area ID as a decimal value\n"
1458 "Configure OSPF area as stub\n"
1459 "Do not inject inter-area routes into area\n")
1461 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1462 int idx_ipv4_number
= 2;
1463 struct in_addr area_id
;
1466 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1467 argv
[idx_ipv4_number
]->arg
);
1468 ospf_area_no_summary_unset(ospf
, area_id
);
1473 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1474 struct cmd_token
**argv
, int nosum
)
1476 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1477 struct in_addr area_id
;
1480 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1482 ret
= ospf_area_nssa_set(ospf
, area_id
);
1483 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1487 "%% Area cannot be nssa as it contains a virtual link\n");
1488 return CMD_WARNING_CONFIG_FAILED
;
1492 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1493 ospf_area_nssa_translator_role_set(
1494 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1495 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1496 ospf_area_nssa_translator_role_set(
1497 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1498 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1499 ospf_area_nssa_translator_role_set(
1500 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1502 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1503 OSPF_NSSA_ROLE_CANDIDATE
);
1507 ospf_area_no_summary_set(ospf
, area_id
);
1509 ospf_area_no_summary_unset(ospf
, area_id
);
1511 ospf_schedule_abr_task(ospf
);
1516 DEFUN (ospf_area_nssa_translate_no_summary
,
1517 ospf_area_nssa_translate_no_summary_cmd
,
1518 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1519 "OSPF area parameters\n"
1520 "OSPF area ID in IP address format\n"
1521 "OSPF area ID as a decimal value\n"
1522 "Configure OSPF area as nssa\n"
1523 "Configure NSSA-ABR for translate election (default)\n"
1524 "Configure NSSA-ABR to never translate\n"
1525 "Configure NSSA-ABR to always translate\n"
1526 "Do not inject inter-area routes into nssa\n")
1528 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1531 DEFUN (ospf_area_nssa_translate
,
1532 ospf_area_nssa_translate_cmd
,
1533 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1534 "OSPF area parameters\n"
1535 "OSPF area ID in IP address format\n"
1536 "OSPF area ID as a decimal value\n"
1537 "Configure OSPF area as nssa\n"
1538 "Configure NSSA-ABR for translate election (default)\n"
1539 "Configure NSSA-ABR to never translate\n"
1540 "Configure NSSA-ABR to always translate\n")
1542 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1545 DEFUN (ospf_area_nssa
,
1547 "area <A.B.C.D|(0-4294967295)> nssa",
1548 "OSPF area parameters\n"
1549 "OSPF area ID in IP address format\n"
1550 "OSPF area ID as a decimal value\n"
1551 "Configure OSPF area as nssa\n")
1553 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1556 DEFUN (ospf_area_nssa_no_summary
,
1557 ospf_area_nssa_no_summary_cmd
,
1558 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1559 "OSPF area parameters\n"
1560 "OSPF area ID in IP address format\n"
1561 "OSPF area ID as a decimal value\n"
1562 "Configure OSPF area as nssa\n"
1563 "Do not inject inter-area routes into nssa\n")
1565 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1568 DEFUN (no_ospf_area_nssa
,
1569 no_ospf_area_nssa_cmd
,
1570 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1572 "OSPF area parameters\n"
1573 "OSPF area ID in IP address format\n"
1574 "OSPF area ID as a decimal value\n"
1575 "Configure OSPF area as nssa\n"
1576 "Configure NSSA-ABR for translate election (default)\n"
1577 "Configure NSSA-ABR to never translate\n"
1578 "Configure NSSA-ABR to always translate\n"
1579 "Do not inject inter-area routes into nssa\n")
1581 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1582 int idx_ipv4_number
= 2;
1583 struct in_addr area_id
;
1586 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1587 argv
[idx_ipv4_number
]->arg
);
1589 ospf_area_nssa_unset(ospf
, area_id
);
1590 ospf_area_no_summary_unset(ospf
, area_id
);
1592 ospf_schedule_abr_task(ospf
);
1598 DEFUN (ospf_area_default_cost
,
1599 ospf_area_default_cost_cmd
,
1600 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1601 "OSPF area parameters\n"
1602 "OSPF area ID in IP address format\n"
1603 "OSPF area ID as a decimal value\n"
1604 "Set the summary-default cost of a NSSA or stub area\n"
1605 "Stub's advertised default summary cost\n")
1607 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1608 int idx_ipv4_number
= 1;
1610 struct ospf_area
*area
;
1611 struct in_addr area_id
;
1614 struct prefix_ipv4 p
;
1616 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1617 argv
[idx_ipv4_number
]->arg
);
1618 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1620 area
= ospf_area_get(ospf
, area_id
);
1621 ospf_area_display_format_set(ospf
, area
, format
);
1623 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1624 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1625 return CMD_WARNING_CONFIG_FAILED
;
1628 area
->default_cost
= cost
;
1631 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1633 if (IS_DEBUG_OSPF_EVENT
)
1635 "ospf_abr_announce_stub_defaults(): "
1636 "announcing 0.0.0.0/0 to area %s",
1637 inet_ntoa(area
->area_id
));
1638 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1643 DEFUN (no_ospf_area_default_cost
,
1644 no_ospf_area_default_cost_cmd
,
1645 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1647 "OSPF area parameters\n"
1648 "OSPF area ID in IP address format\n"
1649 "OSPF area ID as a decimal value\n"
1650 "Set the summary-default cost of a NSSA or stub area\n"
1651 "Stub's advertised default summary cost\n")
1653 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1654 int idx_ipv4_number
= 2;
1655 struct ospf_area
*area
;
1656 struct in_addr area_id
;
1658 struct prefix_ipv4 p
;
1660 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1661 argv
[idx_ipv4_number
]->arg
);
1663 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1667 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1668 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1669 return CMD_WARNING_CONFIG_FAILED
;
1672 area
->default_cost
= 1;
1675 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1677 if (IS_DEBUG_OSPF_EVENT
)
1679 "ospf_abr_announce_stub_defaults(): "
1680 "announcing 0.0.0.0/0 to area %s",
1681 inet_ntoa(area
->area_id
));
1682 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1685 ospf_area_check_free(ospf
, area_id
);
1690 DEFUN (ospf_area_export_list
,
1691 ospf_area_export_list_cmd
,
1692 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1693 "OSPF area parameters\n"
1694 "OSPF area ID in IP address format\n"
1695 "OSPF area ID as a decimal value\n"
1696 "Set the filter for networks announced to other areas\n"
1697 "Name of the access-list\n")
1699 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1700 int idx_ipv4_number
= 1;
1701 struct ospf_area
*area
;
1702 struct in_addr area_id
;
1705 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1707 area
= ospf_area_get(ospf
, area_id
);
1708 ospf_area_display_format_set(ospf
, area
, format
);
1709 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1714 DEFUN (no_ospf_area_export_list
,
1715 no_ospf_area_export_list_cmd
,
1716 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1718 "OSPF area parameters\n"
1719 "OSPF area ID in IP address format\n"
1720 "OSPF area ID as a decimal value\n"
1721 "Unset the filter for networks announced to other areas\n"
1722 "Name of the access-list\n")
1724 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1725 int idx_ipv4_number
= 2;
1726 struct ospf_area
*area
;
1727 struct in_addr area_id
;
1730 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1732 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1736 ospf_area_export_list_unset(ospf
, area
);
1742 DEFUN (ospf_area_import_list
,
1743 ospf_area_import_list_cmd
,
1744 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1745 "OSPF area parameters\n"
1746 "OSPF area ID in IP address format\n"
1747 "OSPF area ID as a decimal value\n"
1748 "Set the filter for networks from other areas announced to the specified one\n"
1749 "Name of the access-list\n")
1751 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1752 int idx_ipv4_number
= 1;
1753 struct ospf_area
*area
;
1754 struct in_addr area_id
;
1757 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1759 area
= ospf_area_get(ospf
, area_id
);
1760 ospf_area_display_format_set(ospf
, area
, format
);
1761 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1766 DEFUN (no_ospf_area_import_list
,
1767 no_ospf_area_import_list_cmd
,
1768 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1770 "OSPF area parameters\n"
1771 "OSPF area ID in IP address format\n"
1772 "OSPF area ID as a decimal value\n"
1773 "Unset the filter for networks announced to other areas\n"
1774 "Name of the access-list\n")
1776 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1777 int idx_ipv4_number
= 2;
1778 struct ospf_area
*area
;
1779 struct in_addr area_id
;
1782 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1784 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1788 ospf_area_import_list_unset(ospf
, area
);
1793 DEFUN (ospf_area_filter_list
,
1794 ospf_area_filter_list_cmd
,
1795 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1796 "OSPF area parameters\n"
1797 "OSPF area ID in IP address format\n"
1798 "OSPF area ID as a decimal value\n"
1799 "Filter networks between OSPF areas\n"
1800 "Filter prefixes between OSPF areas\n"
1801 "Name of an IP prefix-list\n"
1802 "Filter networks sent to this area\n"
1803 "Filter networks sent from this area\n")
1805 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1806 int idx_ipv4_number
= 1;
1809 struct ospf_area
*area
;
1810 struct in_addr area_id
;
1811 struct prefix_list
*plist
;
1814 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1816 area
= ospf_area_get(ospf
, area_id
);
1817 ospf_area_display_format_set(ospf
, area
, format
);
1818 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1819 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1820 PREFIX_LIST_IN(area
) = plist
;
1821 if (PREFIX_NAME_IN(area
))
1822 free(PREFIX_NAME_IN(area
));
1824 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1825 ospf_schedule_abr_task(ospf
);
1827 PREFIX_LIST_OUT(area
) = plist
;
1828 if (PREFIX_NAME_OUT(area
))
1829 free(PREFIX_NAME_OUT(area
));
1831 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1832 ospf_schedule_abr_task(ospf
);
1838 DEFUN (no_ospf_area_filter_list
,
1839 no_ospf_area_filter_list_cmd
,
1840 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1842 "OSPF area parameters\n"
1843 "OSPF area ID in IP address format\n"
1844 "OSPF area ID as a decimal value\n"
1845 "Filter networks between OSPF areas\n"
1846 "Filter prefixes between OSPF areas\n"
1847 "Name of an IP prefix-list\n"
1848 "Filter networks sent to this area\n"
1849 "Filter networks sent from this area\n")
1851 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1852 int idx_ipv4_number
= 2;
1855 struct ospf_area
*area
;
1856 struct in_addr area_id
;
1859 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1861 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1864 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1865 if (PREFIX_NAME_IN(area
))
1866 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1870 PREFIX_LIST_IN(area
) = NULL
;
1871 if (PREFIX_NAME_IN(area
))
1872 free(PREFIX_NAME_IN(area
));
1874 PREFIX_NAME_IN(area
) = NULL
;
1876 ospf_schedule_abr_task(ospf
);
1878 if (PREFIX_NAME_OUT(area
))
1879 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1883 PREFIX_LIST_OUT(area
) = NULL
;
1884 if (PREFIX_NAME_OUT(area
))
1885 free(PREFIX_NAME_OUT(area
));
1887 PREFIX_NAME_OUT(area
) = NULL
;
1889 ospf_schedule_abr_task(ospf
);
1896 DEFUN (ospf_area_authentication_message_digest
,
1897 ospf_area_authentication_message_digest_cmd
,
1898 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1899 "OSPF area parameters\n"
1900 "OSPF area ID in IP address format\n"
1901 "OSPF area ID as a decimal value\n"
1902 "Enable authentication\n"
1903 "Use message-digest authentication\n")
1905 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1906 int idx_ipv4_number
= 1;
1907 struct ospf_area
*area
;
1908 struct in_addr area_id
;
1911 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1913 area
= ospf_area_get(ospf
, area_id
);
1914 ospf_area_display_format_set(ospf
, area
, format
);
1915 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1920 DEFUN (ospf_area_authentication
,
1921 ospf_area_authentication_cmd
,
1922 "area <A.B.C.D|(0-4294967295)> authentication",
1923 "OSPF area parameters\n"
1924 "OSPF area ID in IP address format\n"
1925 "OSPF area ID as a decimal value\n"
1926 "Enable authentication\n")
1928 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1929 int idx_ipv4_number
= 1;
1930 struct ospf_area
*area
;
1931 struct in_addr area_id
;
1934 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1936 area
= ospf_area_get(ospf
, area_id
);
1937 ospf_area_display_format_set(ospf
, area
, format
);
1938 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1943 DEFUN (no_ospf_area_authentication
,
1944 no_ospf_area_authentication_cmd
,
1945 "no area <A.B.C.D|(0-4294967295)> authentication",
1947 "OSPF area parameters\n"
1948 "OSPF area ID in IP address format\n"
1949 "OSPF area ID as a decimal value\n"
1950 "Enable authentication\n")
1952 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1953 int idx_ipv4_number
= 2;
1954 struct ospf_area
*area
;
1955 struct in_addr area_id
;
1958 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1960 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1964 area
->auth_type
= OSPF_AUTH_NULL
;
1966 ospf_area_check_free(ospf
, area_id
);
1972 DEFUN (ospf_abr_type
,
1974 "ospf abr-type <cisco|ibm|shortcut|standard>",
1975 "OSPF specific commands\n"
1976 "Set OSPF ABR type\n"
1977 "Alternative ABR, cisco implementation\n"
1978 "Alternative ABR, IBM implementation\n"
1980 "Standard behavior (RFC2328)\n")
1982 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1984 u_char abr_type
= OSPF_ABR_UNKNOWN
;
1986 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
1987 abr_type
= OSPF_ABR_CISCO
;
1988 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
1989 abr_type
= OSPF_ABR_IBM
;
1990 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
1991 abr_type
= OSPF_ABR_SHORTCUT
;
1992 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
1993 abr_type
= OSPF_ABR_STAND
;
1995 return CMD_WARNING_CONFIG_FAILED
;
1997 /* If ABR type value is changed, schedule ABR task. */
1998 if (ospf
->abr_type
!= abr_type
) {
1999 ospf
->abr_type
= abr_type
;
2000 ospf_schedule_abr_task(ospf
);
2006 DEFUN (no_ospf_abr_type
,
2007 no_ospf_abr_type_cmd
,
2008 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2010 "OSPF specific commands\n"
2011 "Set OSPF ABR type\n"
2012 "Alternative ABR, cisco implementation\n"
2013 "Alternative ABR, IBM implementation\n"
2017 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2019 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2021 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2022 abr_type
= OSPF_ABR_CISCO
;
2023 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2024 abr_type
= OSPF_ABR_IBM
;
2025 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2026 abr_type
= OSPF_ABR_SHORTCUT
;
2027 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2028 abr_type
= OSPF_ABR_STAND
;
2030 return CMD_WARNING_CONFIG_FAILED
;
2032 /* If ABR type value is changed, schedule ABR task. */
2033 if (ospf
->abr_type
== abr_type
) {
2034 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2035 ospf_schedule_abr_task(ospf
);
2041 DEFUN (ospf_log_adjacency_changes
,
2042 ospf_log_adjacency_changes_cmd
,
2043 "log-adjacency-changes",
2044 "Log changes in adjacency state\n")
2046 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2048 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2049 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2053 DEFUN (ospf_log_adjacency_changes_detail
,
2054 ospf_log_adjacency_changes_detail_cmd
,
2055 "log-adjacency-changes detail",
2056 "Log changes in adjacency state\n"
2057 "Log all state changes\n")
2059 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2061 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2062 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2066 DEFUN (no_ospf_log_adjacency_changes
,
2067 no_ospf_log_adjacency_changes_cmd
,
2068 "no log-adjacency-changes",
2070 "Log changes in adjacency state\n")
2072 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2074 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2075 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2079 DEFUN (no_ospf_log_adjacency_changes_detail
,
2080 no_ospf_log_adjacency_changes_detail_cmd
,
2081 "no log-adjacency-changes detail",
2083 "Log changes in adjacency state\n"
2084 "Log all state changes\n")
2086 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2088 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2092 DEFUN (ospf_compatible_rfc1583
,
2093 ospf_compatible_rfc1583_cmd
,
2094 "compatible rfc1583",
2095 "OSPF compatibility list\n"
2096 "compatible with RFC 1583\n")
2098 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2100 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2101 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2102 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2107 DEFUN (no_ospf_compatible_rfc1583
,
2108 no_ospf_compatible_rfc1583_cmd
,
2109 "no compatible rfc1583",
2111 "OSPF compatibility list\n"
2112 "compatible with RFC 1583\n")
2114 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2116 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2117 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2118 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2123 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2124 "ospf rfc1583compatibility",
2125 "OSPF specific commands\n"
2126 "Enable the RFC1583Compatibility flag\n")
2128 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2129 "no ospf rfc1583compatibility", NO_STR
2130 "OSPF specific commands\n"
2131 "Disable the RFC1583Compatibility flag\n")
2133 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2134 unsigned int hold
, unsigned int max
)
2136 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2138 ospf
->spf_delay
= delay
;
2139 ospf
->spf_holdtime
= hold
;
2140 ospf
->spf_max_holdtime
= max
;
2145 DEFUN (ospf_timers_min_ls_interval
,
2146 ospf_timers_min_ls_interval_cmd
,
2147 "timers throttle lsa all (0-5000)",
2148 "Adjust routing timers\n"
2149 "Throttling adaptive timer\n"
2150 "LSA delay between transmissions\n"
2152 "Delay (msec) between sending LSAs\n")
2154 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2156 unsigned int interval
;
2159 vty_out(vty
, "Insufficient arguments\n");
2160 return CMD_WARNING_CONFIG_FAILED
;
2163 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2165 ospf
->min_ls_interval
= interval
;
2170 DEFUN (no_ospf_timers_min_ls_interval
,
2171 no_ospf_timers_min_ls_interval_cmd
,
2172 "no timers throttle lsa all [(0-5000)]",
2174 "Adjust routing timers\n"
2175 "Throttling adaptive timer\n"
2176 "LSA delay between transmissions\n"
2178 "Delay (msec) between sending LSAs\n")
2180 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2181 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2187 DEFUN (ospf_timers_min_ls_arrival
,
2188 ospf_timers_min_ls_arrival_cmd
,
2189 "timers lsa arrival (0-1000)",
2190 "Adjust routing timers\n"
2191 "Throttling link state advertisement delays\n"
2192 "OSPF minimum arrival interval delay\n"
2193 "Delay (msec) between accepted LSAs\n")
2195 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2197 unsigned int arrival
;
2200 vty_out(vty
, "Insufficient arguments\n");
2201 return CMD_WARNING_CONFIG_FAILED
;
2204 arrival
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2206 ospf
->min_ls_arrival
= arrival
;
2211 DEFUN (no_ospf_timers_min_ls_arrival
,
2212 no_ospf_timers_min_ls_arrival_cmd
,
2213 "no timers lsa arrival [(0-1000)]",
2215 "Adjust routing timers\n"
2216 "Throttling link state advertisement delays\n"
2217 "OSPF minimum arrival interval delay\n"
2218 "Delay (msec) between accepted LSAs\n")
2220 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2222 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2228 DEFUN (ospf_timers_throttle_spf
,
2229 ospf_timers_throttle_spf_cmd
,
2230 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2231 "Adjust routing timers\n"
2232 "Throttling adaptive timer\n"
2234 "Delay (msec) from first change received till SPF calculation\n"
2235 "Initial hold time (msec) between consecutive SPF calculations\n"
2236 "Maximum hold time (msec)\n")
2239 int idx_number_2
= 4;
2240 int idx_number_3
= 5;
2241 unsigned int delay
, hold
, max
;
2244 vty_out(vty
, "Insufficient arguments\n");
2245 return CMD_WARNING_CONFIG_FAILED
;
2248 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2249 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2250 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2252 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2255 DEFUN (no_ospf_timers_throttle_spf
,
2256 no_ospf_timers_throttle_spf_cmd
,
2257 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2259 "Adjust routing timers\n"
2260 "Throttling adaptive timer\n"
2262 "Delay (msec) from first change received till SPF calculation\n"
2263 "Initial hold time (msec) between consecutive SPF calculations\n"
2264 "Maximum hold time (msec)\n")
2266 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2267 OSPF_SPF_HOLDTIME_DEFAULT
,
2268 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2272 DEFUN (ospf_timers_lsa
,
2273 ospf_timers_lsa_cmd
,
2274 "timers lsa min-arrival (0-600000)",
2275 "Adjust routing timers\n"
2277 "Minimum delay in receiving new version of a LSA\n"
2278 "Delay in milliseconds\n")
2280 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2282 unsigned int minarrival
;
2285 vty_out(vty
, "Insufficient number of arguments\n");
2286 return CMD_WARNING_CONFIG_FAILED
;
2289 minarrival
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2291 ospf
->min_ls_arrival
= minarrival
;
2296 DEFUN (no_ospf_timers_lsa
,
2297 no_ospf_timers_lsa_cmd
,
2298 "no timers lsa min-arrival [(0-600000)]",
2300 "Adjust routing timers\n"
2302 "Minimum delay in receiving new version of a LSA\n"
2303 "Delay in milliseconds\n")
2305 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2306 unsigned int minarrival
;
2309 minarrival
= strtoul(argv
[4]->arg
, NULL
, 10);
2311 if (ospf
->min_ls_arrival
!= minarrival
2312 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2316 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2321 DEFUN (ospf_neighbor
,
2323 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2325 "Neighbor IP address\n"
2326 "Neighbor Priority\n"
2328 "Dead Neighbor Polling interval\n"
2331 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2335 struct in_addr nbr_addr
;
2336 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2337 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2339 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2342 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2345 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2347 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2350 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2353 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2358 DEFUN (ospf_neighbor_poll_interval
,
2359 ospf_neighbor_poll_interval_cmd
,
2360 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2362 "Neighbor IP address\n"
2363 "Dead Neighbor Polling interval\n"
2365 "OSPF priority of non-broadcast neighbor\n"
2368 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2372 struct in_addr nbr_addr
;
2373 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2374 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2376 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2378 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2381 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2383 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2384 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2387 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2392 DEFUN (no_ospf_neighbor
,
2393 no_ospf_neighbor_cmd
,
2394 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2397 "Neighbor IP address\n"
2398 "Neighbor Priority\n"
2400 "Dead Neighbor Polling interval\n"
2403 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2405 struct in_addr nbr_addr
;
2407 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2409 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2414 DEFUN (no_ospf_neighbor_poll
,
2415 no_ospf_neighbor_poll_cmd
,
2416 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2419 "Neighbor IP address\n"
2420 "Dead Neighbor Polling interval\n"
2422 "Neighbor Priority\n"
2425 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2427 struct in_addr nbr_addr
;
2429 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2431 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2436 DEFUN (ospf_refresh_timer
,
2437 ospf_refresh_timer_cmd
,
2438 "refresh timer (10-1800)",
2439 "Adjust refresh parameters\n"
2440 "Set refresh timer\n"
2441 "Timer value in seconds\n")
2443 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2445 unsigned int interval
;
2447 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2448 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2449 * OSPF_LSA_REFRESHER_GRANULARITY
;
2451 ospf_timers_refresh_set(ospf
, interval
);
2456 DEFUN (no_ospf_refresh_timer
,
2457 no_ospf_refresh_timer_val_cmd
,
2458 "no refresh timer [(10-1800)]",
2460 "Adjust refresh parameters\n"
2461 "Unset refresh timer\n"
2462 "Timer value in seconds\n")
2464 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2466 unsigned int interval
;
2469 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2471 if (ospf
->lsa_refresh_interval
!= interval
2472 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2476 ospf_timers_refresh_unset(ospf
);
2482 DEFUN (ospf_auto_cost_reference_bandwidth
,
2483 ospf_auto_cost_reference_bandwidth_cmd
,
2484 "auto-cost reference-bandwidth (1-4294967)",
2485 "Calculate OSPF interface cost according to bandwidth\n"
2486 "Use reference bandwidth method to assign OSPF cost\n"
2487 "The reference bandwidth in terms of Mbits per second\n")
2489 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2492 struct listnode
*node
;
2493 struct interface
*ifp
;
2495 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2496 if (refbw
< 1 || refbw
> 4294967) {
2497 vty_out(vty
, "reference-bandwidth value is invalid\n");
2498 return CMD_WARNING_CONFIG_FAILED
;
2501 /* If reference bandwidth is changed. */
2502 if ((refbw
) == ospf
->ref_bandwidth
)
2505 ospf
->ref_bandwidth
= refbw
;
2506 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
2507 ospf_if_recalculate_output_cost(ifp
);
2512 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2513 no_ospf_auto_cost_reference_bandwidth_cmd
,
2514 "no auto-cost reference-bandwidth [(1-4294967)]",
2516 "Calculate OSPF interface cost according to bandwidth\n"
2517 "Use reference bandwidth method to assign OSPF cost\n"
2518 "The reference bandwidth in terms of Mbits per second\n")
2520 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2521 struct listnode
*node
, *nnode
;
2522 struct interface
*ifp
;
2524 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2527 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2528 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2530 " Please ensure reference bandwidth is consistent across all routers\n");
2532 for (ALL_LIST_ELEMENTS(om
->iflist
, node
, nnode
, ifp
))
2533 ospf_if_recalculate_output_cost(ifp
);
2538 DEFUN (ospf_write_multiplier
,
2539 ospf_write_multiplier_cmd
,
2540 "ospf write-multiplier (1-100)",
2541 "OSPF specific commands\n"
2542 "Write multiplier\n"
2543 "Maximum number of interface serviced per write\n")
2545 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2547 u_int32_t write_oi_count
;
2554 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2555 if (write_oi_count
< 1 || write_oi_count
> 100) {
2556 vty_out(vty
, "write-multiplier value is invalid\n");
2557 return CMD_WARNING_CONFIG_FAILED
;
2560 ospf
->write_oi_count
= write_oi_count
;
2564 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2565 "Write multiplier\n"
2566 "Maximum number of interface serviced per write\n")
2568 DEFUN (no_ospf_write_multiplier
,
2569 no_ospf_write_multiplier_cmd
,
2570 "no ospf write-multiplier (1-100)",
2572 "OSPF specific commands\n"
2573 "Write multiplier\n"
2574 "Maximum number of interface serviced per write\n")
2576 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2578 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2582 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2583 "no write-multiplier (1-100)", NO_STR
2584 "Write multiplier\n"
2585 "Maximum number of interface serviced per write\n")
2587 const char *ospf_abr_type_descr_str
[] = {"Unknown", "Standard (RFC2328)",
2588 "Alternative IBM", "Alternative Cisco",
2589 "Alternative Shortcut"};
2591 const char *ospf_shortcut_mode_descr_str
[] = {"Default", "Enabled", "Disabled"};
2593 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2594 json_object
*json_areas
, u_char use_json
)
2596 json_object
*json_area
= NULL
;
2599 json_area
= json_object_new_object();
2603 vty_out(vty
, " Area ID: %s", inet_ntoa(area
->area_id
));
2605 /* Show Area type/mode. */
2606 if (OSPF_IS_AREA_BACKBONE(area
)) {
2608 json_object_boolean_true_add(json_area
, "backbone");
2610 vty_out(vty
, " (Backbone)\n");
2613 if (area
->external_routing
== OSPF_AREA_STUB
) {
2614 if (area
->no_summary
)
2615 json_object_boolean_true_add(
2616 json_area
, "stubNoSummary");
2617 if (area
->shortcut_configured
)
2618 json_object_boolean_true_add(
2619 json_area
, "stubShortcut");
2620 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2621 if (area
->no_summary
)
2622 json_object_boolean_true_add(
2623 json_area
, "nssaNoSummary");
2624 if (area
->shortcut_configured
)
2625 json_object_boolean_true_add(
2626 json_area
, "nssaShortcut");
2629 json_object_string_add(
2630 json_area
, "shortcuttingMode",
2631 ospf_shortcut_mode_descr_str
2632 [area
->shortcut_configured
]);
2633 if (area
->shortcut_capability
)
2634 json_object_boolean_true_add(json_area
,
2637 if (area
->external_routing
== OSPF_AREA_STUB
)
2638 vty_out(vty
, " (Stub%s%s)",
2639 area
->no_summary
? ", no summary" : "",
2640 area
->shortcut_configured
? "; " : "");
2641 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2642 vty_out(vty
, " (NSSA%s%s)",
2643 area
->no_summary
? ", no summary" : "",
2644 area
->shortcut_configured
? "; " : "");
2647 vty_out(vty
, " Shortcutting mode: %s",
2648 ospf_shortcut_mode_descr_str
2649 [area
->shortcut_configured
]);
2650 vty_out(vty
, ", S-bit consensus: %s\n",
2651 area
->shortcut_capability
? "ok" : "no");
2655 /* Show number of interfaces */
2657 json_object_int_add(json_area
, "areaIfTotalCounter",
2658 listcount(area
->oiflist
));
2659 json_object_int_add(json_area
, "areaIfActiveCounter",
2663 " Number of interfaces in this area: Total: %d, "
2665 listcount(area
->oiflist
), area
->act_ints
);
2667 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2669 json_object_boolean_true_add(json_area
, "nssa");
2670 if (!IS_OSPF_ABR(area
->ospf
))
2671 json_object_boolean_false_add(json_area
, "abr");
2672 else if (area
->NSSATranslatorState
) {
2673 json_object_boolean_true_add(json_area
, "abr");
2674 if (area
->NSSATranslatorRole
2675 == OSPF_NSSA_ROLE_CANDIDATE
)
2676 json_object_boolean_true_add(
2678 "nssaTranslatorElected");
2679 else if (area
->NSSATranslatorRole
2680 == OSPF_NSSA_ROLE_ALWAYS
)
2681 json_object_boolean_true_add(
2683 "nssaTranslatorAlways");
2685 json_object_boolean_true_add(json_area
, "abr");
2686 if (area
->NSSATranslatorRole
2687 == OSPF_NSSA_ROLE_CANDIDATE
)
2688 json_object_boolean_false_add(
2690 "nssaTranslatorElected");
2692 json_object_boolean_true_add(
2694 "nssaTranslatorNever");
2698 " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n");
2699 if (!IS_OSPF_ABR(area
->ospf
))
2701 " It is not ABR, therefore not Translator. \n");
2702 else if (area
->NSSATranslatorState
) {
2703 vty_out(vty
, " We are an ABR and ");
2704 if (area
->NSSATranslatorRole
2705 == OSPF_NSSA_ROLE_CANDIDATE
)
2707 "the NSSA Elected Translator. \n");
2708 else if (area
->NSSATranslatorRole
2709 == OSPF_NSSA_ROLE_ALWAYS
)
2711 "always an NSSA Translator. \n");
2713 vty_out(vty
, " We are an ABR, but ");
2714 if (area
->NSSATranslatorRole
2715 == OSPF_NSSA_ROLE_CANDIDATE
)
2717 "not the NSSA Elected Translator. \n");
2720 "never an NSSA Translator. \n");
2725 /* Stub-router state for this area */
2726 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2727 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2730 json_object_boolean_true_add(
2731 json_area
, "originStubMaxDistRouterLsa");
2732 if (CHECK_FLAG(area
->stub_router_state
,
2733 OSPF_AREA_ADMIN_STUB_ROUTED
))
2734 json_object_boolean_true_add(
2735 json_area
, "indefiniteActiveAdmin");
2736 if (area
->t_stub_router
) {
2740 &area
->t_stub_router
->u
.sands
,
2743 json_object_int_add(
2745 "activeStartupRemainderMsecs",
2750 " Originating stub / maximum-distance Router-LSA\n");
2751 if (CHECK_FLAG(area
->stub_router_state
,
2752 OSPF_AREA_ADMIN_STUB_ROUTED
))
2754 " Administratively activated (indefinitely)\n");
2755 if (area
->t_stub_router
)
2757 " Active from startup, %s remaining\n",
2758 ospf_timer_dump(area
->t_stub_router
,
2765 /* Show number of fully adjacent neighbors. */
2766 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2769 /* Show authentication type. */
2770 if (area
->auth_type
== OSPF_AUTH_NULL
)
2771 json_object_string_add(json_area
, "authentication",
2772 "authenticationNone");
2773 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2774 json_object_string_add(json_area
, "authentication",
2775 "authenticationSimplePassword");
2776 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2777 json_object_string_add(json_area
, "authentication",
2778 "authenticationMessageDigest");
2780 if (!OSPF_IS_AREA_BACKBONE(area
))
2781 json_object_int_add(json_area
,
2782 "virtualAdjacenciesPassingCounter",
2785 /* Show SPF calculation times. */
2786 json_object_int_add(json_area
, "spfExecutedCounter",
2787 area
->spf_calculation
);
2788 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2789 json_object_int_add(
2790 json_area
, "lsaRouterNumber",
2791 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2792 json_object_int_add(
2793 json_area
, "lsaRouterChecksum",
2794 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2795 json_object_int_add(
2796 json_area
, "lsaNetworkNumber",
2797 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2798 json_object_int_add(
2799 json_area
, "lsaNetworkChecksum",
2800 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2801 json_object_int_add(
2802 json_area
, "lsaSummaryNumber",
2803 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2804 json_object_int_add(
2805 json_area
, "lsaSummaryChecksum",
2806 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2807 json_object_int_add(
2808 json_area
, "lsaAsbrNumber",
2809 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2810 json_object_int_add(
2811 json_area
, "lsaAsbrChecksum",
2812 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2813 json_object_int_add(
2814 json_area
, "lsaNssaNumber",
2815 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2816 json_object_int_add(
2817 json_area
, "lsaNssaChecksum",
2818 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2820 /* Show number of fully adjacent neighbors. */
2822 " Number of fully adjacent neighbors in this area:"
2826 /* Show authentication type. */
2827 vty_out(vty
, " Area has ");
2828 if (area
->auth_type
== OSPF_AUTH_NULL
)
2829 vty_out(vty
, "no authentication\n");
2830 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2831 vty_out(vty
, "simple password authentication\n");
2832 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2833 vty_out(vty
, "message digest authentication\n");
2835 if (!OSPF_IS_AREA_BACKBONE(area
))
2837 " Number of full virtual adjacencies going through"
2841 /* Show SPF calculation times. */
2842 vty_out(vty
, " SPF algorithm executed %d times\n",
2843 area
->spf_calculation
);
2845 /* Show number of LSA. */
2846 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
2848 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
2849 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
2850 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2852 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
2853 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
2854 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2856 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
2857 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
2858 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2860 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
2861 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2862 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2863 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
2864 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2865 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2869 json_object_int_add(
2870 json_area
, "lsaOpaqueLinkNumber",
2871 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2872 json_object_int_add(
2873 json_area
, "lsaOpaqueLinkChecksum",
2874 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2875 json_object_int_add(
2876 json_area
, "lsaOpaqueAreaNumber",
2877 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2878 json_object_int_add(
2879 json_area
, "lsaOpaqueAreaChecksum",
2880 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2883 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
2884 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2885 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2887 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
2888 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2889 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2893 json_object_object_add(json_areas
, inet_ntoa(area
->area_id
),
2899 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
2902 struct listnode
*node
, *nnode
;
2903 struct ospf_area
*area
;
2904 struct timeval result
;
2905 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2906 json_object
*json
= NULL
;
2907 json_object
*json_areas
= NULL
;
2910 json
= json_object_new_object();
2911 json_areas
= json_object_new_object();
2914 if (ospf
->instance
) {
2916 json_object_int_add(json
, "ospfInstance",
2919 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
2923 /* Show Router ID. */
2925 json_object_string_add(json
, "routerId",
2926 inet_ntoa(ospf
->router_id
));
2928 vty_out(vty
, " OSPF Routing Process, Router ID: %s\n",
2929 inet_ntoa(ospf
->router_id
));
2932 /* Graceful shutdown */
2933 if (ospf
->t_deferred_shutdown
) {
2938 &ospf
->t_deferred_shutdown
->u
.sands
,
2941 json_object_int_add(json
, "deferredShutdownMsecs",
2945 " Deferred shutdown in progress, %s remaining\n",
2946 ospf_timer_dump(ospf
->t_deferred_shutdown
,
2947 timebuf
, sizeof(timebuf
)));
2951 /* Show capability. */
2953 json_object_boolean_true_add(json
, "tosRoutesOnly");
2954 json_object_boolean_true_add(json
, "rfc2328Conform");
2955 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2956 json_object_boolean_true_add(json
,
2957 "rfc1583Compatibility");
2960 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
2961 vty_out(vty
, " This implementation conforms to RFC2328\n");
2962 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
2963 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
2969 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
2970 json_object_boolean_true_add(json
, "opaqueCapable");
2973 vty_out(vty
, " OpaqueCapability flag is %s\n",
2974 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
2979 /* Show stub-router configuration */
2980 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
2981 || ospf
->stub_router_shutdown_time
2982 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
2984 json_object_boolean_true_add(json
, "stubAdvertisement");
2985 if (ospf
->stub_router_startup_time
2986 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2987 json_object_int_add(
2988 json
, "postStartEnabledMsecs",
2989 ospf
->stub_router_startup_time
/ 1000);
2990 if (ospf
->stub_router_shutdown_time
2991 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2992 json_object_int_add(
2993 json
, "preShutdownEnabledMsecs",
2994 ospf
->stub_router_shutdown_time
/ 1000);
2997 " Stub router advertisement is configured\n");
2998 if (ospf
->stub_router_startup_time
2999 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3001 " Enabled for %us after start-up\n",
3002 ospf
->stub_router_startup_time
);
3003 if (ospf
->stub_router_shutdown_time
3004 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3006 " Enabled for %us prior to full shutdown\n",
3007 ospf
->stub_router_shutdown_time
);
3011 /* Show SPF timers. */
3013 json_object_int_add(json
, "spfScheduleDelayMsecs",
3015 json_object_int_add(json
, "holdtimeMinMsecs",
3016 ospf
->spf_holdtime
);
3017 json_object_int_add(json
, "holdtimeMaxMsecs",
3018 ospf
->spf_max_holdtime
);
3019 json_object_int_add(json
, "holdtimeMultplier",
3020 ospf
->spf_hold_multiplier
);
3023 " Initial SPF scheduling delay %d millisec(s)\n"
3024 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
3025 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
3026 " Hold time multiplier is currently %d\n",
3027 ospf
->spf_delay
, ospf
->spf_holdtime
,
3028 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3032 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3033 long time_store
= 0;
3036 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3037 json_object_int_add(json
, "spfLastExecutedMsecs",
3040 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3041 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3042 json_object_int_add(json
, "spfLastDurationMsecs",
3045 json_object_boolean_true_add(json
, "spfHasNotRun");
3047 vty_out(vty
, " SPF algorithm ");
3048 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3049 monotime_since(&ospf
->ts_spf
, &result
);
3050 vty_out(vty
, "last executed %s ago\n",
3051 ospf_timeval_dump(&result
, timebuf
,
3053 vty_out(vty
, " Last SPF duration %s\n",
3054 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3055 timebuf
, sizeof(timebuf
)));
3057 vty_out(vty
, "has not been run\n");
3061 if (ospf
->t_spf_calc
) {
3064 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3066 json_object_int_add(json
, "spfTimerDueInMsecs",
3070 json_object_int_add(json
, "lsaMinIntervalMsecs",
3071 ospf
->min_ls_interval
);
3072 json_object_int_add(json
, "lsaMinArrivalMsecs",
3073 ospf
->min_ls_arrival
);
3074 /* Show write multiplier values */
3075 json_object_int_add(json
, "writeMultiplier",
3076 ospf
->write_oi_count
);
3077 /* Show refresh parameters. */
3078 json_object_int_add(json
, "refreshTimerMsecs",
3079 ospf
->lsa_refresh_interval
* 1000);
3081 vty_out(vty
, " SPF timer %s%s\n",
3082 (ospf
->t_spf_calc
? "due in " : "is "),
3083 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3086 vty_out(vty
, " LSA minimum interval %d msecs\n",
3087 ospf
->min_ls_interval
);
3088 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3089 ospf
->min_ls_arrival
);
3091 /* Show write multiplier values */
3092 vty_out(vty
, " Write Multiplier set to %d \n",
3093 ospf
->write_oi_count
);
3095 /* Show refresh parameters. */
3096 vty_out(vty
, " Refresh timer %d secs\n",
3097 ospf
->lsa_refresh_interval
);
3100 /* Show ABR/ASBR flags. */
3101 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3103 json_object_string_add(
3105 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3108 " This router is an ABR, ABR type is: %s\n",
3109 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3111 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3113 json_object_string_add(
3115 "injectingExternalRoutingInformation");
3118 " This router is an ASBR "
3119 "(injecting external routing information)\n");
3122 /* Show Number of AS-external-LSAs. */
3124 json_object_int_add(
3125 json
, "lsaExternalCounter",
3126 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3127 json_object_int_add(
3128 json
, "lsaExternalChecksum",
3129 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3132 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3133 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3134 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3138 json_object_int_add(
3139 json
, "lsaAsopaqueCounter",
3140 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3141 json_object_int_add(
3142 json
, "lsaAsOpaqueChecksum",
3143 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3146 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3147 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3148 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3151 /* Show number of areas attached. */
3153 json_object_int_add(json
, "attachedAreaCounter",
3154 listcount(ospf
->areas
));
3156 vty_out(vty
, " Number of areas attached to this router: %d\n",
3157 listcount(ospf
->areas
));
3159 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3160 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3162 json_object_boolean_true_add(
3163 json
, "adjacencyChangesLoggedAll");
3166 " All adjacency changes are logged\n");
3169 json_object_boolean_true_add(
3170 json
, "adjacencyChangesLogged");
3172 vty_out(vty
, " Adjacency changes are logged\n");
3175 /* Show each area status. */
3176 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3177 show_ip_ospf_area(vty
, area
, json_areas
, use_json
);
3180 json_object_object_add(json
, "areas", json_areas
);
3181 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3182 json
, JSON_C_TO_STRING_PRETTY
));
3183 json_object_free(json
);
3190 DEFUN (show_ip_ospf
,
3192 "show ip ospf [json]",
3195 "OSPF information\n"
3199 u_char uj
= use_json(argc
, argv
);
3201 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3204 return (show_ip_ospf_common(vty
, ospf
, uj
));
3207 DEFUN (show_ip_ospf_instance
,
3208 show_ip_ospf_instance_cmd
,
3209 "show ip ospf (1-65535) [json]",
3212 "OSPF information\n"
3218 u_short instance
= 0;
3219 u_char uj
= use_json(argc
, argv
);
3221 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3222 ospf
= ospf_lookup_instance(instance
);
3224 return CMD_NOT_MY_INSTANCE
;
3226 if (!ospf
->oi_running
)
3229 return (show_ip_ospf_common(vty
, ospf
, uj
));
3232 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3233 struct interface
*ifp
,
3234 json_object
*json_interface_sub
,
3238 struct ospf_neighbor
*nbr
;
3239 struct route_node
*rn
;
3240 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3242 /* Is interface up? */
3244 is_up
= if_is_operative(ifp
);
3246 json_object_boolean_true_add(json_interface_sub
,
3249 json_object_boolean_false_add(json_interface_sub
,
3252 json_object_int_add(json_interface_sub
, "ifIndex",
3254 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3255 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3257 json_object_string_add(json_interface_sub
, "ifFlags",
3258 if_flag_dump(ifp
->flags
));
3260 vty_out(vty
, "%s is %s\n", ifp
->name
,
3261 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3262 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3263 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3264 if_flag_dump(ifp
->flags
));
3267 /* Is interface OSPF enabled? */
3269 if (ospf_oi_count(ifp
) == 0) {
3270 json_object_boolean_false_add(json_interface_sub
,
3273 } else if (!is_up
) {
3274 json_object_boolean_false_add(json_interface_sub
,
3278 json_object_boolean_true_add(json_interface_sub
,
3281 if (ospf_oi_count(ifp
) == 0) {
3282 vty_out(vty
, " OSPF not enabled on this interface\n");
3284 } else if (!is_up
) {
3286 " OSPF is enabled, but not running on this interface\n");
3291 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3292 struct ospf_interface
*oi
= rn
->info
;
3297 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3299 json_object_boolean_true_add(json_interface_sub
,
3302 vty_out(vty
, " This interface is UNNUMBERED,");
3304 /* Show OSPF interface information. */
3306 json_object_string_add(
3307 json_interface_sub
, "ipAddress",
3308 inet_ntoa(oi
->address
->u
.prefix4
));
3309 json_object_int_add(json_interface_sub
,
3310 "ipAddressPrefixlen",
3311 oi
->address
->prefixlen
);
3313 vty_out(vty
, " Internet Address %s/%d,",
3314 inet_ntoa(oi
->address
->u
.prefix4
),
3315 oi
->address
->prefixlen
);
3317 if (oi
->connected
->destination
3318 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3319 struct in_addr
*dest
;
3322 if (CONNECTED_PEER(oi
->connected
)
3323 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3328 /* For Vlinks, showing the peer address is
3330 * * * * * informative than the local
3331 * interface that is being used
3333 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3334 dest
= &oi
->vl_data
->peer_addr
;
3336 dest
= &oi
->connected
->destination
->u
3340 json_object_string_add(
3342 "ospfIfType", dstr
);
3343 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3344 json_object_string_add(
3349 json_object_string_add(
3354 vty_out(vty
, " %s %s,", dstr
,
3359 json_object_string_add(json_interface_sub
, "area",
3360 ospf_area_desc_string(oi
->area
));
3361 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3362 json_object_boolean_true_add(
3364 "mtuMismatchDetect");
3365 json_object_string_add(json_interface_sub
, "routerId",
3366 inet_ntoa(ospf
->router_id
));
3367 json_object_string_add(json_interface_sub
,
3369 ospf_network_type_str
[oi
->type
]);
3370 json_object_int_add(json_interface_sub
, "cost",
3372 json_object_int_add(
3373 json_interface_sub
, "transmitDelayMsecs",
3374 1000 / OSPF_IF_PARAM(oi
, transmit_delay
));
3375 json_object_string_add(json_interface_sub
, "state",
3376 lookup_msg(ospf_ism_state_msg
,
3378 json_object_int_add(json_interface_sub
, "priority",
3381 vty_out(vty
, " Area %s\n",
3382 ospf_area_desc_string(oi
->area
));
3384 vty_out(vty
, " MTU mismatch detection: %s\n",
3385 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3389 " Router ID %s, Network Type %s, Cost: %d\n",
3390 inet_ntoa(ospf
->router_id
),
3391 ospf_network_type_str
[oi
->type
],
3395 " Transmit Delay is %d sec, State %s, Priority %d\n",
3396 OSPF_IF_PARAM(oi
, transmit_delay
),
3397 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3401 /* Show DR information. */
3402 if (DR(oi
).s_addr
== 0) {
3405 " No backup designated router on this network\n");
3407 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3411 " No backup designated router on this network\n");
3414 json_object_string_add(
3415 json_interface_sub
, "bdrId",
3416 inet_ntoa(nbr
->router_id
));
3417 json_object_string_add(
3420 inet_ntoa(nbr
->address
.u
3424 " Backup Designated Router (ID) %s,",
3425 inet_ntoa(nbr
->router_id
));
3426 vty_out(vty
, " Interface Address %s\n",
3427 inet_ntoa(nbr
->address
.u
3433 /* Next network-LSA sequence number we'll use, if we're elected
3436 && ntohl(oi
->params
->network_lsa_seqnum
)
3437 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3439 json_object_int_add(
3441 "networkLsaSequence",
3442 ntohl(oi
->params
->network_lsa_seqnum
));
3445 " Saved Network-LSA sequence number 0x%x\n",
3446 ntohl(oi
->params
->network_lsa_seqnum
));
3450 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3451 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3452 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3453 json_object_boolean_true_add(
3455 "mcastMemberOspfAllRouters");
3456 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3457 json_object_boolean_true_add(
3459 "mcastMemberOspfDesignatedRouters");
3462 vty_out(vty
, " Multicast group memberships:");
3463 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3464 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3465 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3466 vty_out(vty
, " OSPFAllRouters");
3467 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3468 vty_out(vty
, " OSPFDesignatedRouters");
3470 vty_out(vty
, " <None>");
3475 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3476 json_object_int_add(
3477 json_interface_sub
, "timerMsecs",
3478 1000 / OSPF_IF_PARAM(oi
, v_hello
));
3480 json_object_int_add(
3481 json_interface_sub
, "timerMsecs",
3482 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3483 json_object_int_add(json_interface_sub
,
3485 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3486 json_object_int_add(json_interface_sub
,
3488 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3489 json_object_int_add(
3490 json_interface_sub
, "timerRetransmit",
3491 1000 / OSPF_IF_PARAM(oi
, retransmit_interval
));
3493 vty_out(vty
, " Timer intervals configured,");
3494 vty_out(vty
, " Hello ");
3495 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3496 vty_out(vty
, "%ds,",
3497 OSPF_IF_PARAM(oi
, v_hello
));
3499 vty_out(vty
, "%dms,",
3500 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3501 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3502 OSPF_IF_PARAM(oi
, v_wait
),
3503 OSPF_IF_PARAM(oi
, v_wait
),
3504 OSPF_IF_PARAM(oi
, retransmit_interval
));
3507 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3508 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3510 long time_store
= 0;
3514 &oi
->t_hello
->u
.sands
,
3517 json_object_int_add(json_interface_sub
,
3518 "timerHelloInMsecs",
3521 vty_out(vty
, " Hello due in %s\n",
3522 ospf_timer_dump(oi
->t_hello
, timebuf
,
3524 } else /* passive-interface is set */
3527 json_object_boolean_true_add(
3529 "timerPassiveIface");
3532 " No Hellos (Passive interface)\n");
3536 json_object_int_add(json_interface_sub
, "nbrCount",
3537 ospf_nbr_count(oi
, 0));
3538 json_object_int_add(json_interface_sub
,
3540 ospf_nbr_count(oi
, NSM_Full
));
3543 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3544 ospf_nbr_count(oi
, 0),
3545 ospf_nbr_count(oi
, NSM_Full
));
3546 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3550 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3551 int argc
, struct cmd_token
**argv
,
3552 int iface_argv
, u_char use_json
)
3554 struct interface
*ifp
;
3555 struct listnode
*node
;
3556 json_object
*json
= NULL
;
3557 json_object
*json_interface_sub
= NULL
;
3560 json
= json_object_new_object();
3563 if (ospf
->instance
) {
3565 json_object_int_add(json
, "ospfInstance",
3568 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3571 if (argc
== iface_argv
) {
3572 /* Show All Interfaces.*/
3573 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
)) {
3574 if (ospf_oi_count(ifp
)) {
3576 json_interface_sub
=
3577 json_object_new_object();
3579 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3584 json_object_object_add(
3586 json_interface_sub
);
3590 /* Interface name is specified. */
3591 if ((ifp
= if_lookup_by_name(argv
[iface_argv
]->arg
,
3595 json_object_boolean_true_add(json
,
3598 vty_out(vty
, "No such interface name\n");
3601 json_interface_sub
= json_object_new_object();
3603 show_ip_ospf_interface_sub(
3604 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3607 json_object_object_add(json
, ifp
->name
,
3608 json_interface_sub
);
3613 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3614 json
, JSON_C_TO_STRING_PRETTY
));
3615 json_object_free(json
);
3622 DEFUN (show_ip_ospf_interface
,
3623 show_ip_ospf_interface_cmd
,
3624 "show ip ospf interface [INTERFACE] [json]",
3627 "OSPF information\n"
3628 "Interface information\n"
3633 u_char uj
= use_json(argc
, argv
);
3635 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3641 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3644 DEFUN (show_ip_ospf_instance_interface
,
3645 show_ip_ospf_instance_interface_cmd
,
3646 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3649 "OSPF information\n"
3651 "Interface information\n"
3657 u_short instance
= 0;
3658 u_char uj
= use_json(argc
, argv
);
3660 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3661 ospf
= ospf_lookup_instance(instance
);
3663 return CMD_NOT_MY_INSTANCE
;
3665 if (!ospf
->oi_running
)
3671 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3674 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
3676 vty_out(vty
, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n",
3677 "Neighbor ID", "Pri", "State", "Dead Time", "Address",
3678 "Interface", "RXmtL", "RqstL", "DBsmL");
3681 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
3682 struct ospf_interface
*oi
,
3683 json_object
*json
, u_char use_json
)
3685 struct route_node
*rn
;
3686 struct ospf_neighbor
*nbr
;
3688 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3689 json_object
*json_neighbor
= NULL
;
3691 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
3692 if ((nbr
= rn
->info
)) {
3693 /* Do not show myself. */
3694 if (nbr
!= oi
->nbr_self
) {
3695 /* Down state is not shown. */
3696 if (nbr
->state
!= NSM_Down
) {
3699 json_object_new_object();
3700 ospf_nbr_state_message(
3713 json_object_int_add(
3717 json_object_string_add(
3718 json_neighbor
, "state",
3720 json_object_int_add(
3724 json_object_string_add(
3727 inet_ntoa(nbr
->src
));
3728 json_object_string_add(
3732 json_object_int_add(
3734 "retransmitCounter",
3735 ospf_ls_retransmit_count(
3737 json_object_int_add(
3740 ospf_ls_request_count(
3742 json_object_int_add(
3745 ospf_db_summary_count(
3747 if (nbr
->state
== NSM_Attempt
3748 && nbr
->router_id
.s_addr
3750 json_object_object_add(
3755 json_object_object_add(
3761 ospf_nbr_state_message(
3764 if (nbr
->state
== NSM_Attempt
3765 && nbr
->router_id
.s_addr
3780 vty_out(vty
, "%9s ",
3785 vty_out(vty
, "%-15s ",
3786 inet_ntoa(nbr
->src
));
3788 "%-20s %5ld %5ld %5d\n",
3790 ospf_ls_retransmit_count(
3792 ospf_ls_request_count(
3794 ospf_db_summary_count(
3803 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
3806 struct ospf_interface
*oi
;
3807 struct listnode
*node
;
3808 json_object
*json
= NULL
;
3811 json
= json_object_new_object();
3813 show_ip_ospf_neighbour_header(vty
);
3815 if (ospf
->instance
) {
3817 json_object_int_add(json
, "ospfInstance",
3820 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3823 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
3824 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3827 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3828 json
, JSON_C_TO_STRING_PRETTY
));
3829 json_object_free(json
);
3836 DEFUN (show_ip_ospf_neighbor
,
3837 show_ip_ospf_neighbor_cmd
,
3838 "show ip ospf neighbor [json]",
3841 "OSPF information\n"
3846 u_char uj
= use_json(argc
, argv
);
3848 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3851 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3855 DEFUN (show_ip_ospf_instance_neighbor
,
3856 show_ip_ospf_instance_neighbor_cmd
,
3857 "show ip ospf (1-65535) neighbor [json]",
3860 "OSPF information\n"
3867 u_short instance
= 0;
3868 u_char uj
= use_json(argc
, argv
);
3870 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3871 ospf
= ospf_lookup_instance(instance
);
3873 return CMD_NOT_MY_INSTANCE
;
3875 if (!ospf
->oi_running
)
3878 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3881 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
3884 struct listnode
*node
;
3885 struct ospf_interface
*oi
;
3886 json_object
*json
= NULL
;
3887 json_object
*json_neighbor_sub
= NULL
;
3890 json
= json_object_new_object();
3891 json_neighbor_sub
= json_object_new_object();
3893 show_ip_ospf_neighbour_header(vty
);
3895 if (ospf
->instance
) {
3897 json_object_int_add(json
, "ospfInstance",
3900 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3903 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
3904 struct listnode
*nbr_node
;
3905 struct ospf_nbr_nbma
*nbr_nbma
;
3907 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3909 /* print Down neighbor status */
3910 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
3911 if (nbr_nbma
->nbr
== NULL
3912 || nbr_nbma
->nbr
->state
== NSM_Down
) {
3914 json_object_int_add(json_neighbor_sub
,
3916 nbr_nbma
->priority
);
3917 json_object_boolean_true_add(
3920 json_object_string_add(
3924 json_object_int_add(
3926 "nbrNbmaRetransmitCounter", 0);
3927 json_object_int_add(
3929 "nbrNbmaRequestCounter", 0);
3930 json_object_int_add(
3932 "nbrNbmaDbSummaryCounter", 0);
3933 json_object_object_add(
3934 json
, inet_ntoa(nbr_nbma
->addr
),
3937 vty_out(vty
, "%-15s %3d %-15s %9s ",
3938 "-", nbr_nbma
->priority
, "Down",
3941 "%-15s %-20s %5d %5d %5d\n",
3942 inet_ntoa(nbr_nbma
->addr
),
3943 IF_NAME(oi
), 0, 0, 0);
3950 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3951 json
, JSON_C_TO_STRING_PRETTY
));
3952 json_object_free(json
);
3959 DEFUN (show_ip_ospf_neighbor_all
,
3960 show_ip_ospf_neighbor_all_cmd
,
3961 "show ip ospf neighbor all [json]",
3964 "OSPF information\n"
3966 "include down status neighbor\n"
3970 u_char uj
= use_json(argc
, argv
);
3972 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3975 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3978 DEFUN (show_ip_ospf_instance_neighbor_all
,
3979 show_ip_ospf_instance_neighbor_all_cmd
,
3980 "show ip ospf (1-65535) neighbor all [json]",
3983 "OSPF information\n"
3986 "include down status neighbor\n"
3991 u_short instance
= 0;
3992 u_char uj
= use_json(argc
, argv
);
3994 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3995 ospf
= ospf_lookup_instance(instance
);
3997 return CMD_NOT_MY_INSTANCE
;
3999 if (!ospf
->oi_running
)
4002 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4005 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4007 struct cmd_token
**argv
,
4010 struct interface
*ifp
;
4011 struct route_node
*rn
;
4012 json_object
*json
= NULL
;
4015 json
= json_object_new_object();
4017 show_ip_ospf_neighbour_header(vty
);
4019 if (ospf
->instance
) {
4021 json_object_int_add(json
, "ospfInstance",
4024 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4027 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
4030 json_object_boolean_true_add(json
, "noSuchIface");
4032 vty_out(vty
, "No such interface.\n");
4036 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4037 struct ospf_interface
*oi
= rn
->info
;
4042 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4046 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4047 json
, JSON_C_TO_STRING_PRETTY
));
4048 json_object_free(json
);
4055 DEFUN (show_ip_ospf_neighbor_int
,
4056 show_ip_ospf_neighbor_int_cmd
,
4057 "show ip ospf neighbor IFNAME [json]",
4060 "OSPF information\n"
4066 u_char uj
= use_json(argc
, argv
);
4068 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4071 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4074 DEFUN (show_ip_ospf_instance_neighbor_int
,
4075 show_ip_ospf_instance_neighbor_int_cmd
,
4076 "show ip ospf (1-65535) neighbor IFNAME [json]",
4079 "OSPF information\n"
4087 u_short instance
= 0;
4088 u_char uj
= use_json(argc
, argv
);
4090 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4091 ospf
= ospf_lookup_instance(instance
);
4093 return CMD_NOT_MY_INSTANCE
;
4095 if (!ospf
->oi_running
)
4098 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4101 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4102 struct ospf_interface
*oi
,
4103 struct ospf_nbr_nbma
*nbr_nbma
,
4104 u_char use_json
, json_object
*json
)
4106 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4107 json_object
*json_sub
= NULL
;
4110 json_sub
= json_object_new_object();
4111 else /* Show neighbor ID. */
4112 vty_out(vty
, " Neighbor %s,", "-");
4114 /* Show interface address. */
4116 json_object_string_add(json_sub
, "ifaceAddress",
4117 inet_ntoa(nbr_nbma
->addr
));
4119 vty_out(vty
, " interface address %s\n",
4120 inet_ntoa(nbr_nbma
->addr
));
4124 json_object_string_add(json_sub
, "areaId",
4125 ospf_area_desc_string(oi
->area
));
4126 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
4128 vty_out(vty
, " In the area %s via interface %s\n",
4129 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
4131 /* Show neighbor priority and state. */
4133 json_object_int_add(json_sub
, "nbrPriority",
4134 nbr_nbma
->priority
);
4135 json_object_string_add(json_sub
, "nbrState", "down");
4137 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4138 nbr_nbma
->priority
, "Down");
4140 /* Show state changes. */
4142 json_object_int_add(json_sub
, "stateChangeCounter",
4143 nbr_nbma
->state_change
);
4145 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
4147 /* Show PollInterval */
4149 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4151 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
4153 /* Show poll-interval timer. */
4156 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
)
4158 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec",
4161 vty_out(vty
, " Poll timer due in %s\n",
4162 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
4165 /* Show poll-interval timer thread. */
4167 if (nbr_nbma
->t_poll
!= NULL
)
4168 json_object_string_add(json_sub
,
4169 "pollIntervalTimerThread", "on");
4171 vty_out(vty
, " Thread Poll Timer %s\n",
4172 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
4175 json_object_object_add(json
, "noNbrId", json_sub
);
4178 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
4179 struct ospf_interface
*oi
,
4180 struct ospf_neighbor
*nbr
,
4181 u_char use_json
, json_object
*json
)
4183 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4184 json_object
*json_sub
= NULL
;
4187 json_sub
= json_object_new_object();
4189 /* Show neighbor ID. */
4190 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4191 vty_out(vty
, " Neighbor %s,", "-");
4193 vty_out(vty
, " Neighbor %s,",
4194 inet_ntoa(nbr
->router_id
));
4197 /* Show interface address. */
4199 json_object_string_add(json_sub
, "ifaceAddress",
4200 inet_ntoa(nbr
->address
.u
.prefix4
));
4202 vty_out(vty
, " interface address %s\n",
4203 inet_ntoa(nbr
->address
.u
.prefix4
));
4207 json_object_string_add(json_sub
, "areaId",
4208 ospf_area_desc_string(oi
->area
));
4209 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4211 vty_out(vty
, " In the area %s via interface %s\n",
4212 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
4214 /* Show neighbor priority and state. */
4216 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4217 json_object_string_add(
4218 json_sub
, "nbrState",
4219 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4221 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4223 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4225 /* Show state changes. */
4227 json_object_int_add(json_sub
, "stateChangeCounter",
4230 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
4232 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
4237 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4239 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec",
4243 " Most recent state change statistics:\n");
4244 vty_out(vty
, " Progressive change %s ago\n",
4245 ospf_timeval_dump(&res
, timebuf
,
4250 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
4255 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4257 json_object_int_add(json_sub
,
4258 "lastRegressiveChangeMsec",
4260 if (nbr
->last_regress_str
)
4261 json_object_string_add(
4262 json_sub
, "lastRegressiveChangeReason",
4263 nbr
->last_regress_str
);
4266 " Regressive change %s ago, due to %s\n",
4267 ospf_timeval_dump(&res
, timebuf
,
4269 (nbr
->last_regress_str
? nbr
->last_regress_str
4274 /* Show Designated Rotuer ID. */
4276 json_object_string_add(json_sub
, "routerDesignatedId",
4277 inet_ntoa(nbr
->d_router
));
4279 vty_out(vty
, " DR is %s,", inet_ntoa(nbr
->d_router
));
4281 /* Show Backup Designated Rotuer ID. */
4283 json_object_string_add(json_sub
, "routerDesignatedBackupId",
4284 inet_ntoa(nbr
->bd_router
));
4286 vty_out(vty
, " BDR is %s\n", inet_ntoa(nbr
->bd_router
));
4290 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4291 json_object_string_add(json_sub
, "optionsList",
4292 ospf_options_dump(nbr
->options
));
4294 vty_out(vty
, " Options %d %s\n", nbr
->options
,
4295 ospf_options_dump(nbr
->options
));
4297 /* Show Router Dead interval timer. */
4299 if (nbr
->t_inactivity
) {
4301 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
4304 json_object_int_add(json_sub
,
4305 "routerDeadIntervalTimerDueMsec",
4308 json_object_int_add(
4309 json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4311 vty_out(vty
, " Dead timer due in %s\n",
4312 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
4315 /* Show Database Summary list. */
4317 json_object_int_add(json_sub
, "databaseSummaryListCounter",
4318 ospf_db_summary_count(nbr
));
4320 vty_out(vty
, " Database Summary List %d\n",
4321 ospf_db_summary_count(nbr
));
4323 /* Show Link State Request list. */
4325 json_object_int_add(json_sub
, "linkStateRequestListCounter",
4326 ospf_ls_request_count(nbr
));
4328 vty_out(vty
, " Link State Request List %ld\n",
4329 ospf_ls_request_count(nbr
));
4331 /* Show Link State Retransmission list. */
4333 json_object_int_add(json_sub
,
4334 "linkStateRetransmissionListCounter",
4335 ospf_ls_retransmit_count(nbr
));
4337 vty_out(vty
, " Link State Retransmission List %ld\n",
4338 ospf_ls_retransmit_count(nbr
));
4340 /* Show inactivity timer thread. */
4342 if (nbr
->t_inactivity
!= NULL
)
4343 json_object_string_add(json_sub
,
4344 "threadInactivityTimer", "on");
4346 vty_out(vty
, " Thread Inactivity Timer %s\n",
4347 nbr
->t_inactivity
!= NULL
? "on" : "off");
4349 /* Show Database Description retransmission thread. */
4351 if (nbr
->t_db_desc
!= NULL
)
4352 json_object_string_add(
4354 "threadDatabaseDescriptionRetransmission",
4358 " Thread Database Description Retransmision %s\n",
4359 nbr
->t_db_desc
!= NULL
? "on" : "off");
4361 /* Show Link State Request Retransmission thread. */
4363 if (nbr
->t_ls_req
!= NULL
)
4364 json_object_string_add(
4366 "threadLinkStateRequestRetransmission", "on");
4369 " Thread Link State Request Retransmission %s\n",
4370 nbr
->t_ls_req
!= NULL
? "on" : "off");
4372 /* Show Link State Update Retransmission thread. */
4374 if (nbr
->t_ls_upd
!= NULL
)
4375 json_object_string_add(
4376 json_sub
, "threadLinkStateUpdateRetransmission",
4380 " Thread Link State Update Retransmission %s\n\n",
4381 nbr
->t_ls_upd
!= NULL
? "on" : "off");
4384 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4385 json_object_object_add(json
, "noNbrId", json_sub
);
4387 json_object_object_add(json
, inet_ntoa(nbr
->router_id
),
4391 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4394 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
4396 struct cmd_token
**argv
,
4399 struct listnode
*node
;
4400 struct ospf_neighbor
*nbr
;
4401 struct ospf_interface
*oi
;
4402 struct in_addr router_id
;
4404 json_object
*json
= NULL
;
4407 json
= json_object_new_object();
4409 if (ospf
->instance
) {
4411 json_object_int_add(json
, "ospfInstance",
4414 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4417 ret
= inet_aton(argv
[arg_base
]->arg
, &router_id
);
4420 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
4422 vty_out(vty
, "{}\n");
4423 json_object_free(json
);
4428 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4429 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, &router_id
))) {
4430 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, use_json
,
4436 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4437 json
, JSON_C_TO_STRING_PRETTY
));
4438 json_object_free(json
);
4445 DEFUN (show_ip_ospf_neighbor_id
,
4446 show_ip_ospf_neighbor_id_cmd
,
4447 "show ip ospf neighbor A.B.C.D [json]",
4450 "OSPF information\n"
4456 u_char uj
= use_json(argc
, argv
);
4458 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4461 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4464 DEFUN (show_ip_ospf_instance_neighbor_id
,
4465 show_ip_ospf_instance_neighbor_id_cmd
,
4466 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4469 "OSPF information\n"
4477 u_short instance
= 0;
4478 u_char uj
= use_json(argc
, argv
);
4480 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4481 ospf
= ospf_lookup_instance(instance
);
4483 return CMD_NOT_MY_INSTANCE
;
4485 if (!ospf
->oi_running
)
4488 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4491 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
4495 struct ospf_interface
*oi
;
4496 struct listnode
*node
;
4497 json_object
*json
= NULL
;
4500 json
= json_object_new_object();
4502 if (ospf
->instance
) {
4504 json_object_int_add(json
, "ospfInstance",
4507 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4510 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4511 struct route_node
*rn
;
4512 struct ospf_neighbor
*nbr
;
4514 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4515 if ((nbr
= rn
->info
)) {
4516 if (nbr
!= oi
->nbr_self
) {
4517 if (nbr
->state
!= NSM_Down
) {
4518 show_ip_ospf_neighbor_detail_sub(
4519 vty
, oi
, nbr
, use_json
,
4528 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4529 json
, JSON_C_TO_STRING_PRETTY
));
4530 json_object_free(json
);
4537 DEFUN (show_ip_ospf_neighbor_detail
,
4538 show_ip_ospf_neighbor_detail_cmd
,
4539 "show ip ospf neighbor detail [json]",
4542 "OSPF information\n"
4544 "detail of all neighbors\n"
4548 u_char uj
= use_json(argc
, argv
);
4550 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4553 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4556 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4557 show_ip_ospf_instance_neighbor_detail_cmd
,
4558 "show ip ospf (1-65535) neighbor detail [json]",
4561 "OSPF information\n"
4564 "detail of all neighbors\n"
4569 u_short instance
= 0;
4570 u_char uj
= use_json(argc
, argv
);
4572 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4573 ospf
= ospf_lookup_instance(instance
);
4575 return CMD_NOT_MY_INSTANCE
;
4577 if (!ospf
->oi_running
)
4580 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4583 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
4587 struct listnode
*node
;
4588 struct ospf_interface
*oi
;
4589 json_object
*json
= NULL
;
4592 json
= json_object_new_object();
4594 if (ospf
->instance
) {
4596 json_object_int_add(json
, "ospfInstance",
4599 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4602 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4603 struct route_node
*rn
;
4604 struct ospf_neighbor
*nbr
;
4605 struct ospf_nbr_nbma
*nbr_nbma
;
4607 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
4608 if ((nbr
= rn
->info
))
4609 if (nbr
!= oi
->nbr_self
)
4610 if (nbr
->state
!= NSM_Down
)
4611 show_ip_ospf_neighbor_detail_sub(
4615 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
4616 struct listnode
*nd
;
4618 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
4619 if (nbr_nbma
->nbr
== NULL
4620 || nbr_nbma
->nbr
->state
== NSM_Down
)
4621 show_ip_ospf_nbr_nbma_detail_sub(
4622 vty
, oi
, nbr_nbma
, use_json
,
4629 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4630 json
, JSON_C_TO_STRING_PRETTY
));
4631 json_object_free(json
);
4639 DEFUN (show_ip_ospf_neighbor_detail_all
,
4640 show_ip_ospf_neighbor_detail_all_cmd
,
4641 "show ip ospf neighbor detail all [json]",
4644 "OSPF information\n"
4646 "detail of all neighbors\n"
4647 "include down status neighbor\n"
4651 u_char uj
= use_json(argc
, argv
);
4653 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4656 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4659 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4660 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4661 "show ip ospf (1-65535) neighbor detail all [json]",
4664 "OSPF information\n"
4667 "detail of all neighbors\n"
4668 "include down status neighbor\n"
4673 u_short instance
= 0;
4674 u_char uj
= use_json(argc
, argv
);
4676 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4677 ospf
= ospf_lookup_instance(instance
);
4679 return CMD_NOT_MY_INSTANCE
;
4681 if (!ospf
->oi_running
)
4684 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4687 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
4690 struct cmd_token
**argv
,
4693 struct ospf_interface
*oi
;
4694 struct interface
*ifp
;
4695 struct route_node
*rn
, *nrn
;
4696 struct ospf_neighbor
*nbr
;
4697 json_object
*json
= NULL
;
4700 json
= json_object_new_object();
4702 if (ospf
->instance
) {
4704 json_object_int_add(json
, "ospfInstance",
4707 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4710 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
4713 vty_out(vty
, "No such interface.\n");
4715 vty_out(vty
, "{}\n");
4716 json_object_free(json
);
4721 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4722 if ((oi
= rn
->info
)) {
4723 for (nrn
= route_top(oi
->nbrs
); nrn
;
4724 nrn
= route_next(nrn
)) {
4725 if ((nbr
= nrn
->info
)) {
4726 if (nbr
!= oi
->nbr_self
) {
4727 if (nbr
->state
!= NSM_Down
)
4728 show_ip_ospf_neighbor_detail_sub(
4738 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4739 json
, JSON_C_TO_STRING_PRETTY
));
4740 json_object_free(json
);
4747 DEFUN (show_ip_ospf_neighbor_int_detail
,
4748 show_ip_ospf_neighbor_int_detail_cmd
,
4749 "show ip ospf neighbor IFNAME detail [json]",
4752 "OSPF information\n"
4755 "detail of all neighbors\n"
4759 u_char uj
= use_json(argc
, argv
);
4761 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4764 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4767 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4768 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4769 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4772 "OSPF information\n"
4776 "detail of all neighbors\n"
4781 u_short instance
= 0;
4782 u_char uj
= use_json(argc
, argv
);
4784 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4785 ospf
= ospf_lookup_instance(instance
);
4787 return CMD_NOT_MY_INSTANCE
;
4789 if (!ospf
->oi_running
)
4792 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4795 /* Show functions */
4796 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4798 struct router_lsa
*rl
;
4799 struct summary_lsa
*sl
;
4800 struct as_external_lsa
*asel
;
4801 struct prefix_ipv4 p
;
4804 /* If self option is set, check LSA self flag. */
4805 if (self
== 0 || IS_LSA_SELF(lsa
)) {
4806 /* LSA common part show. */
4807 vty_out(vty
, "%-15s ", inet_ntoa(lsa
->data
->id
));
4808 vty_out(vty
, "%-15s %4d 0x%08lx 0x%04x",
4809 inet_ntoa(lsa
->data
->adv_router
), LS_AGE(lsa
),
4810 (u_long
)ntohl(lsa
->data
->ls_seqnum
),
4811 ntohs(lsa
->data
->checksum
));
4812 /* LSA specific part show. */
4813 switch (lsa
->data
->type
) {
4814 case OSPF_ROUTER_LSA
:
4815 rl
= (struct router_lsa
*)lsa
->data
;
4816 vty_out(vty
, " %-d", ntohs(rl
->links
));
4818 case OSPF_SUMMARY_LSA
:
4819 sl
= (struct summary_lsa
*)lsa
->data
;
4822 p
.prefix
= sl
->header
.id
;
4823 p
.prefixlen
= ip_masklen(sl
->mask
);
4824 apply_mask_ipv4(&p
);
4826 vty_out(vty
, " %s/%d", inet_ntoa(p
.prefix
),
4829 case OSPF_AS_EXTERNAL_LSA
:
4830 case OSPF_AS_NSSA_LSA
:
4831 asel
= (struct as_external_lsa
*)lsa
->data
;
4834 p
.prefix
= asel
->header
.id
;
4835 p
.prefixlen
= ip_masklen(asel
->mask
);
4836 apply_mask_ipv4(&p
);
4838 vty_out(vty
, " %s %s/%d [0x%lx]",
4839 IS_EXTERNAL_METRIC(asel
->e
[0].tos
)
4842 inet_ntoa(p
.prefix
), p
.prefixlen
,
4843 (u_long
)ntohl(asel
->e
[0].route_tag
));
4845 case OSPF_NETWORK_LSA
:
4846 case OSPF_ASBR_SUMMARY_LSA
:
4847 case OSPF_OPAQUE_LINK_LSA
:
4848 case OSPF_OPAQUE_AREA_LSA
:
4849 case OSPF_OPAQUE_AS_LSA
:
4859 static const char *show_database_desc
[] = {
4861 "Router Link States",
4863 "Summary Link States",
4864 "ASBR-Summary Link States",
4865 "AS External Link States",
4866 "Group Membership LSA",
4867 "NSSA-external Link States",
4869 "Link-Local Opaque-LSA",
4870 "Area-Local Opaque-LSA",
4871 "AS-external Opaque-LSA",
4874 static const char *show_database_header
[] = {
4876 "Link ID ADV Router Age Seq# CkSum Link count",
4877 "Link ID ADV Router Age Seq# CkSum",
4878 "Link ID ADV Router Age Seq# CkSum Route",
4879 "Link ID ADV Router Age Seq# CkSum",
4880 "Link ID ADV Router Age Seq# CkSum Route",
4881 " --- header for Group Member ----",
4882 "Link ID ADV Router Age Seq# CkSum Route",
4884 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4885 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4886 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4889 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
)
4891 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
4893 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
4894 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
4895 ospf_options_dump(lsa
->data
->options
));
4896 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
4897 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)"
4900 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
4901 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
4904 vty_out(vty
, " :%s%s%s%s",
4905 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR" : "",
4906 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR" : "",
4907 IS_ROUTER_LSA_VIRTUAL(rlsa
) ? " VL-endpoint"
4909 IS_ROUTER_LSA_SHORTCUT(rlsa
) ? " Shortcut"
4914 vty_out(vty
, " LS Type: %s\n",
4915 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
4916 vty_out(vty
, " Link State ID: %s %s\n", inet_ntoa(lsa
->data
->id
),
4917 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
));
4918 vty_out(vty
, " Advertising Router: %s\n",
4919 inet_ntoa(lsa
->data
->adv_router
));
4920 vty_out(vty
, " LS Seq Number: %08lx\n",
4921 (u_long
)ntohl(lsa
->data
->ls_seqnum
));
4922 vty_out(vty
, " Checksum: 0x%04x\n", ntohs(lsa
->data
->checksum
));
4923 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
4926 const char *link_type_desc
[] = {
4928 "another Router (point-to-point)",
4929 "a Transit Network",
4934 const char *link_id_desc
[] = {
4935 "(null)", "Neighboring Router ID", "Designated Router address",
4936 "Net", "Neighboring Router ID",
4939 const char *link_data_desc
[] = {
4940 "(null)", "Router Interface address", "Router Interface address",
4941 "Network Mask", "Router Interface address",
4944 /* Show router-LSA each Link information. */
4945 static void show_ip_ospf_database_router_links(struct vty
*vty
,
4946 struct router_lsa
*rl
)
4951 len
= ntohs(rl
->header
.length
) - 4;
4952 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
4953 type
= rl
->link
[i
].type
;
4955 vty_out(vty
, " Link connected to: %s\n",
4956 link_type_desc
[type
]);
4957 vty_out(vty
, " (Link ID) %s: %s\n", link_id_desc
[type
],
4958 inet_ntoa(rl
->link
[i
].link_id
));
4959 vty_out(vty
, " (Link Data) %s: %s\n", link_data_desc
[type
],
4960 inet_ntoa(rl
->link
[i
].link_data
));
4961 vty_out(vty
, " Number of TOS metrics: 0\n");
4962 vty_out(vty
, " TOS 0 Metric: %d\n",
4963 ntohs(rl
->link
[i
].metric
));
4968 /* Show router-LSA detail information. */
4969 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4972 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
4974 show_ip_ospf_database_header(vty
, lsa
);
4976 vty_out(vty
, " Number of Links: %d\n\n", ntohs(rl
->links
));
4978 show_ip_ospf_database_router_links(vty
, rl
);
4985 /* Show network-LSA detail information. */
4986 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4991 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
4993 show_ip_ospf_database_header(vty
, lsa
);
4995 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(nl
->mask
));
4997 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4999 for (i
= 0; length
> 0; i
++, length
-= 4)
5000 vty_out(vty
, " Attached Router: %s\n",
5001 inet_ntoa(nl
->routers
[i
]));
5009 /* Show summary-LSA detail information. */
5010 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5013 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5015 show_ip_ospf_database_header(vty
, lsa
);
5017 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5018 vty_out(vty
, " TOS: 0 Metric: %d\n",
5019 GET_METRIC(sl
->metric
));
5026 /* Show summary-ASBR-LSA detail information. */
5027 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5030 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5032 show_ip_ospf_database_header(vty
, lsa
);
5034 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5035 vty_out(vty
, " TOS: 0 Metric: %d\n",
5036 GET_METRIC(sl
->metric
));
5043 /* Show AS-external-LSA detail information. */
5044 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5047 struct as_external_lsa
*al
=
5048 (struct as_external_lsa
*)lsa
->data
;
5050 show_ip_ospf_database_header(vty
, lsa
);
5052 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5053 vty_out(vty
, " Metric Type: %s\n",
5054 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5055 ? "2 (Larger than any link state path)"
5057 vty_out(vty
, " TOS: 0\n");
5058 vty_out(vty
, " Metric: %d\n",
5059 GET_METRIC(al
->e
[0].metric
));
5060 vty_out(vty
, " Forward Address: %s\n",
5061 inet_ntoa(al
->e
[0].fwd_addr
));
5064 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5065 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5072 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5074 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5076 /* show_ip_ospf_database_header (vty, lsa); */
5078 zlog_debug( " Network Mask: /%d%s",
5079 ip_masklen (al
->mask
), "\n");
5080 zlog_debug( " Metric Type: %s%s",
5081 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5082 "2 (Larger than any link state path)" : "1", "\n");
5083 zlog_debug( " TOS: 0%s", "\n");
5084 zlog_debug( " Metric: %d%s",
5085 GET_METRIC (al
->e
[0].metric
), "\n");
5086 zlog_debug( " Forward Address: %s%s",
5087 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5089 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5090 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5095 /* Show AS-NSSA-LSA detail information. */
5096 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5099 struct as_external_lsa
*al
=
5100 (struct as_external_lsa
*)lsa
->data
;
5102 show_ip_ospf_database_header(vty
, lsa
);
5104 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5105 vty_out(vty
, " Metric Type: %s\n",
5106 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5107 ? "2 (Larger than any link state path)"
5109 vty_out(vty
, " TOS: 0\n");
5110 vty_out(vty
, " Metric: %d\n",
5111 GET_METRIC(al
->e
[0].metric
));
5112 vty_out(vty
, " NSSA: Forward Address: %s\n",
5113 inet_ntoa(al
->e
[0].fwd_addr
));
5116 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5117 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5123 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
)
5128 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5131 show_ip_ospf_database_header(vty
, lsa
);
5132 show_opaque_info_detail(vty
, lsa
);
5139 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) = {
5141 show_router_lsa_detail
,
5142 show_network_lsa_detail
,
5143 show_summary_lsa_detail
,
5144 show_summary_asbr_lsa_detail
,
5145 show_as_external_lsa_detail
,
5147 show_as_nssa_lsa_detail
, /* almost same as external */
5149 show_opaque_lsa_detail
,
5150 show_opaque_lsa_detail
,
5151 show_opaque_lsa_detail
,
5154 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
5155 struct in_addr
*id
, struct in_addr
*adv_router
)
5157 memset(lp
, 0, sizeof(struct prefix_ls
));
5161 else if (adv_router
== NULL
) {
5167 lp
->adv_router
= *adv_router
;
5171 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
5172 struct in_addr
*id
, struct in_addr
*adv_router
)
5174 struct prefix_ls lp
;
5175 struct route_node
*rn
, *start
;
5176 struct ospf_lsa
*lsa
;
5178 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
5179 start
= route_node_get(rt
, (struct prefix
*)&lp
);
5181 route_lock_node(start
);
5182 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
5183 if ((lsa
= rn
->info
)) {
5184 if (show_function
[lsa
->data
->type
] != NULL
)
5185 show_function
[lsa
->data
->type
](vty
,
5188 route_unlock_node(start
);
5192 /* Show detail LSA information
5193 -- if id is NULL then show all LSAs. */
5194 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
5195 struct in_addr
*id
, struct in_addr
*adv_router
)
5197 struct listnode
*node
;
5198 struct ospf_area
*area
;
5201 case OSPF_AS_EXTERNAL_LSA
:
5202 case OSPF_OPAQUE_AS_LSA
:
5203 vty_out(vty
, " %s \n\n",
5204 show_database_desc
[type
]);
5205 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
);
5208 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5209 vty_out(vty
, "\n %s (Area %s)\n\n",
5210 show_database_desc
[type
],
5211 ospf_area_desc_string(area
));
5212 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
5219 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
5220 struct route_table
*rt
,
5221 struct in_addr
*adv_router
)
5223 struct route_node
*rn
;
5224 struct ospf_lsa
*lsa
;
5226 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
5227 if ((lsa
= rn
->info
))
5228 if (IPV4_ADDR_SAME(adv_router
,
5229 &lsa
->data
->adv_router
)) {
5230 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5232 if (show_function
[lsa
->data
->type
] != NULL
)
5233 show_function
[lsa
->data
->type
](vty
,
5238 /* Show detail LSA information. */
5239 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
5240 int type
, struct in_addr
*adv_router
)
5242 struct listnode
*node
;
5243 struct ospf_area
*area
;
5246 case OSPF_AS_EXTERNAL_LSA
:
5247 case OSPF_OPAQUE_AS_LSA
:
5248 vty_out(vty
, " %s \n\n",
5249 show_database_desc
[type
]);
5250 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
5254 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5255 vty_out(vty
, "\n %s (Area %s)\n\n",
5256 show_database_desc
[type
],
5257 ospf_area_desc_string(area
));
5258 show_lsa_detail_adv_router_proc(
5259 vty
, AREA_LSDB(area
, type
), adv_router
);
5265 static void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
,
5268 struct ospf_lsa
*lsa
;
5269 struct route_node
*rn
;
5270 struct ospf_area
*area
;
5271 struct listnode
*node
;
5274 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5275 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5277 case OSPF_AS_EXTERNAL_LSA
:
5278 case OSPF_OPAQUE_AS_LSA
:
5283 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
5285 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
5286 vty_out(vty
, " %s (Area %s)\n\n",
5287 show_database_desc
[type
],
5288 ospf_area_desc_string(area
));
5289 vty_out(vty
, "%s\n",
5290 show_database_header
[type
]);
5292 LSDB_LOOP(AREA_LSDB(area
, type
), rn
, lsa
)
5293 show_lsa_summary(vty
, lsa
, self
);
5300 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5302 case OSPF_AS_EXTERNAL_LSA
:
5303 case OSPF_OPAQUE_AS_LSA
:
5308 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
5309 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
5310 vty_out(vty
, " %s\n\n",
5311 show_database_desc
[type
]);
5312 vty_out(vty
, "%s\n", show_database_header
[type
]);
5314 LSDB_LOOP(AS_LSDB(ospf
, type
), rn
, lsa
)
5315 show_lsa_summary(vty
, lsa
, self
);
5324 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
)
5326 struct route_node
*rn
;
5328 vty_out(vty
, "\n MaxAge Link States:\n\n");
5330 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
5331 struct ospf_lsa
*lsa
;
5333 if ((lsa
= rn
->info
) != NULL
) {
5334 vty_out(vty
, "Link type: %d\n", lsa
->data
->type
);
5335 vty_out(vty
, "Link State ID: %s\n",
5336 inet_ntoa(lsa
->data
->id
));
5337 vty_out(vty
, "Advertising Router: %s\n",
5338 inet_ntoa(lsa
->data
->adv_router
));
5339 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
5345 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5346 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5348 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5349 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5350 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5351 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5353 #define OSPF_LSA_TYPES_DESC \
5354 "ASBR summary link states\n" \
5355 "External link states\n" \
5356 "Network link states\n" \
5357 "Router link states\n" \
5358 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
5359 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5360 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5362 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
5363 int arg_base
, int argc
,
5364 struct cmd_token
**argv
)
5368 struct in_addr id
, adv_router
;
5371 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5373 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5374 inet_ntoa(ospf
->router_id
));
5377 if (argc
== arg_base
+ 4) {
5378 show_ip_ospf_database_summary(vty
, ospf
, 0);
5382 /* Set database type to show. */
5383 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5384 type
= OSPF_ROUTER_LSA
;
5385 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5386 type
= OSPF_NETWORK_LSA
;
5387 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5388 type
= OSPF_AS_NSSA_LSA
;
5389 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5390 type
= OSPF_SUMMARY_LSA
;
5391 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5392 type
= OSPF_ASBR_SUMMARY_LSA
;
5393 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5394 type
= OSPF_AS_EXTERNAL_LSA
;
5395 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
5396 show_ip_ospf_database_summary(vty
, ospf
, 1);
5398 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
5399 show_ip_ospf_database_maxage(vty
, ospf
);
5401 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5402 type
= OSPF_OPAQUE_LINK_LSA
;
5403 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5404 type
= OSPF_OPAQUE_AREA_LSA
;
5405 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5406 type
= OSPF_OPAQUE_AS_LSA
;
5410 /* `show ip ospf database LSA'. */
5411 if (argc
== arg_base
+ 5)
5412 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
);
5413 else if (argc
>= arg_base
+ 6) {
5414 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
5418 /* `show ip ospf database LSA ID'. */
5419 if (argc
== arg_base
+ 6)
5420 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
);
5421 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5422 else if (argc
== arg_base
+ 7) {
5423 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5424 adv_router
= ospf
->router_id
;
5426 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
5431 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
);
5438 DEFUN (show_ip_ospf_database_max
,
5439 show_ip_ospf_database_max_cmd
,
5440 "show ip ospf database <max-age|self-originate>",
5443 "OSPF information\n"
5444 "Database summary\n"
5445 "LSAs in MaxAge list\n"
5446 "Self-originated link states\n")
5450 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5453 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5456 DEFUN (show_ip_ospf_instance_database
,
5457 show_ip_ospf_instance_database_cmd
,
5458 "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>]]]",
5461 "OSPF information\n"
5463 "Database summary\n"
5465 "Link State ID (as an IP address)\n"
5466 "Self-originated link states\n"
5467 "Advertising Router link states\n"
5468 "Advertising Router (as an IP address)\n")
5471 u_short instance
= 0;
5474 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5475 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5476 ospf
= ospf_lookup_instance(instance
);
5478 return CMD_NOT_MY_INSTANCE
;
5480 ospf
= ospf_lookup();
5483 if (!ospf
|| !ospf
->oi_running
)
5486 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
,
5490 DEFUN (show_ip_ospf_instance_database_max
,
5491 show_ip_ospf_instance_database_max_cmd
,
5492 "show ip ospf (1-65535) database <max-age|self-originate>",
5495 "OSPF information\n"
5497 "Database summary\n"
5498 "LSAs in MaxAge list\n"
5499 "Self-originated link states\n")
5503 u_short instance
= 0;
5505 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5507 ospf
= ospf_lookup_instance(instance
);
5509 return CMD_NOT_MY_INSTANCE
;
5511 if (!ospf
->oi_running
)
5514 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5518 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
5520 int arg_base
, int argc
,
5521 struct cmd_token
**argv
)
5525 struct in_addr adv_router
;
5528 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5530 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5531 inet_ntoa(ospf
->router_id
));
5533 /* Set database type to show. */
5534 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5535 type
= OSPF_ROUTER_LSA
;
5536 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5537 type
= OSPF_NETWORK_LSA
;
5538 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5539 type
= OSPF_AS_NSSA_LSA
;
5540 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5541 type
= OSPF_SUMMARY_LSA
;
5542 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5543 type
= OSPF_ASBR_SUMMARY_LSA
;
5544 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5545 type
= OSPF_AS_EXTERNAL_LSA
;
5546 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5547 type
= OSPF_OPAQUE_LINK_LSA
;
5548 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5549 type
= OSPF_OPAQUE_AREA_LSA
;
5550 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5551 type
= OSPF_OPAQUE_AS_LSA
;
5555 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5556 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5557 adv_router
= ospf
->router_id
;
5559 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
5564 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
);
5569 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5570 show_ip_ospf_instance_database_type_adv_router_cmd
,
5571 "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>",
5574 "OSPF information\n"
5576 "Database summary\n"
5578 "Advertising Router link states\n"
5579 "Advertising Router (as an IP address)\n"
5580 "Self-originated link states\n")
5583 u_short instance
= 0;
5586 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5587 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5588 ospf
= ospf_lookup_instance(instance
);
5590 return CMD_NOT_MY_INSTANCE
;
5592 ospf
= ospf_lookup();
5594 if (!ospf
|| !ospf
->oi_running
)
5597 return (show_ip_ospf_database_type_adv_router_common(
5598 vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5601 DEFUN (ip_ospf_authentication_args
,
5602 ip_ospf_authentication_args_addr_cmd
,
5603 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5605 "OSPF interface commands\n"
5606 "Enable authentication on this interface\n"
5607 "Use null authentication\n"
5608 "Use message-digest authentication\n"
5609 "Address of interface\n")
5611 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5612 int idx_encryption
= 3;
5614 struct in_addr addr
;
5616 struct ospf_if_params
*params
;
5618 params
= IF_DEF_PARAMS(ifp
);
5621 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5624 "Please specify interface address by A.B.C.D\n");
5625 return CMD_WARNING_CONFIG_FAILED
;
5628 params
= ospf_get_if_params(ifp
, addr
);
5629 ospf_if_update_params(ifp
, addr
);
5632 /* Handle null authentication */
5633 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5634 SET_IF_PARAM(params
, auth_type
);
5635 params
->auth_type
= OSPF_AUTH_NULL
;
5639 /* Handle message-digest authentication */
5640 if (argv
[idx_encryption
]->arg
[0] == 'm') {
5641 SET_IF_PARAM(params
, auth_type
);
5642 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5646 vty_out(vty
, "You shouldn't get here!\n");
5647 return CMD_WARNING_CONFIG_FAILED
;
5650 DEFUN (ip_ospf_authentication
,
5651 ip_ospf_authentication_addr_cmd
,
5652 "ip ospf authentication [A.B.C.D]",
5654 "OSPF interface commands\n"
5655 "Enable authentication on this interface\n"
5656 "Address of interface")
5658 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5660 struct in_addr addr
;
5662 struct ospf_if_params
*params
;
5664 params
= IF_DEF_PARAMS(ifp
);
5667 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5670 "Please specify interface address by A.B.C.D\n");
5671 return CMD_WARNING_CONFIG_FAILED
;
5674 params
= ospf_get_if_params(ifp
, addr
);
5675 ospf_if_update_params(ifp
, addr
);
5678 SET_IF_PARAM(params
, auth_type
);
5679 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5684 DEFUN (no_ip_ospf_authentication_args
,
5685 no_ip_ospf_authentication_args_addr_cmd
,
5686 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5689 "OSPF interface commands\n"
5690 "Enable authentication on this interface\n"
5691 "Use null authentication\n"
5692 "Use message-digest authentication\n"
5693 "Address of interface")
5695 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5696 int idx_encryption
= 4;
5698 struct in_addr addr
;
5700 struct ospf_if_params
*params
;
5701 struct route_node
*rn
;
5704 params
= IF_DEF_PARAMS(ifp
);
5707 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5710 "Please specify interface address by A.B.C.D\n");
5711 return CMD_WARNING_CONFIG_FAILED
;
5714 params
= ospf_lookup_if_params(ifp
, addr
);
5715 if (params
== NULL
) {
5716 vty_out(vty
, "Ip Address specified is unknown\n");
5717 return CMD_WARNING_CONFIG_FAILED
;
5719 params
->auth_type
= OSPF_AUTH_NOTSET
;
5720 UNSET_IF_PARAM(params
, auth_type
);
5721 if (params
!= IF_DEF_PARAMS(ifp
)) {
5722 ospf_free_if_params(ifp
, addr
);
5723 ospf_if_update_params(ifp
, addr
);
5726 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5727 auth_type
= OSPF_AUTH_NULL
;
5728 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
5729 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5731 vty_out(vty
, "Unexpected input encountered\n");
5732 return CMD_WARNING_CONFIG_FAILED
;
5735 * Here we have a case where the user has entered
5736 * 'no ip ospf authentication (null | message_digest )'
5737 * we need to find if we have any ip addresses underneath it
5739 * correspond to the associated type.
5741 if (params
->auth_type
== auth_type
) {
5742 params
->auth_type
= OSPF_AUTH_NOTSET
;
5743 UNSET_IF_PARAM(params
, auth_type
);
5746 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5747 rn
= route_next(rn
)) {
5748 if ((params
= rn
->info
)) {
5749 if (params
->auth_type
== auth_type
) {
5750 params
->auth_type
= OSPF_AUTH_NOTSET
;
5751 UNSET_IF_PARAM(params
, auth_type
);
5752 if (params
!= IF_DEF_PARAMS(ifp
)) {
5753 ospf_free_if_params(
5754 ifp
, rn
->p
.u
.prefix4
);
5755 ospf_if_update_params(
5756 ifp
, rn
->p
.u
.prefix4
);
5766 DEFUN (no_ip_ospf_authentication
,
5767 no_ip_ospf_authentication_addr_cmd
,
5768 "no ip ospf authentication [A.B.C.D]",
5771 "OSPF interface commands\n"
5772 "Enable authentication on this interface\n"
5773 "Address of interface")
5775 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5777 struct in_addr addr
;
5779 struct ospf_if_params
*params
;
5780 struct route_node
*rn
;
5782 params
= IF_DEF_PARAMS(ifp
);
5785 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5788 "Please specify interface address by A.B.C.D\n");
5789 return CMD_WARNING_CONFIG_FAILED
;
5792 params
= ospf_lookup_if_params(ifp
, addr
);
5793 if (params
== NULL
) {
5794 vty_out(vty
, "Ip Address specified is unknown\n");
5795 return CMD_WARNING_CONFIG_FAILED
;
5798 params
->auth_type
= OSPF_AUTH_NOTSET
;
5799 UNSET_IF_PARAM(params
, auth_type
);
5800 if (params
!= IF_DEF_PARAMS(ifp
)) {
5801 ospf_free_if_params(ifp
, addr
);
5802 ospf_if_update_params(ifp
, addr
);
5806 * When a user enters 'no ip ospf authentication'
5807 * We should remove all authentication types from
5810 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5811 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
5812 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
5813 params
->auth_type
= OSPF_AUTH_NOTSET
;
5814 UNSET_IF_PARAM(params
, auth_type
);
5817 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5818 rn
= route_next(rn
)) {
5819 if ((params
= rn
->info
)) {
5821 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5822 || (params
->auth_type
5823 == OSPF_AUTH_CRYPTOGRAPHIC
)
5824 || (params
->auth_type
5825 == OSPF_AUTH_SIMPLE
)) {
5826 params
->auth_type
= OSPF_AUTH_NOTSET
;
5827 UNSET_IF_PARAM(params
, auth_type
);
5828 if (params
!= IF_DEF_PARAMS(ifp
)) {
5829 ospf_free_if_params(
5830 ifp
, rn
->p
.u
.prefix4
);
5831 ospf_if_update_params(
5832 ifp
, rn
->p
.u
.prefix4
);
5843 DEFUN (ip_ospf_authentication_key
,
5844 ip_ospf_authentication_key_addr_cmd
,
5845 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5847 "OSPF interface commands\n"
5848 "Authentication password (key)\n"
5849 "The OSPF password (key)\n"
5850 "Address of interface")
5852 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5854 struct in_addr addr
;
5855 struct ospf_if_params
*params
;
5857 params
= IF_DEF_PARAMS(ifp
);
5859 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5860 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5862 "Please specify interface address by A.B.C.D\n");
5863 return CMD_WARNING_CONFIG_FAILED
;
5866 params
= ospf_get_if_params(ifp
, addr
);
5867 ospf_if_update_params(ifp
, addr
);
5870 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5871 strncpy((char *)params
->auth_simple
, argv
[3]->arg
,
5872 OSPF_AUTH_SIMPLE_SIZE
);
5873 SET_IF_PARAM(params
, auth_simple
);
5878 DEFUN_HIDDEN (ospf_authentication_key
,
5879 ospf_authentication_key_cmd
,
5880 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5881 "OSPF interface commands\n"
5882 "Authentication password (key)\n"
5883 "The OSPF password (key)\n"
5884 "Address of interface\n")
5886 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
5889 DEFUN (no_ip_ospf_authentication_key
,
5890 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5891 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5894 "OSPF interface commands\n"
5895 "Authentication password (key)\n"
5896 "The OSPF password (key)")
5898 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5900 struct in_addr addr
;
5901 struct ospf_if_params
*params
;
5902 params
= IF_DEF_PARAMS(ifp
);
5904 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5905 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5907 "Please specify interface address by A.B.C.D\n");
5908 return CMD_WARNING_CONFIG_FAILED
;
5911 params
= ospf_lookup_if_params(ifp
, addr
);
5916 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5917 UNSET_IF_PARAM(params
, auth_simple
);
5919 if (params
!= IF_DEF_PARAMS(ifp
)) {
5920 ospf_free_if_params(ifp
, addr
);
5921 ospf_if_update_params(ifp
, addr
);
5927 DEFUN_HIDDEN (no_ospf_authentication_key
,
5928 no_ospf_authentication_key_authkey_addr_cmd
,
5929 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5931 "OSPF interface commands\n"
5932 "Authentication password (key)\n"
5933 "The OSPF password (key)")
5935 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
5938 DEFUN (ip_ospf_message_digest_key
,
5939 ip_ospf_message_digest_key_cmd
,
5940 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5942 "OSPF interface commands\n"
5943 "Message digest authentication password (key)\n"
5945 "Use MD5 algorithm\n"
5946 "The OSPF password (key)\n"
5947 "Address of interface\n")
5949 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5950 struct crypt_key
*ck
;
5952 struct in_addr addr
;
5953 struct ospf_if_params
*params
;
5955 params
= IF_DEF_PARAMS(ifp
);
5958 argv_find(argv
, argc
, "(1-255)", &idx
);
5959 char *keyid
= argv
[idx
]->arg
;
5960 argv_find(argv
, argc
, "KEY", &idx
);
5961 char *cryptkey
= argv
[idx
]->arg
;
5963 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5964 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5966 "Please specify interface address by A.B.C.D\n");
5967 return CMD_WARNING_CONFIG_FAILED
;
5970 params
= ospf_get_if_params(ifp
, addr
);
5971 ospf_if_update_params(ifp
, addr
);
5974 key_id
= strtol(keyid
, NULL
, 10);
5975 if (ospf_crypt_key_lookup(params
->auth_crypt
, key_id
) != NULL
) {
5976 vty_out(vty
, "OSPF: Key %d already exists\n", key_id
);
5977 return CMD_WARNING_CONFIG_FAILED
;
5980 ck
= ospf_crypt_key_new();
5981 ck
->key_id
= (u_char
)key_id
;
5982 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
5983 strncpy((char *)ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5985 ospf_crypt_key_add(params
->auth_crypt
, ck
);
5986 SET_IF_PARAM(params
, auth_crypt
);
5991 DEFUN_HIDDEN (ospf_message_digest_key
,
5992 ospf_message_digest_key_cmd
,
5993 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5994 "OSPF interface commands\n"
5995 "Message digest authentication password (key)\n"
5997 "Use MD5 algorithm\n"
5998 "The OSPF password (key)\n"
5999 "Address of interface\n")
6001 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6004 DEFUN (no_ip_ospf_message_digest_key
,
6005 no_ip_ospf_message_digest_key_cmd
,
6006 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6009 "OSPF interface commands\n"
6010 "Message digest authentication password (key)\n"
6012 "Use MD5 algorithm\n"
6013 "The OSPF password (key)\n"
6014 "Address of interface\n")
6016 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6018 struct crypt_key
*ck
;
6020 struct in_addr addr
;
6021 struct ospf_if_params
*params
;
6022 params
= IF_DEF_PARAMS(ifp
);
6024 argv_find(argv
, argc
, "(1-255)", &idx
);
6025 char *keyid
= argv
[idx
]->arg
;
6027 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6028 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6030 "Please specify interface address by A.B.C.D\n");
6031 return CMD_WARNING_CONFIG_FAILED
;
6034 params
= ospf_lookup_if_params(ifp
, addr
);
6039 key_id
= strtol(keyid
, NULL
, 10);
6040 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
6042 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
6043 return CMD_WARNING_CONFIG_FAILED
;
6046 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
6048 if (params
!= IF_DEF_PARAMS(ifp
)) {
6049 ospf_free_if_params(ifp
, addr
);
6050 ospf_if_update_params(ifp
, addr
);
6056 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6057 no_ospf_message_digest_key_cmd
,
6058 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6060 "OSPF interface commands\n"
6061 "Message digest authentication password (key)\n"
6063 "Address of interface")
6065 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6068 DEFUN (ip_ospf_cost
,
6070 "ip ospf cost (1-65535) [A.B.C.D]",
6072 "OSPF interface commands\n"
6075 "Address of interface\n")
6077 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6080 struct in_addr addr
;
6081 struct ospf_if_params
*params
;
6082 params
= IF_DEF_PARAMS(ifp
);
6085 char *coststr
= NULL
, *ifaddr
= NULL
;
6086 coststr
= argv_find(argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
6088 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6090 cost
= strtol(coststr
, NULL
, 10);
6093 if (!inet_aton(ifaddr
, &addr
)) {
6095 "Please specify interface address by A.B.C.D\n");
6096 return CMD_WARNING_CONFIG_FAILED
;
6099 params
= ospf_get_if_params(ifp
, addr
);
6100 ospf_if_update_params(ifp
, addr
);
6103 SET_IF_PARAM(params
, output_cost_cmd
);
6104 params
->output_cost_cmd
= cost
;
6106 ospf_if_recalculate_output_cost(ifp
);
6111 DEFUN_HIDDEN (ospf_cost
,
6113 "ospf cost (1-65535) [A.B.C.D]",
6114 "OSPF interface commands\n"
6117 "Address of interface\n")
6119 return ip_ospf_cost(self
, vty
, argc
, argv
);
6122 DEFUN (no_ip_ospf_cost
,
6123 no_ip_ospf_cost_cmd
,
6124 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6126 "OSPF interface commands\n"
6128 "Address of interface")
6130 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6132 struct in_addr addr
;
6133 struct ospf_if_params
*params
;
6135 params
= IF_DEF_PARAMS(ifp
);
6138 char *ifaddr
= NULL
;
6139 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6141 /* According to the semantics we are mimicking "no ip ospf cost N" is
6142 * always treated as "no ip ospf cost" regardless of the actual value
6143 * of N already configured for the interface. Thus ignore cost. */
6146 if (!inet_aton(ifaddr
, &addr
)) {
6148 "Please specify interface address by A.B.C.D\n");
6149 return CMD_WARNING_CONFIG_FAILED
;
6152 params
= ospf_lookup_if_params(ifp
, addr
);
6157 UNSET_IF_PARAM(params
, output_cost_cmd
);
6159 if (params
!= IF_DEF_PARAMS(ifp
)) {
6160 ospf_free_if_params(ifp
, addr
);
6161 ospf_if_update_params(ifp
, addr
);
6164 ospf_if_recalculate_output_cost(ifp
);
6169 DEFUN_HIDDEN (no_ospf_cost
,
6171 "no ospf cost [(1-65535)] [A.B.C.D]",
6173 "OSPF interface commands\n"
6176 "Address of interface\n")
6178 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
6181 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
6183 struct route_node
*rn
;
6184 struct ospf_neighbor
*nbr
;
6186 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
6187 if ((nbr
= rn
->info
)) {
6188 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
6189 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6190 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6191 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6195 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
6196 const char *nbr_str
,
6197 const char *fast_hello_str
)
6199 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6202 struct in_addr addr
;
6204 struct ospf_if_params
*params
;
6205 struct ospf_interface
*oi
;
6206 struct route_node
*rn
;
6208 params
= IF_DEF_PARAMS(ifp
);
6211 ret
= inet_aton(nbr_str
, &addr
);
6214 "Please specify interface address by A.B.C.D\n");
6215 return CMD_WARNING_CONFIG_FAILED
;
6218 params
= ospf_get_if_params(ifp
, addr
);
6219 ospf_if_update_params(ifp
, addr
);
6223 seconds
= strtoul(interval_str
, NULL
, 10);
6225 /* reset fast_hello too, just to be sure */
6226 UNSET_IF_PARAM(params
, fast_hello
);
6227 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6228 } else if (fast_hello_str
) {
6229 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
6230 /* 1s dead-interval with sub-second hellos desired */
6231 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6232 SET_IF_PARAM(params
, fast_hello
);
6233 params
->fast_hello
= hellomult
;
6236 "Please specify dead-interval or hello-multiplier\n");
6237 return CMD_WARNING_CONFIG_FAILED
;
6240 SET_IF_PARAM(params
, v_wait
);
6241 params
->v_wait
= seconds
;
6243 /* Update timer values in neighbor structure. */
6246 if ((ospf
= ospf_lookup())) {
6247 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6249 ospf_nbr_timer_update(oi
);
6252 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6253 if ((oi
= rn
->info
))
6254 ospf_nbr_timer_update(oi
);
6260 DEFUN (ip_ospf_dead_interval
,
6261 ip_ospf_dead_interval_cmd
,
6262 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6264 "OSPF interface commands\n"
6265 "Interval time after which a neighbor is declared down\n"
6267 "Address of interface\n")
6270 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
6274 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6275 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
6279 DEFUN_HIDDEN (ospf_dead_interval
,
6280 ospf_dead_interval_cmd
,
6281 "ospf dead-interval (1-65535) [A.B.C.D]",
6282 "OSPF interface commands\n"
6283 "Interval time after which a neighbor is declared down\n"
6285 "Address of interface\n")
6287 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6290 DEFUN (ip_ospf_dead_interval_minimal
,
6291 ip_ospf_dead_interval_minimal_addr_cmd
,
6292 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6294 "OSPF interface commands\n"
6295 "Interval time after which a neighbor is declared down\n"
6296 "Minimal 1s dead-interval with fast sub-second hellos\n"
6297 "Hello multiplier factor\n"
6298 "Number of Hellos to send each second\n"
6299 "Address of interface\n")
6304 return ospf_vty_dead_interval_set(
6305 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6307 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
6308 argv
[idx_number
]->arg
);
6311 DEFUN (no_ip_ospf_dead_interval
,
6312 no_ip_ospf_dead_interval_cmd
,
6313 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6316 "OSPF interface commands\n"
6317 "Interval time after which a neighbor is declared down\n"
6319 "Address of interface")
6321 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6322 int idx_ipv4
= argc
- 1;
6323 struct in_addr addr
= {.s_addr
= 0L};
6325 struct ospf_if_params
*params
;
6326 struct ospf_interface
*oi
;
6327 struct route_node
*rn
;
6329 params
= IF_DEF_PARAMS(ifp
);
6331 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
6332 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6335 "Please specify interface address by A.B.C.D\n");
6336 return CMD_WARNING_CONFIG_FAILED
;
6339 params
= ospf_lookup_if_params(ifp
, addr
);
6344 UNSET_IF_PARAM(params
, v_wait
);
6345 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6347 UNSET_IF_PARAM(params
, fast_hello
);
6348 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6350 if (params
!= IF_DEF_PARAMS(ifp
)) {
6351 ospf_free_if_params(ifp
, addr
);
6352 ospf_if_update_params(ifp
, addr
);
6355 /* Update timer values in neighbor structure. */
6359 if ((ospf
= ospf_lookup())) {
6360 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6362 ospf_nbr_timer_update(oi
);
6365 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6366 if ((oi
= rn
->info
))
6367 ospf_nbr_timer_update(oi
);
6373 DEFUN_HIDDEN (no_ospf_dead_interval
,
6374 no_ospf_dead_interval_cmd
,
6375 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6377 "OSPF interface commands\n"
6378 "Interval time after which a neighbor is declared down\n"
6380 "Address of interface")
6382 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6385 DEFUN (ip_ospf_hello_interval
,
6386 ip_ospf_hello_interval_cmd
,
6387 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6389 "OSPF interface commands\n"
6390 "Time between HELLO packets\n"
6392 "Address of interface\n")
6394 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6396 struct in_addr addr
;
6397 struct ospf_if_params
*params
;
6398 params
= IF_DEF_PARAMS(ifp
);
6399 u_int32_t seconds
= 0;
6401 argv_find(argv
, argc
, "(1-65535)", &idx
);
6402 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6404 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6405 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6407 "Please specify interface address by A.B.C.D\n");
6408 return CMD_WARNING_CONFIG_FAILED
;
6411 params
= ospf_get_if_params(ifp
, addr
);
6412 ospf_if_update_params(ifp
, addr
);
6415 SET_IF_PARAM(params
, v_hello
);
6416 params
->v_hello
= seconds
;
6421 DEFUN_HIDDEN (ospf_hello_interval
,
6422 ospf_hello_interval_cmd
,
6423 "ospf hello-interval (1-65535) [A.B.C.D]",
6424 "OSPF interface commands\n"
6425 "Time between HELLO packets\n"
6427 "Address of interface\n")
6429 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6432 DEFUN (no_ip_ospf_hello_interval
,
6433 no_ip_ospf_hello_interval_cmd
,
6434 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6437 "OSPF interface commands\n"
6438 "Time between HELLO packets\n" // ignored
6440 "Address of interface\n")
6442 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6444 struct in_addr addr
;
6445 struct ospf_if_params
*params
;
6447 params
= IF_DEF_PARAMS(ifp
);
6449 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6450 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6452 "Please specify interface address by A.B.C.D\n");
6453 return CMD_WARNING_CONFIG_FAILED
;
6456 params
= ospf_lookup_if_params(ifp
, addr
);
6461 UNSET_IF_PARAM(params
, v_hello
);
6462 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6464 if (params
!= IF_DEF_PARAMS(ifp
)) {
6465 ospf_free_if_params(ifp
, addr
);
6466 ospf_if_update_params(ifp
, addr
);
6472 DEFUN_HIDDEN (no_ospf_hello_interval
,
6473 no_ospf_hello_interval_cmd
,
6474 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6476 "OSPF interface commands\n"
6477 "Time between HELLO packets\n" // ignored
6479 "Address of interface\n")
6481 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6484 DEFUN (ip_ospf_network
,
6485 ip_ospf_network_cmd
,
6486 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6488 "OSPF interface commands\n"
6490 "Specify OSPF broadcast multi-access network\n"
6491 "Specify OSPF NBMA network\n"
6492 "Specify OSPF point-to-multipoint network\n"
6493 "Specify OSPF point-to-point network\n")
6495 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6497 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6498 struct route_node
*rn
;
6500 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
6502 "This is a loopback interface. Can't set network type.\n");
6503 return CMD_WARNING_CONFIG_FAILED
;
6506 if (argv_find(argv
, argc
, "broadcast", &idx
))
6507 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6508 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
6509 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
6510 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
6511 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6512 else if (argv_find(argv
, argc
, "point-to-point", &idx
))
6513 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6515 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6518 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
6520 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6521 struct ospf_interface
*oi
= rn
->info
;
6526 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6528 if (oi
->state
> ISM_Down
) {
6529 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6530 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6537 DEFUN_HIDDEN (ospf_network
,
6539 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6540 "OSPF interface commands\n"
6542 "Specify OSPF broadcast multi-access network\n"
6543 "Specify OSPF NBMA network\n"
6544 "Specify OSPF point-to-multipoint network\n"
6545 "Specify OSPF point-to-point network\n")
6547 return ip_ospf_network(self
, vty
, argc
, argv
);
6550 DEFUN (no_ip_ospf_network
,
6551 no_ip_ospf_network_cmd
,
6552 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6555 "OSPF interface commands\n"
6557 "Specify OSPF broadcast multi-access network\n"
6558 "Specify OSPF NBMA network\n"
6559 "Specify OSPF point-to-multipoint network\n"
6560 "Specify OSPF point-to-point network\n")
6562 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6563 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6564 struct route_node
*rn
;
6566 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
6568 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6571 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6572 struct ospf_interface
*oi
= rn
->info
;
6577 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6579 if (oi
->state
> ISM_Down
) {
6580 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6581 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6588 DEFUN_HIDDEN (no_ospf_network
,
6589 no_ospf_network_cmd
,
6590 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6592 "OSPF interface commands\n"
6594 "Specify OSPF broadcast multi-access network\n"
6595 "Specify OSPF NBMA network\n"
6596 "Specify OSPF point-to-multipoint network\n"
6597 "Specify OSPF point-to-point network\n")
6599 return no_ip_ospf_network(self
, vty
, argc
, argv
);
6602 DEFUN (ip_ospf_priority
,
6603 ip_ospf_priority_cmd
,
6604 "ip ospf priority (0-255) [A.B.C.D]",
6606 "OSPF interface commands\n"
6609 "Address of interface")
6611 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6614 struct route_node
*rn
;
6615 struct in_addr addr
;
6616 struct ospf_if_params
*params
;
6617 params
= IF_DEF_PARAMS(ifp
);
6619 argv_find(argv
, argc
, "(0-255)", &idx
);
6620 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
6622 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6623 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6625 "Please specify interface address by A.B.C.D\n");
6626 return CMD_WARNING_CONFIG_FAILED
;
6629 params
= ospf_get_if_params(ifp
, addr
);
6630 ospf_if_update_params(ifp
, addr
);
6633 SET_IF_PARAM(params
, priority
);
6634 params
->priority
= priority
;
6636 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6637 struct ospf_interface
*oi
= rn
->info
;
6642 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6643 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6644 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6651 DEFUN_HIDDEN (ospf_priority
,
6653 "ospf priority (0-255) [A.B.C.D]",
6654 "OSPF interface commands\n"
6657 "Address of interface")
6659 return ip_ospf_priority(self
, vty
, argc
, argv
);
6662 DEFUN (no_ip_ospf_priority
,
6663 no_ip_ospf_priority_cmd
,
6664 "no ip ospf priority [(0-255) [A.B.C.D]]",
6667 "OSPF interface commands\n"
6668 "Router priority\n" // ignored
6670 "Address of interface")
6672 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6674 struct route_node
*rn
;
6675 struct in_addr addr
;
6676 struct ospf_if_params
*params
;
6678 params
= IF_DEF_PARAMS(ifp
);
6680 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6681 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6683 "Please specify interface address by A.B.C.D\n");
6684 return CMD_WARNING_CONFIG_FAILED
;
6687 params
= ospf_lookup_if_params(ifp
, addr
);
6692 UNSET_IF_PARAM(params
, priority
);
6693 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6695 if (params
!= IF_DEF_PARAMS(ifp
)) {
6696 ospf_free_if_params(ifp
, addr
);
6697 ospf_if_update_params(ifp
, addr
);
6700 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6701 struct ospf_interface
*oi
= rn
->info
;
6706 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6707 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6708 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6715 DEFUN_HIDDEN (no_ospf_priority
,
6716 no_ospf_priority_cmd
,
6717 "no ospf priority [(0-255) [A.B.C.D]]",
6719 "OSPF interface commands\n"
6722 "Address of interface")
6724 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
6727 DEFUN (ip_ospf_retransmit_interval
,
6728 ip_ospf_retransmit_interval_addr_cmd
,
6729 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6731 "OSPF interface commands\n"
6732 "Time between retransmitting lost link state advertisements\n"
6734 "Address of interface")
6736 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6739 struct in_addr addr
;
6740 struct ospf_if_params
*params
;
6741 params
= IF_DEF_PARAMS(ifp
);
6743 argv_find(argv
, argc
, "(3-65535)", &idx
);
6744 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6746 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6747 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6749 "Please specify interface address by A.B.C.D\n");
6750 return CMD_WARNING_CONFIG_FAILED
;
6753 params
= ospf_get_if_params(ifp
, addr
);
6754 ospf_if_update_params(ifp
, addr
);
6757 SET_IF_PARAM(params
, retransmit_interval
);
6758 params
->retransmit_interval
= seconds
;
6763 DEFUN_HIDDEN (ospf_retransmit_interval
,
6764 ospf_retransmit_interval_cmd
,
6765 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6766 "OSPF interface commands\n"
6767 "Time between retransmitting lost link state advertisements\n"
6769 "Address of interface")
6771 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6774 DEFUN (no_ip_ospf_retransmit_interval
,
6775 no_ip_ospf_retransmit_interval_addr_cmd
,
6776 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6779 "OSPF interface commands\n"
6780 "Time between retransmitting lost link state advertisements\n"
6782 "Address of interface\n")
6784 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6786 struct in_addr addr
;
6787 struct ospf_if_params
*params
;
6789 params
= IF_DEF_PARAMS(ifp
);
6791 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6792 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6794 "Please specify interface address by A.B.C.D\n");
6795 return CMD_WARNING_CONFIG_FAILED
;
6798 params
= ospf_lookup_if_params(ifp
, addr
);
6803 UNSET_IF_PARAM(params
, retransmit_interval
);
6804 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6806 if (params
!= IF_DEF_PARAMS(ifp
)) {
6807 ospf_free_if_params(ifp
, addr
);
6808 ospf_if_update_params(ifp
, addr
);
6814 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6815 no_ospf_retransmit_interval_cmd
,
6816 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6818 "OSPF interface commands\n"
6819 "Time between retransmitting lost link state advertisements\n"
6821 "Address of interface\n")
6823 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6826 DEFUN (ip_ospf_transmit_delay
,
6827 ip_ospf_transmit_delay_addr_cmd
,
6828 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6830 "OSPF interface commands\n"
6831 "Link state transmit delay\n"
6833 "Address of interface")
6835 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6838 struct in_addr addr
;
6839 struct ospf_if_params
*params
;
6841 params
= IF_DEF_PARAMS(ifp
);
6842 argv_find(argv
, argc
, "(1-65535)", &idx
);
6843 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6845 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6846 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6848 "Please specify interface address by A.B.C.D\n");
6849 return CMD_WARNING_CONFIG_FAILED
;
6852 params
= ospf_get_if_params(ifp
, addr
);
6853 ospf_if_update_params(ifp
, addr
);
6856 SET_IF_PARAM(params
, transmit_delay
);
6857 params
->transmit_delay
= seconds
;
6862 DEFUN_HIDDEN (ospf_transmit_delay
,
6863 ospf_transmit_delay_cmd
,
6864 "ospf transmit-delay (1-65535) [A.B.C.D]",
6865 "OSPF interface commands\n"
6866 "Link state transmit delay\n"
6868 "Address of interface")
6870 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
6873 DEFUN (no_ip_ospf_transmit_delay
,
6874 no_ip_ospf_transmit_delay_addr_cmd
,
6875 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6878 "OSPF interface commands\n"
6879 "Link state transmit delay\n"
6880 "Address of interface")
6882 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6884 struct in_addr addr
;
6885 struct ospf_if_params
*params
;
6887 params
= IF_DEF_PARAMS(ifp
);
6889 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6890 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6892 "Please specify interface address by A.B.C.D\n");
6893 return CMD_WARNING_CONFIG_FAILED
;
6896 params
= ospf_lookup_if_params(ifp
, addr
);
6901 UNSET_IF_PARAM(params
, transmit_delay
);
6902 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6904 if (params
!= IF_DEF_PARAMS(ifp
)) {
6905 ospf_free_if_params(ifp
, addr
);
6906 ospf_if_update_params(ifp
, addr
);
6913 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6914 no_ospf_transmit_delay_cmd
,
6915 "no ospf transmit-delay",
6917 "OSPF interface commands\n"
6918 "Link state transmit delay\n")
6920 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
6923 DEFUN (ip_ospf_area
,
6925 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
6927 "OSPF interface commands\n"
6929 "Enable OSPF on this interface\n"
6930 "OSPF area ID in IP address format\n"
6931 "OSPF area ID as a decimal value\n"
6932 "Address of interface\n")
6934 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6937 struct in_addr area_id
;
6938 struct in_addr addr
;
6939 struct ospf_if_params
*params
;
6940 struct route_node
*rn
;
6942 u_short instance
= 0;
6945 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
6946 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
6948 argv_find(argv
, argc
, "area", &idx
);
6949 areaid
= argv
[idx
+ 1]->arg
;
6951 ospf
= ospf_lookup_instance(instance
);
6953 params
= IF_DEF_PARAMS(ifp
);
6954 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
6955 UNSET_IF_PARAM(params
, if_area
);
6956 ospf_interface_area_unset(ifp
);
6957 ospf
= ospf_lookup();
6958 ospf
->if_ospf_cli_count
--;
6960 return CMD_NOT_MY_INSTANCE
;
6963 ret
= str2area_id(areaid
, &area_id
, &format
);
6965 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
6966 return CMD_WARNING_CONFIG_FAILED
;
6968 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
6969 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
6970 return CMD_WARNING_CONFIG_FAILED
;
6973 params
= IF_DEF_PARAMS(ifp
);
6974 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
6975 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
6977 "Must remove previous area config before changing ospf area \n");
6978 return CMD_WARNING_CONFIG_FAILED
;
6981 // Check if we have an address arg and proccess it
6982 if (argc
== idx
+ 3) {
6983 inet_aton(argv
[idx
+ 2]->arg
, &addr
);
6984 // update/create address-level params
6985 params
= ospf_get_if_params((ifp
), (addr
));
6986 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
6988 "Must remove previous area/address config before changing ospf area");
6989 return CMD_WARNING_CONFIG_FAILED
;
6991 ospf_if_update_params((ifp
), (addr
));
6994 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
6995 if (rn
->info
!= NULL
) {
6997 "Please remove all network commands first.\n");
6998 return CMD_WARNING_CONFIG_FAILED
;
7002 /* enable ospf on this interface with area_id */
7003 SET_IF_PARAM(params
, if_area
);
7004 params
->if_area
= area_id
;
7005 ospf_interface_area_set(ifp
);
7006 ospf
->if_ospf_cli_count
++;
7011 DEFUN (no_ip_ospf_area
,
7012 no_ip_ospf_area_cmd
,
7013 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
7016 "OSPF interface commands\n"
7018 "Disable OSPF on this interface\n"
7019 "OSPF area ID in IP address format\n"
7020 "OSPF area ID as a decimal value\n"
7021 "Address of interface\n")
7023 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7026 struct ospf_if_params
*params
;
7027 u_short instance
= 0;
7028 struct in_addr addr
;
7030 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7031 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7033 ospf
= ospf_lookup_instance(instance
);
7035 return CMD_NOT_MY_INSTANCE
;
7037 argv_find(argv
, argc
, "area", &idx
);
7039 // Check if we have an address arg and proccess it
7040 if (argc
== idx
+ 3) {
7041 inet_aton(argv
[idx
+ 2]->arg
, &addr
);
7042 params
= ospf_lookup_if_params(ifp
, addr
);
7043 if ((params
) == NULL
)
7046 params
= IF_DEF_PARAMS(ifp
);
7048 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7050 "Can't find specified interface area configuration.\n");
7051 return CMD_WARNING_CONFIG_FAILED
;
7054 UNSET_IF_PARAM(params
, if_area
);
7055 if (params
!= IF_DEF_PARAMS((ifp
))) {
7056 ospf_free_if_params((ifp
), (addr
));
7057 ospf_if_update_params((ifp
), (addr
));
7060 ospf_interface_area_unset(ifp
);
7061 ospf
->if_ospf_cli_count
--;
7065 DEFUN (ospf_redistribute_source
,
7066 ospf_redistribute_source_cmd
,
7067 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7069 FRR_REDIST_HELP_STR_OSPFD
7070 "Metric for redistributed routes\n"
7071 "OSPF default metric\n"
7072 "OSPF exterior metric type for redistributed routes\n"
7073 "Set OSPF External Type 1/2 metrics\n"
7074 "Route map reference\n"
7075 "Pointer to route-map entries\n")
7077 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7078 int idx_protocol
= 1;
7082 struct ospf_redist
*red
;
7088 /* Get distribute source. */
7089 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7091 return CMD_WARNING_CONFIG_FAILED
;
7093 red
= ospf_redist_add(ospf
, source
, 0);
7095 /* Get metric value. */
7096 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7097 if (!str2metric(argv
[idx
]->arg
, &metric
))
7098 return CMD_WARNING_CONFIG_FAILED
;
7100 /* Get metric type. */
7101 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7102 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7103 return CMD_WARNING_CONFIG_FAILED
;
7106 else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7107 ospf_routemap_set(red
, argv
[idx
]->arg
);
7109 ospf_routemap_unset(red
);
7111 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
7114 DEFUN (no_ospf_redistribute_source
,
7115 no_ospf_redistribute_source_cmd
,
7116 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7119 FRR_REDIST_HELP_STR_OSPFD
7120 "Metric for redistributed routes\n"
7121 "OSPF default metric\n"
7122 "OSPF exterior metric type for redistributed routes\n"
7123 "Set OSPF External Type 1/2 metrics\n"
7124 "Route map reference\n"
7125 "Pointer to route-map entries\n")
7127 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7128 int idx_protocol
= 2;
7130 struct ospf_redist
*red
;
7132 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7134 return CMD_WARNING_CONFIG_FAILED
;
7136 red
= ospf_redist_lookup(ospf
, source
, 0);
7140 ospf_routemap_unset(red
);
7141 return ospf_redistribute_unset(ospf
, source
, 0);
7144 DEFUN (ospf_redistribute_instance_source
,
7145 ospf_redistribute_instance_source_cmd
,
7146 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7148 "Open Shortest Path First\n"
7149 "Non-main Kernel Routing Table\n"
7150 "Instance ID/Table ID\n"
7151 "Metric for redistributed routes\n"
7152 "OSPF default metric\n"
7153 "OSPF exterior metric type for redistributed routes\n"
7154 "Set OSPF External Type 1/2 metrics\n"
7155 "Route map reference\n"
7156 "Pointer to route-map entries\n")
7158 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7159 int idx_ospf_table
= 1;
7166 struct ospf_redist
*red
;
7171 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
7173 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7178 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7180 "Instance redistribution in non-instanced OSPF not allowed\n");
7181 return CMD_WARNING_CONFIG_FAILED
;
7184 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7185 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7186 return CMD_WARNING_CONFIG_FAILED
;
7189 /* Get metric value. */
7190 if (argv_find(argv
, argc
, "metric", &idx
))
7191 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
7192 return CMD_WARNING_CONFIG_FAILED
;
7195 /* Get metric type. */
7196 if (argv_find(argv
, argc
, "metric-type", &idx
))
7197 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
7198 return CMD_WARNING_CONFIG_FAILED
;
7200 red
= ospf_redist_add(ospf
, source
, instance
);
7203 if (argv_find(argv
, argc
, "route-map", &idx
))
7204 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
7206 ospf_routemap_unset(red
);
7208 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
7211 DEFUN (no_ospf_redistribute_instance_source
,
7212 no_ospf_redistribute_instance_source_cmd
,
7213 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7216 "Open Shortest Path First\n"
7217 "Non-main Kernel Routing Table\n"
7218 "Instance ID/Table Id\n"
7219 "Metric for redistributed routes\n"
7220 "OSPF default metric\n"
7221 "OSPF exterior metric type for redistributed routes\n"
7222 "Set OSPF External Type 1/2 metrics\n"
7223 "Route map reference\n"
7224 "Pointer to route-map entries\n")
7226 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7227 int idx_ospf_table
= 2;
7230 struct ospf_redist
*red
;
7233 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7234 source
= ZEBRA_ROUTE_OSPF
;
7236 source
= ZEBRA_ROUTE_TABLE
;
7238 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7240 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7242 "Instance redistribution in non-instanced OSPF not allowed\n");
7243 return CMD_WARNING_CONFIG_FAILED
;
7246 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7247 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7248 return CMD_WARNING_CONFIG_FAILED
;
7251 red
= ospf_redist_lookup(ospf
, source
, instance
);
7255 ospf_routemap_unset(red
);
7256 return ospf_redistribute_unset(ospf
, source
, instance
);
7259 DEFUN (ospf_distribute_list_out
,
7260 ospf_distribute_list_out_cmd
,
7261 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7262 "Filter networks in routing updates\n"
7263 "Access-list name\n"
7265 FRR_REDIST_HELP_STR_OSPFD
)
7267 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7271 char *proto
= argv
[argc
- 1]->text
;
7273 /* Get distribute source. */
7274 source
= proto_redistnum(AFI_IP
, proto
);
7276 return CMD_WARNING_CONFIG_FAILED
;
7278 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
7281 DEFUN (no_ospf_distribute_list_out
,
7282 no_ospf_distribute_list_out_cmd
,
7283 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7285 "Filter networks in routing updates\n"
7286 "Access-list name\n"
7288 FRR_REDIST_HELP_STR_OSPFD
)
7290 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7294 char *proto
= argv
[argc
- 1]->text
;
7295 source
= proto_redistnum(AFI_IP
, proto
);
7297 return CMD_WARNING_CONFIG_FAILED
;
7299 return ospf_distribute_list_out_unset(ospf
, source
,
7300 argv
[idx_word
]->arg
);
7303 /* Default information originate. */
7304 DEFUN (ospf_default_information_originate
,
7305 ospf_default_information_originate_cmd
,
7306 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7307 "Control distribution of default information\n"
7308 "Distribute a default route\n"
7309 "Always advertise default route\n"
7310 "OSPF default metric\n"
7312 "OSPF metric type for default routes\n"
7313 "Set OSPF External Type 1/2 metrics\n"
7314 "Route map reference\n"
7315 "Pointer to route-map entries\n")
7317 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7318 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7321 struct ospf_redist
*red
;
7324 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7326 /* Check whether "always" was specified */
7327 if (argv_find(argv
, argc
, "always", &idx
))
7328 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7329 /* Get metric value */
7330 else if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7331 if (!str2metric(argv
[idx
]->arg
, &metric
))
7332 return CMD_WARNING_CONFIG_FAILED
;
7334 /* Get metric type. */
7335 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7336 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7337 return CMD_WARNING_CONFIG_FAILED
;
7340 else if (argv_find(argv
, argc
, "WORD", &idx
))
7341 ospf_routemap_set(red
, argv
[idx
]->arg
);
7343 ospf_routemap_unset(red
);
7345 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
7349 DEFUN (no_ospf_default_information_originate
,
7350 no_ospf_default_information_originate_cmd
,
7351 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7353 "Control distribution of default information\n"
7354 "Distribute a default route\n"
7355 "Always advertise default route\n"
7356 "OSPF default metric\n"
7358 "OSPF metric type for default routes\n"
7359 "Set OSPF External Type 1/2 metrics\n"
7360 "Route map reference\n"
7361 "Pointer to route-map entries\n")
7363 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7364 struct prefix_ipv4 p
;
7365 struct ospf_external
*ext
;
7366 struct ospf_redist
*red
;
7369 p
.prefix
.s_addr
= 0;
7372 ospf_external_lsa_flush(ospf
, DEFAULT_ROUTE
, &p
, 0);
7374 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0))
7375 && EXTERNAL_INFO(ext
)) {
7376 ospf_external_info_delete(DEFAULT_ROUTE
, 0, p
);
7377 ospf_external_del(DEFAULT_ROUTE
, 0);
7380 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7384 ospf_routemap_unset(red
);
7385 return ospf_redistribute_default_unset(ospf
);
7388 DEFUN (ospf_default_metric
,
7389 ospf_default_metric_cmd
,
7390 "default-metric (0-16777214)",
7391 "Set metric of redistributed routes\n"
7394 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7398 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
7399 return CMD_WARNING_CONFIG_FAILED
;
7401 ospf
->default_metric
= metric
;
7406 DEFUN (no_ospf_default_metric
,
7407 no_ospf_default_metric_cmd
,
7408 "no default-metric [(0-16777214)]",
7410 "Set metric of redistributed routes\n"
7413 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7415 ospf
->default_metric
= -1;
7421 DEFUN (ospf_distance
,
7424 "Administrative distance\n"
7425 "OSPF Administrative distance\n")
7427 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7430 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
7435 DEFUN (no_ospf_distance
,
7436 no_ospf_distance_cmd
,
7437 "no distance (1-255)",
7439 "Administrative distance\n"
7440 "OSPF Administrative distance\n")
7442 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7444 ospf
->distance_all
= 0;
7449 DEFUN (no_ospf_distance_ospf
,
7450 no_ospf_distance_ospf_cmd
,
7451 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7453 "Administrative distance\n"
7454 "OSPF administrative distance\n"
7455 "Intra-area routes\n"
7456 "Distance for intra-area routes\n"
7457 "Inter-area routes\n"
7458 "Distance for inter-area routes\n"
7460 "Distance for external routes\n")
7462 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7468 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
7469 idx
= ospf
->distance_intra
= 0;
7470 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
7471 idx
= ospf
->distance_inter
= 0;
7472 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
7473 ospf
->distance_external
= 0;
7478 DEFUN (ospf_distance_ospf
,
7479 ospf_distance_ospf_cmd
,
7480 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7481 "Administrative distance\n"
7482 "OSPF administrative distance\n"
7483 "Intra-area routes\n"
7484 "Distance for intra-area routes\n"
7485 "Inter-area routes\n"
7486 "Distance for inter-area routes\n"
7488 "Distance for external routes\n")
7490 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7493 if (argv_find(argv
, argc
, "intra-area", &idx
))
7494 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7496 if (argv_find(argv
, argc
, "inter-area", &idx
))
7497 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7499 if (argv_find(argv
, argc
, "external", &idx
))
7500 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7506 DEFUN (ospf_distance_source
,
7507 ospf_distance_source_cmd
,
7508 "distance (1-255) A.B.C.D/M",
7509 "Administrative distance\n"
7511 "IP source prefix\n")
7513 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7515 int idx_ipv4_prefixlen
= 2;
7520 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7525 DEFUN (no_ospf_distance_source
,
7526 no_ospf_distance_source_cmd
,
7527 "no distance (1-255) A.B.C.D/M",
7529 "Administrative distance\n"
7531 "IP source prefix\n")
7533 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7535 int idx_ipv4_prefixlen
= 3;
7540 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7545 DEFUN (ospf_distance_source_access_list
,
7546 ospf_distance_source_access_list_cmd
,
7547 "distance (1-255) A.B.C.D/M WORD",
7548 "Administrative distance\n"
7550 "IP source prefix\n"
7551 "Access list name\n")
7553 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7555 int idx_ipv4_prefixlen
= 2;
7561 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7566 DEFUN (no_ospf_distance_source_access_list
,
7567 no_ospf_distance_source_access_list_cmd
,
7568 "no distance (1-255) A.B.C.D/M WORD",
7570 "Administrative distance\n"
7572 "IP source prefix\n"
7573 "Access list name\n")
7575 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7577 int idx_ipv4_prefixlen
= 3;
7583 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7589 DEFUN (ip_ospf_mtu_ignore
,
7590 ip_ospf_mtu_ignore_addr_cmd
,
7591 "ip ospf mtu-ignore [A.B.C.D]",
7593 "OSPF interface commands\n"
7594 "Disable MTU mismatch detection on this interface\n"
7595 "Address of interface")
7597 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7599 struct in_addr addr
;
7602 struct ospf_if_params
*params
;
7603 params
= IF_DEF_PARAMS(ifp
);
7606 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7609 "Please specify interface address by A.B.C.D\n");
7610 return CMD_WARNING_CONFIG_FAILED
;
7612 params
= ospf_get_if_params(ifp
, addr
);
7613 ospf_if_update_params(ifp
, addr
);
7615 params
->mtu_ignore
= 1;
7616 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7617 SET_IF_PARAM(params
, mtu_ignore
);
7619 UNSET_IF_PARAM(params
, mtu_ignore
);
7620 if (params
!= IF_DEF_PARAMS(ifp
)) {
7621 ospf_free_if_params(ifp
, addr
);
7622 ospf_if_update_params(ifp
, addr
);
7628 DEFUN (no_ip_ospf_mtu_ignore
,
7629 no_ip_ospf_mtu_ignore_addr_cmd
,
7630 "no ip ospf mtu-ignore [A.B.C.D]",
7632 "OSPF interface commands\n"
7633 "Disable MTU mismatch detection on this interface\n"
7634 "Address of interface")
7636 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7638 struct in_addr addr
;
7641 struct ospf_if_params
*params
;
7642 params
= IF_DEF_PARAMS(ifp
);
7645 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7648 "Please specify interface address by A.B.C.D\n");
7649 return CMD_WARNING_CONFIG_FAILED
;
7651 params
= ospf_get_if_params(ifp
, addr
);
7652 ospf_if_update_params(ifp
, addr
);
7654 params
->mtu_ignore
= 0;
7655 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7656 SET_IF_PARAM(params
, mtu_ignore
);
7658 UNSET_IF_PARAM(params
, mtu_ignore
);
7659 if (params
!= IF_DEF_PARAMS(ifp
)) {
7660 ospf_free_if_params(ifp
, addr
);
7661 ospf_if_update_params(ifp
, addr
);
7668 DEFUN (ospf_max_metric_router_lsa_admin
,
7669 ospf_max_metric_router_lsa_admin_cmd
,
7670 "max-metric router-lsa administrative",
7671 "OSPF maximum / infinite-distance metric\n"
7672 "Advertise own Router-LSA with infinite distance (stub router)\n"
7673 "Administratively applied, for an indefinite period\n")
7675 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7676 struct listnode
*ln
;
7677 struct ospf_area
*area
;
7679 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7680 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7682 if (!CHECK_FLAG(area
->stub_router_state
,
7683 OSPF_AREA_IS_STUB_ROUTED
))
7684 ospf_router_lsa_update_area(area
);
7687 /* Allows for areas configured later to get the property */
7688 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7693 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7694 no_ospf_max_metric_router_lsa_admin_cmd
,
7695 "no max-metric router-lsa administrative",
7697 "OSPF maximum / infinite-distance metric\n"
7698 "Advertise own Router-LSA with infinite distance (stub router)\n"
7699 "Administratively applied, for an indefinite period\n")
7701 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7702 struct listnode
*ln
;
7703 struct ospf_area
*area
;
7705 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7706 UNSET_FLAG(area
->stub_router_state
,
7707 OSPF_AREA_ADMIN_STUB_ROUTED
);
7709 /* Don't trample on the start-up stub timer */
7710 if (CHECK_FLAG(area
->stub_router_state
,
7711 OSPF_AREA_IS_STUB_ROUTED
)
7712 && !area
->t_stub_router
) {
7713 UNSET_FLAG(area
->stub_router_state
,
7714 OSPF_AREA_IS_STUB_ROUTED
);
7715 ospf_router_lsa_update_area(area
);
7718 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7722 DEFUN (ospf_max_metric_router_lsa_startup
,
7723 ospf_max_metric_router_lsa_startup_cmd
,
7724 "max-metric router-lsa on-startup (5-86400)",
7725 "OSPF maximum / infinite-distance metric\n"
7726 "Advertise own Router-LSA with infinite distance (stub router)\n"
7727 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7728 "Time (seconds) to advertise self as stub-router\n")
7730 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7732 unsigned int seconds
;
7735 vty_out(vty
, "%% Must supply stub-router period");
7736 return CMD_WARNING_CONFIG_FAILED
;
7739 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7741 ospf
->stub_router_startup_time
= seconds
;
7746 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7747 no_ospf_max_metric_router_lsa_startup_cmd
,
7748 "no max-metric router-lsa on-startup [(5-86400)]",
7750 "OSPF maximum / infinite-distance metric\n"
7751 "Advertise own Router-LSA with infinite distance (stub router)\n"
7752 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7753 "Time (seconds) to advertise self as stub-router\n")
7755 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7756 struct listnode
*ln
;
7757 struct ospf_area
*area
;
7759 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7761 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7762 SET_FLAG(area
->stub_router_state
,
7763 OSPF_AREA_WAS_START_STUB_ROUTED
);
7764 OSPF_TIMER_OFF(area
->t_stub_router
);
7766 /* Don't trample on admin stub routed */
7767 if (!CHECK_FLAG(area
->stub_router_state
,
7768 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7769 UNSET_FLAG(area
->stub_router_state
,
7770 OSPF_AREA_IS_STUB_ROUTED
);
7771 ospf_router_lsa_update_area(area
);
7778 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7779 ospf_max_metric_router_lsa_shutdown_cmd
,
7780 "max-metric router-lsa on-shutdown (5-100)",
7781 "OSPF maximum / infinite-distance metric\n"
7782 "Advertise own Router-LSA with infinite distance (stub router)\n"
7783 "Advertise stub-router prior to full shutdown of OSPF\n"
7784 "Time (seconds) to wait till full shutdown\n")
7786 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7788 unsigned int seconds
;
7791 vty_out(vty
, "%% Must supply stub-router shutdown period");
7792 return CMD_WARNING_CONFIG_FAILED
;
7795 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7797 ospf
->stub_router_shutdown_time
= seconds
;
7802 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7803 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7804 "no max-metric router-lsa on-shutdown [(5-100)]",
7806 "OSPF maximum / infinite-distance metric\n"
7807 "Advertise own Router-LSA with infinite distance (stub router)\n"
7808 "Advertise stub-router prior to full shutdown of OSPF\n"
7809 "Time (seconds) to wait till full shutdown\n")
7811 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7813 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7818 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
7820 struct listnode
*ln
;
7821 struct ospf_area
*area
;
7823 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7824 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
7825 ospf
->stub_router_startup_time
);
7826 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7827 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
7828 ospf
->stub_router_shutdown_time
);
7829 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7830 if (CHECK_FLAG(area
->stub_router_state
,
7831 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7832 vty_out(vty
, " max-metric router-lsa administrative\n");
7839 static void show_ip_ospf_route_network(struct vty
*vty
, struct route_table
*rt
)
7841 struct route_node
*rn
;
7842 struct ospf_route
* or ;
7843 struct listnode
*pnode
, *pnnode
;
7844 struct ospf_path
*path
;
7846 vty_out(vty
, "============ OSPF network routing table ============\n");
7848 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
7849 if ((or = rn
->info
) != NULL
) {
7851 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
7854 switch (or->path_type
) {
7855 case OSPF_PATH_INTER_AREA
:
7856 if (or->type
== OSPF_DESTINATION_NETWORK
)
7858 "N IA %-18s [%d] area: %s\n",
7860 inet_ntoa(or->u
.std
.area_id
));
7861 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7863 "D IA %-18s Discard entry\n",
7866 case OSPF_PATH_INTRA_AREA
:
7867 vty_out(vty
, "N %-18s [%d] area: %s\n",
7869 inet_ntoa(or->u
.std
.area_id
));
7875 if (or->type
== OSPF_DESTINATION_NETWORK
)
7876 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
7878 if (if_lookup_by_index(path
->ifindex
,
7880 if (path
->nexthop
.s_addr
== 0)
7882 "%24s directly attached to %s\n",
7889 "%24s via %s, %s\n",
7902 static void show_ip_ospf_route_router(struct vty
*vty
, struct route_table
*rtrs
)
7904 struct route_node
*rn
;
7905 struct ospf_route
* or ;
7906 struct listnode
*pnode
;
7907 struct listnode
*node
;
7908 struct ospf_path
*path
;
7910 vty_out(vty
, "============ OSPF router routing table =============\n");
7911 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
))
7915 vty_out(vty
, "R %-15s ",
7916 inet_ntoa(rn
->p
.u
.prefix4
));
7918 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
,
7921 vty_out(vty
, "%24s", "");
7924 vty_out(vty
, "%s [%d] area: %s",
7925 (or->path_type
== OSPF_PATH_INTER_AREA
7928 or->cost
, inet_ntoa(or->u
.std
.area_id
));
7930 vty_out(vty
, "%s%s\n",
7931 (or->u
.std
.flags
& ROUTER_LSA_BORDER
7934 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
7938 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
,
7940 if (if_lookup_by_index(path
->ifindex
,
7942 if (path
->nexthop
.s_addr
== 0)
7944 "%24s directly attached to %s\n",
7951 "%24s via %s, %s\n",
7965 static void show_ip_ospf_route_external(struct vty
*vty
, struct route_table
*rt
)
7967 struct route_node
*rn
;
7968 struct ospf_route
*er
;
7969 struct listnode
*pnode
, *pnnode
;
7970 struct ospf_path
*path
;
7972 vty_out(vty
, "============ OSPF external routing table ===========\n");
7973 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
7974 if ((er
= rn
->info
) != NULL
) {
7976 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
7979 switch (er
->path_type
) {
7980 case OSPF_PATH_TYPE1_EXTERNAL
:
7982 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
7984 buf1
, er
->cost
, er
->u
.ext
.tag
);
7986 case OSPF_PATH_TYPE2_EXTERNAL
:
7988 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
7990 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
7995 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
,
7997 if (if_lookup_by_index(path
->ifindex
,
7999 if (path
->nexthop
.s_addr
== 0)
8001 "%24s directly attached to %s\n",
8008 "%24s via %s, %s\n",
8021 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
8025 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
8027 if (ospf
->new_table
== NULL
) {
8028 vty_out(vty
, "No OSPF routing information exist\n");
8032 /* Show Network routes.
8033 show_ip_ospf_route_network (vty, ospf->new_table); */
8035 /* Show Router routes. */
8036 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8043 DEFUN (show_ip_ospf_border_routers
,
8044 show_ip_ospf_border_routers_cmd
,
8045 "show ip ospf border-routers",
8048 "OSPF information\n"
8049 "Show all the ABR's and ASBR's\n")
8053 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8056 return show_ip_ospf_border_routers_common(vty
, ospf
);
8059 DEFUN (show_ip_ospf_instance_border_routers
,
8060 show_ip_ospf_instance_border_routers_cmd
,
8061 "show ip ospf (1-65535) border-routers",
8064 "OSPF information\n"
8066 "Show all the ABR's and ASBR's\n")
8070 u_short instance
= 0;
8072 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8073 ospf
= ospf_lookup_instance(instance
);
8075 return CMD_NOT_MY_INSTANCE
;
8077 if (!ospf
->oi_running
)
8080 return show_ip_ospf_border_routers_common(vty
, ospf
);
8083 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
)
8086 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
8088 if (ospf
->new_table
== NULL
) {
8089 vty_out(vty
, "No OSPF routing information exist\n");
8093 /* Show Network routes. */
8094 show_ip_ospf_route_network(vty
, ospf
->new_table
);
8096 /* Show Router routes. */
8097 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8099 /* Show AS External routes. */
8100 show_ip_ospf_route_external(vty
, ospf
->old_external_route
);
8107 DEFUN (show_ip_ospf_route
,
8108 show_ip_ospf_route_cmd
,
8109 "show ip ospf route",
8112 "OSPF information\n"
8113 "OSPF routing table\n")
8117 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8120 return show_ip_ospf_route_common(vty
, ospf
);
8123 DEFUN (show_ip_ospf_instance_route
,
8124 show_ip_ospf_instance_route_cmd
,
8125 "show ip ospf (1-65535) route",
8128 "OSPF information\n"
8130 "OSPF routing table\n")
8134 u_short instance
= 0;
8136 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8137 ospf
= ospf_lookup_instance(instance
);
8139 return CMD_NOT_MY_INSTANCE
;
8141 if (!ospf
->oi_running
)
8144 return show_ip_ospf_route_common(vty
, ospf
);
8147 const char *ospf_abr_type_str
[] = {"unknown", "standard", "ibm", "cisco",
8150 const char *ospf_shortcut_mode_str
[] = {"default", "enable", "disable"};
8152 const char *ospf_int_type_str
[] = {"unknown", /* should never be used. */
8153 "point-to-point", "broadcast",
8154 "non-broadcast", "point-to-multipoint",
8155 "virtual-link", /* should never be used. */
8158 /* Configuration write function for ospfd. */
8159 static int config_write_interface(struct vty
*vty
)
8161 struct listnode
*n1
, *n2
;
8162 struct interface
*ifp
;
8163 struct crypt_key
*ck
;
8165 struct route_node
*rn
= NULL
;
8166 struct ospf_if_params
*params
;
8167 struct ospf
*ospf
= ospf_lookup();
8169 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), n1
, ifp
)) {
8170 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
8173 if (ifp
->ifindex
== IFINDEX_DELETED
)
8176 vty_out(vty
, "!\n");
8177 vty_out(vty
, "interface %s\n", ifp
->name
);
8179 vty_out(vty
, " description %s\n", ifp
->desc
);
8183 params
= IF_DEF_PARAMS(ifp
);
8186 /* Interface Network print. */
8187 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
8188 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
8189 if (params
->type
!= ospf_default_iftype(ifp
)) {
8190 vty_out(vty
, " ip ospf network %s",
8193 if (params
!= IF_DEF_PARAMS(ifp
))
8201 /* OSPF interface authentication print */
8202 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
8203 && params
->auth_type
!= OSPF_AUTH_NOTSET
) {
8204 const char *auth_str
;
8206 /* Translation tables are not that much help
8208 of the simple option */
8209 switch (params
->auth_type
) {
8211 case OSPF_AUTH_NULL
:
8215 case OSPF_AUTH_SIMPLE
:
8219 case OSPF_AUTH_CRYPTOGRAPHIC
:
8220 auth_str
= " message-digest";
8228 vty_out(vty
, " ip ospf authentication%s",
8230 if (params
!= IF_DEF_PARAMS(ifp
))
8232 inet_ntoa(rn
->p
.u
.prefix4
));
8236 /* Simple Authentication Password print. */
8237 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
8238 && params
->auth_simple
[0] != '\0') {
8239 vty_out(vty
, " ip ospf authentication-key %s",
8240 params
->auth_simple
);
8241 if (params
!= IF_DEF_PARAMS(ifp
))
8243 inet_ntoa(rn
->p
.u
.prefix4
));
8247 /* Cryptographic Authentication Key print. */
8248 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
, n2
, ck
)) {
8250 " ip ospf message-digest-key %d md5 %s",
8251 ck
->key_id
, ck
->auth_key
);
8252 if (params
!= IF_DEF_PARAMS(ifp
))
8254 inet_ntoa(rn
->p
.u
.prefix4
));
8258 /* Interface Output Cost print. */
8259 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
8260 vty_out(vty
, " ip ospf cost %u",
8261 params
->output_cost_cmd
);
8262 if (params
!= IF_DEF_PARAMS(ifp
))
8264 inet_ntoa(rn
->p
.u
.prefix4
));
8268 /* Hello Interval print. */
8269 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
8270 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
8271 vty_out(vty
, " ip ospf hello-interval %u",
8273 if (params
!= IF_DEF_PARAMS(ifp
))
8275 inet_ntoa(rn
->p
.u
.prefix4
));
8280 /* Router Dead Interval print. */
8281 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
8283 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
8284 vty_out(vty
, " ip ospf dead-interval ");
8287 if (OSPF_IF_PARAM_CONFIGURED(params
,
8290 "minimal hello-multiplier %d",
8291 params
->fast_hello
);
8293 vty_out(vty
, "%u", params
->v_wait
);
8295 if (params
!= IF_DEF_PARAMS(ifp
))
8297 inet_ntoa(rn
->p
.u
.prefix4
));
8301 /* Router Priority print. */
8302 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
8304 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
8305 vty_out(vty
, " ip ospf priority %u",
8307 if (params
!= IF_DEF_PARAMS(ifp
))
8309 inet_ntoa(rn
->p
.u
.prefix4
));
8313 /* Retransmit Interval print. */
8314 if (OSPF_IF_PARAM_CONFIGURED(params
,
8315 retransmit_interval
)
8316 && params
->retransmit_interval
8317 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
8318 vty_out(vty
, " ip ospf retransmit-interval %u",
8319 params
->retransmit_interval
);
8320 if (params
!= IF_DEF_PARAMS(ifp
))
8322 inet_ntoa(rn
->p
.u
.prefix4
));
8326 /* Transmit Delay print. */
8327 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
8328 && params
->transmit_delay
8329 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
8330 vty_out(vty
, " ip ospf transmit-delay %u",
8331 params
->transmit_delay
);
8332 if (params
!= IF_DEF_PARAMS(ifp
))
8334 inet_ntoa(rn
->p
.u
.prefix4
));
8339 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8341 vty_out(vty
, " ip ospf %d",
8344 vty_out(vty
, " ip ospf");
8346 vty_out(vty
, " area %s",
8347 inet_ntoa(params
->if_area
));
8348 if (params
!= IF_DEF_PARAMS(ifp
))
8350 inet_ntoa(rn
->p
.u
.prefix4
));
8355 ospf_bfd_write_config(vty
, params
);
8357 /* MTU ignore print. */
8358 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
8359 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
8360 if (params
->mtu_ignore
== 0)
8361 vty_out(vty
, " no ip ospf mtu-ignore");
8363 vty_out(vty
, " ip ospf mtu-ignore");
8364 if (params
!= IF_DEF_PARAMS(ifp
))
8366 inet_ntoa(rn
->p
.u
.prefix4
));
8373 rn
= route_top(IF_OIFS_PARAMS(ifp
));
8375 rn
= route_next(rn
);
8385 ospf_opaque_config_write_if(vty
, ifp
);
8391 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
8393 struct route_node
*rn
;
8394 u_char buf
[INET_ADDRSTRLEN
];
8396 /* `network area' print. */
8397 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
8399 struct ospf_network
*n
= rn
->info
;
8401 memset(buf
, 0, INET_ADDRSTRLEN
);
8403 /* Create Area ID string by specified Area ID format. */
8404 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8405 strncpy((char *)buf
, inet_ntoa(n
->area_id
),
8408 sprintf((char *)buf
, "%lu",
8409 (unsigned long int)ntohl(
8410 n
->area_id
.s_addr
));
8412 /* Network print. */
8413 vty_out(vty
, " network %s/%d area %s\n",
8414 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8421 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
8423 struct listnode
*node
;
8424 struct ospf_area
*area
;
8425 u_char buf
[INET_ADDRSTRLEN
];
8427 /* Area configuration print. */
8428 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
8429 struct route_node
*rn1
;
8431 area_id2str((char *)buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8434 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
8435 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8436 vty_out(vty
, " area %s authentication\n", buf
);
8439 " area %s authentication message-digest\n",
8443 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8444 vty_out(vty
, " area %s shortcut %s\n", buf
,
8445 ospf_shortcut_mode_str
8446 [area
->shortcut_configured
]);
8448 if ((area
->external_routing
== OSPF_AREA_STUB
)
8449 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
8450 if (area
->external_routing
== OSPF_AREA_STUB
)
8451 vty_out(vty
, " area %s stub", buf
);
8452 else if (area
->external_routing
== OSPF_AREA_NSSA
) {
8453 vty_out(vty
, " area %s nssa", buf
);
8454 switch (area
->NSSATranslatorRole
) {
8455 case OSPF_NSSA_ROLE_NEVER
:
8456 vty_out(vty
, " translate-never");
8458 case OSPF_NSSA_ROLE_ALWAYS
:
8459 vty_out(vty
, " translate-always");
8461 case OSPF_NSSA_ROLE_CANDIDATE
:
8463 vty_out(vty
, " translate-candidate");
8467 if (area
->no_summary
)
8468 vty_out(vty
, " no-summary");
8472 if (area
->default_cost
!= 1)
8473 vty_out(vty
, " area %s default-cost %d\n", buf
,
8474 area
->default_cost
);
8477 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
8479 struct ospf_area_range
*range
= rn1
->info
;
8481 vty_out(vty
, " area %s range %s/%d", buf
,
8482 inet_ntoa(rn1
->p
.u
.prefix4
),
8485 if (range
->cost_config
8486 != OSPF_AREA_RANGE_COST_UNSPEC
)
8487 vty_out(vty
, " cost %d",
8488 range
->cost_config
);
8490 if (!CHECK_FLAG(range
->flags
,
8491 OSPF_AREA_RANGE_ADVERTISE
))
8492 vty_out(vty
, " not-advertise");
8494 if (CHECK_FLAG(range
->flags
,
8495 OSPF_AREA_RANGE_SUBSTITUTE
))
8496 vty_out(vty
, " substitute %s/%d",
8497 inet_ntoa(range
->subst_addr
),
8498 range
->subst_masklen
);
8503 if (EXPORT_NAME(area
))
8504 vty_out(vty
, " area %s export-list %s\n", buf
,
8507 if (IMPORT_NAME(area
))
8508 vty_out(vty
, " area %s import-list %s\n", buf
,
8511 if (PREFIX_NAME_IN(area
))
8512 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
8513 PREFIX_NAME_IN(area
));
8515 if (PREFIX_NAME_OUT(area
))
8516 vty_out(vty
, " area %s filter-list prefix %s out\n",
8517 buf
, PREFIX_NAME_OUT(area
));
8523 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
8525 struct ospf_nbr_nbma
*nbr_nbma
;
8526 struct route_node
*rn
;
8528 /* Static Neighbor configuration print. */
8529 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
8530 if ((nbr_nbma
= rn
->info
)) {
8531 vty_out(vty
, " neighbor %s", inet_ntoa(nbr_nbma
->addr
));
8533 if (nbr_nbma
->priority
8534 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8535 vty_out(vty
, " priority %d",
8536 nbr_nbma
->priority
);
8538 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8539 vty_out(vty
, " poll-interval %d",
8548 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
8550 struct listnode
*node
;
8551 struct ospf_vl_data
*vl_data
;
8552 char buf
[INET_ADDRSTRLEN
];
8554 /* Virtual-Link print */
8555 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
8556 struct listnode
*n2
;
8557 struct crypt_key
*ck
;
8558 struct ospf_interface
*oi
;
8560 if (vl_data
!= NULL
) {
8561 memset(buf
, 0, INET_ADDRSTRLEN
);
8563 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
8564 vl_data
->vl_area_id_fmt
);
8565 oi
= vl_data
->vl_oi
;
8568 if (OSPF_IF_PARAM(oi
, v_hello
)
8569 != OSPF_HELLO_INTERVAL_DEFAULT
8570 || OSPF_IF_PARAM(oi
, v_wait
)
8571 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
8572 || OSPF_IF_PARAM(oi
, retransmit_interval
)
8573 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
8574 || OSPF_IF_PARAM(oi
, transmit_delay
)
8575 != OSPF_TRANSMIT_DELAY_DEFAULT
)
8577 " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
8578 buf
, inet_ntoa(vl_data
->vl_peer
),
8579 OSPF_IF_PARAM(oi
, v_hello
),
8580 OSPF_IF_PARAM(oi
, retransmit_interval
),
8581 OSPF_IF_PARAM(oi
, transmit_delay
),
8582 OSPF_IF_PARAM(oi
, v_wait
));
8584 vty_out(vty
, " area %s virtual-link %s\n", buf
,
8585 inet_ntoa(vl_data
->vl_peer
));
8587 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
8590 " area %s virtual-link %s authentication-key %s\n",
8591 buf
, inet_ntoa(vl_data
->vl_peer
),
8592 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8595 for (ALL_LIST_ELEMENTS_RO(
8596 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8600 " area %s virtual-link %s"
8601 " message-digest-key %d md5 %s\n",
8602 buf
, inet_ntoa(vl_data
->vl_peer
),
8603 ck
->key_id
, ck
->auth_key
);
8611 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
8615 /* redistribute print. */
8616 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
8617 struct list
*red_list
;
8618 struct listnode
*node
;
8619 struct ospf_redist
*red
;
8621 red_list
= ospf
->redist
[type
];
8625 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
8626 vty_out(vty
, " redistribute %s",
8627 zebra_route_string(type
));
8629 vty_out(vty
, " %d", red
->instance
);
8631 if (red
->dmetric
.value
>= 0)
8632 vty_out(vty
, " metric %d", red
->dmetric
.value
);
8634 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8635 vty_out(vty
, " metric-type 1");
8637 if (ROUTEMAP_NAME(red
))
8638 vty_out(vty
, " route-map %s",
8639 ROUTEMAP_NAME(red
));
8648 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
8650 if (ospf
->default_metric
!= -1)
8651 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
8655 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
8658 struct ospf_redist
*red
;
8661 /* distribute-list print. */
8662 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8663 if (DISTRIBUTE_NAME(ospf
, type
))
8664 vty_out(vty
, " distribute-list %s out %s\n",
8665 DISTRIBUTE_NAME(ospf
, type
),
8666 zebra_route_string(type
));
8668 /* default-information print. */
8669 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
8670 vty_out(vty
, " default-information originate");
8671 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8672 vty_out(vty
, " always");
8674 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8676 if (red
->dmetric
.value
>= 0)
8677 vty_out(vty
, " metric %d",
8678 red
->dmetric
.value
);
8679 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8680 vty_out(vty
, " metric-type 1");
8682 if (ROUTEMAP_NAME(red
))
8683 vty_out(vty
, " route-map %s",
8684 ROUTEMAP_NAME(red
));
8694 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
8696 struct route_node
*rn
;
8697 struct ospf_distance
*odistance
;
8699 if (ospf
->distance_all
)
8700 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
8702 if (ospf
->distance_intra
|| ospf
->distance_inter
8703 || ospf
->distance_external
) {
8704 vty_out(vty
, " distance ospf");
8706 if (ospf
->distance_intra
)
8707 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
8708 if (ospf
->distance_inter
)
8709 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
8710 if (ospf
->distance_external
)
8711 vty_out(vty
, " external %d", ospf
->distance_external
);
8716 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
8717 if ((odistance
= rn
->info
) != NULL
) {
8718 vty_out(vty
, " distance %d %s/%d %s\n",
8719 odistance
->distance
, inet_ntoa(rn
->p
.u
.prefix4
),
8721 odistance
->access_list
? odistance
->access_list
8727 /* OSPF configuration write function. */
8728 static int ospf_config_write(struct vty
*vty
)
8731 struct interface
*ifp
;
8732 struct ospf_interface
*oi
;
8733 struct listnode
*node
;
8736 ospf
= ospf_lookup();
8737 if (ospf
!= NULL
&& ospf
->oi_running
) {
8738 /* `router ospf' print. */
8740 vty_out(vty
, "router ospf %d\n", ospf
->instance
);
8742 vty_out(vty
, "router ospf\n");
8746 if (!ospf
->networks
)
8749 /* Router ID print. */
8750 if (ospf
->router_id_static
.s_addr
!= 0)
8751 vty_out(vty
, " ospf router-id %s\n",
8752 inet_ntoa(ospf
->router_id_static
));
8754 /* ABR type print. */
8755 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8756 vty_out(vty
, " ospf abr-type %s\n",
8757 ospf_abr_type_str
[ospf
->abr_type
]);
8759 /* log-adjacency-changes flag print. */
8760 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
8761 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8762 vty_out(vty
, " log-adjacency-changes detail\n");
8763 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8764 vty_out(vty
, " log-adjacency-changes\n");
8765 } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
) {
8766 vty_out(vty
, " no log-adjacency-changes\n");
8769 /* RFC1583 compatibility flag print -- Compatible with CISCO
8771 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8772 vty_out(vty
, " compatible rfc1583\n");
8774 /* auto-cost reference-bandwidth configuration. */
8775 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
8777 "! Important: ensure reference bandwidth "
8778 "is consistent across all routers\n");
8779 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
8780 ospf
->ref_bandwidth
);
8783 /* SPF timers print. */
8784 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
8785 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
8786 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8787 vty_out(vty
, " timers throttle spf %d %d %d\n",
8788 ospf
->spf_delay
, ospf
->spf_holdtime
,
8789 ospf
->spf_max_holdtime
);
8791 /* LSA timers print. */
8792 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8793 vty_out(vty
, " timers throttle lsa all %d\n",
8794 ospf
->min_ls_interval
);
8795 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8796 vty_out(vty
, " timers lsa min-arrival %d\n",
8797 ospf
->min_ls_arrival
);
8799 /* Write multiplier print. */
8800 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8801 vty_out(vty
, " ospf write-multiplier %d\n",
8802 ospf
->write_oi_count
);
8804 /* Max-metric router-lsa print */
8805 config_write_stub_router(vty
, ospf
);
8807 /* SPF refresh parameters print. */
8808 if (ospf
->lsa_refresh_interval
8809 != OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8810 vty_out(vty
, " refresh timer %d\n",
8811 ospf
->lsa_refresh_interval
);
8813 /* Redistribute information print. */
8814 config_write_ospf_redistribute(vty
, ospf
);
8816 /* passive-interface print. */
8817 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8818 vty_out(vty
, " passive-interface default\n");
8820 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
8821 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
8823 && IF_DEF_PARAMS(ifp
)->passive_interface
8824 != ospf
->passive_interface_default
) {
8825 vty_out(vty
, " %spassive-interface %s\n",
8826 IF_DEF_PARAMS(ifp
)->passive_interface
8831 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
8832 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
,
8835 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
8836 passive_interface
)) {
8837 if (oi
->params
->passive_interface
8838 == IF_DEF_PARAMS(oi
->ifp
)
8839 ->passive_interface
)
8841 } else if (oi
->params
->passive_interface
8842 == ospf
->passive_interface_default
)
8845 vty_out(vty
, " %spassive-interface %s %s\n",
8846 oi
->params
->passive_interface
? "" : "no ",
8848 inet_ntoa(oi
->address
->u
.prefix4
));
8851 /* Network area print. */
8852 config_write_network_area(vty
, ospf
);
8854 /* Area config print. */
8855 config_write_ospf_area(vty
, ospf
);
8857 /* static neighbor print. */
8858 config_write_ospf_nbr_nbma(vty
, ospf
);
8860 /* Virtual-Link print. */
8861 config_write_virtual_link(vty
, ospf
);
8863 /* Default metric configuration. */
8864 config_write_ospf_default_metric(vty
, ospf
);
8866 /* Distribute-list and default-information print. */
8867 config_write_ospf_distribute(vty
, ospf
);
8869 /* Distance configuration. */
8870 config_write_ospf_distance(vty
, ospf
);
8872 ospf_opaque_config_write_router(vty
, ospf
);
8878 void ospf_vty_show_init(void)
8880 /* "show ip ospf" commands. */
8881 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
8883 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8885 /* "show ip ospf database" commands. */
8886 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8888 install_element(VIEW_NODE
,
8889 &show_ip_ospf_instance_database_type_adv_router_cmd
);
8890 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8891 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8893 /* "show ip ospf interface" commands. */
8894 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8896 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8898 /* "show ip ospf neighbor" commands. */
8899 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8900 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8901 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8902 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8903 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8904 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8905 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8907 install_element(VIEW_NODE
,
8908 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8909 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8910 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8911 install_element(VIEW_NODE
,
8912 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8913 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8914 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8915 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8917 /* "show ip ospf route" commands. */
8918 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
8919 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8921 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8922 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8926 /* ospfd's interface node. */
8927 static struct cmd_node interface_node
= {INTERFACE_NODE
, "%s(config-if)# ", 1};
8929 /* Initialization of OSPF interface. */
8930 static void ospf_vty_if_init(void)
8932 /* Install interface node. */
8933 install_node(&interface_node
, config_write_interface
);
8936 /* "ip ospf authentication" commands. */
8937 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8938 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8939 install_element(INTERFACE_NODE
,
8940 &no_ip_ospf_authentication_args_addr_cmd
);
8941 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8942 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8943 install_element(INTERFACE_NODE
,
8944 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8945 install_element(INTERFACE_NODE
,
8946 &no_ospf_authentication_key_authkey_addr_cmd
);
8948 /* "ip ospf message-digest-key" commands. */
8949 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8950 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8952 /* "ip ospf cost" commands. */
8953 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8954 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8956 /* "ip ospf mtu-ignore" commands. */
8957 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8958 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8960 /* "ip ospf dead-interval" commands. */
8961 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8962 install_element(INTERFACE_NODE
,
8963 &ip_ospf_dead_interval_minimal_addr_cmd
);
8964 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8966 /* "ip ospf hello-interval" commands. */
8967 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
8968 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
8970 /* "ip ospf network" commands. */
8971 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
8972 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
8974 /* "ip ospf priority" commands. */
8975 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
8976 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
8978 /* "ip ospf retransmit-interval" commands. */
8979 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
8980 install_element(INTERFACE_NODE
,
8981 &no_ip_ospf_retransmit_interval_addr_cmd
);
8983 /* "ip ospf transmit-delay" commands. */
8984 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
8985 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
8987 /* "ip ospf area" commands. */
8988 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
8989 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
8991 /* These commands are compatibitliy for previous version. */
8992 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
8993 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
8994 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
8995 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
8996 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
8997 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
8998 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
8999 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
9000 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
9001 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
9002 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
9003 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
9004 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
9005 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9006 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9007 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9008 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9011 static void ospf_vty_zebra_init(void)
9013 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
9014 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9015 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9016 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9018 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9019 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9021 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
9022 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9024 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
9025 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
9027 install_element(OSPF_NODE
, &ospf_distance_cmd
);
9028 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
9029 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9030 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
9032 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9033 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9034 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9035 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9039 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# ", 1};
9041 static void ospf_interface_clear(struct interface
*ifp
)
9043 if (!if_is_operative(ifp
))
9046 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
9047 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9052 DEFUN (clear_ip_ospf_interface
,
9053 clear_ip_ospf_interface_cmd
,
9054 "clear ip ospf interface [IFNAME]",
9057 "OSPF information\n"
9058 "Interface information\n"
9062 struct interface
*ifp
;
9063 struct listnode
*node
;
9065 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9067 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
))
9068 ospf_interface_clear(ifp
);
9069 } else /* Interface name is specified. */
9071 if ((ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
,
9074 vty_out(vty
, "No such interface name\n");
9076 ospf_interface_clear(ifp
);
9082 void ospf_vty_clear_init(void)
9084 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9088 /* Install OSPF related vty commands. */
9089 void ospf_vty_init(void)
9091 /* Install ospf top node. */
9092 install_node(&ospf_node
, ospf_config_write
);
9094 /* "router ospf" commands. */
9095 install_element(CONFIG_NODE
, &router_ospf_cmd
);
9096 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
9099 install_default(OSPF_NODE
);
9101 /* "ospf router-id" commands. */
9102 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
9103 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
9104 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
9106 /* "passive-interface" commands. */
9107 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9108 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9110 /* "ospf abr-type" commands. */
9111 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
9112 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
9114 /* "ospf log-adjacency-changes" commands. */
9115 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9116 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9117 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9118 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9120 /* "ospf rfc1583-compatible" commands. */
9121 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9122 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9123 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9124 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9126 /* "network area" commands. */
9127 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
9128 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
9130 /* "area authentication" commands. */
9131 install_element(OSPF_NODE
,
9132 &ospf_area_authentication_message_digest_cmd
);
9133 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
9134 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9136 /* "area range" commands. */
9137 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
9138 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
9139 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9140 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
9141 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9142 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9144 /* "area virtual-link" commands. */
9145 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
9146 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9147 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9148 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9151 /* "area stub" commands. */
9152 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9153 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
9154 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9155 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
9157 /* "area nssa" commands. */
9158 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
9159 install_element(OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9160 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9161 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9162 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9164 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
9165 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9167 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
9168 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9170 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
9171 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9173 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
9174 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9176 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
9177 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9179 /* SPF timer commands */
9180 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9181 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9183 /* LSA timers commands */
9184 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9185 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9186 install_element(OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9187 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9188 install_element(OSPF_NODE
, &ospf_timers_lsa_cmd
);
9189 install_element(OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9191 /* refresh timer commands */
9192 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
9193 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9195 /* max-metric commands */
9196 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9197 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9198 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9199 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9200 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9201 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9203 /* reference bandwidth commands */
9204 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9205 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9207 /* "neighbor" commands. */
9208 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
9209 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9210 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
9211 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9213 /* write multiplier commands */
9214 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
9215 install_element(OSPF_NODE
, &write_multiplier_cmd
);
9216 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9217 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
9219 /* Init interface related vty commands. */
9222 /* Init zebra related vty commands. */
9223 ospf_vty_zebra_init();