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 */
1107 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1108 if (vl_config
.crypto_key_id
< 0)
1111 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1112 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1113 vl_config
.md5_key
= md5_key
;
1120 /* Action configuration */
1122 return ospf_vl_set (ospf
, &vl_config
);
1126 DEFUN (ospf_area_vlink_intervals
,
1127 ospf_area_vlink_intervals_cmd
,
1128 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1129 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1130 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1131 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1132 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1134 VLINK_HELPSTR_IPADDR
1135 VLINK_HELPSTR_TIME_PARAM
1136 VLINK_HELPSTR_TIME_PARAM
1137 VLINK_HELPSTR_TIME_PARAM
1138 VLINK_HELPSTR_TIME_PARAM
)
1140 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1141 struct ospf_vl_config_data vl_config
;
1144 ospf_vl_config_data_init(&vl_config
, vty
);
1146 char *area_id
= argv
[1]->arg
;
1147 char *router_id
= argv
[3]->arg
;
1149 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1152 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1156 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1159 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1162 for (unsigned int i
= 0; i
< 4; i
++)
1165 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1166 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1167 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1168 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1169 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1170 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1171 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1172 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1175 /* Action configuration */
1176 return ospf_vl_set (ospf
, &vl_config
);
1179 DEFUN (no_ospf_area_vlink
,
1180 no_ospf_area_vlink_cmd
,
1181 "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>]",
1183 VLINK_HELPSTR_IPADDR
1184 "Enable authentication on this virtual link\n" \
1185 "Use null authentication\n" \
1186 "Use message-digest authentication\n"
1187 "Message digest authentication password (key)\n" \
1189 "Use MD5 algorithm\n" \
1190 "The OSPF password (key)")
1192 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1193 int idx_ipv4_number
= 2;
1195 struct ospf_area
*area
;
1196 struct ospf_vl_config_data vl_config
;
1197 struct ospf_vl_data
*vl_data
= NULL
;
1198 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1202 ospf_vl_config_data_init(&vl_config
, vty
);
1204 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1207 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1211 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1214 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1218 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1221 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1228 /* Basic VLink no command */
1229 /* Thats all folks! - BUGS B. strikes again!!!*/
1230 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1231 ospf_vl_delete (ospf
, vl_data
);
1233 ospf_area_check_free (ospf
, vl_config
.area_id
);
1238 /* If we are down here, we are reseting parameters */
1240 /* Deal with other parameters */
1241 for (i
=6; argc
; i
++)
1243 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1245 switch (argv
[i
]->arg
[0])
1249 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1251 /* authentication-key - this option can occur anywhere on
1252 command line. At start of command line
1253 must check for authentication option. */
1254 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1255 vl_config
.auth_key
= auth_key
;
1257 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1259 /* authentication - this option can only occur at start
1261 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1266 /* message-digest-key */
1267 /* Delete one key */
1271 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1272 if (vl_config
.crypto_key_id
< 0)
1274 vl_config
.md5_key
= NULL
;
1284 /* Action configuration */
1286 return ospf_vl_set (ospf
, &vl_config
);
1289 DEFUN (no_ospf_area_vlink_intervals
,
1290 no_ospf_area_vlink_intervals_cmd
,
1291 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1292 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1293 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1294 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1295 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1298 VLINK_HELPSTR_IPADDR
1299 VLINK_HELPSTR_TIME_PARAM
1300 VLINK_HELPSTR_TIME_PARAM
1301 VLINK_HELPSTR_TIME_PARAM
1302 VLINK_HELPSTR_TIME_PARAM
)
1304 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1305 struct ospf_vl_config_data vl_config
;
1308 ospf_vl_config_data_init(&vl_config
, vty
);
1310 char *area_id
= argv
[2]->arg
;
1311 char *router_id
= argv
[4]->arg
;
1313 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1316 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1320 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1323 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1327 for (unsigned int i
= 0; i
< 4; i
++)
1330 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1331 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1332 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1333 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1334 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1335 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1336 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1337 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1340 /* Action configuration */
1341 return ospf_vl_set (ospf
, &vl_config
);
1344 DEFUN (ospf_area_shortcut
,
1345 ospf_area_shortcut_cmd
,
1346 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1347 "OSPF area parameters\n"
1348 "OSPF area ID in IP address format\n"
1349 "OSPF area ID as a decimal value\n"
1350 "Configure the area's shortcutting mode\n"
1351 "Set default shortcutting behavior\n"
1352 "Enable shortcutting through the area\n"
1353 "Disable shortcutting through the area\n")
1355 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1356 int idx_ipv4_number
= 1;
1357 int idx_enable_disable
= 3;
1358 struct ospf_area
*area
;
1359 struct in_addr area_id
;
1363 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1365 area
= ospf_area_get (ospf
, area_id
, format
);
1367 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1368 mode
= OSPF_SHORTCUT_DEFAULT
;
1369 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1370 mode
= OSPF_SHORTCUT_DISABLE
;
1371 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1372 mode
= OSPF_SHORTCUT_ENABLE
;
1376 ospf_area_shortcut_set (ospf
, area
, mode
);
1378 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1379 vty_out (vty
, "Shortcut area setting will take effect "
1380 "only when the router is configured as Shortcut ABR%s",
1386 DEFUN (no_ospf_area_shortcut
,
1387 no_ospf_area_shortcut_cmd
,
1388 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1390 "OSPF area parameters\n"
1391 "OSPF area ID in IP address format\n"
1392 "OSPF area ID as a decimal value\n"
1393 "Deconfigure the area's shortcutting mode\n"
1394 "Deconfigure enabled shortcutting through the area\n"
1395 "Deconfigure disabled shortcutting through the area\n")
1397 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1398 int idx_ipv4_number
= 2;
1399 struct ospf_area
*area
;
1400 struct in_addr area_id
;
1403 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1405 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1409 ospf_area_shortcut_unset (ospf
, area
);
1415 DEFUN (ospf_area_stub
,
1417 "area <A.B.C.D|(0-4294967295)> stub",
1418 "OSPF area parameters\n"
1419 "OSPF area ID in IP address format\n"
1420 "OSPF area ID as a decimal value\n"
1421 "Configure OSPF area as stub\n")
1423 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1424 int idx_ipv4_number
= 1;
1425 struct in_addr area_id
;
1428 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1430 ret
= ospf_area_stub_set (ospf
, area_id
);
1433 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1438 ospf_area_no_summary_unset (ospf
, area_id
);
1443 DEFUN (ospf_area_stub_no_summary
,
1444 ospf_area_stub_no_summary_cmd
,
1445 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1446 "OSPF stub parameters\n"
1447 "OSPF area ID in IP address format\n"
1448 "OSPF area ID as a decimal value\n"
1449 "Configure OSPF area as stub\n"
1450 "Do not inject inter-area routes into stub\n")
1452 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1453 int idx_ipv4_number
= 1;
1454 struct in_addr area_id
;
1457 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1459 ret
= ospf_area_stub_set (ospf
, area_id
);
1462 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1467 ospf_area_no_summary_set (ospf
, area_id
);
1472 DEFUN (no_ospf_area_stub
,
1473 no_ospf_area_stub_cmd
,
1474 "no area <A.B.C.D|(0-4294967295)> stub",
1476 "OSPF area parameters\n"
1477 "OSPF area ID in IP address format\n"
1478 "OSPF area ID as a decimal value\n"
1479 "Configure OSPF area as stub\n")
1481 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1482 int idx_ipv4_number
= 2;
1483 struct in_addr area_id
;
1486 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1488 ospf_area_stub_unset (ospf
, area_id
);
1489 ospf_area_no_summary_unset (ospf
, area_id
);
1494 DEFUN (no_ospf_area_stub_no_summary
,
1495 no_ospf_area_stub_no_summary_cmd
,
1496 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1498 "OSPF area parameters\n"
1499 "OSPF area ID in IP address format\n"
1500 "OSPF area ID as a decimal value\n"
1501 "Configure OSPF area as stub\n"
1502 "Do not inject inter-area routes into area\n")
1504 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1505 int idx_ipv4_number
= 2;
1506 struct in_addr area_id
;
1509 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1510 ospf_area_no_summary_unset (ospf
, area_id
);
1516 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1519 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1520 struct in_addr area_id
;
1523 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1525 ret
= ospf_area_nssa_set (ospf
, area_id
);
1528 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1535 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1536 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1537 OSPF_NSSA_ROLE_CANDIDATE
);
1538 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1539 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1540 OSPF_NSSA_ROLE_NEVER
);
1541 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1542 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1543 OSPF_NSSA_ROLE_ALWAYS
);
1547 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1548 OSPF_NSSA_ROLE_CANDIDATE
);
1552 ospf_area_no_summary_set (ospf
, area_id
);
1554 ospf_area_no_summary_unset (ospf
, area_id
);
1556 ospf_schedule_abr_task (ospf
);
1561 DEFUN (ospf_area_nssa_translate_no_summary
,
1562 ospf_area_nssa_translate_no_summary_cmd
,
1563 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1564 "OSPF area parameters\n"
1565 "OSPF area ID in IP address format\n"
1566 "OSPF area ID as a decimal value\n"
1567 "Configure OSPF area as nssa\n"
1568 "Configure NSSA-ABR for translate election (default)\n"
1569 "Configure NSSA-ABR to never translate\n"
1570 "Configure NSSA-ABR to always translate\n"
1571 "Do not inject inter-area routes into nssa\n")
1573 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1576 DEFUN (ospf_area_nssa_translate
,
1577 ospf_area_nssa_translate_cmd
,
1578 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1579 "OSPF area parameters\n"
1580 "OSPF area ID in IP address format\n"
1581 "OSPF area ID as a decimal value\n"
1582 "Configure OSPF area as nssa\n"
1583 "Configure NSSA-ABR for translate election (default)\n"
1584 "Configure NSSA-ABR to never translate\n"
1585 "Configure NSSA-ABR to always translate\n")
1587 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1590 DEFUN (ospf_area_nssa
,
1592 "area <A.B.C.D|(0-4294967295)> nssa",
1593 "OSPF area parameters\n"
1594 "OSPF area ID in IP address format\n"
1595 "OSPF area ID as a decimal value\n"
1596 "Configure OSPF area as nssa\n")
1598 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1601 DEFUN (ospf_area_nssa_no_summary
,
1602 ospf_area_nssa_no_summary_cmd
,
1603 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1604 "OSPF area parameters\n"
1605 "OSPF area ID in IP address format\n"
1606 "OSPF area ID as a decimal value\n"
1607 "Configure OSPF area as nssa\n"
1608 "Do not inject inter-area routes into nssa\n")
1610 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1613 DEFUN (no_ospf_area_nssa
,
1614 no_ospf_area_nssa_cmd
,
1615 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1617 "OSPF area parameters\n"
1618 "OSPF area ID in IP address format\n"
1619 "OSPF area ID as a decimal value\n"
1620 "Configure OSPF area as nssa\n"
1621 "Configure NSSA-ABR for translate election (default)\n"
1622 "Configure NSSA-ABR to never translate\n"
1623 "Configure NSSA-ABR to always translate\n"
1624 "Do not inject inter-area routes into nssa\n")
1626 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1627 int idx_ipv4_number
= 2;
1628 struct in_addr area_id
;
1631 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1633 ospf_area_nssa_unset (ospf
, area_id
);
1634 ospf_area_no_summary_unset (ospf
, area_id
);
1636 ospf_schedule_abr_task (ospf
);
1642 DEFUN (ospf_area_default_cost
,
1643 ospf_area_default_cost_cmd
,
1644 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1645 "OSPF area parameters\n"
1646 "OSPF area ID in IP address format\n"
1647 "OSPF area ID as a decimal value\n"
1648 "Set the summary-default cost of a NSSA or stub area\n"
1649 "Stub's advertised default summary cost\n")
1651 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1652 int idx_ipv4_number
= 1;
1654 struct ospf_area
*area
;
1655 struct in_addr area_id
;
1658 struct prefix_ipv4 p
;
1660 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1661 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1663 area
= ospf_area_get (ospf
, area_id
, format
);
1665 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1667 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1671 area
->default_cost
= cost
;
1674 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1676 if (IS_DEBUG_OSPF_EVENT
)
1677 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1678 "announcing 0.0.0.0/0 to area %s",
1679 inet_ntoa (area
->area_id
));
1680 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1685 DEFUN (no_ospf_area_default_cost
,
1686 no_ospf_area_default_cost_cmd
,
1687 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1689 "OSPF area parameters\n"
1690 "OSPF area ID in IP address format\n"
1691 "OSPF area ID as a decimal value\n"
1692 "Set the summary-default cost of a NSSA or stub area\n"
1693 "Stub's advertised default summary cost\n")
1695 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1696 int idx_ipv4_number
= 2;
1698 struct ospf_area
*area
;
1699 struct in_addr area_id
;
1701 struct prefix_ipv4 p
;
1703 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1704 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1706 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1710 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1712 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1716 area
->default_cost
= 1;
1719 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1721 if (IS_DEBUG_OSPF_EVENT
)
1722 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1723 "announcing 0.0.0.0/0 to area %s",
1724 inet_ntoa (area
->area_id
));
1725 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1728 ospf_area_check_free (ospf
, area_id
);
1733 DEFUN (ospf_area_export_list
,
1734 ospf_area_export_list_cmd
,
1735 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1736 "OSPF area parameters\n"
1737 "OSPF area ID in IP address format\n"
1738 "OSPF area ID as a decimal value\n"
1739 "Set the filter for networks announced to other areas\n"
1740 "Name of the access-list\n")
1742 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1743 int idx_ipv4_number
= 1;
1744 struct ospf_area
*area
;
1745 struct in_addr area_id
;
1748 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1750 area
= ospf_area_get (ospf
, area_id
, format
);
1751 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1756 DEFUN (no_ospf_area_export_list
,
1757 no_ospf_area_export_list_cmd
,
1758 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1760 "OSPF area parameters\n"
1761 "OSPF area ID in IP address format\n"
1762 "OSPF area ID as a decimal value\n"
1763 "Unset the filter for networks announced to other areas\n"
1764 "Name of the access-list\n")
1766 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1767 int idx_ipv4_number
= 2;
1768 struct ospf_area
*area
;
1769 struct in_addr area_id
;
1772 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1774 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1778 ospf_area_export_list_unset (ospf
, area
);
1784 DEFUN (ospf_area_import_list
,
1785 ospf_area_import_list_cmd
,
1786 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1787 "OSPF area parameters\n"
1788 "OSPF area ID in IP address format\n"
1789 "OSPF area ID as a decimal value\n"
1790 "Set the filter for networks from other areas announced to the specified one\n"
1791 "Name of the access-list\n")
1793 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1794 int idx_ipv4_number
= 1;
1795 struct ospf_area
*area
;
1796 struct in_addr area_id
;
1799 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1801 area
= ospf_area_get (ospf
, area_id
, format
);
1802 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1807 DEFUN (no_ospf_area_import_list
,
1808 no_ospf_area_import_list_cmd
,
1809 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1811 "OSPF area parameters\n"
1812 "OSPF area ID in IP address format\n"
1813 "OSPF area ID as a decimal value\n"
1814 "Unset the filter for networks announced to other areas\n"
1815 "Name of the access-list\n")
1817 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1818 int idx_ipv4_number
= 2;
1819 struct ospf_area
*area
;
1820 struct in_addr area_id
;
1823 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1825 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1829 ospf_area_import_list_unset (ospf
, area
);
1834 DEFUN (ospf_area_filter_list
,
1835 ospf_area_filter_list_cmd
,
1836 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1837 "OSPF area parameters\n"
1838 "OSPF area ID in IP address format\n"
1839 "OSPF area ID as a decimal value\n"
1840 "Filter networks between OSPF areas\n"
1841 "Filter prefixes between OSPF areas\n"
1842 "Name of an IP prefix-list\n"
1843 "Filter networks sent to this area\n"
1844 "Filter networks sent from this area\n")
1846 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1847 int idx_ipv4_number
= 1;
1850 struct ospf_area
*area
;
1851 struct in_addr area_id
;
1852 struct prefix_list
*plist
;
1855 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1857 area
= ospf_area_get (ospf
, area_id
, format
);
1858 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1859 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1861 PREFIX_LIST_IN (area
) = plist
;
1862 if (PREFIX_NAME_IN (area
))
1863 free (PREFIX_NAME_IN (area
));
1865 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1866 ospf_schedule_abr_task (ospf
);
1870 PREFIX_LIST_OUT (area
) = plist
;
1871 if (PREFIX_NAME_OUT (area
))
1872 free (PREFIX_NAME_OUT (area
));
1874 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1875 ospf_schedule_abr_task (ospf
);
1881 DEFUN (no_ospf_area_filter_list
,
1882 no_ospf_area_filter_list_cmd
,
1883 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1885 "OSPF area parameters\n"
1886 "OSPF area ID in IP address format\n"
1887 "OSPF area ID as a decimal value\n"
1888 "Filter networks between OSPF areas\n"
1889 "Filter prefixes between OSPF areas\n"
1890 "Name of an IP prefix-list\n"
1891 "Filter networks sent to this area\n"
1892 "Filter networks sent from this area\n")
1894 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1895 int idx_ipv4_number
= 2;
1898 struct ospf_area
*area
;
1899 struct in_addr area_id
;
1902 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1904 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1907 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1909 if (PREFIX_NAME_IN (area
))
1910 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1913 PREFIX_LIST_IN (area
) = NULL
;
1914 if (PREFIX_NAME_IN (area
))
1915 free (PREFIX_NAME_IN (area
));
1917 PREFIX_NAME_IN (area
) = NULL
;
1919 ospf_schedule_abr_task (ospf
);
1923 if (PREFIX_NAME_OUT (area
))
1924 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1927 PREFIX_LIST_OUT (area
) = NULL
;
1928 if (PREFIX_NAME_OUT (area
))
1929 free (PREFIX_NAME_OUT (area
));
1931 PREFIX_NAME_OUT (area
) = NULL
;
1933 ospf_schedule_abr_task (ospf
);
1940 DEFUN (ospf_area_authentication_message_digest
,
1941 ospf_area_authentication_message_digest_cmd
,
1942 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1943 "OSPF area parameters\n"
1944 "OSPF area ID in IP address format\n"
1945 "OSPF area ID as a decimal value\n"
1946 "Enable authentication\n"
1947 "Use message-digest authentication\n")
1949 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1950 int idx_ipv4_number
= 1;
1951 struct ospf_area
*area
;
1952 struct in_addr area_id
;
1955 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1957 area
= ospf_area_get (ospf
, area_id
, format
);
1958 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1963 DEFUN (ospf_area_authentication
,
1964 ospf_area_authentication_cmd
,
1965 "area <A.B.C.D|(0-4294967295)> authentication",
1966 "OSPF area parameters\n"
1967 "OSPF area ID in IP address format\n"
1968 "OSPF area ID as a decimal value\n"
1969 "Enable authentication\n")
1971 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1972 int idx_ipv4_number
= 1;
1973 struct ospf_area
*area
;
1974 struct in_addr area_id
;
1977 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1979 area
= ospf_area_get (ospf
, area_id
, format
);
1980 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1985 DEFUN (no_ospf_area_authentication
,
1986 no_ospf_area_authentication_cmd
,
1987 "no area <A.B.C.D|(0-4294967295)> authentication",
1989 "OSPF area parameters\n"
1990 "OSPF area ID in IP address format\n"
1991 "OSPF area ID as a decimal value\n"
1992 "Enable authentication\n")
1994 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1995 int idx_ipv4_number
= 2;
1996 struct ospf_area
*area
;
1997 struct in_addr area_id
;
2000 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2002 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2006 area
->auth_type
= OSPF_AUTH_NULL
;
2008 ospf_area_check_free (ospf
, area_id
);
2014 DEFUN (ospf_abr_type
,
2016 "ospf abr-type <cisco|ibm|shortcut|standard>",
2017 "OSPF specific commands\n"
2018 "Set OSPF ABR type\n"
2019 "Alternative ABR, cisco implementation\n"
2020 "Alternative ABR, IBM implementation\n"
2022 "Standard behavior (RFC2328)\n")
2024 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2026 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2028 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2029 abr_type
= OSPF_ABR_CISCO
;
2030 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2031 abr_type
= OSPF_ABR_IBM
;
2032 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2033 abr_type
= OSPF_ABR_SHORTCUT
;
2034 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2035 abr_type
= OSPF_ABR_STAND
;
2039 /* If ABR type value is changed, schedule ABR task. */
2040 if (ospf
->abr_type
!= abr_type
)
2042 ospf
->abr_type
= abr_type
;
2043 ospf_schedule_abr_task (ospf
);
2049 DEFUN (no_ospf_abr_type
,
2050 no_ospf_abr_type_cmd
,
2051 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2053 "OSPF specific commands\n"
2054 "Set OSPF ABR type\n"
2055 "Alternative ABR, cisco implementation\n"
2056 "Alternative ABR, IBM implementation\n"
2060 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2062 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2064 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2065 abr_type
= OSPF_ABR_CISCO
;
2066 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2067 abr_type
= OSPF_ABR_IBM
;
2068 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2069 abr_type
= OSPF_ABR_SHORTCUT
;
2070 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2071 abr_type
= OSPF_ABR_STAND
;
2075 /* If ABR type value is changed, schedule ABR task. */
2076 if (ospf
->abr_type
== abr_type
)
2078 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2079 ospf_schedule_abr_task (ospf
);
2085 DEFUN (ospf_log_adjacency_changes
,
2086 ospf_log_adjacency_changes_cmd
,
2087 "log-adjacency-changes",
2088 "Log changes in adjacency state\n")
2090 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2092 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2093 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2097 DEFUN (ospf_log_adjacency_changes_detail
,
2098 ospf_log_adjacency_changes_detail_cmd
,
2099 "log-adjacency-changes detail",
2100 "Log changes in adjacency state\n"
2101 "Log all state changes\n")
2103 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2105 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2106 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2110 DEFUN (no_ospf_log_adjacency_changes
,
2111 no_ospf_log_adjacency_changes_cmd
,
2112 "no log-adjacency-changes",
2114 "Log changes in adjacency state\n")
2116 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2118 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2119 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2123 DEFUN (no_ospf_log_adjacency_changes_detail
,
2124 no_ospf_log_adjacency_changes_detail_cmd
,
2125 "no log-adjacency-changes detail",
2127 "Log changes in adjacency state\n"
2128 "Log all state changes\n")
2130 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2132 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2133 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2137 DEFUN (ospf_compatible_rfc1583
,
2138 ospf_compatible_rfc1583_cmd
,
2139 "compatible rfc1583",
2140 "OSPF compatibility list\n"
2141 "compatible with RFC 1583\n")
2143 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2145 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2147 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2148 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2153 DEFUN (no_ospf_compatible_rfc1583
,
2154 no_ospf_compatible_rfc1583_cmd
,
2155 "no compatible rfc1583",
2157 "OSPF compatibility list\n"
2158 "compatible with RFC 1583\n")
2160 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2162 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2164 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2165 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2170 ALIAS (ospf_compatible_rfc1583
,
2171 ospf_rfc1583_flag_cmd
,
2172 "ospf rfc1583compatibility",
2173 "OSPF specific commands\n"
2174 "Enable the RFC1583Compatibility flag\n")
2176 ALIAS (no_ospf_compatible_rfc1583
,
2177 no_ospf_rfc1583_flag_cmd
,
2178 "no ospf rfc1583compatibility",
2180 "OSPF specific commands\n"
2181 "Disable the RFC1583Compatibility flag\n")
2184 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2188 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2190 ospf
->spf_delay
= delay
;
2191 ospf
->spf_holdtime
= hold
;
2192 ospf
->spf_max_holdtime
= max
;
2197 DEFUN (ospf_timers_min_ls_interval
,
2198 ospf_timers_min_ls_interval_cmd
,
2199 "timers throttle lsa all (0-5000)",
2200 "Adjust routing timers\n"
2201 "Throttling adaptive timer\n"
2202 "LSA delay between transmissions\n"
2204 "Delay (msec) between sending LSAs\n")
2206 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2208 unsigned int interval
;
2212 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2216 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2218 ospf
->min_ls_interval
= interval
;
2223 DEFUN (no_ospf_timers_min_ls_interval
,
2224 no_ospf_timers_min_ls_interval_cmd
,
2225 "no timers throttle lsa all [(0-5000)]",
2227 "Adjust routing timers\n"
2228 "Throttling adaptive timer\n"
2229 "LSA delay between transmissions\n"
2231 "Delay (msec) between sending LSAs\n")
2233 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2234 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2240 DEFUN (ospf_timers_min_ls_arrival
,
2241 ospf_timers_min_ls_arrival_cmd
,
2242 "timers lsa arrival (0-1000)",
2243 "Adjust routing timers\n"
2244 "Throttling link state advertisement delays\n"
2245 "OSPF minimum arrival interval delay\n"
2246 "Delay (msec) between accepted LSAs\n")
2248 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2250 unsigned int arrival
;
2254 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2258 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2260 ospf
->min_ls_arrival
= arrival
;
2265 DEFUN (no_ospf_timers_min_ls_arrival
,
2266 no_ospf_timers_min_ls_arrival_cmd
,
2267 "no timers lsa arrival [(0-1000)]",
2269 "Adjust routing timers\n"
2270 "Throttling link state advertisement delays\n"
2271 "OSPF minimum arrival interval delay\n"
2272 "Delay (msec) between accepted LSAs\n")
2274 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2276 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2282 DEFUN (ospf_timers_throttle_spf
,
2283 ospf_timers_throttle_spf_cmd
,
2284 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2285 "Adjust routing timers\n"
2286 "Throttling adaptive timer\n"
2288 "Delay (msec) from first change received till SPF calculation\n"
2289 "Initial hold time (msec) between consecutive SPF calculations\n"
2290 "Maximum hold time (msec)\n")
2293 int idx_number_2
= 4;
2294 int idx_number_3
= 5;
2295 unsigned int delay
, hold
, max
;
2299 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2303 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2304 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2305 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2307 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2310 DEFUN (no_ospf_timers_throttle_spf
,
2311 no_ospf_timers_throttle_spf_cmd
,
2312 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2314 "Adjust routing timers\n"
2315 "Throttling adaptive timer\n"
2317 "Delay (msec) from first change received till SPF calculation\n"
2318 "Initial hold time (msec) between consecutive SPF calculations\n"
2319 "Maximum hold time (msec)\n")
2321 return ospf_timers_spf_set (vty
,
2322 OSPF_SPF_DELAY_DEFAULT
,
2323 OSPF_SPF_HOLDTIME_DEFAULT
,
2324 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2328 DEFUN (ospf_timers_lsa
,
2329 ospf_timers_lsa_cmd
,
2330 "timers lsa min-arrival (0-600000)",
2331 "Adjust routing timers\n"
2333 "Minimum delay in receiving new version of a LSA\n"
2334 "Delay in milliseconds\n")
2336 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2338 unsigned int minarrival
;
2342 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2346 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2348 ospf
->min_ls_arrival
= minarrival
;
2353 DEFUN (no_ospf_timers_lsa
,
2354 no_ospf_timers_lsa_cmd
,
2355 "no timers lsa min-arrival [(0-600000)]",
2357 "Adjust routing timers\n"
2359 "Minimum delay in receiving new version of a LSA\n"
2360 "Delay in milliseconds\n")
2362 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2363 unsigned int minarrival
;
2367 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2369 if (ospf
->min_ls_arrival
!= minarrival
||
2370 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2374 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2379 DEFUN (ospf_neighbor
,
2381 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2383 "Neighbor IP address\n"
2384 "Neighbor Priority\n"
2386 "Dead Neighbor Polling interval\n"
2389 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2393 struct in_addr nbr_addr
;
2394 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2395 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2397 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2400 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2403 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2405 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2408 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2411 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2416 DEFUN (ospf_neighbor_poll_interval
,
2417 ospf_neighbor_poll_interval_cmd
,
2418 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2420 "Neighbor IP address\n"
2421 "Dead Neighbor Polling interval\n"
2423 "OSPF priority of non-broadcast neighbor\n"
2426 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2430 struct in_addr nbr_addr
;
2431 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2432 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2434 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2436 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2439 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2441 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2442 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2445 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2450 DEFUN (no_ospf_neighbor
,
2451 no_ospf_neighbor_cmd
,
2452 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2455 "Neighbor IP address\n"
2456 "Neighbor Priority\n"
2458 "Dead Neighbor Polling interval\n"
2461 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2463 struct in_addr nbr_addr
;
2465 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2467 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2472 DEFUN (no_ospf_neighbor_poll
,
2473 no_ospf_neighbor_poll_cmd
,
2474 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2477 "Neighbor IP address\n"
2478 "Dead Neighbor Polling interval\n"
2480 "Neighbor Priority\n"
2483 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2485 struct in_addr nbr_addr
;
2487 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2489 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2494 DEFUN (ospf_refresh_timer
,
2495 ospf_refresh_timer_cmd
,
2496 "refresh timer (10-1800)",
2497 "Adjust refresh parameters\n"
2498 "Set refresh timer\n"
2499 "Timer value in seconds\n")
2501 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2503 unsigned int interval
;
2505 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2506 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2508 ospf_timers_refresh_set (ospf
, interval
);
2513 DEFUN (no_ospf_refresh_timer
,
2514 no_ospf_refresh_timer_val_cmd
,
2515 "no refresh timer [(10-1800)]",
2517 "Adjust refresh parameters\n"
2518 "Unset refresh timer\n"
2519 "Timer value in seconds\n")
2521 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2523 unsigned int interval
;
2527 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2529 if (ospf
->lsa_refresh_interval
!= interval
||
2530 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2534 ospf_timers_refresh_unset (ospf
);
2540 DEFUN (ospf_auto_cost_reference_bandwidth
,
2541 ospf_auto_cost_reference_bandwidth_cmd
,
2542 "auto-cost reference-bandwidth (1-4294967)",
2543 "Calculate OSPF interface cost according to bandwidth\n"
2544 "Use reference bandwidth method to assign OSPF cost\n"
2545 "The reference bandwidth in terms of Mbits per second\n")
2547 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2550 struct listnode
*node
;
2551 struct interface
*ifp
;
2553 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2554 if (refbw
< 1 || refbw
> 4294967)
2556 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2560 /* If reference bandwidth is changed. */
2561 if ((refbw
) == ospf
->ref_bandwidth
)
2564 ospf
->ref_bandwidth
= refbw
;
2565 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2566 ospf_if_recalculate_output_cost (ifp
);
2571 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2572 no_ospf_auto_cost_reference_bandwidth_cmd
,
2573 "no auto-cost reference-bandwidth [(1-4294967)]",
2575 "Calculate OSPF interface cost according to bandwidth\n"
2576 "Use reference bandwidth method to assign OSPF cost\n"
2577 "The reference bandwidth in terms of Mbits per second\n")
2579 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2580 struct listnode
*node
, *nnode
;
2581 struct interface
*ifp
;
2583 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2586 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2587 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2588 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2590 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2591 ospf_if_recalculate_output_cost (ifp
);
2596 DEFUN (ospf_write_multiplier
,
2597 ospf_write_multiplier_cmd
,
2598 "ospf write-multiplier (1-100)",
2599 "OSPF specific commands\n"
2600 "Write multiplier\n"
2601 "Maximum number of interface serviced per write\n")
2603 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2605 u_int32_t write_oi_count
;
2612 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2613 if (write_oi_count
< 1 || write_oi_count
> 100)
2615 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2619 ospf
->write_oi_count
= write_oi_count
;
2623 ALIAS (ospf_write_multiplier
,
2624 write_multiplier_cmd
,
2625 "write-multiplier (1-100)",
2626 "Write multiplier\n"
2627 "Maximum number of interface serviced per write\n")
2629 DEFUN (no_ospf_write_multiplier
,
2630 no_ospf_write_multiplier_cmd
,
2631 "no ospf write-multiplier (1-100)",
2633 "OSPF specific commands\n"
2634 "Write multiplier\n"
2635 "Maximum number of interface serviced per write\n")
2637 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2639 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2643 ALIAS (no_ospf_write_multiplier
,
2644 no_write_multiplier_cmd
,
2645 "no write-multiplier (1-100)",
2647 "Write multiplier\n"
2648 "Maximum number of interface serviced per write\n")
2650 const char *ospf_abr_type_descr_str
[] =
2653 "Standard (RFC2328)",
2655 "Alternative Cisco",
2656 "Alternative Shortcut"
2659 const char *ospf_shortcut_mode_descr_str
[] =
2667 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2669 json_object
*json_area
= NULL
;
2672 json_area
= json_object_new_object();
2676 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2678 /* Show Area type/mode. */
2679 if (OSPF_IS_AREA_BACKBONE (area
))
2682 json_object_boolean_true_add(json_area
, "backbone");
2684 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2690 if (area
->external_routing
== OSPF_AREA_STUB
)
2692 if (area
->no_summary
)
2693 json_object_boolean_true_add(json_area
, "stubNoSummary");
2694 if (area
->shortcut_configured
)
2695 json_object_boolean_true_add(json_area
, "stubShortcut");
2697 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2699 if (area
->no_summary
)
2700 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2701 if (area
->shortcut_configured
)
2702 json_object_boolean_true_add(json_area
, "nssaShortcut");
2705 json_object_string_add(json_area
,"shortcuttingMode",
2706 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2707 if (area
->shortcut_capability
)
2708 json_object_boolean_true_add(json_area
,"sBitConcensus");
2712 if (area
->external_routing
== OSPF_AREA_STUB
)
2713 vty_out (vty
, " (Stub%s%s)",
2714 area
->no_summary
? ", no summary" : "",
2715 area
->shortcut_configured
? "; " : "");
2716 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2717 vty_out (vty
, " (NSSA%s%s)",
2718 area
->no_summary
? ", no summary" : "",
2719 area
->shortcut_configured
? "; " : "");
2721 vty_out (vty
, "%s", VTY_NEWLINE
);
2722 vty_out (vty
, " Shortcutting mode: %s",
2723 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2724 vty_out (vty
, ", S-bit consensus: %s%s",
2725 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2729 /* Show number of interfaces */
2732 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2733 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2736 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2737 "Active: %d%s", listcount (area
->oiflist
),
2738 area
->act_ints
, VTY_NEWLINE
);
2740 if (area
->external_routing
== OSPF_AREA_NSSA
)
2744 json_object_boolean_true_add(json_area
, "nssa");
2745 if (! IS_OSPF_ABR (area
->ospf
))
2746 json_object_boolean_false_add(json_area
, "abr");
2747 else if (area
->NSSATranslatorState
)
2749 json_object_boolean_true_add(json_area
, "abr");
2750 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2751 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2752 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2753 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2757 json_object_boolean_true_add(json_area
, "abr");
2758 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2759 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2761 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2766 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2767 if (! IS_OSPF_ABR (area
->ospf
))
2768 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2770 else if (area
->NSSATranslatorState
)
2772 vty_out (vty
, " We are an ABR and ");
2773 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2774 vty_out (vty
, "the NSSA Elected Translator. %s",
2776 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2777 vty_out (vty
, "always an NSSA Translator. %s",
2782 vty_out (vty
, " We are an ABR, but ");
2783 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2784 vty_out (vty
, "not the NSSA Elected Translator. %s",
2787 vty_out (vty
, "never an NSSA Translator. %s",
2793 /* Stub-router state for this area */
2794 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2796 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2800 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2801 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2802 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2803 if (area
->t_stub_router
)
2805 struct timeval result
;
2806 unsigned long time_store
= 0;
2807 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
2808 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2809 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2814 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2816 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2817 vty_out (vty
, " Administratively activated (indefinitely)%s",
2819 if (area
->t_stub_router
)
2820 vty_out (vty
, " Active from startup, %s remaining%s",
2821 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2822 sizeof(timebuf
)), VTY_NEWLINE
);
2828 /* Show number of fully adjacent neighbors. */
2829 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2831 /* Show authentication type. */
2832 if (area
->auth_type
== OSPF_AUTH_NULL
)
2833 json_object_string_add(json_area
, "authentication", "authenticationNone");
2834 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2835 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2836 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2837 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2839 if (!OSPF_IS_AREA_BACKBONE (area
))
2840 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2842 /* Show SPF calculation times. */
2843 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2844 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2845 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2846 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2847 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2848 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2849 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2850 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2851 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2852 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2853 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2854 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2858 /* Show number of fully adjacent neighbors. */
2859 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2860 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2862 /* Show authentication type. */
2863 vty_out (vty
, " Area has ");
2864 if (area
->auth_type
== OSPF_AUTH_NULL
)
2865 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2866 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2867 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2868 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2869 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2871 if (!OSPF_IS_AREA_BACKBONE (area
))
2872 vty_out (vty
, " Number of full virtual adjacencies going through"
2873 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2875 /* Show SPF calculation times. */
2876 vty_out (vty
, " SPF algorithm executed %d times%s",
2877 area
->spf_calculation
, VTY_NEWLINE
);
2879 /* Show number of LSA. */
2880 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2881 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2882 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2883 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2884 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2885 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2886 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2887 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2888 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2889 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2890 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2891 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2892 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2893 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2894 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2895 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2900 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2901 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2902 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2903 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2907 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2908 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2909 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2910 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2911 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2912 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2916 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2918 vty_out (vty
, "%s", VTY_NEWLINE
);
2922 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2924 struct listnode
*node
, *nnode
;
2925 struct ospf_area
* area
;
2926 struct timeval result
;
2927 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2928 json_object
*json
= NULL
;
2929 json_object
*json_areas
= NULL
;
2933 json
= json_object_new_object();
2934 json_areas
= json_object_new_object();
2941 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2945 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2946 VTY_NEWLINE
, VTY_NEWLINE
);
2950 /* Show Router ID. */
2953 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2957 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2958 inet_ntoa (ospf
->router_id
),
2962 /* Graceful shutdown */
2963 if (ospf
->t_deferred_shutdown
)
2967 unsigned long time_store
= 0;
2968 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
2969 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2970 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2974 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2975 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2976 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2980 /* Show capability. */
2983 json_object_boolean_true_add(json
, "tosRoutesOnly");
2984 json_object_boolean_true_add(json
, "rfc2328Conform");
2985 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2987 json_object_boolean_true_add(json
, "rfc1583Compatibility");
2992 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
2993 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
2994 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
2995 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
2996 "enabled" : "disabled", VTY_NEWLINE
);
3001 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3003 json_object_boolean_true_add(json
, "opaqueCapable");
3008 vty_out (vty
, " OpaqueCapability flag is %s%s",
3009 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3013 /* Show stub-router configuration */
3014 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3015 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3019 json_object_boolean_true_add(json
, "stubAdvertisement");
3020 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3021 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3022 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3023 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3027 vty_out (vty
, " Stub router advertisement is configured%s",
3029 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3030 vty_out (vty
, " Enabled for %us after start-up%s",
3031 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3032 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3033 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3034 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3038 /* Show SPF timers. */
3041 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3042 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3043 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3044 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3048 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3049 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3050 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3051 " Hold time multiplier is currently %d%s",
3052 ospf
->spf_delay
, VTY_NEWLINE
,
3053 ospf
->spf_holdtime
, VTY_NEWLINE
,
3054 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3055 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3060 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3062 unsigned long time_store
= 0;
3064 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3065 result
= tv_sub (result
, recent_relative_time());
3066 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3067 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3069 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3070 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3073 json_object_boolean_true_add(json
, "spfHasNotRun");
3077 vty_out (vty
, " SPF algorithm ");
3078 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3080 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3081 vty_out (vty
, "last executed %s ago%s",
3082 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3084 vty_out (vty
, " Last SPF duration %s%s",
3085 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3089 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3094 struct timeval temp_time
;
3095 unsigned long time_store
= 0;
3097 if (ospf
->t_spf_calc
)
3099 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3100 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3101 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3104 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3105 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3106 /* Show write multiplier values */
3107 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3108 /* Show refresh parameters. */
3109 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3113 vty_out (vty
, " SPF timer %s%s%s",
3114 (ospf
->t_spf_calc
? "due in " : "is "),
3115 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3118 vty_out (vty
, " LSA minimum interval %d msecs%s",
3119 ospf
->min_ls_interval
, VTY_NEWLINE
);
3120 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3121 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3123 /* Show write multiplier values */
3124 vty_out (vty
, " Write Multiplier set to %d %s",
3125 ospf
->write_oi_count
, VTY_NEWLINE
);
3127 /* Show refresh parameters. */
3128 vty_out (vty
, " Refresh timer %d secs%s",
3129 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3132 /* Show ABR/ASBR flags. */
3133 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3136 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3138 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3139 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3141 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3144 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3146 vty_out (vty
, " This router is an ASBR "
3147 "(injecting external routing information)%s", VTY_NEWLINE
);
3150 /* Show Number of AS-external-LSAs. */
3153 json_object_int_add(json
, "lsaExternalCounter",
3154 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3155 json_object_int_add(json
, "lsaExternalChecksum",
3156 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3160 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3161 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3162 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3167 json_object_int_add(json
, "lsaAsopaqueCounter",
3168 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3169 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3170 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3174 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3175 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3176 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3179 /* Show number of areas attached. */
3181 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3183 vty_out (vty
, " Number of areas attached to this router: %d%s",
3184 listcount (ospf
->areas
), VTY_NEWLINE
);
3186 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3188 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3191 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3193 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3198 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3200 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3203 /* Show each area status. */
3204 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3205 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3209 json_object_object_add(json
, "areas", json_areas
);
3210 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3211 json_object_free(json
);
3214 vty_out (vty
, "%s",VTY_NEWLINE
);
3219 DEFUN (show_ip_ospf
,
3221 "show ip ospf [json]",
3224 "OSPF information\n"
3228 u_char uj
= use_json(argc
, argv
);
3230 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3233 return (show_ip_ospf_common(vty
, ospf
, uj
));
3236 DEFUN (show_ip_ospf_instance
,
3237 show_ip_ospf_instance_cmd
,
3238 "show ip ospf (1-65535) [json]",
3241 "OSPF information\n"
3247 u_short instance
= 0;
3248 u_char uj
= use_json(argc
, argv
);
3250 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3251 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3254 return (show_ip_ospf_common(vty
, ospf
, uj
));
3258 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3259 json_object
*json_interface_sub
, u_char use_json
)
3262 struct ospf_neighbor
*nbr
;
3263 struct route_node
*rn
;
3265 /* Is interface up? */
3268 is_up
= if_is_operative(ifp
);
3270 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3272 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3274 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3275 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3276 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3277 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3281 vty_out (vty
, "%s is %s%s", ifp
->name
,
3282 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3283 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3284 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3288 /* Is interface OSPF enabled? */
3291 if (ospf_oi_count(ifp
) == 0)
3293 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3298 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3302 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3306 if (ospf_oi_count(ifp
) == 0)
3308 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3313 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3319 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3321 struct ospf_interface
*oi
= rn
->info
;
3326 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3329 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3331 vty_out (vty
, " This interface is UNNUMBERED,");
3335 /* Show OSPF interface information. */
3338 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3339 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3342 vty_out (vty
, " Internet Address %s/%d,",
3343 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3345 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3347 struct in_addr
*dest
;
3350 if (CONNECTED_PEER(oi
->connected
)
3351 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3356 /* For Vlinks, showing the peer address is probably more
3357 * * * * * informative than the local interface that is being used
3359 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3360 dest
= &oi
->vl_data
->peer_addr
;
3362 dest
= &oi
->connected
->destination
->u
.prefix4
;
3366 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3367 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3368 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3370 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3373 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3378 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3379 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3380 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3381 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3382 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3383 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3384 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3385 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3386 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3390 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3393 vty_out (vty
, " MTU mismatch detection:%s%s",
3394 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3396 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3397 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3398 oi
->output_cost
, VTY_NEWLINE
);
3400 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3401 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3402 PRIORITY (oi
), VTY_NEWLINE
);
3405 /* Show DR information. */
3406 if (DR (oi
).s_addr
== 0)
3409 vty_out (vty
, " No backup designated router on this network%s",
3414 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3418 vty_out (vty
, " No backup designated router on this network%s",
3425 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3426 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3430 vty_out (vty
, " Backup Designated Router (ID) %s,",
3431 inet_ntoa (nbr
->router_id
));
3432 vty_out (vty
, " Interface Address %s%s",
3433 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3438 /* Next network-LSA sequence number we'll use, if we're elected DR */
3439 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3442 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3444 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3445 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3450 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3451 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3453 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3454 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3455 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3456 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3461 vty_out (vty
, " Multicast group memberships:");
3462 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3463 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3465 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3466 vty_out (vty
, " OSPFAllRouters");
3467 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3468 vty_out (vty
, " OSPFDesignatedRouters");
3471 vty_out (vty
, " <None>");
3472 vty_out (vty
, "%s", VTY_NEWLINE
);
3477 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3478 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3480 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3481 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3482 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3483 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3487 vty_out (vty
, " Timer intervals configured,");
3488 vty_out (vty
, " Hello ");
3489 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3490 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3492 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3493 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3494 OSPF_IF_PARAM (oi
, v_wait
),
3495 OSPF_IF_PARAM (oi
, v_wait
),
3496 OSPF_IF_PARAM (oi
, retransmit_interval
),
3500 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3502 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3505 struct timeval result
;
3506 unsigned long time_store
= 0;
3508 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3514 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3515 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3518 vty_out (vty
, " Hello due in %s%s",
3519 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3522 else /* passive-interface is set */
3525 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3527 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3532 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3533 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3536 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3537 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3539 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3544 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3545 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3547 struct interface
*ifp
;
3548 struct listnode
*node
;
3549 json_object
*json
= NULL
;
3550 json_object
*json_interface_sub
= NULL
;
3554 json
= json_object_new_object();
3555 json_interface_sub
= json_object_new_object();
3561 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3563 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3564 VTY_NEWLINE
, VTY_NEWLINE
);
3567 if (argc
== (iface_argv
+ 1))
3569 /* Show All Interfaces.*/
3570 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3572 if (ospf_oi_count(ifp
))
3574 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3576 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3580 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3584 json
= json_object_new_object();
3585 json_interface_sub
= json_object_new_object ();
3588 /* Show All Interfaces. */
3589 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3591 if (ospf_oi_count(ifp
))
3593 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3595 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3601 /* Interface name is specified. */
3602 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3605 json_object_boolean_true_add(json
, "noSuchIface");
3607 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3611 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3613 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3619 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3620 json_object_free(json
);
3623 vty_out (vty
, "%s", VTY_NEWLINE
);
3628 DEFUN (show_ip_ospf_interface
,
3629 show_ip_ospf_interface_cmd
,
3630 "show ip ospf interface [INTERFACE] [json]",
3633 "OSPF information\n"
3634 "Interface information\n"
3639 u_char uj
= use_json(argc
, argv
);
3641 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3644 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3647 DEFUN (show_ip_ospf_instance_interface
,
3648 show_ip_ospf_instance_interface_cmd
,
3649 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3652 "OSPF information\n"
3654 "Interface information\n"
3660 u_short instance
= 0;
3661 u_char uj
= use_json(argc
, argv
);
3663 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3664 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3667 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3671 show_ip_ospf_neighbour_header (struct vty
*vty
)
3673 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3675 "Neighbor ID", "Pri", "State", "Dead Time",
3676 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3681 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3683 struct route_node
*rn
;
3684 struct ospf_neighbor
*nbr
;
3686 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3687 json_object
*json_neighbor
= NULL
;
3689 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3691 if ((nbr
= rn
->info
))
3693 /* Do not show myself. */
3694 if (nbr
!= oi
->nbr_self
)
3696 /* Down state is not shown. */
3697 if (nbr
->state
!= NSM_Down
)
3701 json_neighbor
= json_object_new_object();
3702 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3704 struct timeval result
;
3705 unsigned long time_store
= 0;
3707 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3708 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3710 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3711 json_object_string_add (json_neighbor
, "state", msgbuf
);
3712 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3713 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3714 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3715 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3716 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3717 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3718 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3719 json_object_object_add(json
, "neighbor", json_neighbor
);
3721 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3725 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3727 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3728 vty_out (vty
, "%-15s %3d %-15s ",
3732 vty_out (vty
, "%-15s %3d %-15s ",
3733 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3736 vty_out (vty
, "%9s ",
3737 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3739 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3740 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3741 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3742 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3752 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3754 struct ospf_interface
*oi
;
3755 struct listnode
*node
;
3756 json_object
*json
= NULL
;
3759 json
= json_object_new_object();
3761 show_ip_ospf_neighbour_header (vty
);
3766 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3768 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3769 VTY_NEWLINE
, VTY_NEWLINE
);
3772 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3773 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3777 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3778 json_object_free(json
);
3781 vty_out (vty
, "%s", VTY_NEWLINE
);
3786 DEFUN (show_ip_ospf_neighbor
,
3787 show_ip_ospf_neighbor_cmd
,
3788 "show ip ospf neighbor [json]",
3791 "OSPF information\n"
3796 u_char uj
= use_json(argc
, argv
);
3798 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3801 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3805 DEFUN (show_ip_ospf_instance_neighbor
,
3806 show_ip_ospf_instance_neighbor_cmd
,
3807 "show ip ospf (1-65535) neighbor [json]",
3810 "OSPF information\n"
3817 u_short instance
= 0;
3818 u_char uj
= use_json(argc
, argv
);
3820 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3821 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3824 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3828 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3830 struct listnode
*node
;
3831 struct ospf_interface
*oi
;
3832 json_object
*json
= NULL
;
3833 json_object
*json_neighbor_sub
= NULL
;
3837 json
= json_object_new_object();
3838 json_neighbor_sub
= json_object_new_object();
3841 show_ip_ospf_neighbour_header (vty
);
3846 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3848 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3849 VTY_NEWLINE
, VTY_NEWLINE
);
3852 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3854 struct listnode
*nbr_node
;
3855 struct ospf_nbr_nbma
*nbr_nbma
;
3857 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3859 /* print Down neighbor status */
3860 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3862 if (nbr_nbma
->nbr
== NULL
3863 || nbr_nbma
->nbr
->state
== NSM_Down
)
3867 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3868 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3869 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3870 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3871 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3872 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3873 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3877 vty_out (vty
, "%-15s %3d %-15s %9s ",
3878 "-", nbr_nbma
->priority
, "Down", "-");
3879 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3880 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3881 0, 0, 0, VTY_NEWLINE
);
3889 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3890 json_object_free(json
);
3893 vty_out (vty
, "%s", VTY_NEWLINE
);
3898 DEFUN (show_ip_ospf_neighbor_all
,
3899 show_ip_ospf_neighbor_all_cmd
,
3900 "show ip ospf neighbor all [json]",
3903 "OSPF information\n"
3905 "include down status neighbor\n"
3909 u_char uj
= use_json(argc
, argv
);
3911 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3914 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3917 DEFUN (show_ip_ospf_instance_neighbor_all
,
3918 show_ip_ospf_instance_neighbor_all_cmd
,
3919 "show ip ospf (1-65535) neighbor all [json]",
3922 "OSPF information\n"
3925 "include down status neighbor\n"
3930 u_short instance
= 0;
3931 u_char uj
= use_json(argc
, argv
);
3933 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3934 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3937 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3941 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3942 struct cmd_token
**argv
, u_char use_json
)
3944 struct interface
*ifp
;
3945 struct route_node
*rn
;
3946 json_object
*json
= NULL
;
3949 json
= json_object_new_object();
3951 show_ip_ospf_neighbour_header (vty
);
3956 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3958 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3959 VTY_NEWLINE
, VTY_NEWLINE
);
3962 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
3966 json_object_boolean_true_add(json
, "noSuchIface");
3968 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3972 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3974 struct ospf_interface
*oi
= rn
->info
;
3979 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3984 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3985 json_object_free(json
);
3988 vty_out (vty
, "%s", VTY_NEWLINE
);
3993 DEFUN (show_ip_ospf_neighbor_int
,
3994 show_ip_ospf_neighbor_int_cmd
,
3995 "show ip ospf neighbor IFNAME [json]",
3998 "OSPF information\n"
4004 u_char uj
= use_json(argc
, argv
);
4006 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4009 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4012 DEFUN (show_ip_ospf_instance_neighbor_int
,
4013 show_ip_ospf_instance_neighbor_int_cmd
,
4014 "show ip ospf (1-65535) neighbor IFNAME [json]",
4017 "OSPF information\n"
4025 u_short instance
= 0;
4026 u_char uj
= use_json(argc
, argv
);
4028 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4029 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4032 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4036 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4037 u_char use_json
, json_object
*json
)
4039 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4040 json_object
*json_sub
= NULL
;
4043 json_sub
= json_object_new_object();
4044 else /* Show neighbor ID. */
4045 vty_out (vty
, " Neighbor %s,", "-");
4047 /* Show interface address. */
4049 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4051 vty_out (vty
, " interface address %s%s",
4052 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4057 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4058 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4061 vty_out (vty
, " In the area %s via interface %s%s",
4062 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4064 /* Show neighbor priority and state. */
4067 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4068 json_object_string_add(json_sub
, "nbrState", "down");
4071 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4072 nbr_nbma
->priority
, "Down");
4074 /* Show state changes. */
4076 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4078 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4080 /* Show PollInterval */
4082 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4084 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4086 /* Show poll-interval timer. */
4089 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4090 unsigned long time_store
= 0;
4091 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4092 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4095 vty_out (vty
, " Poll timer due in %s%s",
4096 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4099 /* Show poll-interval timer thread. */
4102 if (nbr_nbma
->t_poll
!= NULL
)
4103 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4106 vty_out (vty
, " Thread Poll Timer %s%s",
4107 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4110 json_object_object_add(json
, "noNbrId", json_sub
);
4114 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4115 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4117 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4118 json_object
*json_sub
= NULL
;
4121 json_sub
= json_object_new_object();
4124 /* Show neighbor ID. */
4125 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4126 vty_out (vty
, " Neighbor %s,", "-");
4128 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4131 /* Show interface address. */
4133 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4135 vty_out (vty
, " interface address %s%s",
4136 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4141 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4142 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4145 vty_out (vty
, " In the area %s via interface %s%s",
4146 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4148 /* Show neighbor priority and state. */
4151 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4152 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4155 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4156 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4158 /* Show state changes. */
4160 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4162 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4164 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4166 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4169 unsigned long time_store
= 0;
4170 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4171 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4175 vty_out (vty
, " Most recent state change statistics:%s",
4177 vty_out (vty
, " Progressive change %s ago%s",
4178 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4183 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4185 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4188 unsigned long time_store
= 0;
4189 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4190 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4191 if (nbr
->last_regress_str
)
4192 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4196 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4197 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4198 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4203 /* Show Designated Rotuer ID. */
4205 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4207 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4209 /* Show Backup Designated Rotuer ID. */
4211 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4213 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4218 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4219 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4222 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4223 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4225 /* Show Router Dead interval timer. */
4228 if (nbr
->t_inactivity
)
4230 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4231 unsigned long time_store
= 0;
4232 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4233 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4236 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4239 vty_out (vty
, " Dead timer due in %s%s",
4240 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4243 /* Show Database Summary list. */
4245 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4247 vty_out (vty
, " Database Summary List %d%s",
4248 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4250 /* Show Link State Request list. */
4252 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4254 vty_out (vty
, " Link State Request List %ld%s",
4255 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4257 /* Show Link State Retransmission list. */
4259 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4261 vty_out (vty
, " Link State Retransmission List %ld%s",
4262 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4264 /* Show inactivity timer thread. */
4267 if (nbr
->t_inactivity
!= NULL
)
4268 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4271 vty_out (vty
, " Thread Inactivity Timer %s%s",
4272 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4274 /* Show Database Description retransmission thread. */
4277 if (nbr
->t_db_desc
!= NULL
)
4278 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4281 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4282 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4284 /* Show Link State Request Retransmission thread. */
4287 if (nbr
->t_ls_req
!= NULL
)
4288 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4291 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4292 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4294 /* Show Link State Update Retransmission thread. */
4297 if (nbr
->t_ls_upd
!= NULL
)
4298 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4301 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4302 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4306 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4307 json_object_object_add(json
, "noNbrId", json_sub
);
4309 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4312 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4316 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4317 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4319 struct listnode
*node
;
4320 struct ospf_neighbor
*nbr
;
4321 struct ospf_interface
*oi
;
4322 struct in_addr router_id
;
4324 json_object
*json
= NULL
;
4327 json
= json_object_new_object();
4332 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4334 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4335 VTY_NEWLINE
, VTY_NEWLINE
);
4338 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4342 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4346 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4348 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4350 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4356 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4357 json_object_free(json
);
4360 vty_out (vty
, "%s", VTY_NEWLINE
);
4365 DEFUN (show_ip_ospf_neighbor_id
,
4366 show_ip_ospf_neighbor_id_cmd
,
4367 "show ip ospf neighbor A.B.C.D [json]",
4370 "OSPF information\n"
4376 u_char uj
= use_json(argc
, argv
);
4378 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4381 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4384 DEFUN (show_ip_ospf_instance_neighbor_id
,
4385 show_ip_ospf_instance_neighbor_id_cmd
,
4386 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4389 "OSPF information\n"
4397 u_short instance
= 0;
4398 u_char uj
= use_json(argc
, argv
);
4400 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4401 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4404 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4408 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4410 struct ospf_interface
*oi
;
4411 struct listnode
*node
;
4412 json_object
*json
= NULL
;
4415 json
= json_object_new_object();
4420 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4422 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4423 VTY_NEWLINE
, VTY_NEWLINE
);
4426 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4428 struct route_node
*rn
;
4429 struct ospf_neighbor
*nbr
;
4431 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4433 if ((nbr
= rn
->info
))
4435 if (nbr
!= oi
->nbr_self
)
4437 if (nbr
->state
!= NSM_Down
)
4439 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4448 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4449 json_object_free(json
);
4452 vty_out (vty
, "%s", VTY_NEWLINE
);
4457 DEFUN (show_ip_ospf_neighbor_detail
,
4458 show_ip_ospf_neighbor_detail_cmd
,
4459 "show ip ospf neighbor detail [json]",
4462 "OSPF information\n"
4464 "detail of all neighbors\n"
4468 u_char uj
= use_json(argc
, argv
);
4470 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4473 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4476 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4477 show_ip_ospf_instance_neighbor_detail_cmd
,
4478 "show ip ospf (1-65535) neighbor detail [json]",
4481 "OSPF information\n"
4484 "detail of all neighbors\n"
4489 u_short instance
= 0;
4490 u_char uj
= use_json(argc
, argv
);
4492 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4493 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4496 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4500 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4502 struct listnode
*node
;
4503 struct ospf_interface
*oi
;
4504 json_object
*json
= NULL
;
4507 json
= json_object_new_object();
4512 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4514 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4515 VTY_NEWLINE
, VTY_NEWLINE
);
4518 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4520 struct route_node
*rn
;
4521 struct ospf_neighbor
*nbr
;
4522 struct ospf_nbr_nbma
*nbr_nbma
;
4524 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4525 if ((nbr
= rn
->info
))
4526 if (nbr
!= oi
->nbr_self
)
4527 if (nbr
->state
!= NSM_Down
)
4528 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4530 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4532 struct listnode
*nd
;
4534 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4536 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4537 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4544 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4545 json_object_free(json
);
4549 vty_out (vty
, "%s", VTY_NEWLINE
);
4555 DEFUN (show_ip_ospf_neighbor_detail_all
,
4556 show_ip_ospf_neighbor_detail_all_cmd
,
4557 "show ip ospf neighbor detail all [json]",
4560 "OSPF information\n"
4562 "detail of all neighbors\n"
4563 "include down status neighbor\n"
4567 u_char uj
= use_json(argc
, argv
);
4569 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4572 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4575 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4576 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4577 "show ip ospf (1-65535) neighbor detail all [json]",
4580 "OSPF information\n"
4583 "detail of all neighbors\n"
4584 "include down status neighbor\n"
4589 u_short instance
= 0;
4590 u_char uj
= use_json(argc
, argv
);
4592 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4593 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4596 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4600 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4601 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4603 struct ospf_interface
*oi
;
4604 struct interface
*ifp
;
4605 struct route_node
*rn
, *nrn
;
4606 struct ospf_neighbor
*nbr
;
4607 json_object
*json
= NULL
;
4610 json
= json_object_new_object();
4615 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4617 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4618 VTY_NEWLINE
, VTY_NEWLINE
);
4621 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4625 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4629 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4631 if ((oi
= rn
->info
))
4633 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4635 if ((nbr
= nrn
->info
))
4637 if (nbr
!= oi
->nbr_self
)
4639 if (nbr
->state
!= NSM_Down
)
4640 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4649 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4650 json_object_free(json
);
4653 vty_out (vty
, "%s", VTY_NEWLINE
);
4658 DEFUN (show_ip_ospf_neighbor_int_detail
,
4659 show_ip_ospf_neighbor_int_detail_cmd
,
4660 "show ip ospf neighbor IFNAME detail [json]",
4663 "OSPF information\n"
4666 "detail of all neighbors\n"
4670 u_char uj
= use_json(argc
, argv
);
4672 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4675 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4678 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4679 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4680 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4683 "OSPF information\n"
4687 "detail of all neighbors\n"
4692 u_short instance
= 0;
4693 u_char uj
= use_json(argc
, argv
);
4695 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4696 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4699 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4702 /* Show functions */
4704 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4706 struct router_lsa
*rl
;
4707 struct summary_lsa
*sl
;
4708 struct as_external_lsa
*asel
;
4709 struct prefix_ipv4 p
;
4712 /* If self option is set, check LSA self flag. */
4713 if (self
== 0 || IS_LSA_SELF (lsa
))
4715 /* LSA common part show. */
4716 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4717 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4718 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4719 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4720 /* LSA specific part show. */
4721 switch (lsa
->data
->type
)
4723 case OSPF_ROUTER_LSA
:
4724 rl
= (struct router_lsa
*) lsa
->data
;
4725 vty_out (vty
, " %-d", ntohs (rl
->links
));
4727 case OSPF_SUMMARY_LSA
:
4728 sl
= (struct summary_lsa
*) lsa
->data
;
4731 p
.prefix
= sl
->header
.id
;
4732 p
.prefixlen
= ip_masklen (sl
->mask
);
4733 apply_mask_ipv4 (&p
);
4735 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4737 case OSPF_AS_EXTERNAL_LSA
:
4738 case OSPF_AS_NSSA_LSA
:
4739 asel
= (struct as_external_lsa
*) lsa
->data
;
4742 p
.prefix
= asel
->header
.id
;
4743 p
.prefixlen
= ip_masklen (asel
->mask
);
4744 apply_mask_ipv4 (&p
);
4746 vty_out (vty
, " %s %s/%d [0x%lx]",
4747 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4748 inet_ntoa (p
.prefix
), p
.prefixlen
,
4749 (u_long
)ntohl (asel
->e
[0].route_tag
));
4751 case OSPF_NETWORK_LSA
:
4752 case OSPF_ASBR_SUMMARY_LSA
:
4753 case OSPF_OPAQUE_LINK_LSA
:
4754 case OSPF_OPAQUE_AREA_LSA
:
4755 case OSPF_OPAQUE_AS_LSA
:
4759 vty_out (vty
, VTY_NEWLINE
);
4765 static const char *show_database_desc
[] =
4768 "Router Link States",
4770 "Summary Link States",
4771 "ASBR-Summary Link States",
4772 "AS External Link States",
4773 "Group Membership LSA",
4774 "NSSA-external Link States",
4776 "Link-Local Opaque-LSA",
4777 "Area-Local Opaque-LSA",
4778 "AS-external Opaque-LSA",
4781 static const char *show_database_header
[] =
4784 "Link ID ADV Router Age Seq# CkSum Link count",
4785 "Link ID ADV Router Age Seq# CkSum",
4786 "Link ID ADV Router Age Seq# CkSum Route",
4787 "Link ID ADV Router Age Seq# CkSum",
4788 "Link ID ADV Router Age Seq# CkSum Route",
4789 " --- header for Group Member ----",
4790 "Link ID ADV Router Age Seq# CkSum Route",
4792 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4793 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4794 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4798 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4800 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4802 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4803 vty_out (vty
, " Options: 0x%-2x : %s%s",
4805 ospf_options_dump(lsa
->data
->options
),
4807 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4809 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4812 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4814 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4817 vty_out (vty
, " :%s%s%s%s",
4818 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4819 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4820 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4821 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4823 vty_out (vty
, "%s", VTY_NEWLINE
);
4825 vty_out (vty
, " LS Type: %s%s",
4826 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4827 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4828 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4829 vty_out (vty
, " Advertising Router: %s%s",
4830 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4831 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4833 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4835 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4838 const char *link_type_desc
[] =
4841 "another Router (point-to-point)",
4842 "a Transit Network",
4847 const char *link_id_desc
[] =
4850 "Neighboring Router ID",
4851 "Designated Router address",
4853 "Neighboring Router ID",
4856 const char *link_data_desc
[] =
4859 "Router Interface address",
4860 "Router Interface address",
4862 "Router Interface address",
4865 /* Show router-LSA each Link information. */
4867 show_ip_ospf_database_router_links (struct vty
*vty
,
4868 struct router_lsa
*rl
)
4873 len
= ntohs (rl
->header
.length
) - 4;
4874 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4876 type
= rl
->link
[i
].type
;
4878 vty_out (vty
, " Link connected to: %s%s",
4879 link_type_desc
[type
], VTY_NEWLINE
);
4880 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4881 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4882 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4883 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4884 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4885 vty_out (vty
, " TOS 0 Metric: %d%s",
4886 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4887 vty_out (vty
, "%s", VTY_NEWLINE
);
4891 /* Show router-LSA detail information. */
4893 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4897 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4899 show_ip_ospf_database_header (vty
, lsa
);
4901 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4902 VTY_NEWLINE
, VTY_NEWLINE
);
4904 show_ip_ospf_database_router_links (vty
, rl
);
4905 vty_out (vty
, "%s", VTY_NEWLINE
);
4911 /* Show network-LSA detail information. */
4913 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4919 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4921 show_ip_ospf_database_header (vty
, lsa
);
4923 vty_out (vty
, " Network Mask: /%d%s",
4924 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4926 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4928 for (i
= 0; length
> 0; i
++, length
-= 4)
4929 vty_out (vty
, " Attached Router: %s%s",
4930 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4932 vty_out (vty
, "%s", VTY_NEWLINE
);
4938 /* Show summary-LSA detail information. */
4940 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4944 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4946 show_ip_ospf_database_header (vty
, lsa
);
4948 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4950 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4952 vty_out (vty
, "%s", VTY_NEWLINE
);
4958 /* Show summary-ASBR-LSA detail information. */
4960 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4964 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4966 show_ip_ospf_database_header (vty
, lsa
);
4968 vty_out (vty
, " Network Mask: /%d%s",
4969 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4970 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4972 vty_out (vty
, "%s", VTY_NEWLINE
);
4978 /* Show AS-external-LSA detail information. */
4980 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4984 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4986 show_ip_ospf_database_header (vty
, lsa
);
4988 vty_out (vty
, " Network Mask: /%d%s",
4989 ip_masklen (al
->mask
), VTY_NEWLINE
);
4990 vty_out (vty
, " Metric Type: %s%s",
4991 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4992 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4993 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4994 vty_out (vty
, " Metric: %d%s",
4995 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4996 vty_out (vty
, " Forward Address: %s%s",
4997 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4999 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5000 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5007 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5009 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5011 /* show_ip_ospf_database_header (vty, lsa); */
5013 zlog_debug( " Network Mask: /%d%s",
5014 ip_masklen (al
->mask
), "\n");
5015 zlog_debug( " Metric Type: %s%s",
5016 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5017 "2 (Larger than any link state path)" : "1", "\n");
5018 zlog_debug( " TOS: 0%s", "\n");
5019 zlog_debug( " Metric: %d%s",
5020 GET_METRIC (al
->e
[0].metric
), "\n");
5021 zlog_debug( " Forward Address: %s%s",
5022 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5024 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5025 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5030 /* Show AS-NSSA-LSA detail information. */
5032 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5036 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5038 show_ip_ospf_database_header (vty
, lsa
);
5040 vty_out (vty
, " Network Mask: /%d%s",
5041 ip_masklen (al
->mask
), VTY_NEWLINE
);
5042 vty_out (vty
, " Metric Type: %s%s",
5043 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5044 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5045 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5046 vty_out (vty
, " Metric: %d%s",
5047 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5048 vty_out (vty
, " NSSA: Forward Address: %s%s",
5049 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5051 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5052 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5059 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5065 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5069 show_ip_ospf_database_header (vty
, lsa
);
5070 show_opaque_info_detail (vty
, lsa
);
5072 vty_out (vty
, "%s", VTY_NEWLINE
);
5077 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5080 show_router_lsa_detail
,
5081 show_network_lsa_detail
,
5082 show_summary_lsa_detail
,
5083 show_summary_asbr_lsa_detail
,
5084 show_as_external_lsa_detail
,
5086 show_as_nssa_lsa_detail
, /* almost same as external */
5088 show_opaque_lsa_detail
,
5089 show_opaque_lsa_detail
,
5090 show_opaque_lsa_detail
,
5094 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5095 struct in_addr
*adv_router
)
5097 memset (lp
, 0, sizeof (struct prefix_ls
));
5101 else if (adv_router
== NULL
)
5110 lp
->adv_router
= *adv_router
;
5115 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5116 struct in_addr
*id
, struct in_addr
*adv_router
)
5118 struct prefix_ls lp
;
5119 struct route_node
*rn
, *start
;
5120 struct ospf_lsa
*lsa
;
5122 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5123 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5126 route_lock_node (start
);
5127 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5128 if ((lsa
= rn
->info
))
5130 if (show_function
[lsa
->data
->type
] != NULL
)
5131 show_function
[lsa
->data
->type
] (vty
, lsa
);
5133 route_unlock_node (start
);
5137 /* Show detail LSA information
5138 -- if id is NULL then show all LSAs. */
5140 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5141 struct in_addr
*id
, struct in_addr
*adv_router
)
5143 struct listnode
*node
;
5144 struct ospf_area
*area
;
5148 case OSPF_AS_EXTERNAL_LSA
:
5149 case OSPF_OPAQUE_AS_LSA
:
5150 vty_out (vty
, " %s %s%s",
5151 show_database_desc
[type
],
5152 VTY_NEWLINE
, VTY_NEWLINE
);
5153 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5156 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5158 vty_out (vty
, "%s %s (Area %s)%s%s",
5159 VTY_NEWLINE
, show_database_desc
[type
],
5160 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5161 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5168 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5169 struct in_addr
*adv_router
)
5171 struct route_node
*rn
;
5172 struct ospf_lsa
*lsa
;
5174 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5175 if ((lsa
= rn
->info
))
5176 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5178 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5180 if (show_function
[lsa
->data
->type
] != NULL
)
5181 show_function
[lsa
->data
->type
] (vty
, lsa
);
5185 /* Show detail LSA information. */
5187 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5188 struct in_addr
*adv_router
)
5190 struct listnode
*node
;
5191 struct ospf_area
*area
;
5195 case OSPF_AS_EXTERNAL_LSA
:
5196 case OSPF_OPAQUE_AS_LSA
:
5197 vty_out (vty
, " %s %s%s",
5198 show_database_desc
[type
],
5199 VTY_NEWLINE
, VTY_NEWLINE
);
5200 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5204 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5206 vty_out (vty
, "%s %s (Area %s)%s%s",
5207 VTY_NEWLINE
, show_database_desc
[type
],
5208 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5209 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5217 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5219 struct ospf_lsa
*lsa
;
5220 struct route_node
*rn
;
5221 struct ospf_area
*area
;
5222 struct listnode
*node
;
5225 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5227 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5231 case OSPF_AS_EXTERNAL_LSA
:
5232 case OSPF_OPAQUE_AS_LSA
:
5237 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5238 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5240 vty_out (vty
, " %s (Area %s)%s%s",
5241 show_database_desc
[type
],
5242 ospf_area_desc_string (area
),
5243 VTY_NEWLINE
, VTY_NEWLINE
);
5244 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5246 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5247 show_lsa_summary (vty
, lsa
, self
);
5249 vty_out (vty
, "%s", VTY_NEWLINE
);
5254 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5258 case OSPF_AS_EXTERNAL_LSA
:
5259 case OSPF_OPAQUE_AS_LSA
:
5264 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5265 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5267 vty_out (vty
, " %s%s%s",
5268 show_database_desc
[type
],
5269 VTY_NEWLINE
, VTY_NEWLINE
);
5270 vty_out (vty
, "%s%s", show_database_header
[type
],
5273 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5274 show_lsa_summary (vty
, lsa
, self
);
5276 vty_out (vty
, "%s", VTY_NEWLINE
);
5280 vty_out (vty
, "%s", VTY_NEWLINE
);
5284 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5286 struct route_node
*rn
;
5288 vty_out (vty
, "%s MaxAge Link States:%s%s",
5289 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5291 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5293 struct ospf_lsa
*lsa
;
5295 if ((lsa
= rn
->info
) != NULL
)
5297 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5298 vty_out (vty
, "Link State ID: %s%s",
5299 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5300 vty_out (vty
, "Advertising Router: %s%s",
5301 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5302 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5303 vty_out (vty
, "%s", VTY_NEWLINE
);
5308 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5309 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5311 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5312 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5313 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5314 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5316 #define OSPF_LSA_TYPES_DESC \
5317 "ASBR summary link states\n" \
5318 "External link states\n" \
5319 "Network link states\n" \
5320 "Router link states\n" \
5321 "Network summary link states\n" \
5322 OSPF_LSA_TYPE_NSSA_DESC \
5323 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5324 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5325 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5328 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5329 int arg_base
, int argc
, struct cmd_token
**argv
)
5333 struct in_addr id
, adv_router
;
5336 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5339 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5340 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5343 if (argc
== arg_base
+ 4)
5345 show_ip_ospf_database_summary (vty
, ospf
, 0);
5349 /* Set database type to show. */
5350 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5351 type
= OSPF_ROUTER_LSA
;
5352 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5353 type
= OSPF_NETWORK_LSA
;
5354 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5355 type
= OSPF_AS_NSSA_LSA
;
5356 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5357 type
= OSPF_SUMMARY_LSA
;
5358 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5359 type
= OSPF_ASBR_SUMMARY_LSA
;
5360 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5361 type
= OSPF_AS_EXTERNAL_LSA
;
5362 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5364 show_ip_ospf_database_summary (vty
, ospf
, 1);
5367 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5369 show_ip_ospf_database_maxage (vty
, ospf
);
5372 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5373 type
= OSPF_OPAQUE_LINK_LSA
;
5374 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5375 type
= OSPF_OPAQUE_AREA_LSA
;
5376 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5377 type
= OSPF_OPAQUE_AS_LSA
;
5381 /* `show ip ospf database LSA'. */
5382 if (argc
== arg_base
+ 5)
5383 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5384 else if (argc
>= arg_base
+ 6)
5386 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5390 /* `show ip ospf database LSA ID'. */
5391 if (argc
== arg_base
+ 6)
5392 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5393 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5394 else if (argc
== arg_base
+ 7)
5396 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5397 adv_router
= ospf
->router_id
;
5400 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5404 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5411 DEFUN (show_ip_ospf_database_max
,
5412 show_ip_ospf_database_max_cmd
,
5413 "show ip ospf database <max-age|self-originate>",
5416 "OSPF information\n"
5417 "Database summary\n"
5418 "LSAs in MaxAge list\n"
5419 "Self-originated link states\n")
5423 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5426 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5429 DEFUN (show_ip_ospf_instance_database
,
5430 show_ip_ospf_instance_database_cmd
,
5431 "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>]]]",
5434 "OSPF information\n"
5436 "Database summary\n"
5438 "Link State ID (as an IP address)\n"
5439 "Self-originated link states\n"
5440 "Advertising Router link states\n"
5441 "Advertising Router (as an IP address)\n")
5444 u_short instance
= 0;
5447 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5449 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5450 ospf
= ospf_lookup_instance (instance
);
5453 ospf
= ospf_lookup();
5456 if (!ospf
|| !ospf
->oi_running
)
5459 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5462 DEFUN (show_ip_ospf_instance_database_max
,
5463 show_ip_ospf_instance_database_max_cmd
,
5464 "show ip ospf (1-65535) database <max-age|self-originate>",
5467 "OSPF information\n"
5469 "Database summary\n"
5470 "LSAs in MaxAge list\n"
5471 "Self-originated link states\n")
5475 u_short instance
= 0;
5477 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5479 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5482 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5487 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5488 int arg_base
, int argc
, struct cmd_token
**argv
)
5492 struct in_addr adv_router
;
5495 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5498 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5499 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5501 if (argc
!= arg_base
+ 7)
5504 /* Set database type to show. */
5505 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5506 type
= OSPF_ROUTER_LSA
;
5507 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5508 type
= OSPF_NETWORK_LSA
;
5509 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5510 type
= OSPF_AS_NSSA_LSA
;
5511 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5512 type
= OSPF_SUMMARY_LSA
;
5513 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5514 type
= OSPF_ASBR_SUMMARY_LSA
;
5515 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5516 type
= OSPF_AS_EXTERNAL_LSA
;
5517 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5518 type
= OSPF_OPAQUE_LINK_LSA
;
5519 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5520 type
= OSPF_OPAQUE_AREA_LSA
;
5521 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5522 type
= OSPF_OPAQUE_AS_LSA
;
5526 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5527 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5528 adv_router
= ospf
->router_id
;
5531 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5536 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5541 DEFUN (show_ip_ospf_database_type_adv_router
,
5542 show_ip_ospf_database_type_adv_router_cmd
,
5543 "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>",
5546 "OSPF information\n"
5547 "Database summary\n"
5549 "Advertising Router link states\n"
5550 "Advertising Router (as an IP address)\n"
5551 "Self-originated link states\n")
5555 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5558 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5561 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5562 show_ip_ospf_instance_database_type_adv_router_cmd
,
5563 "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>",
5566 "OSPF information\n"
5568 "Database summary\n"
5570 "Advertising Router link states\n"
5571 "Advertising Router (as an IP address)\n"
5572 "Self-originated link states\n")
5576 u_short instance
= 0;
5578 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5580 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5583 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5586 DEFUN (ip_ospf_authentication_args
,
5587 ip_ospf_authentication_args_addr_cmd
,
5588 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5590 "OSPF interface commands\n"
5591 "Enable authentication on this interface\n"
5592 "Use null authentication\n"
5593 "Use message-digest authentication\n"
5594 "Address of interface\n")
5596 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5597 int idx_encryption
= 3;
5599 struct in_addr addr
;
5601 struct ospf_if_params
*params
;
5603 params
= IF_DEF_PARAMS (ifp
);
5607 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5610 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5615 params
= ospf_get_if_params (ifp
, addr
);
5616 ospf_if_update_params (ifp
, addr
);
5619 /* Handle null authentication */
5620 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5622 SET_IF_PARAM (params
, auth_type
);
5623 params
->auth_type
= OSPF_AUTH_NULL
;
5627 /* Handle message-digest authentication */
5628 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5630 SET_IF_PARAM (params
, auth_type
);
5631 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5635 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5639 DEFUN (ip_ospf_authentication
,
5640 ip_ospf_authentication_addr_cmd
,
5641 "ip ospf authentication [A.B.C.D]",
5643 "OSPF interface commands\n"
5644 "Enable authentication on this interface\n"
5645 "Address of interface")
5647 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5649 struct in_addr addr
;
5651 struct ospf_if_params
*params
;
5653 params
= IF_DEF_PARAMS (ifp
);
5657 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5660 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5665 params
= ospf_get_if_params (ifp
, addr
);
5666 ospf_if_update_params (ifp
, addr
);
5669 SET_IF_PARAM (params
, auth_type
);
5670 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5675 DEFUN (no_ip_ospf_authentication_args
,
5676 no_ip_ospf_authentication_args_addr_cmd
,
5677 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5680 "OSPF interface commands\n"
5681 "Enable authentication on this interface\n"
5682 "Use null authentication\n"
5683 "Use message-digest authentication\n"
5684 "Address of interface")
5686 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5687 int idx_encryption
= 4;
5689 struct in_addr addr
;
5691 struct ospf_if_params
*params
;
5692 struct route_node
*rn
;
5695 params
= IF_DEF_PARAMS (ifp
);
5699 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5702 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5707 params
= ospf_lookup_if_params (ifp
, addr
);
5710 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5713 params
->auth_type
= OSPF_AUTH_NOTSET
;
5714 UNSET_IF_PARAM (params
, auth_type
);
5715 if (params
!= IF_DEF_PARAMS (ifp
))
5717 ospf_free_if_params (ifp
, addr
);
5718 ospf_if_update_params (ifp
, addr
);
5723 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5725 auth_type
= OSPF_AUTH_NULL
;
5727 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5729 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5733 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5737 * Here we have a case where the user has entered
5738 * 'no ip ospf authentication (null | message_digest )'
5739 * we need to find if we have any ip addresses underneath it that
5740 * correspond to the associated type.
5742 if (params
->auth_type
== auth_type
)
5744 params
->auth_type
= OSPF_AUTH_NOTSET
;
5745 UNSET_IF_PARAM (params
, auth_type
);
5748 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5750 if ((params
= rn
->info
))
5752 if (params
->auth_type
== auth_type
)
5754 params
->auth_type
= OSPF_AUTH_NOTSET
;
5755 UNSET_IF_PARAM (params
, auth_type
);
5756 if (params
!= IF_DEF_PARAMS (ifp
))
5758 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5759 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5769 DEFUN (no_ip_ospf_authentication
,
5770 no_ip_ospf_authentication_addr_cmd
,
5771 "no ip ospf authentication [A.B.C.D]",
5774 "OSPF interface commands\n"
5775 "Enable authentication on this interface\n"
5776 "Address of interface")
5778 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5780 struct in_addr addr
;
5782 struct ospf_if_params
*params
;
5783 struct route_node
*rn
;
5785 params
= IF_DEF_PARAMS (ifp
);
5789 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5792 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5797 params
= ospf_lookup_if_params (ifp
, addr
);
5800 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5804 params
->auth_type
= OSPF_AUTH_NOTSET
;
5805 UNSET_IF_PARAM (params
, auth_type
);
5806 if (params
!= IF_DEF_PARAMS (ifp
))
5808 ospf_free_if_params (ifp
, addr
);
5809 ospf_if_update_params (ifp
, addr
);
5815 * When a user enters 'no ip ospf authentication'
5816 * We should remove all authentication types from
5819 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5820 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5821 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5823 params
->auth_type
= OSPF_AUTH_NOTSET
;
5824 UNSET_IF_PARAM (params
, auth_type
);
5827 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5829 if ((params
= rn
->info
))
5832 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5833 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5834 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5836 params
->auth_type
= OSPF_AUTH_NOTSET
;
5837 UNSET_IF_PARAM (params
, auth_type
);
5838 if (params
!= IF_DEF_PARAMS (ifp
))
5840 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5841 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5852 DEFUN (ip_ospf_authentication_key
,
5853 ip_ospf_authentication_key_addr_cmd
,
5854 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5856 "OSPF interface commands\n"
5857 "Authentication password (key)\n"
5858 "The OSPF password (key)\n"
5859 "Address of interface")
5861 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5863 struct in_addr addr
;
5864 struct ospf_if_params
*params
;
5866 params
= IF_DEF_PARAMS (ifp
);
5868 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5870 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5872 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5877 params
= ospf_get_if_params (ifp
, addr
);
5878 ospf_if_update_params (ifp
, addr
);
5881 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5882 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5883 SET_IF_PARAM (params
, auth_simple
);
5888 DEFUN_HIDDEN (ospf_authentication_key
,
5889 ospf_authentication_key_cmd
,
5890 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5891 "OSPF interface commands\n"
5892 "Authentication password (key)\n"
5893 "The OSPF password (key)\n"
5894 "Address of interface\n")
5896 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5899 DEFUN (no_ip_ospf_authentication_key
,
5900 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5901 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5904 "OSPF interface commands\n"
5905 "Authentication password (key)\n"
5906 "The OSPF password (key)")
5908 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5910 struct in_addr addr
;
5911 struct ospf_if_params
*params
;
5912 params
= IF_DEF_PARAMS (ifp
);
5914 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5916 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5918 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5923 params
= ospf_lookup_if_params (ifp
, addr
);
5928 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5929 UNSET_IF_PARAM (params
, auth_simple
);
5931 if (params
!= IF_DEF_PARAMS (ifp
))
5933 ospf_free_if_params (ifp
, addr
);
5934 ospf_if_update_params (ifp
, addr
);
5940 DEFUN_HIDDEN (no_ospf_authentication_key
,
5941 no_ospf_authentication_key_authkey_addr_cmd
,
5942 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5944 "OSPF interface commands\n"
5945 "Authentication password (key)\n"
5946 "The OSPF password (key)")
5948 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5951 DEFUN (ip_ospf_message_digest_key
,
5952 ip_ospf_message_digest_key_cmd
,
5953 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5955 "OSPF interface commands\n"
5956 "Message digest authentication password (key)\n"
5958 "Use MD5 algorithm\n"
5959 "The OSPF password (key)\n"
5960 "Address of interface\n")
5962 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5963 struct crypt_key
*ck
;
5965 struct in_addr addr
;
5966 struct ospf_if_params
*params
;
5968 params
= IF_DEF_PARAMS (ifp
);
5971 argv_find (argv
, argc
, "(1-255)", &idx
);
5972 char *keyid
= argv
[idx
]->arg
;
5973 argv_find (argv
, argc
, "KEY", &idx
);
5974 char *cryptkey
= argv
[idx
]->arg
;
5976 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5978 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5980 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5985 params
= ospf_get_if_params (ifp
, addr
);
5986 ospf_if_update_params (ifp
, addr
);
5989 key_id
= strtol (keyid
, NULL
, 10);
5990 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5992 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5996 ck
= ospf_crypt_key_new ();
5997 ck
->key_id
= (u_char
) key_id
;
5998 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5999 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6001 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6002 SET_IF_PARAM (params
, auth_crypt
);
6007 DEFUN_HIDDEN (ospf_message_digest_key
,
6008 ospf_message_digest_key_cmd
,
6009 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6010 "OSPF interface commands\n"
6011 "Message digest authentication password (key)\n"
6013 "Use MD5 algorithm\n"
6014 "The OSPF password (key)\n"
6015 "Address of interface\n")
6017 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6020 DEFUN (no_ip_ospf_message_digest_key
,
6021 no_ip_ospf_message_digest_key_cmd
,
6022 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6025 "OSPF interface commands\n"
6026 "Message digest authentication password (key)\n"
6028 "Use MD5 algorithm\n"
6029 "The OSPF password (key)\n"
6030 "Address of interface\n")
6032 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6034 struct crypt_key
*ck
;
6036 struct in_addr addr
;
6037 struct ospf_if_params
*params
;
6038 params
= IF_DEF_PARAMS (ifp
);
6040 argv_find (argv
, argc
, "(1-255)", &idx
);
6041 char *keyid
= argv
[idx
]->arg
;
6043 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6045 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6047 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6052 params
= ospf_lookup_if_params (ifp
, addr
);
6057 key_id
= strtol (keyid
, NULL
, 10);
6058 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6061 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6065 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6067 if (params
!= IF_DEF_PARAMS (ifp
))
6069 ospf_free_if_params (ifp
, addr
);
6070 ospf_if_update_params (ifp
, addr
);
6076 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6077 no_ospf_message_digest_key_cmd
,
6078 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6080 "OSPF interface commands\n"
6081 "Message digest authentication password (key)\n"
6083 "Address of interface")
6085 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6088 DEFUN (ip_ospf_cost
,
6090 "ip ospf cost (1-65535) [A.B.C.D]",
6092 "OSPF interface commands\n"
6095 "Address of interface\n")
6097 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6100 struct in_addr addr
;
6101 struct ospf_if_params
*params
;
6102 params
= IF_DEF_PARAMS (ifp
);
6105 char *coststr
= NULL
, *ifaddr
= NULL
;
6106 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6107 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6109 cost
= strtol (coststr
, NULL
, 10);
6113 if(!inet_aton(ifaddr
, &addr
))
6115 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6120 params
= ospf_get_if_params (ifp
, addr
);
6121 ospf_if_update_params (ifp
, addr
);
6124 SET_IF_PARAM (params
, output_cost_cmd
);
6125 params
->output_cost_cmd
= cost
;
6127 ospf_if_recalculate_output_cost (ifp
);
6132 DEFUN_HIDDEN (ospf_cost
,
6134 "ospf cost (1-65535) [A.B.C.D]",
6135 "OSPF interface commands\n"
6138 "Address of interface\n")
6140 return ip_ospf_cost (self
, vty
, argc
, argv
);
6143 DEFUN (no_ip_ospf_cost
,
6144 no_ip_ospf_cost_cmd
,
6145 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6147 "OSPF interface commands\n"
6149 "Address of interface")
6151 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6153 struct in_addr addr
;
6154 struct ospf_if_params
*params
;
6156 params
= IF_DEF_PARAMS (ifp
);
6159 char *ifaddr
= NULL
;
6160 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6162 /* According to the semantics we are mimicking "no ip ospf cost N" is
6163 * always treated as "no ip ospf cost" regardless of the actual value
6164 * of N already configured for the interface. Thus ignore cost. */
6168 if (!inet_aton(ifaddr
, &addr
))
6170 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6175 params
= ospf_lookup_if_params (ifp
, addr
);
6180 UNSET_IF_PARAM (params
, output_cost_cmd
);
6182 if (params
!= IF_DEF_PARAMS (ifp
))
6184 ospf_free_if_params (ifp
, addr
);
6185 ospf_if_update_params (ifp
, addr
);
6188 ospf_if_recalculate_output_cost (ifp
);
6193 DEFUN_HIDDEN (no_ospf_cost
,
6195 "no ospf cost [(1-65535)] [A.B.C.D]",
6197 "OSPF interface commands\n"
6200 "Address of interface\n")
6202 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6206 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6208 struct route_node
*rn
;
6209 struct ospf_neighbor
*nbr
;
6211 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6212 if ((nbr
= rn
->info
))
6214 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6215 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6216 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6217 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6222 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6223 const char *nbr_str
,
6224 const char *fast_hello_str
)
6226 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6229 struct in_addr addr
;
6231 struct ospf_if_params
*params
;
6232 struct ospf_interface
*oi
;
6233 struct route_node
*rn
;
6235 params
= IF_DEF_PARAMS (ifp
);
6239 ret
= inet_aton(nbr_str
, &addr
);
6242 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6247 params
= ospf_get_if_params (ifp
, addr
);
6248 ospf_if_update_params (ifp
, addr
);
6253 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6256 /* reset fast_hello too, just to be sure */
6257 UNSET_IF_PARAM (params
, fast_hello
);
6258 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6260 else if (fast_hello_str
)
6262 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6264 /* 1s dead-interval with sub-second hellos desired */
6265 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6266 SET_IF_PARAM (params
, fast_hello
);
6267 params
->fast_hello
= hellomult
;
6271 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6276 SET_IF_PARAM (params
, v_wait
);
6277 params
->v_wait
= seconds
;
6279 /* Update timer values in neighbor structure. */
6283 if ((ospf
= ospf_lookup()))
6285 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6287 ospf_nbr_timer_update (oi
);
6292 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6293 if ((oi
= rn
->info
))
6294 ospf_nbr_timer_update (oi
);
6300 DEFUN (ip_ospf_dead_interval
,
6301 ip_ospf_dead_interval_cmd
,
6302 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6304 "OSPF interface commands\n"
6305 "Interval time after which a neighbor is declared down\n"
6307 "Address of interface\n")
6310 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6311 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6312 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6316 DEFUN_HIDDEN (ospf_dead_interval
,
6317 ospf_dead_interval_cmd
,
6318 "ospf dead-interval (1-65535) [A.B.C.D]",
6319 "OSPF interface commands\n"
6320 "Interval time after which a neighbor is declared down\n"
6322 "Address of interface\n")
6324 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6327 DEFUN (ip_ospf_dead_interval_minimal
,
6328 ip_ospf_dead_interval_minimal_addr_cmd
,
6329 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6331 "OSPF interface commands\n"
6332 "Interval time after which a neighbor is declared down\n"
6333 "Minimal 1s dead-interval with fast sub-second hellos\n"
6334 "Hello multiplier factor\n"
6335 "Number of Hellos to send each second\n"
6336 "Address of interface\n")
6341 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6343 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6346 DEFUN (no_ip_ospf_dead_interval
,
6347 no_ip_ospf_dead_interval_cmd
,
6348 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6351 "OSPF interface commands\n"
6352 "Interval time after which a neighbor is declared down\n"
6354 "Address of interface")
6356 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6357 int idx_ipv4
= argc
- 1;
6358 struct in_addr addr
;
6360 struct ospf_if_params
*params
;
6361 struct ospf_interface
*oi
;
6362 struct route_node
*rn
;
6364 params
= IF_DEF_PARAMS (ifp
);
6366 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6368 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6371 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6376 params
= ospf_lookup_if_params (ifp
, addr
);
6381 UNSET_IF_PARAM (params
, v_wait
);
6382 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6384 UNSET_IF_PARAM (params
, fast_hello
);
6385 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6387 if (params
!= IF_DEF_PARAMS (ifp
))
6389 ospf_free_if_params (ifp
, addr
);
6390 ospf_if_update_params (ifp
, addr
);
6393 /* Update timer values in neighbor structure. */
6398 if ((ospf
= ospf_lookup()))
6400 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6402 ospf_nbr_timer_update (oi
);
6407 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6408 if ((oi
= rn
->info
))
6409 ospf_nbr_timer_update (oi
);
6415 DEFUN_HIDDEN (no_ospf_dead_interval
,
6416 no_ospf_dead_interval_cmd
,
6417 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6419 "OSPF interface commands\n"
6420 "Interval time after which a neighbor is declared down\n"
6422 "Address of interface")
6424 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6427 DEFUN (ip_ospf_hello_interval
,
6428 ip_ospf_hello_interval_cmd
,
6429 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6431 "OSPF interface commands\n"
6432 "Time between HELLO packets\n"
6434 "Address of interface\n")
6436 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6438 struct in_addr addr
;
6439 struct ospf_if_params
*params
;
6440 params
= IF_DEF_PARAMS (ifp
);
6441 u_int32_t seconds
= 0;
6443 argv_find (argv
, argc
, "(1-65535)", &idx
);
6444 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6446 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6448 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6450 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6455 params
= ospf_get_if_params (ifp
, addr
);
6456 ospf_if_update_params (ifp
, addr
);
6459 SET_IF_PARAM (params
, v_hello
);
6460 params
->v_hello
= seconds
;
6465 DEFUN_HIDDEN (ospf_hello_interval
,
6466 ospf_hello_interval_cmd
,
6467 "ospf hello-interval (1-65535) [A.B.C.D]",
6468 "OSPF interface commands\n"
6469 "Time between HELLO packets\n"
6471 "Address of interface\n")
6473 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6476 DEFUN (no_ip_ospf_hello_interval
,
6477 no_ip_ospf_hello_interval_cmd
,
6478 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6481 "OSPF interface commands\n"
6482 "Time between HELLO packets\n" // ignored
6484 "Address of interface\n")
6486 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6488 struct in_addr addr
;
6489 struct ospf_if_params
*params
;
6490 params
= IF_DEF_PARAMS (ifp
);
6492 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6494 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6496 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6501 params
= ospf_lookup_if_params (ifp
, addr
);
6506 UNSET_IF_PARAM (params
, v_hello
);
6507 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6509 if (params
!= IF_DEF_PARAMS (ifp
))
6511 ospf_free_if_params (ifp
, addr
);
6512 ospf_if_update_params (ifp
, addr
);
6518 DEFUN_HIDDEN (no_ospf_hello_interval
,
6519 no_ospf_hello_interval_cmd
,
6520 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6522 "OSPF interface commands\n"
6523 "Time between HELLO packets\n" // ignored
6525 "Address of interface\n")
6527 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6530 DEFUN (ip_ospf_network
,
6531 ip_ospf_network_cmd
,
6532 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6534 "OSPF interface commands\n"
6536 "Specify OSPF broadcast multi-access network\n"
6537 "Specify OSPF NBMA network\n"
6538 "Specify OSPF point-to-multipoint network\n"
6539 "Specify OSPF point-to-point network\n")
6541 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6543 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6544 struct route_node
*rn
;
6546 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6548 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6552 if (argv_find (argv
, argc
, "broadcast", &idx
))
6553 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6554 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6555 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6556 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6557 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6558 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6559 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6561 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6564 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6566 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6568 struct ospf_interface
*oi
= rn
->info
;
6573 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6575 if (oi
->state
> ISM_Down
)
6577 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6578 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6585 DEFUN_HIDDEN (ospf_network
,
6587 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6588 "OSPF interface commands\n"
6590 "Specify OSPF broadcast multi-access network\n"
6591 "Specify OSPF NBMA network\n"
6592 "Specify OSPF point-to-multipoint network\n"
6593 "Specify OSPF point-to-point network\n")
6595 return ip_ospf_network (self
, vty
, argc
, argv
);
6598 DEFUN (no_ip_ospf_network
,
6599 no_ip_ospf_network_cmd
,
6600 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6603 "OSPF interface commands\n"
6605 "Specify OSPF broadcast multi-access network\n"
6606 "Specify OSPF NBMA network\n"
6607 "Specify OSPF point-to-multipoint network\n"
6608 "Specify OSPF point-to-point network\n")
6610 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6611 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6612 struct route_node
*rn
;
6614 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6616 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6619 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6621 struct ospf_interface
*oi
= rn
->info
;
6626 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6628 if (oi
->state
> ISM_Down
)
6630 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6631 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6638 DEFUN_HIDDEN (no_ospf_network
,
6639 no_ospf_network_cmd
,
6640 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6642 "OSPF interface commands\n"
6644 "Specify OSPF broadcast multi-access network\n"
6645 "Specify OSPF NBMA network\n"
6646 "Specify OSPF point-to-multipoint network\n"
6647 "Specify OSPF point-to-point network\n")
6649 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6652 DEFUN (ip_ospf_priority
,
6653 ip_ospf_priority_cmd
,
6654 "ip ospf priority (0-255) [A.B.C.D]",
6656 "OSPF interface commands\n"
6659 "Address of interface")
6661 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6664 struct route_node
*rn
;
6665 struct in_addr addr
;
6666 struct ospf_if_params
*params
;
6667 params
= IF_DEF_PARAMS (ifp
);
6669 argv_find (argv
, argc
, "(0-255)", &idx
);
6670 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6672 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6674 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6676 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6681 params
= ospf_get_if_params (ifp
, addr
);
6682 ospf_if_update_params (ifp
, addr
);
6685 SET_IF_PARAM (params
, priority
);
6686 params
->priority
= priority
;
6688 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6690 struct ospf_interface
*oi
= rn
->info
;
6695 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6697 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6698 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6705 DEFUN_HIDDEN (ospf_priority
,
6707 "ospf priority (0-255) [A.B.C.D]",
6708 "OSPF interface commands\n"
6711 "Address of interface")
6713 return ip_ospf_priority (self
, vty
, argc
, argv
);
6716 DEFUN (no_ip_ospf_priority
,
6717 no_ip_ospf_priority_cmd
,
6718 "no ip ospf priority [(0-255) [A.B.C.D]]",
6721 "OSPF interface commands\n"
6722 "Router priority\n" // ignored
6724 "Address of interface")
6726 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6728 struct route_node
*rn
;
6729 struct in_addr addr
;
6730 struct ospf_if_params
*params
;
6732 params
= IF_DEF_PARAMS (ifp
);
6734 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6736 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6738 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6743 params
= ospf_lookup_if_params (ifp
, addr
);
6748 UNSET_IF_PARAM (params
, priority
);
6749 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6751 if (params
!= IF_DEF_PARAMS (ifp
))
6753 ospf_free_if_params (ifp
, addr
);
6754 ospf_if_update_params (ifp
, addr
);
6757 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6759 struct ospf_interface
*oi
= rn
->info
;
6764 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6766 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6767 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6774 DEFUN_HIDDEN (no_ospf_priority
,
6775 no_ospf_priority_cmd
,
6776 "no ospf priority [(0-255) [A.B.C.D]]",
6778 "OSPF interface commands\n"
6781 "Address of interface")
6783 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6786 DEFUN (ip_ospf_retransmit_interval
,
6787 ip_ospf_retransmit_interval_addr_cmd
,
6788 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6790 "OSPF interface commands\n"
6791 "Time between retransmitting lost link state advertisements\n"
6793 "Address of interface")
6795 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6798 struct in_addr addr
;
6799 struct ospf_if_params
*params
;
6800 params
= IF_DEF_PARAMS (ifp
);
6802 argv_find (argv
, argc
, "(3-65535)", &idx
);
6803 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6805 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6807 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6809 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6814 params
= ospf_get_if_params (ifp
, addr
);
6815 ospf_if_update_params (ifp
, addr
);
6818 SET_IF_PARAM (params
, retransmit_interval
);
6819 params
->retransmit_interval
= seconds
;
6824 DEFUN_HIDDEN (ospf_retransmit_interval
,
6825 ospf_retransmit_interval_cmd
,
6826 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6827 "OSPF interface commands\n"
6828 "Time between retransmitting lost link state advertisements\n"
6830 "Address of interface")
6832 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6835 DEFUN (no_ip_ospf_retransmit_interval
,
6836 no_ip_ospf_retransmit_interval_addr_cmd
,
6837 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6840 "OSPF interface commands\n"
6841 "Time between retransmitting lost link state advertisements\n"
6843 "Address of interface\n")
6845 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6847 struct in_addr addr
;
6848 struct ospf_if_params
*params
;
6850 params
= IF_DEF_PARAMS (ifp
);
6852 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6854 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6856 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6861 params
= ospf_lookup_if_params (ifp
, addr
);
6866 UNSET_IF_PARAM (params
, retransmit_interval
);
6867 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6869 if (params
!= IF_DEF_PARAMS (ifp
))
6871 ospf_free_if_params (ifp
, addr
);
6872 ospf_if_update_params (ifp
, addr
);
6878 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6879 no_ospf_retransmit_interval_cmd
,
6880 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6882 "OSPF interface commands\n"
6883 "Time between retransmitting lost link state advertisements\n"
6885 "Address of interface\n")
6887 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6890 DEFUN (ip_ospf_transmit_delay
,
6891 ip_ospf_transmit_delay_addr_cmd
,
6892 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6894 "OSPF interface commands\n"
6895 "Link state transmit delay\n"
6897 "Address of interface")
6899 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6902 struct in_addr addr
;
6903 struct ospf_if_params
*params
;
6905 params
= IF_DEF_PARAMS (ifp
);
6906 argv_find (argv
, argc
, "(1-65535)", &idx
);
6907 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6909 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6911 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6913 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6918 params
= ospf_get_if_params (ifp
, addr
);
6919 ospf_if_update_params (ifp
, addr
);
6922 SET_IF_PARAM (params
, transmit_delay
);
6923 params
->transmit_delay
= seconds
;
6928 DEFUN_HIDDEN (ospf_transmit_delay
,
6929 ospf_transmit_delay_cmd
,
6930 "ospf transmit-delay (1-65535) [A.B.C.D]",
6931 "OSPF interface commands\n"
6932 "Link state transmit delay\n"
6934 "Address of interface")
6936 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6939 DEFUN (no_ip_ospf_transmit_delay
,
6940 no_ip_ospf_transmit_delay_addr_cmd
,
6941 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6944 "OSPF interface commands\n"
6945 "Link state transmit delay\n"
6946 "Address of interface")
6948 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6950 struct in_addr addr
;
6951 struct ospf_if_params
*params
;
6953 params
= IF_DEF_PARAMS (ifp
);
6955 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6957 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6959 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6964 params
= ospf_lookup_if_params (ifp
, addr
);
6969 UNSET_IF_PARAM (params
, transmit_delay
);
6970 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6972 if (params
!= IF_DEF_PARAMS (ifp
))
6974 ospf_free_if_params (ifp
, addr
);
6975 ospf_if_update_params (ifp
, addr
);
6982 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6983 no_ospf_transmit_delay_cmd
,
6984 "no ospf transmit-delay",
6986 "OSPF interface commands\n"
6987 "Link state transmit delay\n")
6989 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6992 DEFUN (ip_ospf_area
,
6994 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6996 "OSPF interface commands\n"
6998 "Enable OSPF on this interface\n"
6999 "OSPF area ID in IP address format\n"
7000 "OSPF area ID as a decimal value\n")
7002 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7005 struct in_addr area_id
;
7007 struct ospf_if_params
*params
;
7008 struct route_node
*rn
;
7009 u_short instance
= 0;
7011 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7012 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7013 char *areaid
= argv
[argc
- 1]->arg
;
7015 ospf
= ospf_lookup_instance (instance
);
7018 params
= IF_DEF_PARAMS (ifp
);
7019 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7021 ospf_interface_unset (ifp
);
7022 ospf
= ospf_lookup();
7023 ospf
->if_ospf_cli_count
--;
7028 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7031 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7035 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7037 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7041 params
= IF_DEF_PARAMS (ifp
);
7042 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7045 "Must remove previous area config before changing ospf area %s",
7050 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7052 if (rn
->info
!= NULL
)
7054 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7059 /* enable ospf on this interface with area_id */
7060 ospf_interface_set (ifp
, area_id
);
7061 ospf
->if_ospf_cli_count
++;
7066 DEFUN (no_ip_ospf_area
,
7067 no_ip_ospf_area_cmd
,
7068 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7071 "OSPF interface commands\n"
7073 "Disable OSPF on this interface\n"
7074 "OSPF area ID in IP address format\n"
7075 "OSPF area ID as a decimal value\n")
7077 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7080 struct ospf_if_params
*params
;
7081 u_short instance
= 0;
7083 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7084 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7086 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7089 params
= IF_DEF_PARAMS (ifp
);
7090 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7092 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7096 ospf_interface_unset (ifp
);
7097 ospf
->if_ospf_cli_count
--;
7101 DEFUN (ospf_redistribute_source
,
7102 ospf_redistribute_source_cmd
,
7103 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7105 FRR_REDIST_HELP_STR_OSPFD
7106 "Metric for redistributed routes\n"
7107 "OSPF default metric\n"
7108 "OSPF exterior metric type for redistributed routes\n"
7109 "Set OSPF External Type 1 metrics\n"
7110 "Set OSPF External Type 2 metrics\n"
7111 "Route map reference\n"
7112 "Pointer to route-map entries\n")
7114 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7115 int idx_protocol
= 1;
7119 struct ospf_redist
*red
;
7125 /* Get distribute source. */
7126 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7130 red
= ospf_redist_add(ospf
, source
, 0);
7132 /* Get metric value. */
7133 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7134 if (!str2metric (argv
[idx
]->arg
, &metric
))
7137 /* Get metric type. */
7138 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7139 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7143 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7144 ospf_routemap_set (red
, argv
[idx
]->arg
);
7147 ospf_routemap_unset (red
);
7149 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7152 DEFUN (no_ospf_redistribute_source
,
7153 no_ospf_redistribute_source_cmd
,
7154 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7157 FRR_REDIST_HELP_STR_OSPFD
7158 "Metric for redistributed routes\n"
7159 "OSPF default metric\n"
7160 "OSPF exterior metric type for redistributed routes\n"
7161 "Set OSPF External Type 1 metrics\n"
7162 "Set OSPF External Type 2 metrics\n"
7163 "Route map reference\n"
7164 "Pointer to route-map entries\n")
7166 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7167 int idx_protocol
= 2;
7169 struct ospf_redist
*red
;
7171 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7175 red
= ospf_redist_lookup(ospf
, source
, 0);
7179 ospf_routemap_unset (red
);
7180 return ospf_redistribute_unset (ospf
, source
, 0);
7183 DEFUN (ospf_redistribute_instance_source
,
7184 ospf_redistribute_instance_source_cmd
,
7185 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7187 "Open Shortest Path First\n"
7188 "Non-main Kernel Routing Table\n"
7189 "Instance ID/Table ID\n"
7190 "Metric for redistributed routes\n"
7191 "OSPF default metric\n"
7192 "OSPF exterior metric type for redistributed routes\n"
7193 "Set OSPF External Type 1 metrics\n"
7194 "Set OSPF External Type 2 metrics\n"
7195 "Route map reference\n"
7196 "Pointer to route-map entries\n")
7198 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7199 int idx_ospf_table
= 1;
7201 int idx_redist_param
= 3;
7206 struct ospf_redist
*red
;
7211 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7213 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7218 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7220 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7225 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7227 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7232 /* Get metric value. */
7233 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7234 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7237 /* Get metric type. */
7238 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7239 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7242 red
= ospf_redist_add(ospf
, source
, instance
);
7244 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7245 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7247 ospf_routemap_unset (red
);
7249 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7252 DEFUN (no_ospf_redistribute_instance_source
,
7253 no_ospf_redistribute_instance_source_cmd
,
7254 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7257 "Open Shortest Path First\n"
7258 "Non-main Kernel Routing Table\n"
7259 "Instance ID/Table Id\n"
7260 "Metric for redistributed routes\n"
7261 "OSPF default metric\n"
7262 "OSPF exterior metric type for redistributed routes\n"
7263 "Set OSPF External Type 1 metrics\n"
7264 "Set OSPF External Type 2 metrics\n"
7265 "Route map reference\n"
7266 "Pointer to route-map entries\n")
7268 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7269 int idx_ospf_table
= 2;
7272 struct ospf_redist
*red
;
7275 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7276 source
= ZEBRA_ROUTE_OSPF
;
7278 source
= ZEBRA_ROUTE_TABLE
;
7280 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7282 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7284 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7289 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7291 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7296 red
= ospf_redist_lookup(ospf
, source
, instance
);
7300 ospf_routemap_unset (red
);
7301 return ospf_redistribute_unset (ospf
, source
, instance
);
7304 DEFUN (ospf_distribute_list_out
,
7305 ospf_distribute_list_out_cmd
,
7306 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7307 "Filter networks in routing updates\n"
7308 "Access-list name\n"
7310 FRR_REDIST_HELP_STR_OSPFD
)
7312 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7316 char *proto
= argv
[argc
- 1]->text
;
7318 /* Get distribute source. */
7319 source
= proto_redistnum(AFI_IP
, proto
);
7323 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7326 DEFUN (no_ospf_distribute_list_out
,
7327 no_ospf_distribute_list_out_cmd
,
7328 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7330 "Filter networks in routing updates\n"
7331 "Access-list name\n"
7333 FRR_REDIST_HELP_STR_OSPFD
)
7335 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7339 char *proto
= argv
[argc
- 1]->text
;
7340 source
= proto_redistnum(AFI_IP
, proto
);
7344 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7347 /* Default information originate. */
7348 DEFUN (ospf_default_information_originate
,
7349 ospf_default_information_originate_cmd
,
7350 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7351 "Control distribution of default information\n"
7352 "Distribute a default route\n"
7353 "Always advertise default route\n"
7354 "OSPF default metric\n"
7356 "OSPF metric type for default routes\n"
7357 "Set OSPF External Type 1 metrics\n"
7358 "Set OSPF External Type 2 metrics\n"
7359 "Route map reference\n"
7360 "Pointer to route-map entries\n")
7362 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7363 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7366 struct ospf_redist
*red
;
7369 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7371 /* Check whether "always" was specified */
7372 if (argv_find (argv
, argc
, "always", &idx
))
7373 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7374 /* Get metric value */
7375 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7376 if (!str2metric (argv
[idx
]->arg
, &metric
))
7379 /* Get metric type. */
7380 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7381 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7385 else if (argv_find (argv
, argc
, "WORD", &idx
))
7386 ospf_routemap_set (red
, argv
[idx
]->arg
);
7388 ospf_routemap_unset (red
);
7390 return ospf_redistribute_default_set (ospf
, default_originate
,
7394 DEFUN (no_ospf_default_information_originate
,
7395 no_ospf_default_information_originate_cmd
,
7396 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7398 "Control distribution of default information\n"
7399 "Distribute a default route\n"
7400 "Always advertise default route\n"
7401 "OSPF default metric\n"
7403 "OSPF metric type for default routes\n"
7404 "Set OSPF External Type 1 metrics\n"
7405 "Set OSPF External Type 2 metrics\n"
7406 "Route map reference\n"
7407 "Pointer to route-map entries\n")
7409 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7410 struct prefix_ipv4 p
;
7411 struct ospf_external
*ext
;
7412 struct ospf_redist
*red
;
7415 p
.prefix
.s_addr
= 0;
7418 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7420 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7421 EXTERNAL_INFO (ext
)) {
7422 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7423 ospf_external_del (DEFAULT_ROUTE
, 0);
7426 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7430 ospf_routemap_unset (red
);
7431 return ospf_redistribute_default_unset (ospf
);
7434 DEFUN (ospf_default_metric
,
7435 ospf_default_metric_cmd
,
7436 "default-metric (0-16777214)",
7437 "Set metric of redistributed routes\n"
7440 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7444 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7447 ospf
->default_metric
= metric
;
7452 DEFUN (no_ospf_default_metric
,
7453 no_ospf_default_metric_cmd
,
7454 "no default-metric [(0-16777214)]",
7456 "Set metric of redistributed routes\n"
7459 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7461 ospf
->default_metric
= -1;
7467 DEFUN (ospf_distance
,
7470 "Define an administrative distance\n"
7471 "OSPF Administrative distance\n")
7473 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7476 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7481 DEFUN (no_ospf_distance
,
7482 no_ospf_distance_cmd
,
7483 "no distance (1-255)",
7485 "Define an administrative distance\n"
7486 "OSPF Administrative distance\n")
7488 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7490 ospf
->distance_all
= 0;
7495 DEFUN (no_ospf_distance_ospf
,
7496 no_ospf_distance_ospf_cmd
,
7497 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7499 "Define an administrative distance\n"
7500 "OSPF Administrative distance\n"
7501 "Intra-area routes\n"
7502 "Distance for intra-area routes\n"
7503 "Inter-area routes\n"
7504 "Distance for inter-area routes\n"
7506 "Distance for external routes\n")
7508 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7509 int idx_area_distance
= 3;
7520 if (argv
[idx_area_distance
]->arg
!= NULL
)
7521 ospf
->distance_intra
= 0;
7523 if (argv
[1] != NULL
)
7524 ospf
->distance_inter
= 0;
7526 if (argv
[2] != NULL
)
7527 ospf
->distance_external
= 0;
7529 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
7532 /* If no arguments are given, clear all distance information */
7533 ospf
->distance_intra
= 0;
7534 ospf
->distance_inter
= 0;
7535 ospf
->distance_external
= 0;
7540 DEFUN (ospf_distance_ospf
,
7541 ospf_distance_ospf_cmd
,
7542 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7543 "Define an administrative distance\n"
7544 "OSPF Administrative distance\n"
7545 "Intra-area routes\n"
7546 "Distance for intra-area routes\n"
7547 "Inter-area routes\n"
7548 "Distance for inter-area routes\n"
7550 "Distance for external routes\n")
7552 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7553 int idx_area_distance
= 2;
7555 if (argc
< 3) /* should not happen */
7558 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
7560 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
7565 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
7566 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
7568 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
7569 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
7571 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
7572 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
7578 DEFUN (ospf_distance_source
,
7579 ospf_distance_source_cmd
,
7580 "distance (1-255) A.B.C.D/M",
7581 "Administrative distance\n"
7583 "IP source prefix\n")
7585 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7587 int idx_ipv4_prefixlen
= 2;
7592 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7597 DEFUN (no_ospf_distance_source
,
7598 no_ospf_distance_source_cmd
,
7599 "no distance (1-255) A.B.C.D/M",
7601 "Administrative distance\n"
7603 "IP source prefix\n")
7605 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7607 int idx_ipv4_prefixlen
= 3;
7612 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7617 DEFUN (ospf_distance_source_access_list
,
7618 ospf_distance_source_access_list_cmd
,
7619 "distance (1-255) A.B.C.D/M WORD",
7620 "Administrative distance\n"
7622 "IP source prefix\n"
7623 "Access list name\n")
7625 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7627 int idx_ipv4_prefixlen
= 2;
7633 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7638 DEFUN (no_ospf_distance_source_access_list
,
7639 no_ospf_distance_source_access_list_cmd
,
7640 "no distance (1-255) A.B.C.D/M WORD",
7642 "Administrative distance\n"
7644 "IP source prefix\n"
7645 "Access list name\n")
7647 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7649 int idx_ipv4_prefixlen
= 3;
7655 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7661 DEFUN (ip_ospf_mtu_ignore
,
7662 ip_ospf_mtu_ignore_addr_cmd
,
7663 "ip ospf mtu-ignore [A.B.C.D]",
7665 "OSPF interface commands\n"
7666 "Disable MTU mismatch detection on this interface\n"
7667 "Address of interface")
7669 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7671 struct in_addr addr
;
7674 struct ospf_if_params
*params
;
7675 params
= IF_DEF_PARAMS (ifp
);
7679 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7682 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7686 params
= ospf_get_if_params (ifp
, addr
);
7687 ospf_if_update_params (ifp
, addr
);
7689 params
->mtu_ignore
= 1;
7690 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7691 SET_IF_PARAM (params
, mtu_ignore
);
7694 UNSET_IF_PARAM (params
, mtu_ignore
);
7695 if (params
!= IF_DEF_PARAMS (ifp
))
7697 ospf_free_if_params (ifp
, addr
);
7698 ospf_if_update_params (ifp
, addr
);
7704 DEFUN (no_ip_ospf_mtu_ignore
,
7705 no_ip_ospf_mtu_ignore_addr_cmd
,
7706 "no ip ospf mtu-ignore [A.B.C.D]",
7708 "OSPF interface commands\n"
7709 "Disable MTU mismatch detection on this interface\n"
7710 "Address of interface")
7712 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7714 struct in_addr addr
;
7717 struct ospf_if_params
*params
;
7718 params
= IF_DEF_PARAMS (ifp
);
7722 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7725 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7729 params
= ospf_get_if_params (ifp
, addr
);
7730 ospf_if_update_params (ifp
, addr
);
7732 params
->mtu_ignore
= 0;
7733 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7734 SET_IF_PARAM (params
, mtu_ignore
);
7737 UNSET_IF_PARAM (params
, mtu_ignore
);
7738 if (params
!= IF_DEF_PARAMS (ifp
))
7740 ospf_free_if_params (ifp
, addr
);
7741 ospf_if_update_params (ifp
, addr
);
7748 DEFUN (ospf_max_metric_router_lsa_admin
,
7749 ospf_max_metric_router_lsa_admin_cmd
,
7750 "max-metric router-lsa administrative",
7751 "OSPF maximum / infinite-distance metric\n"
7752 "Advertise own Router-LSA with infinite distance (stub router)\n"
7753 "Administratively applied, for an indefinite period\n")
7755 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7756 struct listnode
*ln
;
7757 struct ospf_area
*area
;
7759 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7761 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7763 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7764 ospf_router_lsa_update_area (area
);
7767 /* Allows for areas configured later to get the property */
7768 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7773 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7774 no_ospf_max_metric_router_lsa_admin_cmd
,
7775 "no max-metric router-lsa administrative",
7777 "OSPF maximum / infinite-distance metric\n"
7778 "Advertise own Router-LSA with infinite distance (stub router)\n"
7779 "Administratively applied, for an indefinite period\n")
7781 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7782 struct listnode
*ln
;
7783 struct ospf_area
*area
;
7785 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7787 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7789 /* Don't trample on the start-up stub timer */
7790 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7791 && !area
->t_stub_router
)
7793 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7794 ospf_router_lsa_update_area (area
);
7797 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7801 DEFUN (ospf_max_metric_router_lsa_startup
,
7802 ospf_max_metric_router_lsa_startup_cmd
,
7803 "max-metric router-lsa on-startup (5-86400)",
7804 "OSPF maximum / infinite-distance metric\n"
7805 "Advertise own Router-LSA with infinite distance (stub router)\n"
7806 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7807 "Time (seconds) to advertise self as stub-router\n")
7809 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7811 unsigned int seconds
;
7815 vty_out (vty
, "%% Must supply stub-router period");
7819 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7821 ospf
->stub_router_startup_time
= seconds
;
7826 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7827 no_ospf_max_metric_router_lsa_startup_cmd
,
7828 "no max-metric router-lsa on-startup [(5-86400)]",
7830 "OSPF maximum / infinite-distance metric\n"
7831 "Advertise own Router-LSA with infinite distance (stub router)\n"
7832 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7833 "Time (seconds) to advertise self as stub-router\n")
7835 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7836 struct listnode
*ln
;
7837 struct ospf_area
*area
;
7839 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7841 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7843 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7844 OSPF_TIMER_OFF (area
->t_stub_router
);
7846 /* Don't trample on admin stub routed */
7847 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7849 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7850 ospf_router_lsa_update_area (area
);
7857 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7858 ospf_max_metric_router_lsa_shutdown_cmd
,
7859 "max-metric router-lsa on-shutdown (5-100)",
7860 "OSPF maximum / infinite-distance metric\n"
7861 "Advertise own Router-LSA with infinite distance (stub router)\n"
7862 "Advertise stub-router prior to full shutdown of OSPF\n"
7863 "Time (seconds) to wait till full shutdown\n")
7865 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7867 unsigned int seconds
;
7871 vty_out (vty
, "%% Must supply stub-router shutdown period");
7875 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7877 ospf
->stub_router_shutdown_time
= seconds
;
7882 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7883 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7884 "no max-metric router-lsa on-shutdown [(5-100)]",
7886 "OSPF maximum / infinite-distance metric\n"
7887 "Advertise own Router-LSA with infinite distance (stub router)\n"
7888 "Advertise stub-router prior to full shutdown of OSPF\n"
7889 "Time (seconds) to wait till full shutdown\n")
7891 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7893 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7899 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7901 struct listnode
*ln
;
7902 struct ospf_area
*area
;
7904 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7905 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7906 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7907 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7908 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7909 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7910 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7912 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7914 vty_out (vty
, " max-metric router-lsa administrative%s",
7923 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7925 struct route_node
*rn
;
7926 struct ospf_route
*or;
7927 struct listnode
*pnode
, *pnnode
;
7928 struct ospf_path
*path
;
7930 vty_out (vty
, "============ OSPF network routing table ============%s",
7933 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7934 if ((or = rn
->info
) != NULL
)
7937 snprintf (buf1
, 19, "%s/%d",
7938 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7940 switch (or->path_type
)
7942 case OSPF_PATH_INTER_AREA
:
7943 if (or->type
== OSPF_DESTINATION_NETWORK
)
7944 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7945 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7946 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7947 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7949 case OSPF_PATH_INTRA_AREA
:
7950 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7951 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7957 if (or->type
== OSPF_DESTINATION_NETWORK
)
7958 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7960 if (if_lookup_by_index(path
->ifindex
))
7962 if (path
->nexthop
.s_addr
== 0)
7963 vty_out (vty
, "%24s directly attached to %s%s",
7964 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7966 vty_out (vty
, "%24s via %s, %s%s", "",
7967 inet_ntoa (path
->nexthop
),
7968 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7972 vty_out (vty
, "%s", VTY_NEWLINE
);
7976 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7978 struct route_node
*rn
;
7979 struct ospf_route
*or;
7980 struct listnode
*pnode
;
7981 struct listnode
*node
;
7982 struct ospf_path
*path
;
7984 vty_out (vty
, "============ OSPF router routing table =============%s",
7986 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7991 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7993 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7996 vty_out (vty
, "%24s", "");
7999 vty_out (vty
, "%s [%d] area: %s",
8000 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
8001 or->cost
, inet_ntoa (or->u
.std
.area_id
));
8003 vty_out (vty
, "%s%s%s",
8004 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
8005 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
8008 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8010 if (if_lookup_by_index(path
->ifindex
))
8012 if (path
->nexthop
.s_addr
== 0)
8013 vty_out (vty
, "%24s directly attached to %s%s",
8014 "", ifindex2ifname (path
->ifindex
),
8017 vty_out (vty
, "%24s via %s, %s%s", "",
8018 inet_ntoa (path
->nexthop
),
8019 ifindex2ifname (path
->ifindex
),
8025 vty_out (vty
, "%s", VTY_NEWLINE
);
8029 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8031 struct route_node
*rn
;
8032 struct ospf_route
*er
;
8033 struct listnode
*pnode
, *pnnode
;
8034 struct ospf_path
*path
;
8036 vty_out (vty
, "============ OSPF external routing table ===========%s",
8038 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8039 if ((er
= rn
->info
) != NULL
)
8042 snprintf (buf1
, 19, "%s/%d",
8043 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8045 switch (er
->path_type
)
8047 case OSPF_PATH_TYPE1_EXTERNAL
:
8048 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8049 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8051 case OSPF_PATH_TYPE2_EXTERNAL
:
8052 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8053 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8057 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8059 if (if_lookup_by_index(path
->ifindex
))
8061 if (path
->nexthop
.s_addr
== 0)
8062 vty_out (vty
, "%24s directly attached to %s%s",
8063 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8065 vty_out (vty
, "%24s via %s, %s%s", "",
8066 inet_ntoa (path
->nexthop
),
8067 ifindex2ifname (path
->ifindex
),
8072 vty_out (vty
, "%s", VTY_NEWLINE
);
8076 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8079 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8080 VTY_NEWLINE
, VTY_NEWLINE
);
8082 if (ospf
->new_table
== NULL
)
8084 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8088 /* Show Network routes.
8089 show_ip_ospf_route_network (vty, ospf->new_table); */
8091 /* Show Router routes. */
8092 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8094 vty_out (vty
, "%s", VTY_NEWLINE
);
8099 DEFUN (show_ip_ospf_border_routers
,
8100 show_ip_ospf_border_routers_cmd
,
8101 "show ip ospf border-routers",
8104 "OSPF information\n"
8105 "Show all the ABR's and ASBR's\n")
8109 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8112 return show_ip_ospf_border_routers_common(vty
, ospf
);
8115 DEFUN (show_ip_ospf_instance_border_routers
,
8116 show_ip_ospf_instance_border_routers_cmd
,
8117 "show ip ospf (1-65535) border-routers",
8120 "OSPF information\n"
8122 "Show all the ABR's and ASBR's\n")
8126 u_short instance
= 0;
8128 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8129 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8132 return show_ip_ospf_border_routers_common(vty
, ospf
);
8136 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8139 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8140 VTY_NEWLINE
, VTY_NEWLINE
);
8142 if (ospf
->new_table
== NULL
)
8144 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8148 /* Show Network routes. */
8149 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8151 /* Show Router routes. */
8152 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8154 /* Show AS External routes. */
8155 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8157 vty_out (vty
, "%s", VTY_NEWLINE
);
8162 DEFUN (show_ip_ospf_route
,
8163 show_ip_ospf_route_cmd
,
8164 "show ip ospf route",
8167 "OSPF information\n"
8168 "OSPF routing table\n")
8172 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8175 return show_ip_ospf_route_common(vty
, ospf
);
8178 DEFUN (show_ip_ospf_instance_route
,
8179 show_ip_ospf_instance_route_cmd
,
8180 "show ip ospf (1-65535) route",
8183 "OSPF information\n"
8185 "OSPF routing table\n")
8189 u_short instance
= 0;
8191 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8192 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8195 return show_ip_ospf_route_common(vty
, ospf
);
8198 const char *ospf_abr_type_str
[] =
8207 const char *ospf_shortcut_mode_str
[] =
8216 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8218 memset (buf
, 0, length
);
8220 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8221 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8223 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8227 const char *ospf_int_type_str
[] =
8229 "unknown", /* should never be used. */
8233 "point-to-multipoint",
8234 "virtual-link", /* should never be used. */
8238 /* Configuration write function for ospfd. */
8240 config_write_interface (struct vty
*vty
)
8242 struct listnode
*n1
, *n2
;
8243 struct interface
*ifp
;
8244 struct crypt_key
*ck
;
8246 struct route_node
*rn
= NULL
;
8247 struct ospf_if_params
*params
;
8248 struct ospf
*ospf
= ospf_lookup();
8250 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8252 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8255 if (ifp
->ifindex
== IFINDEX_DELETED
)
8258 vty_out (vty
, "!%s", VTY_NEWLINE
);
8259 vty_out (vty
, "interface %s%s", ifp
->name
,
8262 vty_out (vty
, " description %s%s", ifp
->desc
,
8267 params
= IF_DEF_PARAMS (ifp
);
8270 /* Interface Network print. */
8271 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8272 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8274 if (params
->type
!= ospf_default_iftype(ifp
))
8276 vty_out (vty
, " ip ospf network %s",
8277 ospf_int_type_str
[params
->type
]);
8278 if (params
!= IF_DEF_PARAMS (ifp
))
8279 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8280 vty_out (vty
, "%s", VTY_NEWLINE
);
8284 /* OSPF interface authentication print */
8285 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8286 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8288 const char *auth_str
;
8290 /* Translation tables are not that much help here due to syntax
8291 of the simple option */
8292 switch (params
->auth_type
)
8295 case OSPF_AUTH_NULL
:
8299 case OSPF_AUTH_SIMPLE
:
8303 case OSPF_AUTH_CRYPTOGRAPHIC
:
8304 auth_str
= " message-digest";
8312 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8313 if (params
!= IF_DEF_PARAMS (ifp
))
8314 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8315 vty_out (vty
, "%s", VTY_NEWLINE
);
8318 /* Simple Authentication Password print. */
8319 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8320 params
->auth_simple
[0] != '\0')
8322 vty_out (vty
, " ip ospf authentication-key %s",
8323 params
->auth_simple
);
8324 if (params
!= IF_DEF_PARAMS (ifp
))
8325 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8326 vty_out (vty
, "%s", VTY_NEWLINE
);
8329 /* Cryptographic Authentication Key print. */
8330 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8332 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8333 ck
->key_id
, ck
->auth_key
);
8334 if (params
!= IF_DEF_PARAMS (ifp
))
8335 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8336 vty_out (vty
, "%s", VTY_NEWLINE
);
8339 /* Interface Output Cost print. */
8340 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8342 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8343 if (params
!= IF_DEF_PARAMS (ifp
))
8344 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8345 vty_out (vty
, "%s", VTY_NEWLINE
);
8348 /* Hello Interval print. */
8349 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8350 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8352 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8353 if (params
!= IF_DEF_PARAMS (ifp
))
8354 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8355 vty_out (vty
, "%s", VTY_NEWLINE
);
8359 /* Router Dead Interval print. */
8360 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8361 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8363 vty_out (vty
, " ip ospf dead-interval ");
8366 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8367 vty_out (vty
, "minimal hello-multiplier %d",
8368 params
->fast_hello
);
8370 vty_out (vty
, "%u", params
->v_wait
);
8372 if (params
!= IF_DEF_PARAMS (ifp
))
8373 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8374 vty_out (vty
, "%s", VTY_NEWLINE
);
8377 /* Router Priority print. */
8378 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8379 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8381 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8382 if (params
!= IF_DEF_PARAMS (ifp
))
8383 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8384 vty_out (vty
, "%s", VTY_NEWLINE
);
8387 /* Retransmit Interval print. */
8388 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8389 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8391 vty_out (vty
, " ip ospf retransmit-interval %u",
8392 params
->retransmit_interval
);
8393 if (params
!= IF_DEF_PARAMS (ifp
))
8394 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8395 vty_out (vty
, "%s", VTY_NEWLINE
);
8398 /* Transmit Delay print. */
8399 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8400 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8402 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8403 if (params
!= IF_DEF_PARAMS (ifp
))
8404 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8405 vty_out (vty
, "%s", VTY_NEWLINE
);
8409 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8412 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8413 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8415 vty_out (vty
, " ip ospf area %s%s",
8416 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8421 ospf_bfd_write_config(vty
, params
);
8423 /* MTU ignore print. */
8424 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8425 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8427 if (params
->mtu_ignore
== 0)
8428 vty_out (vty
, " no ip ospf mtu-ignore");
8430 vty_out (vty
, " ip ospf mtu-ignore");
8431 if (params
!= IF_DEF_PARAMS (ifp
))
8432 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8433 vty_out (vty
, "%s", VTY_NEWLINE
);
8440 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8442 rn
= route_next (rn
);
8452 ospf_opaque_config_write_if (vty
, ifp
);
8459 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8461 struct route_node
*rn
;
8462 u_char buf
[INET_ADDRSTRLEN
];
8464 /* `network area' print. */
8465 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8468 struct ospf_network
*n
= rn
->info
;
8470 memset (buf
, 0, INET_ADDRSTRLEN
);
8472 /* Create Area ID string by specified Area ID format. */
8473 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8474 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8476 sprintf ((char *) buf
, "%lu",
8477 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8479 /* Network print. */
8480 vty_out (vty
, " network %s/%d area %s%s",
8481 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8489 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8491 struct listnode
*node
;
8492 struct ospf_area
*area
;
8493 u_char buf
[INET_ADDRSTRLEN
];
8495 /* Area configuration print. */
8496 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8498 struct route_node
*rn1
;
8500 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8502 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8504 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8505 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8507 vty_out (vty
, " area %s authentication message-digest%s",
8511 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8512 vty_out (vty
, " area %s shortcut %s%s", buf
,
8513 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8516 if ((area
->external_routing
== OSPF_AREA_STUB
)
8517 || (area
->external_routing
== OSPF_AREA_NSSA
)
8520 if (area
->external_routing
== OSPF_AREA_STUB
)
8521 vty_out (vty
, " area %s stub", buf
);
8522 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8524 vty_out (vty
, " area %s nssa", buf
);
8525 switch (area
->NSSATranslatorRole
)
8527 case OSPF_NSSA_ROLE_NEVER
:
8528 vty_out (vty
, " translate-never");
8530 case OSPF_NSSA_ROLE_ALWAYS
:
8531 vty_out (vty
, " translate-always");
8533 case OSPF_NSSA_ROLE_CANDIDATE
:
8535 vty_out (vty
, " translate-candidate");
8539 if (area
->no_summary
)
8540 vty_out (vty
, " no-summary");
8542 vty_out (vty
, "%s", VTY_NEWLINE
);
8544 if (area
->default_cost
!= 1)
8545 vty_out (vty
, " area %s default-cost %d%s", buf
,
8546 area
->default_cost
, VTY_NEWLINE
);
8549 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8552 struct ospf_area_range
*range
= rn1
->info
;
8554 vty_out (vty
, " area %s range %s/%d", buf
,
8555 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8557 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8558 vty_out (vty
, " cost %d", range
->cost_config
);
8560 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8561 vty_out (vty
, " not-advertise");
8563 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8564 vty_out (vty
, " substitute %s/%d",
8565 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8567 vty_out (vty
, "%s", VTY_NEWLINE
);
8570 if (EXPORT_NAME (area
))
8571 vty_out (vty
, " area %s export-list %s%s", buf
,
8572 EXPORT_NAME (area
), VTY_NEWLINE
);
8574 if (IMPORT_NAME (area
))
8575 vty_out (vty
, " area %s import-list %s%s", buf
,
8576 IMPORT_NAME (area
), VTY_NEWLINE
);
8578 if (PREFIX_NAME_IN (area
))
8579 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8580 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8582 if (PREFIX_NAME_OUT (area
))
8583 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8584 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8591 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8593 struct ospf_nbr_nbma
*nbr_nbma
;
8594 struct route_node
*rn
;
8596 /* Static Neighbor configuration print. */
8597 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8598 if ((nbr_nbma
= rn
->info
))
8600 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8602 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8603 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8605 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8606 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8608 vty_out (vty
, "%s", VTY_NEWLINE
);
8615 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8617 struct listnode
*node
;
8618 struct ospf_vl_data
*vl_data
;
8619 u_char buf
[INET_ADDRSTRLEN
];
8621 /* Virtual-Link print */
8622 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8624 struct listnode
*n2
;
8625 struct crypt_key
*ck
;
8626 struct ospf_interface
*oi
;
8628 if (vl_data
!= NULL
)
8630 memset (buf
, 0, INET_ADDRSTRLEN
);
8632 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8633 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8635 sprintf ((char *) buf
, "%lu",
8636 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8637 oi
= vl_data
->vl_oi
;
8640 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8641 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8642 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8643 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8644 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8646 inet_ntoa (vl_data
->vl_peer
),
8647 OSPF_IF_PARAM (oi
, v_hello
),
8648 OSPF_IF_PARAM (oi
, retransmit_interval
),
8649 OSPF_IF_PARAM (oi
, transmit_delay
),
8650 OSPF_IF_PARAM (oi
, v_wait
),
8653 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8654 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8656 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8657 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8659 inet_ntoa (vl_data
->vl_peer
),
8660 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8663 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8665 vty_out (vty
, " area %s virtual-link %s"
8666 " message-digest-key %d md5 %s%s",
8668 inet_ntoa (vl_data
->vl_peer
),
8669 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8679 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8683 /* redistribute print. */
8684 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8686 struct list
*red_list
;
8687 struct listnode
*node
;
8688 struct ospf_redist
*red
;
8690 red_list
= ospf
->redist
[type
];
8694 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8696 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8698 vty_out (vty
, " %d", red
->instance
);
8700 if (red
->dmetric
.value
>= 0)
8701 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8703 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8704 vty_out (vty
, " metric-type 1");
8706 if (ROUTEMAP_NAME (red
))
8707 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8709 vty_out (vty
, "%s", VTY_NEWLINE
);
8717 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8719 if (ospf
->default_metric
!= -1)
8720 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8726 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8729 struct ospf_redist
*red
;
8733 /* distribute-list print. */
8734 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8735 if (DISTRIBUTE_NAME (ospf
, type
))
8736 vty_out (vty
, " distribute-list %s out %s%s",
8737 DISTRIBUTE_NAME (ospf
, type
),
8738 zebra_route_string(type
), VTY_NEWLINE
);
8740 /* default-information print. */
8741 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8743 vty_out (vty
, " default-information originate");
8744 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8745 vty_out (vty
, " always");
8747 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8750 if (red
->dmetric
.value
>= 0)
8751 vty_out (vty
, " metric %d",
8752 red
->dmetric
.value
);
8753 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8754 vty_out (vty
, " metric-type 1");
8756 if (ROUTEMAP_NAME (red
))
8757 vty_out (vty
, " route-map %s",
8758 ROUTEMAP_NAME (red
));
8761 vty_out (vty
, "%s", VTY_NEWLINE
);
8770 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8772 struct route_node
*rn
;
8773 struct ospf_distance
*odistance
;
8775 if (ospf
->distance_all
)
8776 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8778 if (ospf
->distance_intra
8779 || ospf
->distance_inter
8780 || ospf
->distance_external
)
8782 vty_out (vty
, " distance ospf");
8784 if (ospf
->distance_intra
)
8785 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8786 if (ospf
->distance_inter
)
8787 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8788 if (ospf
->distance_external
)
8789 vty_out (vty
, " external %d", ospf
->distance_external
);
8791 vty_out (vty
, "%s", VTY_NEWLINE
);
8794 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8795 if ((odistance
= rn
->info
) != NULL
)
8797 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8798 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8799 odistance
->access_list
? odistance
->access_list
: "",
8805 /* OSPF configuration write function. */
8807 ospf_config_write (struct vty
*vty
)
8810 struct interface
*ifp
;
8811 struct ospf_interface
*oi
;
8812 struct listnode
*node
;
8815 ospf
= ospf_lookup ();
8816 if (ospf
!= NULL
&& ospf
->oi_running
)
8818 /* `router ospf' print. */
8820 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8822 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8826 if (!ospf
->networks
)
8829 /* Router ID print. */
8830 if (ospf
->router_id_static
.s_addr
!= 0)
8831 vty_out (vty
, " ospf router-id %s%s",
8832 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8834 /* ABR type print. */
8835 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8836 vty_out (vty
, " ospf abr-type %s%s",
8837 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8839 /* log-adjacency-changes flag print. */
8840 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8842 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8843 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8847 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8850 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8851 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8852 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8854 /* auto-cost reference-bandwidth configuration. */
8855 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8857 vty_out (vty
, "! Important: ensure reference bandwidth "
8858 "is consistent across all routers%s", VTY_NEWLINE
);
8859 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8860 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8863 /* SPF timers print. */
8864 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8865 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8866 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8867 vty_out (vty
, " timers throttle spf %d %d %d%s",
8868 ospf
->spf_delay
, ospf
->spf_holdtime
,
8869 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8871 /* LSA timers print. */
8872 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8873 vty_out (vty
, " timers throttle lsa all %d%s",
8874 ospf
->min_ls_interval
, VTY_NEWLINE
);
8875 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8876 vty_out (vty
, " timers lsa min-arrival %d%s",
8877 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8879 /* Write multiplier print. */
8880 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8881 vty_out (vty
, " ospf write-multiplier %d%s",
8882 ospf
->write_oi_count
, VTY_NEWLINE
);
8884 /* Max-metric router-lsa print */
8885 config_write_stub_router (vty
, ospf
);
8887 /* SPF refresh parameters print. */
8888 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8889 vty_out (vty
, " refresh timer %d%s",
8890 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8892 /* Redistribute information print. */
8893 config_write_ospf_redistribute (vty
, ospf
);
8895 /* passive-interface print. */
8896 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8897 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8899 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8900 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8901 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8902 ospf
->passive_interface_default
)
8904 vty_out (vty
, " %spassive-interface %s%s",
8905 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8906 ifp
->name
, VTY_NEWLINE
);
8908 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8910 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8912 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8915 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8918 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8921 vty_out (vty
, " %spassive-interface %s %s%s",
8922 oi
->params
->passive_interface
? "" : "no ",
8924 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8927 /* Network area print. */
8928 config_write_network_area (vty
, ospf
);
8930 /* Area config print. */
8931 config_write_ospf_area (vty
, ospf
);
8933 /* static neighbor print. */
8934 config_write_ospf_nbr_nbma (vty
, ospf
);
8936 /* Virtual-Link print. */
8937 config_write_virtual_link (vty
, ospf
);
8939 /* Default metric configuration. */
8940 config_write_ospf_default_metric (vty
, ospf
);
8942 /* Distribute-list and default-information print. */
8943 config_write_ospf_distribute (vty
, ospf
);
8945 /* Distance configuration. */
8946 config_write_ospf_distance (vty
, ospf
);
8948 ospf_opaque_config_write_router (vty
, ospf
);
8955 ospf_vty_show_init (void)
8957 /* "show ip ospf" commands. */
8958 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8960 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8962 /* "show ip ospf database" commands. */
8963 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8964 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8966 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8967 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8968 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8970 /* "show ip ospf interface" commands. */
8971 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8973 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8975 /* "show ip ospf neighbor" commands. */
8976 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8977 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8978 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8979 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8980 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8981 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8982 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8984 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8985 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8986 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8987 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8988 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8989 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8990 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8992 /* "show ip ospf route" commands. */
8993 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8994 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8996 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8997 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9001 /* ospfd's interface node. */
9002 static struct cmd_node interface_node
=
9009 /* Initialization of OSPF interface. */
9011 ospf_vty_if_init (void)
9013 /* Install interface node. */
9014 install_node (&interface_node
, config_write_interface
);
9017 /* "ip ospf authentication" commands. */
9018 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9019 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9020 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9021 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9022 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9023 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9024 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9026 /* "ip ospf message-digest-key" commands. */
9027 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9028 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9030 /* "ip ospf cost" commands. */
9031 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9032 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9034 /* "ip ospf mtu-ignore" commands. */
9035 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9036 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9038 /* "ip ospf dead-interval" commands. */
9039 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9040 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9041 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9043 /* "ip ospf hello-interval" commands. */
9044 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9045 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9047 /* "ip ospf network" commands. */
9048 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9049 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9051 /* "ip ospf priority" commands. */
9052 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9053 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9055 /* "ip ospf retransmit-interval" commands. */
9056 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9057 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9059 /* "ip ospf transmit-delay" commands. */
9060 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9061 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9063 /* "ip ospf area" commands. */
9064 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9065 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9067 /* These commands are compatibitliy for previous version. */
9068 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9069 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9070 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9071 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9072 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9073 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9074 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9075 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9076 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9077 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9078 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9079 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9080 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9081 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9082 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9083 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9084 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9088 ospf_vty_zebra_init (void)
9090 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9091 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9092 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9093 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9095 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9096 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9098 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9099 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9101 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9102 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9104 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9105 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9106 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9107 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9109 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9110 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9111 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9112 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9116 static struct cmd_node ospf_node
=
9119 "%s(config-router)# ",
9124 ospf_interface_clear (struct interface
*ifp
)
9126 if (!if_is_operative (ifp
)) return;
9128 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9129 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
9134 DEFUN (clear_ip_ospf_interface
,
9135 clear_ip_ospf_interface_cmd
,
9136 "clear ip ospf interface [IFNAME]",
9139 "OSPF information\n"
9140 "Interface information\n"
9144 struct interface
*ifp
;
9145 struct listnode
*node
;
9147 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9149 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9150 ospf_interface_clear(ifp
);
9152 else /* Interface name is specified. */
9154 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
9155 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9157 ospf_interface_clear(ifp
);
9164 ospf_vty_clear_init (void)
9166 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9170 /* Install OSPF related vty commands. */
9172 ospf_vty_init (void)
9174 /* Install ospf top node. */
9175 install_node (&ospf_node
, ospf_config_write
);
9177 /* "router ospf" commands. */
9178 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9179 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9182 install_default (OSPF_NODE
);
9184 /* "ospf router-id" commands. */
9185 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9186 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9187 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9189 /* "passive-interface" commands. */
9190 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9191 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9193 /* "ospf abr-type" commands. */
9194 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9195 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9197 /* "ospf log-adjacency-changes" commands. */
9198 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9199 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9200 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9201 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9203 /* "ospf rfc1583-compatible" commands. */
9204 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9205 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9206 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9207 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9209 /* "network area" commands. */
9210 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9211 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9213 /* "area authentication" commands. */
9214 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9215 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9216 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9218 /* "area range" commands. */
9219 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9220 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9221 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9222 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9223 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9224 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9226 /* "area virtual-link" commands. */
9227 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9228 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9229 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9230 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9241 /* "area stub" commands. */
9242 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9243 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9244 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9245 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9247 /* "area nssa" commands. */
9248 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9249 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9250 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9251 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9252 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9254 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9255 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9257 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9258 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9260 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9261 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9263 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9264 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9266 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9267 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9269 /* SPF timer commands */
9270 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9271 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9273 /* LSA timers commands */
9274 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9275 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9276 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9277 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9278 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9279 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9281 /* refresh timer commands */
9282 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9283 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9285 /* max-metric commands */
9286 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9287 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9288 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9289 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9290 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9291 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9293 /* reference bandwidth commands */
9294 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9295 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9297 /* "neighbor" commands. */
9298 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9299 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9300 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9301 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9303 /* write multiplier commands */
9304 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9305 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9306 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9307 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9309 /* Init interface related vty commands. */
9310 ospf_vty_if_init ();
9312 /* Init zebra related vty commands. */
9313 ospf_vty_zebra_init ();