2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 #include "ospfd/ospfd.h"
39 #include "ospfd/ospf_asbr.h"
40 #include "ospfd/ospf_lsa.h"
41 #include "ospfd/ospf_lsdb.h"
42 #include "ospfd/ospf_ism.h"
43 #include "ospfd/ospf_interface.h"
44 #include "ospfd/ospf_nsm.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_flood.h"
47 #include "ospfd/ospf_abr.h"
48 #include "ospfd/ospf_spf.h"
49 #include "ospfd/ospf_route.h"
50 #include "ospfd/ospf_zebra.h"
51 /*#include "ospfd/ospf_routemap.h" */
52 #include "ospfd/ospf_vty.h"
53 #include "ospfd/ospf_dump.h"
54 #include "ospfd/ospf_bfd.h"
56 static const char *ospf_network_type_str
[] =
67 /* Utility functions. */
69 ospf_str2area_id (const char *str
, struct in_addr
*area_id
, int *format
)
74 /* match "A.B.C.D". */
75 if (strchr (str
, '.') != NULL
)
77 ret
= inet_aton (str
, area_id
);
80 *format
= OSPF_AREA_ID_FORMAT_ADDRESS
;
82 /* match "<0-4294967295>". */
88 ret
= strtoul (str
, &endptr
, 10);
89 if (*endptr
!= '\0' || errno
|| ret
> UINT32_MAX
)
92 area_id
->s_addr
= htonl (ret
);
93 *format
= OSPF_AREA_ID_FORMAT_DECIMAL
;
101 str2metric (const char *str
, int *metric
)
107 *metric
= strtol (str
, NULL
, 10);
108 if (*metric
< 0 && *metric
> 16777214)
110 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
118 str2metric_type (const char *str
, int *metric_type
)
124 if (strncmp (str
, "1", 1) == 0)
125 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
126 else if (strncmp (str
, "2", 1) == 0)
127 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
135 ospf_oi_count (struct interface
*ifp
)
137 struct route_node
*rn
;
140 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
147 DEFUN_NOSH (router_ospf
,
149 "router ospf [(1-65535)]",
150 "Enable a routing process\n"
151 "Start OSPF configuration\n"
155 u_short instance
= 0;
157 ospf
= ospf_lookup();
160 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
165 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
167 /* The following logic to set the vty qobj index is in place to be able
168 to ignore the commands which dont belong to this instance. */
169 if (ospf
->instance
!= instance
)
170 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
173 if (IS_DEBUG_OSPF_EVENT
)
174 zlog_debug ("Config command 'router ospf %d' received", instance
);
175 ospf
->oi_running
= 1;
176 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
177 ospf_router_id_update (ospf
);
183 DEFUN (no_router_ospf
,
185 "no router ospf [(1-65535)]",
187 "Enable a routing process\n"
188 "Start OSPF configuration\n"
192 u_short instance
= 0;
195 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
197 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
206 DEFUN (ospf_router_id
,
208 "ospf router-id A.B.C.D",
209 "OSPF specific commands\n"
210 "router-id for the OSPF process\n"
211 "OSPF router-id in IP address format\n")
213 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
215 struct listnode
*node
;
216 struct ospf_area
*area
;
217 struct in_addr router_id
;
220 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
223 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
227 ospf
->router_id_static
= router_id
;
229 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
232 vty_out (vty
, "For this router-id change to take effect,"
233 " save config and restart ospfd%s", VTY_NEWLINE
);
237 ospf_router_id_update (ospf
);
242 DEFUN_HIDDEN (ospf_router_id_old
,
243 ospf_router_id_old_cmd
,
245 "router-id for the OSPF process\n"
246 "OSPF router-id in IP address format\n")
248 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
250 struct listnode
*node
;
251 struct ospf_area
*area
;
252 struct in_addr router_id
;
255 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
258 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
262 ospf
->router_id_static
= router_id
;
264 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
267 vty_out (vty
, "For this router-id change to take effect,"
268 " save config and restart ospfd%s", VTY_NEWLINE
);
272 ospf_router_id_update (ospf
);
277 DEFUN (no_ospf_router_id
,
278 no_ospf_router_id_cmd
,
279 "no ospf router-id [A.B.C.D]",
281 "OSPF specific commands\n"
282 "router-id for the OSPF process\n"
283 "OSPF router-id in IP address format\n")
285 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
286 struct listnode
*node
;
287 struct ospf_area
*area
;
289 ospf
->router_id_static
.s_addr
= 0;
291 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
294 vty_out (vty
, "For this router-id change to take effect,"
295 " save config and restart ospfd%s", VTY_NEWLINE
);
299 ospf_router_id_update (ospf
);
306 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
309 struct interface
*ifp
;
310 struct ospf_interface
*oi
;
312 ospf
->passive_interface_default
= newval
;
314 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
317 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
318 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
320 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
322 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
323 UNSET_IF_PARAM (oi
->params
, passive_interface
);
324 /* update multicast memberships */
325 ospf_if_set_multicast(oi
);
330 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
331 struct ospf_if_params
*params
, u_char value
,
336 params
->passive_interface
= value
;
337 if (params
!= IF_DEF_PARAMS (ifp
))
339 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
340 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
342 dflt
= ospf
->passive_interface_default
;
345 SET_IF_PARAM (params
, passive_interface
);
347 UNSET_IF_PARAM (params
, passive_interface
);
349 ospf_free_if_params (ifp
, addr
);
350 ospf_if_update_params (ifp
, addr
);
355 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
356 struct ospf_if_params
*params
, u_char value
)
358 params
->passive_interface
= value
;
359 if (params
== IF_DEF_PARAMS (ifp
))
361 if (value
!= ospf
->passive_interface_default
)
362 SET_IF_PARAM (params
, passive_interface
);
364 UNSET_IF_PARAM (params
, passive_interface
);
368 DEFUN (ospf_passive_interface
,
369 ospf_passive_interface_addr_cmd
,
370 "passive-interface <IFNAME [A.B.C.D]|default>",
371 "Suppress routing updates on an interface\n"
374 "Suppress routing updates on interfaces by default\n")
376 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
378 struct interface
*ifp
;
379 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
381 struct ospf_if_params
*params
;
382 struct route_node
*rn
;
384 if (strcmp (argv
[1]->text
, "default") == 0)
386 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
390 ifp
= if_get_by_name (argv
[1]->arg
, VRF_DEFAULT
);
392 params
= IF_DEF_PARAMS (ifp
);
396 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
399 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
404 params
= ospf_get_if_params (ifp
, addr
);
405 ospf_if_update_params (ifp
, addr
);
406 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
407 OSPF_IF_PASSIVE
, addr
);
410 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
412 /* XXX We should call ospf_if_set_multicast on exactly those
413 * interfaces for which the passive property changed. It is too much
414 * work to determine this set, so we do this for every interface.
415 * This is safe and reasonable because ospf_if_set_multicast uses a
416 * record of joined groups to avoid systems calls if the desired
417 * memberships match the current memership.
420 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
422 struct ospf_interface
*oi
= rn
->info
;
424 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
425 ospf_if_set_multicast(oi
);
428 * XXX It is not clear what state transitions the interface needs to
429 * undergo when going from active to passive. Fixing this will
430 * require precise identification of interfaces having such a
437 DEFUN (no_ospf_passive_interface
,
438 no_ospf_passive_interface_addr_cmd
,
439 "no passive-interface <IFNAME [A.B.C.D]|default>",
441 "Allow routing updates on an interface\n"
444 "Allow routing updates on interfaces by default\n")
446 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
448 struct interface
*ifp
;
449 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
450 struct ospf_if_params
*params
;
452 struct route_node
*rn
;
454 if (strcmp (argv
[2]->text
, "default") == 0)
456 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
460 ifp
= if_get_by_name (argv
[2]->arg
, VRF_DEFAULT
);
462 params
= IF_DEF_PARAMS (ifp
);
466 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
469 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
474 params
= ospf_lookup_if_params (ifp
, addr
);
477 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
480 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
482 /* XXX We should call ospf_if_set_multicast on exactly those
483 * interfaces for which the passive property changed. It is too much
484 * work to determine this set, so we do this for every interface.
485 * This is safe and reasonable because ospf_if_set_multicast uses a
486 * record of joined groups to avoid systems calls if the desired
487 * memberships match the current memership.
489 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
491 struct ospf_interface
*oi
= rn
->info
;
493 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
494 ospf_if_set_multicast(oi
);
502 DEFUN (ospf_network_area
,
503 ospf_network_area_cmd
,
504 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
505 "Enable routing on an IP network\n"
506 "OSPF network prefix\n"
507 "Set the OSPF area ID\n"
508 "OSPF area ID in IP address format\n"
509 "OSPF area ID as a decimal value\n")
511 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
512 int idx_ipv4_prefixlen
= 1;
513 int idx_ipv4_number
= 3;
514 struct prefix_ipv4 p
;
515 struct in_addr area_id
;
520 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
525 if (ospf
->if_ospf_cli_count
> 0)
527 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
532 /* Get network prefix and Area ID. */
533 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
534 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
536 ret
= ospf_network_set (ospf
, &p
, area_id
);
539 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
546 DEFUN (no_ospf_network_area
,
547 no_ospf_network_area_cmd
,
548 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
550 "Enable routing on an IP network\n"
551 "OSPF network prefix\n"
552 "Set the OSPF area ID\n"
553 "OSPF area ID in IP address format\n"
554 "OSPF area ID as a decimal value\n")
556 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
557 int idx_ipv4_prefixlen
= 2;
558 int idx_ipv4_number
= 4;
559 struct prefix_ipv4 p
;
560 struct in_addr area_id
;
565 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
570 /* Get network prefix and Area ID. */
571 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
572 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
574 ret
= ospf_network_unset (ospf
, &p
, area_id
);
577 vty_out (vty
, "Can't find specified network area configuration.%s",
585 DEFUN (ospf_area_range
,
587 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
588 "OSPF area parameters\n"
589 "OSPF area ID in IP address format\n"
590 "OSPF area ID as a decimal value\n"
591 "Summarize routes matching address/mask (border routers only)\n"
592 "Area range prefix\n"
593 "Advertise this range (default)\n"
594 "User specified metric for this range\n"
595 "Advertised metric for this range\n")
597 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
598 int idx_ipv4_number
= 1;
599 int idx_ipv4_prefixlen
= 3;
601 struct prefix_ipv4 p
;
602 struct in_addr area_id
;
606 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
607 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
609 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
612 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
613 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
619 DEFUN (ospf_area_range_cost
,
620 ospf_area_range_cost_cmd
,
621 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
622 "OSPF area parameters\n"
623 "OSPF area ID in IP address format\n"
624 "OSPF area ID as a decimal value\n"
625 "Summarize routes matching address/mask (border routers only)\n"
626 "Area range prefix\n"
627 "User specified metric for this range\n"
628 "Advertised metric for this range\n")
630 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
631 int idx_ipv4_number
= 1;
632 int idx_ipv4_prefixlen
= 3;
634 struct prefix_ipv4 p
;
635 struct in_addr area_id
;
639 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
640 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
642 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
644 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
645 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
650 DEFUN (ospf_area_range_not_advertise
,
651 ospf_area_range_not_advertise_cmd
,
652 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
653 "OSPF area parameters\n"
654 "OSPF area ID in IP address format\n"
655 "OSPF area ID as a decimal value\n"
656 "Summarize routes matching address/mask (border routers only)\n"
657 "Area range prefix\n"
658 "DoNotAdvertise this range\n")
660 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
661 int idx_ipv4_number
= 1;
662 int idx_ipv4_prefixlen
= 3;
663 struct prefix_ipv4 p
;
664 struct in_addr area_id
;
667 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
668 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
670 ospf_area_range_set (ospf
, area_id
, &p
, 0);
675 DEFUN (no_ospf_area_range
,
676 no_ospf_area_range_cmd
,
677 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
679 "OSPF area parameters\n"
680 "OSPF area ID in IP address format\n"
681 "OSPF area ID as a decimal value\n"
682 "Summarize routes matching address/mask (border routers only)\n"
683 "Area range prefix\n"
684 "User specified metric for this range\n"
685 "Advertised metric for this range\n"
686 "Advertise this range (default)\n"
687 "User specified metric for this range\n"
688 "Advertised metric for this range\n"
689 "DoNotAdvertise this range\n")
691 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
692 int idx_ipv4_number
= 2;
693 int idx_ipv4_prefixlen
= 4;
694 struct prefix_ipv4 p
;
695 struct in_addr area_id
;
698 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
699 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
701 ospf_area_range_unset (ospf
, area_id
, &p
);
706 DEFUN (ospf_area_range_substitute
,
707 ospf_area_range_substitute_cmd
,
708 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
709 "OSPF area parameters\n"
710 "OSPF area ID in IP address format\n"
711 "OSPF area ID as a decimal value\n"
712 "Summarize routes matching address/mask (border routers only)\n"
713 "Area range prefix\n"
714 "Announce area range as another prefix\n"
715 "Network prefix to be announced instead of range\n")
717 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
718 int idx_ipv4_number
= 1;
719 int idx_ipv4_prefixlen
= 3;
720 int idx_ipv4_prefixlen_2
= 5;
721 struct prefix_ipv4 p
, s
;
722 struct in_addr area_id
;
725 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
726 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
727 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
729 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
734 DEFUN (no_ospf_area_range_substitute
,
735 no_ospf_area_range_substitute_cmd
,
736 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
738 "OSPF area parameters\n"
739 "OSPF area ID in IP address format\n"
740 "OSPF area ID as a decimal value\n"
741 "Summarize routes matching address/mask (border routers only)\n"
742 "Area range prefix\n"
743 "Announce area range as another prefix\n"
744 "Network prefix to be announced instead of range\n")
746 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
747 int idx_ipv4_number
= 2;
748 int idx_ipv4_prefixlen
= 4;
749 int idx_ipv4_prefixlen_2
= 6;
750 struct prefix_ipv4 p
, s
;
751 struct in_addr area_id
;
754 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
755 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
756 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
758 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
764 /* Command Handler Logic in VLink stuff is delicate!!
766 ALTER AT YOUR OWN RISK!!!!
768 Various dummy values are used to represent 'NoChange' state for
769 VLink configuration NOT being changed by a VLink command, and
770 special syntax is used within the command strings so that the
771 typed in command verbs can be seen in the configuration command
772 bacckend handler. This is to drastically reduce the verbeage
773 required to coe up with a reasonably compatible Cisco VLink command
775 - Matthew Grant <grantma@anathoth.gen.nz>
776 Wed, 21 Feb 2001 15:13:52 +1300
779 /* Configuration data for virtual links
781 struct ospf_vl_config_data
{
782 struct vty
*vty
; /* vty stuff */
783 struct in_addr area_id
; /* area ID from command line */
784 int format
; /* command line area ID format */
785 struct in_addr vl_peer
; /* command line vl_peer */
786 int auth_type
; /* Authehntication type, if given */
787 char *auth_key
; /* simple password if present */
788 int crypto_key_id
; /* Cryptographic key ID */
789 char *md5_key
; /* MD5 authentication key */
790 int hello_interval
; /* Obvious what these are... */
791 int retransmit_interval
;
797 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
800 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
801 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
802 vl_config
->vty
= vty
;
805 static struct ospf_vl_data
*
806 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
808 struct ospf_area
*area
;
809 struct ospf_vl_data
*vl_data
;
811 struct in_addr area_id
;
813 vty
= vl_config
->vty
;
814 area_id
= vl_config
->area_id
;
816 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
819 "Configuring VLs over the backbone is not allowed%s",
823 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
825 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
827 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
828 vty_out (vty
, "Area %s is %s%s",
830 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
833 vty_out (vty
, "Area %ld is %s%s",
834 (u_long
)ntohl (area_id
.s_addr
),
835 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
840 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
842 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
843 if (vl_data
->vl_oi
== NULL
)
845 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
846 ospf_vl_add (ospf
, vl_data
);
847 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
855 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
856 struct ospf_vl_config_data
*vl_config
)
858 struct crypt_key
*ck
;
860 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
862 vty
= vl_config
->vty
;
864 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
866 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
867 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
870 if (vl_config
->auth_key
)
872 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
873 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
874 OSPF_AUTH_SIMPLE_SIZE
);
876 else if (vl_config
->md5_key
)
878 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
881 vty_out (vty
, "OSPF: Key %d already exists%s",
882 vl_config
->crypto_key_id
, VTY_NEWLINE
);
885 ck
= ospf_crypt_key_new ();
886 ck
->key_id
= vl_config
->crypto_key_id
;
887 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
888 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
890 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
892 else if (vl_config
->crypto_key_id
!= 0)
896 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
897 vl_config
->crypto_key_id
) == NULL
)
899 vty_out (vty
, "OSPF: Key %d does not exist%s",
900 vl_config
->crypto_key_id
, VTY_NEWLINE
);
904 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
912 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
913 struct ospf_vl_config_data
*vl_config
)
915 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
916 /* Virtual Link data initialised to defaults, so only set
918 if (vl_config
->hello_interval
)
920 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
921 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
924 if (vl_config
->dead_interval
)
926 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
927 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
930 if (vl_config
->retransmit_interval
)
932 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
933 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
936 if (vl_config
->transmit_delay
)
938 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
939 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
946 /* The business end of all of the above */
948 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
950 struct ospf_vl_data
*vl_data
;
953 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
957 /* Process this one first as it can have a fatal result, which can
958 only logically occur if the virtual link exists already
959 Thus a command error does not result in a change to the
960 running configuration such as unexpectedly altered timer
962 ret
= ospf_vl_set_security (vl_data
, vl_config
);
963 if (ret
!= CMD_SUCCESS
)
966 /* Set any time based parameters, these area already range checked */
968 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
969 if (ret
!= CMD_SUCCESS
)
976 /* This stuff exists to make specifying all the alias commands A LOT simpler
978 #define VLINK_HELPSTR_IPADDR \
979 "OSPF area parameters\n" \
980 "OSPF area ID in IP address format\n" \
981 "OSPF area ID as a decimal value\n" \
982 "Configure a virtual link\n" \
983 "Router ID of the remote ABR\n"
985 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
986 "Enable authentication on this virtual link\n" \
989 #define VLINK_HELPSTR_AUTHTYPE_ALL \
990 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
991 "Use null authentication\n" \
992 "Use message-digest authentication\n"
994 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
995 "Time between HELLO packets\n" \
996 "Time between retransmitting lost link state advertisements\n" \
997 "Link state transmit delay\n" \
998 "Interval time after which a neighbor is declared down\n"
1000 #define VLINK_HELPSTR_TIME_PARAM \
1001 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1004 #define VLINK_HELPSTR_AUTH_SIMPLE \
1005 "Authentication password (key)\n" \
1006 "The OSPF password (key)"
1008 #define VLINK_HELPSTR_AUTH_MD5 \
1009 "Message digest authentication password (key)\n" \
1012 "Use MD5 algorithm\n" \
1013 "The OSPF password (key)"
1015 DEFUN (ospf_area_vlink
,
1016 ospf_area_vlink_cmd
,
1017 "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>]",
1018 VLINK_HELPSTR_IPADDR
1019 "Enable authentication on this virtual link\n" \
1020 "Use null authentication\n" \
1021 "Use message-digest authentication\n"
1022 "Message digest authentication password (key)\n" \
1024 "Use MD5 algorithm\n" \
1025 "The OSPF password (key)")
1027 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1028 int idx_ipv4_number
= 1;
1030 struct ospf_vl_config_data vl_config
;
1031 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1032 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1036 ospf_vl_config_data_init(&vl_config
, vty
);
1038 /* Read off first 2 parameters and check them */
1039 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &vl_config
.format
);
1042 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1046 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1049 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1056 /* Thats all folks! - BUGS B. strikes again!!!*/
1058 return ospf_vl_set (ospf
, &vl_config
);
1061 /* Deal with other parameters */
1062 for (i
=5; i
< argc
; i
++)
1065 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1067 switch (argv
[i
]->arg
[0])
1071 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1073 /* authentication-key - this option can occur anywhere on
1074 command line. At start of command line
1075 must check for authentication option. */
1076 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1077 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1078 vl_config
.auth_key
= auth_key
;
1081 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1083 /* authentication - this option can only occur at start
1085 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1088 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1090 /* "authentication null" */
1091 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1094 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1095 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1097 /* "authentication message-digest" */
1098 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1106 /* message-digest-key */
1110 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1111 if (vl_config
.crypto_key_id
< 0)
1116 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1117 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1118 vl_config
.md5_key
= md5_key
;
1122 vl_config
.md5_key
= NULL
;
1128 /* Action configuration */
1130 return ospf_vl_set (ospf
, &vl_config
);
1134 DEFUN (ospf_area_vlink_intervals
,
1135 ospf_area_vlink_intervals_cmd
,
1136 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
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)"
1140 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1142 VLINK_HELPSTR_IPADDR
1143 VLINK_HELPSTR_TIME_PARAM
1144 VLINK_HELPSTR_TIME_PARAM
1145 VLINK_HELPSTR_TIME_PARAM
1146 VLINK_HELPSTR_TIME_PARAM
)
1148 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1149 struct ospf_vl_config_data vl_config
;
1152 ospf_vl_config_data_init(&vl_config
, vty
);
1154 char *area_id
= argv
[1]->arg
;
1155 char *router_id
= argv
[3]->arg
;
1157 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1160 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1164 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1167 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1170 for (unsigned int i
= 0; i
< 4; i
++)
1173 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1174 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1175 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1176 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1177 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1178 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1179 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1180 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1183 /* Action configuration */
1184 return ospf_vl_set (ospf
, &vl_config
);
1187 DEFUN (no_ospf_area_vlink
,
1188 no_ospf_area_vlink_cmd
,
1189 "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>]",
1191 VLINK_HELPSTR_IPADDR
1192 "Enable authentication on this virtual link\n" \
1193 "Use null authentication\n" \
1194 "Use message-digest authentication\n"
1195 "Message digest authentication password (key)\n" \
1197 "Use MD5 algorithm\n" \
1198 "The OSPF password (key)")
1200 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1201 int idx_ipv4_number
= 2;
1203 struct ospf_area
*area
;
1204 struct ospf_vl_config_data vl_config
;
1205 struct ospf_vl_data
*vl_data
= NULL
;
1206 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1210 ospf_vl_config_data_init(&vl_config
, vty
);
1212 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1215 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1219 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1222 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1226 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1229 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1236 /* Basic VLink no command */
1237 /* Thats all folks! - BUGS B. strikes again!!!*/
1238 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1239 ospf_vl_delete (ospf
, vl_data
);
1241 ospf_area_check_free (ospf
, vl_config
.area_id
);
1246 /* If we are down here, we are reseting parameters */
1248 /* Deal with other parameters */
1249 for (i
=6; i
< argc
; i
++)
1251 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1253 switch (argv
[i
]->arg
[0])
1257 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1259 /* authentication-key - this option can occur anywhere on
1260 command line. At start of command line
1261 must check for authentication option. */
1262 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1263 vl_config
.auth_key
= auth_key
;
1265 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1267 /* authentication - this option can only occur at start
1269 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1274 /* message-digest-key */
1275 /* Delete one key */
1279 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1280 if (vl_config
.crypto_key_id
< 0)
1282 vl_config
.md5_key
= NULL
;
1292 /* Action configuration */
1294 return ospf_vl_set (ospf
, &vl_config
);
1297 DEFUN (no_ospf_area_vlink_intervals
,
1298 no_ospf_area_vlink_intervals_cmd
,
1299 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
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)"
1303 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1306 VLINK_HELPSTR_IPADDR
1307 VLINK_HELPSTR_TIME_PARAM
1308 VLINK_HELPSTR_TIME_PARAM
1309 VLINK_HELPSTR_TIME_PARAM
1310 VLINK_HELPSTR_TIME_PARAM
)
1312 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1313 struct ospf_vl_config_data vl_config
;
1316 ospf_vl_config_data_init(&vl_config
, vty
);
1318 char *area_id
= argv
[2]->arg
;
1319 char *router_id
= argv
[4]->arg
;
1321 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1324 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1328 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1331 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1335 for (unsigned int i
= 0; i
< 4; i
++)
1338 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1339 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1340 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1341 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1342 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1343 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1344 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1345 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1348 /* Action configuration */
1349 return ospf_vl_set (ospf
, &vl_config
);
1352 DEFUN (ospf_area_shortcut
,
1353 ospf_area_shortcut_cmd
,
1354 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1355 "OSPF area parameters\n"
1356 "OSPF area ID in IP address format\n"
1357 "OSPF area ID as a decimal value\n"
1358 "Configure the area's shortcutting mode\n"
1359 "Set default shortcutting behavior\n"
1360 "Enable shortcutting through the area\n"
1361 "Disable shortcutting through the area\n")
1363 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1364 int idx_ipv4_number
= 1;
1365 int idx_enable_disable
= 3;
1366 struct ospf_area
*area
;
1367 struct in_addr area_id
;
1371 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1373 area
= ospf_area_get (ospf
, area_id
, 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
);
1441 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1446 ospf_area_no_summary_unset (ospf
, area_id
);
1451 DEFUN (ospf_area_stub_no_summary
,
1452 ospf_area_stub_no_summary_cmd
,
1453 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1454 "OSPF stub parameters\n"
1455 "OSPF area ID in IP address format\n"
1456 "OSPF area ID as a decimal value\n"
1457 "Configure OSPF area as stub\n"
1458 "Do not inject inter-area routes into stub\n")
1460 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1461 int idx_ipv4_number
= 1;
1462 struct in_addr area_id
;
1465 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1467 ret
= ospf_area_stub_set (ospf
, area_id
);
1470 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1475 ospf_area_no_summary_set (ospf
, area_id
);
1480 DEFUN (no_ospf_area_stub
,
1481 no_ospf_area_stub_cmd
,
1482 "no area <A.B.C.D|(0-4294967295)> stub",
1484 "OSPF area parameters\n"
1485 "OSPF area ID in IP address format\n"
1486 "OSPF area ID as a decimal value\n"
1487 "Configure OSPF area as stub\n")
1489 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1490 int idx_ipv4_number
= 2;
1491 struct in_addr area_id
;
1494 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1496 ospf_area_stub_unset (ospf
, area_id
);
1497 ospf_area_no_summary_unset (ospf
, area_id
);
1502 DEFUN (no_ospf_area_stub_no_summary
,
1503 no_ospf_area_stub_no_summary_cmd
,
1504 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1506 "OSPF area parameters\n"
1507 "OSPF area ID in IP address format\n"
1508 "OSPF area ID as a decimal value\n"
1509 "Configure OSPF area as stub\n"
1510 "Do not inject inter-area routes into area\n")
1512 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1513 int idx_ipv4_number
= 2;
1514 struct in_addr area_id
;
1517 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1518 ospf_area_no_summary_unset (ospf
, area_id
);
1524 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1527 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1528 struct in_addr area_id
;
1531 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1533 ret
= ospf_area_nssa_set (ospf
, area_id
);
1536 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1543 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1544 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1545 OSPF_NSSA_ROLE_CANDIDATE
);
1546 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1547 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1548 OSPF_NSSA_ROLE_NEVER
);
1549 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1550 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1551 OSPF_NSSA_ROLE_ALWAYS
);
1555 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1556 OSPF_NSSA_ROLE_CANDIDATE
);
1560 ospf_area_no_summary_set (ospf
, area_id
);
1562 ospf_area_no_summary_unset (ospf
, area_id
);
1564 ospf_schedule_abr_task (ospf
);
1569 DEFUN (ospf_area_nssa_translate_no_summary
,
1570 ospf_area_nssa_translate_no_summary_cmd
,
1571 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1572 "OSPF area parameters\n"
1573 "OSPF area ID in IP address format\n"
1574 "OSPF area ID as a decimal value\n"
1575 "Configure OSPF area as nssa\n"
1576 "Configure NSSA-ABR for translate election (default)\n"
1577 "Configure NSSA-ABR to never translate\n"
1578 "Configure NSSA-ABR to always translate\n"
1579 "Do not inject inter-area routes into nssa\n")
1581 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1584 DEFUN (ospf_area_nssa_translate
,
1585 ospf_area_nssa_translate_cmd
,
1586 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1587 "OSPF area parameters\n"
1588 "OSPF area ID in IP address format\n"
1589 "OSPF area ID as a decimal value\n"
1590 "Configure OSPF area as nssa\n"
1591 "Configure NSSA-ABR for translate election (default)\n"
1592 "Configure NSSA-ABR to never translate\n"
1593 "Configure NSSA-ABR to always translate\n")
1595 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1598 DEFUN (ospf_area_nssa
,
1600 "area <A.B.C.D|(0-4294967295)> nssa",
1601 "OSPF area parameters\n"
1602 "OSPF area ID in IP address format\n"
1603 "OSPF area ID as a decimal value\n"
1604 "Configure OSPF area as nssa\n")
1606 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1609 DEFUN (ospf_area_nssa_no_summary
,
1610 ospf_area_nssa_no_summary_cmd
,
1611 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1612 "OSPF area parameters\n"
1613 "OSPF area ID in IP address format\n"
1614 "OSPF area ID as a decimal value\n"
1615 "Configure OSPF area as nssa\n"
1616 "Do not inject inter-area routes into nssa\n")
1618 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1621 DEFUN (no_ospf_area_nssa
,
1622 no_ospf_area_nssa_cmd
,
1623 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1625 "OSPF area parameters\n"
1626 "OSPF area ID in IP address format\n"
1627 "OSPF area ID as a decimal value\n"
1628 "Configure OSPF area as nssa\n"
1629 "Configure NSSA-ABR for translate election (default)\n"
1630 "Configure NSSA-ABR to never translate\n"
1631 "Configure NSSA-ABR to always translate\n"
1632 "Do not inject inter-area routes into nssa\n")
1634 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1635 int idx_ipv4_number
= 2;
1636 struct in_addr area_id
;
1639 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1641 ospf_area_nssa_unset (ospf
, area_id
);
1642 ospf_area_no_summary_unset (ospf
, area_id
);
1644 ospf_schedule_abr_task (ospf
);
1650 DEFUN (ospf_area_default_cost
,
1651 ospf_area_default_cost_cmd
,
1652 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1653 "OSPF area parameters\n"
1654 "OSPF area ID in IP address format\n"
1655 "OSPF area ID as a decimal value\n"
1656 "Set the summary-default cost of a NSSA or stub area\n"
1657 "Stub's advertised default summary cost\n")
1659 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1660 int idx_ipv4_number
= 1;
1662 struct ospf_area
*area
;
1663 struct in_addr area_id
;
1666 struct prefix_ipv4 p
;
1668 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1669 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1671 area
= ospf_area_get (ospf
, area_id
, format
);
1673 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1675 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1679 area
->default_cost
= cost
;
1682 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1684 if (IS_DEBUG_OSPF_EVENT
)
1685 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1686 "announcing 0.0.0.0/0 to area %s",
1687 inet_ntoa (area
->area_id
));
1688 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1693 DEFUN (no_ospf_area_default_cost
,
1694 no_ospf_area_default_cost_cmd
,
1695 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1697 "OSPF area parameters\n"
1698 "OSPF area ID in IP address format\n"
1699 "OSPF area ID as a decimal value\n"
1700 "Set the summary-default cost of a NSSA or stub area\n"
1701 "Stub's advertised default summary cost\n")
1703 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1704 int idx_ipv4_number
= 2;
1706 struct ospf_area
*area
;
1707 struct in_addr area_id
;
1709 struct prefix_ipv4 p
;
1711 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1712 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1714 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1718 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1720 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1724 area
->default_cost
= 1;
1727 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1729 if (IS_DEBUG_OSPF_EVENT
)
1730 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1731 "announcing 0.0.0.0/0 to area %s",
1732 inet_ntoa (area
->area_id
));
1733 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1736 ospf_area_check_free (ospf
, area_id
);
1741 DEFUN (ospf_area_export_list
,
1742 ospf_area_export_list_cmd
,
1743 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1744 "OSPF area parameters\n"
1745 "OSPF area ID in IP address format\n"
1746 "OSPF area ID as a decimal value\n"
1747 "Set the filter for networks announced to other areas\n"
1748 "Name of the access-list\n")
1750 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1751 int idx_ipv4_number
= 1;
1752 struct ospf_area
*area
;
1753 struct in_addr area_id
;
1756 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1758 area
= ospf_area_get (ospf
, area_id
, format
);
1759 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1764 DEFUN (no_ospf_area_export_list
,
1765 no_ospf_area_export_list_cmd
,
1766 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1768 "OSPF area parameters\n"
1769 "OSPF area ID in IP address format\n"
1770 "OSPF area ID as a decimal value\n"
1771 "Unset the filter for networks announced to other areas\n"
1772 "Name of the access-list\n")
1774 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1775 int idx_ipv4_number
= 2;
1776 struct ospf_area
*area
;
1777 struct in_addr area_id
;
1780 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1782 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1786 ospf_area_export_list_unset (ospf
, area
);
1792 DEFUN (ospf_area_import_list
,
1793 ospf_area_import_list_cmd
,
1794 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1795 "OSPF area parameters\n"
1796 "OSPF area ID in IP address format\n"
1797 "OSPF area ID as a decimal value\n"
1798 "Set the filter for networks from other areas announced to the specified one\n"
1799 "Name of the access-list\n")
1801 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1802 int idx_ipv4_number
= 1;
1803 struct ospf_area
*area
;
1804 struct in_addr area_id
;
1807 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1809 area
= ospf_area_get (ospf
, area_id
, format
);
1810 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1815 DEFUN (no_ospf_area_import_list
,
1816 no_ospf_area_import_list_cmd
,
1817 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1819 "OSPF area parameters\n"
1820 "OSPF area ID in IP address format\n"
1821 "OSPF area ID as a decimal value\n"
1822 "Unset the filter for networks announced to other areas\n"
1823 "Name of the access-list\n")
1825 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1826 int idx_ipv4_number
= 2;
1827 struct ospf_area
*area
;
1828 struct in_addr area_id
;
1831 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1833 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1837 ospf_area_import_list_unset (ospf
, area
);
1842 DEFUN (ospf_area_filter_list
,
1843 ospf_area_filter_list_cmd
,
1844 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1845 "OSPF area parameters\n"
1846 "OSPF area ID in IP address format\n"
1847 "OSPF area ID as a decimal value\n"
1848 "Filter networks between OSPF areas\n"
1849 "Filter prefixes between OSPF areas\n"
1850 "Name of an IP prefix-list\n"
1851 "Filter networks sent to this area\n"
1852 "Filter networks sent from this area\n")
1854 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1855 int idx_ipv4_number
= 1;
1858 struct ospf_area
*area
;
1859 struct in_addr area_id
;
1860 struct prefix_list
*plist
;
1863 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1865 area
= ospf_area_get (ospf
, area_id
, format
);
1866 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1867 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1869 PREFIX_LIST_IN (area
) = plist
;
1870 if (PREFIX_NAME_IN (area
))
1871 free (PREFIX_NAME_IN (area
));
1873 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1874 ospf_schedule_abr_task (ospf
);
1878 PREFIX_LIST_OUT (area
) = plist
;
1879 if (PREFIX_NAME_OUT (area
))
1880 free (PREFIX_NAME_OUT (area
));
1882 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1883 ospf_schedule_abr_task (ospf
);
1889 DEFUN (no_ospf_area_filter_list
,
1890 no_ospf_area_filter_list_cmd
,
1891 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1893 "OSPF area parameters\n"
1894 "OSPF area ID in IP address format\n"
1895 "OSPF area ID as a decimal value\n"
1896 "Filter networks between OSPF areas\n"
1897 "Filter prefixes between OSPF areas\n"
1898 "Name of an IP prefix-list\n"
1899 "Filter networks sent to this area\n"
1900 "Filter networks sent from this area\n")
1902 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1903 int idx_ipv4_number
= 2;
1906 struct ospf_area
*area
;
1907 struct in_addr area_id
;
1910 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1912 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1915 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1917 if (PREFIX_NAME_IN (area
))
1918 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1921 PREFIX_LIST_IN (area
) = NULL
;
1922 if (PREFIX_NAME_IN (area
))
1923 free (PREFIX_NAME_IN (area
));
1925 PREFIX_NAME_IN (area
) = NULL
;
1927 ospf_schedule_abr_task (ospf
);
1931 if (PREFIX_NAME_OUT (area
))
1932 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1935 PREFIX_LIST_OUT (area
) = NULL
;
1936 if (PREFIX_NAME_OUT (area
))
1937 free (PREFIX_NAME_OUT (area
));
1939 PREFIX_NAME_OUT (area
) = NULL
;
1941 ospf_schedule_abr_task (ospf
);
1948 DEFUN (ospf_area_authentication_message_digest
,
1949 ospf_area_authentication_message_digest_cmd
,
1950 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1951 "OSPF area parameters\n"
1952 "OSPF area ID in IP address format\n"
1953 "OSPF area ID as a decimal value\n"
1954 "Enable authentication\n"
1955 "Use message-digest authentication\n")
1957 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1958 int idx_ipv4_number
= 1;
1959 struct ospf_area
*area
;
1960 struct in_addr area_id
;
1963 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1965 area
= ospf_area_get (ospf
, area_id
, format
);
1966 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1971 DEFUN (ospf_area_authentication
,
1972 ospf_area_authentication_cmd
,
1973 "area <A.B.C.D|(0-4294967295)> authentication",
1974 "OSPF area parameters\n"
1975 "OSPF area ID in IP address format\n"
1976 "OSPF area ID as a decimal value\n"
1977 "Enable authentication\n")
1979 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1980 int idx_ipv4_number
= 1;
1981 struct ospf_area
*area
;
1982 struct in_addr area_id
;
1985 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1987 area
= ospf_area_get (ospf
, area_id
, format
);
1988 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1993 DEFUN (no_ospf_area_authentication
,
1994 no_ospf_area_authentication_cmd
,
1995 "no area <A.B.C.D|(0-4294967295)> authentication",
1997 "OSPF area parameters\n"
1998 "OSPF area ID in IP address format\n"
1999 "OSPF area ID as a decimal value\n"
2000 "Enable authentication\n")
2002 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2003 int idx_ipv4_number
= 2;
2004 struct ospf_area
*area
;
2005 struct in_addr area_id
;
2008 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2010 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2014 area
->auth_type
= OSPF_AUTH_NULL
;
2016 ospf_area_check_free (ospf
, area_id
);
2022 DEFUN (ospf_abr_type
,
2024 "ospf abr-type <cisco|ibm|shortcut|standard>",
2025 "OSPF specific commands\n"
2026 "Set OSPF ABR type\n"
2027 "Alternative ABR, cisco implementation\n"
2028 "Alternative ABR, IBM implementation\n"
2030 "Standard behavior (RFC2328)\n")
2032 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2034 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2036 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2037 abr_type
= OSPF_ABR_CISCO
;
2038 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2039 abr_type
= OSPF_ABR_IBM
;
2040 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2041 abr_type
= OSPF_ABR_SHORTCUT
;
2042 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2043 abr_type
= OSPF_ABR_STAND
;
2047 /* If ABR type value is changed, schedule ABR task. */
2048 if (ospf
->abr_type
!= abr_type
)
2050 ospf
->abr_type
= abr_type
;
2051 ospf_schedule_abr_task (ospf
);
2057 DEFUN (no_ospf_abr_type
,
2058 no_ospf_abr_type_cmd
,
2059 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2061 "OSPF specific commands\n"
2062 "Set OSPF ABR type\n"
2063 "Alternative ABR, cisco implementation\n"
2064 "Alternative ABR, IBM implementation\n"
2068 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2070 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2072 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2073 abr_type
= OSPF_ABR_CISCO
;
2074 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2075 abr_type
= OSPF_ABR_IBM
;
2076 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2077 abr_type
= OSPF_ABR_SHORTCUT
;
2078 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2079 abr_type
= OSPF_ABR_STAND
;
2083 /* If ABR type value is changed, schedule ABR task. */
2084 if (ospf
->abr_type
== abr_type
)
2086 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2087 ospf_schedule_abr_task (ospf
);
2093 DEFUN (ospf_log_adjacency_changes
,
2094 ospf_log_adjacency_changes_cmd
,
2095 "log-adjacency-changes",
2096 "Log changes in adjacency state\n")
2098 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2100 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2101 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2105 DEFUN (ospf_log_adjacency_changes_detail
,
2106 ospf_log_adjacency_changes_detail_cmd
,
2107 "log-adjacency-changes detail",
2108 "Log changes in adjacency state\n"
2109 "Log all state changes\n")
2111 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2113 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2114 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2118 DEFUN (no_ospf_log_adjacency_changes
,
2119 no_ospf_log_adjacency_changes_cmd
,
2120 "no log-adjacency-changes",
2122 "Log changes in adjacency state\n")
2124 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2126 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2127 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2131 DEFUN (no_ospf_log_adjacency_changes_detail
,
2132 no_ospf_log_adjacency_changes_detail_cmd
,
2133 "no log-adjacency-changes detail",
2135 "Log changes in adjacency state\n"
2136 "Log all state changes\n")
2138 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2140 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2144 DEFUN (ospf_compatible_rfc1583
,
2145 ospf_compatible_rfc1583_cmd
,
2146 "compatible rfc1583",
2147 "OSPF compatibility list\n"
2148 "compatible with RFC 1583\n")
2150 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2152 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2154 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2155 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2160 DEFUN (no_ospf_compatible_rfc1583
,
2161 no_ospf_compatible_rfc1583_cmd
,
2162 "no compatible rfc1583",
2164 "OSPF compatibility list\n"
2165 "compatible with RFC 1583\n")
2167 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2169 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2171 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2172 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2177 ALIAS (ospf_compatible_rfc1583
,
2178 ospf_rfc1583_flag_cmd
,
2179 "ospf rfc1583compatibility",
2180 "OSPF specific commands\n"
2181 "Enable the RFC1583Compatibility flag\n")
2183 ALIAS (no_ospf_compatible_rfc1583
,
2184 no_ospf_rfc1583_flag_cmd
,
2185 "no ospf rfc1583compatibility",
2187 "OSPF specific commands\n"
2188 "Disable the RFC1583Compatibility flag\n")
2191 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2195 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2197 ospf
->spf_delay
= delay
;
2198 ospf
->spf_holdtime
= hold
;
2199 ospf
->spf_max_holdtime
= max
;
2204 DEFUN (ospf_timers_min_ls_interval
,
2205 ospf_timers_min_ls_interval_cmd
,
2206 "timers throttle lsa all (0-5000)",
2207 "Adjust routing timers\n"
2208 "Throttling adaptive timer\n"
2209 "LSA delay between transmissions\n"
2211 "Delay (msec) between sending LSAs\n")
2213 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2215 unsigned int interval
;
2219 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2223 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2225 ospf
->min_ls_interval
= interval
;
2230 DEFUN (no_ospf_timers_min_ls_interval
,
2231 no_ospf_timers_min_ls_interval_cmd
,
2232 "no timers throttle lsa all [(0-5000)]",
2234 "Adjust routing timers\n"
2235 "Throttling adaptive timer\n"
2236 "LSA delay between transmissions\n"
2238 "Delay (msec) between sending LSAs\n")
2240 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2241 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2247 DEFUN (ospf_timers_min_ls_arrival
,
2248 ospf_timers_min_ls_arrival_cmd
,
2249 "timers lsa arrival (0-1000)",
2250 "Adjust routing timers\n"
2251 "Throttling link state advertisement delays\n"
2252 "OSPF minimum arrival interval delay\n"
2253 "Delay (msec) between accepted LSAs\n")
2255 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2257 unsigned int arrival
;
2261 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2265 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2267 ospf
->min_ls_arrival
= arrival
;
2272 DEFUN (no_ospf_timers_min_ls_arrival
,
2273 no_ospf_timers_min_ls_arrival_cmd
,
2274 "no timers lsa arrival [(0-1000)]",
2276 "Adjust routing timers\n"
2277 "Throttling link state advertisement delays\n"
2278 "OSPF minimum arrival interval delay\n"
2279 "Delay (msec) between accepted LSAs\n")
2281 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2283 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2289 DEFUN (ospf_timers_throttle_spf
,
2290 ospf_timers_throttle_spf_cmd
,
2291 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2292 "Adjust routing timers\n"
2293 "Throttling adaptive timer\n"
2295 "Delay (msec) from first change received till SPF calculation\n"
2296 "Initial hold time (msec) between consecutive SPF calculations\n"
2297 "Maximum hold time (msec)\n")
2300 int idx_number_2
= 4;
2301 int idx_number_3
= 5;
2302 unsigned int delay
, hold
, max
;
2306 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2310 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2311 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2312 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2314 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2317 DEFUN (no_ospf_timers_throttle_spf
,
2318 no_ospf_timers_throttle_spf_cmd
,
2319 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2321 "Adjust routing timers\n"
2322 "Throttling adaptive timer\n"
2324 "Delay (msec) from first change received till SPF calculation\n"
2325 "Initial hold time (msec) between consecutive SPF calculations\n"
2326 "Maximum hold time (msec)\n")
2328 return ospf_timers_spf_set (vty
,
2329 OSPF_SPF_DELAY_DEFAULT
,
2330 OSPF_SPF_HOLDTIME_DEFAULT
,
2331 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2335 DEFUN (ospf_timers_lsa
,
2336 ospf_timers_lsa_cmd
,
2337 "timers lsa min-arrival (0-600000)",
2338 "Adjust routing timers\n"
2340 "Minimum delay in receiving new version of a LSA\n"
2341 "Delay in milliseconds\n")
2343 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2345 unsigned int minarrival
;
2349 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2353 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2355 ospf
->min_ls_arrival
= minarrival
;
2360 DEFUN (no_ospf_timers_lsa
,
2361 no_ospf_timers_lsa_cmd
,
2362 "no timers lsa min-arrival [(0-600000)]",
2364 "Adjust routing timers\n"
2366 "Minimum delay in receiving new version of a LSA\n"
2367 "Delay in milliseconds\n")
2369 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2370 unsigned int minarrival
;
2374 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2376 if (ospf
->min_ls_arrival
!= minarrival
||
2377 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2381 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2386 DEFUN (ospf_neighbor
,
2388 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2390 "Neighbor IP address\n"
2391 "Neighbor Priority\n"
2393 "Dead Neighbor Polling interval\n"
2396 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2400 struct in_addr nbr_addr
;
2401 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2402 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2404 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2407 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2410 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2412 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2415 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2418 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2423 DEFUN (ospf_neighbor_poll_interval
,
2424 ospf_neighbor_poll_interval_cmd
,
2425 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2427 "Neighbor IP address\n"
2428 "Dead Neighbor Polling interval\n"
2430 "OSPF priority of non-broadcast neighbor\n"
2433 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2437 struct in_addr nbr_addr
;
2438 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2439 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2441 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2443 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2446 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2448 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2449 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2452 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2457 DEFUN (no_ospf_neighbor
,
2458 no_ospf_neighbor_cmd
,
2459 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2462 "Neighbor IP address\n"
2463 "Neighbor Priority\n"
2465 "Dead Neighbor Polling interval\n"
2468 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2470 struct in_addr nbr_addr
;
2472 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2474 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2479 DEFUN (no_ospf_neighbor_poll
,
2480 no_ospf_neighbor_poll_cmd
,
2481 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2484 "Neighbor IP address\n"
2485 "Dead Neighbor Polling interval\n"
2487 "Neighbor Priority\n"
2490 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2492 struct in_addr nbr_addr
;
2494 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2496 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2501 DEFUN (ospf_refresh_timer
,
2502 ospf_refresh_timer_cmd
,
2503 "refresh timer (10-1800)",
2504 "Adjust refresh parameters\n"
2505 "Set refresh timer\n"
2506 "Timer value in seconds\n")
2508 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2510 unsigned int interval
;
2512 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2513 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2515 ospf_timers_refresh_set (ospf
, interval
);
2520 DEFUN (no_ospf_refresh_timer
,
2521 no_ospf_refresh_timer_val_cmd
,
2522 "no refresh timer [(10-1800)]",
2524 "Adjust refresh parameters\n"
2525 "Unset refresh timer\n"
2526 "Timer value in seconds\n")
2528 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2530 unsigned int interval
;
2534 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2536 if (ospf
->lsa_refresh_interval
!= interval
||
2537 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2541 ospf_timers_refresh_unset (ospf
);
2547 DEFUN (ospf_auto_cost_reference_bandwidth
,
2548 ospf_auto_cost_reference_bandwidth_cmd
,
2549 "auto-cost reference-bandwidth (1-4294967)",
2550 "Calculate OSPF interface cost according to bandwidth\n"
2551 "Use reference bandwidth method to assign OSPF cost\n"
2552 "The reference bandwidth in terms of Mbits per second\n")
2554 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2557 struct listnode
*node
;
2558 struct interface
*ifp
;
2560 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2561 if (refbw
< 1 || refbw
> 4294967)
2563 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2567 /* If reference bandwidth is changed. */
2568 if ((refbw
) == ospf
->ref_bandwidth
)
2571 ospf
->ref_bandwidth
= refbw
;
2572 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2573 ospf_if_recalculate_output_cost (ifp
);
2578 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2579 no_ospf_auto_cost_reference_bandwidth_cmd
,
2580 "no auto-cost reference-bandwidth [(1-4294967)]",
2582 "Calculate OSPF interface cost according to bandwidth\n"
2583 "Use reference bandwidth method to assign OSPF cost\n"
2584 "The reference bandwidth in terms of Mbits per second\n")
2586 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2587 struct listnode
*node
, *nnode
;
2588 struct interface
*ifp
;
2590 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2593 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2594 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2595 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2597 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2598 ospf_if_recalculate_output_cost (ifp
);
2603 DEFUN (ospf_write_multiplier
,
2604 ospf_write_multiplier_cmd
,
2605 "ospf write-multiplier (1-100)",
2606 "OSPF specific commands\n"
2607 "Write multiplier\n"
2608 "Maximum number of interface serviced per write\n")
2610 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2612 u_int32_t write_oi_count
;
2619 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2620 if (write_oi_count
< 1 || write_oi_count
> 100)
2622 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2626 ospf
->write_oi_count
= write_oi_count
;
2630 ALIAS (ospf_write_multiplier
,
2631 write_multiplier_cmd
,
2632 "write-multiplier (1-100)",
2633 "Write multiplier\n"
2634 "Maximum number of interface serviced per write\n")
2636 DEFUN (no_ospf_write_multiplier
,
2637 no_ospf_write_multiplier_cmd
,
2638 "no ospf write-multiplier (1-100)",
2640 "OSPF specific commands\n"
2641 "Write multiplier\n"
2642 "Maximum number of interface serviced per write\n")
2644 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2646 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2650 ALIAS (no_ospf_write_multiplier
,
2651 no_write_multiplier_cmd
,
2652 "no write-multiplier (1-100)",
2654 "Write multiplier\n"
2655 "Maximum number of interface serviced per write\n")
2657 const char *ospf_abr_type_descr_str
[] =
2660 "Standard (RFC2328)",
2662 "Alternative Cisco",
2663 "Alternative Shortcut"
2666 const char *ospf_shortcut_mode_descr_str
[] =
2674 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2676 json_object
*json_area
= NULL
;
2679 json_area
= json_object_new_object();
2683 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2685 /* Show Area type/mode. */
2686 if (OSPF_IS_AREA_BACKBONE (area
))
2689 json_object_boolean_true_add(json_area
, "backbone");
2691 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2697 if (area
->external_routing
== OSPF_AREA_STUB
)
2699 if (area
->no_summary
)
2700 json_object_boolean_true_add(json_area
, "stubNoSummary");
2701 if (area
->shortcut_configured
)
2702 json_object_boolean_true_add(json_area
, "stubShortcut");
2704 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2706 if (area
->no_summary
)
2707 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2708 if (area
->shortcut_configured
)
2709 json_object_boolean_true_add(json_area
, "nssaShortcut");
2712 json_object_string_add(json_area
,"shortcuttingMode",
2713 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2714 if (area
->shortcut_capability
)
2715 json_object_boolean_true_add(json_area
,"sBitConcensus");
2719 if (area
->external_routing
== OSPF_AREA_STUB
)
2720 vty_out (vty
, " (Stub%s%s)",
2721 area
->no_summary
? ", no summary" : "",
2722 area
->shortcut_configured
? "; " : "");
2723 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2724 vty_out (vty
, " (NSSA%s%s)",
2725 area
->no_summary
? ", no summary" : "",
2726 area
->shortcut_configured
? "; " : "");
2728 vty_out (vty
, "%s", VTY_NEWLINE
);
2729 vty_out (vty
, " Shortcutting mode: %s",
2730 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2731 vty_out (vty
, ", S-bit consensus: %s%s",
2732 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2736 /* Show number of interfaces */
2739 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2740 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2743 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2744 "Active: %d%s", listcount (area
->oiflist
),
2745 area
->act_ints
, VTY_NEWLINE
);
2747 if (area
->external_routing
== OSPF_AREA_NSSA
)
2751 json_object_boolean_true_add(json_area
, "nssa");
2752 if (! IS_OSPF_ABR (area
->ospf
))
2753 json_object_boolean_false_add(json_area
, "abr");
2754 else if (area
->NSSATranslatorState
)
2756 json_object_boolean_true_add(json_area
, "abr");
2757 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2758 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2759 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2760 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2764 json_object_boolean_true_add(json_area
, "abr");
2765 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2766 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2768 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2773 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2774 if (! IS_OSPF_ABR (area
->ospf
))
2775 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2777 else if (area
->NSSATranslatorState
)
2779 vty_out (vty
, " We are an ABR and ");
2780 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2781 vty_out (vty
, "the NSSA Elected Translator. %s",
2783 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2784 vty_out (vty
, "always an NSSA Translator. %s",
2789 vty_out (vty
, " We are an ABR, but ");
2790 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2791 vty_out (vty
, "not the NSSA Elected Translator. %s",
2794 vty_out (vty
, "never an NSSA Translator. %s",
2800 /* Stub-router state for this area */
2801 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2803 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2807 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2808 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2809 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2810 if (area
->t_stub_router
)
2813 time_store
= monotime_until(&area
->t_stub_router
->u
.sands
, NULL
) / 1000LL;
2814 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2819 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2821 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2822 vty_out (vty
, " Administratively activated (indefinitely)%s",
2824 if (area
->t_stub_router
)
2825 vty_out (vty
, " Active from startup, %s remaining%s",
2826 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2827 sizeof(timebuf
)), VTY_NEWLINE
);
2833 /* Show number of fully adjacent neighbors. */
2834 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2836 /* Show authentication type. */
2837 if (area
->auth_type
== OSPF_AUTH_NULL
)
2838 json_object_string_add(json_area
, "authentication", "authenticationNone");
2839 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2840 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2841 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2842 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2844 if (!OSPF_IS_AREA_BACKBONE (area
))
2845 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2847 /* Show SPF calculation times. */
2848 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2849 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2850 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2851 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2852 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2853 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2854 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2855 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2856 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2857 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2858 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2859 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2863 /* Show number of fully adjacent neighbors. */
2864 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2865 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2867 /* Show authentication type. */
2868 vty_out (vty
, " Area has ");
2869 if (area
->auth_type
== OSPF_AUTH_NULL
)
2870 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2871 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2872 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2873 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2874 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2876 if (!OSPF_IS_AREA_BACKBONE (area
))
2877 vty_out (vty
, " Number of full virtual adjacencies going through"
2878 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2880 /* Show SPF calculation times. */
2881 vty_out (vty
, " SPF algorithm executed %d times%s",
2882 area
->spf_calculation
, VTY_NEWLINE
);
2884 /* Show number of LSA. */
2885 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2886 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2887 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2888 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2889 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2890 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2891 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2892 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2893 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2894 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2895 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2896 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2897 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2898 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2899 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2900 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2905 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2906 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2907 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2908 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2912 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2913 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2914 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2915 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2916 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2917 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2921 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2923 vty_out (vty
, "%s", VTY_NEWLINE
);
2927 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2929 struct listnode
*node
, *nnode
;
2930 struct ospf_area
* area
;
2931 struct timeval result
;
2932 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2933 json_object
*json
= NULL
;
2934 json_object
*json_areas
= NULL
;
2938 json
= json_object_new_object();
2939 json_areas
= json_object_new_object();
2946 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2950 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2951 VTY_NEWLINE
, VTY_NEWLINE
);
2955 /* Show Router ID. */
2958 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2962 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2963 inet_ntoa (ospf
->router_id
),
2967 /* Graceful shutdown */
2968 if (ospf
->t_deferred_shutdown
)
2973 time_store
= monotime_until(&ospf
->t_deferred_shutdown
->u
.sands
, NULL
) / 1000LL;
2974 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2978 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2979 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2980 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2984 /* Show capability. */
2987 json_object_boolean_true_add(json
, "tosRoutesOnly");
2988 json_object_boolean_true_add(json
, "rfc2328Conform");
2989 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2991 json_object_boolean_true_add(json
, "rfc1583Compatibility");
2996 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
2997 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
2998 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
2999 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3000 "enabled" : "disabled", VTY_NEWLINE
);
3005 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3007 json_object_boolean_true_add(json
, "opaqueCapable");
3012 vty_out (vty
, " OpaqueCapability flag is %s%s",
3013 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3017 /* Show stub-router configuration */
3018 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3019 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3023 json_object_boolean_true_add(json
, "stubAdvertisement");
3024 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3025 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3026 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3027 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3031 vty_out (vty
, " Stub router advertisement is configured%s",
3033 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3034 vty_out (vty
, " Enabled for %us after start-up%s",
3035 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3036 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3037 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3038 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3042 /* Show SPF timers. */
3045 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3046 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3047 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3048 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3052 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3053 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3054 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3055 " Hold time multiplier is currently %d%s",
3056 ospf
->spf_delay
, VTY_NEWLINE
,
3057 ospf
->spf_holdtime
, VTY_NEWLINE
,
3058 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3059 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3064 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3066 long time_store
= 0;
3068 time_store
= monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3069 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3071 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3072 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3075 json_object_boolean_true_add(json
, "spfHasNotRun");
3079 vty_out (vty
, " SPF algorithm ");
3080 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3082 monotime_since(&ospf
->ts_spf
, &result
);
3083 vty_out (vty
, "last executed %s ago%s",
3084 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3086 vty_out (vty
, " Last SPF duration %s%s",
3087 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3091 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3096 if (ospf
->t_spf_calc
)
3099 time_store
= monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
) / 1000LL;
3100 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3103 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3104 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3105 /* Show write multiplier values */
3106 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3107 /* Show refresh parameters. */
3108 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3112 vty_out (vty
, " SPF timer %s%s%s",
3113 (ospf
->t_spf_calc
? "due in " : "is "),
3114 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3117 vty_out (vty
, " LSA minimum interval %d msecs%s",
3118 ospf
->min_ls_interval
, VTY_NEWLINE
);
3119 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3120 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3122 /* Show write multiplier values */
3123 vty_out (vty
, " Write Multiplier set to %d %s",
3124 ospf
->write_oi_count
, VTY_NEWLINE
);
3126 /* Show refresh parameters. */
3127 vty_out (vty
, " Refresh timer %d secs%s",
3128 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3131 /* Show ABR/ASBR flags. */
3132 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3135 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3137 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3138 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3140 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3143 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3145 vty_out (vty
, " This router is an ASBR "
3146 "(injecting external routing information)%s", VTY_NEWLINE
);
3149 /* Show Number of AS-external-LSAs. */
3152 json_object_int_add(json
, "lsaExternalCounter",
3153 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3154 json_object_int_add(json
, "lsaExternalChecksum",
3155 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3159 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3160 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3161 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3166 json_object_int_add(json
, "lsaAsopaqueCounter",
3167 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3168 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3169 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3173 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3174 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3175 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3178 /* Show number of areas attached. */
3180 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3182 vty_out (vty
, " Number of areas attached to this router: %d%s",
3183 listcount (ospf
->areas
), VTY_NEWLINE
);
3185 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3187 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3190 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3192 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3197 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3199 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3202 /* Show each area status. */
3203 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3204 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3208 json_object_object_add(json
, "areas", json_areas
);
3209 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3210 json_object_free(json
);
3213 vty_out (vty
, "%s",VTY_NEWLINE
);
3218 DEFUN (show_ip_ospf
,
3220 "show ip ospf [json]",
3223 "OSPF information\n"
3227 u_char uj
= use_json(argc
, argv
);
3229 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3232 return (show_ip_ospf_common(vty
, ospf
, uj
));
3235 DEFUN (show_ip_ospf_instance
,
3236 show_ip_ospf_instance_cmd
,
3237 "show ip ospf (1-65535) [json]",
3240 "OSPF information\n"
3246 u_short instance
= 0;
3247 u_char uj
= use_json(argc
, argv
);
3249 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3250 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3253 return (show_ip_ospf_common(vty
, ospf
, uj
));
3257 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3258 json_object
*json_interface_sub
, u_char use_json
)
3261 struct ospf_neighbor
*nbr
;
3262 struct route_node
*rn
;
3264 /* Is interface up? */
3267 is_up
= if_is_operative(ifp
);
3269 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3271 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3273 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3274 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3275 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3276 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3280 vty_out (vty
, "%s is %s%s", ifp
->name
,
3281 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3282 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3283 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3287 /* Is interface OSPF enabled? */
3290 if (ospf_oi_count(ifp
) == 0)
3292 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3297 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3301 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3305 if (ospf_oi_count(ifp
) == 0)
3307 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3312 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3318 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3320 struct ospf_interface
*oi
= rn
->info
;
3325 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3328 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3330 vty_out (vty
, " This interface is UNNUMBERED,");
3334 /* Show OSPF interface information. */
3337 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3338 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3341 vty_out (vty
, " Internet Address %s/%d,",
3342 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3344 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3346 struct in_addr
*dest
;
3349 if (CONNECTED_PEER(oi
->connected
)
3350 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3355 /* For Vlinks, showing the peer address is probably more
3356 * * * * * informative than the local interface that is being used
3358 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3359 dest
= &oi
->vl_data
->peer_addr
;
3361 dest
= &oi
->connected
->destination
->u
.prefix4
;
3365 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3366 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3367 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3369 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3372 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3377 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3378 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3379 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3380 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3381 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3382 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3383 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3384 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3385 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3389 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3392 vty_out (vty
, " MTU mismatch detection:%s%s",
3393 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3395 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3396 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3397 oi
->output_cost
, VTY_NEWLINE
);
3399 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3400 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3401 PRIORITY (oi
), VTY_NEWLINE
);
3404 /* Show DR information. */
3405 if (DR (oi
).s_addr
== 0)
3408 vty_out (vty
, " No backup designated router on this network%s",
3413 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3417 vty_out (vty
, " No backup designated router on this network%s",
3424 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3425 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3429 vty_out (vty
, " Backup Designated Router (ID) %s,",
3430 inet_ntoa (nbr
->router_id
));
3431 vty_out (vty
, " Interface Address %s%s",
3432 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3437 /* Next network-LSA sequence number we'll use, if we're elected DR */
3438 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3441 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3443 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3444 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3449 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3450 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3452 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3453 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3454 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3455 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3460 vty_out (vty
, " Multicast group memberships:");
3461 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3462 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3464 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3465 vty_out (vty
, " OSPFAllRouters");
3466 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3467 vty_out (vty
, " OSPFDesignatedRouters");
3470 vty_out (vty
, " <None>");
3471 vty_out (vty
, "%s", VTY_NEWLINE
);
3476 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3477 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3479 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3480 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3481 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3482 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3486 vty_out (vty
, " Timer intervals configured,");
3487 vty_out (vty
, " Hello ");
3488 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3489 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3491 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3492 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3493 OSPF_IF_PARAM (oi
, v_wait
),
3494 OSPF_IF_PARAM (oi
, v_wait
),
3495 OSPF_IF_PARAM (oi
, retransmit_interval
),
3499 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3501 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3504 long time_store
= 0;
3506 time_store
= monotime_until(&oi
->t_hello
->u
.sands
, NULL
) / 1000LL;
3507 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3510 vty_out (vty
, " Hello due in %s%s",
3511 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3514 else /* passive-interface is set */
3517 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3519 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3524 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3525 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3528 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3529 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3531 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3536 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3537 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3539 struct interface
*ifp
;
3540 struct listnode
*node
;
3541 json_object
*json
= NULL
;
3542 json_object
*json_interface_sub
= NULL
;
3546 json
= json_object_new_object();
3547 json_interface_sub
= json_object_new_object();
3553 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3555 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3556 VTY_NEWLINE
, VTY_NEWLINE
);
3559 if (argc
== iface_argv
)
3561 /* Show All Interfaces.*/
3562 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3564 if (ospf_oi_count(ifp
))
3566 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3568 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3574 /* Interface name is specified. */
3575 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
, VRF_DEFAULT
)) == NULL
)
3578 json_object_boolean_true_add(json
, "noSuchIface");
3580 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3584 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3586 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3592 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3593 json_object_free(json
);
3596 vty_out (vty
, "%s", VTY_NEWLINE
);
3601 DEFUN (show_ip_ospf_interface
,
3602 show_ip_ospf_interface_cmd
,
3603 "show ip ospf interface [INTERFACE] [json]",
3606 "OSPF information\n"
3607 "Interface information\n"
3612 u_char uj
= use_json(argc
, argv
);
3614 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3620 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3623 DEFUN (show_ip_ospf_instance_interface
,
3624 show_ip_ospf_instance_interface_cmd
,
3625 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3628 "OSPF information\n"
3630 "Interface information\n"
3636 u_short instance
= 0;
3637 u_char uj
= use_json(argc
, argv
);
3639 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3640 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3646 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3650 show_ip_ospf_neighbour_header (struct vty
*vty
)
3652 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3654 "Neighbor ID", "Pri", "State", "Dead Time",
3655 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3660 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3662 struct route_node
*rn
;
3663 struct ospf_neighbor
*nbr
;
3665 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3666 json_object
*json_neighbor
= NULL
;
3668 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3670 if ((nbr
= rn
->info
))
3672 /* Do not show myself. */
3673 if (nbr
!= oi
->nbr_self
)
3675 /* Down state is not shown. */
3676 if (nbr
->state
!= NSM_Down
)
3680 json_neighbor
= json_object_new_object();
3681 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3685 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
3687 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3688 json_object_string_add (json_neighbor
, "state", msgbuf
);
3689 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3690 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3691 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3692 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3693 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3694 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3695 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3696 json_object_object_add(json
, "neighbor", json_neighbor
);
3698 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3702 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3704 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3705 vty_out (vty
, "%-15s %3d %-15s ",
3709 vty_out (vty
, "%-15s %3d %-15s ",
3710 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3713 vty_out (vty
, "%9s ",
3714 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3716 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3717 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3718 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3719 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3729 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3731 struct ospf_interface
*oi
;
3732 struct listnode
*node
;
3733 json_object
*json
= NULL
;
3736 json
= json_object_new_object();
3738 show_ip_ospf_neighbour_header (vty
);
3743 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3745 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3746 VTY_NEWLINE
, VTY_NEWLINE
);
3749 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3750 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3754 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3755 json_object_free(json
);
3758 vty_out (vty
, "%s", VTY_NEWLINE
);
3763 DEFUN (show_ip_ospf_neighbor
,
3764 show_ip_ospf_neighbor_cmd
,
3765 "show ip ospf neighbor [json]",
3768 "OSPF information\n"
3773 u_char uj
= use_json(argc
, argv
);
3775 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3778 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3782 DEFUN (show_ip_ospf_instance_neighbor
,
3783 show_ip_ospf_instance_neighbor_cmd
,
3784 "show ip ospf (1-65535) neighbor [json]",
3787 "OSPF information\n"
3794 u_short instance
= 0;
3795 u_char uj
= use_json(argc
, argv
);
3797 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3798 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3801 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3805 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3807 struct listnode
*node
;
3808 struct ospf_interface
*oi
;
3809 json_object
*json
= NULL
;
3810 json_object
*json_neighbor_sub
= NULL
;
3814 json
= json_object_new_object();
3815 json_neighbor_sub
= json_object_new_object();
3818 show_ip_ospf_neighbour_header (vty
);
3823 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3825 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3826 VTY_NEWLINE
, VTY_NEWLINE
);
3829 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3831 struct listnode
*nbr_node
;
3832 struct ospf_nbr_nbma
*nbr_nbma
;
3834 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3836 /* print Down neighbor status */
3837 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3839 if (nbr_nbma
->nbr
== NULL
3840 || nbr_nbma
->nbr
->state
== NSM_Down
)
3844 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3845 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3846 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3847 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3848 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3849 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3850 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3854 vty_out (vty
, "%-15s %3d %-15s %9s ",
3855 "-", nbr_nbma
->priority
, "Down", "-");
3856 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3857 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3858 0, 0, 0, VTY_NEWLINE
);
3866 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3867 json_object_free(json
);
3870 vty_out (vty
, "%s", VTY_NEWLINE
);
3875 DEFUN (show_ip_ospf_neighbor_all
,
3876 show_ip_ospf_neighbor_all_cmd
,
3877 "show ip ospf neighbor all [json]",
3880 "OSPF information\n"
3882 "include down status neighbor\n"
3886 u_char uj
= use_json(argc
, argv
);
3888 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3891 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3894 DEFUN (show_ip_ospf_instance_neighbor_all
,
3895 show_ip_ospf_instance_neighbor_all_cmd
,
3896 "show ip ospf (1-65535) neighbor all [json]",
3899 "OSPF information\n"
3902 "include down status neighbor\n"
3907 u_short instance
= 0;
3908 u_char uj
= use_json(argc
, argv
);
3910 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3911 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3914 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3918 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3919 struct cmd_token
**argv
, u_char use_json
)
3921 struct interface
*ifp
;
3922 struct route_node
*rn
;
3923 json_object
*json
= NULL
;
3926 json
= json_object_new_object();
3928 show_ip_ospf_neighbour_header (vty
);
3933 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3935 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3936 VTY_NEWLINE
, VTY_NEWLINE
);
3939 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
3943 json_object_boolean_true_add(json
, "noSuchIface");
3945 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3949 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3951 struct ospf_interface
*oi
= rn
->info
;
3956 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3961 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3962 json_object_free(json
);
3965 vty_out (vty
, "%s", VTY_NEWLINE
);
3970 DEFUN (show_ip_ospf_neighbor_int
,
3971 show_ip_ospf_neighbor_int_cmd
,
3972 "show ip ospf neighbor IFNAME [json]",
3975 "OSPF information\n"
3981 u_char uj
= use_json(argc
, argv
);
3983 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3986 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
3989 DEFUN (show_ip_ospf_instance_neighbor_int
,
3990 show_ip_ospf_instance_neighbor_int_cmd
,
3991 "show ip ospf (1-65535) neighbor IFNAME [json]",
3994 "OSPF information\n"
4002 u_short instance
= 0;
4003 u_char uj
= use_json(argc
, argv
);
4005 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4006 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4009 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4013 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4014 u_char use_json
, json_object
*json
)
4016 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4017 json_object
*json_sub
= NULL
;
4020 json_sub
= json_object_new_object();
4021 else /* Show neighbor ID. */
4022 vty_out (vty
, " Neighbor %s,", "-");
4024 /* Show interface address. */
4026 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4028 vty_out (vty
, " interface address %s%s",
4029 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4034 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4035 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4038 vty_out (vty
, " In the area %s via interface %s%s",
4039 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4041 /* Show neighbor priority and state. */
4044 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4045 json_object_string_add(json_sub
, "nbrState", "down");
4048 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4049 nbr_nbma
->priority
, "Down");
4051 /* Show state changes. */
4053 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4055 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4057 /* Show PollInterval */
4059 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4061 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4063 /* Show poll-interval timer. */
4067 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
) / 1000LL;
4068 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4071 vty_out (vty
, " Poll timer due in %s%s",
4072 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4075 /* Show poll-interval timer thread. */
4078 if (nbr_nbma
->t_poll
!= NULL
)
4079 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4082 vty_out (vty
, " Thread Poll Timer %s%s",
4083 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4086 json_object_object_add(json
, "noNbrId", json_sub
);
4090 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4091 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4093 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4094 json_object
*json_sub
= NULL
;
4097 json_sub
= json_object_new_object();
4100 /* Show neighbor ID. */
4101 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4102 vty_out (vty
, " Neighbor %s,", "-");
4104 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4107 /* Show interface address. */
4109 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4111 vty_out (vty
, " interface address %s%s",
4112 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4117 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4118 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4121 vty_out (vty
, " In the area %s via interface %s%s",
4122 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4124 /* Show neighbor priority and state. */
4127 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4128 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4131 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4132 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4134 /* Show state changes. */
4136 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4138 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4140 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4145 time_store
= monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4148 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4152 vty_out (vty
, " Most recent state change statistics:%s",
4154 vty_out (vty
, " Progressive change %s ago%s",
4155 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4160 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4165 time_store
= monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4168 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4169 if (nbr
->last_regress_str
)
4170 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4174 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4175 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4176 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4181 /* Show Designated Rotuer ID. */
4183 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4185 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4187 /* Show Backup Designated Rotuer ID. */
4189 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4191 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4196 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4197 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4200 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4201 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4203 /* Show Router Dead interval timer. */
4206 if (nbr
->t_inactivity
)
4209 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
4210 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4213 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4216 vty_out (vty
, " Dead timer due in %s%s",
4217 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4220 /* Show Database Summary list. */
4222 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4224 vty_out (vty
, " Database Summary List %d%s",
4225 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4227 /* Show Link State Request list. */
4229 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4231 vty_out (vty
, " Link State Request List %ld%s",
4232 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4234 /* Show Link State Retransmission list. */
4236 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4238 vty_out (vty
, " Link State Retransmission List %ld%s",
4239 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4241 /* Show inactivity timer thread. */
4244 if (nbr
->t_inactivity
!= NULL
)
4245 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4248 vty_out (vty
, " Thread Inactivity Timer %s%s",
4249 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4251 /* Show Database Description retransmission thread. */
4254 if (nbr
->t_db_desc
!= NULL
)
4255 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4258 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4259 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4261 /* Show Link State Request Retransmission thread. */
4264 if (nbr
->t_ls_req
!= NULL
)
4265 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4268 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4269 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4271 /* Show Link State Update Retransmission thread. */
4274 if (nbr
->t_ls_upd
!= NULL
)
4275 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4278 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4279 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4283 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4284 json_object_object_add(json
, "noNbrId", json_sub
);
4286 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4289 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4293 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4294 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4296 struct listnode
*node
;
4297 struct ospf_neighbor
*nbr
;
4298 struct ospf_interface
*oi
;
4299 struct in_addr router_id
;
4301 json_object
*json
= NULL
;
4304 json
= json_object_new_object();
4309 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4311 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4312 VTY_NEWLINE
, VTY_NEWLINE
);
4315 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4319 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4323 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4325 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4327 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4333 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4334 json_object_free(json
);
4337 vty_out (vty
, "%s", VTY_NEWLINE
);
4342 DEFUN (show_ip_ospf_neighbor_id
,
4343 show_ip_ospf_neighbor_id_cmd
,
4344 "show ip ospf neighbor A.B.C.D [json]",
4347 "OSPF information\n"
4353 u_char uj
= use_json(argc
, argv
);
4355 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4358 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4361 DEFUN (show_ip_ospf_instance_neighbor_id
,
4362 show_ip_ospf_instance_neighbor_id_cmd
,
4363 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4366 "OSPF information\n"
4374 u_short instance
= 0;
4375 u_char uj
= use_json(argc
, argv
);
4377 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4378 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4381 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4385 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4387 struct ospf_interface
*oi
;
4388 struct listnode
*node
;
4389 json_object
*json
= NULL
;
4392 json
= json_object_new_object();
4397 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4399 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4400 VTY_NEWLINE
, VTY_NEWLINE
);
4403 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4405 struct route_node
*rn
;
4406 struct ospf_neighbor
*nbr
;
4408 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4410 if ((nbr
= rn
->info
))
4412 if (nbr
!= oi
->nbr_self
)
4414 if (nbr
->state
!= NSM_Down
)
4416 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4425 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4426 json_object_free(json
);
4429 vty_out (vty
, "%s", VTY_NEWLINE
);
4434 DEFUN (show_ip_ospf_neighbor_detail
,
4435 show_ip_ospf_neighbor_detail_cmd
,
4436 "show ip ospf neighbor detail [json]",
4439 "OSPF information\n"
4441 "detail of all neighbors\n"
4445 u_char uj
= use_json(argc
, argv
);
4447 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4450 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4453 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4454 show_ip_ospf_instance_neighbor_detail_cmd
,
4455 "show ip ospf (1-65535) neighbor detail [json]",
4458 "OSPF information\n"
4461 "detail of all neighbors\n"
4466 u_short instance
= 0;
4467 u_char uj
= use_json(argc
, argv
);
4469 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4470 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4473 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4477 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4479 struct listnode
*node
;
4480 struct ospf_interface
*oi
;
4481 json_object
*json
= NULL
;
4484 json
= json_object_new_object();
4489 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4491 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4492 VTY_NEWLINE
, VTY_NEWLINE
);
4495 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4497 struct route_node
*rn
;
4498 struct ospf_neighbor
*nbr
;
4499 struct ospf_nbr_nbma
*nbr_nbma
;
4501 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4502 if ((nbr
= rn
->info
))
4503 if (nbr
!= oi
->nbr_self
)
4504 if (nbr
->state
!= NSM_Down
)
4505 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4507 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4509 struct listnode
*nd
;
4511 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4513 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4514 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4521 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4522 json_object_free(json
);
4526 vty_out (vty
, "%s", VTY_NEWLINE
);
4532 DEFUN (show_ip_ospf_neighbor_detail_all
,
4533 show_ip_ospf_neighbor_detail_all_cmd
,
4534 "show ip ospf neighbor detail all [json]",
4537 "OSPF information\n"
4539 "detail of all neighbors\n"
4540 "include down status neighbor\n"
4544 u_char uj
= use_json(argc
, argv
);
4546 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4549 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4552 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4553 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4554 "show ip ospf (1-65535) neighbor detail all [json]",
4557 "OSPF information\n"
4560 "detail of all neighbors\n"
4561 "include down status neighbor\n"
4566 u_short instance
= 0;
4567 u_char uj
= use_json(argc
, argv
);
4569 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4570 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4573 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4577 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4578 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4580 struct ospf_interface
*oi
;
4581 struct interface
*ifp
;
4582 struct route_node
*rn
, *nrn
;
4583 struct ospf_neighbor
*nbr
;
4584 json_object
*json
= NULL
;
4587 json
= json_object_new_object();
4592 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4594 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4595 VTY_NEWLINE
, VTY_NEWLINE
);
4598 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
4602 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4606 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4608 if ((oi
= rn
->info
))
4610 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4612 if ((nbr
= nrn
->info
))
4614 if (nbr
!= oi
->nbr_self
)
4616 if (nbr
->state
!= NSM_Down
)
4617 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4626 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4627 json_object_free(json
);
4630 vty_out (vty
, "%s", VTY_NEWLINE
);
4635 DEFUN (show_ip_ospf_neighbor_int_detail
,
4636 show_ip_ospf_neighbor_int_detail_cmd
,
4637 "show ip ospf neighbor IFNAME detail [json]",
4640 "OSPF information\n"
4643 "detail of all neighbors\n"
4647 u_char uj
= use_json(argc
, argv
);
4649 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4652 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4655 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4656 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4657 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4660 "OSPF information\n"
4664 "detail of all neighbors\n"
4669 u_short instance
= 0;
4670 u_char uj
= use_json(argc
, argv
);
4672 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4673 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4676 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4679 /* Show functions */
4681 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4683 struct router_lsa
*rl
;
4684 struct summary_lsa
*sl
;
4685 struct as_external_lsa
*asel
;
4686 struct prefix_ipv4 p
;
4689 /* If self option is set, check LSA self flag. */
4690 if (self
== 0 || IS_LSA_SELF (lsa
))
4692 /* LSA common part show. */
4693 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4694 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4695 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4696 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4697 /* LSA specific part show. */
4698 switch (lsa
->data
->type
)
4700 case OSPF_ROUTER_LSA
:
4701 rl
= (struct router_lsa
*) lsa
->data
;
4702 vty_out (vty
, " %-d", ntohs (rl
->links
));
4704 case OSPF_SUMMARY_LSA
:
4705 sl
= (struct summary_lsa
*) lsa
->data
;
4708 p
.prefix
= sl
->header
.id
;
4709 p
.prefixlen
= ip_masklen (sl
->mask
);
4710 apply_mask_ipv4 (&p
);
4712 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4714 case OSPF_AS_EXTERNAL_LSA
:
4715 case OSPF_AS_NSSA_LSA
:
4716 asel
= (struct as_external_lsa
*) lsa
->data
;
4719 p
.prefix
= asel
->header
.id
;
4720 p
.prefixlen
= ip_masklen (asel
->mask
);
4721 apply_mask_ipv4 (&p
);
4723 vty_out (vty
, " %s %s/%d [0x%lx]",
4724 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4725 inet_ntoa (p
.prefix
), p
.prefixlen
,
4726 (u_long
)ntohl (asel
->e
[0].route_tag
));
4728 case OSPF_NETWORK_LSA
:
4729 case OSPF_ASBR_SUMMARY_LSA
:
4730 case OSPF_OPAQUE_LINK_LSA
:
4731 case OSPF_OPAQUE_AREA_LSA
:
4732 case OSPF_OPAQUE_AS_LSA
:
4736 vty_out (vty
, VTY_NEWLINE
);
4742 static const char *show_database_desc
[] =
4745 "Router Link States",
4747 "Summary Link States",
4748 "ASBR-Summary Link States",
4749 "AS External Link States",
4750 "Group Membership LSA",
4751 "NSSA-external Link States",
4753 "Link-Local Opaque-LSA",
4754 "Area-Local Opaque-LSA",
4755 "AS-external Opaque-LSA",
4758 static const char *show_database_header
[] =
4761 "Link ID ADV Router Age Seq# CkSum Link count",
4762 "Link ID ADV Router Age Seq# CkSum",
4763 "Link ID ADV Router Age Seq# CkSum Route",
4764 "Link ID ADV Router Age Seq# CkSum",
4765 "Link ID ADV Router Age Seq# CkSum Route",
4766 " --- header for Group Member ----",
4767 "Link ID ADV Router Age Seq# CkSum Route",
4769 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4770 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4771 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4775 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4777 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4779 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4780 vty_out (vty
, " Options: 0x%-2x : %s%s",
4782 ospf_options_dump(lsa
->data
->options
),
4784 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4786 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4789 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4791 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4794 vty_out (vty
, " :%s%s%s%s",
4795 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4796 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4797 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4798 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4800 vty_out (vty
, "%s", VTY_NEWLINE
);
4802 vty_out (vty
, " LS Type: %s%s",
4803 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4804 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4805 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4806 vty_out (vty
, " Advertising Router: %s%s",
4807 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4808 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4810 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4812 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4815 const char *link_type_desc
[] =
4818 "another Router (point-to-point)",
4819 "a Transit Network",
4824 const char *link_id_desc
[] =
4827 "Neighboring Router ID",
4828 "Designated Router address",
4830 "Neighboring Router ID",
4833 const char *link_data_desc
[] =
4836 "Router Interface address",
4837 "Router Interface address",
4839 "Router Interface address",
4842 /* Show router-LSA each Link information. */
4844 show_ip_ospf_database_router_links (struct vty
*vty
,
4845 struct router_lsa
*rl
)
4850 len
= ntohs (rl
->header
.length
) - 4;
4851 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4853 type
= rl
->link
[i
].type
;
4855 vty_out (vty
, " Link connected to: %s%s",
4856 link_type_desc
[type
], VTY_NEWLINE
);
4857 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4858 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4859 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4860 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4861 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4862 vty_out (vty
, " TOS 0 Metric: %d%s",
4863 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4864 vty_out (vty
, "%s", VTY_NEWLINE
);
4868 /* Show router-LSA detail information. */
4870 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4874 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4876 show_ip_ospf_database_header (vty
, lsa
);
4878 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4879 VTY_NEWLINE
, VTY_NEWLINE
);
4881 show_ip_ospf_database_router_links (vty
, rl
);
4882 vty_out (vty
, "%s", VTY_NEWLINE
);
4888 /* Show network-LSA detail information. */
4890 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4896 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4898 show_ip_ospf_database_header (vty
, lsa
);
4900 vty_out (vty
, " Network Mask: /%d%s",
4901 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4903 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4905 for (i
= 0; length
> 0; i
++, length
-= 4)
4906 vty_out (vty
, " Attached Router: %s%s",
4907 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4909 vty_out (vty
, "%s", VTY_NEWLINE
);
4915 /* Show summary-LSA detail information. */
4917 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4921 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4923 show_ip_ospf_database_header (vty
, lsa
);
4925 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4927 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4929 vty_out (vty
, "%s", VTY_NEWLINE
);
4935 /* Show summary-ASBR-LSA detail information. */
4937 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4941 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4943 show_ip_ospf_database_header (vty
, lsa
);
4945 vty_out (vty
, " Network Mask: /%d%s",
4946 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4947 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4949 vty_out (vty
, "%s", VTY_NEWLINE
);
4955 /* Show AS-external-LSA detail information. */
4957 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4961 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4963 show_ip_ospf_database_header (vty
, lsa
);
4965 vty_out (vty
, " Network Mask: /%d%s",
4966 ip_masklen (al
->mask
), VTY_NEWLINE
);
4967 vty_out (vty
, " Metric Type: %s%s",
4968 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4969 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4970 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4971 vty_out (vty
, " Metric: %d%s",
4972 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4973 vty_out (vty
, " Forward Address: %s%s",
4974 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4976 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4977 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
4984 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
4986 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4988 /* show_ip_ospf_database_header (vty, lsa); */
4990 zlog_debug( " Network Mask: /%d%s",
4991 ip_masklen (al
->mask
), "\n");
4992 zlog_debug( " Metric Type: %s%s",
4993 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4994 "2 (Larger than any link state path)" : "1", "\n");
4995 zlog_debug( " TOS: 0%s", "\n");
4996 zlog_debug( " Metric: %d%s",
4997 GET_METRIC (al
->e
[0].metric
), "\n");
4998 zlog_debug( " Forward Address: %s%s",
4999 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5001 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5002 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5007 /* Show AS-NSSA-LSA detail information. */
5009 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5013 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5015 show_ip_ospf_database_header (vty
, lsa
);
5017 vty_out (vty
, " Network Mask: /%d%s",
5018 ip_masklen (al
->mask
), VTY_NEWLINE
);
5019 vty_out (vty
, " Metric Type: %s%s",
5020 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5021 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5022 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5023 vty_out (vty
, " Metric: %d%s",
5024 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5025 vty_out (vty
, " NSSA: Forward Address: %s%s",
5026 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5028 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5029 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5036 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5042 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5046 show_ip_ospf_database_header (vty
, lsa
);
5047 show_opaque_info_detail (vty
, lsa
);
5049 vty_out (vty
, "%s", VTY_NEWLINE
);
5054 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5057 show_router_lsa_detail
,
5058 show_network_lsa_detail
,
5059 show_summary_lsa_detail
,
5060 show_summary_asbr_lsa_detail
,
5061 show_as_external_lsa_detail
,
5063 show_as_nssa_lsa_detail
, /* almost same as external */
5065 show_opaque_lsa_detail
,
5066 show_opaque_lsa_detail
,
5067 show_opaque_lsa_detail
,
5071 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5072 struct in_addr
*adv_router
)
5074 memset (lp
, 0, sizeof (struct prefix_ls
));
5078 else if (adv_router
== NULL
)
5087 lp
->adv_router
= *adv_router
;
5092 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5093 struct in_addr
*id
, struct in_addr
*adv_router
)
5095 struct prefix_ls lp
;
5096 struct route_node
*rn
, *start
;
5097 struct ospf_lsa
*lsa
;
5099 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5100 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5103 route_lock_node (start
);
5104 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5105 if ((lsa
= rn
->info
))
5107 if (show_function
[lsa
->data
->type
] != NULL
)
5108 show_function
[lsa
->data
->type
] (vty
, lsa
);
5110 route_unlock_node (start
);
5114 /* Show detail LSA information
5115 -- if id is NULL then show all LSAs. */
5117 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5118 struct in_addr
*id
, struct in_addr
*adv_router
)
5120 struct listnode
*node
;
5121 struct ospf_area
*area
;
5125 case OSPF_AS_EXTERNAL_LSA
:
5126 case OSPF_OPAQUE_AS_LSA
:
5127 vty_out (vty
, " %s %s%s",
5128 show_database_desc
[type
],
5129 VTY_NEWLINE
, VTY_NEWLINE
);
5130 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5133 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5135 vty_out (vty
, "%s %s (Area %s)%s%s",
5136 VTY_NEWLINE
, show_database_desc
[type
],
5137 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5138 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5145 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5146 struct in_addr
*adv_router
)
5148 struct route_node
*rn
;
5149 struct ospf_lsa
*lsa
;
5151 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5152 if ((lsa
= rn
->info
))
5153 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5155 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5157 if (show_function
[lsa
->data
->type
] != NULL
)
5158 show_function
[lsa
->data
->type
] (vty
, lsa
);
5162 /* Show detail LSA information. */
5164 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5165 struct in_addr
*adv_router
)
5167 struct listnode
*node
;
5168 struct ospf_area
*area
;
5172 case OSPF_AS_EXTERNAL_LSA
:
5173 case OSPF_OPAQUE_AS_LSA
:
5174 vty_out (vty
, " %s %s%s",
5175 show_database_desc
[type
],
5176 VTY_NEWLINE
, VTY_NEWLINE
);
5177 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5181 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5183 vty_out (vty
, "%s %s (Area %s)%s%s",
5184 VTY_NEWLINE
, show_database_desc
[type
],
5185 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5186 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5194 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5196 struct ospf_lsa
*lsa
;
5197 struct route_node
*rn
;
5198 struct ospf_area
*area
;
5199 struct listnode
*node
;
5202 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5204 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5208 case OSPF_AS_EXTERNAL_LSA
:
5209 case OSPF_OPAQUE_AS_LSA
:
5214 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5215 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5217 vty_out (vty
, " %s (Area %s)%s%s",
5218 show_database_desc
[type
],
5219 ospf_area_desc_string (area
),
5220 VTY_NEWLINE
, VTY_NEWLINE
);
5221 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5223 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5224 show_lsa_summary (vty
, lsa
, self
);
5226 vty_out (vty
, "%s", VTY_NEWLINE
);
5231 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5235 case OSPF_AS_EXTERNAL_LSA
:
5236 case OSPF_OPAQUE_AS_LSA
:
5241 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5242 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5244 vty_out (vty
, " %s%s%s",
5245 show_database_desc
[type
],
5246 VTY_NEWLINE
, VTY_NEWLINE
);
5247 vty_out (vty
, "%s%s", show_database_header
[type
],
5250 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5251 show_lsa_summary (vty
, lsa
, self
);
5253 vty_out (vty
, "%s", VTY_NEWLINE
);
5257 vty_out (vty
, "%s", VTY_NEWLINE
);
5261 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5263 struct route_node
*rn
;
5265 vty_out (vty
, "%s MaxAge Link States:%s%s",
5266 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5268 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5270 struct ospf_lsa
*lsa
;
5272 if ((lsa
= rn
->info
) != NULL
)
5274 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5275 vty_out (vty
, "Link State ID: %s%s",
5276 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5277 vty_out (vty
, "Advertising Router: %s%s",
5278 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5279 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5280 vty_out (vty
, "%s", VTY_NEWLINE
);
5285 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5286 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5288 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5289 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5290 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5291 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5293 #define OSPF_LSA_TYPES_DESC \
5294 "ASBR summary link states\n" \
5295 "External link states\n" \
5296 "Network link states\n" \
5297 "Router link states\n" \
5298 "Network summary link states\n" \
5299 OSPF_LSA_TYPE_NSSA_DESC \
5300 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5301 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5302 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5305 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5306 int arg_base
, int argc
, struct cmd_token
**argv
)
5310 struct in_addr id
, adv_router
;
5313 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5316 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5317 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5320 if (argc
== arg_base
+ 4)
5322 show_ip_ospf_database_summary (vty
, ospf
, 0);
5326 /* Set database type to show. */
5327 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5328 type
= OSPF_ROUTER_LSA
;
5329 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5330 type
= OSPF_NETWORK_LSA
;
5331 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5332 type
= OSPF_AS_NSSA_LSA
;
5333 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5334 type
= OSPF_SUMMARY_LSA
;
5335 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5336 type
= OSPF_ASBR_SUMMARY_LSA
;
5337 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5338 type
= OSPF_AS_EXTERNAL_LSA
;
5339 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5341 show_ip_ospf_database_summary (vty
, ospf
, 1);
5344 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5346 show_ip_ospf_database_maxage (vty
, ospf
);
5349 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5350 type
= OSPF_OPAQUE_LINK_LSA
;
5351 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5352 type
= OSPF_OPAQUE_AREA_LSA
;
5353 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5354 type
= OSPF_OPAQUE_AS_LSA
;
5358 /* `show ip ospf database LSA'. */
5359 if (argc
== arg_base
+ 5)
5360 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5361 else if (argc
>= arg_base
+ 6)
5363 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5367 /* `show ip ospf database LSA ID'. */
5368 if (argc
== arg_base
+ 6)
5369 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5370 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5371 else if (argc
== arg_base
+ 7)
5373 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5374 adv_router
= ospf
->router_id
;
5377 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5381 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5388 DEFUN (show_ip_ospf_database_max
,
5389 show_ip_ospf_database_max_cmd
,
5390 "show ip ospf database <max-age|self-originate>",
5393 "OSPF information\n"
5394 "Database summary\n"
5395 "LSAs in MaxAge list\n"
5396 "Self-originated link states\n")
5400 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5403 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5406 DEFUN (show_ip_ospf_instance_database
,
5407 show_ip_ospf_instance_database_cmd
,
5408 "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>]]]",
5411 "OSPF information\n"
5413 "Database summary\n"
5415 "Link State ID (as an IP address)\n"
5416 "Self-originated link states\n"
5417 "Advertising Router link states\n"
5418 "Advertising Router (as an IP address)\n")
5421 u_short instance
= 0;
5424 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5426 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5427 ospf
= ospf_lookup_instance (instance
);
5430 ospf
= ospf_lookup();
5433 if (!ospf
|| !ospf
->oi_running
)
5436 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5439 DEFUN (show_ip_ospf_instance_database_max
,
5440 show_ip_ospf_instance_database_max_cmd
,
5441 "show ip ospf (1-65535) database <max-age|self-originate>",
5444 "OSPF information\n"
5446 "Database summary\n"
5447 "LSAs in MaxAge list\n"
5448 "Self-originated link states\n")
5452 u_short instance
= 0;
5454 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5456 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5459 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5464 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5465 int arg_base
, int argc
, struct cmd_token
**argv
)
5469 struct in_addr adv_router
;
5472 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5475 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5476 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5478 if (argc
!= arg_base
+ 7)
5481 /* Set database type to show. */
5482 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5483 type
= OSPF_ROUTER_LSA
;
5484 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5485 type
= OSPF_NETWORK_LSA
;
5486 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5487 type
= OSPF_AS_NSSA_LSA
;
5488 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5489 type
= OSPF_SUMMARY_LSA
;
5490 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5491 type
= OSPF_ASBR_SUMMARY_LSA
;
5492 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5493 type
= OSPF_AS_EXTERNAL_LSA
;
5494 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5495 type
= OSPF_OPAQUE_LINK_LSA
;
5496 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5497 type
= OSPF_OPAQUE_AREA_LSA
;
5498 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5499 type
= OSPF_OPAQUE_AS_LSA
;
5503 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5504 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5505 adv_router
= ospf
->router_id
;
5508 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5513 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5518 DEFUN (show_ip_ospf_database_type_adv_router
,
5519 show_ip_ospf_database_type_adv_router_cmd
,
5520 "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>",
5523 "OSPF information\n"
5524 "Database summary\n"
5526 "Advertising Router link states\n"
5527 "Advertising Router (as an IP address)\n"
5528 "Self-originated link states\n")
5532 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5535 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5538 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5539 show_ip_ospf_instance_database_type_adv_router_cmd
,
5540 "show ip ospf (1-65535) database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
5543 "OSPF information\n"
5545 "Database summary\n"
5547 "Advertising Router link states\n"
5548 "Advertising Router (as an IP address)\n"
5549 "Self-originated link states\n")
5553 u_short instance
= 0;
5555 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5557 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5560 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5563 DEFUN (ip_ospf_authentication_args
,
5564 ip_ospf_authentication_args_addr_cmd
,
5565 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5567 "OSPF interface commands\n"
5568 "Enable authentication on this interface\n"
5569 "Use null authentication\n"
5570 "Use message-digest authentication\n"
5571 "Address of interface\n")
5573 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5574 int idx_encryption
= 3;
5576 struct in_addr addr
;
5578 struct ospf_if_params
*params
;
5580 params
= IF_DEF_PARAMS (ifp
);
5584 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5587 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5592 params
= ospf_get_if_params (ifp
, addr
);
5593 ospf_if_update_params (ifp
, addr
);
5596 /* Handle null authentication */
5597 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5599 SET_IF_PARAM (params
, auth_type
);
5600 params
->auth_type
= OSPF_AUTH_NULL
;
5604 /* Handle message-digest authentication */
5605 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5607 SET_IF_PARAM (params
, auth_type
);
5608 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5612 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5616 DEFUN (ip_ospf_authentication
,
5617 ip_ospf_authentication_addr_cmd
,
5618 "ip ospf authentication [A.B.C.D]",
5620 "OSPF interface commands\n"
5621 "Enable authentication on this interface\n"
5622 "Address of interface")
5624 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5626 struct in_addr addr
;
5628 struct ospf_if_params
*params
;
5630 params
= IF_DEF_PARAMS (ifp
);
5634 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5637 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5642 params
= ospf_get_if_params (ifp
, addr
);
5643 ospf_if_update_params (ifp
, addr
);
5646 SET_IF_PARAM (params
, auth_type
);
5647 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5652 DEFUN (no_ip_ospf_authentication_args
,
5653 no_ip_ospf_authentication_args_addr_cmd
,
5654 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5657 "OSPF interface commands\n"
5658 "Enable authentication on this interface\n"
5659 "Use null authentication\n"
5660 "Use message-digest authentication\n"
5661 "Address of interface")
5663 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5664 int idx_encryption
= 4;
5666 struct in_addr addr
;
5668 struct ospf_if_params
*params
;
5669 struct route_node
*rn
;
5672 params
= IF_DEF_PARAMS (ifp
);
5676 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5679 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5684 params
= ospf_lookup_if_params (ifp
, addr
);
5687 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5690 params
->auth_type
= OSPF_AUTH_NOTSET
;
5691 UNSET_IF_PARAM (params
, auth_type
);
5692 if (params
!= IF_DEF_PARAMS (ifp
))
5694 ospf_free_if_params (ifp
, addr
);
5695 ospf_if_update_params (ifp
, addr
);
5700 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5702 auth_type
= OSPF_AUTH_NULL
;
5704 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5706 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5710 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5714 * Here we have a case where the user has entered
5715 * 'no ip ospf authentication (null | message_digest )'
5716 * we need to find if we have any ip addresses underneath it that
5717 * correspond to the associated type.
5719 if (params
->auth_type
== auth_type
)
5721 params
->auth_type
= OSPF_AUTH_NOTSET
;
5722 UNSET_IF_PARAM (params
, auth_type
);
5725 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5727 if ((params
= rn
->info
))
5729 if (params
->auth_type
== auth_type
)
5731 params
->auth_type
= OSPF_AUTH_NOTSET
;
5732 UNSET_IF_PARAM (params
, auth_type
);
5733 if (params
!= IF_DEF_PARAMS (ifp
))
5735 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5736 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5746 DEFUN (no_ip_ospf_authentication
,
5747 no_ip_ospf_authentication_addr_cmd
,
5748 "no ip ospf authentication [A.B.C.D]",
5751 "OSPF interface commands\n"
5752 "Enable authentication on this interface\n"
5753 "Address of interface")
5755 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5757 struct in_addr addr
;
5759 struct ospf_if_params
*params
;
5760 struct route_node
*rn
;
5762 params
= IF_DEF_PARAMS (ifp
);
5766 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5769 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5774 params
= ospf_lookup_if_params (ifp
, addr
);
5777 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5781 params
->auth_type
= OSPF_AUTH_NOTSET
;
5782 UNSET_IF_PARAM (params
, auth_type
);
5783 if (params
!= IF_DEF_PARAMS (ifp
))
5785 ospf_free_if_params (ifp
, addr
);
5786 ospf_if_update_params (ifp
, addr
);
5792 * When a user enters 'no ip ospf authentication'
5793 * We should remove all authentication types from
5796 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5797 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5798 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5800 params
->auth_type
= OSPF_AUTH_NOTSET
;
5801 UNSET_IF_PARAM (params
, auth_type
);
5804 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5806 if ((params
= rn
->info
))
5809 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5810 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5811 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5813 params
->auth_type
= OSPF_AUTH_NOTSET
;
5814 UNSET_IF_PARAM (params
, auth_type
);
5815 if (params
!= IF_DEF_PARAMS (ifp
))
5817 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5818 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5829 DEFUN (ip_ospf_authentication_key
,
5830 ip_ospf_authentication_key_addr_cmd
,
5831 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5833 "OSPF interface commands\n"
5834 "Authentication password (key)\n"
5835 "The OSPF password (key)\n"
5836 "Address of interface")
5838 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5840 struct in_addr addr
;
5841 struct ospf_if_params
*params
;
5843 params
= IF_DEF_PARAMS (ifp
);
5845 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5847 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5849 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5854 params
= ospf_get_if_params (ifp
, addr
);
5855 ospf_if_update_params (ifp
, addr
);
5858 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5859 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5860 SET_IF_PARAM (params
, auth_simple
);
5865 DEFUN_HIDDEN (ospf_authentication_key
,
5866 ospf_authentication_key_cmd
,
5867 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5868 "OSPF interface commands\n"
5869 "Authentication password (key)\n"
5870 "The OSPF password (key)\n"
5871 "Address of interface\n")
5873 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5876 DEFUN (no_ip_ospf_authentication_key
,
5877 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5878 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5881 "OSPF interface commands\n"
5882 "Authentication password (key)\n"
5883 "The OSPF password (key)")
5885 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5887 struct in_addr addr
;
5888 struct ospf_if_params
*params
;
5889 params
= IF_DEF_PARAMS (ifp
);
5891 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5893 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5895 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5900 params
= ospf_lookup_if_params (ifp
, addr
);
5905 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5906 UNSET_IF_PARAM (params
, auth_simple
);
5908 if (params
!= IF_DEF_PARAMS (ifp
))
5910 ospf_free_if_params (ifp
, addr
);
5911 ospf_if_update_params (ifp
, addr
);
5917 DEFUN_HIDDEN (no_ospf_authentication_key
,
5918 no_ospf_authentication_key_authkey_addr_cmd
,
5919 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5921 "OSPF interface commands\n"
5922 "Authentication password (key)\n"
5923 "The OSPF password (key)")
5925 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5928 DEFUN (ip_ospf_message_digest_key
,
5929 ip_ospf_message_digest_key_cmd
,
5930 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5932 "OSPF interface commands\n"
5933 "Message digest authentication password (key)\n"
5935 "Use MD5 algorithm\n"
5936 "The OSPF password (key)\n"
5937 "Address of interface\n")
5939 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5940 struct crypt_key
*ck
;
5942 struct in_addr addr
;
5943 struct ospf_if_params
*params
;
5945 params
= IF_DEF_PARAMS (ifp
);
5948 argv_find (argv
, argc
, "(1-255)", &idx
);
5949 char *keyid
= argv
[idx
]->arg
;
5950 argv_find (argv
, argc
, "KEY", &idx
);
5951 char *cryptkey
= argv
[idx
]->arg
;
5953 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5955 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5957 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5962 params
= ospf_get_if_params (ifp
, addr
);
5963 ospf_if_update_params (ifp
, addr
);
5966 key_id
= strtol (keyid
, NULL
, 10);
5967 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5969 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5973 ck
= ospf_crypt_key_new ();
5974 ck
->key_id
= (u_char
) key_id
;
5975 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5976 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5978 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5979 SET_IF_PARAM (params
, auth_crypt
);
5984 DEFUN_HIDDEN (ospf_message_digest_key
,
5985 ospf_message_digest_key_cmd
,
5986 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5987 "OSPF interface commands\n"
5988 "Message digest authentication password (key)\n"
5990 "Use MD5 algorithm\n"
5991 "The OSPF password (key)\n"
5992 "Address of interface\n")
5994 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
5997 DEFUN (no_ip_ospf_message_digest_key
,
5998 no_ip_ospf_message_digest_key_cmd
,
5999 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6002 "OSPF interface commands\n"
6003 "Message digest authentication password (key)\n"
6005 "Use MD5 algorithm\n"
6006 "The OSPF password (key)\n"
6007 "Address of interface\n")
6009 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6011 struct crypt_key
*ck
;
6013 struct in_addr addr
;
6014 struct ospf_if_params
*params
;
6015 params
= IF_DEF_PARAMS (ifp
);
6017 argv_find (argv
, argc
, "(1-255)", &idx
);
6018 char *keyid
= argv
[idx
]->arg
;
6020 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6022 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6024 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6029 params
= ospf_lookup_if_params (ifp
, addr
);
6034 key_id
= strtol (keyid
, NULL
, 10);
6035 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6038 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6042 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6044 if (params
!= IF_DEF_PARAMS (ifp
))
6046 ospf_free_if_params (ifp
, addr
);
6047 ospf_if_update_params (ifp
, addr
);
6053 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6054 no_ospf_message_digest_key_cmd
,
6055 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6057 "OSPF interface commands\n"
6058 "Message digest authentication password (key)\n"
6060 "Address of interface")
6062 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6065 DEFUN (ip_ospf_cost
,
6067 "ip ospf cost (1-65535) [A.B.C.D]",
6069 "OSPF interface commands\n"
6072 "Address of interface\n")
6074 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6077 struct in_addr addr
;
6078 struct ospf_if_params
*params
;
6079 params
= IF_DEF_PARAMS (ifp
);
6082 char *coststr
= NULL
, *ifaddr
= NULL
;
6083 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6084 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6086 cost
= strtol (coststr
, NULL
, 10);
6090 if(!inet_aton(ifaddr
, &addr
))
6092 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6097 params
= ospf_get_if_params (ifp
, addr
);
6098 ospf_if_update_params (ifp
, addr
);
6101 SET_IF_PARAM (params
, output_cost_cmd
);
6102 params
->output_cost_cmd
= cost
;
6104 ospf_if_recalculate_output_cost (ifp
);
6109 DEFUN_HIDDEN (ospf_cost
,
6111 "ospf cost (1-65535) [A.B.C.D]",
6112 "OSPF interface commands\n"
6115 "Address of interface\n")
6117 return ip_ospf_cost (self
, vty
, argc
, argv
);
6120 DEFUN (no_ip_ospf_cost
,
6121 no_ip_ospf_cost_cmd
,
6122 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6124 "OSPF interface commands\n"
6126 "Address of interface")
6128 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6130 struct in_addr addr
;
6131 struct ospf_if_params
*params
;
6133 params
= IF_DEF_PARAMS (ifp
);
6136 char *ifaddr
= NULL
;
6137 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6139 /* According to the semantics we are mimicking "no ip ospf cost N" is
6140 * always treated as "no ip ospf cost" regardless of the actual value
6141 * of N already configured for the interface. Thus ignore cost. */
6145 if (!inet_aton(ifaddr
, &addr
))
6147 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6152 params
= ospf_lookup_if_params (ifp
, addr
);
6157 UNSET_IF_PARAM (params
, output_cost_cmd
);
6159 if (params
!= IF_DEF_PARAMS (ifp
))
6161 ospf_free_if_params (ifp
, addr
);
6162 ospf_if_update_params (ifp
, addr
);
6165 ospf_if_recalculate_output_cost (ifp
);
6170 DEFUN_HIDDEN (no_ospf_cost
,
6172 "no ospf cost [(1-65535)] [A.B.C.D]",
6174 "OSPF interface commands\n"
6177 "Address of interface\n")
6179 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6183 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6185 struct route_node
*rn
;
6186 struct ospf_neighbor
*nbr
;
6188 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6189 if ((nbr
= rn
->info
))
6191 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6192 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6193 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6194 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6199 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6200 const char *nbr_str
,
6201 const char *fast_hello_str
)
6203 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6206 struct in_addr addr
;
6208 struct ospf_if_params
*params
;
6209 struct ospf_interface
*oi
;
6210 struct route_node
*rn
;
6212 params
= IF_DEF_PARAMS (ifp
);
6216 ret
= inet_aton(nbr_str
, &addr
);
6219 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6224 params
= ospf_get_if_params (ifp
, addr
);
6225 ospf_if_update_params (ifp
, addr
);
6230 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6233 /* reset fast_hello too, just to be sure */
6234 UNSET_IF_PARAM (params
, fast_hello
);
6235 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6237 else if (fast_hello_str
)
6239 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6241 /* 1s dead-interval with sub-second hellos desired */
6242 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6243 SET_IF_PARAM (params
, fast_hello
);
6244 params
->fast_hello
= hellomult
;
6248 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6253 SET_IF_PARAM (params
, v_wait
);
6254 params
->v_wait
= seconds
;
6256 /* Update timer values in neighbor structure. */
6260 if ((ospf
= ospf_lookup()))
6262 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6264 ospf_nbr_timer_update (oi
);
6269 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6270 if ((oi
= rn
->info
))
6271 ospf_nbr_timer_update (oi
);
6277 DEFUN (ip_ospf_dead_interval
,
6278 ip_ospf_dead_interval_cmd
,
6279 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6281 "OSPF interface commands\n"
6282 "Interval time after which a neighbor is declared down\n"
6284 "Address of interface\n")
6287 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6288 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6289 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6293 DEFUN_HIDDEN (ospf_dead_interval
,
6294 ospf_dead_interval_cmd
,
6295 "ospf dead-interval (1-65535) [A.B.C.D]",
6296 "OSPF interface commands\n"
6297 "Interval time after which a neighbor is declared down\n"
6299 "Address of interface\n")
6301 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6304 DEFUN (ip_ospf_dead_interval_minimal
,
6305 ip_ospf_dead_interval_minimal_addr_cmd
,
6306 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6308 "OSPF interface commands\n"
6309 "Interval time after which a neighbor is declared down\n"
6310 "Minimal 1s dead-interval with fast sub-second hellos\n"
6311 "Hello multiplier factor\n"
6312 "Number of Hellos to send each second\n"
6313 "Address of interface\n")
6318 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6320 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6323 DEFUN (no_ip_ospf_dead_interval
,
6324 no_ip_ospf_dead_interval_cmd
,
6325 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6328 "OSPF interface commands\n"
6329 "Interval time after which a neighbor is declared down\n"
6331 "Address of interface")
6333 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6334 int idx_ipv4
= argc
- 1;
6335 struct in_addr addr
= { .s_addr
= 0L};
6337 struct ospf_if_params
*params
;
6338 struct ospf_interface
*oi
;
6339 struct route_node
*rn
;
6341 params
= IF_DEF_PARAMS (ifp
);
6343 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6345 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6348 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6353 params
= ospf_lookup_if_params (ifp
, addr
);
6358 UNSET_IF_PARAM (params
, v_wait
);
6359 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6361 UNSET_IF_PARAM (params
, fast_hello
);
6362 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6364 if (params
!= IF_DEF_PARAMS (ifp
))
6366 ospf_free_if_params (ifp
, addr
);
6367 ospf_if_update_params (ifp
, addr
);
6370 /* Update timer values in neighbor structure. */
6375 if ((ospf
= ospf_lookup()))
6377 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6379 ospf_nbr_timer_update (oi
);
6384 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6385 if ((oi
= rn
->info
))
6386 ospf_nbr_timer_update (oi
);
6392 DEFUN_HIDDEN (no_ospf_dead_interval
,
6393 no_ospf_dead_interval_cmd
,
6394 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6396 "OSPF interface commands\n"
6397 "Interval time after which a neighbor is declared down\n"
6399 "Address of interface")
6401 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6404 DEFUN (ip_ospf_hello_interval
,
6405 ip_ospf_hello_interval_cmd
,
6406 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6408 "OSPF interface commands\n"
6409 "Time between HELLO packets\n"
6411 "Address of interface\n")
6413 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6415 struct in_addr addr
;
6416 struct ospf_if_params
*params
;
6417 params
= IF_DEF_PARAMS (ifp
);
6418 u_int32_t seconds
= 0;
6420 argv_find (argv
, argc
, "(1-65535)", &idx
);
6421 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6423 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6425 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6427 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6432 params
= ospf_get_if_params (ifp
, addr
);
6433 ospf_if_update_params (ifp
, addr
);
6436 SET_IF_PARAM (params
, v_hello
);
6437 params
->v_hello
= seconds
;
6442 DEFUN_HIDDEN (ospf_hello_interval
,
6443 ospf_hello_interval_cmd
,
6444 "ospf hello-interval (1-65535) [A.B.C.D]",
6445 "OSPF interface commands\n"
6446 "Time between HELLO packets\n"
6448 "Address of interface\n")
6450 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6453 DEFUN (no_ip_ospf_hello_interval
,
6454 no_ip_ospf_hello_interval_cmd
,
6455 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6458 "OSPF interface commands\n"
6459 "Time between HELLO packets\n" // ignored
6461 "Address of interface\n")
6463 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6465 struct in_addr addr
;
6466 struct ospf_if_params
*params
;
6468 params
= IF_DEF_PARAMS (ifp
);
6470 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6472 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6474 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6479 params
= ospf_lookup_if_params (ifp
, addr
);
6484 UNSET_IF_PARAM (params
, v_hello
);
6485 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6487 if (params
!= IF_DEF_PARAMS (ifp
))
6489 ospf_free_if_params (ifp
, addr
);
6490 ospf_if_update_params (ifp
, addr
);
6496 DEFUN_HIDDEN (no_ospf_hello_interval
,
6497 no_ospf_hello_interval_cmd
,
6498 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6500 "OSPF interface commands\n"
6501 "Time between HELLO packets\n" // ignored
6503 "Address of interface\n")
6505 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6508 DEFUN (ip_ospf_network
,
6509 ip_ospf_network_cmd
,
6510 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6512 "OSPF interface commands\n"
6514 "Specify OSPF broadcast multi-access network\n"
6515 "Specify OSPF NBMA network\n"
6516 "Specify OSPF point-to-multipoint network\n"
6517 "Specify OSPF point-to-point network\n")
6519 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6521 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6522 struct route_node
*rn
;
6524 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6526 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6530 if (argv_find (argv
, argc
, "broadcast", &idx
))
6531 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6532 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6533 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6534 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6535 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6536 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6537 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6539 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6542 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6544 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6546 struct ospf_interface
*oi
= rn
->info
;
6551 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6553 if (oi
->state
> ISM_Down
)
6555 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6556 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6563 DEFUN_HIDDEN (ospf_network
,
6565 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6566 "OSPF interface commands\n"
6568 "Specify OSPF broadcast multi-access network\n"
6569 "Specify OSPF NBMA network\n"
6570 "Specify OSPF point-to-multipoint network\n"
6571 "Specify OSPF point-to-point network\n")
6573 return ip_ospf_network (self
, vty
, argc
, argv
);
6576 DEFUN (no_ip_ospf_network
,
6577 no_ip_ospf_network_cmd
,
6578 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6581 "OSPF interface commands\n"
6583 "Specify OSPF broadcast multi-access network\n"
6584 "Specify OSPF NBMA network\n"
6585 "Specify OSPF point-to-multipoint network\n"
6586 "Specify OSPF point-to-point network\n")
6588 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6589 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6590 struct route_node
*rn
;
6592 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6594 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6597 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6599 struct ospf_interface
*oi
= rn
->info
;
6604 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6606 if (oi
->state
> ISM_Down
)
6608 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6609 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6616 DEFUN_HIDDEN (no_ospf_network
,
6617 no_ospf_network_cmd
,
6618 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6620 "OSPF interface commands\n"
6622 "Specify OSPF broadcast multi-access network\n"
6623 "Specify OSPF NBMA network\n"
6624 "Specify OSPF point-to-multipoint network\n"
6625 "Specify OSPF point-to-point network\n")
6627 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6630 DEFUN (ip_ospf_priority
,
6631 ip_ospf_priority_cmd
,
6632 "ip ospf priority (0-255) [A.B.C.D]",
6634 "OSPF interface commands\n"
6637 "Address of interface")
6639 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6642 struct route_node
*rn
;
6643 struct in_addr addr
;
6644 struct ospf_if_params
*params
;
6645 params
= IF_DEF_PARAMS (ifp
);
6647 argv_find (argv
, argc
, "(0-255)", &idx
);
6648 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6650 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6652 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6654 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6659 params
= ospf_get_if_params (ifp
, addr
);
6660 ospf_if_update_params (ifp
, addr
);
6663 SET_IF_PARAM (params
, priority
);
6664 params
->priority
= priority
;
6666 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6668 struct ospf_interface
*oi
= rn
->info
;
6673 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6675 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6676 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6683 DEFUN_HIDDEN (ospf_priority
,
6685 "ospf priority (0-255) [A.B.C.D]",
6686 "OSPF interface commands\n"
6689 "Address of interface")
6691 return ip_ospf_priority (self
, vty
, argc
, argv
);
6694 DEFUN (no_ip_ospf_priority
,
6695 no_ip_ospf_priority_cmd
,
6696 "no ip ospf priority [(0-255) [A.B.C.D]]",
6699 "OSPF interface commands\n"
6700 "Router priority\n" // ignored
6702 "Address of interface")
6704 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6706 struct route_node
*rn
;
6707 struct in_addr addr
;
6708 struct ospf_if_params
*params
;
6710 params
= IF_DEF_PARAMS (ifp
);
6712 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6714 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6716 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6721 params
= ospf_lookup_if_params (ifp
, addr
);
6726 UNSET_IF_PARAM (params
, priority
);
6727 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6729 if (params
!= IF_DEF_PARAMS (ifp
))
6731 ospf_free_if_params (ifp
, addr
);
6732 ospf_if_update_params (ifp
, addr
);
6735 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6737 struct ospf_interface
*oi
= rn
->info
;
6742 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6744 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6745 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6752 DEFUN_HIDDEN (no_ospf_priority
,
6753 no_ospf_priority_cmd
,
6754 "no ospf priority [(0-255) [A.B.C.D]]",
6756 "OSPF interface commands\n"
6759 "Address of interface")
6761 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6764 DEFUN (ip_ospf_retransmit_interval
,
6765 ip_ospf_retransmit_interval_addr_cmd
,
6766 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6768 "OSPF interface commands\n"
6769 "Time between retransmitting lost link state advertisements\n"
6771 "Address of interface")
6773 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6776 struct in_addr addr
;
6777 struct ospf_if_params
*params
;
6778 params
= IF_DEF_PARAMS (ifp
);
6780 argv_find (argv
, argc
, "(3-65535)", &idx
);
6781 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6783 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6785 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6787 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6792 params
= ospf_get_if_params (ifp
, addr
);
6793 ospf_if_update_params (ifp
, addr
);
6796 SET_IF_PARAM (params
, retransmit_interval
);
6797 params
->retransmit_interval
= seconds
;
6802 DEFUN_HIDDEN (ospf_retransmit_interval
,
6803 ospf_retransmit_interval_cmd
,
6804 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6805 "OSPF interface commands\n"
6806 "Time between retransmitting lost link state advertisements\n"
6808 "Address of interface")
6810 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6813 DEFUN (no_ip_ospf_retransmit_interval
,
6814 no_ip_ospf_retransmit_interval_addr_cmd
,
6815 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6818 "OSPF interface commands\n"
6819 "Time between retransmitting lost link state advertisements\n"
6821 "Address of interface\n")
6823 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6825 struct in_addr addr
;
6826 struct ospf_if_params
*params
;
6828 params
= IF_DEF_PARAMS (ifp
);
6830 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6832 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6834 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6839 params
= ospf_lookup_if_params (ifp
, addr
);
6844 UNSET_IF_PARAM (params
, retransmit_interval
);
6845 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6847 if (params
!= IF_DEF_PARAMS (ifp
))
6849 ospf_free_if_params (ifp
, addr
);
6850 ospf_if_update_params (ifp
, addr
);
6856 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6857 no_ospf_retransmit_interval_cmd
,
6858 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6860 "OSPF interface commands\n"
6861 "Time between retransmitting lost link state advertisements\n"
6863 "Address of interface\n")
6865 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6868 DEFUN (ip_ospf_transmit_delay
,
6869 ip_ospf_transmit_delay_addr_cmd
,
6870 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6872 "OSPF interface commands\n"
6873 "Link state transmit delay\n"
6875 "Address of interface")
6877 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6880 struct in_addr addr
;
6881 struct ospf_if_params
*params
;
6883 params
= IF_DEF_PARAMS (ifp
);
6884 argv_find (argv
, argc
, "(1-65535)", &idx
);
6885 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6887 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6889 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6891 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6896 params
= ospf_get_if_params (ifp
, addr
);
6897 ospf_if_update_params (ifp
, addr
);
6900 SET_IF_PARAM (params
, transmit_delay
);
6901 params
->transmit_delay
= seconds
;
6906 DEFUN_HIDDEN (ospf_transmit_delay
,
6907 ospf_transmit_delay_cmd
,
6908 "ospf transmit-delay (1-65535) [A.B.C.D]",
6909 "OSPF interface commands\n"
6910 "Link state transmit delay\n"
6912 "Address of interface")
6914 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6917 DEFUN (no_ip_ospf_transmit_delay
,
6918 no_ip_ospf_transmit_delay_addr_cmd
,
6919 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6922 "OSPF interface commands\n"
6923 "Link state transmit delay\n"
6924 "Address of interface")
6926 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6928 struct in_addr addr
;
6929 struct ospf_if_params
*params
;
6931 params
= IF_DEF_PARAMS (ifp
);
6933 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6935 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6937 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6942 params
= ospf_lookup_if_params (ifp
, addr
);
6947 UNSET_IF_PARAM (params
, transmit_delay
);
6948 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6950 if (params
!= IF_DEF_PARAMS (ifp
))
6952 ospf_free_if_params (ifp
, addr
);
6953 ospf_if_update_params (ifp
, addr
);
6960 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6961 no_ospf_transmit_delay_cmd
,
6962 "no ospf transmit-delay",
6964 "OSPF interface commands\n"
6965 "Link state transmit delay\n")
6967 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6970 DEFUN (ip_ospf_area
,
6972 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6974 "OSPF interface commands\n"
6976 "Enable OSPF on this interface\n"
6977 "OSPF area ID in IP address format\n"
6978 "OSPF area ID as a decimal value\n")
6980 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6983 struct in_addr area_id
;
6985 struct ospf_if_params
*params
;
6986 struct route_node
*rn
;
6987 u_short instance
= 0;
6989 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
6990 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
6991 char *areaid
= argv
[argc
- 1]->arg
;
6993 ospf
= ospf_lookup_instance (instance
);
6996 params
= IF_DEF_PARAMS (ifp
);
6997 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
6999 ospf_interface_unset (ifp
);
7000 ospf
= ospf_lookup();
7001 ospf
->if_ospf_cli_count
--;
7006 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7009 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7013 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7015 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7019 params
= IF_DEF_PARAMS (ifp
);
7020 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7023 "Must remove previous area config before changing ospf area %s",
7028 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7030 if (rn
->info
!= NULL
)
7032 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7037 /* enable ospf on this interface with area_id */
7038 ospf_interface_set (ifp
, area_id
);
7039 ospf
->if_ospf_cli_count
++;
7044 DEFUN (no_ip_ospf_area
,
7045 no_ip_ospf_area_cmd
,
7046 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7049 "OSPF interface commands\n"
7051 "Disable OSPF on this interface\n"
7052 "OSPF area ID in IP address format\n"
7053 "OSPF area ID as a decimal value\n")
7055 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7058 struct ospf_if_params
*params
;
7059 u_short instance
= 0;
7061 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7062 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7064 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7067 params
= IF_DEF_PARAMS (ifp
);
7068 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7070 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7074 ospf_interface_unset (ifp
);
7075 ospf
->if_ospf_cli_count
--;
7079 DEFUN (ospf_redistribute_source
,
7080 ospf_redistribute_source_cmd
,
7081 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7083 FRR_REDIST_HELP_STR_OSPFD
7084 "Metric for redistributed routes\n"
7085 "OSPF default metric\n"
7086 "OSPF exterior metric type for redistributed routes\n"
7087 "Set OSPF External Type 1 metrics\n"
7088 "Set OSPF External Type 2 metrics\n"
7089 "Route map reference\n"
7090 "Pointer to route-map entries\n")
7092 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7093 int idx_protocol
= 1;
7097 struct ospf_redist
*red
;
7103 /* Get distribute source. */
7104 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7108 red
= ospf_redist_add(ospf
, source
, 0);
7110 /* Get metric value. */
7111 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7112 if (!str2metric (argv
[idx
]->arg
, &metric
))
7115 /* Get metric type. */
7116 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7117 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7121 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7122 ospf_routemap_set (red
, argv
[idx
]->arg
);
7125 ospf_routemap_unset (red
);
7127 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7130 DEFUN (no_ospf_redistribute_source
,
7131 no_ospf_redistribute_source_cmd
,
7132 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7135 FRR_REDIST_HELP_STR_OSPFD
7136 "Metric for redistributed routes\n"
7137 "OSPF default metric\n"
7138 "OSPF exterior metric type for redistributed routes\n"
7139 "Set OSPF External Type 1 metrics\n"
7140 "Set OSPF External Type 2 metrics\n"
7141 "Route map reference\n"
7142 "Pointer to route-map entries\n")
7144 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7145 int idx_protocol
= 2;
7147 struct ospf_redist
*red
;
7149 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7153 red
= ospf_redist_lookup(ospf
, source
, 0);
7157 ospf_routemap_unset (red
);
7158 return ospf_redistribute_unset (ospf
, source
, 0);
7161 DEFUN (ospf_redistribute_instance_source
,
7162 ospf_redistribute_instance_source_cmd
,
7163 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7165 "Open Shortest Path First\n"
7166 "Non-main Kernel Routing Table\n"
7167 "Instance ID/Table ID\n"
7168 "Metric for redistributed routes\n"
7169 "OSPF default metric\n"
7170 "OSPF exterior metric type for redistributed routes\n"
7171 "Set OSPF External Type 1 metrics\n"
7172 "Set OSPF External Type 2 metrics\n"
7173 "Route map reference\n"
7174 "Pointer to route-map entries\n")
7176 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7177 int idx_ospf_table
= 1;
7184 struct ospf_redist
*red
;
7189 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7191 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7196 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7198 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7203 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7205 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7210 /* Get metric value. */
7211 if (argv_find (argv
, argc
, "metric", &idx
))
7212 if (!str2metric (argv
[idx
+1]->arg
, &metric
))
7216 /* Get metric type. */
7217 if (argv_find (argv
, argc
, "metric-type", &idx
))
7218 if (!str2metric_type (argv
[idx
+1]->arg
, &type
))
7221 red
= ospf_redist_add(ospf
, source
, instance
);
7224 if (argv_find (argv
, argc
, "route-map", &idx
))
7225 ospf_routemap_set (red
, argv
[idx
+1]->arg
);
7227 ospf_routemap_unset (red
);
7229 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7232 DEFUN (no_ospf_redistribute_instance_source
,
7233 no_ospf_redistribute_instance_source_cmd
,
7234 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7237 "Open Shortest Path First\n"
7238 "Non-main Kernel Routing Table\n"
7239 "Instance ID/Table Id\n"
7240 "Metric for redistributed routes\n"
7241 "OSPF default metric\n"
7242 "OSPF exterior metric type for redistributed routes\n"
7243 "Set OSPF External Type 1 metrics\n"
7244 "Set OSPF External Type 2 metrics\n"
7245 "Route map reference\n"
7246 "Pointer to route-map entries\n")
7248 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7249 int idx_ospf_table
= 2;
7252 struct ospf_redist
*red
;
7255 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7256 source
= ZEBRA_ROUTE_OSPF
;
7258 source
= ZEBRA_ROUTE_TABLE
;
7260 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7262 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7264 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7269 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7271 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7276 red
= ospf_redist_lookup(ospf
, source
, instance
);
7280 ospf_routemap_unset (red
);
7281 return ospf_redistribute_unset (ospf
, source
, instance
);
7284 DEFUN (ospf_distribute_list_out
,
7285 ospf_distribute_list_out_cmd
,
7286 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7287 "Filter networks in routing updates\n"
7288 "Access-list name\n"
7290 FRR_REDIST_HELP_STR_OSPFD
)
7292 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7296 char *proto
= argv
[argc
- 1]->text
;
7298 /* Get distribute source. */
7299 source
= proto_redistnum(AFI_IP
, proto
);
7303 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7306 DEFUN (no_ospf_distribute_list_out
,
7307 no_ospf_distribute_list_out_cmd
,
7308 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7310 "Filter networks in routing updates\n"
7311 "Access-list name\n"
7313 FRR_REDIST_HELP_STR_OSPFD
)
7315 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7319 char *proto
= argv
[argc
- 1]->text
;
7320 source
= proto_redistnum(AFI_IP
, proto
);
7324 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7327 /* Default information originate. */
7328 DEFUN (ospf_default_information_originate
,
7329 ospf_default_information_originate_cmd
,
7330 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7331 "Control distribution of default information\n"
7332 "Distribute a default route\n"
7333 "Always advertise default route\n"
7334 "OSPF default metric\n"
7336 "OSPF metric type for default routes\n"
7337 "Set OSPF External Type 1 metrics\n"
7338 "Set OSPF External Type 2 metrics\n"
7339 "Route map reference\n"
7340 "Pointer to route-map entries\n")
7342 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7343 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7346 struct ospf_redist
*red
;
7349 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7351 /* Check whether "always" was specified */
7352 if (argv_find (argv
, argc
, "always", &idx
))
7353 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7354 /* Get metric value */
7355 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7356 if (!str2metric (argv
[idx
]->arg
, &metric
))
7359 /* Get metric type. */
7360 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7361 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7365 else if (argv_find (argv
, argc
, "WORD", &idx
))
7366 ospf_routemap_set (red
, argv
[idx
]->arg
);
7368 ospf_routemap_unset (red
);
7370 return ospf_redistribute_default_set (ospf
, default_originate
,
7374 DEFUN (no_ospf_default_information_originate
,
7375 no_ospf_default_information_originate_cmd
,
7376 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7378 "Control distribution of default information\n"
7379 "Distribute a default route\n"
7380 "Always advertise default route\n"
7381 "OSPF default metric\n"
7383 "OSPF metric type for default routes\n"
7384 "Set OSPF External Type 1 metrics\n"
7385 "Set OSPF External Type 2 metrics\n"
7386 "Route map reference\n"
7387 "Pointer to route-map entries\n")
7389 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7390 struct prefix_ipv4 p
;
7391 struct ospf_external
*ext
;
7392 struct ospf_redist
*red
;
7395 p
.prefix
.s_addr
= 0;
7398 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7400 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7401 EXTERNAL_INFO (ext
)) {
7402 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7403 ospf_external_del (DEFAULT_ROUTE
, 0);
7406 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7410 ospf_routemap_unset (red
);
7411 return ospf_redistribute_default_unset (ospf
);
7414 DEFUN (ospf_default_metric
,
7415 ospf_default_metric_cmd
,
7416 "default-metric (0-16777214)",
7417 "Set metric of redistributed routes\n"
7420 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7424 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7427 ospf
->default_metric
= metric
;
7432 DEFUN (no_ospf_default_metric
,
7433 no_ospf_default_metric_cmd
,
7434 "no default-metric [(0-16777214)]",
7436 "Set metric of redistributed routes\n"
7439 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7441 ospf
->default_metric
= -1;
7447 DEFUN (ospf_distance
,
7450 "Administrative distance\n"
7451 "OSPF Administrative distance\n")
7453 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7456 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7461 DEFUN (no_ospf_distance
,
7462 no_ospf_distance_cmd
,
7463 "no distance (1-255)",
7465 "Administrative distance\n"
7466 "OSPF Administrative distance\n")
7468 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7470 ospf
->distance_all
= 0;
7475 DEFUN (no_ospf_distance_ospf
,
7476 no_ospf_distance_ospf_cmd
,
7477 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7479 "Administrative distance\n"
7480 "OSPF administrative distance\n"
7481 "Intra-area routes\n"
7482 "Distance for intra-area routes\n"
7483 "Inter-area routes\n"
7484 "Distance for inter-area routes\n"
7486 "Distance for external routes\n")
7488 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7494 if (argv_find (argv
, argc
, "intra-area", &idx
) || argc
== 3)
7495 idx
= ospf
->distance_intra
= 0;
7496 if (argv_find (argv
, argc
, "inter-area", &idx
) || argc
== 3)
7497 idx
= ospf
->distance_inter
= 0;
7498 if (argv_find (argv
, argc
, "external", &idx
) || argc
== 3)
7499 ospf
->distance_external
= 0;
7504 DEFUN (ospf_distance_ospf
,
7505 ospf_distance_ospf_cmd
,
7506 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7507 "Administrative distance\n"
7508 "OSPF administrative distance\n"
7509 "Intra-area routes\n"
7510 "Distance for intra-area routes\n"
7511 "Inter-area routes\n"
7512 "Distance for inter-area routes\n"
7514 "Distance for external routes\n")
7516 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7519 if (argv_find (argv
, argc
, "intra-area", &idx
))
7520 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7522 if (argv_find (argv
, argc
, "inter-area", &idx
))
7523 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7525 if (argv_find (argv
, argc
, "external", &idx
))
7526 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7532 DEFUN (ospf_distance_source
,
7533 ospf_distance_source_cmd
,
7534 "distance (1-255) A.B.C.D/M",
7535 "Administrative distance\n"
7537 "IP source prefix\n")
7539 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7541 int idx_ipv4_prefixlen
= 2;
7546 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7551 DEFUN (no_ospf_distance_source
,
7552 no_ospf_distance_source_cmd
,
7553 "no distance (1-255) A.B.C.D/M",
7555 "Administrative distance\n"
7557 "IP source prefix\n")
7559 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7561 int idx_ipv4_prefixlen
= 3;
7566 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7571 DEFUN (ospf_distance_source_access_list
,
7572 ospf_distance_source_access_list_cmd
,
7573 "distance (1-255) A.B.C.D/M WORD",
7574 "Administrative distance\n"
7576 "IP source prefix\n"
7577 "Access list name\n")
7579 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7581 int idx_ipv4_prefixlen
= 2;
7587 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7592 DEFUN (no_ospf_distance_source_access_list
,
7593 no_ospf_distance_source_access_list_cmd
,
7594 "no distance (1-255) A.B.C.D/M WORD",
7596 "Administrative distance\n"
7598 "IP source prefix\n"
7599 "Access list name\n")
7601 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7603 int idx_ipv4_prefixlen
= 3;
7609 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7615 DEFUN (ip_ospf_mtu_ignore
,
7616 ip_ospf_mtu_ignore_addr_cmd
,
7617 "ip ospf mtu-ignore [A.B.C.D]",
7619 "OSPF interface commands\n"
7620 "Disable MTU mismatch detection on this interface\n"
7621 "Address of interface")
7623 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7625 struct in_addr addr
;
7628 struct ospf_if_params
*params
;
7629 params
= IF_DEF_PARAMS (ifp
);
7633 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7636 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7640 params
= ospf_get_if_params (ifp
, addr
);
7641 ospf_if_update_params (ifp
, addr
);
7643 params
->mtu_ignore
= 1;
7644 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7645 SET_IF_PARAM (params
, mtu_ignore
);
7648 UNSET_IF_PARAM (params
, mtu_ignore
);
7649 if (params
!= IF_DEF_PARAMS (ifp
))
7651 ospf_free_if_params (ifp
, addr
);
7652 ospf_if_update_params (ifp
, addr
);
7658 DEFUN (no_ip_ospf_mtu_ignore
,
7659 no_ip_ospf_mtu_ignore_addr_cmd
,
7660 "no ip ospf mtu-ignore [A.B.C.D]",
7662 "OSPF interface commands\n"
7663 "Disable MTU mismatch detection on this interface\n"
7664 "Address of interface")
7666 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7668 struct in_addr addr
;
7671 struct ospf_if_params
*params
;
7672 params
= IF_DEF_PARAMS (ifp
);
7676 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7679 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7683 params
= ospf_get_if_params (ifp
, addr
);
7684 ospf_if_update_params (ifp
, addr
);
7686 params
->mtu_ignore
= 0;
7687 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7688 SET_IF_PARAM (params
, mtu_ignore
);
7691 UNSET_IF_PARAM (params
, mtu_ignore
);
7692 if (params
!= IF_DEF_PARAMS (ifp
))
7694 ospf_free_if_params (ifp
, addr
);
7695 ospf_if_update_params (ifp
, addr
);
7702 DEFUN (ospf_max_metric_router_lsa_admin
,
7703 ospf_max_metric_router_lsa_admin_cmd
,
7704 "max-metric router-lsa administrative",
7705 "OSPF maximum / infinite-distance metric\n"
7706 "Advertise own Router-LSA with infinite distance (stub router)\n"
7707 "Administratively applied, for an indefinite period\n")
7709 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7710 struct listnode
*ln
;
7711 struct ospf_area
*area
;
7713 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7715 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7717 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7718 ospf_router_lsa_update_area (area
);
7721 /* Allows for areas configured later to get the property */
7722 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7727 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7728 no_ospf_max_metric_router_lsa_admin_cmd
,
7729 "no max-metric router-lsa administrative",
7731 "OSPF maximum / infinite-distance metric\n"
7732 "Advertise own Router-LSA with infinite distance (stub router)\n"
7733 "Administratively applied, for an indefinite period\n")
7735 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7736 struct listnode
*ln
;
7737 struct ospf_area
*area
;
7739 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7741 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7743 /* Don't trample on the start-up stub timer */
7744 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7745 && !area
->t_stub_router
)
7747 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7748 ospf_router_lsa_update_area (area
);
7751 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7755 DEFUN (ospf_max_metric_router_lsa_startup
,
7756 ospf_max_metric_router_lsa_startup_cmd
,
7757 "max-metric router-lsa on-startup (5-86400)",
7758 "OSPF maximum / infinite-distance metric\n"
7759 "Advertise own Router-LSA with infinite distance (stub router)\n"
7760 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7761 "Time (seconds) to advertise self as stub-router\n")
7763 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7765 unsigned int seconds
;
7769 vty_out (vty
, "%% Must supply stub-router period");
7773 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7775 ospf
->stub_router_startup_time
= seconds
;
7780 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7781 no_ospf_max_metric_router_lsa_startup_cmd
,
7782 "no max-metric router-lsa on-startup [(5-86400)]",
7784 "OSPF maximum / infinite-distance metric\n"
7785 "Advertise own Router-LSA with infinite distance (stub router)\n"
7786 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7787 "Time (seconds) to advertise self as stub-router\n")
7789 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7790 struct listnode
*ln
;
7791 struct ospf_area
*area
;
7793 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7795 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7797 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7798 OSPF_TIMER_OFF (area
->t_stub_router
);
7800 /* Don't trample on admin stub routed */
7801 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7803 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7804 ospf_router_lsa_update_area (area
);
7811 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7812 ospf_max_metric_router_lsa_shutdown_cmd
,
7813 "max-metric router-lsa on-shutdown (5-100)",
7814 "OSPF maximum / infinite-distance metric\n"
7815 "Advertise own Router-LSA with infinite distance (stub router)\n"
7816 "Advertise stub-router prior to full shutdown of OSPF\n"
7817 "Time (seconds) to wait till full shutdown\n")
7819 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7821 unsigned int seconds
;
7825 vty_out (vty
, "%% Must supply stub-router shutdown period");
7829 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7831 ospf
->stub_router_shutdown_time
= seconds
;
7836 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7837 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7838 "no max-metric router-lsa on-shutdown [(5-100)]",
7840 "OSPF maximum / infinite-distance metric\n"
7841 "Advertise own Router-LSA with infinite distance (stub router)\n"
7842 "Advertise stub-router prior to full shutdown of OSPF\n"
7843 "Time (seconds) to wait till full shutdown\n")
7845 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7847 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7853 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7855 struct listnode
*ln
;
7856 struct ospf_area
*area
;
7858 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7859 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7860 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7861 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7862 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7863 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7864 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7866 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7868 vty_out (vty
, " max-metric router-lsa administrative%s",
7877 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7879 struct route_node
*rn
;
7880 struct ospf_route
*or;
7881 struct listnode
*pnode
, *pnnode
;
7882 struct ospf_path
*path
;
7884 vty_out (vty
, "============ OSPF network routing table ============%s",
7887 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7888 if ((or = rn
->info
) != NULL
)
7891 snprintf (buf1
, 19, "%s/%d",
7892 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7894 switch (or->path_type
)
7896 case OSPF_PATH_INTER_AREA
:
7897 if (or->type
== OSPF_DESTINATION_NETWORK
)
7898 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7899 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7900 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7901 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7903 case OSPF_PATH_INTRA_AREA
:
7904 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7905 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7911 if (or->type
== OSPF_DESTINATION_NETWORK
)
7912 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7914 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7916 if (path
->nexthop
.s_addr
== 0)
7917 vty_out (vty
, "%24s directly attached to %s%s",
7918 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7920 vty_out (vty
, "%24s via %s, %s%s", "",
7921 inet_ntoa (path
->nexthop
),
7922 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7926 vty_out (vty
, "%s", VTY_NEWLINE
);
7930 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7932 struct route_node
*rn
;
7933 struct ospf_route
*or;
7934 struct listnode
*pnode
;
7935 struct listnode
*node
;
7936 struct ospf_path
*path
;
7938 vty_out (vty
, "============ OSPF router routing table =============%s",
7940 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7945 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7947 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7950 vty_out (vty
, "%24s", "");
7953 vty_out (vty
, "%s [%d] area: %s",
7954 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7955 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7957 vty_out (vty
, "%s%s%s",
7958 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
7959 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
7962 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
7964 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7966 if (path
->nexthop
.s_addr
== 0)
7967 vty_out (vty
, "%24s directly attached to %s%s",
7968 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7971 vty_out (vty
, "%24s via %s, %s%s", "",
7972 inet_ntoa (path
->nexthop
),
7973 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7979 vty_out (vty
, "%s", VTY_NEWLINE
);
7983 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
7985 struct route_node
*rn
;
7986 struct ospf_route
*er
;
7987 struct listnode
*pnode
, *pnnode
;
7988 struct ospf_path
*path
;
7990 vty_out (vty
, "============ OSPF external routing table ===========%s",
7992 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7993 if ((er
= rn
->info
) != NULL
)
7996 snprintf (buf1
, 19, "%s/%d",
7997 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7999 switch (er
->path_type
)
8001 case OSPF_PATH_TYPE1_EXTERNAL
:
8002 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8003 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8005 case OSPF_PATH_TYPE2_EXTERNAL
:
8006 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8007 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8011 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8013 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
8015 if (path
->nexthop
.s_addr
== 0)
8016 vty_out (vty
, "%24s directly attached to %s%s",
8017 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
8019 vty_out (vty
, "%24s via %s, %s%s", "",
8020 inet_ntoa (path
->nexthop
),
8021 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
8026 vty_out (vty
, "%s", VTY_NEWLINE
);
8030 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8033 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8034 VTY_NEWLINE
, VTY_NEWLINE
);
8036 if (ospf
->new_table
== NULL
)
8038 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8042 /* Show Network routes.
8043 show_ip_ospf_route_network (vty, ospf->new_table); */
8045 /* Show Router routes. */
8046 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8048 vty_out (vty
, "%s", VTY_NEWLINE
);
8053 DEFUN (show_ip_ospf_border_routers
,
8054 show_ip_ospf_border_routers_cmd
,
8055 "show ip ospf border-routers",
8058 "OSPF information\n"
8059 "Show all the ABR's and ASBR's\n")
8063 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8066 return show_ip_ospf_border_routers_common(vty
, ospf
);
8069 DEFUN (show_ip_ospf_instance_border_routers
,
8070 show_ip_ospf_instance_border_routers_cmd
,
8071 "show ip ospf (1-65535) border-routers",
8074 "OSPF information\n"
8076 "Show all the ABR's and ASBR's\n")
8080 u_short instance
= 0;
8082 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8083 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8086 return show_ip_ospf_border_routers_common(vty
, ospf
);
8090 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8093 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8094 VTY_NEWLINE
, VTY_NEWLINE
);
8096 if (ospf
->new_table
== NULL
)
8098 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8102 /* Show Network routes. */
8103 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8105 /* Show Router routes. */
8106 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8108 /* Show AS External routes. */
8109 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8111 vty_out (vty
, "%s", VTY_NEWLINE
);
8116 DEFUN (show_ip_ospf_route
,
8117 show_ip_ospf_route_cmd
,
8118 "show ip ospf route",
8121 "OSPF information\n"
8122 "OSPF routing table\n")
8126 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8129 return show_ip_ospf_route_common(vty
, ospf
);
8132 DEFUN (show_ip_ospf_instance_route
,
8133 show_ip_ospf_instance_route_cmd
,
8134 "show ip ospf (1-65535) route",
8137 "OSPF information\n"
8139 "OSPF routing table\n")
8143 u_short instance
= 0;
8145 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8146 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8149 return show_ip_ospf_route_common(vty
, ospf
);
8152 const char *ospf_abr_type_str
[] =
8161 const char *ospf_shortcut_mode_str
[] =
8170 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8172 memset (buf
, 0, length
);
8174 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8175 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8177 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8181 const char *ospf_int_type_str
[] =
8183 "unknown", /* should never be used. */
8187 "point-to-multipoint",
8188 "virtual-link", /* should never be used. */
8192 /* Configuration write function for ospfd. */
8194 config_write_interface (struct vty
*vty
)
8196 struct listnode
*n1
, *n2
;
8197 struct interface
*ifp
;
8198 struct crypt_key
*ck
;
8200 struct route_node
*rn
= NULL
;
8201 struct ospf_if_params
*params
;
8202 struct ospf
*ospf
= ospf_lookup();
8204 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8206 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8209 if (ifp
->ifindex
== IFINDEX_DELETED
)
8212 vty_out (vty
, "!%s", VTY_NEWLINE
);
8213 vty_out (vty
, "interface %s%s", ifp
->name
,
8216 vty_out (vty
, " description %s%s", ifp
->desc
,
8221 params
= IF_DEF_PARAMS (ifp
);
8224 /* Interface Network print. */
8225 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8226 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8228 if (params
->type
!= ospf_default_iftype(ifp
))
8230 vty_out (vty
, " ip ospf network %s",
8231 ospf_int_type_str
[params
->type
]);
8232 if (params
!= IF_DEF_PARAMS (ifp
))
8233 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8234 vty_out (vty
, "%s", VTY_NEWLINE
);
8238 /* OSPF interface authentication print */
8239 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8240 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8242 const char *auth_str
;
8244 /* Translation tables are not that much help here due to syntax
8245 of the simple option */
8246 switch (params
->auth_type
)
8249 case OSPF_AUTH_NULL
:
8253 case OSPF_AUTH_SIMPLE
:
8257 case OSPF_AUTH_CRYPTOGRAPHIC
:
8258 auth_str
= " message-digest";
8266 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8267 if (params
!= IF_DEF_PARAMS (ifp
))
8268 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8269 vty_out (vty
, "%s", VTY_NEWLINE
);
8272 /* Simple Authentication Password print. */
8273 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8274 params
->auth_simple
[0] != '\0')
8276 vty_out (vty
, " ip ospf authentication-key %s",
8277 params
->auth_simple
);
8278 if (params
!= IF_DEF_PARAMS (ifp
))
8279 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8280 vty_out (vty
, "%s", VTY_NEWLINE
);
8283 /* Cryptographic Authentication Key print. */
8284 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8286 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8287 ck
->key_id
, ck
->auth_key
);
8288 if (params
!= IF_DEF_PARAMS (ifp
))
8289 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8290 vty_out (vty
, "%s", VTY_NEWLINE
);
8293 /* Interface Output Cost print. */
8294 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8296 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8297 if (params
!= IF_DEF_PARAMS (ifp
))
8298 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8299 vty_out (vty
, "%s", VTY_NEWLINE
);
8302 /* Hello Interval print. */
8303 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8304 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8306 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8307 if (params
!= IF_DEF_PARAMS (ifp
))
8308 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8309 vty_out (vty
, "%s", VTY_NEWLINE
);
8313 /* Router Dead Interval print. */
8314 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8315 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8317 vty_out (vty
, " ip ospf dead-interval ");
8320 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8321 vty_out (vty
, "minimal hello-multiplier %d",
8322 params
->fast_hello
);
8324 vty_out (vty
, "%u", params
->v_wait
);
8326 if (params
!= IF_DEF_PARAMS (ifp
))
8327 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8328 vty_out (vty
, "%s", VTY_NEWLINE
);
8331 /* Router Priority print. */
8332 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8333 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8335 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8336 if (params
!= IF_DEF_PARAMS (ifp
))
8337 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8338 vty_out (vty
, "%s", VTY_NEWLINE
);
8341 /* Retransmit Interval print. */
8342 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8343 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8345 vty_out (vty
, " ip ospf retransmit-interval %u",
8346 params
->retransmit_interval
);
8347 if (params
!= IF_DEF_PARAMS (ifp
))
8348 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8349 vty_out (vty
, "%s", VTY_NEWLINE
);
8352 /* Transmit Delay print. */
8353 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8354 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8356 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8357 if (params
!= IF_DEF_PARAMS (ifp
))
8358 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8359 vty_out (vty
, "%s", VTY_NEWLINE
);
8363 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8366 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8367 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8369 vty_out (vty
, " ip ospf area %s%s",
8370 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8375 ospf_bfd_write_config(vty
, params
);
8377 /* MTU ignore print. */
8378 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8379 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8381 if (params
->mtu_ignore
== 0)
8382 vty_out (vty
, " no ip ospf mtu-ignore");
8384 vty_out (vty
, " ip ospf mtu-ignore");
8385 if (params
!= IF_DEF_PARAMS (ifp
))
8386 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8387 vty_out (vty
, "%s", VTY_NEWLINE
);
8394 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8396 rn
= route_next (rn
);
8406 ospf_opaque_config_write_if (vty
, ifp
);
8413 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8415 struct route_node
*rn
;
8416 u_char buf
[INET_ADDRSTRLEN
];
8418 /* `network area' print. */
8419 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8422 struct ospf_network
*n
= rn
->info
;
8424 memset (buf
, 0, INET_ADDRSTRLEN
);
8426 /* Create Area ID string by specified Area ID format. */
8427 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8428 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8430 sprintf ((char *) buf
, "%lu",
8431 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8433 /* Network print. */
8434 vty_out (vty
, " network %s/%d area %s%s",
8435 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8443 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8445 struct listnode
*node
;
8446 struct ospf_area
*area
;
8447 u_char buf
[INET_ADDRSTRLEN
];
8449 /* Area configuration print. */
8450 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8452 struct route_node
*rn1
;
8454 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8456 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8458 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8459 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8461 vty_out (vty
, " area %s authentication message-digest%s",
8465 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8466 vty_out (vty
, " area %s shortcut %s%s", buf
,
8467 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8470 if ((area
->external_routing
== OSPF_AREA_STUB
)
8471 || (area
->external_routing
== OSPF_AREA_NSSA
)
8474 if (area
->external_routing
== OSPF_AREA_STUB
)
8475 vty_out (vty
, " area %s stub", buf
);
8476 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8478 vty_out (vty
, " area %s nssa", buf
);
8479 switch (area
->NSSATranslatorRole
)
8481 case OSPF_NSSA_ROLE_NEVER
:
8482 vty_out (vty
, " translate-never");
8484 case OSPF_NSSA_ROLE_ALWAYS
:
8485 vty_out (vty
, " translate-always");
8487 case OSPF_NSSA_ROLE_CANDIDATE
:
8489 vty_out (vty
, " translate-candidate");
8493 if (area
->no_summary
)
8494 vty_out (vty
, " no-summary");
8496 vty_out (vty
, "%s", VTY_NEWLINE
);
8498 if (area
->default_cost
!= 1)
8499 vty_out (vty
, " area %s default-cost %d%s", buf
,
8500 area
->default_cost
, VTY_NEWLINE
);
8503 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8506 struct ospf_area_range
*range
= rn1
->info
;
8508 vty_out (vty
, " area %s range %s/%d", buf
,
8509 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8511 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8512 vty_out (vty
, " cost %d", range
->cost_config
);
8514 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8515 vty_out (vty
, " not-advertise");
8517 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8518 vty_out (vty
, " substitute %s/%d",
8519 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8521 vty_out (vty
, "%s", VTY_NEWLINE
);
8524 if (EXPORT_NAME (area
))
8525 vty_out (vty
, " area %s export-list %s%s", buf
,
8526 EXPORT_NAME (area
), VTY_NEWLINE
);
8528 if (IMPORT_NAME (area
))
8529 vty_out (vty
, " area %s import-list %s%s", buf
,
8530 IMPORT_NAME (area
), VTY_NEWLINE
);
8532 if (PREFIX_NAME_IN (area
))
8533 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8534 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8536 if (PREFIX_NAME_OUT (area
))
8537 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8538 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8545 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8547 struct ospf_nbr_nbma
*nbr_nbma
;
8548 struct route_node
*rn
;
8550 /* Static Neighbor configuration print. */
8551 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8552 if ((nbr_nbma
= rn
->info
))
8554 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8556 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8557 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8559 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8560 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8562 vty_out (vty
, "%s", VTY_NEWLINE
);
8569 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8571 struct listnode
*node
;
8572 struct ospf_vl_data
*vl_data
;
8573 u_char buf
[INET_ADDRSTRLEN
];
8575 /* Virtual-Link print */
8576 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8578 struct listnode
*n2
;
8579 struct crypt_key
*ck
;
8580 struct ospf_interface
*oi
;
8582 if (vl_data
!= NULL
)
8584 memset (buf
, 0, INET_ADDRSTRLEN
);
8586 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8587 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8589 sprintf ((char *) buf
, "%lu",
8590 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8591 oi
= vl_data
->vl_oi
;
8594 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8595 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8596 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8597 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8598 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8600 inet_ntoa (vl_data
->vl_peer
),
8601 OSPF_IF_PARAM (oi
, v_hello
),
8602 OSPF_IF_PARAM (oi
, retransmit_interval
),
8603 OSPF_IF_PARAM (oi
, transmit_delay
),
8604 OSPF_IF_PARAM (oi
, v_wait
),
8607 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8608 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8610 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8611 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8613 inet_ntoa (vl_data
->vl_peer
),
8614 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8617 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8619 vty_out (vty
, " area %s virtual-link %s"
8620 " message-digest-key %d md5 %s%s",
8622 inet_ntoa (vl_data
->vl_peer
),
8623 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8633 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8637 /* redistribute print. */
8638 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8640 struct list
*red_list
;
8641 struct listnode
*node
;
8642 struct ospf_redist
*red
;
8644 red_list
= ospf
->redist
[type
];
8648 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8650 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8652 vty_out (vty
, " %d", red
->instance
);
8654 if (red
->dmetric
.value
>= 0)
8655 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8657 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8658 vty_out (vty
, " metric-type 1");
8660 if (ROUTEMAP_NAME (red
))
8661 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8663 vty_out (vty
, "%s", VTY_NEWLINE
);
8671 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8673 if (ospf
->default_metric
!= -1)
8674 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8680 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8683 struct ospf_redist
*red
;
8687 /* distribute-list print. */
8688 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8689 if (DISTRIBUTE_NAME (ospf
, type
))
8690 vty_out (vty
, " distribute-list %s out %s%s",
8691 DISTRIBUTE_NAME (ospf
, type
),
8692 zebra_route_string(type
), VTY_NEWLINE
);
8694 /* default-information print. */
8695 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8697 vty_out (vty
, " default-information originate");
8698 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8699 vty_out (vty
, " always");
8701 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8704 if (red
->dmetric
.value
>= 0)
8705 vty_out (vty
, " metric %d",
8706 red
->dmetric
.value
);
8707 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8708 vty_out (vty
, " metric-type 1");
8710 if (ROUTEMAP_NAME (red
))
8711 vty_out (vty
, " route-map %s",
8712 ROUTEMAP_NAME (red
));
8715 vty_out (vty
, "%s", VTY_NEWLINE
);
8724 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8726 struct route_node
*rn
;
8727 struct ospf_distance
*odistance
;
8729 if (ospf
->distance_all
)
8730 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8732 if (ospf
->distance_intra
8733 || ospf
->distance_inter
8734 || ospf
->distance_external
)
8736 vty_out (vty
, " distance ospf");
8738 if (ospf
->distance_intra
)
8739 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8740 if (ospf
->distance_inter
)
8741 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8742 if (ospf
->distance_external
)
8743 vty_out (vty
, " external %d", ospf
->distance_external
);
8745 vty_out (vty
, "%s", VTY_NEWLINE
);
8748 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8749 if ((odistance
= rn
->info
) != NULL
)
8751 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8752 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8753 odistance
->access_list
? odistance
->access_list
: "",
8759 /* OSPF configuration write function. */
8761 ospf_config_write (struct vty
*vty
)
8764 struct interface
*ifp
;
8765 struct ospf_interface
*oi
;
8766 struct listnode
*node
;
8769 ospf
= ospf_lookup ();
8770 if (ospf
!= NULL
&& ospf
->oi_running
)
8772 /* `router ospf' print. */
8774 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8776 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8780 if (!ospf
->networks
)
8783 /* Router ID print. */
8784 if (ospf
->router_id_static
.s_addr
!= 0)
8785 vty_out (vty
, " ospf router-id %s%s",
8786 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8788 /* ABR type print. */
8789 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8790 vty_out (vty
, " ospf abr-type %s%s",
8791 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8793 /* log-adjacency-changes flag print. */
8794 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8796 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8797 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8798 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8799 vty_out(vty
, " log-adjacency-changes%s", VTY_NEWLINE
);
8801 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8803 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8806 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8807 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8808 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8810 /* auto-cost reference-bandwidth configuration. */
8811 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8813 vty_out (vty
, "! Important: ensure reference bandwidth "
8814 "is consistent across all routers%s", VTY_NEWLINE
);
8815 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8816 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8819 /* SPF timers print. */
8820 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8821 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8822 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8823 vty_out (vty
, " timers throttle spf %d %d %d%s",
8824 ospf
->spf_delay
, ospf
->spf_holdtime
,
8825 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8827 /* LSA timers print. */
8828 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8829 vty_out (vty
, " timers throttle lsa all %d%s",
8830 ospf
->min_ls_interval
, VTY_NEWLINE
);
8831 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8832 vty_out (vty
, " timers lsa min-arrival %d%s",
8833 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8835 /* Write multiplier print. */
8836 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8837 vty_out (vty
, " ospf write-multiplier %d%s",
8838 ospf
->write_oi_count
, VTY_NEWLINE
);
8840 /* Max-metric router-lsa print */
8841 config_write_stub_router (vty
, ospf
);
8843 /* SPF refresh parameters print. */
8844 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8845 vty_out (vty
, " refresh timer %d%s",
8846 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8848 /* Redistribute information print. */
8849 config_write_ospf_redistribute (vty
, ospf
);
8851 /* passive-interface print. */
8852 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8853 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8855 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8856 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8857 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8858 ospf
->passive_interface_default
)
8860 vty_out (vty
, " %spassive-interface %s%s",
8861 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8862 ifp
->name
, VTY_NEWLINE
);
8864 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8866 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8868 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8871 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8874 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8877 vty_out (vty
, " %spassive-interface %s %s%s",
8878 oi
->params
->passive_interface
? "" : "no ",
8880 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8883 /* Network area print. */
8884 config_write_network_area (vty
, ospf
);
8886 /* Area config print. */
8887 config_write_ospf_area (vty
, ospf
);
8889 /* static neighbor print. */
8890 config_write_ospf_nbr_nbma (vty
, ospf
);
8892 /* Virtual-Link print. */
8893 config_write_virtual_link (vty
, ospf
);
8895 /* Default metric configuration. */
8896 config_write_ospf_default_metric (vty
, ospf
);
8898 /* Distribute-list and default-information print. */
8899 config_write_ospf_distribute (vty
, ospf
);
8901 /* Distance configuration. */
8902 config_write_ospf_distance (vty
, ospf
);
8904 ospf_opaque_config_write_router (vty
, ospf
);
8911 ospf_vty_show_init (void)
8913 /* "show ip ospf" commands. */
8914 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8916 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8918 /* "show ip ospf database" commands. */
8919 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8920 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8922 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8923 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8924 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8926 /* "show ip ospf interface" commands. */
8927 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8929 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8931 /* "show ip ospf neighbor" commands. */
8932 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8933 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8934 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8935 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8936 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8937 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8938 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8940 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8941 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8942 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8943 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8944 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8945 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8946 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8948 /* "show ip ospf route" commands. */
8949 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8950 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8952 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8953 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8957 /* ospfd's interface node. */
8958 static struct cmd_node interface_node
=
8965 /* Initialization of OSPF interface. */
8967 ospf_vty_if_init (void)
8969 /* Install interface node. */
8970 install_node (&interface_node
, config_write_interface
);
8973 /* "ip ospf authentication" commands. */
8974 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8975 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8976 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
8977 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8978 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8979 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8980 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
8982 /* "ip ospf message-digest-key" commands. */
8983 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8984 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8986 /* "ip ospf cost" commands. */
8987 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8988 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8990 /* "ip ospf mtu-ignore" commands. */
8991 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8992 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8994 /* "ip ospf dead-interval" commands. */
8995 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8996 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
8997 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8999 /* "ip ospf hello-interval" commands. */
9000 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9001 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9003 /* "ip ospf network" commands. */
9004 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9005 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9007 /* "ip ospf priority" commands. */
9008 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9009 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9011 /* "ip ospf retransmit-interval" commands. */
9012 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9013 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9015 /* "ip ospf transmit-delay" commands. */
9016 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9017 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9019 /* "ip ospf area" commands. */
9020 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9021 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9023 /* These commands are compatibitliy for previous version. */
9024 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9025 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9026 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9027 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9028 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9029 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9030 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9031 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9032 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9033 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9034 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9035 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9036 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9037 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9038 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9039 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9040 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9044 ospf_vty_zebra_init (void)
9046 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9047 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9048 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9049 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9051 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9052 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9054 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9055 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9057 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9058 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9060 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9061 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9062 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9063 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9065 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9066 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9067 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9068 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9072 static struct cmd_node ospf_node
=
9075 "%s(config-router)# ",
9080 ospf_interface_clear (struct interface
*ifp
)
9082 if (!if_is_operative (ifp
)) return;
9084 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9085 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9090 DEFUN (clear_ip_ospf_interface
,
9091 clear_ip_ospf_interface_cmd
,
9092 "clear ip ospf interface [IFNAME]",
9095 "OSPF information\n"
9096 "Interface information\n"
9100 struct interface
*ifp
;
9101 struct listnode
*node
;
9103 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9105 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9106 ospf_interface_clear(ifp
);
9108 else /* Interface name is specified. */
9110 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
, VRF_DEFAULT
)) == NULL
)
9111 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9113 ospf_interface_clear(ifp
);
9120 ospf_vty_clear_init (void)
9122 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9126 /* Install OSPF related vty commands. */
9128 ospf_vty_init (void)
9130 /* Install ospf top node. */
9131 install_node (&ospf_node
, ospf_config_write
);
9133 /* "router ospf" commands. */
9134 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9135 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9138 install_default (OSPF_NODE
);
9140 /* "ospf router-id" commands. */
9141 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9142 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9143 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9145 /* "passive-interface" commands. */
9146 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9147 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9149 /* "ospf abr-type" commands. */
9150 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9151 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9153 /* "ospf log-adjacency-changes" commands. */
9154 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9155 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9156 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9157 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9159 /* "ospf rfc1583-compatible" commands. */
9160 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9161 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9162 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9163 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9165 /* "network area" commands. */
9166 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9167 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9169 /* "area authentication" commands. */
9170 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9171 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9172 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9174 /* "area range" commands. */
9175 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9176 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9177 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9178 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9179 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9180 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9182 /* "area virtual-link" commands. */
9183 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9184 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9185 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9186 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9197 /* "area stub" commands. */
9198 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9199 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9200 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9201 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9203 /* "area nssa" commands. */
9204 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9205 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9206 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9207 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9208 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9210 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9211 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9213 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9214 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9216 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9217 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9219 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9220 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9222 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9223 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9225 /* SPF timer commands */
9226 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9227 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9229 /* LSA timers commands */
9230 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9231 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9232 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9233 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9234 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9235 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9237 /* refresh timer commands */
9238 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9239 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9241 /* max-metric commands */
9242 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9243 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9244 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9245 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9246 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9247 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9249 /* reference bandwidth commands */
9250 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9251 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9253 /* "neighbor" commands. */
9254 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9255 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9256 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9257 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9259 /* write multiplier commands */
9260 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9261 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9262 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9263 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9265 /* Init interface related vty commands. */
9266 ospf_vty_if_init ();
9268 /* Init zebra related vty commands. */
9269 ospf_vty_zebra_init ();