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
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
39 #include "ospfd/ospfd.h"
40 #include "ospfd/ospf_asbr.h"
41 #include "ospfd/ospf_lsa.h"
42 #include "ospfd/ospf_lsdb.h"
43 #include "ospfd/ospf_ism.h"
44 #include "ospfd/ospf_interface.h"
45 #include "ospfd/ospf_nsm.h"
46 #include "ospfd/ospf_neighbor.h"
47 #include "ospfd/ospf_flood.h"
48 #include "ospfd/ospf_abr.h"
49 #include "ospfd/ospf_spf.h"
50 #include "ospfd/ospf_route.h"
51 #include "ospfd/ospf_zebra.h"
52 /*#include "ospfd/ospf_routemap.h" */
53 #include "ospfd/ospf_vty.h"
54 #include "ospfd/ospf_dump.h"
55 #include "ospfd/ospf_bfd.h"
57 static const char *ospf_network_type_str
[] =
68 /* Utility functions. */
70 str2area_id (const char *str
, struct in_addr
*area_id
, int *area_id_fmt
)
74 area_id
->s_addr
= htonl (strtoul (str
, &ep
, 10));
75 if (*ep
&& !inet_aton (str
, area_id
))
78 *area_id_fmt
= *ep
? OSPF_AREA_ID_FMT_DOTTEDQUAD
: OSPF_AREA_ID_FMT_DECIMAL
;
84 area_id2str (char *buf
, int length
, struct in_addr
*area_id
, int area_id_fmt
)
86 memset (buf
, 0, length
);
88 if (area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
89 strncpy (buf
, inet_ntoa (*area_id
), length
);
91 sprintf (buf
, "%lu", (unsigned long) ntohl (area_id
->s_addr
));
95 str2metric (const char *str
, int *metric
)
101 *metric
= strtol (str
, NULL
, 10);
102 if (*metric
< 0 && *metric
> 16777214)
104 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
112 str2metric_type (const char *str
, int *metric_type
)
118 if (strncmp (str
, "1", 1) == 0)
119 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
120 else if (strncmp (str
, "2", 1) == 0)
121 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
129 ospf_oi_count (struct interface
*ifp
)
131 struct route_node
*rn
;
134 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
141 DEFUN_NOSH (router_ospf
,
143 "router ospf [(1-65535)]",
144 "Enable a routing process\n"
145 "Start OSPF configuration\n"
149 u_short instance
= 0;
151 ospf
= ospf_lookup();
154 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
159 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
161 /* The following logic to set the vty qobj index is in place to be able
162 to ignore the commands which dont belong to this instance. */
163 if (ospf
->instance
!= instance
)
164 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
167 if (IS_DEBUG_OSPF_EVENT
)
168 zlog_debug ("Config command 'router ospf %d' received", instance
);
169 ospf
->oi_running
= 1;
170 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
171 ospf_router_id_update (ospf
);
177 DEFUN (no_router_ospf
,
179 "no router ospf [(1-65535)]",
181 "Enable a routing process\n"
182 "Start OSPF configuration\n"
186 u_short instance
= 0;
189 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
191 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
200 DEFUN (ospf_router_id
,
202 "ospf router-id A.B.C.D",
203 "OSPF specific commands\n"
204 "router-id for the OSPF process\n"
205 "OSPF router-id in IP address format\n")
207 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
209 struct listnode
*node
;
210 struct ospf_area
*area
;
211 struct in_addr router_id
;
214 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
217 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
221 ospf
->router_id_static
= router_id
;
223 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
226 vty_out (vty
, "For this router-id change to take effect,"
227 " save config and restart ospfd%s", VTY_NEWLINE
);
231 ospf_router_id_update (ospf
);
236 DEFUN_HIDDEN (ospf_router_id_old
,
237 ospf_router_id_old_cmd
,
239 "router-id for the OSPF process\n"
240 "OSPF router-id in IP address format\n")
242 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
244 struct listnode
*node
;
245 struct ospf_area
*area
;
246 struct in_addr router_id
;
249 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
252 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
256 ospf
->router_id_static
= router_id
;
258 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
261 vty_out (vty
, "For this router-id change to take effect,"
262 " save config and restart ospfd%s", VTY_NEWLINE
);
266 ospf_router_id_update (ospf
);
271 DEFUN (no_ospf_router_id
,
272 no_ospf_router_id_cmd
,
273 "no ospf router-id [A.B.C.D]",
275 "OSPF specific commands\n"
276 "router-id for the OSPF process\n"
277 "OSPF router-id in IP address format\n")
279 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
280 struct listnode
*node
;
281 struct ospf_area
*area
;
283 ospf
->router_id_static
.s_addr
= 0;
285 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
288 vty_out (vty
, "For this router-id change to take effect,"
289 " save config and restart ospfd%s", VTY_NEWLINE
);
293 ospf_router_id_update (ospf
);
300 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
303 struct interface
*ifp
;
304 struct ospf_interface
*oi
;
306 ospf
->passive_interface_default
= newval
;
308 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
311 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
312 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
314 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
316 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
317 UNSET_IF_PARAM (oi
->params
, passive_interface
);
318 /* update multicast memberships */
319 ospf_if_set_multicast(oi
);
324 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
325 struct ospf_if_params
*params
, u_char value
,
330 params
->passive_interface
= value
;
331 if (params
!= IF_DEF_PARAMS (ifp
))
333 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
334 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
336 dflt
= ospf
->passive_interface_default
;
339 SET_IF_PARAM (params
, passive_interface
);
341 UNSET_IF_PARAM (params
, passive_interface
);
343 ospf_free_if_params (ifp
, addr
);
344 ospf_if_update_params (ifp
, addr
);
349 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
350 struct ospf_if_params
*params
, u_char value
)
352 params
->passive_interface
= value
;
353 if (params
== IF_DEF_PARAMS (ifp
))
355 if (value
!= ospf
->passive_interface_default
)
356 SET_IF_PARAM (params
, passive_interface
);
358 UNSET_IF_PARAM (params
, passive_interface
);
362 DEFUN (ospf_passive_interface
,
363 ospf_passive_interface_addr_cmd
,
364 "passive-interface <IFNAME [A.B.C.D]|default>",
365 "Suppress routing updates on an interface\n"
368 "Suppress routing updates on interfaces by default\n")
370 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
372 struct interface
*ifp
;
373 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
375 struct ospf_if_params
*params
;
376 struct route_node
*rn
;
378 if (strcmp (argv
[1]->text
, "default") == 0)
380 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
384 ifp
= if_get_by_name (argv
[1]->arg
, VRF_DEFAULT
);
386 params
= IF_DEF_PARAMS (ifp
);
390 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
393 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
398 params
= ospf_get_if_params (ifp
, addr
);
399 ospf_if_update_params (ifp
, addr
);
400 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
401 OSPF_IF_PASSIVE
, addr
);
404 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
406 /* XXX We should call ospf_if_set_multicast on exactly those
407 * interfaces for which the passive property changed. It is too much
408 * work to determine this set, so we do this for every interface.
409 * This is safe and reasonable because ospf_if_set_multicast uses a
410 * record of joined groups to avoid systems calls if the desired
411 * memberships match the current memership.
414 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
416 struct ospf_interface
*oi
= rn
->info
;
418 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
419 ospf_if_set_multicast(oi
);
422 * XXX It is not clear what state transitions the interface needs to
423 * undergo when going from active to passive. Fixing this will
424 * require precise identification of interfaces having such a
431 DEFUN (no_ospf_passive_interface
,
432 no_ospf_passive_interface_addr_cmd
,
433 "no passive-interface <IFNAME [A.B.C.D]|default>",
435 "Allow routing updates on an interface\n"
438 "Allow routing updates on interfaces by default\n")
440 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
442 struct interface
*ifp
;
443 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
444 struct ospf_if_params
*params
;
446 struct route_node
*rn
;
448 if (strcmp (argv
[2]->text
, "default") == 0)
450 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
454 ifp
= if_get_by_name (argv
[2]->arg
, VRF_DEFAULT
);
456 params
= IF_DEF_PARAMS (ifp
);
460 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
463 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
468 params
= ospf_lookup_if_params (ifp
, addr
);
471 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
474 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
476 /* XXX We should call ospf_if_set_multicast on exactly those
477 * interfaces for which the passive property changed. It is too much
478 * work to determine this set, so we do this for every interface.
479 * This is safe and reasonable because ospf_if_set_multicast uses a
480 * record of joined groups to avoid systems calls if the desired
481 * memberships match the current memership.
483 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
485 struct ospf_interface
*oi
= rn
->info
;
487 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
488 ospf_if_set_multicast(oi
);
496 DEFUN (ospf_network_area
,
497 ospf_network_area_cmd
,
498 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
499 "Enable routing on an IP network\n"
500 "OSPF network prefix\n"
501 "Set the OSPF area ID\n"
502 "OSPF area ID in IP address format\n"
503 "OSPF area ID as a decimal value\n")
505 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
506 int idx_ipv4_prefixlen
= 1;
507 int idx_ipv4_number
= 3;
508 struct prefix_ipv4 p
;
509 struct in_addr area_id
;
514 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
519 if (ospf
->if_ospf_cli_count
> 0)
521 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
526 /* Get network prefix and Area ID. */
527 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
528 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
530 ret
= ospf_network_set (ospf
, &p
, area_id
, format
);
533 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
540 DEFUN (no_ospf_network_area
,
541 no_ospf_network_area_cmd
,
542 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
544 "Enable routing on an IP network\n"
545 "OSPF network prefix\n"
546 "Set the OSPF area ID\n"
547 "OSPF area ID in IP address format\n"
548 "OSPF area ID as a decimal value\n")
550 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
551 int idx_ipv4_prefixlen
= 2;
552 int idx_ipv4_number
= 4;
553 struct prefix_ipv4 p
;
554 struct in_addr area_id
;
559 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
564 /* Get network prefix and Area ID. */
565 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
566 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
568 ret
= ospf_network_unset (ospf
, &p
, area_id
);
571 vty_out (vty
, "Can't find specified network area configuration.%s",
579 DEFUN (ospf_area_range
,
581 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
582 "OSPF area parameters\n"
583 "OSPF area ID in IP address format\n"
584 "OSPF area ID as a decimal value\n"
585 "Summarize routes matching address/mask (border routers only)\n"
586 "Area range prefix\n"
587 "Advertise this range (default)\n"
588 "User specified metric for this range\n"
589 "Advertised metric for this range\n")
591 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
592 int idx_ipv4_number
= 1;
593 int idx_ipv4_prefixlen
= 3;
595 struct prefix_ipv4 p
;
596 struct in_addr area_id
;
600 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
601 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
603 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
606 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
607 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
613 DEFUN (ospf_area_range_cost
,
614 ospf_area_range_cost_cmd
,
615 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
616 "OSPF area parameters\n"
617 "OSPF area ID in IP address format\n"
618 "OSPF area ID as a decimal value\n"
619 "Summarize routes matching address/mask (border routers only)\n"
620 "Area range prefix\n"
621 "User specified metric for this range\n"
622 "Advertised metric for this range\n")
624 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
625 int idx_ipv4_number
= 1;
626 int idx_ipv4_prefixlen
= 3;
628 struct prefix_ipv4 p
;
629 struct in_addr area_id
;
633 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
634 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
636 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
637 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
639 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
640 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
645 DEFUN (ospf_area_range_not_advertise
,
646 ospf_area_range_not_advertise_cmd
,
647 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M 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 "DoNotAdvertise this range\n")
655 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
656 int idx_ipv4_number
= 1;
657 int idx_ipv4_prefixlen
= 3;
658 struct prefix_ipv4 p
;
659 struct in_addr area_id
;
662 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
663 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
665 ospf_area_range_set (ospf
, area_id
, &p
, 0);
666 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
671 DEFUN (no_ospf_area_range
,
672 no_ospf_area_range_cmd
,
673 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
675 "OSPF area parameters\n"
676 "OSPF area ID in IP address format\n"
677 "OSPF area ID as a decimal value\n"
678 "Summarize routes matching address/mask (border routers only)\n"
679 "Area range prefix\n"
680 "User specified metric for this range\n"
681 "Advertised metric for this range\n"
682 "Advertise this range (default)\n"
683 "User specified metric for this range\n"
684 "Advertised metric for this range\n"
685 "DoNotAdvertise this range\n")
687 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
688 int idx_ipv4_number
= 2;
689 int idx_ipv4_prefixlen
= 4;
690 struct prefix_ipv4 p
;
691 struct in_addr area_id
;
694 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
695 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
697 ospf_area_range_unset (ospf
, area_id
, &p
);
702 DEFUN (ospf_area_range_substitute
,
703 ospf_area_range_substitute_cmd
,
704 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
705 "OSPF area parameters\n"
706 "OSPF area ID in IP address format\n"
707 "OSPF area ID as a decimal value\n"
708 "Summarize routes matching address/mask (border routers only)\n"
709 "Area range prefix\n"
710 "Announce area range as another prefix\n"
711 "Network prefix to be announced instead of range\n")
713 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
714 int idx_ipv4_number
= 1;
715 int idx_ipv4_prefixlen
= 3;
716 int idx_ipv4_prefixlen_2
= 5;
717 struct prefix_ipv4 p
, s
;
718 struct in_addr area_id
;
721 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
722 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
723 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
725 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
726 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
731 DEFUN (no_ospf_area_range_substitute
,
732 no_ospf_area_range_substitute_cmd
,
733 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
735 "OSPF area parameters\n"
736 "OSPF area ID in IP address format\n"
737 "OSPF area ID as a decimal value\n"
738 "Summarize routes matching address/mask (border routers only)\n"
739 "Area range prefix\n"
740 "Announce area range as another prefix\n"
741 "Network prefix to be announced instead of range\n")
743 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
744 int idx_ipv4_number
= 2;
745 int idx_ipv4_prefixlen
= 4;
746 int idx_ipv4_prefixlen_2
= 6;
747 struct prefix_ipv4 p
, s
;
748 struct in_addr area_id
;
751 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
752 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
753 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
755 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
761 /* Command Handler Logic in VLink stuff is delicate!!
763 ALTER AT YOUR OWN RISK!!!!
765 Various dummy values are used to represent 'NoChange' state for
766 VLink configuration NOT being changed by a VLink command, and
767 special syntax is used within the command strings so that the
768 typed in command verbs can be seen in the configuration command
769 bacckend handler. This is to drastically reduce the verbeage
770 required to coe up with a reasonably compatible Cisco VLink command
772 - Matthew Grant <grantma@anathoth.gen.nz>
773 Wed, 21 Feb 2001 15:13:52 +1300
776 /* Configuration data for virtual links
778 struct ospf_vl_config_data
{
779 struct vty
*vty
; /* vty stuff */
780 struct in_addr area_id
; /* area ID from command line */
781 int area_id_fmt
; /* command line area ID format */
782 struct in_addr vl_peer
; /* command line vl_peer */
783 int auth_type
; /* Authehntication type, if given */
784 char *auth_key
; /* simple password if present */
785 int crypto_key_id
; /* Cryptographic key ID */
786 char *md5_key
; /* MD5 authentication key */
787 int hello_interval
; /* Obvious what these are... */
788 int retransmit_interval
;
794 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
797 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
798 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
799 vl_config
->vty
= vty
;
802 static struct ospf_vl_data
*
803 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
805 struct ospf_area
*area
;
806 struct ospf_vl_data
*vl_data
;
808 struct in_addr area_id
;
810 vty
= vl_config
->vty
;
811 area_id
= vl_config
->area_id
;
813 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
816 "Configuring VLs over the backbone is not allowed%s",
820 area
= ospf_area_get (ospf
, area_id
);
821 ospf_area_display_format_set (ospf
, area
, vl_config
->area_id_fmt
);
823 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
825 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
826 vty_out (vty
, "Area %s is %s%s",
828 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
831 vty_out (vty
, "Area %ld is %s%s",
832 (u_long
)ntohl (area_id
.s_addr
),
833 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
838 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
840 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
841 if (vl_data
->vl_oi
== NULL
)
843 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
844 ospf_vl_add (ospf
, vl_data
);
845 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
853 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
854 struct ospf_vl_config_data
*vl_config
)
856 struct crypt_key
*ck
;
858 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
860 vty
= vl_config
->vty
;
862 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
864 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
865 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
868 if (vl_config
->auth_key
)
870 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
871 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
872 OSPF_AUTH_SIMPLE_SIZE
);
874 else if (vl_config
->md5_key
)
876 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
879 vty_out (vty
, "OSPF: Key %d already exists%s",
880 vl_config
->crypto_key_id
, VTY_NEWLINE
);
883 ck
= ospf_crypt_key_new ();
884 ck
->key_id
= vl_config
->crypto_key_id
;
885 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
886 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
888 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
890 else if (vl_config
->crypto_key_id
!= 0)
894 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
895 vl_config
->crypto_key_id
) == NULL
)
897 vty_out (vty
, "OSPF: Key %d does not exist%s",
898 vl_config
->crypto_key_id
, VTY_NEWLINE
);
902 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
910 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
911 struct ospf_vl_config_data
*vl_config
)
913 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
914 /* Virtual Link data initialised to defaults, so only set
916 if (vl_config
->hello_interval
)
918 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
919 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
922 if (vl_config
->dead_interval
)
924 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
925 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
928 if (vl_config
->retransmit_interval
)
930 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
931 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
934 if (vl_config
->transmit_delay
)
936 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
937 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
944 /* The business end of all of the above */
946 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
948 struct ospf_vl_data
*vl_data
;
951 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
955 /* Process this one first as it can have a fatal result, which can
956 only logically occur if the virtual link exists already
957 Thus a command error does not result in a change to the
958 running configuration such as unexpectedly altered timer
960 ret
= ospf_vl_set_security (vl_data
, vl_config
);
961 if (ret
!= CMD_SUCCESS
)
964 /* Set any time based parameters, these area already range checked */
966 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
967 if (ret
!= CMD_SUCCESS
)
974 /* This stuff exists to make specifying all the alias commands A LOT simpler
976 #define VLINK_HELPSTR_IPADDR \
977 "OSPF area parameters\n" \
978 "OSPF area ID in IP address format\n" \
979 "OSPF area ID as a decimal value\n" \
980 "Configure a virtual link\n" \
981 "Router ID of the remote ABR\n"
983 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
984 "Enable authentication on this virtual link\n" \
987 #define VLINK_HELPSTR_AUTHTYPE_ALL \
988 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
989 "Use null authentication\n" \
990 "Use message-digest authentication\n"
992 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
993 "Time between HELLO packets\n" \
994 "Time between retransmitting lost link state advertisements\n" \
995 "Link state transmit delay\n" \
996 "Interval time after which a neighbor is declared down\n"
998 #define VLINK_HELPSTR_TIME_PARAM \
999 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1002 #define VLINK_HELPSTR_AUTH_SIMPLE \
1003 "Authentication password (key)\n" \
1004 "The OSPF password (key)"
1006 #define VLINK_HELPSTR_AUTH_MD5 \
1007 "Message digest authentication password (key)\n" \
1010 "Use MD5 algorithm\n" \
1011 "The OSPF password (key)"
1013 DEFUN (ospf_area_vlink
,
1014 ospf_area_vlink_cmd
,
1015 "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>]",
1016 VLINK_HELPSTR_IPADDR
1017 "Enable authentication on this virtual link\n" \
1018 "Use null authentication\n" \
1019 "Use message-digest authentication\n"
1020 "Message digest authentication password (key)\n" \
1022 "Use MD5 algorithm\n" \
1023 "The OSPF password (key)")
1025 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1026 int idx_ipv4_number
= 1;
1028 struct ospf_vl_config_data vl_config
;
1029 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1030 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1034 ospf_vl_config_data_init(&vl_config
, vty
);
1036 /* Read off first 2 parameters and check them */
1037 ret
= str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1038 &vl_config
.area_id_fmt
);
1041 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1045 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1048 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1055 /* Thats all folks! - BUGS B. strikes again!!!*/
1057 return ospf_vl_set (ospf
, &vl_config
);
1060 /* Deal with other parameters */
1061 for (i
=5; i
< argc
; i
++)
1064 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1066 switch (argv
[i
]->arg
[0])
1070 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1072 /* authentication-key - this option can occur anywhere on
1073 command line. At start of command line
1074 must check for authentication option. */
1075 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1076 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1077 vl_config
.auth_key
= auth_key
;
1080 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1082 /* authentication - this option can only occur at start
1084 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1087 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1089 /* "authentication null" */
1090 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1093 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1094 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1096 /* "authentication message-digest" */
1097 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1105 /* message-digest-key */
1109 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1110 if (vl_config
.crypto_key_id
< 0)
1115 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1116 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1117 vl_config
.md5_key
= md5_key
;
1121 vl_config
.md5_key
= NULL
;
1127 /* Action configuration */
1129 return ospf_vl_set (ospf
, &vl_config
);
1133 DEFUN (ospf_area_vlink_intervals
,
1134 ospf_area_vlink_intervals_cmd
,
1135 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1136 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1137 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1138 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1139 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1141 VLINK_HELPSTR_IPADDR
1142 VLINK_HELPSTR_TIME_PARAM
1143 VLINK_HELPSTR_TIME_PARAM
1144 VLINK_HELPSTR_TIME_PARAM
1145 VLINK_HELPSTR_TIME_PARAM
)
1147 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1148 struct ospf_vl_config_data vl_config
;
1151 ospf_vl_config_data_init(&vl_config
, vty
);
1153 char *area_id
= argv
[1]->arg
;
1154 char *router_id
= argv
[3]->arg
;
1156 ret
= str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1159 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1163 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1166 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1169 for (unsigned int i
= 0; i
< 4; i
++)
1172 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1173 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1174 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1175 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1176 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1177 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1178 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1179 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1182 /* Action configuration */
1183 return ospf_vl_set (ospf
, &vl_config
);
1186 DEFUN (no_ospf_area_vlink
,
1187 no_ospf_area_vlink_cmd
,
1188 "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>]",
1190 VLINK_HELPSTR_IPADDR
1191 "Enable authentication on this virtual link\n" \
1192 "Use null authentication\n" \
1193 "Use message-digest authentication\n"
1194 "Message digest authentication password (key)\n" \
1196 "Use MD5 algorithm\n" \
1197 "The OSPF password (key)")
1199 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1200 int idx_ipv4_number
= 2;
1202 struct ospf_area
*area
;
1203 struct ospf_vl_config_data vl_config
;
1204 struct ospf_vl_data
*vl_data
= NULL
;
1205 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1209 ospf_vl_config_data_init(&vl_config
, vty
);
1211 ret
= str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1214 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1218 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1221 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1225 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1228 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1235 /* Basic VLink no command */
1236 /* Thats all folks! - BUGS B. strikes again!!!*/
1237 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1238 ospf_vl_delete (ospf
, vl_data
);
1240 ospf_area_check_free (ospf
, vl_config
.area_id
);
1245 /* If we are down here, we are reseting parameters */
1247 /* Deal with other parameters */
1248 for (i
=6; i
< argc
; i
++)
1250 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1252 switch (argv
[i
]->arg
[0])
1256 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1258 /* authentication-key - this option can occur anywhere on
1259 command line. At start of command line
1260 must check for authentication option. */
1261 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1262 vl_config
.auth_key
= auth_key
;
1264 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1266 /* authentication - this option can only occur at start
1268 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1273 /* message-digest-key */
1274 /* Delete one key */
1278 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1279 if (vl_config
.crypto_key_id
< 0)
1281 vl_config
.md5_key
= NULL
;
1291 /* Action configuration */
1293 return ospf_vl_set (ospf
, &vl_config
);
1296 DEFUN (no_ospf_area_vlink_intervals
,
1297 no_ospf_area_vlink_intervals_cmd
,
1298 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1299 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1300 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1301 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1302 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1305 VLINK_HELPSTR_IPADDR
1306 VLINK_HELPSTR_TIME_PARAM
1307 VLINK_HELPSTR_TIME_PARAM
1308 VLINK_HELPSTR_TIME_PARAM
1309 VLINK_HELPSTR_TIME_PARAM
)
1311 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1312 struct ospf_vl_config_data vl_config
;
1315 ospf_vl_config_data_init(&vl_config
, vty
);
1317 char *area_id
= argv
[2]->arg
;
1318 char *router_id
= argv
[4]->arg
;
1320 ret
= str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1323 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1327 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1330 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1334 for (unsigned int i
= 0; i
< 4; i
++)
1337 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1338 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1339 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1340 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1341 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1342 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1343 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1344 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1347 /* Action configuration */
1348 return ospf_vl_set (ospf
, &vl_config
);
1351 DEFUN (ospf_area_shortcut
,
1352 ospf_area_shortcut_cmd
,
1353 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1354 "OSPF area parameters\n"
1355 "OSPF area ID in IP address format\n"
1356 "OSPF area ID as a decimal value\n"
1357 "Configure the area's shortcutting mode\n"
1358 "Set default shortcutting behavior\n"
1359 "Enable shortcutting through the area\n"
1360 "Disable shortcutting through the area\n")
1362 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1363 int idx_ipv4_number
= 1;
1364 int idx_enable_disable
= 3;
1365 struct ospf_area
*area
;
1366 struct in_addr area_id
;
1370 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1372 area
= ospf_area_get (ospf
, area_id
);
1373 ospf_area_display_format_set (ospf
, area
, format
);
1375 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1376 mode
= OSPF_SHORTCUT_DEFAULT
;
1377 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1378 mode
= OSPF_SHORTCUT_DISABLE
;
1379 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1380 mode
= OSPF_SHORTCUT_ENABLE
;
1384 ospf_area_shortcut_set (ospf
, area
, mode
);
1386 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1387 vty_out (vty
, "Shortcut area setting will take effect "
1388 "only when the router is configured as Shortcut ABR%s",
1394 DEFUN (no_ospf_area_shortcut
,
1395 no_ospf_area_shortcut_cmd
,
1396 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1398 "OSPF area parameters\n"
1399 "OSPF area ID in IP address format\n"
1400 "OSPF area ID as a decimal value\n"
1401 "Deconfigure the area's shortcutting mode\n"
1402 "Deconfigure enabled shortcutting through the area\n"
1403 "Deconfigure disabled shortcutting through the area\n")
1405 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1406 int idx_ipv4_number
= 2;
1407 struct ospf_area
*area
;
1408 struct in_addr area_id
;
1411 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1413 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1417 ospf_area_shortcut_unset (ospf
, area
);
1423 DEFUN (ospf_area_stub
,
1425 "area <A.B.C.D|(0-4294967295)> stub",
1426 "OSPF area parameters\n"
1427 "OSPF area ID in IP address format\n"
1428 "OSPF area ID as a decimal value\n"
1429 "Configure OSPF area as stub\n")
1431 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1432 int idx_ipv4_number
= 1;
1433 struct in_addr area_id
;
1436 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1438 ret
= ospf_area_stub_set (ospf
, area_id
);
1439 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1442 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1447 ospf_area_no_summary_unset (ospf
, area_id
);
1452 DEFUN (ospf_area_stub_no_summary
,
1453 ospf_area_stub_no_summary_cmd
,
1454 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1455 "OSPF stub 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 stub\n")
1461 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1462 int idx_ipv4_number
= 1;
1463 struct in_addr area_id
;
1466 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1468 ret
= ospf_area_stub_set (ospf
, area_id
);
1469 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1472 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1477 ospf_area_no_summary_set (ospf
, area_id
);
1482 DEFUN (no_ospf_area_stub
,
1483 no_ospf_area_stub_cmd
,
1484 "no area <A.B.C.D|(0-4294967295)> stub",
1486 "OSPF area parameters\n"
1487 "OSPF area ID in IP address format\n"
1488 "OSPF area ID as a decimal value\n"
1489 "Configure OSPF area as stub\n")
1491 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1492 int idx_ipv4_number
= 2;
1493 struct in_addr area_id
;
1496 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1498 ospf_area_stub_unset (ospf
, area_id
);
1499 ospf_area_no_summary_unset (ospf
, area_id
);
1504 DEFUN (no_ospf_area_stub_no_summary
,
1505 no_ospf_area_stub_no_summary_cmd
,
1506 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1508 "OSPF area parameters\n"
1509 "OSPF area ID in IP address format\n"
1510 "OSPF area ID as a decimal value\n"
1511 "Configure OSPF area as stub\n"
1512 "Do not inject inter-area routes into area\n")
1514 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1515 int idx_ipv4_number
= 2;
1516 struct in_addr area_id
;
1519 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1520 ospf_area_no_summary_unset (ospf
, area_id
);
1526 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1529 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1530 struct in_addr area_id
;
1533 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1535 ret
= ospf_area_nssa_set (ospf
, area_id
);
1536 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1539 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1546 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1547 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1548 OSPF_NSSA_ROLE_CANDIDATE
);
1549 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1550 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1551 OSPF_NSSA_ROLE_NEVER
);
1552 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1553 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1554 OSPF_NSSA_ROLE_ALWAYS
);
1558 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1559 OSPF_NSSA_ROLE_CANDIDATE
);
1563 ospf_area_no_summary_set (ospf
, area_id
);
1565 ospf_area_no_summary_unset (ospf
, area_id
);
1567 ospf_schedule_abr_task (ospf
);
1572 DEFUN (ospf_area_nssa_translate_no_summary
,
1573 ospf_area_nssa_translate_no_summary_cmd
,
1574 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1575 "OSPF area parameters\n"
1576 "OSPF area ID in IP address format\n"
1577 "OSPF area ID as a decimal value\n"
1578 "Configure OSPF area as nssa\n"
1579 "Configure NSSA-ABR for translate election (default)\n"
1580 "Configure NSSA-ABR to never translate\n"
1581 "Configure NSSA-ABR to always translate\n"
1582 "Do not inject inter-area routes into nssa\n")
1584 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1587 DEFUN (ospf_area_nssa_translate
,
1588 ospf_area_nssa_translate_cmd
,
1589 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1590 "OSPF area parameters\n"
1591 "OSPF area ID in IP address format\n"
1592 "OSPF area ID as a decimal value\n"
1593 "Configure OSPF area as nssa\n"
1594 "Configure NSSA-ABR for translate election (default)\n"
1595 "Configure NSSA-ABR to never translate\n"
1596 "Configure NSSA-ABR to always translate\n")
1598 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1601 DEFUN (ospf_area_nssa
,
1603 "area <A.B.C.D|(0-4294967295)> nssa",
1604 "OSPF area parameters\n"
1605 "OSPF area ID in IP address format\n"
1606 "OSPF area ID as a decimal value\n"
1607 "Configure OSPF area as nssa\n")
1609 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1612 DEFUN (ospf_area_nssa_no_summary
,
1613 ospf_area_nssa_no_summary_cmd
,
1614 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1615 "OSPF area parameters\n"
1616 "OSPF area ID in IP address format\n"
1617 "OSPF area ID as a decimal value\n"
1618 "Configure OSPF area as nssa\n"
1619 "Do not inject inter-area routes into nssa\n")
1621 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1624 DEFUN (no_ospf_area_nssa
,
1625 no_ospf_area_nssa_cmd
,
1626 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1628 "OSPF area parameters\n"
1629 "OSPF area ID in IP address format\n"
1630 "OSPF area ID as a decimal value\n"
1631 "Configure OSPF area as nssa\n"
1632 "Configure NSSA-ABR for translate election (default)\n"
1633 "Configure NSSA-ABR to never translate\n"
1634 "Configure NSSA-ABR to always translate\n"
1635 "Do not inject inter-area routes into nssa\n")
1637 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1638 int idx_ipv4_number
= 2;
1639 struct in_addr area_id
;
1642 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1644 ospf_area_nssa_unset (ospf
, area_id
);
1645 ospf_area_no_summary_unset (ospf
, area_id
);
1647 ospf_schedule_abr_task (ospf
);
1653 DEFUN (ospf_area_default_cost
,
1654 ospf_area_default_cost_cmd
,
1655 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1656 "OSPF area parameters\n"
1657 "OSPF area ID in IP address format\n"
1658 "OSPF area ID as a decimal value\n"
1659 "Set the summary-default cost of a NSSA or stub area\n"
1660 "Stub's advertised default summary cost\n")
1662 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1663 int idx_ipv4_number
= 1;
1665 struct ospf_area
*area
;
1666 struct in_addr area_id
;
1669 struct prefix_ipv4 p
;
1671 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1672 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1674 area
= ospf_area_get (ospf
, area_id
);
1675 ospf_area_display_format_set (ospf
, area
, format
);
1677 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1679 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1683 area
->default_cost
= cost
;
1686 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1688 if (IS_DEBUG_OSPF_EVENT
)
1689 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1690 "announcing 0.0.0.0/0 to area %s",
1691 inet_ntoa (area
->area_id
));
1692 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1697 DEFUN (no_ospf_area_default_cost
,
1698 no_ospf_area_default_cost_cmd
,
1699 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1701 "OSPF area parameters\n"
1702 "OSPF area ID in IP address format\n"
1703 "OSPF area ID as a decimal value\n"
1704 "Set the summary-default cost of a NSSA or stub area\n"
1705 "Stub's advertised default summary cost\n")
1707 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1708 int idx_ipv4_number
= 2;
1710 struct ospf_area
*area
;
1711 struct in_addr area_id
;
1713 struct prefix_ipv4 p
;
1715 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1716 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1718 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1722 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1724 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1728 area
->default_cost
= 1;
1731 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1733 if (IS_DEBUG_OSPF_EVENT
)
1734 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1735 "announcing 0.0.0.0/0 to area %s",
1736 inet_ntoa (area
->area_id
));
1737 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1740 ospf_area_check_free (ospf
, area_id
);
1745 DEFUN (ospf_area_export_list
,
1746 ospf_area_export_list_cmd
,
1747 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1748 "OSPF area parameters\n"
1749 "OSPF area ID in IP address format\n"
1750 "OSPF area ID as a decimal value\n"
1751 "Set the filter for networks announced to other areas\n"
1752 "Name of the access-list\n")
1754 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1755 int idx_ipv4_number
= 1;
1756 struct ospf_area
*area
;
1757 struct in_addr area_id
;
1760 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1762 area
= ospf_area_get (ospf
, area_id
);
1763 ospf_area_display_format_set (ospf
, area
, format
);
1764 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1769 DEFUN (no_ospf_area_export_list
,
1770 no_ospf_area_export_list_cmd
,
1771 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1773 "OSPF area parameters\n"
1774 "OSPF area ID in IP address format\n"
1775 "OSPF area ID as a decimal value\n"
1776 "Unset the filter for networks announced to other areas\n"
1777 "Name of the access-list\n")
1779 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1780 int idx_ipv4_number
= 2;
1781 struct ospf_area
*area
;
1782 struct in_addr area_id
;
1785 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1787 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1791 ospf_area_export_list_unset (ospf
, area
);
1797 DEFUN (ospf_area_import_list
,
1798 ospf_area_import_list_cmd
,
1799 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1800 "OSPF area parameters\n"
1801 "OSPF area ID in IP address format\n"
1802 "OSPF area ID as a decimal value\n"
1803 "Set the filter for networks from other areas announced to the specified one\n"
1804 "Name of the access-list\n")
1806 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1807 int idx_ipv4_number
= 1;
1808 struct ospf_area
*area
;
1809 struct in_addr area_id
;
1812 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1814 area
= ospf_area_get (ospf
, area_id
);
1815 ospf_area_display_format_set (ospf
, area
, format
);
1816 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1821 DEFUN (no_ospf_area_import_list
,
1822 no_ospf_area_import_list_cmd
,
1823 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1825 "OSPF area parameters\n"
1826 "OSPF area ID in IP address format\n"
1827 "OSPF area ID as a decimal value\n"
1828 "Unset the filter for networks announced to other areas\n"
1829 "Name of the access-list\n")
1831 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1832 int idx_ipv4_number
= 2;
1833 struct ospf_area
*area
;
1834 struct in_addr area_id
;
1837 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1839 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1843 ospf_area_import_list_unset (ospf
, area
);
1848 DEFUN (ospf_area_filter_list
,
1849 ospf_area_filter_list_cmd
,
1850 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1851 "OSPF area parameters\n"
1852 "OSPF area ID in IP address format\n"
1853 "OSPF area ID as a decimal value\n"
1854 "Filter networks between OSPF areas\n"
1855 "Filter prefixes between OSPF areas\n"
1856 "Name of an IP prefix-list\n"
1857 "Filter networks sent to this area\n"
1858 "Filter networks sent from this area\n")
1860 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1861 int idx_ipv4_number
= 1;
1864 struct ospf_area
*area
;
1865 struct in_addr area_id
;
1866 struct prefix_list
*plist
;
1869 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1871 area
= ospf_area_get (ospf
, area_id
);
1872 ospf_area_display_format_set (ospf
, area
, format
);
1873 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1874 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1876 PREFIX_LIST_IN (area
) = plist
;
1877 if (PREFIX_NAME_IN (area
))
1878 free (PREFIX_NAME_IN (area
));
1880 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1881 ospf_schedule_abr_task (ospf
);
1885 PREFIX_LIST_OUT (area
) = plist
;
1886 if (PREFIX_NAME_OUT (area
))
1887 free (PREFIX_NAME_OUT (area
));
1889 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1890 ospf_schedule_abr_task (ospf
);
1896 DEFUN (no_ospf_area_filter_list
,
1897 no_ospf_area_filter_list_cmd
,
1898 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1900 "OSPF area parameters\n"
1901 "OSPF area ID in IP address format\n"
1902 "OSPF area ID as a decimal value\n"
1903 "Filter networks between OSPF areas\n"
1904 "Filter prefixes between OSPF areas\n"
1905 "Name of an IP prefix-list\n"
1906 "Filter networks sent to this area\n"
1907 "Filter networks sent from this area\n")
1909 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1910 int idx_ipv4_number
= 2;
1913 struct ospf_area
*area
;
1914 struct in_addr area_id
;
1917 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1919 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1922 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1924 if (PREFIX_NAME_IN (area
))
1925 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1928 PREFIX_LIST_IN (area
) = NULL
;
1929 if (PREFIX_NAME_IN (area
))
1930 free (PREFIX_NAME_IN (area
));
1932 PREFIX_NAME_IN (area
) = NULL
;
1934 ospf_schedule_abr_task (ospf
);
1938 if (PREFIX_NAME_OUT (area
))
1939 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1942 PREFIX_LIST_OUT (area
) = NULL
;
1943 if (PREFIX_NAME_OUT (area
))
1944 free (PREFIX_NAME_OUT (area
));
1946 PREFIX_NAME_OUT (area
) = NULL
;
1948 ospf_schedule_abr_task (ospf
);
1955 DEFUN (ospf_area_authentication_message_digest
,
1956 ospf_area_authentication_message_digest_cmd
,
1957 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1958 "OSPF area parameters\n"
1959 "OSPF area ID in IP address format\n"
1960 "OSPF area ID as a decimal value\n"
1961 "Enable authentication\n"
1962 "Use message-digest authentication\n")
1964 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1965 int idx_ipv4_number
= 1;
1966 struct ospf_area
*area
;
1967 struct in_addr area_id
;
1970 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1972 area
= ospf_area_get (ospf
, area_id
);
1973 ospf_area_display_format_set (ospf
, area
, format
);
1974 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1979 DEFUN (ospf_area_authentication
,
1980 ospf_area_authentication_cmd
,
1981 "area <A.B.C.D|(0-4294967295)> authentication",
1982 "OSPF area parameters\n"
1983 "OSPF area ID in IP address format\n"
1984 "OSPF area ID as a decimal value\n"
1985 "Enable authentication\n")
1987 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1988 int idx_ipv4_number
= 1;
1989 struct ospf_area
*area
;
1990 struct in_addr area_id
;
1993 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1995 area
= ospf_area_get (ospf
, area_id
);
1996 ospf_area_display_format_set (ospf
, area
, format
);
1997 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2002 DEFUN (no_ospf_area_authentication
,
2003 no_ospf_area_authentication_cmd
,
2004 "no area <A.B.C.D|(0-4294967295)> authentication",
2006 "OSPF area parameters\n"
2007 "OSPF area ID in IP address format\n"
2008 "OSPF area ID as a decimal value\n"
2009 "Enable authentication\n")
2011 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2012 int idx_ipv4_number
= 2;
2013 struct ospf_area
*area
;
2014 struct in_addr area_id
;
2017 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2019 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2023 area
->auth_type
= OSPF_AUTH_NULL
;
2025 ospf_area_check_free (ospf
, area_id
);
2031 DEFUN (ospf_abr_type
,
2033 "ospf abr-type <cisco|ibm|shortcut|standard>",
2034 "OSPF specific commands\n"
2035 "Set OSPF ABR type\n"
2036 "Alternative ABR, cisco implementation\n"
2037 "Alternative ABR, IBM implementation\n"
2039 "Standard behavior (RFC2328)\n")
2041 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2043 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2045 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2046 abr_type
= OSPF_ABR_CISCO
;
2047 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2048 abr_type
= OSPF_ABR_IBM
;
2049 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2050 abr_type
= OSPF_ABR_SHORTCUT
;
2051 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2052 abr_type
= OSPF_ABR_STAND
;
2056 /* If ABR type value is changed, schedule ABR task. */
2057 if (ospf
->abr_type
!= abr_type
)
2059 ospf
->abr_type
= abr_type
;
2060 ospf_schedule_abr_task (ospf
);
2066 DEFUN (no_ospf_abr_type
,
2067 no_ospf_abr_type_cmd
,
2068 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2070 "OSPF specific commands\n"
2071 "Set OSPF ABR type\n"
2072 "Alternative ABR, cisco implementation\n"
2073 "Alternative ABR, IBM implementation\n"
2077 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2079 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2081 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2082 abr_type
= OSPF_ABR_CISCO
;
2083 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2084 abr_type
= OSPF_ABR_IBM
;
2085 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2086 abr_type
= OSPF_ABR_SHORTCUT
;
2087 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2088 abr_type
= OSPF_ABR_STAND
;
2092 /* If ABR type value is changed, schedule ABR task. */
2093 if (ospf
->abr_type
== abr_type
)
2095 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2096 ospf_schedule_abr_task (ospf
);
2102 DEFUN (ospf_log_adjacency_changes
,
2103 ospf_log_adjacency_changes_cmd
,
2104 "log-adjacency-changes",
2105 "Log changes in adjacency state\n")
2107 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2109 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2110 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2114 DEFUN (ospf_log_adjacency_changes_detail
,
2115 ospf_log_adjacency_changes_detail_cmd
,
2116 "log-adjacency-changes detail",
2117 "Log changes in adjacency state\n"
2118 "Log all state changes\n")
2120 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2122 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2123 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2127 DEFUN (no_ospf_log_adjacency_changes
,
2128 no_ospf_log_adjacency_changes_cmd
,
2129 "no log-adjacency-changes",
2131 "Log changes in adjacency state\n")
2133 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2135 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2136 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2140 DEFUN (no_ospf_log_adjacency_changes_detail
,
2141 no_ospf_log_adjacency_changes_detail_cmd
,
2142 "no log-adjacency-changes detail",
2144 "Log changes in adjacency state\n"
2145 "Log all state changes\n")
2147 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2149 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2153 DEFUN (ospf_compatible_rfc1583
,
2154 ospf_compatible_rfc1583_cmd
,
2155 "compatible rfc1583",
2156 "OSPF compatibility list\n"
2157 "compatible with RFC 1583\n")
2159 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2161 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2163 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2164 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2169 DEFUN (no_ospf_compatible_rfc1583
,
2170 no_ospf_compatible_rfc1583_cmd
,
2171 "no compatible rfc1583",
2173 "OSPF compatibility list\n"
2174 "compatible with RFC 1583\n")
2176 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2178 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2180 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2181 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2186 ALIAS (ospf_compatible_rfc1583
,
2187 ospf_rfc1583_flag_cmd
,
2188 "ospf rfc1583compatibility",
2189 "OSPF specific commands\n"
2190 "Enable the RFC1583Compatibility flag\n")
2192 ALIAS (no_ospf_compatible_rfc1583
,
2193 no_ospf_rfc1583_flag_cmd
,
2194 "no ospf rfc1583compatibility",
2196 "OSPF specific commands\n"
2197 "Disable the RFC1583Compatibility flag\n")
2200 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2204 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2206 ospf
->spf_delay
= delay
;
2207 ospf
->spf_holdtime
= hold
;
2208 ospf
->spf_max_holdtime
= max
;
2213 DEFUN (ospf_timers_min_ls_interval
,
2214 ospf_timers_min_ls_interval_cmd
,
2215 "timers throttle lsa all (0-5000)",
2216 "Adjust routing timers\n"
2217 "Throttling adaptive timer\n"
2218 "LSA delay between transmissions\n"
2220 "Delay (msec) between sending LSAs\n")
2222 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2224 unsigned int interval
;
2228 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2232 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2234 ospf
->min_ls_interval
= interval
;
2239 DEFUN (no_ospf_timers_min_ls_interval
,
2240 no_ospf_timers_min_ls_interval_cmd
,
2241 "no timers throttle lsa all [(0-5000)]",
2243 "Adjust routing timers\n"
2244 "Throttling adaptive timer\n"
2245 "LSA delay between transmissions\n"
2247 "Delay (msec) between sending LSAs\n")
2249 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2250 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2256 DEFUN (ospf_timers_min_ls_arrival
,
2257 ospf_timers_min_ls_arrival_cmd
,
2258 "timers lsa arrival (0-1000)",
2259 "Adjust routing timers\n"
2260 "Throttling link state advertisement delays\n"
2261 "OSPF minimum arrival interval delay\n"
2262 "Delay (msec) between accepted LSAs\n")
2264 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2266 unsigned int arrival
;
2270 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2274 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2276 ospf
->min_ls_arrival
= arrival
;
2281 DEFUN (no_ospf_timers_min_ls_arrival
,
2282 no_ospf_timers_min_ls_arrival_cmd
,
2283 "no timers lsa arrival [(0-1000)]",
2285 "Adjust routing timers\n"
2286 "Throttling link state advertisement delays\n"
2287 "OSPF minimum arrival interval delay\n"
2288 "Delay (msec) between accepted LSAs\n")
2290 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2292 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2298 DEFUN (ospf_timers_throttle_spf
,
2299 ospf_timers_throttle_spf_cmd
,
2300 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2301 "Adjust routing timers\n"
2302 "Throttling adaptive timer\n"
2304 "Delay (msec) from first change received till SPF calculation\n"
2305 "Initial hold time (msec) between consecutive SPF calculations\n"
2306 "Maximum hold time (msec)\n")
2309 int idx_number_2
= 4;
2310 int idx_number_3
= 5;
2311 unsigned int delay
, hold
, max
;
2315 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2319 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2320 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2321 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2323 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2326 DEFUN (no_ospf_timers_throttle_spf
,
2327 no_ospf_timers_throttle_spf_cmd
,
2328 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2330 "Adjust routing timers\n"
2331 "Throttling adaptive timer\n"
2333 "Delay (msec) from first change received till SPF calculation\n"
2334 "Initial hold time (msec) between consecutive SPF calculations\n"
2335 "Maximum hold time (msec)\n")
2337 return ospf_timers_spf_set (vty
,
2338 OSPF_SPF_DELAY_DEFAULT
,
2339 OSPF_SPF_HOLDTIME_DEFAULT
,
2340 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2344 DEFUN (ospf_timers_lsa
,
2345 ospf_timers_lsa_cmd
,
2346 "timers lsa min-arrival (0-600000)",
2347 "Adjust routing timers\n"
2349 "Minimum delay in receiving new version of a LSA\n"
2350 "Delay in milliseconds\n")
2352 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2354 unsigned int minarrival
;
2358 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2362 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2364 ospf
->min_ls_arrival
= minarrival
;
2369 DEFUN (no_ospf_timers_lsa
,
2370 no_ospf_timers_lsa_cmd
,
2371 "no timers lsa min-arrival [(0-600000)]",
2373 "Adjust routing timers\n"
2375 "Minimum delay in receiving new version of a LSA\n"
2376 "Delay in milliseconds\n")
2378 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2379 unsigned int minarrival
;
2383 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2385 if (ospf
->min_ls_arrival
!= minarrival
||
2386 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2390 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2395 DEFUN (ospf_neighbor
,
2397 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2399 "Neighbor IP address\n"
2400 "Neighbor Priority\n"
2402 "Dead Neighbor Polling interval\n"
2405 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2409 struct in_addr nbr_addr
;
2410 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2411 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2413 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2416 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2419 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2421 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2424 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2427 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2432 DEFUN (ospf_neighbor_poll_interval
,
2433 ospf_neighbor_poll_interval_cmd
,
2434 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2436 "Neighbor IP address\n"
2437 "Dead Neighbor Polling interval\n"
2439 "OSPF priority of non-broadcast neighbor\n"
2442 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2446 struct in_addr nbr_addr
;
2447 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2448 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2450 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2452 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2455 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2457 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2458 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2461 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2466 DEFUN (no_ospf_neighbor
,
2467 no_ospf_neighbor_cmd
,
2468 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2471 "Neighbor IP address\n"
2472 "Neighbor Priority\n"
2474 "Dead Neighbor Polling interval\n"
2477 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2479 struct in_addr nbr_addr
;
2481 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2483 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2488 DEFUN (no_ospf_neighbor_poll
,
2489 no_ospf_neighbor_poll_cmd
,
2490 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2493 "Neighbor IP address\n"
2494 "Dead Neighbor Polling interval\n"
2496 "Neighbor Priority\n"
2499 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2501 struct in_addr nbr_addr
;
2503 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2505 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2510 DEFUN (ospf_refresh_timer
,
2511 ospf_refresh_timer_cmd
,
2512 "refresh timer (10-1800)",
2513 "Adjust refresh parameters\n"
2514 "Set refresh timer\n"
2515 "Timer value in seconds\n")
2517 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2519 unsigned int interval
;
2521 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2522 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2524 ospf_timers_refresh_set (ospf
, interval
);
2529 DEFUN (no_ospf_refresh_timer
,
2530 no_ospf_refresh_timer_val_cmd
,
2531 "no refresh timer [(10-1800)]",
2533 "Adjust refresh parameters\n"
2534 "Unset refresh timer\n"
2535 "Timer value in seconds\n")
2537 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2539 unsigned int interval
;
2543 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2545 if (ospf
->lsa_refresh_interval
!= interval
||
2546 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2550 ospf_timers_refresh_unset (ospf
);
2556 DEFUN (ospf_auto_cost_reference_bandwidth
,
2557 ospf_auto_cost_reference_bandwidth_cmd
,
2558 "auto-cost reference-bandwidth (1-4294967)",
2559 "Calculate OSPF interface cost according to bandwidth\n"
2560 "Use reference bandwidth method to assign OSPF cost\n"
2561 "The reference bandwidth in terms of Mbits per second\n")
2563 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2566 struct listnode
*node
;
2567 struct interface
*ifp
;
2569 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2570 if (refbw
< 1 || refbw
> 4294967)
2572 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2576 /* If reference bandwidth is changed. */
2577 if ((refbw
) == ospf
->ref_bandwidth
)
2580 ospf
->ref_bandwidth
= refbw
;
2581 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2582 ospf_if_recalculate_output_cost (ifp
);
2587 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2588 no_ospf_auto_cost_reference_bandwidth_cmd
,
2589 "no auto-cost reference-bandwidth [(1-4294967)]",
2591 "Calculate OSPF interface cost according to bandwidth\n"
2592 "Use reference bandwidth method to assign OSPF cost\n"
2593 "The reference bandwidth in terms of Mbits per second\n")
2595 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2596 struct listnode
*node
, *nnode
;
2597 struct interface
*ifp
;
2599 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2602 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2603 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2604 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2606 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2607 ospf_if_recalculate_output_cost (ifp
);
2612 DEFUN (ospf_write_multiplier
,
2613 ospf_write_multiplier_cmd
,
2614 "ospf write-multiplier (1-100)",
2615 "OSPF specific commands\n"
2616 "Write multiplier\n"
2617 "Maximum number of interface serviced per write\n")
2619 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2621 u_int32_t write_oi_count
;
2628 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2629 if (write_oi_count
< 1 || write_oi_count
> 100)
2631 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2635 ospf
->write_oi_count
= write_oi_count
;
2639 ALIAS (ospf_write_multiplier
,
2640 write_multiplier_cmd
,
2641 "write-multiplier (1-100)",
2642 "Write multiplier\n"
2643 "Maximum number of interface serviced per write\n")
2645 DEFUN (no_ospf_write_multiplier
,
2646 no_ospf_write_multiplier_cmd
,
2647 "no ospf write-multiplier (1-100)",
2649 "OSPF specific commands\n"
2650 "Write multiplier\n"
2651 "Maximum number of interface serviced per write\n")
2653 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2655 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2659 ALIAS (no_ospf_write_multiplier
,
2660 no_write_multiplier_cmd
,
2661 "no write-multiplier (1-100)",
2663 "Write multiplier\n"
2664 "Maximum number of interface serviced per write\n")
2666 const char *ospf_abr_type_descr_str
[] =
2669 "Standard (RFC2328)",
2671 "Alternative Cisco",
2672 "Alternative Shortcut"
2675 const char *ospf_shortcut_mode_descr_str
[] =
2683 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2685 json_object
*json_area
= NULL
;
2688 json_area
= json_object_new_object();
2692 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2694 /* Show Area type/mode. */
2695 if (OSPF_IS_AREA_BACKBONE (area
))
2698 json_object_boolean_true_add(json_area
, "backbone");
2700 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2706 if (area
->external_routing
== OSPF_AREA_STUB
)
2708 if (area
->no_summary
)
2709 json_object_boolean_true_add(json_area
, "stubNoSummary");
2710 if (area
->shortcut_configured
)
2711 json_object_boolean_true_add(json_area
, "stubShortcut");
2713 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2715 if (area
->no_summary
)
2716 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2717 if (area
->shortcut_configured
)
2718 json_object_boolean_true_add(json_area
, "nssaShortcut");
2721 json_object_string_add(json_area
,"shortcuttingMode",
2722 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2723 if (area
->shortcut_capability
)
2724 json_object_boolean_true_add(json_area
,"sBitConcensus");
2728 if (area
->external_routing
== OSPF_AREA_STUB
)
2729 vty_out (vty
, " (Stub%s%s)",
2730 area
->no_summary
? ", no summary" : "",
2731 area
->shortcut_configured
? "; " : "");
2732 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2733 vty_out (vty
, " (NSSA%s%s)",
2734 area
->no_summary
? ", no summary" : "",
2735 area
->shortcut_configured
? "; " : "");
2737 vty_out (vty
, "%s", VTY_NEWLINE
);
2738 vty_out (vty
, " Shortcutting mode: %s",
2739 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2740 vty_out (vty
, ", S-bit consensus: %s%s",
2741 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2745 /* Show number of interfaces */
2748 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2749 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2752 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2753 "Active: %d%s", listcount (area
->oiflist
),
2754 area
->act_ints
, VTY_NEWLINE
);
2756 if (area
->external_routing
== OSPF_AREA_NSSA
)
2760 json_object_boolean_true_add(json_area
, "nssa");
2761 if (! IS_OSPF_ABR (area
->ospf
))
2762 json_object_boolean_false_add(json_area
, "abr");
2763 else if (area
->NSSATranslatorState
)
2765 json_object_boolean_true_add(json_area
, "abr");
2766 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2767 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2768 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2769 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2773 json_object_boolean_true_add(json_area
, "abr");
2774 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2775 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2777 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2782 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2783 if (! IS_OSPF_ABR (area
->ospf
))
2784 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2786 else if (area
->NSSATranslatorState
)
2788 vty_out (vty
, " We are an ABR and ");
2789 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2790 vty_out (vty
, "the NSSA Elected Translator. %s",
2792 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2793 vty_out (vty
, "always an NSSA Translator. %s",
2798 vty_out (vty
, " We are an ABR, but ");
2799 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2800 vty_out (vty
, "not the NSSA Elected Translator. %s",
2803 vty_out (vty
, "never an NSSA Translator. %s",
2809 /* Stub-router state for this area */
2810 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2812 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2816 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2817 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2818 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2819 if (area
->t_stub_router
)
2822 time_store
= monotime_until(&area
->t_stub_router
->u
.sands
, NULL
) / 1000LL;
2823 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2828 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2830 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2831 vty_out (vty
, " Administratively activated (indefinitely)%s",
2833 if (area
->t_stub_router
)
2834 vty_out (vty
, " Active from startup, %s remaining%s",
2835 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2836 sizeof(timebuf
)), VTY_NEWLINE
);
2842 /* Show number of fully adjacent neighbors. */
2843 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2845 /* Show authentication type. */
2846 if (area
->auth_type
== OSPF_AUTH_NULL
)
2847 json_object_string_add(json_area
, "authentication", "authenticationNone");
2848 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2849 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2850 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2851 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2853 if (!OSPF_IS_AREA_BACKBONE (area
))
2854 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2856 /* Show SPF calculation times. */
2857 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2858 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2859 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2860 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2861 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2862 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2863 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2864 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2865 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2866 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2867 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2868 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2872 /* Show number of fully adjacent neighbors. */
2873 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2874 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2876 /* Show authentication type. */
2877 vty_out (vty
, " Area has ");
2878 if (area
->auth_type
== OSPF_AUTH_NULL
)
2879 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2880 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2881 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2882 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2883 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2885 if (!OSPF_IS_AREA_BACKBONE (area
))
2886 vty_out (vty
, " Number of full virtual adjacencies going through"
2887 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2889 /* Show SPF calculation times. */
2890 vty_out (vty
, " SPF algorithm executed %d times%s",
2891 area
->spf_calculation
, VTY_NEWLINE
);
2893 /* Show number of LSA. */
2894 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2895 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2896 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2897 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2898 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2899 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2900 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2901 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2902 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2903 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2904 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2905 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2906 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2907 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2908 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2909 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2914 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2915 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2916 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2917 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2921 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2922 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2923 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2924 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2925 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2926 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2930 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2932 vty_out (vty
, "%s", VTY_NEWLINE
);
2936 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2938 struct listnode
*node
, *nnode
;
2939 struct ospf_area
* area
;
2940 struct timeval result
;
2941 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2942 json_object
*json
= NULL
;
2943 json_object
*json_areas
= NULL
;
2947 json
= json_object_new_object();
2948 json_areas
= json_object_new_object();
2955 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2959 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2960 VTY_NEWLINE
, VTY_NEWLINE
);
2964 /* Show Router ID. */
2967 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2971 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2972 inet_ntoa (ospf
->router_id
),
2976 /* Graceful shutdown */
2977 if (ospf
->t_deferred_shutdown
)
2982 time_store
= monotime_until(&ospf
->t_deferred_shutdown
->u
.sands
, NULL
) / 1000LL;
2983 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2987 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2988 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2989 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2993 /* Show capability. */
2996 json_object_boolean_true_add(json
, "tosRoutesOnly");
2997 json_object_boolean_true_add(json
, "rfc2328Conform");
2998 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3000 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3005 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3006 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3007 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3008 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3009 "enabled" : "disabled", VTY_NEWLINE
);
3014 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3016 json_object_boolean_true_add(json
, "opaqueCapable");
3021 vty_out (vty
, " OpaqueCapability flag is %s%s",
3022 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3026 /* Show stub-router configuration */
3027 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3028 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3032 json_object_boolean_true_add(json
, "stubAdvertisement");
3033 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3034 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3035 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3036 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3040 vty_out (vty
, " Stub router advertisement is configured%s",
3042 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3043 vty_out (vty
, " Enabled for %us after start-up%s",
3044 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3045 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3046 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3047 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3051 /* Show SPF timers. */
3054 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3055 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3056 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3057 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3061 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3062 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3063 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3064 " Hold time multiplier is currently %d%s",
3065 ospf
->spf_delay
, VTY_NEWLINE
,
3066 ospf
->spf_holdtime
, VTY_NEWLINE
,
3067 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3068 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3073 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3075 long time_store
= 0;
3077 time_store
= monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3078 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3080 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3081 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3084 json_object_boolean_true_add(json
, "spfHasNotRun");
3088 vty_out (vty
, " SPF algorithm ");
3089 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3091 monotime_since(&ospf
->ts_spf
, &result
);
3092 vty_out (vty
, "last executed %s ago%s",
3093 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3095 vty_out (vty
, " Last SPF duration %s%s",
3096 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3100 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3105 if (ospf
->t_spf_calc
)
3108 time_store
= monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
) / 1000LL;
3109 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3112 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3113 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3114 /* Show write multiplier values */
3115 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3116 /* Show refresh parameters. */
3117 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3121 vty_out (vty
, " SPF timer %s%s%s",
3122 (ospf
->t_spf_calc
? "due in " : "is "),
3123 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3126 vty_out (vty
, " LSA minimum interval %d msecs%s",
3127 ospf
->min_ls_interval
, VTY_NEWLINE
);
3128 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3129 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3131 /* Show write multiplier values */
3132 vty_out (vty
, " Write Multiplier set to %d %s",
3133 ospf
->write_oi_count
, VTY_NEWLINE
);
3135 /* Show refresh parameters. */
3136 vty_out (vty
, " Refresh timer %d secs%s",
3137 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3140 /* Show ABR/ASBR flags. */
3141 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3144 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3146 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3147 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3149 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3152 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3154 vty_out (vty
, " This router is an ASBR "
3155 "(injecting external routing information)%s", VTY_NEWLINE
);
3158 /* Show Number of AS-external-LSAs. */
3161 json_object_int_add(json
, "lsaExternalCounter",
3162 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3163 json_object_int_add(json
, "lsaExternalChecksum",
3164 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3168 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3169 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3170 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3175 json_object_int_add(json
, "lsaAsopaqueCounter",
3176 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3177 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3178 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3182 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3183 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3184 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3187 /* Show number of areas attached. */
3189 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3191 vty_out (vty
, " Number of areas attached to this router: %d%s",
3192 listcount (ospf
->areas
), VTY_NEWLINE
);
3194 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3196 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3199 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3201 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3206 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3208 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3211 /* Show each area status. */
3212 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3213 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3217 json_object_object_add(json
, "areas", json_areas
);
3218 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3219 json_object_free(json
);
3222 vty_out (vty
, "%s",VTY_NEWLINE
);
3227 DEFUN (show_ip_ospf
,
3229 "show ip ospf [json]",
3232 "OSPF information\n"
3236 u_char uj
= use_json(argc
, argv
);
3238 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3241 return (show_ip_ospf_common(vty
, ospf
, uj
));
3244 DEFUN (show_ip_ospf_instance
,
3245 show_ip_ospf_instance_cmd
,
3246 "show ip ospf (1-65535) [json]",
3249 "OSPF information\n"
3255 u_short instance
= 0;
3256 u_char uj
= use_json(argc
, argv
);
3258 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3259 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3262 return (show_ip_ospf_common(vty
, ospf
, uj
));
3266 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3267 json_object
*json_interface_sub
, u_char use_json
)
3270 struct ospf_neighbor
*nbr
;
3271 struct route_node
*rn
;
3273 /* Is interface up? */
3276 is_up
= if_is_operative(ifp
);
3278 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3280 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3282 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3283 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3284 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3285 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3289 vty_out (vty
, "%s is %s%s", ifp
->name
,
3290 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3291 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3292 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3296 /* Is interface OSPF enabled? */
3299 if (ospf_oi_count(ifp
) == 0)
3301 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3306 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3310 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3314 if (ospf_oi_count(ifp
) == 0)
3316 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3321 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3327 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3329 struct ospf_interface
*oi
= rn
->info
;
3334 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3337 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3339 vty_out (vty
, " This interface is UNNUMBERED,");
3343 /* Show OSPF interface information. */
3346 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3347 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3350 vty_out (vty
, " Internet Address %s/%d,",
3351 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3353 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3355 struct in_addr
*dest
;
3358 if (CONNECTED_PEER(oi
->connected
)
3359 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3364 /* For Vlinks, showing the peer address is probably more
3365 * * * * * informative than the local interface that is being used
3367 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3368 dest
= &oi
->vl_data
->peer_addr
;
3370 dest
= &oi
->connected
->destination
->u
.prefix4
;
3374 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3375 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3376 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3378 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3381 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3386 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3387 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3388 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3389 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3390 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3391 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3392 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3393 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3394 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3398 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3401 vty_out (vty
, " MTU mismatch detection:%s%s",
3402 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3404 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3405 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3406 oi
->output_cost
, VTY_NEWLINE
);
3408 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3409 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3410 PRIORITY (oi
), VTY_NEWLINE
);
3413 /* Show DR information. */
3414 if (DR (oi
).s_addr
== 0)
3417 vty_out (vty
, " No backup designated router on this network%s",
3422 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3426 vty_out (vty
, " No backup designated router on this network%s",
3433 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3434 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3438 vty_out (vty
, " Backup Designated Router (ID) %s,",
3439 inet_ntoa (nbr
->router_id
));
3440 vty_out (vty
, " Interface Address %s%s",
3441 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3446 /* Next network-LSA sequence number we'll use, if we're elected DR */
3447 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3450 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3452 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3453 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3458 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3459 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3461 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3462 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3463 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3464 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3469 vty_out (vty
, " Multicast group memberships:");
3470 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3471 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3473 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3474 vty_out (vty
, " OSPFAllRouters");
3475 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3476 vty_out (vty
, " OSPFDesignatedRouters");
3479 vty_out (vty
, " <None>");
3480 vty_out (vty
, "%s", VTY_NEWLINE
);
3485 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3486 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3488 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3489 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3490 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3491 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3495 vty_out (vty
, " Timer intervals configured,");
3496 vty_out (vty
, " Hello ");
3497 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3498 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3500 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3501 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3502 OSPF_IF_PARAM (oi
, v_wait
),
3503 OSPF_IF_PARAM (oi
, v_wait
),
3504 OSPF_IF_PARAM (oi
, retransmit_interval
),
3508 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3510 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3513 long time_store
= 0;
3515 time_store
= monotime_until(&oi
->t_hello
->u
.sands
, NULL
) / 1000LL;
3516 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3519 vty_out (vty
, " Hello due in %s%s",
3520 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3523 else /* passive-interface is set */
3526 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3528 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3533 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3534 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3537 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3538 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3540 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3545 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3546 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3548 struct interface
*ifp
;
3549 struct listnode
*node
;
3550 json_object
*json
= NULL
;
3551 json_object
*json_interface_sub
= NULL
;
3555 json
= json_object_new_object();
3556 json_interface_sub
= json_object_new_object();
3562 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3564 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3565 VTY_NEWLINE
, VTY_NEWLINE
);
3568 if (argc
== iface_argv
)
3570 /* Show All Interfaces.*/
3571 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3573 if (ospf_oi_count(ifp
))
3575 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3577 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3583 /* Interface name is specified. */
3584 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
, VRF_DEFAULT
)) == NULL
)
3587 json_object_boolean_true_add(json
, "noSuchIface");
3589 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3593 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3595 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3601 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3602 json_object_free(json
);
3605 vty_out (vty
, "%s", VTY_NEWLINE
);
3610 DEFUN (show_ip_ospf_interface
,
3611 show_ip_ospf_interface_cmd
,
3612 "show ip ospf interface [INTERFACE] [json]",
3615 "OSPF information\n"
3616 "Interface information\n"
3621 u_char uj
= use_json(argc
, argv
);
3623 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3629 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3632 DEFUN (show_ip_ospf_instance_interface
,
3633 show_ip_ospf_instance_interface_cmd
,
3634 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3637 "OSPF information\n"
3639 "Interface information\n"
3645 u_short instance
= 0;
3646 u_char uj
= use_json(argc
, argv
);
3648 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3649 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3655 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3659 show_ip_ospf_neighbour_header (struct vty
*vty
)
3661 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3663 "Neighbor ID", "Pri", "State", "Dead Time",
3664 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3669 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3671 struct route_node
*rn
;
3672 struct ospf_neighbor
*nbr
;
3674 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3675 json_object
*json_neighbor
= NULL
;
3677 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3679 if ((nbr
= rn
->info
))
3681 /* Do not show myself. */
3682 if (nbr
!= oi
->nbr_self
)
3684 /* Down state is not shown. */
3685 if (nbr
->state
!= NSM_Down
)
3689 json_neighbor
= json_object_new_object();
3690 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3694 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
3696 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3697 json_object_string_add (json_neighbor
, "state", msgbuf
);
3698 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3699 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3700 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3701 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3702 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3703 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3704 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3705 json_object_object_add(json
, "neighbor", json_neighbor
);
3707 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3711 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3713 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3714 vty_out (vty
, "%-15s %3d %-15s ",
3718 vty_out (vty
, "%-15s %3d %-15s ",
3719 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3722 vty_out (vty
, "%9s ",
3723 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3725 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3726 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3727 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3728 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3738 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3740 struct ospf_interface
*oi
;
3741 struct listnode
*node
;
3742 json_object
*json
= NULL
;
3745 json
= json_object_new_object();
3747 show_ip_ospf_neighbour_header (vty
);
3752 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3754 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3755 VTY_NEWLINE
, VTY_NEWLINE
);
3758 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3759 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3763 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3764 json_object_free(json
);
3767 vty_out (vty
, "%s", VTY_NEWLINE
);
3772 DEFUN (show_ip_ospf_neighbor
,
3773 show_ip_ospf_neighbor_cmd
,
3774 "show ip ospf neighbor [json]",
3777 "OSPF information\n"
3782 u_char uj
= use_json(argc
, argv
);
3784 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3787 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3791 DEFUN (show_ip_ospf_instance_neighbor
,
3792 show_ip_ospf_instance_neighbor_cmd
,
3793 "show ip ospf (1-65535) neighbor [json]",
3796 "OSPF information\n"
3803 u_short instance
= 0;
3804 u_char uj
= use_json(argc
, argv
);
3806 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3807 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3810 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3814 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3816 struct listnode
*node
;
3817 struct ospf_interface
*oi
;
3818 json_object
*json
= NULL
;
3819 json_object
*json_neighbor_sub
= NULL
;
3823 json
= json_object_new_object();
3824 json_neighbor_sub
= json_object_new_object();
3827 show_ip_ospf_neighbour_header (vty
);
3832 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3834 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3835 VTY_NEWLINE
, VTY_NEWLINE
);
3838 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3840 struct listnode
*nbr_node
;
3841 struct ospf_nbr_nbma
*nbr_nbma
;
3843 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3845 /* print Down neighbor status */
3846 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3848 if (nbr_nbma
->nbr
== NULL
3849 || nbr_nbma
->nbr
->state
== NSM_Down
)
3853 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3854 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3855 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3856 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3857 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3858 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3859 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3863 vty_out (vty
, "%-15s %3d %-15s %9s ",
3864 "-", nbr_nbma
->priority
, "Down", "-");
3865 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3866 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3867 0, 0, 0, VTY_NEWLINE
);
3875 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3876 json_object_free(json
);
3879 vty_out (vty
, "%s", VTY_NEWLINE
);
3884 DEFUN (show_ip_ospf_neighbor_all
,
3885 show_ip_ospf_neighbor_all_cmd
,
3886 "show ip ospf neighbor all [json]",
3889 "OSPF information\n"
3891 "include down status neighbor\n"
3895 u_char uj
= use_json(argc
, argv
);
3897 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3900 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3903 DEFUN (show_ip_ospf_instance_neighbor_all
,
3904 show_ip_ospf_instance_neighbor_all_cmd
,
3905 "show ip ospf (1-65535) neighbor all [json]",
3908 "OSPF information\n"
3911 "include down status neighbor\n"
3916 u_short instance
= 0;
3917 u_char uj
= use_json(argc
, argv
);
3919 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3920 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3923 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3927 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3928 struct cmd_token
**argv
, u_char use_json
)
3930 struct interface
*ifp
;
3931 struct route_node
*rn
;
3932 json_object
*json
= NULL
;
3935 json
= json_object_new_object();
3937 show_ip_ospf_neighbour_header (vty
);
3942 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3944 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3945 VTY_NEWLINE
, VTY_NEWLINE
);
3948 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
3952 json_object_boolean_true_add(json
, "noSuchIface");
3954 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3958 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3960 struct ospf_interface
*oi
= rn
->info
;
3965 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3970 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3971 json_object_free(json
);
3974 vty_out (vty
, "%s", VTY_NEWLINE
);
3979 DEFUN (show_ip_ospf_neighbor_int
,
3980 show_ip_ospf_neighbor_int_cmd
,
3981 "show ip ospf neighbor IFNAME [json]",
3984 "OSPF information\n"
3990 u_char uj
= use_json(argc
, argv
);
3992 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3995 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
3998 DEFUN (show_ip_ospf_instance_neighbor_int
,
3999 show_ip_ospf_instance_neighbor_int_cmd
,
4000 "show ip ospf (1-65535) neighbor IFNAME [json]",
4003 "OSPF information\n"
4011 u_short instance
= 0;
4012 u_char uj
= use_json(argc
, argv
);
4014 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4015 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4018 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4022 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4023 u_char use_json
, json_object
*json
)
4025 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4026 json_object
*json_sub
= NULL
;
4029 json_sub
= json_object_new_object();
4030 else /* Show neighbor ID. */
4031 vty_out (vty
, " Neighbor %s,", "-");
4033 /* Show interface address. */
4035 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4037 vty_out (vty
, " interface address %s%s",
4038 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4043 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4044 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4047 vty_out (vty
, " In the area %s via interface %s%s",
4048 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4050 /* Show neighbor priority and state. */
4053 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4054 json_object_string_add(json_sub
, "nbrState", "down");
4057 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4058 nbr_nbma
->priority
, "Down");
4060 /* Show state changes. */
4062 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4064 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4066 /* Show PollInterval */
4068 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4070 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4072 /* Show poll-interval timer. */
4076 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
) / 1000LL;
4077 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4080 vty_out (vty
, " Poll timer due in %s%s",
4081 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4084 /* Show poll-interval timer thread. */
4087 if (nbr_nbma
->t_poll
!= NULL
)
4088 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4091 vty_out (vty
, " Thread Poll Timer %s%s",
4092 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4095 json_object_object_add(json
, "noNbrId", json_sub
);
4099 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4100 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4102 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4103 json_object
*json_sub
= NULL
;
4106 json_sub
= json_object_new_object();
4109 /* Show neighbor ID. */
4110 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4111 vty_out (vty
, " Neighbor %s,", "-");
4113 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4116 /* Show interface address. */
4118 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4120 vty_out (vty
, " interface address %s%s",
4121 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4126 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4127 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4130 vty_out (vty
, " In the area %s via interface %s%s",
4131 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4133 /* Show neighbor priority and state. */
4136 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4137 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4140 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4141 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4143 /* Show state changes. */
4145 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4147 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4149 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4154 time_store
= monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4157 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4161 vty_out (vty
, " Most recent state change statistics:%s",
4163 vty_out (vty
, " Progressive change %s ago%s",
4164 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4169 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4174 time_store
= monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4177 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4178 if (nbr
->last_regress_str
)
4179 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4183 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4184 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4185 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4190 /* Show Designated Rotuer ID. */
4192 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4194 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4196 /* Show Backup Designated Rotuer ID. */
4198 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4200 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4205 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4206 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4209 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4210 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4212 /* Show Router Dead interval timer. */
4215 if (nbr
->t_inactivity
)
4218 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
4219 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4222 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4225 vty_out (vty
, " Dead timer due in %s%s",
4226 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4229 /* Show Database Summary list. */
4231 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4233 vty_out (vty
, " Database Summary List %d%s",
4234 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4236 /* Show Link State Request list. */
4238 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4240 vty_out (vty
, " Link State Request List %ld%s",
4241 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4243 /* Show Link State Retransmission list. */
4245 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4247 vty_out (vty
, " Link State Retransmission List %ld%s",
4248 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4250 /* Show inactivity timer thread. */
4253 if (nbr
->t_inactivity
!= NULL
)
4254 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4257 vty_out (vty
, " Thread Inactivity Timer %s%s",
4258 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4260 /* Show Database Description retransmission thread. */
4263 if (nbr
->t_db_desc
!= NULL
)
4264 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4267 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4268 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4270 /* Show Link State Request Retransmission thread. */
4273 if (nbr
->t_ls_req
!= NULL
)
4274 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4277 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4278 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4280 /* Show Link State Update Retransmission thread. */
4283 if (nbr
->t_ls_upd
!= NULL
)
4284 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4287 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4288 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4292 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4293 json_object_object_add(json
, "noNbrId", json_sub
);
4295 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4298 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4302 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4303 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4305 struct listnode
*node
;
4306 struct ospf_neighbor
*nbr
;
4307 struct ospf_interface
*oi
;
4308 struct in_addr router_id
;
4310 json_object
*json
= NULL
;
4313 json
= json_object_new_object();
4318 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4320 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4321 VTY_NEWLINE
, VTY_NEWLINE
);
4324 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4328 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4332 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4334 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4336 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4342 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4343 json_object_free(json
);
4346 vty_out (vty
, "%s", VTY_NEWLINE
);
4351 DEFUN (show_ip_ospf_neighbor_id
,
4352 show_ip_ospf_neighbor_id_cmd
,
4353 "show ip ospf neighbor A.B.C.D [json]",
4356 "OSPF information\n"
4362 u_char uj
= use_json(argc
, argv
);
4364 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4367 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4370 DEFUN (show_ip_ospf_instance_neighbor_id
,
4371 show_ip_ospf_instance_neighbor_id_cmd
,
4372 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4375 "OSPF information\n"
4383 u_short instance
= 0;
4384 u_char uj
= use_json(argc
, argv
);
4386 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4387 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4390 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4394 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4396 struct ospf_interface
*oi
;
4397 struct listnode
*node
;
4398 json_object
*json
= NULL
;
4401 json
= json_object_new_object();
4406 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4408 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4409 VTY_NEWLINE
, VTY_NEWLINE
);
4412 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4414 struct route_node
*rn
;
4415 struct ospf_neighbor
*nbr
;
4417 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4419 if ((nbr
= rn
->info
))
4421 if (nbr
!= oi
->nbr_self
)
4423 if (nbr
->state
!= NSM_Down
)
4425 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4434 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4435 json_object_free(json
);
4438 vty_out (vty
, "%s", VTY_NEWLINE
);
4443 DEFUN (show_ip_ospf_neighbor_detail
,
4444 show_ip_ospf_neighbor_detail_cmd
,
4445 "show ip ospf neighbor detail [json]",
4448 "OSPF information\n"
4450 "detail of all neighbors\n"
4454 u_char uj
= use_json(argc
, argv
);
4456 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4459 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4462 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4463 show_ip_ospf_instance_neighbor_detail_cmd
,
4464 "show ip ospf (1-65535) neighbor detail [json]",
4467 "OSPF information\n"
4470 "detail of all neighbors\n"
4475 u_short instance
= 0;
4476 u_char uj
= use_json(argc
, argv
);
4478 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4479 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4482 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4486 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4488 struct listnode
*node
;
4489 struct ospf_interface
*oi
;
4490 json_object
*json
= NULL
;
4493 json
= json_object_new_object();
4498 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4500 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4501 VTY_NEWLINE
, VTY_NEWLINE
);
4504 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4506 struct route_node
*rn
;
4507 struct ospf_neighbor
*nbr
;
4508 struct ospf_nbr_nbma
*nbr_nbma
;
4510 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4511 if ((nbr
= rn
->info
))
4512 if (nbr
!= oi
->nbr_self
)
4513 if (nbr
->state
!= NSM_Down
)
4514 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4516 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4518 struct listnode
*nd
;
4520 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4522 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4523 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4530 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4531 json_object_free(json
);
4535 vty_out (vty
, "%s", VTY_NEWLINE
);
4541 DEFUN (show_ip_ospf_neighbor_detail_all
,
4542 show_ip_ospf_neighbor_detail_all_cmd
,
4543 "show ip ospf neighbor detail all [json]",
4546 "OSPF information\n"
4548 "detail of all neighbors\n"
4549 "include down status neighbor\n"
4553 u_char uj
= use_json(argc
, argv
);
4555 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4558 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4561 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4562 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4563 "show ip ospf (1-65535) neighbor detail all [json]",
4566 "OSPF information\n"
4569 "detail of all neighbors\n"
4570 "include down status neighbor\n"
4575 u_short instance
= 0;
4576 u_char uj
= use_json(argc
, argv
);
4578 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4579 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4582 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4586 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4587 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4589 struct ospf_interface
*oi
;
4590 struct interface
*ifp
;
4591 struct route_node
*rn
, *nrn
;
4592 struct ospf_neighbor
*nbr
;
4593 json_object
*json
= NULL
;
4596 json
= json_object_new_object();
4601 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4603 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4604 VTY_NEWLINE
, VTY_NEWLINE
);
4607 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
4611 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4615 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4617 if ((oi
= rn
->info
))
4619 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4621 if ((nbr
= nrn
->info
))
4623 if (nbr
!= oi
->nbr_self
)
4625 if (nbr
->state
!= NSM_Down
)
4626 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4635 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4636 json_object_free(json
);
4639 vty_out (vty
, "%s", VTY_NEWLINE
);
4644 DEFUN (show_ip_ospf_neighbor_int_detail
,
4645 show_ip_ospf_neighbor_int_detail_cmd
,
4646 "show ip ospf neighbor IFNAME detail [json]",
4649 "OSPF information\n"
4652 "detail of all neighbors\n"
4656 u_char uj
= use_json(argc
, argv
);
4658 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4661 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4664 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4665 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4666 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4669 "OSPF information\n"
4673 "detail of all neighbors\n"
4678 u_short instance
= 0;
4679 u_char uj
= use_json(argc
, argv
);
4681 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4682 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4685 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4688 /* Show functions */
4690 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4692 struct router_lsa
*rl
;
4693 struct summary_lsa
*sl
;
4694 struct as_external_lsa
*asel
;
4695 struct prefix_ipv4 p
;
4698 /* If self option is set, check LSA self flag. */
4699 if (self
== 0 || IS_LSA_SELF (lsa
))
4701 /* LSA common part show. */
4702 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4703 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4704 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4705 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4706 /* LSA specific part show. */
4707 switch (lsa
->data
->type
)
4709 case OSPF_ROUTER_LSA
:
4710 rl
= (struct router_lsa
*) lsa
->data
;
4711 vty_out (vty
, " %-d", ntohs (rl
->links
));
4713 case OSPF_SUMMARY_LSA
:
4714 sl
= (struct summary_lsa
*) lsa
->data
;
4717 p
.prefix
= sl
->header
.id
;
4718 p
.prefixlen
= ip_masklen (sl
->mask
);
4719 apply_mask_ipv4 (&p
);
4721 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4723 case OSPF_AS_EXTERNAL_LSA
:
4724 case OSPF_AS_NSSA_LSA
:
4725 asel
= (struct as_external_lsa
*) lsa
->data
;
4728 p
.prefix
= asel
->header
.id
;
4729 p
.prefixlen
= ip_masklen (asel
->mask
);
4730 apply_mask_ipv4 (&p
);
4732 vty_out (vty
, " %s %s/%d [0x%lx]",
4733 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4734 inet_ntoa (p
.prefix
), p
.prefixlen
,
4735 (u_long
)ntohl (asel
->e
[0].route_tag
));
4737 case OSPF_NETWORK_LSA
:
4738 case OSPF_ASBR_SUMMARY_LSA
:
4739 case OSPF_OPAQUE_LINK_LSA
:
4740 case OSPF_OPAQUE_AREA_LSA
:
4741 case OSPF_OPAQUE_AS_LSA
:
4745 vty_out (vty
, VTY_NEWLINE
);
4751 static const char *show_database_desc
[] =
4754 "Router Link States",
4756 "Summary Link States",
4757 "ASBR-Summary Link States",
4758 "AS External Link States",
4759 "Group Membership LSA",
4760 "NSSA-external Link States",
4762 "Link-Local Opaque-LSA",
4763 "Area-Local Opaque-LSA",
4764 "AS-external Opaque-LSA",
4767 static const char *show_database_header
[] =
4770 "Link ID ADV Router Age Seq# CkSum Link count",
4771 "Link ID ADV Router Age Seq# CkSum",
4772 "Link ID ADV Router Age Seq# CkSum Route",
4773 "Link ID ADV Router Age Seq# CkSum",
4774 "Link ID ADV Router Age Seq# CkSum Route",
4775 " --- header for Group Member ----",
4776 "Link ID ADV Router Age Seq# CkSum Route",
4778 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4779 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4780 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4784 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4786 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4788 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4789 vty_out (vty
, " Options: 0x%-2x : %s%s",
4791 ospf_options_dump(lsa
->data
->options
),
4793 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4795 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4798 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4800 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4803 vty_out (vty
, " :%s%s%s%s",
4804 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4805 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4806 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4807 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4809 vty_out (vty
, "%s", VTY_NEWLINE
);
4811 vty_out (vty
, " LS Type: %s%s",
4812 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4813 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4814 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4815 vty_out (vty
, " Advertising Router: %s%s",
4816 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4817 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4819 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4821 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4824 const char *link_type_desc
[] =
4827 "another Router (point-to-point)",
4828 "a Transit Network",
4833 const char *link_id_desc
[] =
4836 "Neighboring Router ID",
4837 "Designated Router address",
4839 "Neighboring Router ID",
4842 const char *link_data_desc
[] =
4845 "Router Interface address",
4846 "Router Interface address",
4848 "Router Interface address",
4851 /* Show router-LSA each Link information. */
4853 show_ip_ospf_database_router_links (struct vty
*vty
,
4854 struct router_lsa
*rl
)
4859 len
= ntohs (rl
->header
.length
) - 4;
4860 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4862 type
= rl
->link
[i
].type
;
4864 vty_out (vty
, " Link connected to: %s%s",
4865 link_type_desc
[type
], VTY_NEWLINE
);
4866 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4867 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4868 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4869 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4870 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4871 vty_out (vty
, " TOS 0 Metric: %d%s",
4872 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4873 vty_out (vty
, "%s", VTY_NEWLINE
);
4877 /* Show router-LSA detail information. */
4879 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4883 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4885 show_ip_ospf_database_header (vty
, lsa
);
4887 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4888 VTY_NEWLINE
, VTY_NEWLINE
);
4890 show_ip_ospf_database_router_links (vty
, rl
);
4891 vty_out (vty
, "%s", VTY_NEWLINE
);
4897 /* Show network-LSA detail information. */
4899 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4905 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4907 show_ip_ospf_database_header (vty
, lsa
);
4909 vty_out (vty
, " Network Mask: /%d%s",
4910 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4912 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4914 for (i
= 0; length
> 0; i
++, length
-= 4)
4915 vty_out (vty
, " Attached Router: %s%s",
4916 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4918 vty_out (vty
, "%s", VTY_NEWLINE
);
4924 /* Show summary-LSA detail information. */
4926 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4930 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4932 show_ip_ospf_database_header (vty
, lsa
);
4934 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4936 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4938 vty_out (vty
, "%s", VTY_NEWLINE
);
4944 /* Show summary-ASBR-LSA detail information. */
4946 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4950 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4952 show_ip_ospf_database_header (vty
, lsa
);
4954 vty_out (vty
, " Network Mask: /%d%s",
4955 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4956 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4958 vty_out (vty
, "%s", VTY_NEWLINE
);
4964 /* Show AS-external-LSA detail information. */
4966 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4970 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4972 show_ip_ospf_database_header (vty
, lsa
);
4974 vty_out (vty
, " Network Mask: /%d%s",
4975 ip_masklen (al
->mask
), VTY_NEWLINE
);
4976 vty_out (vty
, " Metric Type: %s%s",
4977 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4978 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4979 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4980 vty_out (vty
, " Metric: %d%s",
4981 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4982 vty_out (vty
, " Forward Address: %s%s",
4983 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4985 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4986 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
4993 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
4995 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4997 /* show_ip_ospf_database_header (vty, lsa); */
4999 zlog_debug( " Network Mask: /%d%s",
5000 ip_masklen (al
->mask
), "\n");
5001 zlog_debug( " Metric Type: %s%s",
5002 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5003 "2 (Larger than any link state path)" : "1", "\n");
5004 zlog_debug( " TOS: 0%s", "\n");
5005 zlog_debug( " Metric: %d%s",
5006 GET_METRIC (al
->e
[0].metric
), "\n");
5007 zlog_debug( " Forward Address: %s%s",
5008 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5010 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5011 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5016 /* Show AS-NSSA-LSA detail information. */
5018 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5022 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5024 show_ip_ospf_database_header (vty
, lsa
);
5026 vty_out (vty
, " Network Mask: /%d%s",
5027 ip_masklen (al
->mask
), VTY_NEWLINE
);
5028 vty_out (vty
, " Metric Type: %s%s",
5029 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5030 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5031 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5032 vty_out (vty
, " Metric: %d%s",
5033 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5034 vty_out (vty
, " NSSA: Forward Address: %s%s",
5035 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5037 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5038 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5045 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5051 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5055 show_ip_ospf_database_header (vty
, lsa
);
5056 show_opaque_info_detail (vty
, lsa
);
5058 vty_out (vty
, "%s", VTY_NEWLINE
);
5063 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5066 show_router_lsa_detail
,
5067 show_network_lsa_detail
,
5068 show_summary_lsa_detail
,
5069 show_summary_asbr_lsa_detail
,
5070 show_as_external_lsa_detail
,
5072 show_as_nssa_lsa_detail
, /* almost same as external */
5074 show_opaque_lsa_detail
,
5075 show_opaque_lsa_detail
,
5076 show_opaque_lsa_detail
,
5080 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5081 struct in_addr
*adv_router
)
5083 memset (lp
, 0, sizeof (struct prefix_ls
));
5087 else if (adv_router
== NULL
)
5096 lp
->adv_router
= *adv_router
;
5101 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5102 struct in_addr
*id
, struct in_addr
*adv_router
)
5104 struct prefix_ls lp
;
5105 struct route_node
*rn
, *start
;
5106 struct ospf_lsa
*lsa
;
5108 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5109 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5112 route_lock_node (start
);
5113 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5114 if ((lsa
= rn
->info
))
5116 if (show_function
[lsa
->data
->type
] != NULL
)
5117 show_function
[lsa
->data
->type
] (vty
, lsa
);
5119 route_unlock_node (start
);
5123 /* Show detail LSA information
5124 -- if id is NULL then show all LSAs. */
5126 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5127 struct in_addr
*id
, struct in_addr
*adv_router
)
5129 struct listnode
*node
;
5130 struct ospf_area
*area
;
5134 case OSPF_AS_EXTERNAL_LSA
:
5135 case OSPF_OPAQUE_AS_LSA
:
5136 vty_out (vty
, " %s %s%s",
5137 show_database_desc
[type
],
5138 VTY_NEWLINE
, VTY_NEWLINE
);
5139 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5142 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5144 vty_out (vty
, "%s %s (Area %s)%s%s",
5145 VTY_NEWLINE
, show_database_desc
[type
],
5146 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5147 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5154 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5155 struct in_addr
*adv_router
)
5157 struct route_node
*rn
;
5158 struct ospf_lsa
*lsa
;
5160 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5161 if ((lsa
= rn
->info
))
5162 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5164 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5166 if (show_function
[lsa
->data
->type
] != NULL
)
5167 show_function
[lsa
->data
->type
] (vty
, lsa
);
5171 /* Show detail LSA information. */
5173 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5174 struct in_addr
*adv_router
)
5176 struct listnode
*node
;
5177 struct ospf_area
*area
;
5181 case OSPF_AS_EXTERNAL_LSA
:
5182 case OSPF_OPAQUE_AS_LSA
:
5183 vty_out (vty
, " %s %s%s",
5184 show_database_desc
[type
],
5185 VTY_NEWLINE
, VTY_NEWLINE
);
5186 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5190 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5192 vty_out (vty
, "%s %s (Area %s)%s%s",
5193 VTY_NEWLINE
, show_database_desc
[type
],
5194 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5195 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5203 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5205 struct ospf_lsa
*lsa
;
5206 struct route_node
*rn
;
5207 struct ospf_area
*area
;
5208 struct listnode
*node
;
5211 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5213 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5217 case OSPF_AS_EXTERNAL_LSA
:
5218 case OSPF_OPAQUE_AS_LSA
:
5223 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5224 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5226 vty_out (vty
, " %s (Area %s)%s%s",
5227 show_database_desc
[type
],
5228 ospf_area_desc_string (area
),
5229 VTY_NEWLINE
, VTY_NEWLINE
);
5230 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5232 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5233 show_lsa_summary (vty
, lsa
, self
);
5235 vty_out (vty
, "%s", VTY_NEWLINE
);
5240 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5244 case OSPF_AS_EXTERNAL_LSA
:
5245 case OSPF_OPAQUE_AS_LSA
:
5250 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5251 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5253 vty_out (vty
, " %s%s%s",
5254 show_database_desc
[type
],
5255 VTY_NEWLINE
, VTY_NEWLINE
);
5256 vty_out (vty
, "%s%s", show_database_header
[type
],
5259 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5260 show_lsa_summary (vty
, lsa
, self
);
5262 vty_out (vty
, "%s", VTY_NEWLINE
);
5266 vty_out (vty
, "%s", VTY_NEWLINE
);
5270 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5272 struct route_node
*rn
;
5274 vty_out (vty
, "%s MaxAge Link States:%s%s",
5275 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5277 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5279 struct ospf_lsa
*lsa
;
5281 if ((lsa
= rn
->info
) != NULL
)
5283 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5284 vty_out (vty
, "Link State ID: %s%s",
5285 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5286 vty_out (vty
, "Advertising Router: %s%s",
5287 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5288 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5289 vty_out (vty
, "%s", VTY_NEWLINE
);
5294 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5295 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5297 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5298 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5299 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5300 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5302 #define OSPF_LSA_TYPES_DESC \
5303 "ASBR summary link states\n" \
5304 "External link states\n" \
5305 "Network link states\n" \
5306 "Router link states\n" \
5307 "Network summary link states\n" \
5308 OSPF_LSA_TYPE_NSSA_DESC \
5309 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5310 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5311 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5314 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5315 int arg_base
, int argc
, struct cmd_token
**argv
)
5319 struct in_addr id
, adv_router
;
5322 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5325 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5326 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5329 if (argc
== arg_base
+ 4)
5331 show_ip_ospf_database_summary (vty
, ospf
, 0);
5335 /* Set database type to show. */
5336 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5337 type
= OSPF_ROUTER_LSA
;
5338 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5339 type
= OSPF_NETWORK_LSA
;
5340 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5341 type
= OSPF_AS_NSSA_LSA
;
5342 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5343 type
= OSPF_SUMMARY_LSA
;
5344 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5345 type
= OSPF_ASBR_SUMMARY_LSA
;
5346 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5347 type
= OSPF_AS_EXTERNAL_LSA
;
5348 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5350 show_ip_ospf_database_summary (vty
, ospf
, 1);
5353 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5355 show_ip_ospf_database_maxage (vty
, ospf
);
5358 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5359 type
= OSPF_OPAQUE_LINK_LSA
;
5360 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5361 type
= OSPF_OPAQUE_AREA_LSA
;
5362 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5363 type
= OSPF_OPAQUE_AS_LSA
;
5367 /* `show ip ospf database LSA'. */
5368 if (argc
== arg_base
+ 5)
5369 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5370 else if (argc
>= arg_base
+ 6)
5372 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5376 /* `show ip ospf database LSA ID'. */
5377 if (argc
== arg_base
+ 6)
5378 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5379 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5380 else if (argc
== arg_base
+ 7)
5382 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5383 adv_router
= ospf
->router_id
;
5386 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5390 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5397 DEFUN (show_ip_ospf_database_max
,
5398 show_ip_ospf_database_max_cmd
,
5399 "show ip ospf database <max-age|self-originate>",
5402 "OSPF information\n"
5403 "Database summary\n"
5404 "LSAs in MaxAge list\n"
5405 "Self-originated link states\n")
5409 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5412 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5415 DEFUN (show_ip_ospf_instance_database
,
5416 show_ip_ospf_instance_database_cmd
,
5417 "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>]]]",
5420 "OSPF information\n"
5422 "Database summary\n"
5424 "Link State ID (as an IP address)\n"
5425 "Self-originated link states\n"
5426 "Advertising Router link states\n"
5427 "Advertising Router (as an IP address)\n")
5430 u_short instance
= 0;
5433 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5435 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5436 ospf
= ospf_lookup_instance (instance
);
5439 ospf
= ospf_lookup();
5442 if (!ospf
|| !ospf
->oi_running
)
5445 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5448 DEFUN (show_ip_ospf_instance_database_max
,
5449 show_ip_ospf_instance_database_max_cmd
,
5450 "show ip ospf (1-65535) database <max-age|self-originate>",
5453 "OSPF information\n"
5455 "Database summary\n"
5456 "LSAs in MaxAge list\n"
5457 "Self-originated link states\n")
5461 u_short instance
= 0;
5463 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5465 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5468 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5473 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5474 int arg_base
, int argc
, struct cmd_token
**argv
)
5478 struct in_addr adv_router
;
5481 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5484 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5485 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5487 if (argc
!= arg_base
+ 7)
5490 /* Set database type to show. */
5491 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5492 type
= OSPF_ROUTER_LSA
;
5493 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5494 type
= OSPF_NETWORK_LSA
;
5495 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5496 type
= OSPF_AS_NSSA_LSA
;
5497 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5498 type
= OSPF_SUMMARY_LSA
;
5499 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5500 type
= OSPF_ASBR_SUMMARY_LSA
;
5501 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5502 type
= OSPF_AS_EXTERNAL_LSA
;
5503 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5504 type
= OSPF_OPAQUE_LINK_LSA
;
5505 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5506 type
= OSPF_OPAQUE_AREA_LSA
;
5507 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5508 type
= OSPF_OPAQUE_AS_LSA
;
5512 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5513 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5514 adv_router
= ospf
->router_id
;
5517 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5522 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5527 DEFUN (show_ip_ospf_database_type_adv_router
,
5528 show_ip_ospf_database_type_adv_router_cmd
,
5529 "show ip ospf database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
5532 "OSPF information\n"
5533 "Database summary\n"
5535 "Advertising Router link states\n"
5536 "Advertising Router (as an IP address)\n"
5537 "Self-originated link states\n")
5541 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5544 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5547 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5548 show_ip_ospf_instance_database_type_adv_router_cmd
,
5549 "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>",
5552 "OSPF information\n"
5554 "Database summary\n"
5556 "Advertising Router link states\n"
5557 "Advertising Router (as an IP address)\n"
5558 "Self-originated link states\n")
5562 u_short instance
= 0;
5564 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5566 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5569 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5572 DEFUN (ip_ospf_authentication_args
,
5573 ip_ospf_authentication_args_addr_cmd
,
5574 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5576 "OSPF interface commands\n"
5577 "Enable authentication on this interface\n"
5578 "Use null authentication\n"
5579 "Use message-digest authentication\n"
5580 "Address of interface\n")
5582 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5583 int idx_encryption
= 3;
5585 struct in_addr addr
;
5587 struct ospf_if_params
*params
;
5589 params
= IF_DEF_PARAMS (ifp
);
5593 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5596 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5601 params
= ospf_get_if_params (ifp
, addr
);
5602 ospf_if_update_params (ifp
, addr
);
5605 /* Handle null authentication */
5606 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5608 SET_IF_PARAM (params
, auth_type
);
5609 params
->auth_type
= OSPF_AUTH_NULL
;
5613 /* Handle message-digest authentication */
5614 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5616 SET_IF_PARAM (params
, auth_type
);
5617 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5621 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5625 DEFUN (ip_ospf_authentication
,
5626 ip_ospf_authentication_addr_cmd
,
5627 "ip ospf authentication [A.B.C.D]",
5629 "OSPF interface commands\n"
5630 "Enable authentication on this interface\n"
5631 "Address of interface")
5633 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5635 struct in_addr addr
;
5637 struct ospf_if_params
*params
;
5639 params
= IF_DEF_PARAMS (ifp
);
5643 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5646 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5651 params
= ospf_get_if_params (ifp
, addr
);
5652 ospf_if_update_params (ifp
, addr
);
5655 SET_IF_PARAM (params
, auth_type
);
5656 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5661 DEFUN (no_ip_ospf_authentication_args
,
5662 no_ip_ospf_authentication_args_addr_cmd
,
5663 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5666 "OSPF interface commands\n"
5667 "Enable authentication on this interface\n"
5668 "Use null authentication\n"
5669 "Use message-digest authentication\n"
5670 "Address of interface")
5672 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5673 int idx_encryption
= 4;
5675 struct in_addr addr
;
5677 struct ospf_if_params
*params
;
5678 struct route_node
*rn
;
5681 params
= IF_DEF_PARAMS (ifp
);
5685 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5688 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5693 params
= ospf_lookup_if_params (ifp
, addr
);
5696 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5699 params
->auth_type
= OSPF_AUTH_NOTSET
;
5700 UNSET_IF_PARAM (params
, auth_type
);
5701 if (params
!= IF_DEF_PARAMS (ifp
))
5703 ospf_free_if_params (ifp
, addr
);
5704 ospf_if_update_params (ifp
, addr
);
5709 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5711 auth_type
= OSPF_AUTH_NULL
;
5713 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5715 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5719 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5723 * Here we have a case where the user has entered
5724 * 'no ip ospf authentication (null | message_digest )'
5725 * we need to find if we have any ip addresses underneath it that
5726 * correspond to the associated type.
5728 if (params
->auth_type
== auth_type
)
5730 params
->auth_type
= OSPF_AUTH_NOTSET
;
5731 UNSET_IF_PARAM (params
, auth_type
);
5734 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5736 if ((params
= rn
->info
))
5738 if (params
->auth_type
== auth_type
)
5740 params
->auth_type
= OSPF_AUTH_NOTSET
;
5741 UNSET_IF_PARAM (params
, auth_type
);
5742 if (params
!= IF_DEF_PARAMS (ifp
))
5744 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5745 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5755 DEFUN (no_ip_ospf_authentication
,
5756 no_ip_ospf_authentication_addr_cmd
,
5757 "no ip ospf authentication [A.B.C.D]",
5760 "OSPF interface commands\n"
5761 "Enable authentication on this interface\n"
5762 "Address of interface")
5764 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5766 struct in_addr addr
;
5768 struct ospf_if_params
*params
;
5769 struct route_node
*rn
;
5771 params
= IF_DEF_PARAMS (ifp
);
5775 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5778 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5783 params
= ospf_lookup_if_params (ifp
, addr
);
5786 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5790 params
->auth_type
= OSPF_AUTH_NOTSET
;
5791 UNSET_IF_PARAM (params
, auth_type
);
5792 if (params
!= IF_DEF_PARAMS (ifp
))
5794 ospf_free_if_params (ifp
, addr
);
5795 ospf_if_update_params (ifp
, addr
);
5801 * When a user enters 'no ip ospf authentication'
5802 * We should remove all authentication types from
5805 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5806 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5807 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5809 params
->auth_type
= OSPF_AUTH_NOTSET
;
5810 UNSET_IF_PARAM (params
, auth_type
);
5813 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5815 if ((params
= rn
->info
))
5818 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5819 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5820 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5822 params
->auth_type
= OSPF_AUTH_NOTSET
;
5823 UNSET_IF_PARAM (params
, auth_type
);
5824 if (params
!= IF_DEF_PARAMS (ifp
))
5826 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5827 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5838 DEFUN (ip_ospf_authentication_key
,
5839 ip_ospf_authentication_key_addr_cmd
,
5840 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5842 "OSPF interface commands\n"
5843 "Authentication password (key)\n"
5844 "The OSPF password (key)\n"
5845 "Address of interface")
5847 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5849 struct in_addr addr
;
5850 struct ospf_if_params
*params
;
5852 params
= IF_DEF_PARAMS (ifp
);
5854 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5856 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5858 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5863 params
= ospf_get_if_params (ifp
, addr
);
5864 ospf_if_update_params (ifp
, addr
);
5867 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5868 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5869 SET_IF_PARAM (params
, auth_simple
);
5874 DEFUN_HIDDEN (ospf_authentication_key
,
5875 ospf_authentication_key_cmd
,
5876 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5877 "OSPF interface commands\n"
5878 "Authentication password (key)\n"
5879 "The OSPF password (key)\n"
5880 "Address of interface\n")
5882 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5885 DEFUN (no_ip_ospf_authentication_key
,
5886 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5887 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5890 "OSPF interface commands\n"
5891 "Authentication password (key)\n"
5892 "The OSPF password (key)")
5894 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5896 struct in_addr addr
;
5897 struct ospf_if_params
*params
;
5898 params
= IF_DEF_PARAMS (ifp
);
5900 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5902 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5904 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5909 params
= ospf_lookup_if_params (ifp
, addr
);
5914 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5915 UNSET_IF_PARAM (params
, auth_simple
);
5917 if (params
!= IF_DEF_PARAMS (ifp
))
5919 ospf_free_if_params (ifp
, addr
);
5920 ospf_if_update_params (ifp
, addr
);
5926 DEFUN_HIDDEN (no_ospf_authentication_key
,
5927 no_ospf_authentication_key_authkey_addr_cmd
,
5928 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5930 "OSPF interface commands\n"
5931 "Authentication password (key)\n"
5932 "The OSPF password (key)")
5934 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5937 DEFUN (ip_ospf_message_digest_key
,
5938 ip_ospf_message_digest_key_cmd
,
5939 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5941 "OSPF interface commands\n"
5942 "Message digest authentication password (key)\n"
5944 "Use MD5 algorithm\n"
5945 "The OSPF password (key)\n"
5946 "Address of interface\n")
5948 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5949 struct crypt_key
*ck
;
5951 struct in_addr addr
;
5952 struct ospf_if_params
*params
;
5954 params
= IF_DEF_PARAMS (ifp
);
5957 argv_find (argv
, argc
, "(1-255)", &idx
);
5958 char *keyid
= argv
[idx
]->arg
;
5959 argv_find (argv
, argc
, "KEY", &idx
);
5960 char *cryptkey
= argv
[idx
]->arg
;
5962 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5964 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5966 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5971 params
= ospf_get_if_params (ifp
, addr
);
5972 ospf_if_update_params (ifp
, addr
);
5975 key_id
= strtol (keyid
, NULL
, 10);
5976 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5978 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5982 ck
= ospf_crypt_key_new ();
5983 ck
->key_id
= (u_char
) key_id
;
5984 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5985 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5987 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5988 SET_IF_PARAM (params
, auth_crypt
);
5993 DEFUN_HIDDEN (ospf_message_digest_key
,
5994 ospf_message_digest_key_cmd
,
5995 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5996 "OSPF interface commands\n"
5997 "Message digest authentication password (key)\n"
5999 "Use MD5 algorithm\n"
6000 "The OSPF password (key)\n"
6001 "Address of interface\n")
6003 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6006 DEFUN (no_ip_ospf_message_digest_key
,
6007 no_ip_ospf_message_digest_key_cmd
,
6008 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6011 "OSPF interface commands\n"
6012 "Message digest authentication password (key)\n"
6014 "Use MD5 algorithm\n"
6015 "The OSPF password (key)\n"
6016 "Address of interface\n")
6018 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6020 struct crypt_key
*ck
;
6022 struct in_addr addr
;
6023 struct ospf_if_params
*params
;
6024 params
= IF_DEF_PARAMS (ifp
);
6026 argv_find (argv
, argc
, "(1-255)", &idx
);
6027 char *keyid
= argv
[idx
]->arg
;
6029 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6031 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6033 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6038 params
= ospf_lookup_if_params (ifp
, addr
);
6043 key_id
= strtol (keyid
, NULL
, 10);
6044 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6047 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6051 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6053 if (params
!= IF_DEF_PARAMS (ifp
))
6055 ospf_free_if_params (ifp
, addr
);
6056 ospf_if_update_params (ifp
, addr
);
6062 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6063 no_ospf_message_digest_key_cmd
,
6064 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6066 "OSPF interface commands\n"
6067 "Message digest authentication password (key)\n"
6069 "Address of interface")
6071 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6074 DEFUN (ip_ospf_cost
,
6076 "ip ospf cost (1-65535) [A.B.C.D]",
6078 "OSPF interface commands\n"
6081 "Address of interface\n")
6083 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6086 struct in_addr addr
;
6087 struct ospf_if_params
*params
;
6088 params
= IF_DEF_PARAMS (ifp
);
6091 char *coststr
= NULL
, *ifaddr
= NULL
;
6092 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6093 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6095 cost
= strtol (coststr
, NULL
, 10);
6099 if(!inet_aton(ifaddr
, &addr
))
6101 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6106 params
= ospf_get_if_params (ifp
, addr
);
6107 ospf_if_update_params (ifp
, addr
);
6110 SET_IF_PARAM (params
, output_cost_cmd
);
6111 params
->output_cost_cmd
= cost
;
6113 ospf_if_recalculate_output_cost (ifp
);
6118 DEFUN_HIDDEN (ospf_cost
,
6120 "ospf cost (1-65535) [A.B.C.D]",
6121 "OSPF interface commands\n"
6124 "Address of interface\n")
6126 return ip_ospf_cost (self
, vty
, argc
, argv
);
6129 DEFUN (no_ip_ospf_cost
,
6130 no_ip_ospf_cost_cmd
,
6131 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6133 "OSPF interface commands\n"
6135 "Address of interface")
6137 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6139 struct in_addr addr
;
6140 struct ospf_if_params
*params
;
6142 params
= IF_DEF_PARAMS (ifp
);
6145 char *ifaddr
= NULL
;
6146 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6148 /* According to the semantics we are mimicking "no ip ospf cost N" is
6149 * always treated as "no ip ospf cost" regardless of the actual value
6150 * of N already configured for the interface. Thus ignore cost. */
6154 if (!inet_aton(ifaddr
, &addr
))
6156 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6161 params
= ospf_lookup_if_params (ifp
, addr
);
6166 UNSET_IF_PARAM (params
, output_cost_cmd
);
6168 if (params
!= IF_DEF_PARAMS (ifp
))
6170 ospf_free_if_params (ifp
, addr
);
6171 ospf_if_update_params (ifp
, addr
);
6174 ospf_if_recalculate_output_cost (ifp
);
6179 DEFUN_HIDDEN (no_ospf_cost
,
6181 "no ospf cost [(1-65535)] [A.B.C.D]",
6183 "OSPF interface commands\n"
6186 "Address of interface\n")
6188 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6192 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6194 struct route_node
*rn
;
6195 struct ospf_neighbor
*nbr
;
6197 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6198 if ((nbr
= rn
->info
))
6200 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6201 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6202 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6203 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6208 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6209 const char *nbr_str
,
6210 const char *fast_hello_str
)
6212 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6215 struct in_addr addr
;
6217 struct ospf_if_params
*params
;
6218 struct ospf_interface
*oi
;
6219 struct route_node
*rn
;
6221 params
= IF_DEF_PARAMS (ifp
);
6225 ret
= inet_aton(nbr_str
, &addr
);
6228 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6233 params
= ospf_get_if_params (ifp
, addr
);
6234 ospf_if_update_params (ifp
, addr
);
6239 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6242 /* reset fast_hello too, just to be sure */
6243 UNSET_IF_PARAM (params
, fast_hello
);
6244 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6246 else if (fast_hello_str
)
6248 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6250 /* 1s dead-interval with sub-second hellos desired */
6251 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6252 SET_IF_PARAM (params
, fast_hello
);
6253 params
->fast_hello
= hellomult
;
6257 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6262 SET_IF_PARAM (params
, v_wait
);
6263 params
->v_wait
= seconds
;
6265 /* Update timer values in neighbor structure. */
6269 if ((ospf
= ospf_lookup()))
6271 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6273 ospf_nbr_timer_update (oi
);
6278 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6279 if ((oi
= rn
->info
))
6280 ospf_nbr_timer_update (oi
);
6286 DEFUN (ip_ospf_dead_interval
,
6287 ip_ospf_dead_interval_cmd
,
6288 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6290 "OSPF interface commands\n"
6291 "Interval time after which a neighbor is declared down\n"
6293 "Address of interface\n")
6296 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6297 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6298 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6302 DEFUN_HIDDEN (ospf_dead_interval
,
6303 ospf_dead_interval_cmd
,
6304 "ospf dead-interval (1-65535) [A.B.C.D]",
6305 "OSPF interface commands\n"
6306 "Interval time after which a neighbor is declared down\n"
6308 "Address of interface\n")
6310 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6313 DEFUN (ip_ospf_dead_interval_minimal
,
6314 ip_ospf_dead_interval_minimal_addr_cmd
,
6315 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6317 "OSPF interface commands\n"
6318 "Interval time after which a neighbor is declared down\n"
6319 "Minimal 1s dead-interval with fast sub-second hellos\n"
6320 "Hello multiplier factor\n"
6321 "Number of Hellos to send each second\n"
6322 "Address of interface\n")
6327 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6329 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6332 DEFUN (no_ip_ospf_dead_interval
,
6333 no_ip_ospf_dead_interval_cmd
,
6334 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6337 "OSPF interface commands\n"
6338 "Interval time after which a neighbor is declared down\n"
6340 "Address of interface")
6342 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6343 int idx_ipv4
= argc
- 1;
6344 struct in_addr addr
= { .s_addr
= 0L};
6346 struct ospf_if_params
*params
;
6347 struct ospf_interface
*oi
;
6348 struct route_node
*rn
;
6350 params
= IF_DEF_PARAMS (ifp
);
6352 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6354 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6357 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6362 params
= ospf_lookup_if_params (ifp
, addr
);
6367 UNSET_IF_PARAM (params
, v_wait
);
6368 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6370 UNSET_IF_PARAM (params
, fast_hello
);
6371 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6373 if (params
!= IF_DEF_PARAMS (ifp
))
6375 ospf_free_if_params (ifp
, addr
);
6376 ospf_if_update_params (ifp
, addr
);
6379 /* Update timer values in neighbor structure. */
6384 if ((ospf
= ospf_lookup()))
6386 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6388 ospf_nbr_timer_update (oi
);
6393 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6394 if ((oi
= rn
->info
))
6395 ospf_nbr_timer_update (oi
);
6401 DEFUN_HIDDEN (no_ospf_dead_interval
,
6402 no_ospf_dead_interval_cmd
,
6403 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6405 "OSPF interface commands\n"
6406 "Interval time after which a neighbor is declared down\n"
6408 "Address of interface")
6410 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6413 DEFUN (ip_ospf_hello_interval
,
6414 ip_ospf_hello_interval_cmd
,
6415 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6417 "OSPF interface commands\n"
6418 "Time between HELLO packets\n"
6420 "Address of interface\n")
6422 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6424 struct in_addr addr
;
6425 struct ospf_if_params
*params
;
6426 params
= IF_DEF_PARAMS (ifp
);
6427 u_int32_t seconds
= 0;
6429 argv_find (argv
, argc
, "(1-65535)", &idx
);
6430 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6432 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6434 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6436 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6441 params
= ospf_get_if_params (ifp
, addr
);
6442 ospf_if_update_params (ifp
, addr
);
6445 SET_IF_PARAM (params
, v_hello
);
6446 params
->v_hello
= seconds
;
6451 DEFUN_HIDDEN (ospf_hello_interval
,
6452 ospf_hello_interval_cmd
,
6453 "ospf hello-interval (1-65535) [A.B.C.D]",
6454 "OSPF interface commands\n"
6455 "Time between HELLO packets\n"
6457 "Address of interface\n")
6459 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6462 DEFUN (no_ip_ospf_hello_interval
,
6463 no_ip_ospf_hello_interval_cmd
,
6464 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6467 "OSPF interface commands\n"
6468 "Time between HELLO packets\n" // ignored
6470 "Address of interface\n")
6472 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6474 struct in_addr addr
;
6475 struct ospf_if_params
*params
;
6476 params
= IF_DEF_PARAMS (ifp
);
6478 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6480 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6482 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6487 params
= ospf_lookup_if_params (ifp
, addr
);
6492 UNSET_IF_PARAM (params
, v_hello
);
6493 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6495 if (params
!= IF_DEF_PARAMS (ifp
))
6497 ospf_free_if_params (ifp
, addr
);
6498 ospf_if_update_params (ifp
, addr
);
6504 DEFUN_HIDDEN (no_ospf_hello_interval
,
6505 no_ospf_hello_interval_cmd
,
6506 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6508 "OSPF interface commands\n"
6509 "Time between HELLO packets\n" // ignored
6511 "Address of interface\n")
6513 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6516 DEFUN (ip_ospf_network
,
6517 ip_ospf_network_cmd
,
6518 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6520 "OSPF interface commands\n"
6522 "Specify OSPF broadcast multi-access network\n"
6523 "Specify OSPF NBMA network\n"
6524 "Specify OSPF point-to-multipoint network\n"
6525 "Specify OSPF point-to-point network\n")
6527 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6529 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6530 struct route_node
*rn
;
6532 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6534 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6538 if (argv_find (argv
, argc
, "broadcast", &idx
))
6539 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6540 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6541 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6542 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6543 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6544 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6545 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6547 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6550 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6552 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6554 struct ospf_interface
*oi
= rn
->info
;
6559 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6561 if (oi
->state
> ISM_Down
)
6563 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6564 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6571 DEFUN_HIDDEN (ospf_network
,
6573 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6574 "OSPF interface commands\n"
6576 "Specify OSPF broadcast multi-access network\n"
6577 "Specify OSPF NBMA network\n"
6578 "Specify OSPF point-to-multipoint network\n"
6579 "Specify OSPF point-to-point network\n")
6581 return ip_ospf_network (self
, vty
, argc
, argv
);
6584 DEFUN (no_ip_ospf_network
,
6585 no_ip_ospf_network_cmd
,
6586 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6589 "OSPF interface commands\n"
6591 "Specify OSPF broadcast multi-access network\n"
6592 "Specify OSPF NBMA network\n"
6593 "Specify OSPF point-to-multipoint network\n"
6594 "Specify OSPF point-to-point network\n")
6596 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6597 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6598 struct route_node
*rn
;
6600 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6602 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6605 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6607 struct ospf_interface
*oi
= rn
->info
;
6612 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6614 if (oi
->state
> ISM_Down
)
6616 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6617 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6624 DEFUN_HIDDEN (no_ospf_network
,
6625 no_ospf_network_cmd
,
6626 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6628 "OSPF interface commands\n"
6630 "Specify OSPF broadcast multi-access network\n"
6631 "Specify OSPF NBMA network\n"
6632 "Specify OSPF point-to-multipoint network\n"
6633 "Specify OSPF point-to-point network\n")
6635 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6638 DEFUN (ip_ospf_priority
,
6639 ip_ospf_priority_cmd
,
6640 "ip ospf priority (0-255) [A.B.C.D]",
6642 "OSPF interface commands\n"
6645 "Address of interface")
6647 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6650 struct route_node
*rn
;
6651 struct in_addr addr
;
6652 struct ospf_if_params
*params
;
6653 params
= IF_DEF_PARAMS (ifp
);
6655 argv_find (argv
, argc
, "(0-255)", &idx
);
6656 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6658 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6660 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6662 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6667 params
= ospf_get_if_params (ifp
, addr
);
6668 ospf_if_update_params (ifp
, addr
);
6671 SET_IF_PARAM (params
, priority
);
6672 params
->priority
= priority
;
6674 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6676 struct ospf_interface
*oi
= rn
->info
;
6681 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6683 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6684 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6691 DEFUN_HIDDEN (ospf_priority
,
6693 "ospf priority (0-255) [A.B.C.D]",
6694 "OSPF interface commands\n"
6697 "Address of interface")
6699 return ip_ospf_priority (self
, vty
, argc
, argv
);
6702 DEFUN (no_ip_ospf_priority
,
6703 no_ip_ospf_priority_cmd
,
6704 "no ip ospf priority [(0-255) [A.B.C.D]]",
6707 "OSPF interface commands\n"
6708 "Router priority\n" // ignored
6710 "Address of interface")
6712 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6714 struct route_node
*rn
;
6715 struct in_addr addr
;
6716 struct ospf_if_params
*params
;
6718 params
= IF_DEF_PARAMS (ifp
);
6720 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6722 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6724 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6729 params
= ospf_lookup_if_params (ifp
, addr
);
6734 UNSET_IF_PARAM (params
, priority
);
6735 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6737 if (params
!= IF_DEF_PARAMS (ifp
))
6739 ospf_free_if_params (ifp
, addr
);
6740 ospf_if_update_params (ifp
, addr
);
6743 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6745 struct ospf_interface
*oi
= rn
->info
;
6750 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6752 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6753 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6760 DEFUN_HIDDEN (no_ospf_priority
,
6761 no_ospf_priority_cmd
,
6762 "no ospf priority [(0-255) [A.B.C.D]]",
6764 "OSPF interface commands\n"
6767 "Address of interface")
6769 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6772 DEFUN (ip_ospf_retransmit_interval
,
6773 ip_ospf_retransmit_interval_addr_cmd
,
6774 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6776 "OSPF interface commands\n"
6777 "Time between retransmitting lost link state advertisements\n"
6779 "Address of interface")
6781 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6784 struct in_addr addr
;
6785 struct ospf_if_params
*params
;
6786 params
= IF_DEF_PARAMS (ifp
);
6788 argv_find (argv
, argc
, "(3-65535)", &idx
);
6789 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6791 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6793 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6795 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6800 params
= ospf_get_if_params (ifp
, addr
);
6801 ospf_if_update_params (ifp
, addr
);
6804 SET_IF_PARAM (params
, retransmit_interval
);
6805 params
->retransmit_interval
= seconds
;
6810 DEFUN_HIDDEN (ospf_retransmit_interval
,
6811 ospf_retransmit_interval_cmd
,
6812 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6813 "OSPF interface commands\n"
6814 "Time between retransmitting lost link state advertisements\n"
6816 "Address of interface")
6818 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6821 DEFUN (no_ip_ospf_retransmit_interval
,
6822 no_ip_ospf_retransmit_interval_addr_cmd
,
6823 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6826 "OSPF interface commands\n"
6827 "Time between retransmitting lost link state advertisements\n"
6829 "Address of interface\n")
6831 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6833 struct in_addr addr
;
6834 struct ospf_if_params
*params
;
6836 params
= IF_DEF_PARAMS (ifp
);
6838 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6840 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6842 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6847 params
= ospf_lookup_if_params (ifp
, addr
);
6852 UNSET_IF_PARAM (params
, retransmit_interval
);
6853 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6855 if (params
!= IF_DEF_PARAMS (ifp
))
6857 ospf_free_if_params (ifp
, addr
);
6858 ospf_if_update_params (ifp
, addr
);
6864 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6865 no_ospf_retransmit_interval_cmd
,
6866 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6868 "OSPF interface commands\n"
6869 "Time between retransmitting lost link state advertisements\n"
6871 "Address of interface\n")
6873 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6876 DEFUN (ip_ospf_transmit_delay
,
6877 ip_ospf_transmit_delay_addr_cmd
,
6878 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6880 "OSPF interface commands\n"
6881 "Link state transmit delay\n"
6883 "Address of interface")
6885 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6888 struct in_addr addr
;
6889 struct ospf_if_params
*params
;
6891 params
= IF_DEF_PARAMS (ifp
);
6892 argv_find (argv
, argc
, "(1-65535)", &idx
);
6893 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6895 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6897 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6899 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6904 params
= ospf_get_if_params (ifp
, addr
);
6905 ospf_if_update_params (ifp
, addr
);
6908 SET_IF_PARAM (params
, transmit_delay
);
6909 params
->transmit_delay
= seconds
;
6914 DEFUN_HIDDEN (ospf_transmit_delay
,
6915 ospf_transmit_delay_cmd
,
6916 "ospf transmit-delay (1-65535) [A.B.C.D]",
6917 "OSPF interface commands\n"
6918 "Link state transmit delay\n"
6920 "Address of interface")
6922 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6925 DEFUN (no_ip_ospf_transmit_delay
,
6926 no_ip_ospf_transmit_delay_addr_cmd
,
6927 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6930 "OSPF interface commands\n"
6931 "Link state transmit delay\n"
6932 "Address of interface")
6934 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6936 struct in_addr addr
;
6937 struct ospf_if_params
*params
;
6939 params
= IF_DEF_PARAMS (ifp
);
6941 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6943 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6945 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6950 params
= ospf_lookup_if_params (ifp
, addr
);
6955 UNSET_IF_PARAM (params
, transmit_delay
);
6956 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6958 if (params
!= IF_DEF_PARAMS (ifp
))
6960 ospf_free_if_params (ifp
, addr
);
6961 ospf_if_update_params (ifp
, addr
);
6968 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6969 no_ospf_transmit_delay_cmd
,
6970 "no ospf transmit-delay",
6972 "OSPF interface commands\n"
6973 "Link state transmit delay\n")
6975 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6978 DEFUN (ip_ospf_area
,
6980 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6982 "OSPF interface commands\n"
6984 "Enable OSPF on this interface\n"
6985 "OSPF area ID in IP address format\n"
6986 "OSPF area ID as a decimal value\n")
6988 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6991 struct in_addr area_id
;
6993 struct ospf_if_params
*params
;
6994 struct route_node
*rn
;
6995 u_short instance
= 0;
6997 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
6998 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
6999 char *areaid
= argv
[argc
- 1]->arg
;
7001 ospf
= ospf_lookup_instance (instance
);
7004 params
= IF_DEF_PARAMS (ifp
);
7005 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7007 ospf_interface_unset (ifp
);
7008 ospf
= ospf_lookup();
7009 ospf
->if_ospf_cli_count
--;
7014 ret
= str2area_id (areaid
, &area_id
, &format
);
7017 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7021 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7023 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7027 params
= IF_DEF_PARAMS (ifp
);
7028 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7031 "Must remove previous area config before changing ospf area %s",
7036 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7038 if (rn
->info
!= NULL
)
7040 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7045 /* enable ospf on this interface with area_id */
7046 ospf_interface_set (ifp
, area_id
);
7047 ospf
->if_ospf_cli_count
++;
7052 DEFUN (no_ip_ospf_area
,
7053 no_ip_ospf_area_cmd
,
7054 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7057 "OSPF interface commands\n"
7059 "Disable OSPF on this interface\n"
7060 "OSPF area ID in IP address format\n"
7061 "OSPF area ID as a decimal value\n")
7063 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7066 struct ospf_if_params
*params
;
7067 u_short instance
= 0;
7069 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7070 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7072 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7075 params
= IF_DEF_PARAMS (ifp
);
7076 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7078 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7082 ospf_interface_unset (ifp
);
7083 ospf
->if_ospf_cli_count
--;
7087 DEFUN (ospf_redistribute_source
,
7088 ospf_redistribute_source_cmd
,
7089 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7091 FRR_REDIST_HELP_STR_OSPFD
7092 "Metric for redistributed routes\n"
7093 "OSPF default metric\n"
7094 "OSPF exterior metric type for redistributed routes\n"
7095 "Set OSPF External Type 1 metrics\n"
7096 "Set OSPF External Type 2 metrics\n"
7097 "Route map reference\n"
7098 "Pointer to route-map entries\n")
7100 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7101 int idx_protocol
= 1;
7105 struct ospf_redist
*red
;
7111 /* Get distribute source. */
7112 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7116 red
= ospf_redist_add(ospf
, source
, 0);
7118 /* Get metric value. */
7119 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7120 if (!str2metric (argv
[idx
]->arg
, &metric
))
7123 /* Get metric type. */
7124 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7125 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7129 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7130 ospf_routemap_set (red
, argv
[idx
]->arg
);
7133 ospf_routemap_unset (red
);
7135 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7138 DEFUN (no_ospf_redistribute_source
,
7139 no_ospf_redistribute_source_cmd
,
7140 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7143 FRR_REDIST_HELP_STR_OSPFD
7144 "Metric for redistributed routes\n"
7145 "OSPF default metric\n"
7146 "OSPF exterior metric type for redistributed routes\n"
7147 "Set OSPF External Type 1 metrics\n"
7148 "Set OSPF External Type 2 metrics\n"
7149 "Route map reference\n"
7150 "Pointer to route-map entries\n")
7152 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7153 int idx_protocol
= 2;
7155 struct ospf_redist
*red
;
7157 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7161 red
= ospf_redist_lookup(ospf
, source
, 0);
7165 ospf_routemap_unset (red
);
7166 return ospf_redistribute_unset (ospf
, source
, 0);
7169 DEFUN (ospf_redistribute_instance_source
,
7170 ospf_redistribute_instance_source_cmd
,
7171 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7173 "Open Shortest Path First\n"
7174 "Non-main Kernel Routing Table\n"
7175 "Instance ID/Table ID\n"
7176 "Metric for redistributed routes\n"
7177 "OSPF default metric\n"
7178 "OSPF exterior metric type for redistributed routes\n"
7179 "Set OSPF External Type 1 metrics\n"
7180 "Set OSPF External Type 2 metrics\n"
7181 "Route map reference\n"
7182 "Pointer to route-map entries\n")
7184 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7185 int idx_ospf_table
= 1;
7192 struct ospf_redist
*red
;
7197 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7199 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7204 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7206 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7211 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7213 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7218 /* Get metric value. */
7219 if (argv_find (argv
, argc
, "metric", &idx
))
7220 if (!str2metric (argv
[idx
+1]->arg
, &metric
))
7224 /* Get metric type. */
7225 if (argv_find (argv
, argc
, "metric-type", &idx
))
7226 if (!str2metric_type (argv
[idx
+1]->arg
, &type
))
7229 red
= ospf_redist_add(ospf
, source
, instance
);
7232 if (argv_find (argv
, argc
, "route-map", &idx
))
7233 ospf_routemap_set (red
, argv
[idx
+1]->arg
);
7235 ospf_routemap_unset (red
);
7237 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7240 DEFUN (no_ospf_redistribute_instance_source
,
7241 no_ospf_redistribute_instance_source_cmd
,
7242 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7245 "Open Shortest Path First\n"
7246 "Non-main Kernel Routing Table\n"
7247 "Instance ID/Table Id\n"
7248 "Metric for redistributed routes\n"
7249 "OSPF default metric\n"
7250 "OSPF exterior metric type for redistributed routes\n"
7251 "Set OSPF External Type 1 metrics\n"
7252 "Set OSPF External Type 2 metrics\n"
7253 "Route map reference\n"
7254 "Pointer to route-map entries\n")
7256 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7257 int idx_ospf_table
= 2;
7260 struct ospf_redist
*red
;
7263 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7264 source
= ZEBRA_ROUTE_OSPF
;
7266 source
= ZEBRA_ROUTE_TABLE
;
7268 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7270 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7272 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7277 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7279 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7284 red
= ospf_redist_lookup(ospf
, source
, instance
);
7288 ospf_routemap_unset (red
);
7289 return ospf_redistribute_unset (ospf
, source
, instance
);
7292 DEFUN (ospf_distribute_list_out
,
7293 ospf_distribute_list_out_cmd
,
7294 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7295 "Filter networks in routing updates\n"
7296 "Access-list name\n"
7298 FRR_REDIST_HELP_STR_OSPFD
)
7300 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7304 char *proto
= argv
[argc
- 1]->text
;
7306 /* Get distribute source. */
7307 source
= proto_redistnum(AFI_IP
, proto
);
7311 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7314 DEFUN (no_ospf_distribute_list_out
,
7315 no_ospf_distribute_list_out_cmd
,
7316 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7318 "Filter networks in routing updates\n"
7319 "Access-list name\n"
7321 FRR_REDIST_HELP_STR_OSPFD
)
7323 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7327 char *proto
= argv
[argc
- 1]->text
;
7328 source
= proto_redistnum(AFI_IP
, proto
);
7332 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7335 /* Default information originate. */
7336 DEFUN (ospf_default_information_originate
,
7337 ospf_default_information_originate_cmd
,
7338 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7339 "Control distribution of default information\n"
7340 "Distribute a default route\n"
7341 "Always advertise default route\n"
7342 "OSPF default metric\n"
7344 "OSPF metric type for default routes\n"
7345 "Set OSPF External Type 1 metrics\n"
7346 "Set OSPF External Type 2 metrics\n"
7347 "Route map reference\n"
7348 "Pointer to route-map entries\n")
7350 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7351 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7354 struct ospf_redist
*red
;
7357 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7359 /* Check whether "always" was specified */
7360 if (argv_find (argv
, argc
, "always", &idx
))
7361 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7362 /* Get metric value */
7363 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7364 if (!str2metric (argv
[idx
]->arg
, &metric
))
7367 /* Get metric type. */
7368 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7369 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7373 else if (argv_find (argv
, argc
, "WORD", &idx
))
7374 ospf_routemap_set (red
, argv
[idx
]->arg
);
7376 ospf_routemap_unset (red
);
7378 return ospf_redistribute_default_set (ospf
, default_originate
,
7382 DEFUN (no_ospf_default_information_originate
,
7383 no_ospf_default_information_originate_cmd
,
7384 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7386 "Control distribution of default information\n"
7387 "Distribute a default route\n"
7388 "Always advertise default route\n"
7389 "OSPF default metric\n"
7391 "OSPF metric type for default routes\n"
7392 "Set OSPF External Type 1 metrics\n"
7393 "Set OSPF External Type 2 metrics\n"
7394 "Route map reference\n"
7395 "Pointer to route-map entries\n")
7397 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7398 struct prefix_ipv4 p
;
7399 struct ospf_external
*ext
;
7400 struct ospf_redist
*red
;
7403 p
.prefix
.s_addr
= 0;
7406 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7408 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7409 EXTERNAL_INFO (ext
)) {
7410 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7411 ospf_external_del (DEFAULT_ROUTE
, 0);
7414 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7418 ospf_routemap_unset (red
);
7419 return ospf_redistribute_default_unset (ospf
);
7422 DEFUN (ospf_default_metric
,
7423 ospf_default_metric_cmd
,
7424 "default-metric (0-16777214)",
7425 "Set metric of redistributed routes\n"
7428 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7432 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7435 ospf
->default_metric
= metric
;
7440 DEFUN (no_ospf_default_metric
,
7441 no_ospf_default_metric_cmd
,
7442 "no default-metric [(0-16777214)]",
7444 "Set metric of redistributed routes\n"
7447 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7449 ospf
->default_metric
= -1;
7455 DEFUN (ospf_distance
,
7458 "Administrative distance\n"
7459 "OSPF Administrative distance\n")
7461 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7464 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7469 DEFUN (no_ospf_distance
,
7470 no_ospf_distance_cmd
,
7471 "no distance (1-255)",
7473 "Administrative distance\n"
7474 "OSPF Administrative distance\n")
7476 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7478 ospf
->distance_all
= 0;
7483 DEFUN (no_ospf_distance_ospf
,
7484 no_ospf_distance_ospf_cmd
,
7485 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7487 "Administrative distance\n"
7488 "OSPF administrative distance\n"
7489 "Intra-area routes\n"
7490 "Distance for intra-area routes\n"
7491 "Inter-area routes\n"
7492 "Distance for inter-area routes\n"
7494 "Distance for external routes\n")
7496 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7502 if (argv_find (argv
, argc
, "intra-area", &idx
) || argc
== 3)
7503 idx
= ospf
->distance_intra
= 0;
7504 if (argv_find (argv
, argc
, "inter-area", &idx
) || argc
== 3)
7505 idx
= ospf
->distance_inter
= 0;
7506 if (argv_find (argv
, argc
, "external", &idx
) || argc
== 3)
7507 ospf
->distance_external
= 0;
7512 DEFUN (ospf_distance_ospf
,
7513 ospf_distance_ospf_cmd
,
7514 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7515 "Administrative distance\n"
7516 "OSPF administrative distance\n"
7517 "Intra-area routes\n"
7518 "Distance for intra-area routes\n"
7519 "Inter-area routes\n"
7520 "Distance for inter-area routes\n"
7522 "Distance for external routes\n")
7524 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7527 if (argv_find (argv
, argc
, "intra-area", &idx
))
7528 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7530 if (argv_find (argv
, argc
, "inter-area", &idx
))
7531 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7533 if (argv_find (argv
, argc
, "external", &idx
))
7534 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7540 DEFUN (ospf_distance_source
,
7541 ospf_distance_source_cmd
,
7542 "distance (1-255) A.B.C.D/M",
7543 "Administrative distance\n"
7545 "IP source prefix\n")
7547 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7549 int idx_ipv4_prefixlen
= 2;
7554 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7559 DEFUN (no_ospf_distance_source
,
7560 no_ospf_distance_source_cmd
,
7561 "no distance (1-255) A.B.C.D/M",
7563 "Administrative distance\n"
7565 "IP source prefix\n")
7567 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7569 int idx_ipv4_prefixlen
= 3;
7574 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7579 DEFUN (ospf_distance_source_access_list
,
7580 ospf_distance_source_access_list_cmd
,
7581 "distance (1-255) A.B.C.D/M WORD",
7582 "Administrative distance\n"
7584 "IP source prefix\n"
7585 "Access list name\n")
7587 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7589 int idx_ipv4_prefixlen
= 2;
7595 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7600 DEFUN (no_ospf_distance_source_access_list
,
7601 no_ospf_distance_source_access_list_cmd
,
7602 "no distance (1-255) A.B.C.D/M WORD",
7604 "Administrative distance\n"
7606 "IP source prefix\n"
7607 "Access list name\n")
7609 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7611 int idx_ipv4_prefixlen
= 3;
7617 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7623 DEFUN (ip_ospf_mtu_ignore
,
7624 ip_ospf_mtu_ignore_addr_cmd
,
7625 "ip ospf mtu-ignore [A.B.C.D]",
7627 "OSPF interface commands\n"
7628 "Disable MTU mismatch detection on this interface\n"
7629 "Address of interface")
7631 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7633 struct in_addr addr
;
7636 struct ospf_if_params
*params
;
7637 params
= IF_DEF_PARAMS (ifp
);
7641 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7644 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7648 params
= ospf_get_if_params (ifp
, addr
);
7649 ospf_if_update_params (ifp
, addr
);
7651 params
->mtu_ignore
= 1;
7652 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7653 SET_IF_PARAM (params
, mtu_ignore
);
7656 UNSET_IF_PARAM (params
, mtu_ignore
);
7657 if (params
!= IF_DEF_PARAMS (ifp
))
7659 ospf_free_if_params (ifp
, addr
);
7660 ospf_if_update_params (ifp
, addr
);
7666 DEFUN (no_ip_ospf_mtu_ignore
,
7667 no_ip_ospf_mtu_ignore_addr_cmd
,
7668 "no ip ospf mtu-ignore [A.B.C.D]",
7670 "OSPF interface commands\n"
7671 "Disable MTU mismatch detection on this interface\n"
7672 "Address of interface")
7674 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7676 struct in_addr addr
;
7679 struct ospf_if_params
*params
;
7680 params
= IF_DEF_PARAMS (ifp
);
7684 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7687 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7691 params
= ospf_get_if_params (ifp
, addr
);
7692 ospf_if_update_params (ifp
, addr
);
7694 params
->mtu_ignore
= 0;
7695 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7696 SET_IF_PARAM (params
, mtu_ignore
);
7699 UNSET_IF_PARAM (params
, mtu_ignore
);
7700 if (params
!= IF_DEF_PARAMS (ifp
))
7702 ospf_free_if_params (ifp
, addr
);
7703 ospf_if_update_params (ifp
, addr
);
7710 DEFUN (ospf_max_metric_router_lsa_admin
,
7711 ospf_max_metric_router_lsa_admin_cmd
,
7712 "max-metric router-lsa administrative",
7713 "OSPF maximum / infinite-distance metric\n"
7714 "Advertise own Router-LSA with infinite distance (stub router)\n"
7715 "Administratively applied, for an indefinite period\n")
7717 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7718 struct listnode
*ln
;
7719 struct ospf_area
*area
;
7721 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7723 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7725 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7726 ospf_router_lsa_update_area (area
);
7729 /* Allows for areas configured later to get the property */
7730 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7735 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7736 no_ospf_max_metric_router_lsa_admin_cmd
,
7737 "no max-metric router-lsa administrative",
7739 "OSPF maximum / infinite-distance metric\n"
7740 "Advertise own Router-LSA with infinite distance (stub router)\n"
7741 "Administratively applied, for an indefinite period\n")
7743 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7744 struct listnode
*ln
;
7745 struct ospf_area
*area
;
7747 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7749 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7751 /* Don't trample on the start-up stub timer */
7752 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7753 && !area
->t_stub_router
)
7755 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7756 ospf_router_lsa_update_area (area
);
7759 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7763 DEFUN (ospf_max_metric_router_lsa_startup
,
7764 ospf_max_metric_router_lsa_startup_cmd
,
7765 "max-metric router-lsa on-startup (5-86400)",
7766 "OSPF maximum / infinite-distance metric\n"
7767 "Advertise own Router-LSA with infinite distance (stub router)\n"
7768 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7769 "Time (seconds) to advertise self as stub-router\n")
7771 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7773 unsigned int seconds
;
7777 vty_out (vty
, "%% Must supply stub-router period");
7781 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7783 ospf
->stub_router_startup_time
= seconds
;
7788 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7789 no_ospf_max_metric_router_lsa_startup_cmd
,
7790 "no max-metric router-lsa on-startup [(5-86400)]",
7792 "OSPF maximum / infinite-distance metric\n"
7793 "Advertise own Router-LSA with infinite distance (stub router)\n"
7794 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7795 "Time (seconds) to advertise self as stub-router\n")
7797 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7798 struct listnode
*ln
;
7799 struct ospf_area
*area
;
7801 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7803 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7805 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7806 OSPF_TIMER_OFF (area
->t_stub_router
);
7808 /* Don't trample on admin stub routed */
7809 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7811 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7812 ospf_router_lsa_update_area (area
);
7819 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7820 ospf_max_metric_router_lsa_shutdown_cmd
,
7821 "max-metric router-lsa on-shutdown (5-100)",
7822 "OSPF maximum / infinite-distance metric\n"
7823 "Advertise own Router-LSA with infinite distance (stub router)\n"
7824 "Advertise stub-router prior to full shutdown of OSPF\n"
7825 "Time (seconds) to wait till full shutdown\n")
7827 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7829 unsigned int seconds
;
7833 vty_out (vty
, "%% Must supply stub-router shutdown period");
7837 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7839 ospf
->stub_router_shutdown_time
= seconds
;
7844 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7845 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7846 "no max-metric router-lsa on-shutdown [(5-100)]",
7848 "OSPF maximum / infinite-distance metric\n"
7849 "Advertise own Router-LSA with infinite distance (stub router)\n"
7850 "Advertise stub-router prior to full shutdown of OSPF\n"
7851 "Time (seconds) to wait till full shutdown\n")
7853 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7855 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7861 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7863 struct listnode
*ln
;
7864 struct ospf_area
*area
;
7866 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7867 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7868 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7869 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7870 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7871 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7872 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7874 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7876 vty_out (vty
, " max-metric router-lsa administrative%s",
7885 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7887 struct route_node
*rn
;
7888 struct ospf_route
*or;
7889 struct listnode
*pnode
, *pnnode
;
7890 struct ospf_path
*path
;
7892 vty_out (vty
, "============ OSPF network routing table ============%s",
7895 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7896 if ((or = rn
->info
) != NULL
)
7899 snprintf (buf1
, 19, "%s/%d",
7900 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7902 switch (or->path_type
)
7904 case OSPF_PATH_INTER_AREA
:
7905 if (or->type
== OSPF_DESTINATION_NETWORK
)
7906 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7907 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7908 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7909 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7911 case OSPF_PATH_INTRA_AREA
:
7912 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7913 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7919 if (or->type
== OSPF_DESTINATION_NETWORK
)
7920 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7922 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7924 if (path
->nexthop
.s_addr
== 0)
7925 vty_out (vty
, "%24s directly attached to %s%s",
7926 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7928 vty_out (vty
, "%24s via %s, %s%s", "",
7929 inet_ntoa (path
->nexthop
),
7930 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7934 vty_out (vty
, "%s", VTY_NEWLINE
);
7938 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7940 struct route_node
*rn
;
7941 struct ospf_route
*or;
7942 struct listnode
*pnode
;
7943 struct listnode
*node
;
7944 struct ospf_path
*path
;
7946 vty_out (vty
, "============ OSPF router routing table =============%s",
7948 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7953 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7955 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7958 vty_out (vty
, "%24s", "");
7961 vty_out (vty
, "%s [%d] area: %s",
7962 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7963 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7965 vty_out (vty
, "%s%s%s",
7966 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
7967 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
7970 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
7972 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7974 if (path
->nexthop
.s_addr
== 0)
7975 vty_out (vty
, "%24s directly attached to %s%s",
7976 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7979 vty_out (vty
, "%24s via %s, %s%s", "",
7980 inet_ntoa (path
->nexthop
),
7981 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7987 vty_out (vty
, "%s", VTY_NEWLINE
);
7991 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
7993 struct route_node
*rn
;
7994 struct ospf_route
*er
;
7995 struct listnode
*pnode
, *pnnode
;
7996 struct ospf_path
*path
;
7998 vty_out (vty
, "============ OSPF external routing table ===========%s",
8000 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8001 if ((er
= rn
->info
) != NULL
)
8004 snprintf (buf1
, 19, "%s/%d",
8005 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8007 switch (er
->path_type
)
8009 case OSPF_PATH_TYPE1_EXTERNAL
:
8010 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8011 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8013 case OSPF_PATH_TYPE2_EXTERNAL
:
8014 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8015 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8019 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8021 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
8023 if (path
->nexthop
.s_addr
== 0)
8024 vty_out (vty
, "%24s directly attached to %s%s",
8025 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
8027 vty_out (vty
, "%24s via %s, %s%s", "",
8028 inet_ntoa (path
->nexthop
),
8029 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
8034 vty_out (vty
, "%s", VTY_NEWLINE
);
8038 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8041 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8042 VTY_NEWLINE
, VTY_NEWLINE
);
8044 if (ospf
->new_table
== NULL
)
8046 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8050 /* Show Network routes.
8051 show_ip_ospf_route_network (vty, ospf->new_table); */
8053 /* Show Router routes. */
8054 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8056 vty_out (vty
, "%s", VTY_NEWLINE
);
8061 DEFUN (show_ip_ospf_border_routers
,
8062 show_ip_ospf_border_routers_cmd
,
8063 "show ip ospf border-routers",
8066 "OSPF information\n"
8067 "Show all the ABR's and ASBR's\n")
8071 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8074 return show_ip_ospf_border_routers_common(vty
, ospf
);
8077 DEFUN (show_ip_ospf_instance_border_routers
,
8078 show_ip_ospf_instance_border_routers_cmd
,
8079 "show ip ospf (1-65535) border-routers",
8082 "OSPF information\n"
8084 "Show all the ABR's and ASBR's\n")
8088 u_short instance
= 0;
8090 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8091 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8094 return show_ip_ospf_border_routers_common(vty
, ospf
);
8098 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8101 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8102 VTY_NEWLINE
, VTY_NEWLINE
);
8104 if (ospf
->new_table
== NULL
)
8106 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8110 /* Show Network routes. */
8111 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8113 /* Show Router routes. */
8114 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8116 /* Show AS External routes. */
8117 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8119 vty_out (vty
, "%s", VTY_NEWLINE
);
8124 DEFUN (show_ip_ospf_route
,
8125 show_ip_ospf_route_cmd
,
8126 "show ip ospf route",
8129 "OSPF information\n"
8130 "OSPF routing table\n")
8134 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8137 return show_ip_ospf_route_common(vty
, ospf
);
8140 DEFUN (show_ip_ospf_instance_route
,
8141 show_ip_ospf_instance_route_cmd
,
8142 "show ip ospf (1-65535) route",
8145 "OSPF information\n"
8147 "OSPF routing table\n")
8151 u_short instance
= 0;
8153 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8154 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8157 return show_ip_ospf_route_common(vty
, ospf
);
8160 const char *ospf_abr_type_str
[] =
8169 const char *ospf_shortcut_mode_str
[] =
8176 const char *ospf_int_type_str
[] =
8178 "unknown", /* should never be used. */
8182 "point-to-multipoint",
8183 "virtual-link", /* should never be used. */
8187 /* Configuration write function for ospfd. */
8189 config_write_interface (struct vty
*vty
)
8191 struct listnode
*n1
, *n2
;
8192 struct interface
*ifp
;
8193 struct crypt_key
*ck
;
8195 struct route_node
*rn
= NULL
;
8196 struct ospf_if_params
*params
;
8197 struct ospf
*ospf
= ospf_lookup();
8199 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8201 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8204 if (ifp
->ifindex
== IFINDEX_DELETED
)
8207 vty_out (vty
, "!%s", VTY_NEWLINE
);
8208 vty_out (vty
, "interface %s%s", ifp
->name
,
8211 vty_out (vty
, " description %s%s", ifp
->desc
,
8216 params
= IF_DEF_PARAMS (ifp
);
8219 /* Interface Network print. */
8220 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8221 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8223 if (params
->type
!= ospf_default_iftype(ifp
))
8225 vty_out (vty
, " ip ospf network %s",
8226 ospf_int_type_str
[params
->type
]);
8227 if (params
!= IF_DEF_PARAMS (ifp
))
8228 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8229 vty_out (vty
, "%s", VTY_NEWLINE
);
8233 /* OSPF interface authentication print */
8234 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8235 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8237 const char *auth_str
;
8239 /* Translation tables are not that much help here due to syntax
8240 of the simple option */
8241 switch (params
->auth_type
)
8244 case OSPF_AUTH_NULL
:
8248 case OSPF_AUTH_SIMPLE
:
8252 case OSPF_AUTH_CRYPTOGRAPHIC
:
8253 auth_str
= " message-digest";
8261 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8262 if (params
!= IF_DEF_PARAMS (ifp
))
8263 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8264 vty_out (vty
, "%s", VTY_NEWLINE
);
8267 /* Simple Authentication Password print. */
8268 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8269 params
->auth_simple
[0] != '\0')
8271 vty_out (vty
, " ip ospf authentication-key %s",
8272 params
->auth_simple
);
8273 if (params
!= IF_DEF_PARAMS (ifp
))
8274 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8275 vty_out (vty
, "%s", VTY_NEWLINE
);
8278 /* Cryptographic Authentication Key print. */
8279 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8281 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8282 ck
->key_id
, ck
->auth_key
);
8283 if (params
!= IF_DEF_PARAMS (ifp
))
8284 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8285 vty_out (vty
, "%s", VTY_NEWLINE
);
8288 /* Interface Output Cost print. */
8289 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8291 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8292 if (params
!= IF_DEF_PARAMS (ifp
))
8293 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8294 vty_out (vty
, "%s", VTY_NEWLINE
);
8297 /* Hello Interval print. */
8298 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8299 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8301 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8302 if (params
!= IF_DEF_PARAMS (ifp
))
8303 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8304 vty_out (vty
, "%s", VTY_NEWLINE
);
8308 /* Router Dead Interval print. */
8309 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8310 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8312 vty_out (vty
, " ip ospf dead-interval ");
8315 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8316 vty_out (vty
, "minimal hello-multiplier %d",
8317 params
->fast_hello
);
8319 vty_out (vty
, "%u", params
->v_wait
);
8321 if (params
!= IF_DEF_PARAMS (ifp
))
8322 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8323 vty_out (vty
, "%s", VTY_NEWLINE
);
8326 /* Router Priority print. */
8327 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8328 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8330 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8331 if (params
!= IF_DEF_PARAMS (ifp
))
8332 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8333 vty_out (vty
, "%s", VTY_NEWLINE
);
8336 /* Retransmit Interval print. */
8337 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8338 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8340 vty_out (vty
, " ip ospf retransmit-interval %u",
8341 params
->retransmit_interval
);
8342 if (params
!= IF_DEF_PARAMS (ifp
))
8343 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8344 vty_out (vty
, "%s", VTY_NEWLINE
);
8347 /* Transmit Delay print. */
8348 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8349 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8351 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8352 if (params
!= IF_DEF_PARAMS (ifp
))
8353 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8354 vty_out (vty
, "%s", VTY_NEWLINE
);
8358 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8361 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8362 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8364 vty_out (vty
, " ip ospf area %s%s",
8365 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8370 ospf_bfd_write_config(vty
, params
);
8372 /* MTU ignore print. */
8373 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8374 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8376 if (params
->mtu_ignore
== 0)
8377 vty_out (vty
, " no ip ospf mtu-ignore");
8379 vty_out (vty
, " ip ospf mtu-ignore");
8380 if (params
!= IF_DEF_PARAMS (ifp
))
8381 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8382 vty_out (vty
, "%s", VTY_NEWLINE
);
8389 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8391 rn
= route_next (rn
);
8401 ospf_opaque_config_write_if (vty
, ifp
);
8408 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8410 struct route_node
*rn
;
8411 u_char buf
[INET_ADDRSTRLEN
];
8413 /* `network area' print. */
8414 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8417 struct ospf_network
*n
= rn
->info
;
8419 memset (buf
, 0, INET_ADDRSTRLEN
);
8421 /* Create Area ID string by specified Area ID format. */
8422 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8423 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8425 sprintf ((char *) buf
, "%lu",
8426 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8428 /* Network print. */
8429 vty_out (vty
, " network %s/%d area %s%s",
8430 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8438 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8440 struct listnode
*node
;
8441 struct ospf_area
*area
;
8442 u_char buf
[INET_ADDRSTRLEN
];
8444 /* Area configuration print. */
8445 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8447 struct route_node
*rn1
;
8449 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8452 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8454 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8455 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8457 vty_out (vty
, " area %s authentication message-digest%s",
8461 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8462 vty_out (vty
, " area %s shortcut %s%s", buf
,
8463 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8466 if ((area
->external_routing
== OSPF_AREA_STUB
)
8467 || (area
->external_routing
== OSPF_AREA_NSSA
)
8470 if (area
->external_routing
== OSPF_AREA_STUB
)
8471 vty_out (vty
, " area %s stub", buf
);
8472 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8474 vty_out (vty
, " area %s nssa", buf
);
8475 switch (area
->NSSATranslatorRole
)
8477 case OSPF_NSSA_ROLE_NEVER
:
8478 vty_out (vty
, " translate-never");
8480 case OSPF_NSSA_ROLE_ALWAYS
:
8481 vty_out (vty
, " translate-always");
8483 case OSPF_NSSA_ROLE_CANDIDATE
:
8485 vty_out (vty
, " translate-candidate");
8489 if (area
->no_summary
)
8490 vty_out (vty
, " no-summary");
8492 vty_out (vty
, "%s", VTY_NEWLINE
);
8494 if (area
->default_cost
!= 1)
8495 vty_out (vty
, " area %s default-cost %d%s", buf
,
8496 area
->default_cost
, VTY_NEWLINE
);
8499 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8502 struct ospf_area_range
*range
= rn1
->info
;
8504 vty_out (vty
, " area %s range %s/%d", buf
,
8505 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8507 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8508 vty_out (vty
, " cost %d", range
->cost_config
);
8510 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8511 vty_out (vty
, " not-advertise");
8513 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8514 vty_out (vty
, " substitute %s/%d",
8515 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8517 vty_out (vty
, "%s", VTY_NEWLINE
);
8520 if (EXPORT_NAME (area
))
8521 vty_out (vty
, " area %s export-list %s%s", buf
,
8522 EXPORT_NAME (area
), VTY_NEWLINE
);
8524 if (IMPORT_NAME (area
))
8525 vty_out (vty
, " area %s import-list %s%s", buf
,
8526 IMPORT_NAME (area
), VTY_NEWLINE
);
8528 if (PREFIX_NAME_IN (area
))
8529 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8530 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8532 if (PREFIX_NAME_OUT (area
))
8533 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8534 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8541 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8543 struct ospf_nbr_nbma
*nbr_nbma
;
8544 struct route_node
*rn
;
8546 /* Static Neighbor configuration print. */
8547 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8548 if ((nbr_nbma
= rn
->info
))
8550 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8552 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8553 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8555 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8556 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8558 vty_out (vty
, "%s", VTY_NEWLINE
);
8565 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8567 struct listnode
*node
;
8568 struct ospf_vl_data
*vl_data
;
8569 char buf
[INET_ADDRSTRLEN
];
8571 /* Virtual-Link print */
8572 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8574 struct listnode
*n2
;
8575 struct crypt_key
*ck
;
8576 struct ospf_interface
*oi
;
8578 if (vl_data
!= NULL
)
8580 memset (buf
, 0, INET_ADDRSTRLEN
);
8582 area_id2str (buf
, sizeof(buf
), &vl_data
->vl_area_id
, vl_data
->vl_area_id_fmt
);
8583 oi
= vl_data
->vl_oi
;
8586 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8587 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8588 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8589 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8590 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8592 inet_ntoa (vl_data
->vl_peer
),
8593 OSPF_IF_PARAM (oi
, v_hello
),
8594 OSPF_IF_PARAM (oi
, retransmit_interval
),
8595 OSPF_IF_PARAM (oi
, transmit_delay
),
8596 OSPF_IF_PARAM (oi
, v_wait
),
8599 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8600 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8602 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8603 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8605 inet_ntoa (vl_data
->vl_peer
),
8606 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8609 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8611 vty_out (vty
, " area %s virtual-link %s"
8612 " message-digest-key %d md5 %s%s",
8614 inet_ntoa (vl_data
->vl_peer
),
8615 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8625 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8629 /* redistribute print. */
8630 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8632 struct list
*red_list
;
8633 struct listnode
*node
;
8634 struct ospf_redist
*red
;
8636 red_list
= ospf
->redist
[type
];
8640 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8642 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8644 vty_out (vty
, " %d", red
->instance
);
8646 if (red
->dmetric
.value
>= 0)
8647 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8649 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8650 vty_out (vty
, " metric-type 1");
8652 if (ROUTEMAP_NAME (red
))
8653 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8655 vty_out (vty
, "%s", VTY_NEWLINE
);
8663 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8665 if (ospf
->default_metric
!= -1)
8666 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8672 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8675 struct ospf_redist
*red
;
8679 /* distribute-list print. */
8680 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8681 if (DISTRIBUTE_NAME (ospf
, type
))
8682 vty_out (vty
, " distribute-list %s out %s%s",
8683 DISTRIBUTE_NAME (ospf
, type
),
8684 zebra_route_string(type
), VTY_NEWLINE
);
8686 /* default-information print. */
8687 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8689 vty_out (vty
, " default-information originate");
8690 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8691 vty_out (vty
, " always");
8693 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8696 if (red
->dmetric
.value
>= 0)
8697 vty_out (vty
, " metric %d",
8698 red
->dmetric
.value
);
8699 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8700 vty_out (vty
, " metric-type 1");
8702 if (ROUTEMAP_NAME (red
))
8703 vty_out (vty
, " route-map %s",
8704 ROUTEMAP_NAME (red
));
8707 vty_out (vty
, "%s", VTY_NEWLINE
);
8716 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8718 struct route_node
*rn
;
8719 struct ospf_distance
*odistance
;
8721 if (ospf
->distance_all
)
8722 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8724 if (ospf
->distance_intra
8725 || ospf
->distance_inter
8726 || ospf
->distance_external
)
8728 vty_out (vty
, " distance ospf");
8730 if (ospf
->distance_intra
)
8731 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8732 if (ospf
->distance_inter
)
8733 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8734 if (ospf
->distance_external
)
8735 vty_out (vty
, " external %d", ospf
->distance_external
);
8737 vty_out (vty
, "%s", VTY_NEWLINE
);
8740 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8741 if ((odistance
= rn
->info
) != NULL
)
8743 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8744 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8745 odistance
->access_list
? odistance
->access_list
: "",
8751 /* OSPF configuration write function. */
8753 ospf_config_write (struct vty
*vty
)
8756 struct interface
*ifp
;
8757 struct ospf_interface
*oi
;
8758 struct listnode
*node
;
8761 ospf
= ospf_lookup ();
8762 if (ospf
!= NULL
&& ospf
->oi_running
)
8764 /* `router ospf' print. */
8766 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8768 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8772 if (!ospf
->networks
)
8775 /* Router ID print. */
8776 if (ospf
->router_id_static
.s_addr
!= 0)
8777 vty_out (vty
, " ospf router-id %s%s",
8778 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8780 /* ABR type print. */
8781 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8782 vty_out (vty
, " ospf abr-type %s%s",
8783 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8785 /* log-adjacency-changes flag print. */
8786 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8788 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8789 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8790 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8791 vty_out(vty
, " log-adjacency-changes%s", VTY_NEWLINE
);
8793 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8795 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8798 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8799 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8800 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8802 /* auto-cost reference-bandwidth configuration. */
8803 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8805 vty_out (vty
, "! Important: ensure reference bandwidth "
8806 "is consistent across all routers%s", VTY_NEWLINE
);
8807 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8808 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8811 /* SPF timers print. */
8812 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8813 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8814 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8815 vty_out (vty
, " timers throttle spf %d %d %d%s",
8816 ospf
->spf_delay
, ospf
->spf_holdtime
,
8817 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8819 /* LSA timers print. */
8820 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8821 vty_out (vty
, " timers throttle lsa all %d%s",
8822 ospf
->min_ls_interval
, VTY_NEWLINE
);
8823 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8824 vty_out (vty
, " timers lsa min-arrival %d%s",
8825 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8827 /* Write multiplier print. */
8828 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8829 vty_out (vty
, " ospf write-multiplier %d%s",
8830 ospf
->write_oi_count
, VTY_NEWLINE
);
8832 /* Max-metric router-lsa print */
8833 config_write_stub_router (vty
, ospf
);
8835 /* SPF refresh parameters print. */
8836 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8837 vty_out (vty
, " refresh timer %d%s",
8838 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8840 /* Redistribute information print. */
8841 config_write_ospf_redistribute (vty
, ospf
);
8843 /* passive-interface print. */
8844 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8845 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8847 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8848 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8849 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8850 ospf
->passive_interface_default
)
8852 vty_out (vty
, " %spassive-interface %s%s",
8853 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8854 ifp
->name
, VTY_NEWLINE
);
8856 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8858 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8860 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8863 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8866 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8869 vty_out (vty
, " %spassive-interface %s %s%s",
8870 oi
->params
->passive_interface
? "" : "no ",
8872 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8875 /* Network area print. */
8876 config_write_network_area (vty
, ospf
);
8878 /* Area config print. */
8879 config_write_ospf_area (vty
, ospf
);
8881 /* static neighbor print. */
8882 config_write_ospf_nbr_nbma (vty
, ospf
);
8884 /* Virtual-Link print. */
8885 config_write_virtual_link (vty
, ospf
);
8887 /* Default metric configuration. */
8888 config_write_ospf_default_metric (vty
, ospf
);
8890 /* Distribute-list and default-information print. */
8891 config_write_ospf_distribute (vty
, ospf
);
8893 /* Distance configuration. */
8894 config_write_ospf_distance (vty
, ospf
);
8896 ospf_opaque_config_write_router (vty
, ospf
);
8903 ospf_vty_show_init (void)
8905 /* "show ip ospf" commands. */
8906 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8908 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8910 /* "show ip ospf database" commands. */
8911 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8912 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8914 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8915 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8916 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8918 /* "show ip ospf interface" commands. */
8919 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8921 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8923 /* "show ip ospf neighbor" commands. */
8924 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8925 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8926 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8927 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8928 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8929 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8930 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8932 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8933 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8934 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8935 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8936 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8937 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8938 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8940 /* "show ip ospf route" commands. */
8941 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8942 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8944 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8945 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8949 /* ospfd's interface node. */
8950 static struct cmd_node interface_node
=
8957 /* Initialization of OSPF interface. */
8959 ospf_vty_if_init (void)
8961 /* Install interface node. */
8962 install_node (&interface_node
, config_write_interface
);
8965 /* "ip ospf authentication" commands. */
8966 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8967 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8968 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
8969 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8970 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8971 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8972 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
8974 /* "ip ospf message-digest-key" commands. */
8975 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8976 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8978 /* "ip ospf cost" commands. */
8979 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8980 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8982 /* "ip ospf mtu-ignore" commands. */
8983 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8984 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8986 /* "ip ospf dead-interval" commands. */
8987 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8988 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
8989 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8991 /* "ip ospf hello-interval" commands. */
8992 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
8993 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
8995 /* "ip ospf network" commands. */
8996 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
8997 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
8999 /* "ip ospf priority" commands. */
9000 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9001 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9003 /* "ip ospf retransmit-interval" commands. */
9004 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9005 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9007 /* "ip ospf transmit-delay" commands. */
9008 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9009 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9011 /* "ip ospf area" commands. */
9012 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9013 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9015 /* These commands are compatibitliy for previous version. */
9016 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9017 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9018 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9019 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9020 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9021 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9022 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9023 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9024 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9025 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9026 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9027 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9028 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9029 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9030 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9031 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9032 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9036 ospf_vty_zebra_init (void)
9038 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9039 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9040 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9041 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9043 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9044 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9046 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9047 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9049 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9050 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9052 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9053 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9054 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9055 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9057 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9058 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9059 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9060 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9064 static struct cmd_node ospf_node
=
9067 "%s(config-router)# ",
9072 ospf_interface_clear (struct interface
*ifp
)
9074 if (!if_is_operative (ifp
)) return;
9076 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9077 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9082 DEFUN (clear_ip_ospf_interface
,
9083 clear_ip_ospf_interface_cmd
,
9084 "clear ip ospf interface [IFNAME]",
9087 "OSPF information\n"
9088 "Interface information\n"
9092 struct interface
*ifp
;
9093 struct listnode
*node
;
9095 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9097 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9098 ospf_interface_clear(ifp
);
9100 else /* Interface name is specified. */
9102 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
, VRF_DEFAULT
)) == NULL
)
9103 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9105 ospf_interface_clear(ifp
);
9112 ospf_vty_clear_init (void)
9114 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9118 /* Install OSPF related vty commands. */
9120 ospf_vty_init (void)
9122 /* Install ospf top node. */
9123 install_node (&ospf_node
, ospf_config_write
);
9125 /* "router ospf" commands. */
9126 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9127 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9130 install_default (OSPF_NODE
);
9132 /* "ospf router-id" commands. */
9133 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9134 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9135 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9137 /* "passive-interface" commands. */
9138 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9139 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9141 /* "ospf abr-type" commands. */
9142 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9143 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9145 /* "ospf log-adjacency-changes" commands. */
9146 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9147 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9148 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9149 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9151 /* "ospf rfc1583-compatible" commands. */
9152 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9153 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9154 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9155 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9157 /* "network area" commands. */
9158 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9159 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9161 /* "area authentication" commands. */
9162 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9163 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9164 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9166 /* "area range" commands. */
9167 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9168 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9169 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9170 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9171 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9172 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9174 /* "area virtual-link" commands. */
9175 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9176 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9177 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9178 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9189 /* "area stub" commands. */
9190 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9191 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9192 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9193 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9195 /* "area nssa" commands. */
9196 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9197 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9198 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9199 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9200 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9202 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9203 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9205 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9206 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9208 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9209 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9211 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9212 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9214 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9215 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9217 /* SPF timer commands */
9218 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9219 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9221 /* LSA timers commands */
9222 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9223 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9224 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9225 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9226 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9227 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9229 /* refresh timer commands */
9230 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9231 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9233 /* max-metric commands */
9234 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9235 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9236 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9237 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9238 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9239 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9241 /* reference bandwidth commands */
9242 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9243 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9245 /* "neighbor" commands. */
9246 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9247 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9248 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9249 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9251 /* write multiplier commands */
9252 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9253 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9254 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9255 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9257 /* Init interface related vty commands. */
9258 ospf_vty_if_init ();
9260 /* Init zebra related vty commands. */
9261 ospf_vty_zebra_init ();