2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
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
+ 1))
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
);
3572 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3576 json
= json_object_new_object();
3577 json_interface_sub
= json_object_new_object ();
3580 /* Show All Interfaces. */
3581 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3583 if (ospf_oi_count(ifp
))
3585 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3587 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3593 /* Interface name is specified. */
3594 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
, VRF_DEFAULT
)) == NULL
)
3597 json_object_boolean_true_add(json
, "noSuchIface");
3599 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3603 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3605 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3611 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3612 json_object_free(json
);
3615 vty_out (vty
, "%s", VTY_NEWLINE
);
3620 DEFUN (show_ip_ospf_interface
,
3621 show_ip_ospf_interface_cmd
,
3622 "show ip ospf interface [INTERFACE] [json]",
3625 "OSPF information\n"
3626 "Interface information\n"
3631 u_char uj
= use_json(argc
, argv
);
3633 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3636 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3639 DEFUN (show_ip_ospf_instance_interface
,
3640 show_ip_ospf_instance_interface_cmd
,
3641 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3644 "OSPF information\n"
3646 "Interface information\n"
3652 u_short instance
= 0;
3653 u_char uj
= use_json(argc
, argv
);
3655 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3656 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3659 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3663 show_ip_ospf_neighbour_header (struct vty
*vty
)
3665 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3667 "Neighbor ID", "Pri", "State", "Dead Time",
3668 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3673 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3675 struct route_node
*rn
;
3676 struct ospf_neighbor
*nbr
;
3678 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3679 json_object
*json_neighbor
= NULL
;
3681 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3683 if ((nbr
= rn
->info
))
3685 /* Do not show myself. */
3686 if (nbr
!= oi
->nbr_self
)
3688 /* Down state is not shown. */
3689 if (nbr
->state
!= NSM_Down
)
3693 json_neighbor
= json_object_new_object();
3694 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3698 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
3700 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3701 json_object_string_add (json_neighbor
, "state", msgbuf
);
3702 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3703 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3704 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3705 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3706 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3707 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3708 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3709 json_object_object_add(json
, "neighbor", json_neighbor
);
3711 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3715 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3717 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3718 vty_out (vty
, "%-15s %3d %-15s ",
3722 vty_out (vty
, "%-15s %3d %-15s ",
3723 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3726 vty_out (vty
, "%9s ",
3727 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3729 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3730 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3731 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3732 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3742 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3744 struct ospf_interface
*oi
;
3745 struct listnode
*node
;
3746 json_object
*json
= NULL
;
3749 json
= json_object_new_object();
3751 show_ip_ospf_neighbour_header (vty
);
3756 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3758 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3759 VTY_NEWLINE
, VTY_NEWLINE
);
3762 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3763 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3767 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3768 json_object_free(json
);
3771 vty_out (vty
, "%s", VTY_NEWLINE
);
3776 DEFUN (show_ip_ospf_neighbor
,
3777 show_ip_ospf_neighbor_cmd
,
3778 "show ip ospf neighbor [json]",
3781 "OSPF information\n"
3786 u_char uj
= use_json(argc
, argv
);
3788 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3791 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3795 DEFUN (show_ip_ospf_instance_neighbor
,
3796 show_ip_ospf_instance_neighbor_cmd
,
3797 "show ip ospf (1-65535) neighbor [json]",
3800 "OSPF information\n"
3807 u_short instance
= 0;
3808 u_char uj
= use_json(argc
, argv
);
3810 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3811 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3814 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3818 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3820 struct listnode
*node
;
3821 struct ospf_interface
*oi
;
3822 json_object
*json
= NULL
;
3823 json_object
*json_neighbor_sub
= NULL
;
3827 json
= json_object_new_object();
3828 json_neighbor_sub
= json_object_new_object();
3831 show_ip_ospf_neighbour_header (vty
);
3836 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3838 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3839 VTY_NEWLINE
, VTY_NEWLINE
);
3842 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3844 struct listnode
*nbr_node
;
3845 struct ospf_nbr_nbma
*nbr_nbma
;
3847 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3849 /* print Down neighbor status */
3850 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3852 if (nbr_nbma
->nbr
== NULL
3853 || nbr_nbma
->nbr
->state
== NSM_Down
)
3857 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3858 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3859 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3860 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3861 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3862 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3863 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3867 vty_out (vty
, "%-15s %3d %-15s %9s ",
3868 "-", nbr_nbma
->priority
, "Down", "-");
3869 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3870 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3871 0, 0, 0, VTY_NEWLINE
);
3879 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3880 json_object_free(json
);
3883 vty_out (vty
, "%s", VTY_NEWLINE
);
3888 DEFUN (show_ip_ospf_neighbor_all
,
3889 show_ip_ospf_neighbor_all_cmd
,
3890 "show ip ospf neighbor all [json]",
3893 "OSPF information\n"
3895 "include down status neighbor\n"
3899 u_char uj
= use_json(argc
, argv
);
3901 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3904 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3907 DEFUN (show_ip_ospf_instance_neighbor_all
,
3908 show_ip_ospf_instance_neighbor_all_cmd
,
3909 "show ip ospf (1-65535) neighbor all [json]",
3912 "OSPF information\n"
3915 "include down status neighbor\n"
3920 u_short instance
= 0;
3921 u_char uj
= use_json(argc
, argv
);
3923 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3924 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3927 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3931 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3932 struct cmd_token
**argv
, u_char use_json
)
3934 struct interface
*ifp
;
3935 struct route_node
*rn
;
3936 json_object
*json
= NULL
;
3939 json
= json_object_new_object();
3941 show_ip_ospf_neighbour_header (vty
);
3946 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3948 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3949 VTY_NEWLINE
, VTY_NEWLINE
);
3952 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
3956 json_object_boolean_true_add(json
, "noSuchIface");
3958 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3962 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3964 struct ospf_interface
*oi
= rn
->info
;
3969 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3974 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3975 json_object_free(json
);
3978 vty_out (vty
, "%s", VTY_NEWLINE
);
3983 DEFUN (show_ip_ospf_neighbor_int
,
3984 show_ip_ospf_neighbor_int_cmd
,
3985 "show ip ospf neighbor IFNAME [json]",
3988 "OSPF information\n"
3994 u_char uj
= use_json(argc
, argv
);
3996 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3999 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4002 DEFUN (show_ip_ospf_instance_neighbor_int
,
4003 show_ip_ospf_instance_neighbor_int_cmd
,
4004 "show ip ospf (1-65535) neighbor IFNAME [json]",
4007 "OSPF information\n"
4015 u_short instance
= 0;
4016 u_char uj
= use_json(argc
, argv
);
4018 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4019 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4022 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4026 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4027 u_char use_json
, json_object
*json
)
4029 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4030 json_object
*json_sub
= NULL
;
4033 json_sub
= json_object_new_object();
4034 else /* Show neighbor ID. */
4035 vty_out (vty
, " Neighbor %s,", "-");
4037 /* Show interface address. */
4039 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4041 vty_out (vty
, " interface address %s%s",
4042 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4047 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4048 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4051 vty_out (vty
, " In the area %s via interface %s%s",
4052 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4054 /* Show neighbor priority and state. */
4057 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4058 json_object_string_add(json_sub
, "nbrState", "down");
4061 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4062 nbr_nbma
->priority
, "Down");
4064 /* Show state changes. */
4066 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4068 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4070 /* Show PollInterval */
4072 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4074 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4076 /* Show poll-interval timer. */
4080 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
) / 1000LL;
4081 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4084 vty_out (vty
, " Poll timer due in %s%s",
4085 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4088 /* Show poll-interval timer thread. */
4091 if (nbr_nbma
->t_poll
!= NULL
)
4092 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4095 vty_out (vty
, " Thread Poll Timer %s%s",
4096 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4099 json_object_object_add(json
, "noNbrId", json_sub
);
4103 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4104 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4106 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4107 json_object
*json_sub
= NULL
;
4110 json_sub
= json_object_new_object();
4113 /* Show neighbor ID. */
4114 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4115 vty_out (vty
, " Neighbor %s,", "-");
4117 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4120 /* Show interface address. */
4122 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4124 vty_out (vty
, " interface address %s%s",
4125 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4130 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4131 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4134 vty_out (vty
, " In the area %s via interface %s%s",
4135 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4137 /* Show neighbor priority and state. */
4140 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4141 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4144 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4145 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4147 /* Show state changes. */
4149 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4151 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4153 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4158 time_store
= monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4161 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4165 vty_out (vty
, " Most recent state change statistics:%s",
4167 vty_out (vty
, " Progressive change %s ago%s",
4168 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4173 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4178 time_store
= monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4181 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4182 if (nbr
->last_regress_str
)
4183 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4187 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4188 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4189 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4194 /* Show Designated Rotuer ID. */
4196 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4198 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4200 /* Show Backup Designated Rotuer ID. */
4202 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4204 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4209 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4210 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4213 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4214 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4216 /* Show Router Dead interval timer. */
4219 if (nbr
->t_inactivity
)
4222 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
4223 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4226 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4229 vty_out (vty
, " Dead timer due in %s%s",
4230 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4233 /* Show Database Summary list. */
4235 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4237 vty_out (vty
, " Database Summary List %d%s",
4238 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4240 /* Show Link State Request list. */
4242 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4244 vty_out (vty
, " Link State Request List %ld%s",
4245 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4247 /* Show Link State Retransmission list. */
4249 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4251 vty_out (vty
, " Link State Retransmission List %ld%s",
4252 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4254 /* Show inactivity timer thread. */
4257 if (nbr
->t_inactivity
!= NULL
)
4258 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4261 vty_out (vty
, " Thread Inactivity Timer %s%s",
4262 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4264 /* Show Database Description retransmission thread. */
4267 if (nbr
->t_db_desc
!= NULL
)
4268 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4271 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4272 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4274 /* Show Link State Request Retransmission thread. */
4277 if (nbr
->t_ls_req
!= NULL
)
4278 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4281 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4282 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4284 /* Show Link State Update Retransmission thread. */
4287 if (nbr
->t_ls_upd
!= NULL
)
4288 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4291 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4292 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4296 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4297 json_object_object_add(json
, "noNbrId", json_sub
);
4299 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4302 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4306 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4307 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4309 struct listnode
*node
;
4310 struct ospf_neighbor
*nbr
;
4311 struct ospf_interface
*oi
;
4312 struct in_addr router_id
;
4314 json_object
*json
= NULL
;
4317 json
= json_object_new_object();
4322 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4324 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4325 VTY_NEWLINE
, VTY_NEWLINE
);
4328 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4332 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4336 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4338 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4340 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4346 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4347 json_object_free(json
);
4350 vty_out (vty
, "%s", VTY_NEWLINE
);
4355 DEFUN (show_ip_ospf_neighbor_id
,
4356 show_ip_ospf_neighbor_id_cmd
,
4357 "show ip ospf neighbor A.B.C.D [json]",
4360 "OSPF information\n"
4366 u_char uj
= use_json(argc
, argv
);
4368 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4371 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4374 DEFUN (show_ip_ospf_instance_neighbor_id
,
4375 show_ip_ospf_instance_neighbor_id_cmd
,
4376 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4379 "OSPF information\n"
4387 u_short instance
= 0;
4388 u_char uj
= use_json(argc
, argv
);
4390 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4391 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4394 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4398 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4400 struct ospf_interface
*oi
;
4401 struct listnode
*node
;
4402 json_object
*json
= NULL
;
4405 json
= json_object_new_object();
4410 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4412 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4413 VTY_NEWLINE
, VTY_NEWLINE
);
4416 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4418 struct route_node
*rn
;
4419 struct ospf_neighbor
*nbr
;
4421 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4423 if ((nbr
= rn
->info
))
4425 if (nbr
!= oi
->nbr_self
)
4427 if (nbr
->state
!= NSM_Down
)
4429 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4438 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4439 json_object_free(json
);
4442 vty_out (vty
, "%s", VTY_NEWLINE
);
4447 DEFUN (show_ip_ospf_neighbor_detail
,
4448 show_ip_ospf_neighbor_detail_cmd
,
4449 "show ip ospf neighbor detail [json]",
4452 "OSPF information\n"
4454 "detail of all neighbors\n"
4458 u_char uj
= use_json(argc
, argv
);
4460 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4463 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4466 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4467 show_ip_ospf_instance_neighbor_detail_cmd
,
4468 "show ip ospf (1-65535) neighbor detail [json]",
4471 "OSPF information\n"
4474 "detail of all neighbors\n"
4479 u_short instance
= 0;
4480 u_char uj
= use_json(argc
, argv
);
4482 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4483 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4486 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4490 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4492 struct listnode
*node
;
4493 struct ospf_interface
*oi
;
4494 json_object
*json
= NULL
;
4497 json
= json_object_new_object();
4502 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4504 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4505 VTY_NEWLINE
, VTY_NEWLINE
);
4508 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4510 struct route_node
*rn
;
4511 struct ospf_neighbor
*nbr
;
4512 struct ospf_nbr_nbma
*nbr_nbma
;
4514 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4515 if ((nbr
= rn
->info
))
4516 if (nbr
!= oi
->nbr_self
)
4517 if (nbr
->state
!= NSM_Down
)
4518 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4520 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4522 struct listnode
*nd
;
4524 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4526 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4527 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4534 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4535 json_object_free(json
);
4539 vty_out (vty
, "%s", VTY_NEWLINE
);
4545 DEFUN (show_ip_ospf_neighbor_detail_all
,
4546 show_ip_ospf_neighbor_detail_all_cmd
,
4547 "show ip ospf neighbor detail all [json]",
4550 "OSPF information\n"
4552 "detail of all neighbors\n"
4553 "include down status neighbor\n"
4557 u_char uj
= use_json(argc
, argv
);
4559 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4562 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4565 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4566 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4567 "show ip ospf (1-65535) neighbor detail all [json]",
4570 "OSPF information\n"
4573 "detail of all neighbors\n"
4574 "include down status neighbor\n"
4579 u_short instance
= 0;
4580 u_char uj
= use_json(argc
, argv
);
4582 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4583 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4586 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4590 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4591 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4593 struct ospf_interface
*oi
;
4594 struct interface
*ifp
;
4595 struct route_node
*rn
, *nrn
;
4596 struct ospf_neighbor
*nbr
;
4597 json_object
*json
= NULL
;
4600 json
= json_object_new_object();
4605 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4607 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4608 VTY_NEWLINE
, VTY_NEWLINE
);
4611 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
4615 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4619 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4621 if ((oi
= rn
->info
))
4623 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4625 if ((nbr
= nrn
->info
))
4627 if (nbr
!= oi
->nbr_self
)
4629 if (nbr
->state
!= NSM_Down
)
4630 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4639 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4640 json_object_free(json
);
4643 vty_out (vty
, "%s", VTY_NEWLINE
);
4648 DEFUN (show_ip_ospf_neighbor_int_detail
,
4649 show_ip_ospf_neighbor_int_detail_cmd
,
4650 "show ip ospf neighbor IFNAME detail [json]",
4653 "OSPF information\n"
4656 "detail of all neighbors\n"
4660 u_char uj
= use_json(argc
, argv
);
4662 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4665 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4668 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4669 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4670 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4673 "OSPF information\n"
4677 "detail of all neighbors\n"
4682 u_short instance
= 0;
4683 u_char uj
= use_json(argc
, argv
);
4685 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4686 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4689 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4692 /* Show functions */
4694 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4696 struct router_lsa
*rl
;
4697 struct summary_lsa
*sl
;
4698 struct as_external_lsa
*asel
;
4699 struct prefix_ipv4 p
;
4702 /* If self option is set, check LSA self flag. */
4703 if (self
== 0 || IS_LSA_SELF (lsa
))
4705 /* LSA common part show. */
4706 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4707 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4708 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4709 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4710 /* LSA specific part show. */
4711 switch (lsa
->data
->type
)
4713 case OSPF_ROUTER_LSA
:
4714 rl
= (struct router_lsa
*) lsa
->data
;
4715 vty_out (vty
, " %-d", ntohs (rl
->links
));
4717 case OSPF_SUMMARY_LSA
:
4718 sl
= (struct summary_lsa
*) lsa
->data
;
4721 p
.prefix
= sl
->header
.id
;
4722 p
.prefixlen
= ip_masklen (sl
->mask
);
4723 apply_mask_ipv4 (&p
);
4725 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4727 case OSPF_AS_EXTERNAL_LSA
:
4728 case OSPF_AS_NSSA_LSA
:
4729 asel
= (struct as_external_lsa
*) lsa
->data
;
4732 p
.prefix
= asel
->header
.id
;
4733 p
.prefixlen
= ip_masklen (asel
->mask
);
4734 apply_mask_ipv4 (&p
);
4736 vty_out (vty
, " %s %s/%d [0x%lx]",
4737 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4738 inet_ntoa (p
.prefix
), p
.prefixlen
,
4739 (u_long
)ntohl (asel
->e
[0].route_tag
));
4741 case OSPF_NETWORK_LSA
:
4742 case OSPF_ASBR_SUMMARY_LSA
:
4743 case OSPF_OPAQUE_LINK_LSA
:
4744 case OSPF_OPAQUE_AREA_LSA
:
4745 case OSPF_OPAQUE_AS_LSA
:
4749 vty_out (vty
, VTY_NEWLINE
);
4755 static const char *show_database_desc
[] =
4758 "Router Link States",
4760 "Summary Link States",
4761 "ASBR-Summary Link States",
4762 "AS External Link States",
4763 "Group Membership LSA",
4764 "NSSA-external Link States",
4766 "Link-Local Opaque-LSA",
4767 "Area-Local Opaque-LSA",
4768 "AS-external Opaque-LSA",
4771 static const char *show_database_header
[] =
4774 "Link ID ADV Router Age Seq# CkSum Link count",
4775 "Link ID ADV Router Age Seq# CkSum",
4776 "Link ID ADV Router Age Seq# CkSum Route",
4777 "Link ID ADV Router Age Seq# CkSum",
4778 "Link ID ADV Router Age Seq# CkSum Route",
4779 " --- header for Group Member ----",
4780 "Link ID ADV Router Age Seq# CkSum Route",
4782 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4783 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4784 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4788 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4790 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4792 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4793 vty_out (vty
, " Options: 0x%-2x : %s%s",
4795 ospf_options_dump(lsa
->data
->options
),
4797 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4799 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4802 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4804 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4807 vty_out (vty
, " :%s%s%s%s",
4808 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4809 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4810 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4811 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4813 vty_out (vty
, "%s", VTY_NEWLINE
);
4815 vty_out (vty
, " LS Type: %s%s",
4816 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4817 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4818 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4819 vty_out (vty
, " Advertising Router: %s%s",
4820 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4821 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4823 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4825 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4828 const char *link_type_desc
[] =
4831 "another Router (point-to-point)",
4832 "a Transit Network",
4837 const char *link_id_desc
[] =
4840 "Neighboring Router ID",
4841 "Designated Router address",
4843 "Neighboring Router ID",
4846 const char *link_data_desc
[] =
4849 "Router Interface address",
4850 "Router Interface address",
4852 "Router Interface address",
4855 /* Show router-LSA each Link information. */
4857 show_ip_ospf_database_router_links (struct vty
*vty
,
4858 struct router_lsa
*rl
)
4863 len
= ntohs (rl
->header
.length
) - 4;
4864 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4866 type
= rl
->link
[i
].type
;
4868 vty_out (vty
, " Link connected to: %s%s",
4869 link_type_desc
[type
], VTY_NEWLINE
);
4870 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4871 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4872 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4873 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4874 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4875 vty_out (vty
, " TOS 0 Metric: %d%s",
4876 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4877 vty_out (vty
, "%s", VTY_NEWLINE
);
4881 /* Show router-LSA detail information. */
4883 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4887 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4889 show_ip_ospf_database_header (vty
, lsa
);
4891 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4892 VTY_NEWLINE
, VTY_NEWLINE
);
4894 show_ip_ospf_database_router_links (vty
, rl
);
4895 vty_out (vty
, "%s", VTY_NEWLINE
);
4901 /* Show network-LSA detail information. */
4903 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4909 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4911 show_ip_ospf_database_header (vty
, lsa
);
4913 vty_out (vty
, " Network Mask: /%d%s",
4914 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4916 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4918 for (i
= 0; length
> 0; i
++, length
-= 4)
4919 vty_out (vty
, " Attached Router: %s%s",
4920 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4922 vty_out (vty
, "%s", VTY_NEWLINE
);
4928 /* Show summary-LSA detail information. */
4930 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4934 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4936 show_ip_ospf_database_header (vty
, lsa
);
4938 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4940 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4942 vty_out (vty
, "%s", VTY_NEWLINE
);
4948 /* Show summary-ASBR-LSA detail information. */
4950 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4954 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4956 show_ip_ospf_database_header (vty
, lsa
);
4958 vty_out (vty
, " Network Mask: /%d%s",
4959 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4960 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4962 vty_out (vty
, "%s", VTY_NEWLINE
);
4968 /* Show AS-external-LSA detail information. */
4970 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4974 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4976 show_ip_ospf_database_header (vty
, lsa
);
4978 vty_out (vty
, " Network Mask: /%d%s",
4979 ip_masklen (al
->mask
), VTY_NEWLINE
);
4980 vty_out (vty
, " Metric Type: %s%s",
4981 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4982 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4983 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4984 vty_out (vty
, " Metric: %d%s",
4985 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4986 vty_out (vty
, " Forward Address: %s%s",
4987 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4989 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4990 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
4997 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
4999 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5001 /* show_ip_ospf_database_header (vty, lsa); */
5003 zlog_debug( " Network Mask: /%d%s",
5004 ip_masklen (al
->mask
), "\n");
5005 zlog_debug( " Metric Type: %s%s",
5006 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5007 "2 (Larger than any link state path)" : "1", "\n");
5008 zlog_debug( " TOS: 0%s", "\n");
5009 zlog_debug( " Metric: %d%s",
5010 GET_METRIC (al
->e
[0].metric
), "\n");
5011 zlog_debug( " Forward Address: %s%s",
5012 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5014 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5015 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5020 /* Show AS-NSSA-LSA detail information. */
5022 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5026 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5028 show_ip_ospf_database_header (vty
, lsa
);
5030 vty_out (vty
, " Network Mask: /%d%s",
5031 ip_masklen (al
->mask
), VTY_NEWLINE
);
5032 vty_out (vty
, " Metric Type: %s%s",
5033 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5034 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5035 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5036 vty_out (vty
, " Metric: %d%s",
5037 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5038 vty_out (vty
, " NSSA: Forward Address: %s%s",
5039 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5041 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5042 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5049 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5055 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5059 show_ip_ospf_database_header (vty
, lsa
);
5060 show_opaque_info_detail (vty
, lsa
);
5062 vty_out (vty
, "%s", VTY_NEWLINE
);
5067 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5070 show_router_lsa_detail
,
5071 show_network_lsa_detail
,
5072 show_summary_lsa_detail
,
5073 show_summary_asbr_lsa_detail
,
5074 show_as_external_lsa_detail
,
5076 show_as_nssa_lsa_detail
, /* almost same as external */
5078 show_opaque_lsa_detail
,
5079 show_opaque_lsa_detail
,
5080 show_opaque_lsa_detail
,
5084 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5085 struct in_addr
*adv_router
)
5087 memset (lp
, 0, sizeof (struct prefix_ls
));
5091 else if (adv_router
== NULL
)
5100 lp
->adv_router
= *adv_router
;
5105 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5106 struct in_addr
*id
, struct in_addr
*adv_router
)
5108 struct prefix_ls lp
;
5109 struct route_node
*rn
, *start
;
5110 struct ospf_lsa
*lsa
;
5112 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5113 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5116 route_lock_node (start
);
5117 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5118 if ((lsa
= rn
->info
))
5120 if (show_function
[lsa
->data
->type
] != NULL
)
5121 show_function
[lsa
->data
->type
] (vty
, lsa
);
5123 route_unlock_node (start
);
5127 /* Show detail LSA information
5128 -- if id is NULL then show all LSAs. */
5130 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5131 struct in_addr
*id
, struct in_addr
*adv_router
)
5133 struct listnode
*node
;
5134 struct ospf_area
*area
;
5138 case OSPF_AS_EXTERNAL_LSA
:
5139 case OSPF_OPAQUE_AS_LSA
:
5140 vty_out (vty
, " %s %s%s",
5141 show_database_desc
[type
],
5142 VTY_NEWLINE
, VTY_NEWLINE
);
5143 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5146 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5148 vty_out (vty
, "%s %s (Area %s)%s%s",
5149 VTY_NEWLINE
, show_database_desc
[type
],
5150 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5151 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5158 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5159 struct in_addr
*adv_router
)
5161 struct route_node
*rn
;
5162 struct ospf_lsa
*lsa
;
5164 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5165 if ((lsa
= rn
->info
))
5166 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5168 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5170 if (show_function
[lsa
->data
->type
] != NULL
)
5171 show_function
[lsa
->data
->type
] (vty
, lsa
);
5175 /* Show detail LSA information. */
5177 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5178 struct in_addr
*adv_router
)
5180 struct listnode
*node
;
5181 struct ospf_area
*area
;
5185 case OSPF_AS_EXTERNAL_LSA
:
5186 case OSPF_OPAQUE_AS_LSA
:
5187 vty_out (vty
, " %s %s%s",
5188 show_database_desc
[type
],
5189 VTY_NEWLINE
, VTY_NEWLINE
);
5190 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5194 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5196 vty_out (vty
, "%s %s (Area %s)%s%s",
5197 VTY_NEWLINE
, show_database_desc
[type
],
5198 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5199 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5207 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5209 struct ospf_lsa
*lsa
;
5210 struct route_node
*rn
;
5211 struct ospf_area
*area
;
5212 struct listnode
*node
;
5215 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5217 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5221 case OSPF_AS_EXTERNAL_LSA
:
5222 case OSPF_OPAQUE_AS_LSA
:
5227 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5228 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5230 vty_out (vty
, " %s (Area %s)%s%s",
5231 show_database_desc
[type
],
5232 ospf_area_desc_string (area
),
5233 VTY_NEWLINE
, VTY_NEWLINE
);
5234 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5236 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5237 show_lsa_summary (vty
, lsa
, self
);
5239 vty_out (vty
, "%s", VTY_NEWLINE
);
5244 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5248 case OSPF_AS_EXTERNAL_LSA
:
5249 case OSPF_OPAQUE_AS_LSA
:
5254 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5255 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5257 vty_out (vty
, " %s%s%s",
5258 show_database_desc
[type
],
5259 VTY_NEWLINE
, VTY_NEWLINE
);
5260 vty_out (vty
, "%s%s", show_database_header
[type
],
5263 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5264 show_lsa_summary (vty
, lsa
, self
);
5266 vty_out (vty
, "%s", VTY_NEWLINE
);
5270 vty_out (vty
, "%s", VTY_NEWLINE
);
5274 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5276 struct route_node
*rn
;
5278 vty_out (vty
, "%s MaxAge Link States:%s%s",
5279 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5281 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5283 struct ospf_lsa
*lsa
;
5285 if ((lsa
= rn
->info
) != NULL
)
5287 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5288 vty_out (vty
, "Link State ID: %s%s",
5289 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5290 vty_out (vty
, "Advertising Router: %s%s",
5291 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5292 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5293 vty_out (vty
, "%s", VTY_NEWLINE
);
5298 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5299 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5301 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5302 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5303 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5304 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5306 #define OSPF_LSA_TYPES_DESC \
5307 "ASBR summary link states\n" \
5308 "External link states\n" \
5309 "Network link states\n" \
5310 "Router link states\n" \
5311 "Network summary link states\n" \
5312 OSPF_LSA_TYPE_NSSA_DESC \
5313 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5314 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5315 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5318 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5319 int arg_base
, int argc
, struct cmd_token
**argv
)
5323 struct in_addr id
, adv_router
;
5326 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5329 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5330 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5333 if (argc
== arg_base
+ 4)
5335 show_ip_ospf_database_summary (vty
, ospf
, 0);
5339 /* Set database type to show. */
5340 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5341 type
= OSPF_ROUTER_LSA
;
5342 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5343 type
= OSPF_NETWORK_LSA
;
5344 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5345 type
= OSPF_AS_NSSA_LSA
;
5346 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5347 type
= OSPF_SUMMARY_LSA
;
5348 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5349 type
= OSPF_ASBR_SUMMARY_LSA
;
5350 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5351 type
= OSPF_AS_EXTERNAL_LSA
;
5352 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5354 show_ip_ospf_database_summary (vty
, ospf
, 1);
5357 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5359 show_ip_ospf_database_maxage (vty
, ospf
);
5362 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5363 type
= OSPF_OPAQUE_LINK_LSA
;
5364 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5365 type
= OSPF_OPAQUE_AREA_LSA
;
5366 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5367 type
= OSPF_OPAQUE_AS_LSA
;
5371 /* `show ip ospf database LSA'. */
5372 if (argc
== arg_base
+ 5)
5373 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5374 else if (argc
>= arg_base
+ 6)
5376 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5380 /* `show ip ospf database LSA ID'. */
5381 if (argc
== arg_base
+ 6)
5382 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5383 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5384 else if (argc
== arg_base
+ 7)
5386 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5387 adv_router
= ospf
->router_id
;
5390 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5394 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5401 DEFUN (show_ip_ospf_database_max
,
5402 show_ip_ospf_database_max_cmd
,
5403 "show ip ospf database <max-age|self-originate>",
5406 "OSPF information\n"
5407 "Database summary\n"
5408 "LSAs in MaxAge list\n"
5409 "Self-originated link states\n")
5413 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5416 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5419 DEFUN (show_ip_ospf_instance_database
,
5420 show_ip_ospf_instance_database_cmd
,
5421 "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>]]]",
5424 "OSPF information\n"
5426 "Database summary\n"
5428 "Link State ID (as an IP address)\n"
5429 "Self-originated link states\n"
5430 "Advertising Router link states\n"
5431 "Advertising Router (as an IP address)\n")
5434 u_short instance
= 0;
5437 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5439 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5440 ospf
= ospf_lookup_instance (instance
);
5443 ospf
= ospf_lookup();
5446 if (!ospf
|| !ospf
->oi_running
)
5449 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5452 DEFUN (show_ip_ospf_instance_database_max
,
5453 show_ip_ospf_instance_database_max_cmd
,
5454 "show ip ospf (1-65535) database <max-age|self-originate>",
5457 "OSPF information\n"
5459 "Database summary\n"
5460 "LSAs in MaxAge list\n"
5461 "Self-originated link states\n")
5465 u_short instance
= 0;
5467 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5469 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5472 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5477 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5478 int arg_base
, int argc
, struct cmd_token
**argv
)
5482 struct in_addr adv_router
;
5485 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5488 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5489 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5491 if (argc
!= arg_base
+ 7)
5494 /* Set database type to show. */
5495 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5496 type
= OSPF_ROUTER_LSA
;
5497 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5498 type
= OSPF_NETWORK_LSA
;
5499 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5500 type
= OSPF_AS_NSSA_LSA
;
5501 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5502 type
= OSPF_SUMMARY_LSA
;
5503 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5504 type
= OSPF_ASBR_SUMMARY_LSA
;
5505 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5506 type
= OSPF_AS_EXTERNAL_LSA
;
5507 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5508 type
= OSPF_OPAQUE_LINK_LSA
;
5509 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5510 type
= OSPF_OPAQUE_AREA_LSA
;
5511 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5512 type
= OSPF_OPAQUE_AS_LSA
;
5516 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5517 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5518 adv_router
= ospf
->router_id
;
5521 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5526 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5531 DEFUN (show_ip_ospf_database_type_adv_router
,
5532 show_ip_ospf_database_type_adv_router_cmd
,
5533 "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>",
5536 "OSPF information\n"
5537 "Database summary\n"
5539 "Advertising Router link states\n"
5540 "Advertising Router (as an IP address)\n"
5541 "Self-originated link states\n")
5545 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5548 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5551 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5552 show_ip_ospf_instance_database_type_adv_router_cmd
,
5553 "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>",
5556 "OSPF information\n"
5558 "Database summary\n"
5560 "Advertising Router link states\n"
5561 "Advertising Router (as an IP address)\n"
5562 "Self-originated link states\n")
5566 u_short instance
= 0;
5568 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5570 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5573 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5576 DEFUN (ip_ospf_authentication_args
,
5577 ip_ospf_authentication_args_addr_cmd
,
5578 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5580 "OSPF interface commands\n"
5581 "Enable authentication on this interface\n"
5582 "Use null authentication\n"
5583 "Use message-digest authentication\n"
5584 "Address of interface\n")
5586 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5587 int idx_encryption
= 3;
5589 struct in_addr addr
;
5591 struct ospf_if_params
*params
;
5593 params
= IF_DEF_PARAMS (ifp
);
5597 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5600 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5605 params
= ospf_get_if_params (ifp
, addr
);
5606 ospf_if_update_params (ifp
, addr
);
5609 /* Handle null authentication */
5610 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5612 SET_IF_PARAM (params
, auth_type
);
5613 params
->auth_type
= OSPF_AUTH_NULL
;
5617 /* Handle message-digest authentication */
5618 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5620 SET_IF_PARAM (params
, auth_type
);
5621 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5625 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5629 DEFUN (ip_ospf_authentication
,
5630 ip_ospf_authentication_addr_cmd
,
5631 "ip ospf authentication [A.B.C.D]",
5633 "OSPF interface commands\n"
5634 "Enable authentication on this interface\n"
5635 "Address of interface")
5637 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5639 struct in_addr addr
;
5641 struct ospf_if_params
*params
;
5643 params
= IF_DEF_PARAMS (ifp
);
5647 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5650 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5655 params
= ospf_get_if_params (ifp
, addr
);
5656 ospf_if_update_params (ifp
, addr
);
5659 SET_IF_PARAM (params
, auth_type
);
5660 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5665 DEFUN (no_ip_ospf_authentication_args
,
5666 no_ip_ospf_authentication_args_addr_cmd
,
5667 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5670 "OSPF interface commands\n"
5671 "Enable authentication on this interface\n"
5672 "Use null authentication\n"
5673 "Use message-digest authentication\n"
5674 "Address of interface")
5676 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5677 int idx_encryption
= 4;
5679 struct in_addr addr
;
5681 struct ospf_if_params
*params
;
5682 struct route_node
*rn
;
5685 params
= IF_DEF_PARAMS (ifp
);
5689 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5692 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5697 params
= ospf_lookup_if_params (ifp
, addr
);
5700 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5703 params
->auth_type
= OSPF_AUTH_NOTSET
;
5704 UNSET_IF_PARAM (params
, auth_type
);
5705 if (params
!= IF_DEF_PARAMS (ifp
))
5707 ospf_free_if_params (ifp
, addr
);
5708 ospf_if_update_params (ifp
, addr
);
5713 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5715 auth_type
= OSPF_AUTH_NULL
;
5717 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5719 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5723 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5727 * Here we have a case where the user has entered
5728 * 'no ip ospf authentication (null | message_digest )'
5729 * we need to find if we have any ip addresses underneath it that
5730 * correspond to the associated type.
5732 if (params
->auth_type
== auth_type
)
5734 params
->auth_type
= OSPF_AUTH_NOTSET
;
5735 UNSET_IF_PARAM (params
, auth_type
);
5738 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5740 if ((params
= rn
->info
))
5742 if (params
->auth_type
== auth_type
)
5744 params
->auth_type
= OSPF_AUTH_NOTSET
;
5745 UNSET_IF_PARAM (params
, auth_type
);
5746 if (params
!= IF_DEF_PARAMS (ifp
))
5748 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5749 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5759 DEFUN (no_ip_ospf_authentication
,
5760 no_ip_ospf_authentication_addr_cmd
,
5761 "no ip ospf authentication [A.B.C.D]",
5764 "OSPF interface commands\n"
5765 "Enable authentication on this interface\n"
5766 "Address of interface")
5768 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5770 struct in_addr addr
;
5772 struct ospf_if_params
*params
;
5773 struct route_node
*rn
;
5775 params
= IF_DEF_PARAMS (ifp
);
5779 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5782 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5787 params
= ospf_lookup_if_params (ifp
, addr
);
5790 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5794 params
->auth_type
= OSPF_AUTH_NOTSET
;
5795 UNSET_IF_PARAM (params
, auth_type
);
5796 if (params
!= IF_DEF_PARAMS (ifp
))
5798 ospf_free_if_params (ifp
, addr
);
5799 ospf_if_update_params (ifp
, addr
);
5805 * When a user enters 'no ip ospf authentication'
5806 * We should remove all authentication types from
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
);
5817 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5819 if ((params
= rn
->info
))
5822 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5823 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5824 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5826 params
->auth_type
= OSPF_AUTH_NOTSET
;
5827 UNSET_IF_PARAM (params
, auth_type
);
5828 if (params
!= IF_DEF_PARAMS (ifp
))
5830 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5831 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5842 DEFUN (ip_ospf_authentication_key
,
5843 ip_ospf_authentication_key_addr_cmd
,
5844 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5846 "OSPF interface commands\n"
5847 "Authentication password (key)\n"
5848 "The OSPF password (key)\n"
5849 "Address of interface")
5851 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5853 struct in_addr addr
;
5854 struct ospf_if_params
*params
;
5856 params
= IF_DEF_PARAMS (ifp
);
5858 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5860 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5862 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5867 params
= ospf_get_if_params (ifp
, addr
);
5868 ospf_if_update_params (ifp
, addr
);
5871 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5872 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5873 SET_IF_PARAM (params
, auth_simple
);
5878 DEFUN_HIDDEN (ospf_authentication_key
,
5879 ospf_authentication_key_cmd
,
5880 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5881 "OSPF interface commands\n"
5882 "Authentication password (key)\n"
5883 "The OSPF password (key)\n"
5884 "Address of interface\n")
5886 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5889 DEFUN (no_ip_ospf_authentication_key
,
5890 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5891 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5894 "OSPF interface commands\n"
5895 "Authentication password (key)\n"
5896 "The OSPF password (key)")
5898 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5900 struct in_addr addr
;
5901 struct ospf_if_params
*params
;
5902 params
= IF_DEF_PARAMS (ifp
);
5904 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5906 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5908 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5913 params
= ospf_lookup_if_params (ifp
, addr
);
5918 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5919 UNSET_IF_PARAM (params
, auth_simple
);
5921 if (params
!= IF_DEF_PARAMS (ifp
))
5923 ospf_free_if_params (ifp
, addr
);
5924 ospf_if_update_params (ifp
, addr
);
5930 DEFUN_HIDDEN (no_ospf_authentication_key
,
5931 no_ospf_authentication_key_authkey_addr_cmd
,
5932 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5934 "OSPF interface commands\n"
5935 "Authentication password (key)\n"
5936 "The OSPF password (key)")
5938 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5941 DEFUN (ip_ospf_message_digest_key
,
5942 ip_ospf_message_digest_key_cmd
,
5943 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5945 "OSPF interface commands\n"
5946 "Message digest authentication password (key)\n"
5948 "Use MD5 algorithm\n"
5949 "The OSPF password (key)\n"
5950 "Address of interface\n")
5952 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5953 struct crypt_key
*ck
;
5955 struct in_addr addr
;
5956 struct ospf_if_params
*params
;
5958 params
= IF_DEF_PARAMS (ifp
);
5961 argv_find (argv
, argc
, "(1-255)", &idx
);
5962 char *keyid
= argv
[idx
]->arg
;
5963 argv_find (argv
, argc
, "KEY", &idx
);
5964 char *cryptkey
= argv
[idx
]->arg
;
5966 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5968 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5970 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5975 params
= ospf_get_if_params (ifp
, addr
);
5976 ospf_if_update_params (ifp
, addr
);
5979 key_id
= strtol (keyid
, NULL
, 10);
5980 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5982 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5986 ck
= ospf_crypt_key_new ();
5987 ck
->key_id
= (u_char
) key_id
;
5988 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5989 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5991 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5992 SET_IF_PARAM (params
, auth_crypt
);
5997 DEFUN_HIDDEN (ospf_message_digest_key
,
5998 ospf_message_digest_key_cmd
,
5999 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6000 "OSPF interface commands\n"
6001 "Message digest authentication password (key)\n"
6003 "Use MD5 algorithm\n"
6004 "The OSPF password (key)\n"
6005 "Address of interface\n")
6007 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6010 DEFUN (no_ip_ospf_message_digest_key
,
6011 no_ip_ospf_message_digest_key_cmd
,
6012 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6015 "OSPF interface commands\n"
6016 "Message digest authentication password (key)\n"
6018 "Use MD5 algorithm\n"
6019 "The OSPF password (key)\n"
6020 "Address of interface\n")
6022 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6024 struct crypt_key
*ck
;
6026 struct in_addr addr
;
6027 struct ospf_if_params
*params
;
6028 params
= IF_DEF_PARAMS (ifp
);
6030 argv_find (argv
, argc
, "(1-255)", &idx
);
6031 char *keyid
= argv
[idx
]->arg
;
6033 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6035 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6037 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6042 params
= ospf_lookup_if_params (ifp
, addr
);
6047 key_id
= strtol (keyid
, NULL
, 10);
6048 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6051 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6055 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6057 if (params
!= IF_DEF_PARAMS (ifp
))
6059 ospf_free_if_params (ifp
, addr
);
6060 ospf_if_update_params (ifp
, addr
);
6066 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6067 no_ospf_message_digest_key_cmd
,
6068 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6070 "OSPF interface commands\n"
6071 "Message digest authentication password (key)\n"
6073 "Address of interface")
6075 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6078 DEFUN (ip_ospf_cost
,
6080 "ip ospf cost (1-65535) [A.B.C.D]",
6082 "OSPF interface commands\n"
6085 "Address of interface\n")
6087 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6090 struct in_addr addr
;
6091 struct ospf_if_params
*params
;
6092 params
= IF_DEF_PARAMS (ifp
);
6095 char *coststr
= NULL
, *ifaddr
= NULL
;
6096 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6097 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6099 cost
= strtol (coststr
, NULL
, 10);
6103 if(!inet_aton(ifaddr
, &addr
))
6105 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6110 params
= ospf_get_if_params (ifp
, addr
);
6111 ospf_if_update_params (ifp
, addr
);
6114 SET_IF_PARAM (params
, output_cost_cmd
);
6115 params
->output_cost_cmd
= cost
;
6117 ospf_if_recalculate_output_cost (ifp
);
6122 DEFUN_HIDDEN (ospf_cost
,
6124 "ospf cost (1-65535) [A.B.C.D]",
6125 "OSPF interface commands\n"
6128 "Address of interface\n")
6130 return ip_ospf_cost (self
, vty
, argc
, argv
);
6133 DEFUN (no_ip_ospf_cost
,
6134 no_ip_ospf_cost_cmd
,
6135 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6137 "OSPF interface commands\n"
6139 "Address of interface")
6141 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6143 struct in_addr addr
;
6144 struct ospf_if_params
*params
;
6146 params
= IF_DEF_PARAMS (ifp
);
6149 char *ifaddr
= NULL
;
6150 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6152 /* According to the semantics we are mimicking "no ip ospf cost N" is
6153 * always treated as "no ip ospf cost" regardless of the actual value
6154 * of N already configured for the interface. Thus ignore cost. */
6158 if (!inet_aton(ifaddr
, &addr
))
6160 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6165 params
= ospf_lookup_if_params (ifp
, addr
);
6170 UNSET_IF_PARAM (params
, output_cost_cmd
);
6172 if (params
!= IF_DEF_PARAMS (ifp
))
6174 ospf_free_if_params (ifp
, addr
);
6175 ospf_if_update_params (ifp
, addr
);
6178 ospf_if_recalculate_output_cost (ifp
);
6183 DEFUN_HIDDEN (no_ospf_cost
,
6185 "no ospf cost [(1-65535)] [A.B.C.D]",
6187 "OSPF interface commands\n"
6190 "Address of interface\n")
6192 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6196 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6198 struct route_node
*rn
;
6199 struct ospf_neighbor
*nbr
;
6201 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6202 if ((nbr
= rn
->info
))
6204 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6205 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6206 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6207 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6212 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6213 const char *nbr_str
,
6214 const char *fast_hello_str
)
6216 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6219 struct in_addr addr
;
6221 struct ospf_if_params
*params
;
6222 struct ospf_interface
*oi
;
6223 struct route_node
*rn
;
6225 params
= IF_DEF_PARAMS (ifp
);
6229 ret
= inet_aton(nbr_str
, &addr
);
6232 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6237 params
= ospf_get_if_params (ifp
, addr
);
6238 ospf_if_update_params (ifp
, addr
);
6243 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6246 /* reset fast_hello too, just to be sure */
6247 UNSET_IF_PARAM (params
, fast_hello
);
6248 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6250 else if (fast_hello_str
)
6252 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6254 /* 1s dead-interval with sub-second hellos desired */
6255 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6256 SET_IF_PARAM (params
, fast_hello
);
6257 params
->fast_hello
= hellomult
;
6261 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6266 SET_IF_PARAM (params
, v_wait
);
6267 params
->v_wait
= seconds
;
6269 /* Update timer values in neighbor structure. */
6273 if ((ospf
= ospf_lookup()))
6275 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6277 ospf_nbr_timer_update (oi
);
6282 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6283 if ((oi
= rn
->info
))
6284 ospf_nbr_timer_update (oi
);
6290 DEFUN (ip_ospf_dead_interval
,
6291 ip_ospf_dead_interval_cmd
,
6292 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6294 "OSPF interface commands\n"
6295 "Interval time after which a neighbor is declared down\n"
6297 "Address of interface\n")
6300 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6301 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6302 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6306 DEFUN_HIDDEN (ospf_dead_interval
,
6307 ospf_dead_interval_cmd
,
6308 "ospf dead-interval (1-65535) [A.B.C.D]",
6309 "OSPF interface commands\n"
6310 "Interval time after which a neighbor is declared down\n"
6312 "Address of interface\n")
6314 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6317 DEFUN (ip_ospf_dead_interval_minimal
,
6318 ip_ospf_dead_interval_minimal_addr_cmd
,
6319 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6321 "OSPF interface commands\n"
6322 "Interval time after which a neighbor is declared down\n"
6323 "Minimal 1s dead-interval with fast sub-second hellos\n"
6324 "Hello multiplier factor\n"
6325 "Number of Hellos to send each second\n"
6326 "Address of interface\n")
6331 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6333 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6336 DEFUN (no_ip_ospf_dead_interval
,
6337 no_ip_ospf_dead_interval_cmd
,
6338 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6341 "OSPF interface commands\n"
6342 "Interval time after which a neighbor is declared down\n"
6344 "Address of interface")
6346 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6347 int idx_ipv4
= argc
- 1;
6348 struct in_addr addr
;
6350 struct ospf_if_params
*params
;
6351 struct ospf_interface
*oi
;
6352 struct route_node
*rn
;
6354 params
= IF_DEF_PARAMS (ifp
);
6356 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6358 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6361 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6366 params
= ospf_lookup_if_params (ifp
, addr
);
6371 UNSET_IF_PARAM (params
, v_wait
);
6372 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6374 UNSET_IF_PARAM (params
, fast_hello
);
6375 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6377 if (params
!= IF_DEF_PARAMS (ifp
))
6379 ospf_free_if_params (ifp
, addr
);
6380 ospf_if_update_params (ifp
, addr
);
6383 /* Update timer values in neighbor structure. */
6388 if ((ospf
= ospf_lookup()))
6390 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6392 ospf_nbr_timer_update (oi
);
6397 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6398 if ((oi
= rn
->info
))
6399 ospf_nbr_timer_update (oi
);
6405 DEFUN_HIDDEN (no_ospf_dead_interval
,
6406 no_ospf_dead_interval_cmd
,
6407 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6409 "OSPF interface commands\n"
6410 "Interval time after which a neighbor is declared down\n"
6412 "Address of interface")
6414 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6417 DEFUN (ip_ospf_hello_interval
,
6418 ip_ospf_hello_interval_cmd
,
6419 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6421 "OSPF interface commands\n"
6422 "Time between HELLO packets\n"
6424 "Address of interface\n")
6426 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6428 struct in_addr addr
;
6429 struct ospf_if_params
*params
;
6430 params
= IF_DEF_PARAMS (ifp
);
6431 u_int32_t seconds
= 0;
6433 argv_find (argv
, argc
, "(1-65535)", &idx
);
6434 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6436 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6438 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6440 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6445 params
= ospf_get_if_params (ifp
, addr
);
6446 ospf_if_update_params (ifp
, addr
);
6449 SET_IF_PARAM (params
, v_hello
);
6450 params
->v_hello
= seconds
;
6455 DEFUN_HIDDEN (ospf_hello_interval
,
6456 ospf_hello_interval_cmd
,
6457 "ospf hello-interval (1-65535) [A.B.C.D]",
6458 "OSPF interface commands\n"
6459 "Time between HELLO packets\n"
6461 "Address of interface\n")
6463 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6466 DEFUN (no_ip_ospf_hello_interval
,
6467 no_ip_ospf_hello_interval_cmd
,
6468 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6471 "OSPF interface commands\n"
6472 "Time between HELLO packets\n" // ignored
6474 "Address of interface\n")
6476 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6478 struct in_addr addr
;
6479 struct ospf_if_params
*params
;
6480 params
= IF_DEF_PARAMS (ifp
);
6482 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6484 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6486 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6491 params
= ospf_lookup_if_params (ifp
, addr
);
6496 UNSET_IF_PARAM (params
, v_hello
);
6497 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6499 if (params
!= IF_DEF_PARAMS (ifp
))
6501 ospf_free_if_params (ifp
, addr
);
6502 ospf_if_update_params (ifp
, addr
);
6508 DEFUN_HIDDEN (no_ospf_hello_interval
,
6509 no_ospf_hello_interval_cmd
,
6510 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6512 "OSPF interface commands\n"
6513 "Time between HELLO packets\n" // ignored
6515 "Address of interface\n")
6517 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6520 DEFUN (ip_ospf_network
,
6521 ip_ospf_network_cmd
,
6522 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6524 "OSPF interface commands\n"
6526 "Specify OSPF broadcast multi-access network\n"
6527 "Specify OSPF NBMA network\n"
6528 "Specify OSPF point-to-multipoint network\n"
6529 "Specify OSPF point-to-point network\n")
6531 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6533 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6534 struct route_node
*rn
;
6536 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6538 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6542 if (argv_find (argv
, argc
, "broadcast", &idx
))
6543 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6544 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6545 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6546 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6547 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6548 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6549 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6551 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6554 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6556 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6558 struct ospf_interface
*oi
= rn
->info
;
6563 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6565 if (oi
->state
> ISM_Down
)
6567 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6568 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6575 DEFUN_HIDDEN (ospf_network
,
6577 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6578 "OSPF interface commands\n"
6580 "Specify OSPF broadcast multi-access network\n"
6581 "Specify OSPF NBMA network\n"
6582 "Specify OSPF point-to-multipoint network\n"
6583 "Specify OSPF point-to-point network\n")
6585 return ip_ospf_network (self
, vty
, argc
, argv
);
6588 DEFUN (no_ip_ospf_network
,
6589 no_ip_ospf_network_cmd
,
6590 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6593 "OSPF interface commands\n"
6595 "Specify OSPF broadcast multi-access network\n"
6596 "Specify OSPF NBMA network\n"
6597 "Specify OSPF point-to-multipoint network\n"
6598 "Specify OSPF point-to-point network\n")
6600 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6601 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6602 struct route_node
*rn
;
6604 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6606 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6609 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6611 struct ospf_interface
*oi
= rn
->info
;
6616 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6618 if (oi
->state
> ISM_Down
)
6620 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6621 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6628 DEFUN_HIDDEN (no_ospf_network
,
6629 no_ospf_network_cmd
,
6630 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6632 "OSPF interface commands\n"
6634 "Specify OSPF broadcast multi-access network\n"
6635 "Specify OSPF NBMA network\n"
6636 "Specify OSPF point-to-multipoint network\n"
6637 "Specify OSPF point-to-point network\n")
6639 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6642 DEFUN (ip_ospf_priority
,
6643 ip_ospf_priority_cmd
,
6644 "ip ospf priority (0-255) [A.B.C.D]",
6646 "OSPF interface commands\n"
6649 "Address of interface")
6651 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6654 struct route_node
*rn
;
6655 struct in_addr addr
;
6656 struct ospf_if_params
*params
;
6657 params
= IF_DEF_PARAMS (ifp
);
6659 argv_find (argv
, argc
, "(0-255)", &idx
);
6660 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6662 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6664 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6666 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6671 params
= ospf_get_if_params (ifp
, addr
);
6672 ospf_if_update_params (ifp
, addr
);
6675 SET_IF_PARAM (params
, priority
);
6676 params
->priority
= priority
;
6678 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6680 struct ospf_interface
*oi
= rn
->info
;
6685 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6687 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6688 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6695 DEFUN_HIDDEN (ospf_priority
,
6697 "ospf priority (0-255) [A.B.C.D]",
6698 "OSPF interface commands\n"
6701 "Address of interface")
6703 return ip_ospf_priority (self
, vty
, argc
, argv
);
6706 DEFUN (no_ip_ospf_priority
,
6707 no_ip_ospf_priority_cmd
,
6708 "no ip ospf priority [(0-255) [A.B.C.D]]",
6711 "OSPF interface commands\n"
6712 "Router priority\n" // ignored
6714 "Address of interface")
6716 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6718 struct route_node
*rn
;
6719 struct in_addr addr
;
6720 struct ospf_if_params
*params
;
6722 params
= IF_DEF_PARAMS (ifp
);
6724 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6726 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6728 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6733 params
= ospf_lookup_if_params (ifp
, addr
);
6738 UNSET_IF_PARAM (params
, priority
);
6739 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6741 if (params
!= IF_DEF_PARAMS (ifp
))
6743 ospf_free_if_params (ifp
, addr
);
6744 ospf_if_update_params (ifp
, addr
);
6747 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6749 struct ospf_interface
*oi
= rn
->info
;
6754 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6756 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6757 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6764 DEFUN_HIDDEN (no_ospf_priority
,
6765 no_ospf_priority_cmd
,
6766 "no ospf priority [(0-255) [A.B.C.D]]",
6768 "OSPF interface commands\n"
6771 "Address of interface")
6773 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6776 DEFUN (ip_ospf_retransmit_interval
,
6777 ip_ospf_retransmit_interval_addr_cmd
,
6778 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6780 "OSPF interface commands\n"
6781 "Time between retransmitting lost link state advertisements\n"
6783 "Address of interface")
6785 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6788 struct in_addr addr
;
6789 struct ospf_if_params
*params
;
6790 params
= IF_DEF_PARAMS (ifp
);
6792 argv_find (argv
, argc
, "(3-65535)", &idx
);
6793 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6795 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6797 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6799 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6804 params
= ospf_get_if_params (ifp
, addr
);
6805 ospf_if_update_params (ifp
, addr
);
6808 SET_IF_PARAM (params
, retransmit_interval
);
6809 params
->retransmit_interval
= seconds
;
6814 DEFUN_HIDDEN (ospf_retransmit_interval
,
6815 ospf_retransmit_interval_cmd
,
6816 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6817 "OSPF interface commands\n"
6818 "Time between retransmitting lost link state advertisements\n"
6820 "Address of interface")
6822 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6825 DEFUN (no_ip_ospf_retransmit_interval
,
6826 no_ip_ospf_retransmit_interval_addr_cmd
,
6827 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6830 "OSPF interface commands\n"
6831 "Time between retransmitting lost link state advertisements\n"
6833 "Address of interface\n")
6835 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6837 struct in_addr addr
;
6838 struct ospf_if_params
*params
;
6840 params
= IF_DEF_PARAMS (ifp
);
6842 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6844 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6846 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6851 params
= ospf_lookup_if_params (ifp
, addr
);
6856 UNSET_IF_PARAM (params
, retransmit_interval
);
6857 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6859 if (params
!= IF_DEF_PARAMS (ifp
))
6861 ospf_free_if_params (ifp
, addr
);
6862 ospf_if_update_params (ifp
, addr
);
6868 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6869 no_ospf_retransmit_interval_cmd
,
6870 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6872 "OSPF interface commands\n"
6873 "Time between retransmitting lost link state advertisements\n"
6875 "Address of interface\n")
6877 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6880 DEFUN (ip_ospf_transmit_delay
,
6881 ip_ospf_transmit_delay_addr_cmd
,
6882 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6884 "OSPF interface commands\n"
6885 "Link state transmit delay\n"
6887 "Address of interface")
6889 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6892 struct in_addr addr
;
6893 struct ospf_if_params
*params
;
6895 params
= IF_DEF_PARAMS (ifp
);
6896 argv_find (argv
, argc
, "(1-65535)", &idx
);
6897 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6899 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6901 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6903 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6908 params
= ospf_get_if_params (ifp
, addr
);
6909 ospf_if_update_params (ifp
, addr
);
6912 SET_IF_PARAM (params
, transmit_delay
);
6913 params
->transmit_delay
= seconds
;
6918 DEFUN_HIDDEN (ospf_transmit_delay
,
6919 ospf_transmit_delay_cmd
,
6920 "ospf transmit-delay (1-65535) [A.B.C.D]",
6921 "OSPF interface commands\n"
6922 "Link state transmit delay\n"
6924 "Address of interface")
6926 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6929 DEFUN (no_ip_ospf_transmit_delay
,
6930 no_ip_ospf_transmit_delay_addr_cmd
,
6931 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6934 "OSPF interface commands\n"
6935 "Link state transmit delay\n"
6936 "Address of interface")
6938 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6940 struct in_addr addr
;
6941 struct ospf_if_params
*params
;
6943 params
= IF_DEF_PARAMS (ifp
);
6945 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6947 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6949 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6954 params
= ospf_lookup_if_params (ifp
, addr
);
6959 UNSET_IF_PARAM (params
, transmit_delay
);
6960 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6962 if (params
!= IF_DEF_PARAMS (ifp
))
6964 ospf_free_if_params (ifp
, addr
);
6965 ospf_if_update_params (ifp
, addr
);
6972 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6973 no_ospf_transmit_delay_cmd
,
6974 "no ospf transmit-delay",
6976 "OSPF interface commands\n"
6977 "Link state transmit delay\n")
6979 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6982 DEFUN (ip_ospf_area
,
6984 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6986 "OSPF interface commands\n"
6988 "Enable OSPF on this interface\n"
6989 "OSPF area ID in IP address format\n"
6990 "OSPF area ID as a decimal value\n")
6992 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6995 struct in_addr area_id
;
6997 struct ospf_if_params
*params
;
6998 struct route_node
*rn
;
6999 u_short instance
= 0;
7001 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7002 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7003 char *areaid
= argv
[argc
- 1]->arg
;
7005 ospf
= ospf_lookup_instance (instance
);
7008 params
= IF_DEF_PARAMS (ifp
);
7009 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7011 ospf_interface_unset (ifp
);
7012 ospf
= ospf_lookup();
7013 ospf
->if_ospf_cli_count
--;
7018 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7021 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7025 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7027 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7031 params
= IF_DEF_PARAMS (ifp
);
7032 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7035 "Must remove previous area config before changing ospf area %s",
7040 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7042 if (rn
->info
!= NULL
)
7044 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7049 /* enable ospf on this interface with area_id */
7050 ospf_interface_set (ifp
, area_id
);
7051 ospf
->if_ospf_cli_count
++;
7056 DEFUN (no_ip_ospf_area
,
7057 no_ip_ospf_area_cmd
,
7058 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7061 "OSPF interface commands\n"
7063 "Disable OSPF on this interface\n"
7064 "OSPF area ID in IP address format\n"
7065 "OSPF area ID as a decimal value\n")
7067 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7070 struct ospf_if_params
*params
;
7071 u_short instance
= 0;
7073 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7074 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7076 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7079 params
= IF_DEF_PARAMS (ifp
);
7080 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7082 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7086 ospf_interface_unset (ifp
);
7087 ospf
->if_ospf_cli_count
--;
7091 DEFUN (ospf_redistribute_source
,
7092 ospf_redistribute_source_cmd
,
7093 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7095 FRR_REDIST_HELP_STR_OSPFD
7096 "Metric for redistributed routes\n"
7097 "OSPF default metric\n"
7098 "OSPF exterior metric type for redistributed routes\n"
7099 "Set OSPF External Type 1 metrics\n"
7100 "Set OSPF External Type 2 metrics\n"
7101 "Route map reference\n"
7102 "Pointer to route-map entries\n")
7104 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7105 int idx_protocol
= 1;
7109 struct ospf_redist
*red
;
7115 /* Get distribute source. */
7116 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7120 red
= ospf_redist_add(ospf
, source
, 0);
7122 /* Get metric value. */
7123 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7124 if (!str2metric (argv
[idx
]->arg
, &metric
))
7127 /* Get metric type. */
7128 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7129 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7133 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7134 ospf_routemap_set (red
, argv
[idx
]->arg
);
7137 ospf_routemap_unset (red
);
7139 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7142 DEFUN (no_ospf_redistribute_source
,
7143 no_ospf_redistribute_source_cmd
,
7144 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7147 FRR_REDIST_HELP_STR_OSPFD
7148 "Metric for redistributed routes\n"
7149 "OSPF default metric\n"
7150 "OSPF exterior metric type for redistributed routes\n"
7151 "Set OSPF External Type 1 metrics\n"
7152 "Set OSPF External Type 2 metrics\n"
7153 "Route map reference\n"
7154 "Pointer to route-map entries\n")
7156 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7157 int idx_protocol
= 2;
7159 struct ospf_redist
*red
;
7161 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7165 red
= ospf_redist_lookup(ospf
, source
, 0);
7169 ospf_routemap_unset (red
);
7170 return ospf_redistribute_unset (ospf
, source
, 0);
7173 DEFUN (ospf_redistribute_instance_source
,
7174 ospf_redistribute_instance_source_cmd
,
7175 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7177 "Open Shortest Path First\n"
7178 "Non-main Kernel Routing Table\n"
7179 "Instance ID/Table ID\n"
7180 "Metric for redistributed routes\n"
7181 "OSPF default metric\n"
7182 "OSPF exterior metric type for redistributed routes\n"
7183 "Set OSPF External Type 1 metrics\n"
7184 "Set OSPF External Type 2 metrics\n"
7185 "Route map reference\n"
7186 "Pointer to route-map entries\n")
7188 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7189 int idx_ospf_table
= 1;
7191 int idx_redist_param
= 3;
7196 struct ospf_redist
*red
;
7201 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7203 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7208 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7210 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7215 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7217 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7222 /* Get metric value. */
7223 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7224 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7227 /* Get metric type. */
7228 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7229 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7232 red
= ospf_redist_add(ospf
, source
, instance
);
7234 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7235 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7237 ospf_routemap_unset (red
);
7239 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7242 DEFUN (no_ospf_redistribute_instance_source
,
7243 no_ospf_redistribute_instance_source_cmd
,
7244 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7247 "Open Shortest Path First\n"
7248 "Non-main Kernel Routing Table\n"
7249 "Instance ID/Table Id\n"
7250 "Metric for redistributed routes\n"
7251 "OSPF default metric\n"
7252 "OSPF exterior metric type for redistributed routes\n"
7253 "Set OSPF External Type 1 metrics\n"
7254 "Set OSPF External Type 2 metrics\n"
7255 "Route map reference\n"
7256 "Pointer to route-map entries\n")
7258 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7259 int idx_ospf_table
= 2;
7262 struct ospf_redist
*red
;
7265 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7266 source
= ZEBRA_ROUTE_OSPF
;
7268 source
= ZEBRA_ROUTE_TABLE
;
7270 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7272 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7274 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7279 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7281 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7286 red
= ospf_redist_lookup(ospf
, source
, instance
);
7290 ospf_routemap_unset (red
);
7291 return ospf_redistribute_unset (ospf
, source
, instance
);
7294 DEFUN (ospf_distribute_list_out
,
7295 ospf_distribute_list_out_cmd
,
7296 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7297 "Filter networks in routing updates\n"
7298 "Access-list name\n"
7300 FRR_REDIST_HELP_STR_OSPFD
)
7302 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7306 char *proto
= argv
[argc
- 1]->text
;
7308 /* Get distribute source. */
7309 source
= proto_redistnum(AFI_IP
, proto
);
7313 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7316 DEFUN (no_ospf_distribute_list_out
,
7317 no_ospf_distribute_list_out_cmd
,
7318 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7320 "Filter networks in routing updates\n"
7321 "Access-list name\n"
7323 FRR_REDIST_HELP_STR_OSPFD
)
7325 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7329 char *proto
= argv
[argc
- 1]->text
;
7330 source
= proto_redistnum(AFI_IP
, proto
);
7334 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7337 /* Default information originate. */
7338 DEFUN (ospf_default_information_originate
,
7339 ospf_default_information_originate_cmd
,
7340 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7341 "Control distribution of default information\n"
7342 "Distribute a default route\n"
7343 "Always advertise default route\n"
7344 "OSPF default metric\n"
7346 "OSPF metric type for default routes\n"
7347 "Set OSPF External Type 1 metrics\n"
7348 "Set OSPF External Type 2 metrics\n"
7349 "Route map reference\n"
7350 "Pointer to route-map entries\n")
7352 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7353 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7356 struct ospf_redist
*red
;
7359 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7361 /* Check whether "always" was specified */
7362 if (argv_find (argv
, argc
, "always", &idx
))
7363 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7364 /* Get metric value */
7365 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7366 if (!str2metric (argv
[idx
]->arg
, &metric
))
7369 /* Get metric type. */
7370 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7371 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7375 else if (argv_find (argv
, argc
, "WORD", &idx
))
7376 ospf_routemap_set (red
, argv
[idx
]->arg
);
7378 ospf_routemap_unset (red
);
7380 return ospf_redistribute_default_set (ospf
, default_originate
,
7384 DEFUN (no_ospf_default_information_originate
,
7385 no_ospf_default_information_originate_cmd
,
7386 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7388 "Control distribution of default information\n"
7389 "Distribute a default route\n"
7390 "Always advertise default route\n"
7391 "OSPF default metric\n"
7393 "OSPF metric type for default routes\n"
7394 "Set OSPF External Type 1 metrics\n"
7395 "Set OSPF External Type 2 metrics\n"
7396 "Route map reference\n"
7397 "Pointer to route-map entries\n")
7399 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7400 struct prefix_ipv4 p
;
7401 struct ospf_external
*ext
;
7402 struct ospf_redist
*red
;
7405 p
.prefix
.s_addr
= 0;
7408 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7410 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7411 EXTERNAL_INFO (ext
)) {
7412 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7413 ospf_external_del (DEFAULT_ROUTE
, 0);
7416 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7420 ospf_routemap_unset (red
);
7421 return ospf_redistribute_default_unset (ospf
);
7424 DEFUN (ospf_default_metric
,
7425 ospf_default_metric_cmd
,
7426 "default-metric (0-16777214)",
7427 "Set metric of redistributed routes\n"
7430 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7434 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7437 ospf
->default_metric
= metric
;
7442 DEFUN (no_ospf_default_metric
,
7443 no_ospf_default_metric_cmd
,
7444 "no default-metric [(0-16777214)]",
7446 "Set metric of redistributed routes\n"
7449 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7451 ospf
->default_metric
= -1;
7457 DEFUN (ospf_distance
,
7460 "Administrative distance\n"
7461 "OSPF Administrative distance\n")
7463 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7466 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7471 DEFUN (no_ospf_distance
,
7472 no_ospf_distance_cmd
,
7473 "no distance (1-255)",
7475 "Administrative distance\n"
7476 "OSPF Administrative distance\n")
7478 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7480 ospf
->distance_all
= 0;
7485 DEFUN (no_ospf_distance_ospf
,
7486 no_ospf_distance_ospf_cmd
,
7487 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7489 "Administrative distance\n"
7490 "OSPF administrative distance\n"
7491 "Intra-area routes\n"
7492 "Distance for intra-area routes\n"
7493 "Inter-area routes\n"
7494 "Distance for inter-area routes\n"
7496 "Distance for external routes\n")
7498 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7504 if (argv_find (argv
, argc
, "intra-area", &idx
) || argc
== 3)
7505 idx
= ospf
->distance_intra
= 0;
7506 if (argv_find (argv
, argc
, "inter-area", &idx
) || argc
== 3)
7507 idx
= ospf
->distance_inter
= 0;
7508 if (argv_find (argv
, argc
, "external", &idx
) || argc
== 3)
7509 ospf
->distance_external
= 0;
7514 DEFUN (ospf_distance_ospf
,
7515 ospf_distance_ospf_cmd
,
7516 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7517 "Administrative distance\n"
7518 "OSPF administrative distance\n"
7519 "Intra-area routes\n"
7520 "Distance for intra-area routes\n"
7521 "Inter-area routes\n"
7522 "Distance for inter-area routes\n"
7524 "Distance for external routes\n")
7526 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7529 if (argv_find (argv
, argc
, "intra-area", &idx
))
7530 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7532 if (argv_find (argv
, argc
, "inter-area", &idx
))
7533 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7535 if (argv_find (argv
, argc
, "external", &idx
))
7536 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7542 DEFUN (ospf_distance_source
,
7543 ospf_distance_source_cmd
,
7544 "distance (1-255) A.B.C.D/M",
7545 "Administrative distance\n"
7547 "IP source prefix\n")
7549 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7551 int idx_ipv4_prefixlen
= 2;
7556 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7561 DEFUN (no_ospf_distance_source
,
7562 no_ospf_distance_source_cmd
,
7563 "no distance (1-255) A.B.C.D/M",
7565 "Administrative distance\n"
7567 "IP source prefix\n")
7569 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7571 int idx_ipv4_prefixlen
= 3;
7576 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7581 DEFUN (ospf_distance_source_access_list
,
7582 ospf_distance_source_access_list_cmd
,
7583 "distance (1-255) A.B.C.D/M WORD",
7584 "Administrative distance\n"
7586 "IP source prefix\n"
7587 "Access list name\n")
7589 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7591 int idx_ipv4_prefixlen
= 2;
7597 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7602 DEFUN (no_ospf_distance_source_access_list
,
7603 no_ospf_distance_source_access_list_cmd
,
7604 "no distance (1-255) A.B.C.D/M WORD",
7606 "Administrative distance\n"
7608 "IP source prefix\n"
7609 "Access list name\n")
7611 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7613 int idx_ipv4_prefixlen
= 3;
7619 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7625 DEFUN (ip_ospf_mtu_ignore
,
7626 ip_ospf_mtu_ignore_addr_cmd
,
7627 "ip ospf mtu-ignore [A.B.C.D]",
7629 "OSPF interface commands\n"
7630 "Disable MTU mismatch detection on this interface\n"
7631 "Address of interface")
7633 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7635 struct in_addr addr
;
7638 struct ospf_if_params
*params
;
7639 params
= IF_DEF_PARAMS (ifp
);
7643 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7646 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7650 params
= ospf_get_if_params (ifp
, addr
);
7651 ospf_if_update_params (ifp
, addr
);
7653 params
->mtu_ignore
= 1;
7654 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7655 SET_IF_PARAM (params
, mtu_ignore
);
7658 UNSET_IF_PARAM (params
, mtu_ignore
);
7659 if (params
!= IF_DEF_PARAMS (ifp
))
7661 ospf_free_if_params (ifp
, addr
);
7662 ospf_if_update_params (ifp
, addr
);
7668 DEFUN (no_ip_ospf_mtu_ignore
,
7669 no_ip_ospf_mtu_ignore_addr_cmd
,
7670 "no ip ospf mtu-ignore [A.B.C.D]",
7672 "OSPF interface commands\n"
7673 "Disable MTU mismatch detection on this interface\n"
7674 "Address of interface")
7676 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7678 struct in_addr addr
;
7681 struct ospf_if_params
*params
;
7682 params
= IF_DEF_PARAMS (ifp
);
7686 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7689 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7693 params
= ospf_get_if_params (ifp
, addr
);
7694 ospf_if_update_params (ifp
, addr
);
7696 params
->mtu_ignore
= 0;
7697 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7698 SET_IF_PARAM (params
, mtu_ignore
);
7701 UNSET_IF_PARAM (params
, mtu_ignore
);
7702 if (params
!= IF_DEF_PARAMS (ifp
))
7704 ospf_free_if_params (ifp
, addr
);
7705 ospf_if_update_params (ifp
, addr
);
7712 DEFUN (ospf_max_metric_router_lsa_admin
,
7713 ospf_max_metric_router_lsa_admin_cmd
,
7714 "max-metric router-lsa administrative",
7715 "OSPF maximum / infinite-distance metric\n"
7716 "Advertise own Router-LSA with infinite distance (stub router)\n"
7717 "Administratively applied, for an indefinite period\n")
7719 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7720 struct listnode
*ln
;
7721 struct ospf_area
*area
;
7723 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7725 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7727 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7728 ospf_router_lsa_update_area (area
);
7731 /* Allows for areas configured later to get the property */
7732 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7737 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7738 no_ospf_max_metric_router_lsa_admin_cmd
,
7739 "no max-metric router-lsa administrative",
7741 "OSPF maximum / infinite-distance metric\n"
7742 "Advertise own Router-LSA with infinite distance (stub router)\n"
7743 "Administratively applied, for an indefinite period\n")
7745 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7746 struct listnode
*ln
;
7747 struct ospf_area
*area
;
7749 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7751 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7753 /* Don't trample on the start-up stub timer */
7754 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7755 && !area
->t_stub_router
)
7757 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7758 ospf_router_lsa_update_area (area
);
7761 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7765 DEFUN (ospf_max_metric_router_lsa_startup
,
7766 ospf_max_metric_router_lsa_startup_cmd
,
7767 "max-metric router-lsa on-startup (5-86400)",
7768 "OSPF maximum / infinite-distance metric\n"
7769 "Advertise own Router-LSA with infinite distance (stub router)\n"
7770 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7771 "Time (seconds) to advertise self as stub-router\n")
7773 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7775 unsigned int seconds
;
7779 vty_out (vty
, "%% Must supply stub-router period");
7783 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7785 ospf
->stub_router_startup_time
= seconds
;
7790 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7791 no_ospf_max_metric_router_lsa_startup_cmd
,
7792 "no max-metric router-lsa on-startup [(5-86400)]",
7794 "OSPF maximum / infinite-distance metric\n"
7795 "Advertise own Router-LSA with infinite distance (stub router)\n"
7796 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7797 "Time (seconds) to advertise self as stub-router\n")
7799 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7800 struct listnode
*ln
;
7801 struct ospf_area
*area
;
7803 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7805 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7807 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7808 OSPF_TIMER_OFF (area
->t_stub_router
);
7810 /* Don't trample on admin stub routed */
7811 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7813 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7814 ospf_router_lsa_update_area (area
);
7821 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7822 ospf_max_metric_router_lsa_shutdown_cmd
,
7823 "max-metric router-lsa on-shutdown (5-100)",
7824 "OSPF maximum / infinite-distance metric\n"
7825 "Advertise own Router-LSA with infinite distance (stub router)\n"
7826 "Advertise stub-router prior to full shutdown of OSPF\n"
7827 "Time (seconds) to wait till full shutdown\n")
7829 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7831 unsigned int seconds
;
7835 vty_out (vty
, "%% Must supply stub-router shutdown period");
7839 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7841 ospf
->stub_router_shutdown_time
= seconds
;
7846 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7847 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7848 "no max-metric router-lsa on-shutdown [(5-100)]",
7850 "OSPF maximum / infinite-distance metric\n"
7851 "Advertise own Router-LSA with infinite distance (stub router)\n"
7852 "Advertise stub-router prior to full shutdown of OSPF\n"
7853 "Time (seconds) to wait till full shutdown\n")
7855 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7857 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7863 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7865 struct listnode
*ln
;
7866 struct ospf_area
*area
;
7868 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7869 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7870 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7871 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7872 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7873 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7874 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7876 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7878 vty_out (vty
, " max-metric router-lsa administrative%s",
7887 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7889 struct route_node
*rn
;
7890 struct ospf_route
*or;
7891 struct listnode
*pnode
, *pnnode
;
7892 struct ospf_path
*path
;
7894 vty_out (vty
, "============ OSPF network routing table ============%s",
7897 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7898 if ((or = rn
->info
) != NULL
)
7901 snprintf (buf1
, 19, "%s/%d",
7902 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7904 switch (or->path_type
)
7906 case OSPF_PATH_INTER_AREA
:
7907 if (or->type
== OSPF_DESTINATION_NETWORK
)
7908 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7909 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7910 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7911 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7913 case OSPF_PATH_INTRA_AREA
:
7914 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7915 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7921 if (or->type
== OSPF_DESTINATION_NETWORK
)
7922 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7924 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7926 if (path
->nexthop
.s_addr
== 0)
7927 vty_out (vty
, "%24s directly attached to %s%s",
7928 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7930 vty_out (vty
, "%24s via %s, %s%s", "",
7931 inet_ntoa (path
->nexthop
),
7932 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7936 vty_out (vty
, "%s", VTY_NEWLINE
);
7940 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7942 struct route_node
*rn
;
7943 struct ospf_route
*or;
7944 struct listnode
*pnode
;
7945 struct listnode
*node
;
7946 struct ospf_path
*path
;
7948 vty_out (vty
, "============ OSPF router routing table =============%s",
7950 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7955 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7957 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7960 vty_out (vty
, "%24s", "");
7963 vty_out (vty
, "%s [%d] area: %s",
7964 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7965 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7967 vty_out (vty
, "%s%s%s",
7968 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
7969 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
7972 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
7974 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7976 if (path
->nexthop
.s_addr
== 0)
7977 vty_out (vty
, "%24s directly attached to %s%s",
7978 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7981 vty_out (vty
, "%24s via %s, %s%s", "",
7982 inet_ntoa (path
->nexthop
),
7983 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7989 vty_out (vty
, "%s", VTY_NEWLINE
);
7993 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
7995 struct route_node
*rn
;
7996 struct ospf_route
*er
;
7997 struct listnode
*pnode
, *pnnode
;
7998 struct ospf_path
*path
;
8000 vty_out (vty
, "============ OSPF external routing table ===========%s",
8002 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8003 if ((er
= rn
->info
) != NULL
)
8006 snprintf (buf1
, 19, "%s/%d",
8007 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8009 switch (er
->path_type
)
8011 case OSPF_PATH_TYPE1_EXTERNAL
:
8012 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8013 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8015 case OSPF_PATH_TYPE2_EXTERNAL
:
8016 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8017 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8021 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8023 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
8025 if (path
->nexthop
.s_addr
== 0)
8026 vty_out (vty
, "%24s directly attached to %s%s",
8027 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
8029 vty_out (vty
, "%24s via %s, %s%s", "",
8030 inet_ntoa (path
->nexthop
),
8031 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
8036 vty_out (vty
, "%s", VTY_NEWLINE
);
8040 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8043 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8044 VTY_NEWLINE
, VTY_NEWLINE
);
8046 if (ospf
->new_table
== NULL
)
8048 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8052 /* Show Network routes.
8053 show_ip_ospf_route_network (vty, ospf->new_table); */
8055 /* Show Router routes. */
8056 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8058 vty_out (vty
, "%s", VTY_NEWLINE
);
8063 DEFUN (show_ip_ospf_border_routers
,
8064 show_ip_ospf_border_routers_cmd
,
8065 "show ip ospf border-routers",
8068 "OSPF information\n"
8069 "Show all the ABR's and ASBR's\n")
8073 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8076 return show_ip_ospf_border_routers_common(vty
, ospf
);
8079 DEFUN (show_ip_ospf_instance_border_routers
,
8080 show_ip_ospf_instance_border_routers_cmd
,
8081 "show ip ospf (1-65535) border-routers",
8084 "OSPF information\n"
8086 "Show all the ABR's and ASBR's\n")
8090 u_short instance
= 0;
8092 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8093 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8096 return show_ip_ospf_border_routers_common(vty
, ospf
);
8100 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8103 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8104 VTY_NEWLINE
, VTY_NEWLINE
);
8106 if (ospf
->new_table
== NULL
)
8108 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8112 /* Show Network routes. */
8113 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8115 /* Show Router routes. */
8116 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8118 /* Show AS External routes. */
8119 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8121 vty_out (vty
, "%s", VTY_NEWLINE
);
8126 DEFUN (show_ip_ospf_route
,
8127 show_ip_ospf_route_cmd
,
8128 "show ip ospf route",
8131 "OSPF information\n"
8132 "OSPF routing table\n")
8136 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8139 return show_ip_ospf_route_common(vty
, ospf
);
8142 DEFUN (show_ip_ospf_instance_route
,
8143 show_ip_ospf_instance_route_cmd
,
8144 "show ip ospf (1-65535) route",
8147 "OSPF information\n"
8149 "OSPF routing table\n")
8153 u_short instance
= 0;
8155 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8156 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8159 return show_ip_ospf_route_common(vty
, ospf
);
8162 const char *ospf_abr_type_str
[] =
8171 const char *ospf_shortcut_mode_str
[] =
8180 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8182 memset (buf
, 0, length
);
8184 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8185 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8187 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8191 const char *ospf_int_type_str
[] =
8193 "unknown", /* should never be used. */
8197 "point-to-multipoint",
8198 "virtual-link", /* should never be used. */
8202 /* Configuration write function for ospfd. */
8204 config_write_interface (struct vty
*vty
)
8206 struct listnode
*n1
, *n2
;
8207 struct interface
*ifp
;
8208 struct crypt_key
*ck
;
8210 struct route_node
*rn
= NULL
;
8211 struct ospf_if_params
*params
;
8212 struct ospf
*ospf
= ospf_lookup();
8214 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8216 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8219 if (ifp
->ifindex
== IFINDEX_DELETED
)
8222 vty_out (vty
, "!%s", VTY_NEWLINE
);
8223 vty_out (vty
, "interface %s%s", ifp
->name
,
8226 vty_out (vty
, " description %s%s", ifp
->desc
,
8231 params
= IF_DEF_PARAMS (ifp
);
8234 /* Interface Network print. */
8235 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8236 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8238 if (params
->type
!= ospf_default_iftype(ifp
))
8240 vty_out (vty
, " ip ospf network %s",
8241 ospf_int_type_str
[params
->type
]);
8242 if (params
!= IF_DEF_PARAMS (ifp
))
8243 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8244 vty_out (vty
, "%s", VTY_NEWLINE
);
8248 /* OSPF interface authentication print */
8249 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8250 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8252 const char *auth_str
;
8254 /* Translation tables are not that much help here due to syntax
8255 of the simple option */
8256 switch (params
->auth_type
)
8259 case OSPF_AUTH_NULL
:
8263 case OSPF_AUTH_SIMPLE
:
8267 case OSPF_AUTH_CRYPTOGRAPHIC
:
8268 auth_str
= " message-digest";
8276 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8277 if (params
!= IF_DEF_PARAMS (ifp
))
8278 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8279 vty_out (vty
, "%s", VTY_NEWLINE
);
8282 /* Simple Authentication Password print. */
8283 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8284 params
->auth_simple
[0] != '\0')
8286 vty_out (vty
, " ip ospf authentication-key %s",
8287 params
->auth_simple
);
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 /* Cryptographic Authentication Key print. */
8294 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8296 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8297 ck
->key_id
, ck
->auth_key
);
8298 if (params
!= IF_DEF_PARAMS (ifp
))
8299 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8300 vty_out (vty
, "%s", VTY_NEWLINE
);
8303 /* Interface Output Cost print. */
8304 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8306 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
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
);
8312 /* Hello Interval print. */
8313 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8314 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8316 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8317 if (params
!= IF_DEF_PARAMS (ifp
))
8318 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8319 vty_out (vty
, "%s", VTY_NEWLINE
);
8323 /* Router Dead Interval print. */
8324 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8325 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8327 vty_out (vty
, " ip ospf dead-interval ");
8330 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8331 vty_out (vty
, "minimal hello-multiplier %d",
8332 params
->fast_hello
);
8334 vty_out (vty
, "%u", params
->v_wait
);
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 /* Router Priority print. */
8342 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8343 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8345 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8346 if (params
!= IF_DEF_PARAMS (ifp
))
8347 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8348 vty_out (vty
, "%s", VTY_NEWLINE
);
8351 /* Retransmit Interval print. */
8352 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8353 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8355 vty_out (vty
, " ip ospf retransmit-interval %u",
8356 params
->retransmit_interval
);
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
);
8362 /* Transmit Delay print. */
8363 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8364 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8366 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8367 if (params
!= IF_DEF_PARAMS (ifp
))
8368 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8369 vty_out (vty
, "%s", VTY_NEWLINE
);
8373 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8376 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8377 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8379 vty_out (vty
, " ip ospf area %s%s",
8380 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8385 ospf_bfd_write_config(vty
, params
);
8387 /* MTU ignore print. */
8388 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8389 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8391 if (params
->mtu_ignore
== 0)
8392 vty_out (vty
, " no ip ospf mtu-ignore");
8394 vty_out (vty
, " ip ospf mtu-ignore");
8395 if (params
!= IF_DEF_PARAMS (ifp
))
8396 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8397 vty_out (vty
, "%s", VTY_NEWLINE
);
8404 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8406 rn
= route_next (rn
);
8416 ospf_opaque_config_write_if (vty
, ifp
);
8423 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8425 struct route_node
*rn
;
8426 u_char buf
[INET_ADDRSTRLEN
];
8428 /* `network area' print. */
8429 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8432 struct ospf_network
*n
= rn
->info
;
8434 memset (buf
, 0, INET_ADDRSTRLEN
);
8436 /* Create Area ID string by specified Area ID format. */
8437 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8438 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8440 sprintf ((char *) buf
, "%lu",
8441 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8443 /* Network print. */
8444 vty_out (vty
, " network %s/%d area %s%s",
8445 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8453 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8455 struct listnode
*node
;
8456 struct ospf_area
*area
;
8457 u_char buf
[INET_ADDRSTRLEN
];
8459 /* Area configuration print. */
8460 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8462 struct route_node
*rn1
;
8464 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8466 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8468 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8469 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8471 vty_out (vty
, " area %s authentication message-digest%s",
8475 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8476 vty_out (vty
, " area %s shortcut %s%s", buf
,
8477 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8480 if ((area
->external_routing
== OSPF_AREA_STUB
)
8481 || (area
->external_routing
== OSPF_AREA_NSSA
)
8484 if (area
->external_routing
== OSPF_AREA_STUB
)
8485 vty_out (vty
, " area %s stub", buf
);
8486 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8488 vty_out (vty
, " area %s nssa", buf
);
8489 switch (area
->NSSATranslatorRole
)
8491 case OSPF_NSSA_ROLE_NEVER
:
8492 vty_out (vty
, " translate-never");
8494 case OSPF_NSSA_ROLE_ALWAYS
:
8495 vty_out (vty
, " translate-always");
8497 case OSPF_NSSA_ROLE_CANDIDATE
:
8499 vty_out (vty
, " translate-candidate");
8503 if (area
->no_summary
)
8504 vty_out (vty
, " no-summary");
8506 vty_out (vty
, "%s", VTY_NEWLINE
);
8508 if (area
->default_cost
!= 1)
8509 vty_out (vty
, " area %s default-cost %d%s", buf
,
8510 area
->default_cost
, VTY_NEWLINE
);
8513 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8516 struct ospf_area_range
*range
= rn1
->info
;
8518 vty_out (vty
, " area %s range %s/%d", buf
,
8519 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8521 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8522 vty_out (vty
, " cost %d", range
->cost_config
);
8524 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8525 vty_out (vty
, " not-advertise");
8527 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8528 vty_out (vty
, " substitute %s/%d",
8529 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8531 vty_out (vty
, "%s", VTY_NEWLINE
);
8534 if (EXPORT_NAME (area
))
8535 vty_out (vty
, " area %s export-list %s%s", buf
,
8536 EXPORT_NAME (area
), VTY_NEWLINE
);
8538 if (IMPORT_NAME (area
))
8539 vty_out (vty
, " area %s import-list %s%s", buf
,
8540 IMPORT_NAME (area
), VTY_NEWLINE
);
8542 if (PREFIX_NAME_IN (area
))
8543 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8544 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8546 if (PREFIX_NAME_OUT (area
))
8547 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8548 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8555 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8557 struct ospf_nbr_nbma
*nbr_nbma
;
8558 struct route_node
*rn
;
8560 /* Static Neighbor configuration print. */
8561 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8562 if ((nbr_nbma
= rn
->info
))
8564 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8566 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8567 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8569 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8570 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8572 vty_out (vty
, "%s", VTY_NEWLINE
);
8579 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8581 struct listnode
*node
;
8582 struct ospf_vl_data
*vl_data
;
8583 u_char buf
[INET_ADDRSTRLEN
];
8585 /* Virtual-Link print */
8586 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8588 struct listnode
*n2
;
8589 struct crypt_key
*ck
;
8590 struct ospf_interface
*oi
;
8592 if (vl_data
!= NULL
)
8594 memset (buf
, 0, INET_ADDRSTRLEN
);
8596 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8597 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8599 sprintf ((char *) buf
, "%lu",
8600 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8601 oi
= vl_data
->vl_oi
;
8604 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8605 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8606 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8607 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8608 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8610 inet_ntoa (vl_data
->vl_peer
),
8611 OSPF_IF_PARAM (oi
, v_hello
),
8612 OSPF_IF_PARAM (oi
, retransmit_interval
),
8613 OSPF_IF_PARAM (oi
, transmit_delay
),
8614 OSPF_IF_PARAM (oi
, v_wait
),
8617 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8618 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8620 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8621 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8623 inet_ntoa (vl_data
->vl_peer
),
8624 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8627 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8629 vty_out (vty
, " area %s virtual-link %s"
8630 " message-digest-key %d md5 %s%s",
8632 inet_ntoa (vl_data
->vl_peer
),
8633 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8643 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8647 /* redistribute print. */
8648 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8650 struct list
*red_list
;
8651 struct listnode
*node
;
8652 struct ospf_redist
*red
;
8654 red_list
= ospf
->redist
[type
];
8658 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8660 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8662 vty_out (vty
, " %d", red
->instance
);
8664 if (red
->dmetric
.value
>= 0)
8665 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8667 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8668 vty_out (vty
, " metric-type 1");
8670 if (ROUTEMAP_NAME (red
))
8671 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8673 vty_out (vty
, "%s", VTY_NEWLINE
);
8681 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8683 if (ospf
->default_metric
!= -1)
8684 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8690 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8693 struct ospf_redist
*red
;
8697 /* distribute-list print. */
8698 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8699 if (DISTRIBUTE_NAME (ospf
, type
))
8700 vty_out (vty
, " distribute-list %s out %s%s",
8701 DISTRIBUTE_NAME (ospf
, type
),
8702 zebra_route_string(type
), VTY_NEWLINE
);
8704 /* default-information print. */
8705 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8707 vty_out (vty
, " default-information originate");
8708 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8709 vty_out (vty
, " always");
8711 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8714 if (red
->dmetric
.value
>= 0)
8715 vty_out (vty
, " metric %d",
8716 red
->dmetric
.value
);
8717 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8718 vty_out (vty
, " metric-type 1");
8720 if (ROUTEMAP_NAME (red
))
8721 vty_out (vty
, " route-map %s",
8722 ROUTEMAP_NAME (red
));
8725 vty_out (vty
, "%s", VTY_NEWLINE
);
8734 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8736 struct route_node
*rn
;
8737 struct ospf_distance
*odistance
;
8739 if (ospf
->distance_all
)
8740 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8742 if (ospf
->distance_intra
8743 || ospf
->distance_inter
8744 || ospf
->distance_external
)
8746 vty_out (vty
, " distance ospf");
8748 if (ospf
->distance_intra
)
8749 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8750 if (ospf
->distance_inter
)
8751 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8752 if (ospf
->distance_external
)
8753 vty_out (vty
, " external %d", ospf
->distance_external
);
8755 vty_out (vty
, "%s", VTY_NEWLINE
);
8758 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8759 if ((odistance
= rn
->info
) != NULL
)
8761 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8762 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8763 odistance
->access_list
? odistance
->access_list
: "",
8769 /* OSPF configuration write function. */
8771 ospf_config_write (struct vty
*vty
)
8774 struct interface
*ifp
;
8775 struct ospf_interface
*oi
;
8776 struct listnode
*node
;
8779 ospf
= ospf_lookup ();
8780 if (ospf
!= NULL
&& ospf
->oi_running
)
8782 /* `router ospf' print. */
8784 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8786 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8790 if (!ospf
->networks
)
8793 /* Router ID print. */
8794 if (ospf
->router_id_static
.s_addr
!= 0)
8795 vty_out (vty
, " ospf router-id %s%s",
8796 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8798 /* ABR type print. */
8799 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8800 vty_out (vty
, " ospf abr-type %s%s",
8801 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8803 /* log-adjacency-changes flag print. */
8804 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8806 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8807 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8811 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8814 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8815 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8816 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8818 /* auto-cost reference-bandwidth configuration. */
8819 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8821 vty_out (vty
, "! Important: ensure reference bandwidth "
8822 "is consistent across all routers%s", VTY_NEWLINE
);
8823 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8824 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8827 /* SPF timers print. */
8828 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8829 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8830 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8831 vty_out (vty
, " timers throttle spf %d %d %d%s",
8832 ospf
->spf_delay
, ospf
->spf_holdtime
,
8833 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8835 /* LSA timers print. */
8836 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8837 vty_out (vty
, " timers throttle lsa all %d%s",
8838 ospf
->min_ls_interval
, VTY_NEWLINE
);
8839 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8840 vty_out (vty
, " timers lsa min-arrival %d%s",
8841 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8843 /* Write multiplier print. */
8844 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8845 vty_out (vty
, " ospf write-multiplier %d%s",
8846 ospf
->write_oi_count
, VTY_NEWLINE
);
8848 /* Max-metric router-lsa print */
8849 config_write_stub_router (vty
, ospf
);
8851 /* SPF refresh parameters print. */
8852 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8853 vty_out (vty
, " refresh timer %d%s",
8854 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8856 /* Redistribute information print. */
8857 config_write_ospf_redistribute (vty
, ospf
);
8859 /* passive-interface print. */
8860 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8861 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8863 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8864 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8865 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8866 ospf
->passive_interface_default
)
8868 vty_out (vty
, " %spassive-interface %s%s",
8869 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8870 ifp
->name
, VTY_NEWLINE
);
8872 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8874 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8876 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8879 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8882 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8885 vty_out (vty
, " %spassive-interface %s %s%s",
8886 oi
->params
->passive_interface
? "" : "no ",
8888 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8891 /* Network area print. */
8892 config_write_network_area (vty
, ospf
);
8894 /* Area config print. */
8895 config_write_ospf_area (vty
, ospf
);
8897 /* static neighbor print. */
8898 config_write_ospf_nbr_nbma (vty
, ospf
);
8900 /* Virtual-Link print. */
8901 config_write_virtual_link (vty
, ospf
);
8903 /* Default metric configuration. */
8904 config_write_ospf_default_metric (vty
, ospf
);
8906 /* Distribute-list and default-information print. */
8907 config_write_ospf_distribute (vty
, ospf
);
8909 /* Distance configuration. */
8910 config_write_ospf_distance (vty
, ospf
);
8912 ospf_opaque_config_write_router (vty
, ospf
);
8919 ospf_vty_show_init (void)
8921 /* "show ip ospf" commands. */
8922 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8924 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8926 /* "show ip ospf database" commands. */
8927 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8928 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8930 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8931 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8932 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8934 /* "show ip ospf interface" commands. */
8935 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8937 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8939 /* "show ip ospf neighbor" commands. */
8940 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8941 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8942 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8943 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8944 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8945 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8946 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8948 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8949 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8950 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8951 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8952 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8953 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8954 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8956 /* "show ip ospf route" commands. */
8957 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8958 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8960 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8961 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8965 /* ospfd's interface node. */
8966 static struct cmd_node interface_node
=
8973 /* Initialization of OSPF interface. */
8975 ospf_vty_if_init (void)
8977 /* Install interface node. */
8978 install_node (&interface_node
, config_write_interface
);
8981 /* "ip ospf authentication" commands. */
8982 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8983 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8984 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
8985 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8986 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8987 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8988 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
8990 /* "ip ospf message-digest-key" commands. */
8991 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8992 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8994 /* "ip ospf cost" commands. */
8995 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8996 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8998 /* "ip ospf mtu-ignore" commands. */
8999 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9000 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9002 /* "ip ospf dead-interval" commands. */
9003 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9004 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9005 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9007 /* "ip ospf hello-interval" commands. */
9008 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9009 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9011 /* "ip ospf network" commands. */
9012 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9013 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9015 /* "ip ospf priority" commands. */
9016 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9017 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9019 /* "ip ospf retransmit-interval" commands. */
9020 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9021 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9023 /* "ip ospf transmit-delay" commands. */
9024 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9025 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9027 /* "ip ospf area" commands. */
9028 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9029 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9031 /* These commands are compatibitliy for previous version. */
9032 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9033 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9034 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9035 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9036 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9037 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9038 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9039 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9040 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9041 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9042 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9043 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9044 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9045 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9046 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9047 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9048 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9052 ospf_vty_zebra_init (void)
9054 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9055 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9056 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9057 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9059 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9060 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9062 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9063 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9065 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9066 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9068 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9069 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9070 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9071 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9073 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9074 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9075 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9076 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9080 static struct cmd_node ospf_node
=
9083 "%s(config-router)# ",
9088 ospf_interface_clear (struct interface
*ifp
)
9090 if (!if_is_operative (ifp
)) return;
9092 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9093 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9098 DEFUN (clear_ip_ospf_interface
,
9099 clear_ip_ospf_interface_cmd
,
9100 "clear ip ospf interface [IFNAME]",
9103 "OSPF information\n"
9104 "Interface information\n"
9108 struct interface
*ifp
;
9109 struct listnode
*node
;
9111 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9113 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9114 ospf_interface_clear(ifp
);
9116 else /* Interface name is specified. */
9118 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
, VRF_DEFAULT
)) == NULL
)
9119 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9121 ospf_interface_clear(ifp
);
9128 ospf_vty_clear_init (void)
9130 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9134 /* Install OSPF related vty commands. */
9136 ospf_vty_init (void)
9138 /* Install ospf top node. */
9139 install_node (&ospf_node
, ospf_config_write
);
9141 /* "router ospf" commands. */
9142 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9143 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9146 install_default (OSPF_NODE
);
9148 /* "ospf router-id" commands. */
9149 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9150 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9151 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9153 /* "passive-interface" commands. */
9154 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9155 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9157 /* "ospf abr-type" commands. */
9158 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9159 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9161 /* "ospf log-adjacency-changes" commands. */
9162 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9163 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9164 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9165 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9167 /* "ospf rfc1583-compatible" commands. */
9168 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9169 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9170 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9171 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9173 /* "network area" commands. */
9174 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9175 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9177 /* "area authentication" commands. */
9178 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9179 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9180 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9182 /* "area range" commands. */
9183 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9184 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9185 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9186 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9187 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9188 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9190 /* "area virtual-link" commands. */
9191 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9192 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9193 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9194 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9205 /* "area stub" commands. */
9206 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9207 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9208 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9209 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9211 /* "area nssa" commands. */
9212 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9213 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9214 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9215 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9216 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9218 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9219 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9221 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9222 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9224 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9225 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9227 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9228 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9230 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9231 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9233 /* SPF timer commands */
9234 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9235 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9237 /* LSA timers commands */
9238 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9239 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9240 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9241 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9242 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9243 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9245 /* refresh timer commands */
9246 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9247 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9249 /* max-metric commands */
9250 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9251 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9252 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9253 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9254 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9255 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9257 /* reference bandwidth commands */
9258 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9259 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9261 /* "neighbor" commands. */
9262 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9263 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9264 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9265 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9267 /* write multiplier commands */
9268 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9269 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9270 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9271 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9273 /* Init interface related vty commands. */
9274 ospf_vty_if_init ();
9276 /* Init zebra related vty commands. */
9277 ospf_vty_zebra_init ();