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
37 #include "ospfd/ospfd.h"
38 #include "ospfd/ospf_asbr.h"
39 #include "ospfd/ospf_lsa.h"
40 #include "ospfd/ospf_lsdb.h"
41 #include "ospfd/ospf_ism.h"
42 #include "ospfd/ospf_interface.h"
43 #include "ospfd/ospf_nsm.h"
44 #include "ospfd/ospf_neighbor.h"
45 #include "ospfd/ospf_flood.h"
46 #include "ospfd/ospf_abr.h"
47 #include "ospfd/ospf_spf.h"
48 #include "ospfd/ospf_route.h"
49 #include "ospfd/ospf_zebra.h"
50 /*#include "ospfd/ospf_routemap.h" */
51 #include "ospfd/ospf_vty.h"
52 #include "ospfd/ospf_dump.h"
53 #include "ospfd/ospf_bfd.h"
55 static const char *ospf_network_type_str
[] =
66 /* Utility functions. */
68 ospf_str2area_id (const char *str
, struct in_addr
*area_id
, int *format
)
73 /* match "A.B.C.D". */
74 if (strchr (str
, '.') != NULL
)
76 ret
= inet_aton (str
, area_id
);
79 *format
= OSPF_AREA_ID_FORMAT_ADDRESS
;
81 /* match "<0-4294967295>". */
87 ret
= strtoul (str
, &endptr
, 10);
88 if (*endptr
!= '\0' || errno
|| ret
> UINT32_MAX
)
91 area_id
->s_addr
= htonl (ret
);
92 *format
= OSPF_AREA_ID_FORMAT_DECIMAL
;
100 str2metric (const char *str
, int *metric
)
106 *metric
= strtol (str
, NULL
, 10);
107 if (*metric
< 0 && *metric
> 16777214)
109 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
117 str2metric_type (const char *str
, int *metric_type
)
123 if (strncmp (str
, "1", 1) == 0)
124 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
125 else if (strncmp (str
, "2", 1) == 0)
126 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
134 ospf_oi_count (struct interface
*ifp
)
136 struct route_node
*rn
;
139 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
148 "router ospf [(1-65535)]",
149 "Enable a routing process\n"
150 "Start OSPF configuration\n"
154 u_short instance
= 0;
156 ospf
= ospf_lookup();
159 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
164 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
166 /* The following logic to set the vty qobj index is in place to be able
167 to ignore the commands which dont belong to this instance. */
168 if (ospf
->instance
!= instance
)
169 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
172 if (IS_DEBUG_OSPF_EVENT
)
173 zlog_debug ("Config command 'router ospf %d' received", instance
);
174 ospf
->oi_running
= 1;
175 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
176 ospf_router_id_update (ospf
);
182 DEFUN (no_router_ospf
,
184 "no router ospf [(1-65535)]",
186 "Enable a routing process\n"
187 "Start OSPF configuration\n"
191 u_short instance
= 0;
194 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
196 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
205 DEFUN (ospf_router_id
,
207 "ospf router-id A.B.C.D",
208 "OSPF specific commands\n"
209 "router-id for the OSPF process\n"
210 "OSPF router-id in IP address format\n")
212 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
214 struct listnode
*node
;
215 struct ospf_area
*area
;
216 struct in_addr router_id
;
219 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
222 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
226 ospf
->router_id_static
= router_id
;
228 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
231 vty_out (vty
, "For this router-id change to take effect,"
232 " save config and restart ospfd%s", VTY_NEWLINE
);
236 ospf_router_id_update (ospf
);
241 DEFUN_HIDDEN (ospf_router_id_old
,
242 ospf_router_id_old_cmd
,
244 "router-id for the OSPF process\n"
245 "OSPF router-id in IP address format\n")
247 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
249 struct listnode
*node
;
250 struct ospf_area
*area
;
251 struct in_addr router_id
;
254 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
257 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
261 ospf
->router_id_static
= router_id
;
263 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
266 vty_out (vty
, "For this router-id change to take effect,"
267 " save config and restart ospfd%s", VTY_NEWLINE
);
271 ospf_router_id_update (ospf
);
276 DEFUN (no_ospf_router_id
,
277 no_ospf_router_id_cmd
,
278 "no ospf router-id [A.B.C.D]",
280 "OSPF specific commands\n"
281 "router-id for the OSPF process\n"
282 "OSPF router-id in IP address format\n")
284 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
285 struct listnode
*node
;
286 struct ospf_area
*area
;
288 ospf
->router_id_static
.s_addr
= 0;
290 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
293 vty_out (vty
, "For this router-id change to take effect,"
294 " save config and restart ospfd%s", VTY_NEWLINE
);
298 ospf_router_id_update (ospf
);
305 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
308 struct interface
*ifp
;
309 struct ospf_interface
*oi
;
311 ospf
->passive_interface_default
= newval
;
313 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
316 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
317 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
319 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
321 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
322 UNSET_IF_PARAM (oi
->params
, passive_interface
);
323 /* update multicast memberships */
324 ospf_if_set_multicast(oi
);
329 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
330 struct ospf_if_params
*params
, u_char value
,
335 params
->passive_interface
= value
;
336 if (params
!= IF_DEF_PARAMS (ifp
))
338 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
339 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
341 dflt
= ospf
->passive_interface_default
;
344 SET_IF_PARAM (params
, passive_interface
);
346 UNSET_IF_PARAM (params
, passive_interface
);
348 ospf_free_if_params (ifp
, addr
);
349 ospf_if_update_params (ifp
, addr
);
354 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
355 struct ospf_if_params
*params
, u_char value
)
357 params
->passive_interface
= value
;
358 if (params
== IF_DEF_PARAMS (ifp
))
360 if (value
!= ospf
->passive_interface_default
)
361 SET_IF_PARAM (params
, passive_interface
);
363 UNSET_IF_PARAM (params
, passive_interface
);
367 DEFUN (ospf_passive_interface
,
368 ospf_passive_interface_addr_cmd
,
369 "passive-interface <IFNAME [A.B.C.D]|default>",
370 "Suppress routing updates on an interface\n"
373 "Suppress routing updates on interfaces by default\n")
375 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
377 struct interface
*ifp
;
378 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
380 struct ospf_if_params
*params
;
381 struct route_node
*rn
;
383 if (strcmp (argv
[1]->text
, "default") == 0)
385 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
389 ifp
= if_get_by_name (argv
[1]->arg
);
391 params
= IF_DEF_PARAMS (ifp
);
395 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
398 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
403 params
= ospf_get_if_params (ifp
, addr
);
404 ospf_if_update_params (ifp
, addr
);
405 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
406 OSPF_IF_PASSIVE
, addr
);
409 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
411 /* XXX We should call ospf_if_set_multicast on exactly those
412 * interfaces for which the passive property changed. It is too much
413 * work to determine this set, so we do this for every interface.
414 * This is safe and reasonable because ospf_if_set_multicast uses a
415 * record of joined groups to avoid systems calls if the desired
416 * memberships match the current memership.
419 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
421 struct ospf_interface
*oi
= rn
->info
;
423 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
424 ospf_if_set_multicast(oi
);
427 * XXX It is not clear what state transitions the interface needs to
428 * undergo when going from active to passive. Fixing this will
429 * require precise identification of interfaces having such a
436 DEFUN (no_ospf_passive_interface
,
437 no_ospf_passive_interface_addr_cmd
,
438 "no passive-interface <IFNAME [A.B.C.D]|default>",
440 "Allow routing updates on an interface\n"
443 "Allow routing updates on interfaces by default\n")
445 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
447 struct interface
*ifp
;
448 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
449 struct ospf_if_params
*params
;
451 struct route_node
*rn
;
453 if (strcmp (argv
[2]->text
, "default") == 0)
455 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
459 ifp
= if_get_by_name (argv
[2]->arg
);
461 params
= IF_DEF_PARAMS (ifp
);
465 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
468 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
473 params
= ospf_lookup_if_params (ifp
, addr
);
476 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
479 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
481 /* XXX We should call ospf_if_set_multicast on exactly those
482 * interfaces for which the passive property changed. It is too much
483 * work to determine this set, so we do this for every interface.
484 * This is safe and reasonable because ospf_if_set_multicast uses a
485 * record of joined groups to avoid systems calls if the desired
486 * memberships match the current memership.
488 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
490 struct ospf_interface
*oi
= rn
->info
;
492 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
493 ospf_if_set_multicast(oi
);
501 DEFUN (ospf_network_area
,
502 ospf_network_area_cmd
,
503 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
504 "Enable routing on an IP network\n"
505 "OSPF network prefix\n"
506 "Set the OSPF area ID\n"
507 "OSPF area ID in IP address format\n"
508 "OSPF area ID as a decimal value\n")
510 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
511 int idx_ipv4_prefixlen
= 1;
512 int idx_ipv4_number
= 3;
513 struct prefix_ipv4 p
;
514 struct in_addr area_id
;
519 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
524 if (ospf
->if_ospf_cli_count
> 0)
526 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
531 /* Get network prefix and Area ID. */
532 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
533 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
535 ret
= ospf_network_set (ospf
, &p
, area_id
);
538 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
545 DEFUN (no_ospf_network_area
,
546 no_ospf_network_area_cmd
,
547 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
549 "Enable routing on an IP network\n"
550 "OSPF network prefix\n"
551 "Set the OSPF area ID\n"
552 "OSPF area ID in IP address format\n"
553 "OSPF area ID as a decimal value\n")
555 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
556 int idx_ipv4_prefixlen
= 2;
557 int idx_ipv4_number
= 4;
558 struct prefix_ipv4 p
;
559 struct in_addr area_id
;
564 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
569 /* Get network prefix and Area ID. */
570 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
571 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
573 ret
= ospf_network_unset (ospf
, &p
, area_id
);
576 vty_out (vty
, "Can't find specified network area configuration.%s",
584 DEFUN (ospf_area_range
,
586 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
587 "OSPF area parameters\n"
588 "OSPF area ID in IP address format\n"
589 "OSPF area ID as a decimal value\n"
590 "Summarize routes matching address/mask (border routers only)\n"
591 "Area range prefix\n"
592 "Advertise this range (default)\n"
593 "User specified metric for this range\n"
594 "Advertised metric for this range\n")
596 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
597 int idx_ipv4_number
= 1;
598 int idx_ipv4_prefixlen
= 3;
600 struct prefix_ipv4 p
;
601 struct in_addr area_id
;
605 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
606 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
608 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
611 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
612 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
618 DEFUN (ospf_area_range_cost
,
619 ospf_area_range_cost_cmd
,
620 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
621 "OSPF area parameters\n"
622 "OSPF area ID in IP address format\n"
623 "OSPF area ID as a decimal value\n"
624 "Summarize routes matching address/mask (border routers only)\n"
625 "Area range prefix\n"
626 "User specified metric for this range\n"
627 "Advertised metric for this range\n")
629 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
630 int idx_ipv4_number
= 1;
631 int idx_ipv4_prefixlen
= 3;
633 struct prefix_ipv4 p
;
634 struct in_addr area_id
;
638 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
639 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
641 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
643 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
644 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
649 DEFUN (ospf_area_range_not_advertise
,
650 ospf_area_range_not_advertise_cmd
,
651 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
652 "OSPF area parameters\n"
653 "OSPF area ID in IP address format\n"
654 "OSPF area ID as a decimal value\n"
655 "Summarize routes matching address/mask (border routers only)\n"
656 "Area range prefix\n"
657 "DoNotAdvertise this range\n")
659 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
660 int idx_ipv4_number
= 1;
661 int idx_ipv4_prefixlen
= 3;
662 struct prefix_ipv4 p
;
663 struct in_addr area_id
;
666 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
667 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
669 ospf_area_range_set (ospf
, area_id
, &p
, 0);
674 DEFUN (no_ospf_area_range
,
675 no_ospf_area_range_cmd
,
676 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
678 "OSPF area parameters\n"
679 "OSPF area ID in IP address format\n"
680 "OSPF area ID as a decimal value\n"
681 "Summarize routes matching address/mask (border routers only)\n"
682 "Area range prefix\n"
683 "User specified metric for this range\n"
684 "Advertised metric for this range\n"
685 "Advertise this range (default)\n"
686 "User specified metric for this range\n"
687 "Advertised metric for this range\n"
688 "DoNotAdvertise this range\n")
690 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
691 int idx_ipv4_number
= 2;
692 int idx_ipv4_prefixlen
= 4;
693 struct prefix_ipv4 p
;
694 struct in_addr area_id
;
697 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
698 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
700 ospf_area_range_unset (ospf
, area_id
, &p
);
705 DEFUN (ospf_area_range_substitute
,
706 ospf_area_range_substitute_cmd
,
707 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
708 "OSPF area parameters\n"
709 "OSPF area ID in IP address format\n"
710 "OSPF area ID as a decimal value\n"
711 "Summarize routes matching address/mask (border routers only)\n"
712 "Area range prefix\n"
713 "Announce area range as another prefix\n"
714 "Network prefix to be announced instead of range\n")
716 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
717 int idx_ipv4_number
= 1;
718 int idx_ipv4_prefixlen
= 3;
719 int idx_ipv4_prefixlen_2
= 5;
720 struct prefix_ipv4 p
, s
;
721 struct in_addr area_id
;
724 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
725 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
726 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
728 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
733 DEFUN (no_ospf_area_range_substitute
,
734 no_ospf_area_range_substitute_cmd
,
735 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
737 "OSPF area parameters\n"
738 "OSPF area ID in IP address format\n"
739 "OSPF area ID as a decimal value\n"
740 "Summarize routes matching address/mask (border routers only)\n"
741 "Area range prefix\n"
742 "Announce area range as another prefix\n"
743 "Network prefix to be announced instead of range\n")
745 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
746 int idx_ipv4_number
= 2;
747 int idx_ipv4_prefixlen
= 4;
748 int idx_ipv4_prefixlen_2
= 6;
749 struct prefix_ipv4 p
, s
;
750 struct in_addr area_id
;
753 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
754 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
755 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
757 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
763 /* Command Handler Logic in VLink stuff is delicate!!
765 ALTER AT YOUR OWN RISK!!!!
767 Various dummy values are used to represent 'NoChange' state for
768 VLink configuration NOT being changed by a VLink command, and
769 special syntax is used within the command strings so that the
770 typed in command verbs can be seen in the configuration command
771 bacckend handler. This is to drastically reduce the verbeage
772 required to coe up with a reasonably compatible Cisco VLink command
774 - Matthew Grant <grantma@anathoth.gen.nz>
775 Wed, 21 Feb 2001 15:13:52 +1300
778 /* Configuration data for virtual links
780 struct ospf_vl_config_data
{
781 struct vty
*vty
; /* vty stuff */
782 struct in_addr area_id
; /* area ID from command line */
783 int format
; /* command line area ID format */
784 struct in_addr vl_peer
; /* command line vl_peer */
785 int auth_type
; /* Authehntication type, if given */
786 char *auth_key
; /* simple password if present */
787 int crypto_key_id
; /* Cryptographic key ID */
788 char *md5_key
; /* MD5 authentication key */
789 int hello_interval
; /* Obvious what these are... */
790 int retransmit_interval
;
796 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
799 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
800 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
801 vl_config
->vty
= vty
;
804 static struct ospf_vl_data
*
805 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
807 struct ospf_area
*area
;
808 struct ospf_vl_data
*vl_data
;
810 struct in_addr area_id
;
812 vty
= vl_config
->vty
;
813 area_id
= vl_config
->area_id
;
815 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
818 "Configuring VLs over the backbone is not allowed%s",
822 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
824 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
826 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
827 vty_out (vty
, "Area %s is %s%s",
829 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
832 vty_out (vty
, "Area %ld is %s%s",
833 (u_long
)ntohl (area_id
.s_addr
),
834 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
839 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
841 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
842 if (vl_data
->vl_oi
== NULL
)
844 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
845 ospf_vl_add (ospf
, vl_data
);
846 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
854 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
855 struct ospf_vl_config_data
*vl_config
)
857 struct crypt_key
*ck
;
859 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
861 vty
= vl_config
->vty
;
863 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
865 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
866 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
869 if (vl_config
->auth_key
)
871 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
872 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
873 OSPF_AUTH_SIMPLE_SIZE
);
875 else if (vl_config
->md5_key
)
877 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
880 vty_out (vty
, "OSPF: Key %d already exists%s",
881 vl_config
->crypto_key_id
, VTY_NEWLINE
);
884 ck
= ospf_crypt_key_new ();
885 ck
->key_id
= vl_config
->crypto_key_id
;
886 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
887 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
889 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
891 else if (vl_config
->crypto_key_id
!= 0)
895 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
896 vl_config
->crypto_key_id
) == NULL
)
898 vty_out (vty
, "OSPF: Key %d does not exist%s",
899 vl_config
->crypto_key_id
, VTY_NEWLINE
);
903 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
911 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
912 struct ospf_vl_config_data
*vl_config
)
914 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
915 /* Virtual Link data initialised to defaults, so only set
917 if (vl_config
->hello_interval
)
919 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
920 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
923 if (vl_config
->dead_interval
)
925 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
926 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
929 if (vl_config
->retransmit_interval
)
931 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
932 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
935 if (vl_config
->transmit_delay
)
937 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
938 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
945 /* The business end of all of the above */
947 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
949 struct ospf_vl_data
*vl_data
;
952 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
956 /* Process this one first as it can have a fatal result, which can
957 only logically occur if the virtual link exists already
958 Thus a command error does not result in a change to the
959 running configuration such as unexpectedly altered timer
961 ret
= ospf_vl_set_security (vl_data
, vl_config
);
962 if (ret
!= CMD_SUCCESS
)
965 /* Set any time based parameters, these area already range checked */
967 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
968 if (ret
!= CMD_SUCCESS
)
975 /* This stuff exists to make specifying all the alias commands A LOT simpler
977 #define VLINK_HELPSTR_IPADDR \
978 "OSPF area parameters\n" \
979 "OSPF area ID in IP address format\n" \
980 "OSPF area ID as a decimal value\n" \
981 "Configure a virtual link\n" \
982 "Router ID of the remote ABR\n"
984 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
985 "Enable authentication on this virtual link\n" \
988 #define VLINK_HELPSTR_AUTHTYPE_ALL \
989 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
990 "Use null authentication\n" \
991 "Use message-digest authentication\n"
993 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
994 "Time between HELLO packets\n" \
995 "Time between retransmitting lost link state advertisements\n" \
996 "Link state transmit delay\n" \
997 "Interval time after which a neighbor is declared down\n"
999 #define VLINK_HELPSTR_TIME_PARAM \
1000 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1003 #define VLINK_HELPSTR_AUTH_SIMPLE \
1004 "Authentication password (key)\n" \
1005 "The OSPF password (key)"
1007 #define VLINK_HELPSTR_AUTH_MD5 \
1008 "Message digest authentication password (key)\n" \
1011 "Use MD5 algorithm\n" \
1012 "The OSPF password (key)"
1014 DEFUN (ospf_area_vlink
,
1015 ospf_area_vlink_cmd
,
1016 "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>]",
1017 VLINK_HELPSTR_IPADDR
1018 "Enable authentication on this virtual link\n" \
1019 "Use null authentication\n" \
1020 "Use message-digest authentication\n"
1021 "Message digest authentication password (key)\n" \
1023 "Use MD5 algorithm\n" \
1024 "The OSPF password (key)")
1026 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1027 int idx_ipv4_number
= 1;
1029 struct ospf_vl_config_data vl_config
;
1030 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1031 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1035 ospf_vl_config_data_init(&vl_config
, vty
);
1037 /* Read off first 2 parameters and check them */
1038 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &vl_config
.format
);
1041 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1045 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1048 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1055 /* Thats all folks! - BUGS B. strikes again!!!*/
1057 return ospf_vl_set (ospf
, &vl_config
);
1060 /* Deal with other parameters */
1061 for (i
=5; i
< argc
; i
++)
1064 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1066 switch (argv
[i
]->arg
[0])
1070 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1072 /* authentication-key - this option can occur anywhere on
1073 command line. At start of command line
1074 must check for authentication option. */
1075 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1076 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1077 vl_config
.auth_key
= auth_key
;
1080 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1082 /* authentication - this option can only occur at start
1084 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1087 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1089 /* "authentication null" */
1090 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1093 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1094 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1096 /* "authentication message-digest" */
1097 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1105 /* message-digest-key */
1109 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1110 if (vl_config
.crypto_key_id
< 0)
1115 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1116 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1117 vl_config
.md5_key
= md5_key
;
1121 vl_config
.md5_key
= NULL
;
1127 /* Action configuration */
1129 return ospf_vl_set (ospf
, &vl_config
);
1133 DEFUN (ospf_area_vlink_intervals
,
1134 ospf_area_vlink_intervals_cmd
,
1135 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1136 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1137 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1138 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1139 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1141 VLINK_HELPSTR_IPADDR
1142 VLINK_HELPSTR_TIME_PARAM
1143 VLINK_HELPSTR_TIME_PARAM
1144 VLINK_HELPSTR_TIME_PARAM
1145 VLINK_HELPSTR_TIME_PARAM
)
1147 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1148 struct ospf_vl_config_data vl_config
;
1151 ospf_vl_config_data_init(&vl_config
, vty
);
1153 char *area_id
= argv
[1]->arg
;
1154 char *router_id
= argv
[3]->arg
;
1156 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1159 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1163 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1166 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1169 for (unsigned int i
= 0; i
< 4; i
++)
1172 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1173 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1174 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1175 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1176 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1177 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1178 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1179 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1182 /* Action configuration */
1183 return ospf_vl_set (ospf
, &vl_config
);
1186 DEFUN (no_ospf_area_vlink
,
1187 no_ospf_area_vlink_cmd
,
1188 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
1190 VLINK_HELPSTR_IPADDR
1191 "Enable authentication on this virtual link\n" \
1192 "Use null authentication\n" \
1193 "Use message-digest authentication\n"
1194 "Message digest authentication password (key)\n" \
1196 "Use MD5 algorithm\n" \
1197 "The OSPF password (key)")
1199 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1200 int idx_ipv4_number
= 2;
1202 struct ospf_area
*area
;
1203 struct ospf_vl_config_data vl_config
;
1204 struct ospf_vl_data
*vl_data
= NULL
;
1205 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1209 ospf_vl_config_data_init(&vl_config
, vty
);
1211 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1214 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1218 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1221 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1225 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1228 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1235 /* Basic VLink no command */
1236 /* Thats all folks! - BUGS B. strikes again!!!*/
1237 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1238 ospf_vl_delete (ospf
, vl_data
);
1240 ospf_area_check_free (ospf
, vl_config
.area_id
);
1245 /* If we are down here, we are reseting parameters */
1247 /* Deal with other parameters */
1248 for (i
=6; i
< argc
; i
++)
1250 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1252 switch (argv
[i
]->arg
[0])
1256 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1258 /* authentication-key - this option can occur anywhere on
1259 command line. At start of command line
1260 must check for authentication option. */
1261 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1262 vl_config
.auth_key
= auth_key
;
1264 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1266 /* authentication - this option can only occur at start
1268 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1273 /* message-digest-key */
1274 /* Delete one key */
1278 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1279 if (vl_config
.crypto_key_id
< 0)
1281 vl_config
.md5_key
= NULL
;
1291 /* Action configuration */
1293 return ospf_vl_set (ospf
, &vl_config
);
1296 DEFUN (no_ospf_area_vlink_intervals
,
1297 no_ospf_area_vlink_intervals_cmd
,
1298 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1299 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1300 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1301 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1302 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1305 VLINK_HELPSTR_IPADDR
1306 VLINK_HELPSTR_TIME_PARAM
1307 VLINK_HELPSTR_TIME_PARAM
1308 VLINK_HELPSTR_TIME_PARAM
1309 VLINK_HELPSTR_TIME_PARAM
)
1311 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1312 struct ospf_vl_config_data vl_config
;
1315 ospf_vl_config_data_init(&vl_config
, vty
);
1317 char *area_id
= argv
[2]->arg
;
1318 char *router_id
= argv
[4]->arg
;
1320 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1323 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1327 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1330 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1334 for (unsigned int i
= 0; i
< 4; i
++)
1337 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1338 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1339 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1340 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1341 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1342 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1343 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1344 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1347 /* Action configuration */
1348 return ospf_vl_set (ospf
, &vl_config
);
1351 DEFUN (ospf_area_shortcut
,
1352 ospf_area_shortcut_cmd
,
1353 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1354 "OSPF area parameters\n"
1355 "OSPF area ID in IP address format\n"
1356 "OSPF area ID as a decimal value\n"
1357 "Configure the area's shortcutting mode\n"
1358 "Set default shortcutting behavior\n"
1359 "Enable shortcutting through the area\n"
1360 "Disable shortcutting through the area\n")
1362 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1363 int idx_ipv4_number
= 1;
1364 int idx_enable_disable
= 3;
1365 struct ospf_area
*area
;
1366 struct in_addr area_id
;
1370 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1372 area
= ospf_area_get (ospf
, area_id
, format
);
1374 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1375 mode
= OSPF_SHORTCUT_DEFAULT
;
1376 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1377 mode
= OSPF_SHORTCUT_DISABLE
;
1378 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1379 mode
= OSPF_SHORTCUT_ENABLE
;
1383 ospf_area_shortcut_set (ospf
, area
, mode
);
1385 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1386 vty_out (vty
, "Shortcut area setting will take effect "
1387 "only when the router is configured as Shortcut ABR%s",
1393 DEFUN (no_ospf_area_shortcut
,
1394 no_ospf_area_shortcut_cmd
,
1395 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1397 "OSPF area parameters\n"
1398 "OSPF area ID in IP address format\n"
1399 "OSPF area ID as a decimal value\n"
1400 "Deconfigure the area's shortcutting mode\n"
1401 "Deconfigure enabled shortcutting through the area\n"
1402 "Deconfigure disabled shortcutting through the area\n")
1404 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1405 int idx_ipv4_number
= 2;
1406 struct ospf_area
*area
;
1407 struct in_addr area_id
;
1410 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1412 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1416 ospf_area_shortcut_unset (ospf
, area
);
1422 DEFUN (ospf_area_stub
,
1424 "area <A.B.C.D|(0-4294967295)> stub",
1425 "OSPF area parameters\n"
1426 "OSPF area ID in IP address format\n"
1427 "OSPF area ID as a decimal value\n"
1428 "Configure OSPF area as stub\n")
1430 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1431 int idx_ipv4_number
= 1;
1432 struct in_addr area_id
;
1435 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1437 ret
= ospf_area_stub_set (ospf
, area_id
);
1440 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1445 ospf_area_no_summary_unset (ospf
, area_id
);
1450 DEFUN (ospf_area_stub_no_summary
,
1451 ospf_area_stub_no_summary_cmd
,
1452 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1453 "OSPF stub parameters\n"
1454 "OSPF area ID in IP address format\n"
1455 "OSPF area ID as a decimal value\n"
1456 "Configure OSPF area as stub\n"
1457 "Do not inject inter-area routes into stub\n")
1459 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1460 int idx_ipv4_number
= 1;
1461 struct in_addr area_id
;
1464 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1466 ret
= ospf_area_stub_set (ospf
, area_id
);
1469 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1474 ospf_area_no_summary_set (ospf
, area_id
);
1479 DEFUN (no_ospf_area_stub
,
1480 no_ospf_area_stub_cmd
,
1481 "no area <A.B.C.D|(0-4294967295)> stub",
1483 "OSPF area parameters\n"
1484 "OSPF area ID in IP address format\n"
1485 "OSPF area ID as a decimal value\n"
1486 "Configure OSPF area as stub\n")
1488 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1489 int idx_ipv4_number
= 2;
1490 struct in_addr area_id
;
1493 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1495 ospf_area_stub_unset (ospf
, area_id
);
1496 ospf_area_no_summary_unset (ospf
, area_id
);
1501 DEFUN (no_ospf_area_stub_no_summary
,
1502 no_ospf_area_stub_no_summary_cmd
,
1503 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1505 "OSPF area parameters\n"
1506 "OSPF area ID in IP address format\n"
1507 "OSPF area ID as a decimal value\n"
1508 "Configure OSPF area as stub\n"
1509 "Do not inject inter-area routes into area\n")
1511 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1512 int idx_ipv4_number
= 2;
1513 struct in_addr area_id
;
1516 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1517 ospf_area_no_summary_unset (ospf
, area_id
);
1523 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1526 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1527 struct in_addr area_id
;
1530 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1532 ret
= ospf_area_nssa_set (ospf
, area_id
);
1535 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1542 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1543 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1544 OSPF_NSSA_ROLE_CANDIDATE
);
1545 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1546 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1547 OSPF_NSSA_ROLE_NEVER
);
1548 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1549 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1550 OSPF_NSSA_ROLE_ALWAYS
);
1554 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1555 OSPF_NSSA_ROLE_CANDIDATE
);
1559 ospf_area_no_summary_set (ospf
, area_id
);
1561 ospf_area_no_summary_unset (ospf
, area_id
);
1563 ospf_schedule_abr_task (ospf
);
1568 DEFUN (ospf_area_nssa_translate_no_summary
,
1569 ospf_area_nssa_translate_no_summary_cmd
,
1570 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1571 "OSPF area parameters\n"
1572 "OSPF area ID in IP address format\n"
1573 "OSPF area ID as a decimal value\n"
1574 "Configure OSPF area as nssa\n"
1575 "Configure NSSA-ABR for translate election (default)\n"
1576 "Configure NSSA-ABR to never translate\n"
1577 "Configure NSSA-ABR to always translate\n"
1578 "Do not inject inter-area routes into nssa\n")
1580 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1583 DEFUN (ospf_area_nssa_translate
,
1584 ospf_area_nssa_translate_cmd
,
1585 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1586 "OSPF area parameters\n"
1587 "OSPF area ID in IP address format\n"
1588 "OSPF area ID as a decimal value\n"
1589 "Configure OSPF area as nssa\n"
1590 "Configure NSSA-ABR for translate election (default)\n"
1591 "Configure NSSA-ABR to never translate\n"
1592 "Configure NSSA-ABR to always translate\n")
1594 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1597 DEFUN (ospf_area_nssa
,
1599 "area <A.B.C.D|(0-4294967295)> nssa",
1600 "OSPF area parameters\n"
1601 "OSPF area ID in IP address format\n"
1602 "OSPF area ID as a decimal value\n"
1603 "Configure OSPF area as nssa\n")
1605 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1608 DEFUN (ospf_area_nssa_no_summary
,
1609 ospf_area_nssa_no_summary_cmd
,
1610 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1611 "OSPF area parameters\n"
1612 "OSPF area ID in IP address format\n"
1613 "OSPF area ID as a decimal value\n"
1614 "Configure OSPF area as nssa\n"
1615 "Do not inject inter-area routes into nssa\n")
1617 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1620 DEFUN (no_ospf_area_nssa
,
1621 no_ospf_area_nssa_cmd
,
1622 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1624 "OSPF area parameters\n"
1625 "OSPF area ID in IP address format\n"
1626 "OSPF area ID as a decimal value\n"
1627 "Configure OSPF area as nssa\n"
1628 "Configure NSSA-ABR for translate election (default)\n"
1629 "Configure NSSA-ABR to never translate\n"
1630 "Configure NSSA-ABR to always translate\n"
1631 "Do not inject inter-area routes into nssa\n")
1633 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1634 int idx_ipv4_number
= 2;
1635 struct in_addr area_id
;
1638 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1640 ospf_area_nssa_unset (ospf
, area_id
);
1641 ospf_area_no_summary_unset (ospf
, area_id
);
1643 ospf_schedule_abr_task (ospf
);
1649 DEFUN (ospf_area_default_cost
,
1650 ospf_area_default_cost_cmd
,
1651 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1652 "OSPF area parameters\n"
1653 "OSPF area ID in IP address format\n"
1654 "OSPF area ID as a decimal value\n"
1655 "Set the summary-default cost of a NSSA or stub area\n"
1656 "Stub's advertised default summary cost\n")
1658 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1659 int idx_ipv4_number
= 1;
1661 struct ospf_area
*area
;
1662 struct in_addr area_id
;
1665 struct prefix_ipv4 p
;
1667 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1668 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1670 area
= ospf_area_get (ospf
, area_id
, format
);
1672 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1674 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1678 area
->default_cost
= cost
;
1681 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1683 if (IS_DEBUG_OSPF_EVENT
)
1684 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1685 "announcing 0.0.0.0/0 to area %s",
1686 inet_ntoa (area
->area_id
));
1687 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1692 DEFUN (no_ospf_area_default_cost
,
1693 no_ospf_area_default_cost_cmd
,
1694 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1696 "OSPF area parameters\n"
1697 "OSPF area ID in IP address format\n"
1698 "OSPF area ID as a decimal value\n"
1699 "Set the summary-default cost of a NSSA or stub area\n"
1700 "Stub's advertised default summary cost\n")
1702 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1703 int idx_ipv4_number
= 2;
1705 struct ospf_area
*area
;
1706 struct in_addr area_id
;
1708 struct prefix_ipv4 p
;
1710 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1711 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1713 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1717 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1719 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1723 area
->default_cost
= 1;
1726 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1728 if (IS_DEBUG_OSPF_EVENT
)
1729 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1730 "announcing 0.0.0.0/0 to area %s",
1731 inet_ntoa (area
->area_id
));
1732 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1735 ospf_area_check_free (ospf
, area_id
);
1740 DEFUN (ospf_area_export_list
,
1741 ospf_area_export_list_cmd
,
1742 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1743 "OSPF area parameters\n"
1744 "OSPF area ID in IP address format\n"
1745 "OSPF area ID as a decimal value\n"
1746 "Set the filter for networks announced to other areas\n"
1747 "Name of the access-list\n")
1749 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1750 int idx_ipv4_number
= 1;
1751 struct ospf_area
*area
;
1752 struct in_addr area_id
;
1755 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1757 area
= ospf_area_get (ospf
, area_id
, format
);
1758 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1763 DEFUN (no_ospf_area_export_list
,
1764 no_ospf_area_export_list_cmd
,
1765 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1767 "OSPF area parameters\n"
1768 "OSPF area ID in IP address format\n"
1769 "OSPF area ID as a decimal value\n"
1770 "Unset the filter for networks announced to other areas\n"
1771 "Name of the access-list\n")
1773 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1774 int idx_ipv4_number
= 2;
1775 struct ospf_area
*area
;
1776 struct in_addr area_id
;
1779 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1781 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1785 ospf_area_export_list_unset (ospf
, area
);
1791 DEFUN (ospf_area_import_list
,
1792 ospf_area_import_list_cmd
,
1793 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1794 "OSPF area parameters\n"
1795 "OSPF area ID in IP address format\n"
1796 "OSPF area ID as a decimal value\n"
1797 "Set the filter for networks from other areas announced to the specified one\n"
1798 "Name of the access-list\n")
1800 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1801 int idx_ipv4_number
= 1;
1802 struct ospf_area
*area
;
1803 struct in_addr area_id
;
1806 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1808 area
= ospf_area_get (ospf
, area_id
, format
);
1809 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1814 DEFUN (no_ospf_area_import_list
,
1815 no_ospf_area_import_list_cmd
,
1816 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1818 "OSPF area parameters\n"
1819 "OSPF area ID in IP address format\n"
1820 "OSPF area ID as a decimal value\n"
1821 "Unset the filter for networks announced to other areas\n"
1822 "Name of the access-list\n")
1824 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1825 int idx_ipv4_number
= 2;
1826 struct ospf_area
*area
;
1827 struct in_addr area_id
;
1830 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1832 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1836 ospf_area_import_list_unset (ospf
, area
);
1841 DEFUN (ospf_area_filter_list
,
1842 ospf_area_filter_list_cmd
,
1843 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1844 "OSPF area parameters\n"
1845 "OSPF area ID in IP address format\n"
1846 "OSPF area ID as a decimal value\n"
1847 "Filter networks between OSPF areas\n"
1848 "Filter prefixes between OSPF areas\n"
1849 "Name of an IP prefix-list\n"
1850 "Filter networks sent to this area\n"
1851 "Filter networks sent from this area\n")
1853 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1854 int idx_ipv4_number
= 1;
1857 struct ospf_area
*area
;
1858 struct in_addr area_id
;
1859 struct prefix_list
*plist
;
1862 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1864 area
= ospf_area_get (ospf
, area_id
, format
);
1865 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1866 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1868 PREFIX_LIST_IN (area
) = plist
;
1869 if (PREFIX_NAME_IN (area
))
1870 free (PREFIX_NAME_IN (area
));
1872 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1873 ospf_schedule_abr_task (ospf
);
1877 PREFIX_LIST_OUT (area
) = plist
;
1878 if (PREFIX_NAME_OUT (area
))
1879 free (PREFIX_NAME_OUT (area
));
1881 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1882 ospf_schedule_abr_task (ospf
);
1888 DEFUN (no_ospf_area_filter_list
,
1889 no_ospf_area_filter_list_cmd
,
1890 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1892 "OSPF area parameters\n"
1893 "OSPF area ID in IP address format\n"
1894 "OSPF area ID as a decimal value\n"
1895 "Filter networks between OSPF areas\n"
1896 "Filter prefixes between OSPF areas\n"
1897 "Name of an IP prefix-list\n"
1898 "Filter networks sent to this area\n"
1899 "Filter networks sent from this area\n")
1901 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1902 int idx_ipv4_number
= 2;
1905 struct ospf_area
*area
;
1906 struct in_addr area_id
;
1909 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1911 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1914 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1916 if (PREFIX_NAME_IN (area
))
1917 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1920 PREFIX_LIST_IN (area
) = NULL
;
1921 if (PREFIX_NAME_IN (area
))
1922 free (PREFIX_NAME_IN (area
));
1924 PREFIX_NAME_IN (area
) = NULL
;
1926 ospf_schedule_abr_task (ospf
);
1930 if (PREFIX_NAME_OUT (area
))
1931 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1934 PREFIX_LIST_OUT (area
) = NULL
;
1935 if (PREFIX_NAME_OUT (area
))
1936 free (PREFIX_NAME_OUT (area
));
1938 PREFIX_NAME_OUT (area
) = NULL
;
1940 ospf_schedule_abr_task (ospf
);
1947 DEFUN (ospf_area_authentication_message_digest
,
1948 ospf_area_authentication_message_digest_cmd
,
1949 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1950 "OSPF area parameters\n"
1951 "OSPF area ID in IP address format\n"
1952 "OSPF area ID as a decimal value\n"
1953 "Enable authentication\n"
1954 "Use message-digest authentication\n")
1956 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1957 int idx_ipv4_number
= 1;
1958 struct ospf_area
*area
;
1959 struct in_addr area_id
;
1962 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1964 area
= ospf_area_get (ospf
, area_id
, format
);
1965 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1970 DEFUN (ospf_area_authentication
,
1971 ospf_area_authentication_cmd
,
1972 "area <A.B.C.D|(0-4294967295)> authentication",
1973 "OSPF area parameters\n"
1974 "OSPF area ID in IP address format\n"
1975 "OSPF area ID as a decimal value\n"
1976 "Enable authentication\n")
1978 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1979 int idx_ipv4_number
= 1;
1980 struct ospf_area
*area
;
1981 struct in_addr area_id
;
1984 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1986 area
= ospf_area_get (ospf
, area_id
, format
);
1987 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1992 DEFUN (no_ospf_area_authentication
,
1993 no_ospf_area_authentication_cmd
,
1994 "no area <A.B.C.D|(0-4294967295)> authentication",
1996 "OSPF area parameters\n"
1997 "OSPF area ID in IP address format\n"
1998 "OSPF area ID as a decimal value\n"
1999 "Enable authentication\n")
2001 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2002 int idx_ipv4_number
= 2;
2003 struct ospf_area
*area
;
2004 struct in_addr area_id
;
2007 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2009 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2013 area
->auth_type
= OSPF_AUTH_NULL
;
2015 ospf_area_check_free (ospf
, area_id
);
2021 DEFUN (ospf_abr_type
,
2023 "ospf abr-type <cisco|ibm|shortcut|standard>",
2024 "OSPF specific commands\n"
2025 "Set OSPF ABR type\n"
2026 "Alternative ABR, cisco implementation\n"
2027 "Alternative ABR, IBM implementation\n"
2029 "Standard behavior (RFC2328)\n")
2031 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2033 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2035 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2036 abr_type
= OSPF_ABR_CISCO
;
2037 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2038 abr_type
= OSPF_ABR_IBM
;
2039 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2040 abr_type
= OSPF_ABR_SHORTCUT
;
2041 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2042 abr_type
= OSPF_ABR_STAND
;
2046 /* If ABR type value is changed, schedule ABR task. */
2047 if (ospf
->abr_type
!= abr_type
)
2049 ospf
->abr_type
= abr_type
;
2050 ospf_schedule_abr_task (ospf
);
2056 DEFUN (no_ospf_abr_type
,
2057 no_ospf_abr_type_cmd
,
2058 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2060 "OSPF specific commands\n"
2061 "Set OSPF ABR type\n"
2062 "Alternative ABR, cisco implementation\n"
2063 "Alternative ABR, IBM implementation\n"
2067 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2069 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2071 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2072 abr_type
= OSPF_ABR_CISCO
;
2073 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2074 abr_type
= OSPF_ABR_IBM
;
2075 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2076 abr_type
= OSPF_ABR_SHORTCUT
;
2077 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2078 abr_type
= OSPF_ABR_STAND
;
2082 /* If ABR type value is changed, schedule ABR task. */
2083 if (ospf
->abr_type
== abr_type
)
2085 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2086 ospf_schedule_abr_task (ospf
);
2092 DEFUN (ospf_log_adjacency_changes
,
2093 ospf_log_adjacency_changes_cmd
,
2094 "log-adjacency-changes",
2095 "Log changes in adjacency state\n")
2097 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2099 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2100 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2104 DEFUN (ospf_log_adjacency_changes_detail
,
2105 ospf_log_adjacency_changes_detail_cmd
,
2106 "log-adjacency-changes detail",
2107 "Log changes in adjacency state\n"
2108 "Log all state changes\n")
2110 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2112 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2113 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2117 DEFUN (no_ospf_log_adjacency_changes
,
2118 no_ospf_log_adjacency_changes_cmd
,
2119 "no log-adjacency-changes",
2121 "Log changes in adjacency state\n")
2123 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2125 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2126 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2130 DEFUN (no_ospf_log_adjacency_changes_detail
,
2131 no_ospf_log_adjacency_changes_detail_cmd
,
2132 "no log-adjacency-changes detail",
2134 "Log changes in adjacency state\n"
2135 "Log all state changes\n")
2137 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2139 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
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
)
2812 struct timeval result
;
2813 unsigned long time_store
= 0;
2814 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
2815 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2816 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2821 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2823 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2824 vty_out (vty
, " Administratively activated (indefinitely)%s",
2826 if (area
->t_stub_router
)
2827 vty_out (vty
, " Active from startup, %s remaining%s",
2828 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2829 sizeof(timebuf
)), VTY_NEWLINE
);
2835 /* Show number of fully adjacent neighbors. */
2836 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2838 /* Show authentication type. */
2839 if (area
->auth_type
== OSPF_AUTH_NULL
)
2840 json_object_string_add(json_area
, "authentication", "authenticationNone");
2841 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2842 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2843 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2844 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2846 if (!OSPF_IS_AREA_BACKBONE (area
))
2847 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2849 /* Show SPF calculation times. */
2850 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2851 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2852 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2853 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2854 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2855 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2856 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2857 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2858 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2859 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2860 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2861 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2865 /* Show number of fully adjacent neighbors. */
2866 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2867 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2869 /* Show authentication type. */
2870 vty_out (vty
, " Area has ");
2871 if (area
->auth_type
== OSPF_AUTH_NULL
)
2872 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2873 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2874 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2875 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2876 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2878 if (!OSPF_IS_AREA_BACKBONE (area
))
2879 vty_out (vty
, " Number of full virtual adjacencies going through"
2880 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2882 /* Show SPF calculation times. */
2883 vty_out (vty
, " SPF algorithm executed %d times%s",
2884 area
->spf_calculation
, VTY_NEWLINE
);
2886 /* Show number of LSA. */
2887 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2888 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2889 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2890 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2891 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2892 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2893 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2894 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2895 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2896 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2897 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2898 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2899 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2900 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2901 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2902 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2907 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2908 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2909 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2910 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2914 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2915 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2916 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2917 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2918 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2919 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2923 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2925 vty_out (vty
, "%s", VTY_NEWLINE
);
2929 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2931 struct listnode
*node
, *nnode
;
2932 struct ospf_area
* area
;
2933 struct timeval result
;
2934 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2935 json_object
*json
= NULL
;
2936 json_object
*json_areas
= NULL
;
2940 json
= json_object_new_object();
2941 json_areas
= json_object_new_object();
2948 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2952 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2953 VTY_NEWLINE
, VTY_NEWLINE
);
2957 /* Show Router ID. */
2960 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2964 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2965 inet_ntoa (ospf
->router_id
),
2969 /* Graceful shutdown */
2970 if (ospf
->t_deferred_shutdown
)
2974 unsigned long time_store
= 0;
2975 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
2976 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2977 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2981 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2982 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2983 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2987 /* Show capability. */
2990 json_object_boolean_true_add(json
, "tosRoutesOnly");
2991 json_object_boolean_true_add(json
, "rfc2328Conform");
2992 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2994 json_object_boolean_true_add(json
, "rfc1583Compatibility");
2999 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3000 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3001 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3002 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3003 "enabled" : "disabled", VTY_NEWLINE
);
3008 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3010 json_object_boolean_true_add(json
, "opaqueCapable");
3015 vty_out (vty
, " OpaqueCapability flag is %s%s",
3016 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3020 /* Show stub-router configuration */
3021 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3022 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3026 json_object_boolean_true_add(json
, "stubAdvertisement");
3027 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3028 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3029 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3030 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3034 vty_out (vty
, " Stub router advertisement is configured%s",
3036 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3037 vty_out (vty
, " Enabled for %us after start-up%s",
3038 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3039 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3040 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3041 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3045 /* Show SPF timers. */
3048 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3049 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3050 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3051 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3055 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3056 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3057 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3058 " Hold time multiplier is currently %d%s",
3059 ospf
->spf_delay
, VTY_NEWLINE
,
3060 ospf
->spf_holdtime
, VTY_NEWLINE
,
3061 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3062 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3067 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3069 unsigned long time_store
= 0;
3071 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3072 result
= tv_sub (result
, recent_relative_time());
3073 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3074 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3076 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3077 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3080 json_object_boolean_true_add(json
, "spfHasNotRun");
3084 vty_out (vty
, " SPF algorithm ");
3085 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3087 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3088 vty_out (vty
, "last executed %s ago%s",
3089 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3091 vty_out (vty
, " Last SPF duration %s%s",
3092 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3096 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3101 struct timeval temp_time
;
3102 unsigned long time_store
= 0;
3104 if (ospf
->t_spf_calc
)
3106 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3107 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3108 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3111 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3112 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3113 /* Show write multiplier values */
3114 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3115 /* Show refresh parameters. */
3116 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3120 vty_out (vty
, " SPF timer %s%s%s",
3121 (ospf
->t_spf_calc
? "due in " : "is "),
3122 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3125 vty_out (vty
, " LSA minimum interval %d msecs%s",
3126 ospf
->min_ls_interval
, VTY_NEWLINE
);
3127 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3128 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3130 /* Show write multiplier values */
3131 vty_out (vty
, " Write Multiplier set to %d %s",
3132 ospf
->write_oi_count
, VTY_NEWLINE
);
3134 /* Show refresh parameters. */
3135 vty_out (vty
, " Refresh timer %d secs%s",
3136 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3139 /* Show ABR/ASBR flags. */
3140 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3143 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3145 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3146 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3148 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3151 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3153 vty_out (vty
, " This router is an ASBR "
3154 "(injecting external routing information)%s", VTY_NEWLINE
);
3157 /* Show Number of AS-external-LSAs. */
3160 json_object_int_add(json
, "lsaExternalCounter",
3161 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3162 json_object_int_add(json
, "lsaExternalChecksum",
3163 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3167 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3168 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3169 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3174 json_object_int_add(json
, "lsaAsopaqueCounter",
3175 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3176 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3177 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3181 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3182 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3183 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3186 /* Show number of areas attached. */
3188 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3190 vty_out (vty
, " Number of areas attached to this router: %d%s",
3191 listcount (ospf
->areas
), VTY_NEWLINE
);
3193 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3195 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3198 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3200 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3205 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3207 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3210 /* Show each area status. */
3211 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3212 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3216 json_object_object_add(json
, "areas", json_areas
);
3217 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3218 json_object_free(json
);
3221 vty_out (vty
, "%s",VTY_NEWLINE
);
3226 DEFUN (show_ip_ospf
,
3228 "show ip ospf [json]",
3231 "OSPF information\n"
3235 u_char uj
= use_json(argc
, argv
);
3237 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3240 return (show_ip_ospf_common(vty
, ospf
, uj
));
3243 DEFUN (show_ip_ospf_instance
,
3244 show_ip_ospf_instance_cmd
,
3245 "show ip ospf (1-65535) [json]",
3248 "OSPF information\n"
3254 u_short instance
= 0;
3255 u_char uj
= use_json(argc
, argv
);
3257 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3258 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3261 return (show_ip_ospf_common(vty
, ospf
, uj
));
3265 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3266 json_object
*json_interface_sub
, u_char use_json
)
3269 struct ospf_neighbor
*nbr
;
3270 struct route_node
*rn
;
3272 /* Is interface up? */
3275 is_up
= if_is_operative(ifp
);
3277 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3279 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3281 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3282 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3283 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3284 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3288 vty_out (vty
, "%s is %s%s", ifp
->name
,
3289 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3290 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3291 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3295 /* Is interface OSPF enabled? */
3298 if (ospf_oi_count(ifp
) == 0)
3300 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3305 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3309 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3313 if (ospf_oi_count(ifp
) == 0)
3315 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3320 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3326 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3328 struct ospf_interface
*oi
= rn
->info
;
3333 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3336 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3338 vty_out (vty
, " This interface is UNNUMBERED,");
3342 /* Show OSPF interface information. */
3345 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3346 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3349 vty_out (vty
, " Internet Address %s/%d,",
3350 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3352 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3354 struct in_addr
*dest
;
3357 if (CONNECTED_PEER(oi
->connected
)
3358 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3363 /* For Vlinks, showing the peer address is probably more
3364 * * * * * informative than the local interface that is being used
3366 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3367 dest
= &oi
->vl_data
->peer_addr
;
3369 dest
= &oi
->connected
->destination
->u
.prefix4
;
3373 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3374 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3375 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3377 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3380 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3385 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3386 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3387 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3388 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3389 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3390 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3391 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3392 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3393 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3397 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3400 vty_out (vty
, " MTU mismatch detection:%s%s",
3401 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3403 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3404 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3405 oi
->output_cost
, VTY_NEWLINE
);
3407 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3408 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3409 PRIORITY (oi
), VTY_NEWLINE
);
3412 /* Show DR information. */
3413 if (DR (oi
).s_addr
== 0)
3416 vty_out (vty
, " No backup designated router on this network%s",
3421 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3425 vty_out (vty
, " No backup designated router on this network%s",
3432 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3433 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3437 vty_out (vty
, " Backup Designated Router (ID) %s,",
3438 inet_ntoa (nbr
->router_id
));
3439 vty_out (vty
, " Interface Address %s%s",
3440 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3445 /* Next network-LSA sequence number we'll use, if we're elected DR */
3446 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3449 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3451 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3452 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3457 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3458 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3460 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3461 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3462 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3463 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3468 vty_out (vty
, " Multicast group memberships:");
3469 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3470 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3472 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3473 vty_out (vty
, " OSPFAllRouters");
3474 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3475 vty_out (vty
, " OSPFDesignatedRouters");
3478 vty_out (vty
, " <None>");
3479 vty_out (vty
, "%s", VTY_NEWLINE
);
3484 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3485 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3487 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3488 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3489 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3490 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3494 vty_out (vty
, " Timer intervals configured,");
3495 vty_out (vty
, " Hello ");
3496 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3497 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3499 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3500 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3501 OSPF_IF_PARAM (oi
, v_wait
),
3502 OSPF_IF_PARAM (oi
, v_wait
),
3503 OSPF_IF_PARAM (oi
, retransmit_interval
),
3507 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3509 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3512 struct timeval result
;
3513 unsigned long time_store
= 0;
3515 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3521 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3522 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3525 vty_out (vty
, " Hello due in %s%s",
3526 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3529 else /* passive-interface is set */
3532 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3534 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3539 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3540 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3543 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3544 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3546 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3551 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3552 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3554 struct interface
*ifp
;
3555 struct listnode
*node
;
3556 json_object
*json
= NULL
;
3557 json_object
*json_interface_sub
= NULL
;
3561 json
= json_object_new_object();
3562 json_interface_sub
= json_object_new_object();
3568 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3570 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3571 VTY_NEWLINE
, VTY_NEWLINE
);
3574 if (argc
== (iface_argv
+ 1))
3576 /* Show All Interfaces.*/
3577 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3579 if (ospf_oi_count(ifp
))
3581 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3583 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3587 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3591 json
= json_object_new_object();
3592 json_interface_sub
= json_object_new_object ();
3595 /* Show All Interfaces. */
3596 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3598 if (ospf_oi_count(ifp
))
3600 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3602 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3608 /* Interface name is specified. */
3609 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3612 json_object_boolean_true_add(json
, "noSuchIface");
3614 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3618 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3620 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3626 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3627 json_object_free(json
);
3630 vty_out (vty
, "%s", VTY_NEWLINE
);
3635 DEFUN (show_ip_ospf_interface
,
3636 show_ip_ospf_interface_cmd
,
3637 "show ip ospf interface [INTERFACE] [json]",
3640 "OSPF information\n"
3641 "Interface information\n"
3646 u_char uj
= use_json(argc
, argv
);
3648 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3651 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3654 DEFUN (show_ip_ospf_instance_interface
,
3655 show_ip_ospf_instance_interface_cmd
,
3656 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3659 "OSPF information\n"
3661 "Interface information\n"
3667 u_short instance
= 0;
3668 u_char uj
= use_json(argc
, argv
);
3670 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3671 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3674 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3678 show_ip_ospf_neighbour_header (struct vty
*vty
)
3680 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3682 "Neighbor ID", "Pri", "State", "Dead Time",
3683 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3688 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3690 struct route_node
*rn
;
3691 struct ospf_neighbor
*nbr
;
3693 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3694 json_object
*json_neighbor
= NULL
;
3696 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3698 if ((nbr
= rn
->info
))
3700 /* Do not show myself. */
3701 if (nbr
!= oi
->nbr_self
)
3703 /* Down state is not shown. */
3704 if (nbr
->state
!= NSM_Down
)
3708 json_neighbor
= json_object_new_object();
3709 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3711 struct timeval result
;
3712 unsigned long time_store
= 0;
3714 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3715 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3717 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3718 json_object_string_add (json_neighbor
, "state", msgbuf
);
3719 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3720 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3721 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3722 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3723 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3724 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3725 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3726 json_object_object_add(json
, "neighbor", json_neighbor
);
3728 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3732 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3734 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3735 vty_out (vty
, "%-15s %3d %-15s ",
3739 vty_out (vty
, "%-15s %3d %-15s ",
3740 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3743 vty_out (vty
, "%9s ",
3744 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3746 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3747 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3748 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3749 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3759 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3761 struct ospf_interface
*oi
;
3762 struct listnode
*node
;
3763 json_object
*json
= NULL
;
3766 json
= json_object_new_object();
3768 show_ip_ospf_neighbour_header (vty
);
3773 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3775 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3776 VTY_NEWLINE
, VTY_NEWLINE
);
3779 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3780 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3784 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3785 json_object_free(json
);
3788 vty_out (vty
, "%s", VTY_NEWLINE
);
3793 DEFUN (show_ip_ospf_neighbor
,
3794 show_ip_ospf_neighbor_cmd
,
3795 "show ip ospf neighbor [json]",
3798 "OSPF information\n"
3803 u_char uj
= use_json(argc
, argv
);
3805 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3808 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3812 DEFUN (show_ip_ospf_instance_neighbor
,
3813 show_ip_ospf_instance_neighbor_cmd
,
3814 "show ip ospf (1-65535) neighbor [json]",
3817 "OSPF information\n"
3824 u_short instance
= 0;
3825 u_char uj
= use_json(argc
, argv
);
3827 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3828 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3831 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3835 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3837 struct listnode
*node
;
3838 struct ospf_interface
*oi
;
3839 json_object
*json
= NULL
;
3840 json_object
*json_neighbor_sub
= NULL
;
3844 json
= json_object_new_object();
3845 json_neighbor_sub
= json_object_new_object();
3848 show_ip_ospf_neighbour_header (vty
);
3853 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3855 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3856 VTY_NEWLINE
, VTY_NEWLINE
);
3859 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3861 struct listnode
*nbr_node
;
3862 struct ospf_nbr_nbma
*nbr_nbma
;
3864 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3866 /* print Down neighbor status */
3867 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3869 if (nbr_nbma
->nbr
== NULL
3870 || nbr_nbma
->nbr
->state
== NSM_Down
)
3874 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3875 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3876 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3877 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3878 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3879 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3880 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3884 vty_out (vty
, "%-15s %3d %-15s %9s ",
3885 "-", nbr_nbma
->priority
, "Down", "-");
3886 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3887 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3888 0, 0, 0, VTY_NEWLINE
);
3896 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3897 json_object_free(json
);
3900 vty_out (vty
, "%s", VTY_NEWLINE
);
3905 DEFUN (show_ip_ospf_neighbor_all
,
3906 show_ip_ospf_neighbor_all_cmd
,
3907 "show ip ospf neighbor all [json]",
3910 "OSPF information\n"
3912 "include down status neighbor\n"
3916 u_char uj
= use_json(argc
, argv
);
3918 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3921 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3924 DEFUN (show_ip_ospf_instance_neighbor_all
,
3925 show_ip_ospf_instance_neighbor_all_cmd
,
3926 "show ip ospf (1-65535) neighbor all [json]",
3929 "OSPF information\n"
3932 "include down status neighbor\n"
3937 u_short instance
= 0;
3938 u_char uj
= use_json(argc
, argv
);
3940 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3941 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3944 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3948 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3949 struct cmd_token
**argv
, u_char use_json
)
3951 struct interface
*ifp
;
3952 struct route_node
*rn
;
3953 json_object
*json
= NULL
;
3956 json
= json_object_new_object();
3958 show_ip_ospf_neighbour_header (vty
);
3963 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3965 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3966 VTY_NEWLINE
, VTY_NEWLINE
);
3969 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
3973 json_object_boolean_true_add(json
, "noSuchIface");
3975 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3979 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3981 struct ospf_interface
*oi
= rn
->info
;
3986 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3991 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3992 json_object_free(json
);
3995 vty_out (vty
, "%s", VTY_NEWLINE
);
4000 DEFUN (show_ip_ospf_neighbor_int
,
4001 show_ip_ospf_neighbor_int_cmd
,
4002 "show ip ospf neighbor IFNAME [json]",
4005 "OSPF information\n"
4011 u_char uj
= use_json(argc
, argv
);
4013 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4016 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4019 DEFUN (show_ip_ospf_instance_neighbor_int
,
4020 show_ip_ospf_instance_neighbor_int_cmd
,
4021 "show ip ospf (1-65535) neighbor IFNAME [json]",
4024 "OSPF information\n"
4032 u_short instance
= 0;
4033 u_char uj
= use_json(argc
, argv
);
4035 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4036 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4039 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4043 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4044 u_char use_json
, json_object
*json
)
4046 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4047 json_object
*json_sub
= NULL
;
4050 json_sub
= json_object_new_object();
4051 else /* Show neighbor ID. */
4052 vty_out (vty
, " Neighbor %s,", "-");
4054 /* Show interface address. */
4056 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4058 vty_out (vty
, " interface address %s%s",
4059 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4064 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4065 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4068 vty_out (vty
, " In the area %s via interface %s%s",
4069 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4071 /* Show neighbor priority and state. */
4074 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4075 json_object_string_add(json_sub
, "nbrState", "down");
4078 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4079 nbr_nbma
->priority
, "Down");
4081 /* Show state changes. */
4083 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4085 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4087 /* Show PollInterval */
4089 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4091 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4093 /* Show poll-interval timer. */
4096 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4097 unsigned long time_store
= 0;
4098 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4099 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4102 vty_out (vty
, " Poll timer due in %s%s",
4103 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4106 /* Show poll-interval timer thread. */
4109 if (nbr_nbma
->t_poll
!= NULL
)
4110 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4113 vty_out (vty
, " Thread Poll Timer %s%s",
4114 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4117 json_object_object_add(json
, "noNbrId", json_sub
);
4121 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4122 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4124 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4125 json_object
*json_sub
= NULL
;
4128 json_sub
= json_object_new_object();
4131 /* Show neighbor ID. */
4132 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4133 vty_out (vty
, " Neighbor %s,", "-");
4135 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4138 /* Show interface address. */
4140 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4142 vty_out (vty
, " interface address %s%s",
4143 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4148 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4149 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4152 vty_out (vty
, " In the area %s via interface %s%s",
4153 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4155 /* Show neighbor priority and state. */
4158 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4159 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4162 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4163 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4165 /* Show state changes. */
4167 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4169 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4171 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4173 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4176 unsigned long time_store
= 0;
4177 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4178 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4182 vty_out (vty
, " Most recent state change statistics:%s",
4184 vty_out (vty
, " Progressive change %s ago%s",
4185 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4190 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4192 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4195 unsigned long time_store
= 0;
4196 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4197 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4198 if (nbr
->last_regress_str
)
4199 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4203 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4204 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4205 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4210 /* Show Designated Rotuer ID. */
4212 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4214 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4216 /* Show Backup Designated Rotuer ID. */
4218 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4220 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4225 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4226 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4229 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4230 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4232 /* Show Router Dead interval timer. */
4235 if (nbr
->t_inactivity
)
4237 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4238 unsigned long time_store
= 0;
4239 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4240 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4243 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4246 vty_out (vty
, " Dead timer due in %s%s",
4247 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4250 /* Show Database Summary list. */
4252 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4254 vty_out (vty
, " Database Summary List %d%s",
4255 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4257 /* Show Link State Request list. */
4259 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4261 vty_out (vty
, " Link State Request List %ld%s",
4262 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4264 /* Show Link State Retransmission list. */
4266 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4268 vty_out (vty
, " Link State Retransmission List %ld%s",
4269 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4271 /* Show inactivity timer thread. */
4274 if (nbr
->t_inactivity
!= NULL
)
4275 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4278 vty_out (vty
, " Thread Inactivity Timer %s%s",
4279 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4281 /* Show Database Description retransmission thread. */
4284 if (nbr
->t_db_desc
!= NULL
)
4285 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4288 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4289 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4291 /* Show Link State Request Retransmission thread. */
4294 if (nbr
->t_ls_req
!= NULL
)
4295 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4298 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4299 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4301 /* Show Link State Update Retransmission thread. */
4304 if (nbr
->t_ls_upd
!= NULL
)
4305 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4308 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4309 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4313 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4314 json_object_object_add(json
, "noNbrId", json_sub
);
4316 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4319 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4323 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4324 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4326 struct listnode
*node
;
4327 struct ospf_neighbor
*nbr
;
4328 struct ospf_interface
*oi
;
4329 struct in_addr router_id
;
4331 json_object
*json
= NULL
;
4334 json
= json_object_new_object();
4339 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4341 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4342 VTY_NEWLINE
, VTY_NEWLINE
);
4345 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4349 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4353 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4355 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4357 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4363 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4364 json_object_free(json
);
4367 vty_out (vty
, "%s", VTY_NEWLINE
);
4372 DEFUN (show_ip_ospf_neighbor_id
,
4373 show_ip_ospf_neighbor_id_cmd
,
4374 "show ip ospf neighbor A.B.C.D [json]",
4377 "OSPF information\n"
4383 u_char uj
= use_json(argc
, argv
);
4385 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4388 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4391 DEFUN (show_ip_ospf_instance_neighbor_id
,
4392 show_ip_ospf_instance_neighbor_id_cmd
,
4393 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4396 "OSPF information\n"
4404 u_short instance
= 0;
4405 u_char uj
= use_json(argc
, argv
);
4407 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4408 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4411 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4415 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4417 struct ospf_interface
*oi
;
4418 struct listnode
*node
;
4419 json_object
*json
= NULL
;
4422 json
= json_object_new_object();
4427 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4429 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4430 VTY_NEWLINE
, VTY_NEWLINE
);
4433 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4435 struct route_node
*rn
;
4436 struct ospf_neighbor
*nbr
;
4438 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4440 if ((nbr
= rn
->info
))
4442 if (nbr
!= oi
->nbr_self
)
4444 if (nbr
->state
!= NSM_Down
)
4446 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4455 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4456 json_object_free(json
);
4459 vty_out (vty
, "%s", VTY_NEWLINE
);
4464 DEFUN (show_ip_ospf_neighbor_detail
,
4465 show_ip_ospf_neighbor_detail_cmd
,
4466 "show ip ospf neighbor detail [json]",
4469 "OSPF information\n"
4471 "detail of all neighbors\n"
4475 u_char uj
= use_json(argc
, argv
);
4477 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4480 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4483 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4484 show_ip_ospf_instance_neighbor_detail_cmd
,
4485 "show ip ospf (1-65535) neighbor detail [json]",
4488 "OSPF information\n"
4491 "detail of all neighbors\n"
4496 u_short instance
= 0;
4497 u_char uj
= use_json(argc
, argv
);
4499 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4500 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4503 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4507 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4509 struct listnode
*node
;
4510 struct ospf_interface
*oi
;
4511 json_object
*json
= NULL
;
4514 json
= json_object_new_object();
4519 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4521 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4522 VTY_NEWLINE
, VTY_NEWLINE
);
4525 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4527 struct route_node
*rn
;
4528 struct ospf_neighbor
*nbr
;
4529 struct ospf_nbr_nbma
*nbr_nbma
;
4531 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4532 if ((nbr
= rn
->info
))
4533 if (nbr
!= oi
->nbr_self
)
4534 if (nbr
->state
!= NSM_Down
)
4535 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4537 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4539 struct listnode
*nd
;
4541 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4543 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4544 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4551 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4552 json_object_free(json
);
4556 vty_out (vty
, "%s", VTY_NEWLINE
);
4562 DEFUN (show_ip_ospf_neighbor_detail_all
,
4563 show_ip_ospf_neighbor_detail_all_cmd
,
4564 "show ip ospf neighbor detail all [json]",
4567 "OSPF information\n"
4569 "detail of all neighbors\n"
4570 "include down status neighbor\n"
4574 u_char uj
= use_json(argc
, argv
);
4576 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4579 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4582 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4583 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4584 "show ip ospf (1-65535) neighbor detail all [json]",
4587 "OSPF information\n"
4590 "detail of all neighbors\n"
4591 "include down status neighbor\n"
4596 u_short instance
= 0;
4597 u_char uj
= use_json(argc
, argv
);
4599 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4600 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4603 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4607 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4608 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4610 struct ospf_interface
*oi
;
4611 struct interface
*ifp
;
4612 struct route_node
*rn
, *nrn
;
4613 struct ospf_neighbor
*nbr
;
4614 json_object
*json
= NULL
;
4617 json
= json_object_new_object();
4622 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4624 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4625 VTY_NEWLINE
, VTY_NEWLINE
);
4628 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4632 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4636 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4638 if ((oi
= rn
->info
))
4640 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4642 if ((nbr
= nrn
->info
))
4644 if (nbr
!= oi
->nbr_self
)
4646 if (nbr
->state
!= NSM_Down
)
4647 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4656 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4657 json_object_free(json
);
4660 vty_out (vty
, "%s", VTY_NEWLINE
);
4665 DEFUN (show_ip_ospf_neighbor_int_detail
,
4666 show_ip_ospf_neighbor_int_detail_cmd
,
4667 "show ip ospf neighbor IFNAME detail [json]",
4670 "OSPF information\n"
4673 "detail of all neighbors\n"
4677 u_char uj
= use_json(argc
, argv
);
4679 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4682 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4685 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4686 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4687 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4690 "OSPF information\n"
4694 "detail of all neighbors\n"
4699 u_short instance
= 0;
4700 u_char uj
= use_json(argc
, argv
);
4702 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4703 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4706 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4709 /* Show functions */
4711 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4713 struct router_lsa
*rl
;
4714 struct summary_lsa
*sl
;
4715 struct as_external_lsa
*asel
;
4716 struct prefix_ipv4 p
;
4719 /* If self option is set, check LSA self flag. */
4720 if (self
== 0 || IS_LSA_SELF (lsa
))
4722 /* LSA common part show. */
4723 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4724 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4725 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4726 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4727 /* LSA specific part show. */
4728 switch (lsa
->data
->type
)
4730 case OSPF_ROUTER_LSA
:
4731 rl
= (struct router_lsa
*) lsa
->data
;
4732 vty_out (vty
, " %-d", ntohs (rl
->links
));
4734 case OSPF_SUMMARY_LSA
:
4735 sl
= (struct summary_lsa
*) lsa
->data
;
4738 p
.prefix
= sl
->header
.id
;
4739 p
.prefixlen
= ip_masklen (sl
->mask
);
4740 apply_mask_ipv4 (&p
);
4742 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4744 case OSPF_AS_EXTERNAL_LSA
:
4745 case OSPF_AS_NSSA_LSA
:
4746 asel
= (struct as_external_lsa
*) lsa
->data
;
4749 p
.prefix
= asel
->header
.id
;
4750 p
.prefixlen
= ip_masklen (asel
->mask
);
4751 apply_mask_ipv4 (&p
);
4753 vty_out (vty
, " %s %s/%d [0x%lx]",
4754 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4755 inet_ntoa (p
.prefix
), p
.prefixlen
,
4756 (u_long
)ntohl (asel
->e
[0].route_tag
));
4758 case OSPF_NETWORK_LSA
:
4759 case OSPF_ASBR_SUMMARY_LSA
:
4760 case OSPF_OPAQUE_LINK_LSA
:
4761 case OSPF_OPAQUE_AREA_LSA
:
4762 case OSPF_OPAQUE_AS_LSA
:
4766 vty_out (vty
, VTY_NEWLINE
);
4772 static const char *show_database_desc
[] =
4775 "Router Link States",
4777 "Summary Link States",
4778 "ASBR-Summary Link States",
4779 "AS External Link States",
4780 "Group Membership LSA",
4781 "NSSA-external Link States",
4783 "Link-Local Opaque-LSA",
4784 "Area-Local Opaque-LSA",
4785 "AS-external Opaque-LSA",
4788 static const char *show_database_header
[] =
4791 "Link ID ADV Router Age Seq# CkSum Link count",
4792 "Link ID ADV Router Age Seq# CkSum",
4793 "Link ID ADV Router Age Seq# CkSum Route",
4794 "Link ID ADV Router Age Seq# CkSum",
4795 "Link ID ADV Router Age Seq# CkSum Route",
4796 " --- header for Group Member ----",
4797 "Link ID ADV Router Age Seq# CkSum Route",
4799 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4800 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4801 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4805 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4807 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4809 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4810 vty_out (vty
, " Options: 0x%-2x : %s%s",
4812 ospf_options_dump(lsa
->data
->options
),
4814 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4816 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4819 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4821 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4824 vty_out (vty
, " :%s%s%s%s",
4825 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4826 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4827 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4828 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4830 vty_out (vty
, "%s", VTY_NEWLINE
);
4832 vty_out (vty
, " LS Type: %s%s",
4833 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4834 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4835 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4836 vty_out (vty
, " Advertising Router: %s%s",
4837 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4838 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4840 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4842 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4845 const char *link_type_desc
[] =
4848 "another Router (point-to-point)",
4849 "a Transit Network",
4854 const char *link_id_desc
[] =
4857 "Neighboring Router ID",
4858 "Designated Router address",
4860 "Neighboring Router ID",
4863 const char *link_data_desc
[] =
4866 "Router Interface address",
4867 "Router Interface address",
4869 "Router Interface address",
4872 /* Show router-LSA each Link information. */
4874 show_ip_ospf_database_router_links (struct vty
*vty
,
4875 struct router_lsa
*rl
)
4880 len
= ntohs (rl
->header
.length
) - 4;
4881 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4883 type
= rl
->link
[i
].type
;
4885 vty_out (vty
, " Link connected to: %s%s",
4886 link_type_desc
[type
], VTY_NEWLINE
);
4887 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4888 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4889 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4890 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4891 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4892 vty_out (vty
, " TOS 0 Metric: %d%s",
4893 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4894 vty_out (vty
, "%s", VTY_NEWLINE
);
4898 /* Show router-LSA detail information. */
4900 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4904 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4906 show_ip_ospf_database_header (vty
, lsa
);
4908 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4909 VTY_NEWLINE
, VTY_NEWLINE
);
4911 show_ip_ospf_database_router_links (vty
, rl
);
4912 vty_out (vty
, "%s", VTY_NEWLINE
);
4918 /* Show network-LSA detail information. */
4920 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4926 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4928 show_ip_ospf_database_header (vty
, lsa
);
4930 vty_out (vty
, " Network Mask: /%d%s",
4931 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4933 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4935 for (i
= 0; length
> 0; i
++, length
-= 4)
4936 vty_out (vty
, " Attached Router: %s%s",
4937 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4939 vty_out (vty
, "%s", VTY_NEWLINE
);
4945 /* Show summary-LSA detail information. */
4947 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4951 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4953 show_ip_ospf_database_header (vty
, lsa
);
4955 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4957 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4959 vty_out (vty
, "%s", VTY_NEWLINE
);
4965 /* Show summary-ASBR-LSA detail information. */
4967 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4971 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4973 show_ip_ospf_database_header (vty
, lsa
);
4975 vty_out (vty
, " Network Mask: /%d%s",
4976 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4977 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4979 vty_out (vty
, "%s", VTY_NEWLINE
);
4985 /* Show AS-external-LSA detail information. */
4987 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4991 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4993 show_ip_ospf_database_header (vty
, lsa
);
4995 vty_out (vty
, " Network Mask: /%d%s",
4996 ip_masklen (al
->mask
), VTY_NEWLINE
);
4997 vty_out (vty
, " Metric Type: %s%s",
4998 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4999 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5000 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5001 vty_out (vty
, " Metric: %d%s",
5002 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5003 vty_out (vty
, " Forward Address: %s%s",
5004 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5006 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5007 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5014 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5016 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5018 /* show_ip_ospf_database_header (vty, lsa); */
5020 zlog_debug( " Network Mask: /%d%s",
5021 ip_masklen (al
->mask
), "\n");
5022 zlog_debug( " Metric Type: %s%s",
5023 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5024 "2 (Larger than any link state path)" : "1", "\n");
5025 zlog_debug( " TOS: 0%s", "\n");
5026 zlog_debug( " Metric: %d%s",
5027 GET_METRIC (al
->e
[0].metric
), "\n");
5028 zlog_debug( " Forward Address: %s%s",
5029 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5031 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5032 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5037 /* Show AS-NSSA-LSA detail information. */
5039 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5043 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5045 show_ip_ospf_database_header (vty
, lsa
);
5047 vty_out (vty
, " Network Mask: /%d%s",
5048 ip_masklen (al
->mask
), VTY_NEWLINE
);
5049 vty_out (vty
, " Metric Type: %s%s",
5050 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5051 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5052 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5053 vty_out (vty
, " Metric: %d%s",
5054 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5055 vty_out (vty
, " NSSA: Forward Address: %s%s",
5056 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5058 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5059 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5066 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5072 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5076 show_ip_ospf_database_header (vty
, lsa
);
5077 show_opaque_info_detail (vty
, lsa
);
5079 vty_out (vty
, "%s", VTY_NEWLINE
);
5084 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5087 show_router_lsa_detail
,
5088 show_network_lsa_detail
,
5089 show_summary_lsa_detail
,
5090 show_summary_asbr_lsa_detail
,
5091 show_as_external_lsa_detail
,
5093 show_as_nssa_lsa_detail
, /* almost same as external */
5095 show_opaque_lsa_detail
,
5096 show_opaque_lsa_detail
,
5097 show_opaque_lsa_detail
,
5101 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5102 struct in_addr
*adv_router
)
5104 memset (lp
, 0, sizeof (struct prefix_ls
));
5108 else if (adv_router
== NULL
)
5117 lp
->adv_router
= *adv_router
;
5122 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5123 struct in_addr
*id
, struct in_addr
*adv_router
)
5125 struct prefix_ls lp
;
5126 struct route_node
*rn
, *start
;
5127 struct ospf_lsa
*lsa
;
5129 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5130 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5133 route_lock_node (start
);
5134 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5135 if ((lsa
= rn
->info
))
5137 if (show_function
[lsa
->data
->type
] != NULL
)
5138 show_function
[lsa
->data
->type
] (vty
, lsa
);
5140 route_unlock_node (start
);
5144 /* Show detail LSA information
5145 -- if id is NULL then show all LSAs. */
5147 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5148 struct in_addr
*id
, struct in_addr
*adv_router
)
5150 struct listnode
*node
;
5151 struct ospf_area
*area
;
5155 case OSPF_AS_EXTERNAL_LSA
:
5156 case OSPF_OPAQUE_AS_LSA
:
5157 vty_out (vty
, " %s %s%s",
5158 show_database_desc
[type
],
5159 VTY_NEWLINE
, VTY_NEWLINE
);
5160 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5163 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5165 vty_out (vty
, "%s %s (Area %s)%s%s",
5166 VTY_NEWLINE
, show_database_desc
[type
],
5167 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5168 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5175 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5176 struct in_addr
*adv_router
)
5178 struct route_node
*rn
;
5179 struct ospf_lsa
*lsa
;
5181 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5182 if ((lsa
= rn
->info
))
5183 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5185 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5187 if (show_function
[lsa
->data
->type
] != NULL
)
5188 show_function
[lsa
->data
->type
] (vty
, lsa
);
5192 /* Show detail LSA information. */
5194 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5195 struct in_addr
*adv_router
)
5197 struct listnode
*node
;
5198 struct ospf_area
*area
;
5202 case OSPF_AS_EXTERNAL_LSA
:
5203 case OSPF_OPAQUE_AS_LSA
:
5204 vty_out (vty
, " %s %s%s",
5205 show_database_desc
[type
],
5206 VTY_NEWLINE
, VTY_NEWLINE
);
5207 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5211 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5213 vty_out (vty
, "%s %s (Area %s)%s%s",
5214 VTY_NEWLINE
, show_database_desc
[type
],
5215 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5216 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5224 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5226 struct ospf_lsa
*lsa
;
5227 struct route_node
*rn
;
5228 struct ospf_area
*area
;
5229 struct listnode
*node
;
5232 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5234 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5238 case OSPF_AS_EXTERNAL_LSA
:
5239 case OSPF_OPAQUE_AS_LSA
:
5244 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5245 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5247 vty_out (vty
, " %s (Area %s)%s%s",
5248 show_database_desc
[type
],
5249 ospf_area_desc_string (area
),
5250 VTY_NEWLINE
, VTY_NEWLINE
);
5251 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5253 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5254 show_lsa_summary (vty
, lsa
, self
);
5256 vty_out (vty
, "%s", VTY_NEWLINE
);
5261 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5265 case OSPF_AS_EXTERNAL_LSA
:
5266 case OSPF_OPAQUE_AS_LSA
:
5271 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5272 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5274 vty_out (vty
, " %s%s%s",
5275 show_database_desc
[type
],
5276 VTY_NEWLINE
, VTY_NEWLINE
);
5277 vty_out (vty
, "%s%s", show_database_header
[type
],
5280 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5281 show_lsa_summary (vty
, lsa
, self
);
5283 vty_out (vty
, "%s", VTY_NEWLINE
);
5287 vty_out (vty
, "%s", VTY_NEWLINE
);
5291 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5293 struct route_node
*rn
;
5295 vty_out (vty
, "%s MaxAge Link States:%s%s",
5296 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5298 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5300 struct ospf_lsa
*lsa
;
5302 if ((lsa
= rn
->info
) != NULL
)
5304 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5305 vty_out (vty
, "Link State ID: %s%s",
5306 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5307 vty_out (vty
, "Advertising Router: %s%s",
5308 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5309 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5310 vty_out (vty
, "%s", VTY_NEWLINE
);
5315 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5316 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5318 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5319 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5320 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5321 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5323 #define OSPF_LSA_TYPES_DESC \
5324 "ASBR summary link states\n" \
5325 "External link states\n" \
5326 "Network link states\n" \
5327 "Router link states\n" \
5328 "Network summary link states\n" \
5329 OSPF_LSA_TYPE_NSSA_DESC \
5330 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5331 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5332 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5335 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5336 int arg_base
, int argc
, struct cmd_token
**argv
)
5340 struct in_addr id
, adv_router
;
5343 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5346 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5347 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5350 if (argc
== arg_base
+ 4)
5352 show_ip_ospf_database_summary (vty
, ospf
, 0);
5356 /* Set database type to show. */
5357 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5358 type
= OSPF_ROUTER_LSA
;
5359 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5360 type
= OSPF_NETWORK_LSA
;
5361 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5362 type
= OSPF_AS_NSSA_LSA
;
5363 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5364 type
= OSPF_SUMMARY_LSA
;
5365 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5366 type
= OSPF_ASBR_SUMMARY_LSA
;
5367 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5368 type
= OSPF_AS_EXTERNAL_LSA
;
5369 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5371 show_ip_ospf_database_summary (vty
, ospf
, 1);
5374 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5376 show_ip_ospf_database_maxage (vty
, ospf
);
5379 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5380 type
= OSPF_OPAQUE_LINK_LSA
;
5381 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5382 type
= OSPF_OPAQUE_AREA_LSA
;
5383 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5384 type
= OSPF_OPAQUE_AS_LSA
;
5388 /* `show ip ospf database LSA'. */
5389 if (argc
== arg_base
+ 5)
5390 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5391 else if (argc
>= arg_base
+ 6)
5393 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5397 /* `show ip ospf database LSA ID'. */
5398 if (argc
== arg_base
+ 6)
5399 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5400 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5401 else if (argc
== arg_base
+ 7)
5403 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5404 adv_router
= ospf
->router_id
;
5407 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5411 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5418 DEFUN (show_ip_ospf_database_max
,
5419 show_ip_ospf_database_max_cmd
,
5420 "show ip ospf database <max-age|self-originate>",
5423 "OSPF information\n"
5424 "Database summary\n"
5425 "LSAs in MaxAge list\n"
5426 "Self-originated link states\n")
5430 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5433 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5436 DEFUN (show_ip_ospf_instance_database
,
5437 show_ip_ospf_instance_database_cmd
,
5438 "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>]]]",
5441 "OSPF information\n"
5443 "Database summary\n"
5445 "Link State ID (as an IP address)\n"
5446 "Self-originated link states\n"
5447 "Advertising Router link states\n"
5448 "Advertising Router (as an IP address)\n")
5451 u_short instance
= 0;
5454 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5456 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5457 ospf
= ospf_lookup_instance (instance
);
5460 ospf
= ospf_lookup();
5463 if (!ospf
|| !ospf
->oi_running
)
5466 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5469 DEFUN (show_ip_ospf_instance_database_max
,
5470 show_ip_ospf_instance_database_max_cmd
,
5471 "show ip ospf (1-65535) database <max-age|self-originate>",
5474 "OSPF information\n"
5476 "Database summary\n"
5477 "LSAs in MaxAge list\n"
5478 "Self-originated link states\n")
5482 u_short instance
= 0;
5484 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5486 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5489 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5494 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5495 int arg_base
, int argc
, struct cmd_token
**argv
)
5499 struct in_addr adv_router
;
5502 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5505 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5506 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5508 if (argc
!= arg_base
+ 7)
5511 /* Set database type to show. */
5512 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5513 type
= OSPF_ROUTER_LSA
;
5514 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5515 type
= OSPF_NETWORK_LSA
;
5516 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5517 type
= OSPF_AS_NSSA_LSA
;
5518 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5519 type
= OSPF_SUMMARY_LSA
;
5520 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5521 type
= OSPF_ASBR_SUMMARY_LSA
;
5522 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5523 type
= OSPF_AS_EXTERNAL_LSA
;
5524 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5525 type
= OSPF_OPAQUE_LINK_LSA
;
5526 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5527 type
= OSPF_OPAQUE_AREA_LSA
;
5528 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5529 type
= OSPF_OPAQUE_AS_LSA
;
5533 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5534 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5535 adv_router
= ospf
->router_id
;
5538 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5543 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5548 DEFUN (show_ip_ospf_database_type_adv_router
,
5549 show_ip_ospf_database_type_adv_router_cmd
,
5550 "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>",
5553 "OSPF information\n"
5554 "Database summary\n"
5556 "Advertising Router link states\n"
5557 "Advertising Router (as an IP address)\n"
5558 "Self-originated link states\n")
5562 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5565 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5568 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5569 show_ip_ospf_instance_database_type_adv_router_cmd
,
5570 "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>",
5573 "OSPF information\n"
5575 "Database summary\n"
5577 "Advertising Router link states\n"
5578 "Advertising Router (as an IP address)\n"
5579 "Self-originated link states\n")
5583 u_short instance
= 0;
5585 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5587 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5590 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5593 DEFUN (ip_ospf_authentication_args
,
5594 ip_ospf_authentication_args_addr_cmd
,
5595 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5597 "OSPF interface commands\n"
5598 "Enable authentication on this interface\n"
5599 "Use null authentication\n"
5600 "Use message-digest authentication\n"
5601 "Address of interface\n")
5603 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5604 int idx_encryption
= 3;
5606 struct in_addr addr
;
5608 struct ospf_if_params
*params
;
5610 params
= IF_DEF_PARAMS (ifp
);
5614 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5617 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5622 params
= ospf_get_if_params (ifp
, addr
);
5623 ospf_if_update_params (ifp
, addr
);
5626 /* Handle null authentication */
5627 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5629 SET_IF_PARAM (params
, auth_type
);
5630 params
->auth_type
= OSPF_AUTH_NULL
;
5634 /* Handle message-digest authentication */
5635 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5637 SET_IF_PARAM (params
, auth_type
);
5638 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5642 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5646 DEFUN (ip_ospf_authentication
,
5647 ip_ospf_authentication_addr_cmd
,
5648 "ip ospf authentication [A.B.C.D]",
5650 "OSPF interface commands\n"
5651 "Enable authentication on this interface\n"
5652 "Address of interface")
5654 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5656 struct in_addr addr
;
5658 struct ospf_if_params
*params
;
5660 params
= IF_DEF_PARAMS (ifp
);
5664 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5667 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5672 params
= ospf_get_if_params (ifp
, addr
);
5673 ospf_if_update_params (ifp
, addr
);
5676 SET_IF_PARAM (params
, auth_type
);
5677 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5682 DEFUN (no_ip_ospf_authentication_args
,
5683 no_ip_ospf_authentication_args_addr_cmd
,
5684 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5687 "OSPF interface commands\n"
5688 "Enable authentication on this interface\n"
5689 "Use null authentication\n"
5690 "Use message-digest authentication\n"
5691 "Address of interface")
5693 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5694 int idx_encryption
= 4;
5696 struct in_addr addr
;
5698 struct ospf_if_params
*params
;
5699 struct route_node
*rn
;
5702 params
= IF_DEF_PARAMS (ifp
);
5706 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5709 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5714 params
= ospf_lookup_if_params (ifp
, addr
);
5717 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5720 params
->auth_type
= OSPF_AUTH_NOTSET
;
5721 UNSET_IF_PARAM (params
, auth_type
);
5722 if (params
!= IF_DEF_PARAMS (ifp
))
5724 ospf_free_if_params (ifp
, addr
);
5725 ospf_if_update_params (ifp
, addr
);
5730 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5732 auth_type
= OSPF_AUTH_NULL
;
5734 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5736 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5740 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5744 * Here we have a case where the user has entered
5745 * 'no ip ospf authentication (null | message_digest )'
5746 * we need to find if we have any ip addresses underneath it that
5747 * correspond to the associated type.
5749 if (params
->auth_type
== auth_type
)
5751 params
->auth_type
= OSPF_AUTH_NOTSET
;
5752 UNSET_IF_PARAM (params
, auth_type
);
5755 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5757 if ((params
= rn
->info
))
5759 if (params
->auth_type
== auth_type
)
5761 params
->auth_type
= OSPF_AUTH_NOTSET
;
5762 UNSET_IF_PARAM (params
, auth_type
);
5763 if (params
!= IF_DEF_PARAMS (ifp
))
5765 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5766 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5776 DEFUN (no_ip_ospf_authentication
,
5777 no_ip_ospf_authentication_addr_cmd
,
5778 "no ip ospf authentication [A.B.C.D]",
5781 "OSPF interface commands\n"
5782 "Enable authentication on this interface\n"
5783 "Address of interface")
5785 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5787 struct in_addr addr
;
5789 struct ospf_if_params
*params
;
5790 struct route_node
*rn
;
5792 params
= IF_DEF_PARAMS (ifp
);
5796 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5799 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5804 params
= ospf_lookup_if_params (ifp
, addr
);
5807 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5811 params
->auth_type
= OSPF_AUTH_NOTSET
;
5812 UNSET_IF_PARAM (params
, auth_type
);
5813 if (params
!= IF_DEF_PARAMS (ifp
))
5815 ospf_free_if_params (ifp
, addr
);
5816 ospf_if_update_params (ifp
, addr
);
5822 * When a user enters 'no ip ospf authentication'
5823 * We should remove all authentication types from
5826 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5827 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5828 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5830 params
->auth_type
= OSPF_AUTH_NOTSET
;
5831 UNSET_IF_PARAM (params
, auth_type
);
5834 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5836 if ((params
= rn
->info
))
5839 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5840 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5841 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5843 params
->auth_type
= OSPF_AUTH_NOTSET
;
5844 UNSET_IF_PARAM (params
, auth_type
);
5845 if (params
!= IF_DEF_PARAMS (ifp
))
5847 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5848 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5859 DEFUN (ip_ospf_authentication_key
,
5860 ip_ospf_authentication_key_addr_cmd
,
5861 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5863 "OSPF interface commands\n"
5864 "Authentication password (key)\n"
5865 "The OSPF password (key)\n"
5866 "Address of interface")
5868 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5870 struct in_addr addr
;
5871 struct ospf_if_params
*params
;
5873 params
= IF_DEF_PARAMS (ifp
);
5875 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5877 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5879 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5884 params
= ospf_get_if_params (ifp
, addr
);
5885 ospf_if_update_params (ifp
, addr
);
5888 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5889 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5890 SET_IF_PARAM (params
, auth_simple
);
5895 DEFUN_HIDDEN (ospf_authentication_key
,
5896 ospf_authentication_key_cmd
,
5897 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5898 "OSPF interface commands\n"
5899 "Authentication password (key)\n"
5900 "The OSPF password (key)\n"
5901 "Address of interface\n")
5903 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5906 DEFUN (no_ip_ospf_authentication_key
,
5907 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5908 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5911 "OSPF interface commands\n"
5912 "Authentication password (key)\n"
5913 "The OSPF password (key)")
5915 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5917 struct in_addr addr
;
5918 struct ospf_if_params
*params
;
5919 params
= IF_DEF_PARAMS (ifp
);
5921 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5923 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5925 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5930 params
= ospf_lookup_if_params (ifp
, addr
);
5935 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5936 UNSET_IF_PARAM (params
, auth_simple
);
5938 if (params
!= IF_DEF_PARAMS (ifp
))
5940 ospf_free_if_params (ifp
, addr
);
5941 ospf_if_update_params (ifp
, addr
);
5947 DEFUN_HIDDEN (no_ospf_authentication_key
,
5948 no_ospf_authentication_key_authkey_addr_cmd
,
5949 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5951 "OSPF interface commands\n"
5952 "Authentication password (key)\n"
5953 "The OSPF password (key)")
5955 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5958 DEFUN (ip_ospf_message_digest_key
,
5959 ip_ospf_message_digest_key_cmd
,
5960 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5962 "OSPF interface commands\n"
5963 "Message digest authentication password (key)\n"
5965 "Use MD5 algorithm\n"
5966 "The OSPF password (key)\n"
5967 "Address of interface\n")
5969 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5970 struct crypt_key
*ck
;
5972 struct in_addr addr
;
5973 struct ospf_if_params
*params
;
5975 params
= IF_DEF_PARAMS (ifp
);
5978 argv_find (argv
, argc
, "(1-255)", &idx
);
5979 char *keyid
= argv
[idx
]->arg
;
5980 argv_find (argv
, argc
, "KEY", &idx
);
5981 char *cryptkey
= argv
[idx
]->arg
;
5983 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5985 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5987 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5992 params
= ospf_get_if_params (ifp
, addr
);
5993 ospf_if_update_params (ifp
, addr
);
5996 key_id
= strtol (keyid
, NULL
, 10);
5997 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5999 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6003 ck
= ospf_crypt_key_new ();
6004 ck
->key_id
= (u_char
) key_id
;
6005 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6006 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6008 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6009 SET_IF_PARAM (params
, auth_crypt
);
6014 DEFUN_HIDDEN (ospf_message_digest_key
,
6015 ospf_message_digest_key_cmd
,
6016 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6017 "OSPF interface commands\n"
6018 "Message digest authentication password (key)\n"
6020 "Use MD5 algorithm\n"
6021 "The OSPF password (key)\n"
6022 "Address of interface\n")
6024 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6027 DEFUN (no_ip_ospf_message_digest_key
,
6028 no_ip_ospf_message_digest_key_cmd
,
6029 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6032 "OSPF interface commands\n"
6033 "Message digest authentication password (key)\n"
6035 "Use MD5 algorithm\n"
6036 "The OSPF password (key)\n"
6037 "Address of interface\n")
6039 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6041 struct crypt_key
*ck
;
6043 struct in_addr addr
;
6044 struct ospf_if_params
*params
;
6045 params
= IF_DEF_PARAMS (ifp
);
6047 argv_find (argv
, argc
, "(1-255)", &idx
);
6048 char *keyid
= argv
[idx
]->arg
;
6050 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6052 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6054 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6059 params
= ospf_lookup_if_params (ifp
, addr
);
6064 key_id
= strtol (keyid
, NULL
, 10);
6065 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6068 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6072 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6074 if (params
!= IF_DEF_PARAMS (ifp
))
6076 ospf_free_if_params (ifp
, addr
);
6077 ospf_if_update_params (ifp
, addr
);
6083 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6084 no_ospf_message_digest_key_cmd
,
6085 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6087 "OSPF interface commands\n"
6088 "Message digest authentication password (key)\n"
6090 "Address of interface")
6092 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6095 DEFUN (ip_ospf_cost
,
6097 "ip ospf cost (1-65535) [A.B.C.D]",
6099 "OSPF interface commands\n"
6102 "Address of interface\n")
6104 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6107 struct in_addr addr
;
6108 struct ospf_if_params
*params
;
6109 params
= IF_DEF_PARAMS (ifp
);
6112 char *coststr
= NULL
, *ifaddr
= NULL
;
6113 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6114 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6116 cost
= strtol (coststr
, NULL
, 10);
6120 if(!inet_aton(ifaddr
, &addr
))
6122 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6127 params
= ospf_get_if_params (ifp
, addr
);
6128 ospf_if_update_params (ifp
, addr
);
6131 SET_IF_PARAM (params
, output_cost_cmd
);
6132 params
->output_cost_cmd
= cost
;
6134 ospf_if_recalculate_output_cost (ifp
);
6139 DEFUN_HIDDEN (ospf_cost
,
6141 "ospf cost (1-65535) [A.B.C.D]",
6142 "OSPF interface commands\n"
6145 "Address of interface\n")
6147 return ip_ospf_cost (self
, vty
, argc
, argv
);
6150 DEFUN (no_ip_ospf_cost
,
6151 no_ip_ospf_cost_cmd
,
6152 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6154 "OSPF interface commands\n"
6156 "Address of interface")
6158 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6160 struct in_addr addr
;
6161 struct ospf_if_params
*params
;
6163 params
= IF_DEF_PARAMS (ifp
);
6166 char *ifaddr
= NULL
;
6167 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6169 /* According to the semantics we are mimicking "no ip ospf cost N" is
6170 * always treated as "no ip ospf cost" regardless of the actual value
6171 * of N already configured for the interface. Thus ignore cost. */
6175 if (!inet_aton(ifaddr
, &addr
))
6177 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6182 params
= ospf_lookup_if_params (ifp
, addr
);
6187 UNSET_IF_PARAM (params
, output_cost_cmd
);
6189 if (params
!= IF_DEF_PARAMS (ifp
))
6191 ospf_free_if_params (ifp
, addr
);
6192 ospf_if_update_params (ifp
, addr
);
6195 ospf_if_recalculate_output_cost (ifp
);
6200 DEFUN_HIDDEN (no_ospf_cost
,
6202 "no ospf cost [(1-65535)] [A.B.C.D]",
6204 "OSPF interface commands\n"
6207 "Address of interface\n")
6209 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6213 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6215 struct route_node
*rn
;
6216 struct ospf_neighbor
*nbr
;
6218 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6219 if ((nbr
= rn
->info
))
6221 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6222 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6223 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6224 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6229 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6230 const char *nbr_str
,
6231 const char *fast_hello_str
)
6233 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6236 struct in_addr addr
;
6238 struct ospf_if_params
*params
;
6239 struct ospf_interface
*oi
;
6240 struct route_node
*rn
;
6242 params
= IF_DEF_PARAMS (ifp
);
6246 ret
= inet_aton(nbr_str
, &addr
);
6249 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6254 params
= ospf_get_if_params (ifp
, addr
);
6255 ospf_if_update_params (ifp
, addr
);
6260 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6263 /* reset fast_hello too, just to be sure */
6264 UNSET_IF_PARAM (params
, fast_hello
);
6265 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6267 else if (fast_hello_str
)
6269 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6271 /* 1s dead-interval with sub-second hellos desired */
6272 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6273 SET_IF_PARAM (params
, fast_hello
);
6274 params
->fast_hello
= hellomult
;
6278 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6283 SET_IF_PARAM (params
, v_wait
);
6284 params
->v_wait
= seconds
;
6286 /* Update timer values in neighbor structure. */
6290 if ((ospf
= ospf_lookup()))
6292 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6294 ospf_nbr_timer_update (oi
);
6299 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6300 if ((oi
= rn
->info
))
6301 ospf_nbr_timer_update (oi
);
6307 DEFUN (ip_ospf_dead_interval
,
6308 ip_ospf_dead_interval_cmd
,
6309 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6311 "OSPF interface commands\n"
6312 "Interval time after which a neighbor is declared down\n"
6314 "Address of interface\n")
6317 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6318 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6319 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6323 DEFUN_HIDDEN (ospf_dead_interval
,
6324 ospf_dead_interval_cmd
,
6325 "ospf dead-interval (1-65535) [A.B.C.D]",
6326 "OSPF interface commands\n"
6327 "Interval time after which a neighbor is declared down\n"
6329 "Address of interface\n")
6331 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6334 DEFUN (ip_ospf_dead_interval_minimal
,
6335 ip_ospf_dead_interval_minimal_addr_cmd
,
6336 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6338 "OSPF interface commands\n"
6339 "Interval time after which a neighbor is declared down\n"
6340 "Minimal 1s dead-interval with fast sub-second hellos\n"
6341 "Hello multiplier factor\n"
6342 "Number of Hellos to send each second\n"
6343 "Address of interface\n")
6348 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6350 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6353 DEFUN (no_ip_ospf_dead_interval
,
6354 no_ip_ospf_dead_interval_cmd
,
6355 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6358 "OSPF interface commands\n"
6359 "Interval time after which a neighbor is declared down\n"
6361 "Address of interface")
6363 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6364 int idx_ipv4
= argc
- 1;
6365 struct in_addr addr
;
6367 struct ospf_if_params
*params
;
6368 struct ospf_interface
*oi
;
6369 struct route_node
*rn
;
6371 params
= IF_DEF_PARAMS (ifp
);
6373 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6375 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6378 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6383 params
= ospf_lookup_if_params (ifp
, addr
);
6388 UNSET_IF_PARAM (params
, v_wait
);
6389 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6391 UNSET_IF_PARAM (params
, fast_hello
);
6392 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6394 if (params
!= IF_DEF_PARAMS (ifp
))
6396 ospf_free_if_params (ifp
, addr
);
6397 ospf_if_update_params (ifp
, addr
);
6400 /* Update timer values in neighbor structure. */
6405 if ((ospf
= ospf_lookup()))
6407 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6409 ospf_nbr_timer_update (oi
);
6414 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6415 if ((oi
= rn
->info
))
6416 ospf_nbr_timer_update (oi
);
6422 DEFUN_HIDDEN (no_ospf_dead_interval
,
6423 no_ospf_dead_interval_cmd
,
6424 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6426 "OSPF interface commands\n"
6427 "Interval time after which a neighbor is declared down\n"
6429 "Address of interface")
6431 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6434 DEFUN (ip_ospf_hello_interval
,
6435 ip_ospf_hello_interval_cmd
,
6436 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6438 "OSPF interface commands\n"
6439 "Time between HELLO packets\n"
6441 "Address of interface\n")
6443 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6445 struct in_addr addr
;
6446 struct ospf_if_params
*params
;
6447 params
= IF_DEF_PARAMS (ifp
);
6448 u_int32_t seconds
= 0;
6450 argv_find (argv
, argc
, "(1-65535)", &idx
);
6451 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6453 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6455 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6457 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6462 params
= ospf_get_if_params (ifp
, addr
);
6463 ospf_if_update_params (ifp
, addr
);
6466 SET_IF_PARAM (params
, v_hello
);
6467 params
->v_hello
= seconds
;
6472 DEFUN_HIDDEN (ospf_hello_interval
,
6473 ospf_hello_interval_cmd
,
6474 "ospf hello-interval (1-65535) [A.B.C.D]",
6475 "OSPF interface commands\n"
6476 "Time between HELLO packets\n"
6478 "Address of interface\n")
6480 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6483 DEFUN (no_ip_ospf_hello_interval
,
6484 no_ip_ospf_hello_interval_cmd
,
6485 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6488 "OSPF interface commands\n"
6489 "Time between HELLO packets\n" // ignored
6491 "Address of interface\n")
6493 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6495 struct in_addr addr
;
6496 struct ospf_if_params
*params
;
6497 params
= IF_DEF_PARAMS (ifp
);
6499 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6501 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6503 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6508 params
= ospf_lookup_if_params (ifp
, addr
);
6513 UNSET_IF_PARAM (params
, v_hello
);
6514 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6516 if (params
!= IF_DEF_PARAMS (ifp
))
6518 ospf_free_if_params (ifp
, addr
);
6519 ospf_if_update_params (ifp
, addr
);
6525 DEFUN_HIDDEN (no_ospf_hello_interval
,
6526 no_ospf_hello_interval_cmd
,
6527 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6529 "OSPF interface commands\n"
6530 "Time between HELLO packets\n" // ignored
6532 "Address of interface\n")
6534 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6537 DEFUN (ip_ospf_network
,
6538 ip_ospf_network_cmd
,
6539 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6541 "OSPF interface commands\n"
6543 "Specify OSPF broadcast multi-access network\n"
6544 "Specify OSPF NBMA network\n"
6545 "Specify OSPF point-to-multipoint network\n"
6546 "Specify OSPF point-to-point network\n")
6548 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6550 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6551 struct route_node
*rn
;
6553 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6555 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6559 if (argv_find (argv
, argc
, "broadcast", &idx
))
6560 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6561 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6562 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6563 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6564 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6565 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6566 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6568 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6571 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6573 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6575 struct ospf_interface
*oi
= rn
->info
;
6580 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6582 if (oi
->state
> ISM_Down
)
6584 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6585 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6592 DEFUN_HIDDEN (ospf_network
,
6594 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6595 "OSPF interface commands\n"
6597 "Specify OSPF broadcast multi-access network\n"
6598 "Specify OSPF NBMA network\n"
6599 "Specify OSPF point-to-multipoint network\n"
6600 "Specify OSPF point-to-point network\n")
6602 return ip_ospf_network (self
, vty
, argc
, argv
);
6605 DEFUN (no_ip_ospf_network
,
6606 no_ip_ospf_network_cmd
,
6607 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6610 "OSPF interface commands\n"
6612 "Specify OSPF broadcast multi-access network\n"
6613 "Specify OSPF NBMA network\n"
6614 "Specify OSPF point-to-multipoint network\n"
6615 "Specify OSPF point-to-point network\n")
6617 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6618 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6619 struct route_node
*rn
;
6621 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6623 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6626 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6628 struct ospf_interface
*oi
= rn
->info
;
6633 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6635 if (oi
->state
> ISM_Down
)
6637 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6638 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6645 DEFUN_HIDDEN (no_ospf_network
,
6646 no_ospf_network_cmd
,
6647 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6649 "OSPF interface commands\n"
6651 "Specify OSPF broadcast multi-access network\n"
6652 "Specify OSPF NBMA network\n"
6653 "Specify OSPF point-to-multipoint network\n"
6654 "Specify OSPF point-to-point network\n")
6656 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6659 DEFUN (ip_ospf_priority
,
6660 ip_ospf_priority_cmd
,
6661 "ip ospf priority (0-255) [A.B.C.D]",
6663 "OSPF interface commands\n"
6666 "Address of interface")
6668 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6671 struct route_node
*rn
;
6672 struct in_addr addr
;
6673 struct ospf_if_params
*params
;
6674 params
= IF_DEF_PARAMS (ifp
);
6676 argv_find (argv
, argc
, "(0-255)", &idx
);
6677 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6679 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6681 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6683 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6688 params
= ospf_get_if_params (ifp
, addr
);
6689 ospf_if_update_params (ifp
, addr
);
6692 SET_IF_PARAM (params
, priority
);
6693 params
->priority
= priority
;
6695 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6697 struct ospf_interface
*oi
= rn
->info
;
6702 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6704 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6705 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6712 DEFUN_HIDDEN (ospf_priority
,
6714 "ospf priority (0-255) [A.B.C.D]",
6715 "OSPF interface commands\n"
6718 "Address of interface")
6720 return ip_ospf_priority (self
, vty
, argc
, argv
);
6723 DEFUN (no_ip_ospf_priority
,
6724 no_ip_ospf_priority_cmd
,
6725 "no ip ospf priority [(0-255) [A.B.C.D]]",
6728 "OSPF interface commands\n"
6729 "Router priority\n" // ignored
6731 "Address of interface")
6733 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6735 struct route_node
*rn
;
6736 struct in_addr addr
;
6737 struct ospf_if_params
*params
;
6739 params
= IF_DEF_PARAMS (ifp
);
6741 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6743 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6745 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6750 params
= ospf_lookup_if_params (ifp
, addr
);
6755 UNSET_IF_PARAM (params
, priority
);
6756 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6758 if (params
!= IF_DEF_PARAMS (ifp
))
6760 ospf_free_if_params (ifp
, addr
);
6761 ospf_if_update_params (ifp
, addr
);
6764 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6766 struct ospf_interface
*oi
= rn
->info
;
6771 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6773 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6774 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6781 DEFUN_HIDDEN (no_ospf_priority
,
6782 no_ospf_priority_cmd
,
6783 "no ospf priority [(0-255) [A.B.C.D]]",
6785 "OSPF interface commands\n"
6788 "Address of interface")
6790 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6793 DEFUN (ip_ospf_retransmit_interval
,
6794 ip_ospf_retransmit_interval_addr_cmd
,
6795 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6797 "OSPF interface commands\n"
6798 "Time between retransmitting lost link state advertisements\n"
6800 "Address of interface")
6802 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6805 struct in_addr addr
;
6806 struct ospf_if_params
*params
;
6807 params
= IF_DEF_PARAMS (ifp
);
6809 argv_find (argv
, argc
, "(3-65535)", &idx
);
6810 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6812 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6814 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6816 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6821 params
= ospf_get_if_params (ifp
, addr
);
6822 ospf_if_update_params (ifp
, addr
);
6825 SET_IF_PARAM (params
, retransmit_interval
);
6826 params
->retransmit_interval
= seconds
;
6831 DEFUN_HIDDEN (ospf_retransmit_interval
,
6832 ospf_retransmit_interval_cmd
,
6833 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6834 "OSPF interface commands\n"
6835 "Time between retransmitting lost link state advertisements\n"
6837 "Address of interface")
6839 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6842 DEFUN (no_ip_ospf_retransmit_interval
,
6843 no_ip_ospf_retransmit_interval_addr_cmd
,
6844 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6847 "OSPF interface commands\n"
6848 "Time between retransmitting lost link state advertisements\n"
6850 "Address of interface\n")
6852 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6854 struct in_addr addr
;
6855 struct ospf_if_params
*params
;
6857 params
= IF_DEF_PARAMS (ifp
);
6859 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6861 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6863 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6868 params
= ospf_lookup_if_params (ifp
, addr
);
6873 UNSET_IF_PARAM (params
, retransmit_interval
);
6874 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6876 if (params
!= IF_DEF_PARAMS (ifp
))
6878 ospf_free_if_params (ifp
, addr
);
6879 ospf_if_update_params (ifp
, addr
);
6885 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6886 no_ospf_retransmit_interval_cmd
,
6887 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6889 "OSPF interface commands\n"
6890 "Time between retransmitting lost link state advertisements\n"
6892 "Address of interface\n")
6894 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6897 DEFUN (ip_ospf_transmit_delay
,
6898 ip_ospf_transmit_delay_addr_cmd
,
6899 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6901 "OSPF interface commands\n"
6902 "Link state transmit delay\n"
6904 "Address of interface")
6906 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6909 struct in_addr addr
;
6910 struct ospf_if_params
*params
;
6912 params
= IF_DEF_PARAMS (ifp
);
6913 argv_find (argv
, argc
, "(1-65535)", &idx
);
6914 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6916 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6918 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6920 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6925 params
= ospf_get_if_params (ifp
, addr
);
6926 ospf_if_update_params (ifp
, addr
);
6929 SET_IF_PARAM (params
, transmit_delay
);
6930 params
->transmit_delay
= seconds
;
6935 DEFUN_HIDDEN (ospf_transmit_delay
,
6936 ospf_transmit_delay_cmd
,
6937 "ospf transmit-delay (1-65535) [A.B.C.D]",
6938 "OSPF interface commands\n"
6939 "Link state transmit delay\n"
6941 "Address of interface")
6943 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6946 DEFUN (no_ip_ospf_transmit_delay
,
6947 no_ip_ospf_transmit_delay_addr_cmd
,
6948 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6951 "OSPF interface commands\n"
6952 "Link state transmit delay\n"
6953 "Address of interface")
6955 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6957 struct in_addr addr
;
6958 struct ospf_if_params
*params
;
6960 params
= IF_DEF_PARAMS (ifp
);
6962 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6964 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6966 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6971 params
= ospf_lookup_if_params (ifp
, addr
);
6976 UNSET_IF_PARAM (params
, transmit_delay
);
6977 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6979 if (params
!= IF_DEF_PARAMS (ifp
))
6981 ospf_free_if_params (ifp
, addr
);
6982 ospf_if_update_params (ifp
, addr
);
6989 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6990 no_ospf_transmit_delay_cmd
,
6991 "no ospf transmit-delay",
6993 "OSPF interface commands\n"
6994 "Link state transmit delay\n")
6996 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6999 DEFUN (ip_ospf_area
,
7001 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7003 "OSPF interface commands\n"
7005 "Enable OSPF on this interface\n"
7006 "OSPF area ID in IP address format\n"
7007 "OSPF area ID as a decimal value\n")
7009 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7012 struct in_addr area_id
;
7014 struct ospf_if_params
*params
;
7015 struct route_node
*rn
;
7016 u_short instance
= 0;
7018 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7019 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7020 char *areaid
= argv
[argc
- 1]->arg
;
7022 ospf
= ospf_lookup_instance (instance
);
7025 params
= IF_DEF_PARAMS (ifp
);
7026 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7028 ospf_interface_unset (ifp
);
7029 ospf
= ospf_lookup();
7030 ospf
->if_ospf_cli_count
--;
7035 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7038 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7042 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7044 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7048 params
= IF_DEF_PARAMS (ifp
);
7049 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7052 "Must remove previous area config before changing ospf area %s",
7057 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7059 if (rn
->info
!= NULL
)
7061 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7066 /* enable ospf on this interface with area_id */
7067 ospf_interface_set (ifp
, area_id
);
7068 ospf
->if_ospf_cli_count
++;
7073 DEFUN (no_ip_ospf_area
,
7074 no_ip_ospf_area_cmd
,
7075 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7078 "OSPF interface commands\n"
7080 "Disable OSPF on this interface\n"
7081 "OSPF area ID in IP address format\n"
7082 "OSPF area ID as a decimal value\n")
7084 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7087 struct ospf_if_params
*params
;
7088 u_short instance
= 0;
7090 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7091 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7093 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7096 params
= IF_DEF_PARAMS (ifp
);
7097 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7099 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7103 ospf_interface_unset (ifp
);
7104 ospf
->if_ospf_cli_count
--;
7108 DEFUN (ospf_redistribute_source
,
7109 ospf_redistribute_source_cmd
,
7110 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7112 FRR_REDIST_HELP_STR_OSPFD
7113 "Metric for redistributed routes\n"
7114 "OSPF default metric\n"
7115 "OSPF exterior metric type for redistributed routes\n"
7116 "Set OSPF External Type 1 metrics\n"
7117 "Set OSPF External Type 2 metrics\n"
7118 "Route map reference\n"
7119 "Pointer to route-map entries\n")
7121 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7122 int idx_protocol
= 1;
7126 struct ospf_redist
*red
;
7132 /* Get distribute source. */
7133 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7137 red
= ospf_redist_add(ospf
, source
, 0);
7139 /* Get metric value. */
7140 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7141 if (!str2metric (argv
[idx
]->arg
, &metric
))
7144 /* Get metric type. */
7145 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7146 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7150 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7151 ospf_routemap_set (red
, argv
[idx
]->arg
);
7154 ospf_routemap_unset (red
);
7156 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7159 DEFUN (no_ospf_redistribute_source
,
7160 no_ospf_redistribute_source_cmd
,
7161 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7164 FRR_REDIST_HELP_STR_OSPFD
7165 "Metric for redistributed routes\n"
7166 "OSPF default metric\n"
7167 "OSPF exterior metric type for redistributed routes\n"
7168 "Set OSPF External Type 1 metrics\n"
7169 "Set OSPF External Type 2 metrics\n"
7170 "Route map reference\n"
7171 "Pointer to route-map entries\n")
7173 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7174 int idx_protocol
= 2;
7176 struct ospf_redist
*red
;
7178 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7182 red
= ospf_redist_lookup(ospf
, source
, 0);
7186 ospf_routemap_unset (red
);
7187 return ospf_redistribute_unset (ospf
, source
, 0);
7190 DEFUN (ospf_redistribute_instance_source
,
7191 ospf_redistribute_instance_source_cmd
,
7192 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7194 "Open Shortest Path First\n"
7195 "Non-main Kernel Routing Table\n"
7196 "Instance ID/Table ID\n"
7197 "Metric for redistributed routes\n"
7198 "OSPF default metric\n"
7199 "OSPF exterior metric type for redistributed routes\n"
7200 "Set OSPF External Type 1 metrics\n"
7201 "Set OSPF External Type 2 metrics\n"
7202 "Route map reference\n"
7203 "Pointer to route-map entries\n")
7205 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7206 int idx_ospf_table
= 1;
7208 int idx_redist_param
= 3;
7213 struct ospf_redist
*red
;
7218 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7220 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7225 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7227 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7232 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7234 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7239 /* Get metric value. */
7240 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7241 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7244 /* Get metric type. */
7245 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7246 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7249 red
= ospf_redist_add(ospf
, source
, instance
);
7251 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7252 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7254 ospf_routemap_unset (red
);
7256 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7259 DEFUN (no_ospf_redistribute_instance_source
,
7260 no_ospf_redistribute_instance_source_cmd
,
7261 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7264 "Open Shortest Path First\n"
7265 "Non-main Kernel Routing Table\n"
7266 "Instance ID/Table Id\n"
7267 "Metric for redistributed routes\n"
7268 "OSPF default metric\n"
7269 "OSPF exterior metric type for redistributed routes\n"
7270 "Set OSPF External Type 1 metrics\n"
7271 "Set OSPF External Type 2 metrics\n"
7272 "Route map reference\n"
7273 "Pointer to route-map entries\n")
7275 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7276 int idx_ospf_table
= 2;
7279 struct ospf_redist
*red
;
7282 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7283 source
= ZEBRA_ROUTE_OSPF
;
7285 source
= ZEBRA_ROUTE_TABLE
;
7287 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7289 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7291 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7296 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7298 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7303 red
= ospf_redist_lookup(ospf
, source
, instance
);
7307 ospf_routemap_unset (red
);
7308 return ospf_redistribute_unset (ospf
, source
, instance
);
7311 DEFUN (ospf_distribute_list_out
,
7312 ospf_distribute_list_out_cmd
,
7313 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7314 "Filter networks in routing updates\n"
7315 "Access-list name\n"
7317 FRR_REDIST_HELP_STR_OSPFD
)
7319 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7323 char *proto
= argv
[argc
- 1]->text
;
7325 /* Get distribute source. */
7326 source
= proto_redistnum(AFI_IP
, proto
);
7330 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7333 DEFUN (no_ospf_distribute_list_out
,
7334 no_ospf_distribute_list_out_cmd
,
7335 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7337 "Filter networks in routing updates\n"
7338 "Access-list name\n"
7340 FRR_REDIST_HELP_STR_OSPFD
)
7342 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7346 char *proto
= argv
[argc
- 1]->text
;
7347 source
= proto_redistnum(AFI_IP
, proto
);
7351 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7354 /* Default information originate. */
7355 DEFUN (ospf_default_information_originate
,
7356 ospf_default_information_originate_cmd
,
7357 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7358 "Control distribution of default information\n"
7359 "Distribute a default route\n"
7360 "Always advertise default route\n"
7361 "OSPF default metric\n"
7363 "OSPF metric type for default routes\n"
7364 "Set OSPF External Type 1 metrics\n"
7365 "Set OSPF External Type 2 metrics\n"
7366 "Route map reference\n"
7367 "Pointer to route-map entries\n")
7369 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7370 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7373 struct ospf_redist
*red
;
7376 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7378 /* Check whether "always" was specified */
7379 if (argv_find (argv
, argc
, "always", &idx
))
7380 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7381 /* Get metric value */
7382 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7383 if (!str2metric (argv
[idx
]->arg
, &metric
))
7386 /* Get metric type. */
7387 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7388 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7392 else if (argv_find (argv
, argc
, "WORD", &idx
))
7393 ospf_routemap_set (red
, argv
[idx
]->arg
);
7395 ospf_routemap_unset (red
);
7397 return ospf_redistribute_default_set (ospf
, default_originate
,
7401 DEFUN (no_ospf_default_information_originate
,
7402 no_ospf_default_information_originate_cmd
,
7403 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7405 "Control distribution of default information\n"
7406 "Distribute a default route\n"
7407 "Always advertise default route\n"
7408 "OSPF default metric\n"
7410 "OSPF metric type for default routes\n"
7411 "Set OSPF External Type 1 metrics\n"
7412 "Set OSPF External Type 2 metrics\n"
7413 "Route map reference\n"
7414 "Pointer to route-map entries\n")
7416 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7417 struct prefix_ipv4 p
;
7418 struct ospf_external
*ext
;
7419 struct ospf_redist
*red
;
7422 p
.prefix
.s_addr
= 0;
7425 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7427 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7428 EXTERNAL_INFO (ext
)) {
7429 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7430 ospf_external_del (DEFAULT_ROUTE
, 0);
7433 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7437 ospf_routemap_unset (red
);
7438 return ospf_redistribute_default_unset (ospf
);
7441 DEFUN (ospf_default_metric
,
7442 ospf_default_metric_cmd
,
7443 "default-metric (0-16777214)",
7444 "Set metric of redistributed routes\n"
7447 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7451 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7454 ospf
->default_metric
= metric
;
7459 DEFUN (no_ospf_default_metric
,
7460 no_ospf_default_metric_cmd
,
7461 "no default-metric [(0-16777214)]",
7463 "Set metric of redistributed routes\n"
7466 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7468 ospf
->default_metric
= -1;
7474 DEFUN (ospf_distance
,
7477 "Define an administrative distance\n"
7478 "OSPF Administrative distance\n")
7480 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7483 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7488 DEFUN (no_ospf_distance
,
7489 no_ospf_distance_cmd
,
7490 "no distance (1-255)",
7492 "Define an administrative distance\n"
7493 "OSPF Administrative distance\n")
7495 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7497 ospf
->distance_all
= 0;
7502 DEFUN (no_ospf_distance_ospf
,
7503 no_ospf_distance_ospf_cmd
,
7504 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7506 "Define an administrative distance\n"
7507 "OSPF Administrative distance\n"
7508 "Intra-area routes\n"
7509 "Distance for intra-area routes\n"
7510 "Inter-area routes\n"
7511 "Distance for inter-area routes\n"
7513 "Distance for external routes\n")
7515 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7516 int idx_area_distance
= 3;
7527 if (argv
[idx_area_distance
]->arg
!= NULL
)
7528 ospf
->distance_intra
= 0;
7530 if (argv
[1] != NULL
)
7531 ospf
->distance_inter
= 0;
7533 if (argv
[2] != NULL
)
7534 ospf
->distance_external
= 0;
7536 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
7539 /* If no arguments are given, clear all distance information */
7540 ospf
->distance_intra
= 0;
7541 ospf
->distance_inter
= 0;
7542 ospf
->distance_external
= 0;
7547 DEFUN (ospf_distance_ospf
,
7548 ospf_distance_ospf_cmd
,
7549 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7550 "Define an administrative distance\n"
7551 "OSPF Administrative distance\n"
7552 "Intra-area routes\n"
7553 "Distance for intra-area routes\n"
7554 "Inter-area routes\n"
7555 "Distance for inter-area routes\n"
7557 "Distance for external routes\n")
7559 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7560 int idx_area_distance
= 2;
7562 if (argc
< 3) /* should not happen */
7565 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
7567 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
7572 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
7573 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
7575 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
7576 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
7578 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
7579 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
7585 DEFUN (ospf_distance_source
,
7586 ospf_distance_source_cmd
,
7587 "distance (1-255) A.B.C.D/M",
7588 "Administrative distance\n"
7590 "IP source prefix\n")
7592 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7594 int idx_ipv4_prefixlen
= 2;
7599 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7604 DEFUN (no_ospf_distance_source
,
7605 no_ospf_distance_source_cmd
,
7606 "no distance (1-255) A.B.C.D/M",
7608 "Administrative distance\n"
7610 "IP source prefix\n")
7612 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7614 int idx_ipv4_prefixlen
= 3;
7619 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7624 DEFUN (ospf_distance_source_access_list
,
7625 ospf_distance_source_access_list_cmd
,
7626 "distance (1-255) A.B.C.D/M WORD",
7627 "Administrative distance\n"
7629 "IP source prefix\n"
7630 "Access list name\n")
7632 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7634 int idx_ipv4_prefixlen
= 2;
7640 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7645 DEFUN (no_ospf_distance_source_access_list
,
7646 no_ospf_distance_source_access_list_cmd
,
7647 "no distance (1-255) A.B.C.D/M WORD",
7649 "Administrative distance\n"
7651 "IP source prefix\n"
7652 "Access list name\n")
7654 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7656 int idx_ipv4_prefixlen
= 3;
7662 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7668 DEFUN (ip_ospf_mtu_ignore
,
7669 ip_ospf_mtu_ignore_addr_cmd
,
7670 "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
= 1;
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
);
7711 DEFUN (no_ip_ospf_mtu_ignore
,
7712 no_ip_ospf_mtu_ignore_addr_cmd
,
7713 "no ip ospf mtu-ignore [A.B.C.D]",
7715 "OSPF interface commands\n"
7716 "Disable MTU mismatch detection on this interface\n"
7717 "Address of interface")
7719 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7721 struct in_addr addr
;
7724 struct ospf_if_params
*params
;
7725 params
= IF_DEF_PARAMS (ifp
);
7729 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7732 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7736 params
= ospf_get_if_params (ifp
, addr
);
7737 ospf_if_update_params (ifp
, addr
);
7739 params
->mtu_ignore
= 0;
7740 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7741 SET_IF_PARAM (params
, mtu_ignore
);
7744 UNSET_IF_PARAM (params
, mtu_ignore
);
7745 if (params
!= IF_DEF_PARAMS (ifp
))
7747 ospf_free_if_params (ifp
, addr
);
7748 ospf_if_update_params (ifp
, addr
);
7755 DEFUN (ospf_max_metric_router_lsa_admin
,
7756 ospf_max_metric_router_lsa_admin_cmd
,
7757 "max-metric router-lsa administrative",
7758 "OSPF maximum / infinite-distance metric\n"
7759 "Advertise own Router-LSA with infinite distance (stub router)\n"
7760 "Administratively applied, for an indefinite period\n")
7762 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7763 struct listnode
*ln
;
7764 struct ospf_area
*area
;
7766 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7768 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7770 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7771 ospf_router_lsa_update_area (area
);
7774 /* Allows for areas configured later to get the property */
7775 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7780 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7781 no_ospf_max_metric_router_lsa_admin_cmd
,
7782 "no max-metric router-lsa administrative",
7784 "OSPF maximum / infinite-distance metric\n"
7785 "Advertise own Router-LSA with infinite distance (stub router)\n"
7786 "Administratively applied, for an indefinite period\n")
7788 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7789 struct listnode
*ln
;
7790 struct ospf_area
*area
;
7792 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7794 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7796 /* Don't trample on the start-up stub timer */
7797 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7798 && !area
->t_stub_router
)
7800 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7801 ospf_router_lsa_update_area (area
);
7804 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7808 DEFUN (ospf_max_metric_router_lsa_startup
,
7809 ospf_max_metric_router_lsa_startup_cmd
,
7810 "max-metric router-lsa on-startup (5-86400)",
7811 "OSPF maximum / infinite-distance metric\n"
7812 "Advertise own Router-LSA with infinite distance (stub router)\n"
7813 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7814 "Time (seconds) to advertise self as stub-router\n")
7816 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7818 unsigned int seconds
;
7822 vty_out (vty
, "%% Must supply stub-router period");
7826 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7828 ospf
->stub_router_startup_time
= seconds
;
7833 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7834 no_ospf_max_metric_router_lsa_startup_cmd
,
7835 "no max-metric router-lsa on-startup [(5-86400)]",
7837 "OSPF maximum / infinite-distance metric\n"
7838 "Advertise own Router-LSA with infinite distance (stub router)\n"
7839 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7840 "Time (seconds) to advertise self as stub-router\n")
7842 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7843 struct listnode
*ln
;
7844 struct ospf_area
*area
;
7846 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7848 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7850 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7851 OSPF_TIMER_OFF (area
->t_stub_router
);
7853 /* Don't trample on admin stub routed */
7854 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7856 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7857 ospf_router_lsa_update_area (area
);
7864 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7865 ospf_max_metric_router_lsa_shutdown_cmd
,
7866 "max-metric router-lsa on-shutdown (5-100)",
7867 "OSPF maximum / infinite-distance metric\n"
7868 "Advertise own Router-LSA with infinite distance (stub router)\n"
7869 "Advertise stub-router prior to full shutdown of OSPF\n"
7870 "Time (seconds) to wait till full shutdown\n")
7872 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7874 unsigned int seconds
;
7878 vty_out (vty
, "%% Must supply stub-router shutdown period");
7882 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7884 ospf
->stub_router_shutdown_time
= seconds
;
7889 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7890 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7891 "no max-metric router-lsa on-shutdown [(5-100)]",
7893 "OSPF maximum / infinite-distance metric\n"
7894 "Advertise own Router-LSA with infinite distance (stub router)\n"
7895 "Advertise stub-router prior to full shutdown of OSPF\n"
7896 "Time (seconds) to wait till full shutdown\n")
7898 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7900 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7906 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7908 struct listnode
*ln
;
7909 struct ospf_area
*area
;
7911 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7912 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7913 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7914 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7915 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7916 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7917 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7919 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7921 vty_out (vty
, " max-metric router-lsa administrative%s",
7930 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7932 struct route_node
*rn
;
7933 struct ospf_route
*or;
7934 struct listnode
*pnode
, *pnnode
;
7935 struct ospf_path
*path
;
7937 vty_out (vty
, "============ OSPF network routing table ============%s",
7940 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7941 if ((or = rn
->info
) != NULL
)
7944 snprintf (buf1
, 19, "%s/%d",
7945 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7947 switch (or->path_type
)
7949 case OSPF_PATH_INTER_AREA
:
7950 if (or->type
== OSPF_DESTINATION_NETWORK
)
7951 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7952 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7953 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7954 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7956 case OSPF_PATH_INTRA_AREA
:
7957 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7958 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7964 if (or->type
== OSPF_DESTINATION_NETWORK
)
7965 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7967 if (if_lookup_by_index(path
->ifindex
))
7969 if (path
->nexthop
.s_addr
== 0)
7970 vty_out (vty
, "%24s directly attached to %s%s",
7971 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7973 vty_out (vty
, "%24s via %s, %s%s", "",
7974 inet_ntoa (path
->nexthop
),
7975 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7979 vty_out (vty
, "%s", VTY_NEWLINE
);
7983 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7985 struct route_node
*rn
;
7986 struct ospf_route
*or;
7987 struct listnode
*pnode
;
7988 struct listnode
*node
;
7989 struct ospf_path
*path
;
7991 vty_out (vty
, "============ OSPF router routing table =============%s",
7993 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7998 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
8000 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
8003 vty_out (vty
, "%24s", "");
8006 vty_out (vty
, "%s [%d] area: %s",
8007 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
8008 or->cost
, inet_ntoa (or->u
.std
.area_id
));
8010 vty_out (vty
, "%s%s%s",
8011 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
8012 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
8015 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8017 if (if_lookup_by_index(path
->ifindex
))
8019 if (path
->nexthop
.s_addr
== 0)
8020 vty_out (vty
, "%24s directly attached to %s%s",
8021 "", ifindex2ifname (path
->ifindex
),
8024 vty_out (vty
, "%24s via %s, %s%s", "",
8025 inet_ntoa (path
->nexthop
),
8026 ifindex2ifname (path
->ifindex
),
8032 vty_out (vty
, "%s", VTY_NEWLINE
);
8036 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8038 struct route_node
*rn
;
8039 struct ospf_route
*er
;
8040 struct listnode
*pnode
, *pnnode
;
8041 struct ospf_path
*path
;
8043 vty_out (vty
, "============ OSPF external routing table ===========%s",
8045 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8046 if ((er
= rn
->info
) != NULL
)
8049 snprintf (buf1
, 19, "%s/%d",
8050 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8052 switch (er
->path_type
)
8054 case OSPF_PATH_TYPE1_EXTERNAL
:
8055 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8056 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8058 case OSPF_PATH_TYPE2_EXTERNAL
:
8059 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8060 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8064 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8066 if (if_lookup_by_index(path
->ifindex
))
8068 if (path
->nexthop
.s_addr
== 0)
8069 vty_out (vty
, "%24s directly attached to %s%s",
8070 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8072 vty_out (vty
, "%24s via %s, %s%s", "",
8073 inet_ntoa (path
->nexthop
),
8074 ifindex2ifname (path
->ifindex
),
8079 vty_out (vty
, "%s", VTY_NEWLINE
);
8083 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8086 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8087 VTY_NEWLINE
, VTY_NEWLINE
);
8089 if (ospf
->new_table
== NULL
)
8091 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8095 /* Show Network routes.
8096 show_ip_ospf_route_network (vty, ospf->new_table); */
8098 /* Show Router routes. */
8099 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8101 vty_out (vty
, "%s", VTY_NEWLINE
);
8106 DEFUN (show_ip_ospf_border_routers
,
8107 show_ip_ospf_border_routers_cmd
,
8108 "show ip ospf border-routers",
8111 "OSPF information\n"
8112 "Show all the ABR's and ASBR's\n")
8116 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8119 return show_ip_ospf_border_routers_common(vty
, ospf
);
8122 DEFUN (show_ip_ospf_instance_border_routers
,
8123 show_ip_ospf_instance_border_routers_cmd
,
8124 "show ip ospf (1-65535) border-routers",
8127 "OSPF information\n"
8129 "Show all the ABR's and ASBR's\n")
8133 u_short instance
= 0;
8135 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8136 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8139 return show_ip_ospf_border_routers_common(vty
, ospf
);
8143 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8146 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8147 VTY_NEWLINE
, VTY_NEWLINE
);
8149 if (ospf
->new_table
== NULL
)
8151 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8155 /* Show Network routes. */
8156 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8158 /* Show Router routes. */
8159 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8161 /* Show AS External routes. */
8162 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8164 vty_out (vty
, "%s", VTY_NEWLINE
);
8169 DEFUN (show_ip_ospf_route
,
8170 show_ip_ospf_route_cmd
,
8171 "show ip ospf route",
8174 "OSPF information\n"
8175 "OSPF routing table\n")
8179 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8182 return show_ip_ospf_route_common(vty
, ospf
);
8185 DEFUN (show_ip_ospf_instance_route
,
8186 show_ip_ospf_instance_route_cmd
,
8187 "show ip ospf (1-65535) route",
8190 "OSPF information\n"
8192 "OSPF routing table\n")
8196 u_short instance
= 0;
8198 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8199 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8202 return show_ip_ospf_route_common(vty
, ospf
);
8205 const char *ospf_abr_type_str
[] =
8214 const char *ospf_shortcut_mode_str
[] =
8223 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8225 memset (buf
, 0, length
);
8227 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8228 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8230 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8234 const char *ospf_int_type_str
[] =
8236 "unknown", /* should never be used. */
8240 "point-to-multipoint",
8241 "virtual-link", /* should never be used. */
8245 /* Configuration write function for ospfd. */
8247 config_write_interface (struct vty
*vty
)
8249 struct listnode
*n1
, *n2
;
8250 struct interface
*ifp
;
8251 struct crypt_key
*ck
;
8253 struct route_node
*rn
= NULL
;
8254 struct ospf_if_params
*params
;
8255 struct ospf
*ospf
= ospf_lookup();
8257 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8259 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8262 if (ifp
->ifindex
== IFINDEX_DELETED
)
8265 vty_out (vty
, "!%s", VTY_NEWLINE
);
8266 vty_out (vty
, "interface %s%s", ifp
->name
,
8269 vty_out (vty
, " description %s%s", ifp
->desc
,
8274 params
= IF_DEF_PARAMS (ifp
);
8277 /* Interface Network print. */
8278 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8279 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8281 if (params
->type
!= ospf_default_iftype(ifp
))
8283 vty_out (vty
, " ip ospf network %s",
8284 ospf_int_type_str
[params
->type
]);
8285 if (params
!= IF_DEF_PARAMS (ifp
))
8286 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8287 vty_out (vty
, "%s", VTY_NEWLINE
);
8291 /* OSPF interface authentication print */
8292 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8293 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8295 const char *auth_str
;
8297 /* Translation tables are not that much help here due to syntax
8298 of the simple option */
8299 switch (params
->auth_type
)
8302 case OSPF_AUTH_NULL
:
8306 case OSPF_AUTH_SIMPLE
:
8310 case OSPF_AUTH_CRYPTOGRAPHIC
:
8311 auth_str
= " message-digest";
8319 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8320 if (params
!= IF_DEF_PARAMS (ifp
))
8321 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8322 vty_out (vty
, "%s", VTY_NEWLINE
);
8325 /* Simple Authentication Password print. */
8326 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8327 params
->auth_simple
[0] != '\0')
8329 vty_out (vty
, " ip ospf authentication-key %s",
8330 params
->auth_simple
);
8331 if (params
!= IF_DEF_PARAMS (ifp
))
8332 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8333 vty_out (vty
, "%s", VTY_NEWLINE
);
8336 /* Cryptographic Authentication Key print. */
8337 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8339 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8340 ck
->key_id
, ck
->auth_key
);
8341 if (params
!= IF_DEF_PARAMS (ifp
))
8342 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8343 vty_out (vty
, "%s", VTY_NEWLINE
);
8346 /* Interface Output Cost print. */
8347 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8349 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8350 if (params
!= IF_DEF_PARAMS (ifp
))
8351 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8352 vty_out (vty
, "%s", VTY_NEWLINE
);
8355 /* Hello Interval print. */
8356 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8357 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8359 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8360 if (params
!= IF_DEF_PARAMS (ifp
))
8361 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8362 vty_out (vty
, "%s", VTY_NEWLINE
);
8366 /* Router Dead Interval print. */
8367 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8368 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8370 vty_out (vty
, " ip ospf dead-interval ");
8373 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8374 vty_out (vty
, "minimal hello-multiplier %d",
8375 params
->fast_hello
);
8377 vty_out (vty
, "%u", params
->v_wait
);
8379 if (params
!= IF_DEF_PARAMS (ifp
))
8380 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8381 vty_out (vty
, "%s", VTY_NEWLINE
);
8384 /* Router Priority print. */
8385 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8386 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8388 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8389 if (params
!= IF_DEF_PARAMS (ifp
))
8390 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8391 vty_out (vty
, "%s", VTY_NEWLINE
);
8394 /* Retransmit Interval print. */
8395 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8396 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8398 vty_out (vty
, " ip ospf retransmit-interval %u",
8399 params
->retransmit_interval
);
8400 if (params
!= IF_DEF_PARAMS (ifp
))
8401 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8402 vty_out (vty
, "%s", VTY_NEWLINE
);
8405 /* Transmit Delay print. */
8406 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8407 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8409 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8410 if (params
!= IF_DEF_PARAMS (ifp
))
8411 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8412 vty_out (vty
, "%s", VTY_NEWLINE
);
8416 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8419 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8420 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8422 vty_out (vty
, " ip ospf area %s%s",
8423 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8428 ospf_bfd_write_config(vty
, params
);
8430 /* MTU ignore print. */
8431 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8432 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8434 if (params
->mtu_ignore
== 0)
8435 vty_out (vty
, " no ip ospf mtu-ignore");
8437 vty_out (vty
, " ip ospf mtu-ignore");
8438 if (params
!= IF_DEF_PARAMS (ifp
))
8439 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8440 vty_out (vty
, "%s", VTY_NEWLINE
);
8447 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8449 rn
= route_next (rn
);
8459 ospf_opaque_config_write_if (vty
, ifp
);
8466 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8468 struct route_node
*rn
;
8469 u_char buf
[INET_ADDRSTRLEN
];
8471 /* `network area' print. */
8472 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8475 struct ospf_network
*n
= rn
->info
;
8477 memset (buf
, 0, INET_ADDRSTRLEN
);
8479 /* Create Area ID string by specified Area ID format. */
8480 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8481 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8483 sprintf ((char *) buf
, "%lu",
8484 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8486 /* Network print. */
8487 vty_out (vty
, " network %s/%d area %s%s",
8488 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8496 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8498 struct listnode
*node
;
8499 struct ospf_area
*area
;
8500 u_char buf
[INET_ADDRSTRLEN
];
8502 /* Area configuration print. */
8503 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8505 struct route_node
*rn1
;
8507 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8509 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8511 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8512 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8514 vty_out (vty
, " area %s authentication message-digest%s",
8518 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8519 vty_out (vty
, " area %s shortcut %s%s", buf
,
8520 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8523 if ((area
->external_routing
== OSPF_AREA_STUB
)
8524 || (area
->external_routing
== OSPF_AREA_NSSA
)
8527 if (area
->external_routing
== OSPF_AREA_STUB
)
8528 vty_out (vty
, " area %s stub", buf
);
8529 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8531 vty_out (vty
, " area %s nssa", buf
);
8532 switch (area
->NSSATranslatorRole
)
8534 case OSPF_NSSA_ROLE_NEVER
:
8535 vty_out (vty
, " translate-never");
8537 case OSPF_NSSA_ROLE_ALWAYS
:
8538 vty_out (vty
, " translate-always");
8540 case OSPF_NSSA_ROLE_CANDIDATE
:
8542 vty_out (vty
, " translate-candidate");
8546 if (area
->no_summary
)
8547 vty_out (vty
, " no-summary");
8549 vty_out (vty
, "%s", VTY_NEWLINE
);
8551 if (area
->default_cost
!= 1)
8552 vty_out (vty
, " area %s default-cost %d%s", buf
,
8553 area
->default_cost
, VTY_NEWLINE
);
8556 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8559 struct ospf_area_range
*range
= rn1
->info
;
8561 vty_out (vty
, " area %s range %s/%d", buf
,
8562 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8564 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8565 vty_out (vty
, " cost %d", range
->cost_config
);
8567 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8568 vty_out (vty
, " not-advertise");
8570 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8571 vty_out (vty
, " substitute %s/%d",
8572 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8574 vty_out (vty
, "%s", VTY_NEWLINE
);
8577 if (EXPORT_NAME (area
))
8578 vty_out (vty
, " area %s export-list %s%s", buf
,
8579 EXPORT_NAME (area
), VTY_NEWLINE
);
8581 if (IMPORT_NAME (area
))
8582 vty_out (vty
, " area %s import-list %s%s", buf
,
8583 IMPORT_NAME (area
), VTY_NEWLINE
);
8585 if (PREFIX_NAME_IN (area
))
8586 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8587 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8589 if (PREFIX_NAME_OUT (area
))
8590 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8591 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8598 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8600 struct ospf_nbr_nbma
*nbr_nbma
;
8601 struct route_node
*rn
;
8603 /* Static Neighbor configuration print. */
8604 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8605 if ((nbr_nbma
= rn
->info
))
8607 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8609 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8610 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8612 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8613 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8615 vty_out (vty
, "%s", VTY_NEWLINE
);
8622 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8624 struct listnode
*node
;
8625 struct ospf_vl_data
*vl_data
;
8626 u_char buf
[INET_ADDRSTRLEN
];
8628 /* Virtual-Link print */
8629 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8631 struct listnode
*n2
;
8632 struct crypt_key
*ck
;
8633 struct ospf_interface
*oi
;
8635 if (vl_data
!= NULL
)
8637 memset (buf
, 0, INET_ADDRSTRLEN
);
8639 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8640 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8642 sprintf ((char *) buf
, "%lu",
8643 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8644 oi
= vl_data
->vl_oi
;
8647 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8648 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8649 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8650 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8651 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8653 inet_ntoa (vl_data
->vl_peer
),
8654 OSPF_IF_PARAM (oi
, v_hello
),
8655 OSPF_IF_PARAM (oi
, retransmit_interval
),
8656 OSPF_IF_PARAM (oi
, transmit_delay
),
8657 OSPF_IF_PARAM (oi
, v_wait
),
8660 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8661 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8663 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8664 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8666 inet_ntoa (vl_data
->vl_peer
),
8667 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8670 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8672 vty_out (vty
, " area %s virtual-link %s"
8673 " message-digest-key %d md5 %s%s",
8675 inet_ntoa (vl_data
->vl_peer
),
8676 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8686 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8690 /* redistribute print. */
8691 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8693 struct list
*red_list
;
8694 struct listnode
*node
;
8695 struct ospf_redist
*red
;
8697 red_list
= ospf
->redist
[type
];
8701 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8703 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8705 vty_out (vty
, " %d", red
->instance
);
8707 if (red
->dmetric
.value
>= 0)
8708 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8710 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8711 vty_out (vty
, " metric-type 1");
8713 if (ROUTEMAP_NAME (red
))
8714 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8716 vty_out (vty
, "%s", VTY_NEWLINE
);
8724 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8726 if (ospf
->default_metric
!= -1)
8727 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8733 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8736 struct ospf_redist
*red
;
8740 /* distribute-list print. */
8741 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8742 if (DISTRIBUTE_NAME (ospf
, type
))
8743 vty_out (vty
, " distribute-list %s out %s%s",
8744 DISTRIBUTE_NAME (ospf
, type
),
8745 zebra_route_string(type
), VTY_NEWLINE
);
8747 /* default-information print. */
8748 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8750 vty_out (vty
, " default-information originate");
8751 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8752 vty_out (vty
, " always");
8754 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8757 if (red
->dmetric
.value
>= 0)
8758 vty_out (vty
, " metric %d",
8759 red
->dmetric
.value
);
8760 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8761 vty_out (vty
, " metric-type 1");
8763 if (ROUTEMAP_NAME (red
))
8764 vty_out (vty
, " route-map %s",
8765 ROUTEMAP_NAME (red
));
8768 vty_out (vty
, "%s", VTY_NEWLINE
);
8777 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8779 struct route_node
*rn
;
8780 struct ospf_distance
*odistance
;
8782 if (ospf
->distance_all
)
8783 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8785 if (ospf
->distance_intra
8786 || ospf
->distance_inter
8787 || ospf
->distance_external
)
8789 vty_out (vty
, " distance ospf");
8791 if (ospf
->distance_intra
)
8792 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8793 if (ospf
->distance_inter
)
8794 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8795 if (ospf
->distance_external
)
8796 vty_out (vty
, " external %d", ospf
->distance_external
);
8798 vty_out (vty
, "%s", VTY_NEWLINE
);
8801 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8802 if ((odistance
= rn
->info
) != NULL
)
8804 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8805 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8806 odistance
->access_list
? odistance
->access_list
: "",
8812 /* OSPF configuration write function. */
8814 ospf_config_write (struct vty
*vty
)
8817 struct interface
*ifp
;
8818 struct ospf_interface
*oi
;
8819 struct listnode
*node
;
8822 ospf
= ospf_lookup ();
8823 if (ospf
!= NULL
&& ospf
->oi_running
)
8825 /* `router ospf' print. */
8827 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8829 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8833 if (!ospf
->networks
)
8836 /* Router ID print. */
8837 if (ospf
->router_id_static
.s_addr
!= 0)
8838 vty_out (vty
, " ospf router-id %s%s",
8839 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8841 /* ABR type print. */
8842 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8843 vty_out (vty
, " ospf abr-type %s%s",
8844 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8846 /* log-adjacency-changes flag print. */
8847 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8849 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8850 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8854 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8857 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8858 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8859 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8861 /* auto-cost reference-bandwidth configuration. */
8862 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8864 vty_out (vty
, "! Important: ensure reference bandwidth "
8865 "is consistent across all routers%s", VTY_NEWLINE
);
8866 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8867 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8870 /* SPF timers print. */
8871 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8872 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8873 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8874 vty_out (vty
, " timers throttle spf %d %d %d%s",
8875 ospf
->spf_delay
, ospf
->spf_holdtime
,
8876 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8878 /* LSA timers print. */
8879 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8880 vty_out (vty
, " timers throttle lsa all %d%s",
8881 ospf
->min_ls_interval
, VTY_NEWLINE
);
8882 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8883 vty_out (vty
, " timers lsa min-arrival %d%s",
8884 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8886 /* Write multiplier print. */
8887 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8888 vty_out (vty
, " ospf write-multiplier %d%s",
8889 ospf
->write_oi_count
, VTY_NEWLINE
);
8891 /* Max-metric router-lsa print */
8892 config_write_stub_router (vty
, ospf
);
8894 /* SPF refresh parameters print. */
8895 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8896 vty_out (vty
, " refresh timer %d%s",
8897 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8899 /* Redistribute information print. */
8900 config_write_ospf_redistribute (vty
, ospf
);
8902 /* passive-interface print. */
8903 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8904 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8906 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8907 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8908 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8909 ospf
->passive_interface_default
)
8911 vty_out (vty
, " %spassive-interface %s%s",
8912 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8913 ifp
->name
, VTY_NEWLINE
);
8915 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8917 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8919 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8922 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8925 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8928 vty_out (vty
, " %spassive-interface %s %s%s",
8929 oi
->params
->passive_interface
? "" : "no ",
8931 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8934 /* Network area print. */
8935 config_write_network_area (vty
, ospf
);
8937 /* Area config print. */
8938 config_write_ospf_area (vty
, ospf
);
8940 /* static neighbor print. */
8941 config_write_ospf_nbr_nbma (vty
, ospf
);
8943 /* Virtual-Link print. */
8944 config_write_virtual_link (vty
, ospf
);
8946 /* Default metric configuration. */
8947 config_write_ospf_default_metric (vty
, ospf
);
8949 /* Distribute-list and default-information print. */
8950 config_write_ospf_distribute (vty
, ospf
);
8952 /* Distance configuration. */
8953 config_write_ospf_distance (vty
, ospf
);
8955 ospf_opaque_config_write_router (vty
, ospf
);
8962 ospf_vty_show_init (void)
8964 /* "show ip ospf" commands. */
8965 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8967 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8969 /* "show ip ospf database" commands. */
8970 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8971 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8973 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8974 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8975 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8977 /* "show ip ospf interface" commands. */
8978 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8980 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8982 /* "show ip ospf neighbor" commands. */
8983 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8984 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8985 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8986 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8987 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8988 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8989 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8991 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8992 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8993 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8994 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8995 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8996 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8997 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8999 /* "show ip ospf route" commands. */
9000 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
9001 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
9003 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
9004 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9008 /* ospfd's interface node. */
9009 static struct cmd_node interface_node
=
9016 /* Initialization of OSPF interface. */
9018 ospf_vty_if_init (void)
9020 /* Install interface node. */
9021 install_node (&interface_node
, config_write_interface
);
9024 /* "ip ospf authentication" commands. */
9025 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9026 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9027 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9028 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9029 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9030 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9031 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9033 /* "ip ospf message-digest-key" commands. */
9034 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9035 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9037 /* "ip ospf cost" commands. */
9038 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9039 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9041 /* "ip ospf mtu-ignore" commands. */
9042 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9043 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9045 /* "ip ospf dead-interval" commands. */
9046 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9047 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9048 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9050 /* "ip ospf hello-interval" commands. */
9051 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9052 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9054 /* "ip ospf network" commands. */
9055 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9056 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9058 /* "ip ospf priority" commands. */
9059 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9060 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9062 /* "ip ospf retransmit-interval" commands. */
9063 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9064 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9066 /* "ip ospf transmit-delay" commands. */
9067 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9068 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9070 /* "ip ospf area" commands. */
9071 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9072 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9074 /* These commands are compatibitliy for previous version. */
9075 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9076 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9077 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9078 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9079 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9080 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9081 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9082 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9083 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9084 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9085 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9086 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9087 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9088 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9089 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9090 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9091 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9095 ospf_vty_zebra_init (void)
9097 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9098 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9099 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9100 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9102 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9103 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9105 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9106 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9108 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9109 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9111 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9112 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9113 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9114 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9116 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9117 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9118 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9119 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9123 static struct cmd_node ospf_node
=
9126 "%s(config-router)# ",
9131 ospf_interface_clear (struct interface
*ifp
)
9133 if (!if_is_operative (ifp
)) return;
9135 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9136 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
9141 DEFUN (clear_ip_ospf_interface
,
9142 clear_ip_ospf_interface_cmd
,
9143 "clear ip ospf interface [IFNAME]",
9146 "OSPF information\n"
9147 "Interface information\n"
9151 struct interface
*ifp
;
9152 struct listnode
*node
;
9154 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9156 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9157 ospf_interface_clear(ifp
);
9159 else /* Interface name is specified. */
9161 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
9162 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9164 ospf_interface_clear(ifp
);
9171 ospf_vty_clear_init (void)
9173 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9177 /* Install OSPF related vty commands. */
9179 ospf_vty_init (void)
9181 /* Install ospf top node. */
9182 install_node (&ospf_node
, ospf_config_write
);
9184 /* "router ospf" commands. */
9185 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9186 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9189 install_default (OSPF_NODE
);
9191 /* "ospf router-id" commands. */
9192 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9193 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9194 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9196 /* "passive-interface" commands. */
9197 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9198 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9200 /* "ospf abr-type" commands. */
9201 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9202 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9204 /* "ospf log-adjacency-changes" commands. */
9205 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9206 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9207 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9208 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9210 /* "ospf rfc1583-compatible" commands. */
9211 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9212 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9213 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9214 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9216 /* "network area" commands. */
9217 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9218 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9220 /* "area authentication" commands. */
9221 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9222 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9223 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9225 /* "area range" commands. */
9226 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9227 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9228 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9229 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9230 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9231 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9233 /* "area virtual-link" commands. */
9234 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9235 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9236 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9237 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9248 /* "area stub" commands. */
9249 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9250 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9251 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9252 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9254 /* "area nssa" commands. */
9255 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9256 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9257 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9258 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9259 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9261 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9262 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9264 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9265 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9267 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9268 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9270 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9271 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9273 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9274 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9276 /* SPF timer commands */
9277 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9278 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9280 /* LSA timers commands */
9281 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9282 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9283 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9284 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9285 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9286 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9288 /* refresh timer commands */
9289 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9290 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9292 /* max-metric commands */
9293 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9294 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9295 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9296 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9297 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9298 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9300 /* reference bandwidth commands */
9301 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9302 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9304 /* "neighbor" commands. */
9305 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9306 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9307 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9308 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9310 /* write multiplier commands */
9311 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9312 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9313 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9314 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9316 /* Init interface related vty commands. */
9317 ospf_vty_if_init ();
9319 /* Init zebra related vty commands. */
9320 ospf_vty_zebra_init ();