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 */
1269 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1270 if (vl_config
.crypto_key_id
< 0)
1272 vl_config
.md5_key
= NULL
;
1279 /* Action configuration */
1281 return ospf_vl_set (ospf
, &vl_config
);
1284 DEFUN (no_ospf_area_vlink_intervals
,
1285 no_ospf_area_vlink_intervals_cmd
,
1286 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1287 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1288 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1289 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1290 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1293 VLINK_HELPSTR_IPADDR
1294 VLINK_HELPSTR_TIME_PARAM
1295 VLINK_HELPSTR_TIME_PARAM
1296 VLINK_HELPSTR_TIME_PARAM
1297 VLINK_HELPSTR_TIME_PARAM
)
1299 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1300 struct ospf_vl_config_data vl_config
;
1303 ospf_vl_config_data_init(&vl_config
, vty
);
1305 char *area_id
= argv
[2]->arg
;
1306 char *router_id
= argv
[4]->arg
;
1308 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1311 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1315 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1318 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1322 for (unsigned int i
= 0; i
< 4; i
++)
1325 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1326 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1327 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1328 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1329 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1330 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1331 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1332 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1335 /* Action configuration */
1336 return ospf_vl_set (ospf
, &vl_config
);
1339 DEFUN (ospf_area_shortcut
,
1340 ospf_area_shortcut_cmd
,
1341 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1342 "OSPF area parameters\n"
1343 "OSPF area ID in IP address format\n"
1344 "OSPF area ID as a decimal value\n"
1345 "Configure the area's shortcutting mode\n"
1346 "Set default shortcutting behavior\n"
1347 "Enable shortcutting through the area\n"
1348 "Disable shortcutting through the area\n")
1350 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1351 int idx_ipv4_number
= 1;
1352 int idx_enable_disable
= 3;
1353 struct ospf_area
*area
;
1354 struct in_addr area_id
;
1358 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1360 area
= ospf_area_get (ospf
, area_id
, format
);
1362 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1363 mode
= OSPF_SHORTCUT_DEFAULT
;
1364 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1365 mode
= OSPF_SHORTCUT_DISABLE
;
1366 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1367 mode
= OSPF_SHORTCUT_ENABLE
;
1371 ospf_area_shortcut_set (ospf
, area
, mode
);
1373 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1374 vty_out (vty
, "Shortcut area setting will take effect "
1375 "only when the router is configured as Shortcut ABR%s",
1381 DEFUN (no_ospf_area_shortcut
,
1382 no_ospf_area_shortcut_cmd
,
1383 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1385 "OSPF area parameters\n"
1386 "OSPF area ID in IP address format\n"
1387 "OSPF area ID as a decimal value\n"
1388 "Deconfigure the area's shortcutting mode\n"
1389 "Deconfigure enabled shortcutting through the area\n"
1390 "Deconfigure disabled shortcutting through the area\n")
1392 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1393 int idx_ipv4_number
= 2;
1394 struct ospf_area
*area
;
1395 struct in_addr area_id
;
1398 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1400 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1404 ospf_area_shortcut_unset (ospf
, area
);
1410 DEFUN (ospf_area_stub
,
1412 "area <A.B.C.D|(0-4294967295)> stub",
1413 "OSPF area parameters\n"
1414 "OSPF area ID in IP address format\n"
1415 "OSPF area ID as a decimal value\n"
1416 "Configure OSPF area as stub\n")
1418 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1419 int idx_ipv4_number
= 1;
1420 struct in_addr area_id
;
1423 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1425 ret
= ospf_area_stub_set (ospf
, area_id
);
1428 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1433 ospf_area_no_summary_unset (ospf
, area_id
);
1438 DEFUN (ospf_area_stub_no_summary
,
1439 ospf_area_stub_no_summary_cmd
,
1440 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1441 "OSPF stub parameters\n"
1442 "OSPF area ID in IP address format\n"
1443 "OSPF area ID as a decimal value\n"
1444 "Configure OSPF area as stub\n"
1445 "Do not inject inter-area routes into stub\n")
1447 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1448 int idx_ipv4_number
= 1;
1449 struct in_addr area_id
;
1452 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1454 ret
= ospf_area_stub_set (ospf
, area_id
);
1457 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1462 ospf_area_no_summary_set (ospf
, area_id
);
1467 DEFUN (no_ospf_area_stub
,
1468 no_ospf_area_stub_cmd
,
1469 "no area <A.B.C.D|(0-4294967295)> stub",
1471 "OSPF area parameters\n"
1472 "OSPF area ID in IP address format\n"
1473 "OSPF area ID as a decimal value\n"
1474 "Configure OSPF area as stub\n")
1476 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1477 int idx_ipv4_number
= 2;
1478 struct in_addr area_id
;
1481 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1483 ospf_area_stub_unset (ospf
, area_id
);
1484 ospf_area_no_summary_unset (ospf
, area_id
);
1489 DEFUN (no_ospf_area_stub_no_summary
,
1490 no_ospf_area_stub_no_summary_cmd
,
1491 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1493 "OSPF area parameters\n"
1494 "OSPF area ID in IP address format\n"
1495 "OSPF area ID as a decimal value\n"
1496 "Configure OSPF area as stub\n"
1497 "Do not inject inter-area routes into area\n")
1499 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1500 int idx_ipv4_number
= 2;
1501 struct in_addr area_id
;
1504 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1505 ospf_area_no_summary_unset (ospf
, area_id
);
1511 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1514 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1515 struct in_addr area_id
;
1518 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1520 ret
= ospf_area_nssa_set (ospf
, area_id
);
1523 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1530 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1531 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1532 OSPF_NSSA_ROLE_CANDIDATE
);
1533 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1534 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1535 OSPF_NSSA_ROLE_NEVER
);
1536 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1537 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1538 OSPF_NSSA_ROLE_ALWAYS
);
1542 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1543 OSPF_NSSA_ROLE_CANDIDATE
);
1547 ospf_area_no_summary_set (ospf
, area_id
);
1549 ospf_area_no_summary_unset (ospf
, area_id
);
1551 ospf_schedule_abr_task (ospf
);
1556 DEFUN (ospf_area_nssa_translate_no_summary
,
1557 ospf_area_nssa_translate_no_summary_cmd
,
1558 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1559 "OSPF area parameters\n"
1560 "OSPF area ID in IP address format\n"
1561 "OSPF area ID as a decimal value\n"
1562 "Configure OSPF area as nssa\n"
1563 "Configure NSSA-ABR for translate election (default)\n"
1564 "Configure NSSA-ABR to never translate\n"
1565 "Configure NSSA-ABR to always translate\n"
1566 "Do not inject inter-area routes into nssa\n")
1568 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1571 DEFUN (ospf_area_nssa_translate
,
1572 ospf_area_nssa_translate_cmd
,
1573 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1574 "OSPF area parameters\n"
1575 "OSPF area ID in IP address format\n"
1576 "OSPF area ID as a decimal value\n"
1577 "Configure OSPF area as nssa\n"
1578 "Configure NSSA-ABR for translate election (default)\n"
1579 "Configure NSSA-ABR to never translate\n"
1580 "Configure NSSA-ABR to always translate\n")
1582 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1585 DEFUN (ospf_area_nssa
,
1587 "area <A.B.C.D|(0-4294967295)> nssa",
1588 "OSPF area parameters\n"
1589 "OSPF area ID in IP address format\n"
1590 "OSPF area ID as a decimal value\n"
1591 "Configure OSPF area as nssa\n")
1593 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1596 DEFUN (ospf_area_nssa_no_summary
,
1597 ospf_area_nssa_no_summary_cmd
,
1598 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Do not inject inter-area routes into nssa\n")
1605 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1608 DEFUN (no_ospf_area_nssa
,
1609 no_ospf_area_nssa_cmd
,
1610 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1612 "OSPF area parameters\n"
1613 "OSPF area ID in IP address format\n"
1614 "OSPF area ID as a decimal value\n"
1615 "Configure OSPF area as nssa\n"
1616 "Configure NSSA-ABR for translate election (default)\n"
1617 "Configure NSSA-ABR to never translate\n"
1618 "Configure NSSA-ABR to always translate\n"
1619 "Do not inject inter-area routes into nssa\n")
1621 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1622 int idx_ipv4_number
= 2;
1623 struct in_addr area_id
;
1626 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1628 ospf_area_nssa_unset (ospf
, area_id
);
1629 ospf_area_no_summary_unset (ospf
, area_id
);
1631 ospf_schedule_abr_task (ospf
);
1637 DEFUN (ospf_area_default_cost
,
1638 ospf_area_default_cost_cmd
,
1639 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1640 "OSPF area parameters\n"
1641 "OSPF area ID in IP address format\n"
1642 "OSPF area ID as a decimal value\n"
1643 "Set the summary-default cost of a NSSA or stub area\n"
1644 "Stub's advertised default summary cost\n")
1646 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1647 int idx_ipv4_number
= 1;
1649 struct ospf_area
*area
;
1650 struct in_addr area_id
;
1653 struct prefix_ipv4 p
;
1655 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1656 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1658 area
= ospf_area_get (ospf
, area_id
, format
);
1660 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1662 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1666 area
->default_cost
= cost
;
1669 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1671 if (IS_DEBUG_OSPF_EVENT
)
1672 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1673 "announcing 0.0.0.0/0 to area %s",
1674 inet_ntoa (area
->area_id
));
1675 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1680 DEFUN (no_ospf_area_default_cost
,
1681 no_ospf_area_default_cost_cmd
,
1682 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1684 "OSPF area parameters\n"
1685 "OSPF area ID in IP address format\n"
1686 "OSPF area ID as a decimal value\n"
1687 "Set the summary-default cost of a NSSA or stub area\n"
1688 "Stub's advertised default summary cost\n")
1690 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1691 int idx_ipv4_number
= 2;
1693 struct ospf_area
*area
;
1694 struct in_addr area_id
;
1696 struct prefix_ipv4 p
;
1698 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1699 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1701 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1705 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1707 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1711 area
->default_cost
= 1;
1714 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1716 if (IS_DEBUG_OSPF_EVENT
)
1717 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1718 "announcing 0.0.0.0/0 to area %s",
1719 inet_ntoa (area
->area_id
));
1720 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1723 ospf_area_check_free (ospf
, area_id
);
1728 DEFUN (ospf_area_export_list
,
1729 ospf_area_export_list_cmd
,
1730 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1731 "OSPF area parameters\n"
1732 "OSPF area ID in IP address format\n"
1733 "OSPF area ID as a decimal value\n"
1734 "Set the filter for networks announced to other areas\n"
1735 "Name of the access-list\n")
1737 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1738 int idx_ipv4_number
= 1;
1739 struct ospf_area
*area
;
1740 struct in_addr area_id
;
1743 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1745 area
= ospf_area_get (ospf
, area_id
, format
);
1746 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1751 DEFUN (no_ospf_area_export_list
,
1752 no_ospf_area_export_list_cmd
,
1753 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1755 "OSPF area parameters\n"
1756 "OSPF area ID in IP address format\n"
1757 "OSPF area ID as a decimal value\n"
1758 "Unset the filter for networks announced to other areas\n"
1759 "Name of the access-list\n")
1761 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1762 int idx_ipv4_number
= 2;
1763 struct ospf_area
*area
;
1764 struct in_addr area_id
;
1767 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1769 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1773 ospf_area_export_list_unset (ospf
, area
);
1779 DEFUN (ospf_area_import_list
,
1780 ospf_area_import_list_cmd
,
1781 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1782 "OSPF area parameters\n"
1783 "OSPF area ID in IP address format\n"
1784 "OSPF area ID as a decimal value\n"
1785 "Set the filter for networks from other areas announced to the specified one\n"
1786 "Name of the access-list\n")
1788 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1789 int idx_ipv4_number
= 1;
1790 struct ospf_area
*area
;
1791 struct in_addr area_id
;
1794 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1796 area
= ospf_area_get (ospf
, area_id
, format
);
1797 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1802 DEFUN (no_ospf_area_import_list
,
1803 no_ospf_area_import_list_cmd
,
1804 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1806 "OSPF area parameters\n"
1807 "OSPF area ID in IP address format\n"
1808 "OSPF area ID as a decimal value\n"
1809 "Unset the filter for networks announced to other areas\n"
1810 "Name of the access-list\n")
1812 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1813 int idx_ipv4_number
= 2;
1814 struct ospf_area
*area
;
1815 struct in_addr area_id
;
1818 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1820 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1824 ospf_area_import_list_unset (ospf
, area
);
1829 DEFUN (ospf_area_filter_list
,
1830 ospf_area_filter_list_cmd
,
1831 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1832 "OSPF area parameters\n"
1833 "OSPF area ID in IP address format\n"
1834 "OSPF area ID as a decimal value\n"
1835 "Filter networks between OSPF areas\n"
1836 "Filter prefixes between OSPF areas\n"
1837 "Name of an IP prefix-list\n"
1838 "Filter networks sent to this area\n"
1839 "Filter networks sent from this area\n")
1841 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1842 int idx_ipv4_number
= 1;
1845 struct ospf_area
*area
;
1846 struct in_addr area_id
;
1847 struct prefix_list
*plist
;
1850 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1852 area
= ospf_area_get (ospf
, area_id
, format
);
1853 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1854 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1856 PREFIX_LIST_IN (area
) = plist
;
1857 if (PREFIX_NAME_IN (area
))
1858 free (PREFIX_NAME_IN (area
));
1860 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1861 ospf_schedule_abr_task (ospf
);
1865 PREFIX_LIST_OUT (area
) = plist
;
1866 if (PREFIX_NAME_OUT (area
))
1867 free (PREFIX_NAME_OUT (area
));
1869 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1870 ospf_schedule_abr_task (ospf
);
1876 DEFUN (no_ospf_area_filter_list
,
1877 no_ospf_area_filter_list_cmd
,
1878 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1880 "OSPF area parameters\n"
1881 "OSPF area ID in IP address format\n"
1882 "OSPF area ID as a decimal value\n"
1883 "Filter networks between OSPF areas\n"
1884 "Filter prefixes between OSPF areas\n"
1885 "Name of an IP prefix-list\n"
1886 "Filter networks sent to this area\n"
1887 "Filter networks sent from this area\n")
1889 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1890 int idx_ipv4_number
= 2;
1893 struct ospf_area
*area
;
1894 struct in_addr area_id
;
1897 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1899 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1902 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1904 if (PREFIX_NAME_IN (area
))
1905 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1908 PREFIX_LIST_IN (area
) = NULL
;
1909 if (PREFIX_NAME_IN (area
))
1910 free (PREFIX_NAME_IN (area
));
1912 PREFIX_NAME_IN (area
) = NULL
;
1914 ospf_schedule_abr_task (ospf
);
1918 if (PREFIX_NAME_OUT (area
))
1919 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1922 PREFIX_LIST_OUT (area
) = NULL
;
1923 if (PREFIX_NAME_OUT (area
))
1924 free (PREFIX_NAME_OUT (area
));
1926 PREFIX_NAME_OUT (area
) = NULL
;
1928 ospf_schedule_abr_task (ospf
);
1935 DEFUN (ospf_area_authentication_message_digest
,
1936 ospf_area_authentication_message_digest_cmd
,
1937 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1938 "OSPF area parameters\n"
1939 "OSPF area ID in IP address format\n"
1940 "OSPF area ID as a decimal value\n"
1941 "Enable authentication\n"
1942 "Use message-digest authentication\n")
1944 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1945 int idx_ipv4_number
= 1;
1946 struct ospf_area
*area
;
1947 struct in_addr area_id
;
1950 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1952 area
= ospf_area_get (ospf
, area_id
, format
);
1953 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1958 DEFUN (ospf_area_authentication
,
1959 ospf_area_authentication_cmd
,
1960 "area <A.B.C.D|(0-4294967295)> authentication",
1961 "OSPF area parameters\n"
1962 "OSPF area ID in IP address format\n"
1963 "OSPF area ID as a decimal value\n"
1964 "Enable authentication\n")
1966 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1967 int idx_ipv4_number
= 1;
1968 struct ospf_area
*area
;
1969 struct in_addr area_id
;
1972 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1974 area
= ospf_area_get (ospf
, area_id
, format
);
1975 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1980 DEFUN (no_ospf_area_authentication
,
1981 no_ospf_area_authentication_cmd
,
1982 "no area <A.B.C.D|(0-4294967295)> authentication",
1984 "OSPF area parameters\n"
1985 "OSPF area ID in IP address format\n"
1986 "OSPF area ID as a decimal value\n"
1987 "Enable authentication\n")
1989 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1990 int idx_ipv4_number
= 2;
1991 struct ospf_area
*area
;
1992 struct in_addr area_id
;
1995 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1997 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2001 area
->auth_type
= OSPF_AUTH_NULL
;
2003 ospf_area_check_free (ospf
, area_id
);
2009 DEFUN (ospf_abr_type
,
2011 "ospf abr-type <cisco|ibm|shortcut|standard>",
2012 "OSPF specific commands\n"
2013 "Set OSPF ABR type\n"
2014 "Alternative ABR, cisco implementation\n"
2015 "Alternative ABR, IBM implementation\n"
2017 "Standard behavior (RFC2328)\n")
2019 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2021 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2023 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2024 abr_type
= OSPF_ABR_CISCO
;
2025 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2026 abr_type
= OSPF_ABR_IBM
;
2027 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2028 abr_type
= OSPF_ABR_SHORTCUT
;
2029 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2030 abr_type
= OSPF_ABR_STAND
;
2034 /* If ABR type value is changed, schedule ABR task. */
2035 if (ospf
->abr_type
!= abr_type
)
2037 ospf
->abr_type
= abr_type
;
2038 ospf_schedule_abr_task (ospf
);
2044 DEFUN (no_ospf_abr_type
,
2045 no_ospf_abr_type_cmd
,
2046 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2048 "OSPF specific commands\n"
2049 "Set OSPF ABR type\n"
2050 "Alternative ABR, cisco implementation\n"
2051 "Alternative ABR, IBM implementation\n"
2055 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2057 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2059 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2060 abr_type
= OSPF_ABR_CISCO
;
2061 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2062 abr_type
= OSPF_ABR_IBM
;
2063 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2064 abr_type
= OSPF_ABR_SHORTCUT
;
2065 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2066 abr_type
= OSPF_ABR_STAND
;
2070 /* If ABR type value is changed, schedule ABR task. */
2071 if (ospf
->abr_type
== abr_type
)
2073 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2074 ospf_schedule_abr_task (ospf
);
2080 DEFUN (ospf_log_adjacency_changes
,
2081 ospf_log_adjacency_changes_cmd
,
2082 "log-adjacency-changes",
2083 "Log changes in adjacency state\n")
2085 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2087 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2088 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2092 DEFUN (ospf_log_adjacency_changes_detail
,
2093 ospf_log_adjacency_changes_detail_cmd
,
2094 "log-adjacency-changes detail",
2095 "Log changes in adjacency state\n"
2096 "Log all state changes\n")
2098 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2100 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2101 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2105 DEFUN (no_ospf_log_adjacency_changes
,
2106 no_ospf_log_adjacency_changes_cmd
,
2107 "no log-adjacency-changes",
2109 "Log changes in adjacency state\n")
2111 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2113 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2114 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2118 DEFUN (no_ospf_log_adjacency_changes_detail
,
2119 no_ospf_log_adjacency_changes_detail_cmd
,
2120 "no log-adjacency-changes detail",
2122 "Log changes in adjacency state\n"
2123 "Log all state changes\n")
2125 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2127 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2128 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2132 DEFUN (ospf_compatible_rfc1583
,
2133 ospf_compatible_rfc1583_cmd
,
2134 "compatible rfc1583",
2135 "OSPF compatibility list\n"
2136 "compatible with RFC 1583\n")
2138 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2140 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2142 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2143 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2148 DEFUN (no_ospf_compatible_rfc1583
,
2149 no_ospf_compatible_rfc1583_cmd
,
2150 "no compatible rfc1583",
2152 "OSPF compatibility list\n"
2153 "compatible with RFC 1583\n")
2155 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2157 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2159 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2160 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2165 ALIAS (ospf_compatible_rfc1583
,
2166 ospf_rfc1583_flag_cmd
,
2167 "ospf rfc1583compatibility",
2168 "OSPF specific commands\n"
2169 "Enable the RFC1583Compatibility flag\n")
2171 ALIAS (no_ospf_compatible_rfc1583
,
2172 no_ospf_rfc1583_flag_cmd
,
2173 "no ospf rfc1583compatibility",
2175 "OSPF specific commands\n"
2176 "Disable the RFC1583Compatibility flag\n")
2179 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2183 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2185 ospf
->spf_delay
= delay
;
2186 ospf
->spf_holdtime
= hold
;
2187 ospf
->spf_max_holdtime
= max
;
2192 DEFUN (ospf_timers_min_ls_interval
,
2193 ospf_timers_min_ls_interval_cmd
,
2194 "timers throttle lsa all (0-5000)",
2195 "Adjust routing timers\n"
2196 "Throttling adaptive timer\n"
2197 "LSA delay between transmissions\n"
2199 "Delay (msec) between sending LSAs\n")
2201 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2203 unsigned int interval
;
2207 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2211 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2213 ospf
->min_ls_interval
= interval
;
2218 DEFUN (no_ospf_timers_min_ls_interval
,
2219 no_ospf_timers_min_ls_interval_cmd
,
2220 "no timers throttle lsa all [(0-5000)]",
2222 "Adjust routing timers\n"
2223 "Throttling adaptive timer\n"
2224 "LSA delay between transmissions\n"
2226 "Delay (msec) between sending LSAs\n")
2228 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2229 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2235 DEFUN (ospf_timers_min_ls_arrival
,
2236 ospf_timers_min_ls_arrival_cmd
,
2237 "timers lsa arrival (0-1000)",
2238 "Adjust routing timers\n"
2239 "Throttling link state advertisement delays\n"
2240 "OSPF minimum arrival interval delay\n"
2241 "Delay (msec) between accepted LSAs\n")
2243 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2245 unsigned int arrival
;
2249 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2253 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2255 ospf
->min_ls_arrival
= arrival
;
2260 DEFUN (no_ospf_timers_min_ls_arrival
,
2261 no_ospf_timers_min_ls_arrival_cmd
,
2262 "no timers lsa arrival [(0-1000)]",
2264 "Adjust routing timers\n"
2265 "Throttling link state advertisement delays\n"
2266 "OSPF minimum arrival interval delay\n"
2267 "Delay (msec) between accepted LSAs\n")
2269 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2271 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2277 DEFUN (ospf_timers_throttle_spf
,
2278 ospf_timers_throttle_spf_cmd
,
2279 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2280 "Adjust routing timers\n"
2281 "Throttling adaptive timer\n"
2283 "Delay (msec) from first change received till SPF calculation\n"
2284 "Initial hold time (msec) between consecutive SPF calculations\n"
2285 "Maximum hold time (msec)\n")
2288 int idx_number_2
= 4;
2289 int idx_number_3
= 5;
2290 unsigned int delay
, hold
, max
;
2294 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2298 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2299 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2300 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2302 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2305 DEFUN (no_ospf_timers_throttle_spf
,
2306 no_ospf_timers_throttle_spf_cmd
,
2307 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2309 "Adjust routing timers\n"
2310 "Throttling adaptive timer\n"
2312 "Delay (msec) from first change received till SPF calculation\n"
2313 "Initial hold time (msec) between consecutive SPF calculations\n"
2314 "Maximum hold time (msec)\n")
2316 return ospf_timers_spf_set (vty
,
2317 OSPF_SPF_DELAY_DEFAULT
,
2318 OSPF_SPF_HOLDTIME_DEFAULT
,
2319 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2323 DEFUN (ospf_timers_lsa
,
2324 ospf_timers_lsa_cmd
,
2325 "timers lsa min-arrival (0-600000)",
2326 "Adjust routing timers\n"
2328 "Minimum delay in receiving new version of a LSA\n"
2329 "Delay in milliseconds\n")
2331 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2333 unsigned int minarrival
;
2337 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2341 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2343 ospf
->min_ls_arrival
= minarrival
;
2348 DEFUN (no_ospf_timers_lsa
,
2349 no_ospf_timers_lsa_cmd
,
2350 "no timers lsa min-arrival [(0-600000)]",
2352 "Adjust routing timers\n"
2354 "Minimum delay in receiving new version of a LSA\n"
2355 "Delay in milliseconds\n")
2357 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2358 unsigned int minarrival
;
2362 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2364 if (ospf
->min_ls_arrival
!= minarrival
||
2365 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2369 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2374 DEFUN (ospf_neighbor
,
2376 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2378 "Neighbor IP address\n"
2379 "Neighbor Priority\n"
2381 "Dead Neighbor Polling interval\n"
2384 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2388 struct in_addr nbr_addr
;
2389 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2390 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2392 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2395 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2398 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2400 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2403 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2406 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2411 DEFUN (ospf_neighbor_poll_interval
,
2412 ospf_neighbor_poll_interval_cmd
,
2413 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2415 "Neighbor IP address\n"
2416 "Dead Neighbor Polling interval\n"
2418 "OSPF priority of non-broadcast neighbor\n"
2421 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2425 struct in_addr nbr_addr
;
2426 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2427 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2429 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2431 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2434 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2436 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2437 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2440 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2445 DEFUN (no_ospf_neighbor
,
2446 no_ospf_neighbor_cmd
,
2447 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2450 "Neighbor IP address\n"
2451 "Neighbor Priority\n"
2453 "Dead Neighbor Polling interval\n"
2456 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2458 struct in_addr nbr_addr
;
2460 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2462 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2467 DEFUN (no_ospf_neighbor_poll
,
2468 no_ospf_neighbor_poll_cmd
,
2469 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2472 "Neighbor IP address\n"
2473 "Dead Neighbor Polling interval\n"
2475 "Neighbor Priority\n"
2478 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2480 struct in_addr nbr_addr
;
2482 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2484 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2489 DEFUN (ospf_refresh_timer
,
2490 ospf_refresh_timer_cmd
,
2491 "refresh timer (10-1800)",
2492 "Adjust refresh parameters\n"
2493 "Set refresh timer\n"
2494 "Timer value in seconds\n")
2496 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2498 unsigned int interval
;
2500 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2501 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2503 ospf_timers_refresh_set (ospf
, interval
);
2508 DEFUN (no_ospf_refresh_timer
,
2509 no_ospf_refresh_timer_val_cmd
,
2510 "no refresh timer [(10-1800)]",
2512 "Adjust refresh parameters\n"
2513 "Unset refresh timer\n"
2514 "Timer value in seconds\n")
2516 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2518 unsigned int interval
;
2522 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2524 if (ospf
->lsa_refresh_interval
!= interval
||
2525 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2529 ospf_timers_refresh_unset (ospf
);
2535 DEFUN (ospf_auto_cost_reference_bandwidth
,
2536 ospf_auto_cost_reference_bandwidth_cmd
,
2537 "auto-cost reference-bandwidth (1-4294967)",
2538 "Calculate OSPF interface cost according to bandwidth\n"
2539 "Use reference bandwidth method to assign OSPF cost\n"
2540 "The reference bandwidth in terms of Mbits per second\n")
2542 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2545 struct listnode
*node
;
2546 struct interface
*ifp
;
2548 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2549 if (refbw
< 1 || refbw
> 4294967)
2551 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2555 /* If reference bandwidth is changed. */
2556 if ((refbw
) == ospf
->ref_bandwidth
)
2559 ospf
->ref_bandwidth
= refbw
;
2560 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2561 ospf_if_recalculate_output_cost (ifp
);
2566 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2567 no_ospf_auto_cost_reference_bandwidth_cmd
,
2568 "no auto-cost reference-bandwidth [(1-4294967)]",
2570 "Calculate OSPF interface cost according to bandwidth\n"
2571 "Use reference bandwidth method to assign OSPF cost\n"
2572 "The reference bandwidth in terms of Mbits per second\n")
2574 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2575 struct listnode
*node
, *nnode
;
2576 struct interface
*ifp
;
2578 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2581 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2582 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2583 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2585 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2586 ospf_if_recalculate_output_cost (ifp
);
2591 DEFUN (ospf_write_multiplier
,
2592 ospf_write_multiplier_cmd
,
2593 "ospf write-multiplier (1-100)",
2594 "OSPF specific commands\n"
2595 "Write multiplier\n"
2596 "Maximum number of interface serviced per write\n")
2598 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2600 u_int32_t write_oi_count
;
2607 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2608 if (write_oi_count
< 1 || write_oi_count
> 100)
2610 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2614 ospf
->write_oi_count
= write_oi_count
;
2618 ALIAS (ospf_write_multiplier
,
2619 write_multiplier_cmd
,
2620 "write-multiplier (1-100)",
2621 "Write multiplier\n"
2622 "Maximum number of interface serviced per write\n")
2624 DEFUN (no_ospf_write_multiplier
,
2625 no_ospf_write_multiplier_cmd
,
2626 "no ospf write-multiplier (1-100)",
2628 "OSPF specific commands\n"
2629 "Write multiplier\n"
2630 "Maximum number of interface serviced per write\n")
2632 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2634 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2638 ALIAS (no_ospf_write_multiplier
,
2639 no_write_multiplier_cmd
,
2640 "no write-multiplier (1-100)",
2642 "Write multiplier\n"
2643 "Maximum number of interface serviced per write\n")
2645 const char *ospf_abr_type_descr_str
[] =
2648 "Standard (RFC2328)",
2650 "Alternative Cisco",
2651 "Alternative Shortcut"
2654 const char *ospf_shortcut_mode_descr_str
[] =
2662 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2664 json_object
*json_area
= NULL
;
2667 json_area
= json_object_new_object();
2671 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2673 /* Show Area type/mode. */
2674 if (OSPF_IS_AREA_BACKBONE (area
))
2677 json_object_boolean_true_add(json_area
, "backbone");
2679 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2685 if (area
->external_routing
== OSPF_AREA_STUB
)
2687 if (area
->no_summary
)
2688 json_object_boolean_true_add(json_area
, "stubNoSummary");
2689 if (area
->shortcut_configured
)
2690 json_object_boolean_true_add(json_area
, "stubShortcut");
2692 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2694 if (area
->no_summary
)
2695 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2696 if (area
->shortcut_configured
)
2697 json_object_boolean_true_add(json_area
, "nssaShortcut");
2700 json_object_string_add(json_area
,"shortcuttingMode",
2701 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2702 if (area
->shortcut_capability
)
2703 json_object_boolean_true_add(json_area
,"sBitConcensus");
2707 if (area
->external_routing
== OSPF_AREA_STUB
)
2708 vty_out (vty
, " (Stub%s%s)",
2709 area
->no_summary
? ", no summary" : "",
2710 area
->shortcut_configured
? "; " : "");
2711 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2712 vty_out (vty
, " (NSSA%s%s)",
2713 area
->no_summary
? ", no summary" : "",
2714 area
->shortcut_configured
? "; " : "");
2716 vty_out (vty
, "%s", VTY_NEWLINE
);
2717 vty_out (vty
, " Shortcutting mode: %s",
2718 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2719 vty_out (vty
, ", S-bit consensus: %s%s",
2720 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2724 /* Show number of interfaces */
2727 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2728 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2731 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2732 "Active: %d%s", listcount (area
->oiflist
),
2733 area
->act_ints
, VTY_NEWLINE
);
2735 if (area
->external_routing
== OSPF_AREA_NSSA
)
2739 json_object_boolean_true_add(json_area
, "nssa");
2740 if (! IS_OSPF_ABR (area
->ospf
))
2741 json_object_boolean_false_add(json_area
, "abr");
2742 else if (area
->NSSATranslatorState
)
2744 json_object_boolean_true_add(json_area
, "abr");
2745 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2746 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2747 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2748 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2752 json_object_boolean_true_add(json_area
, "abr");
2753 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2754 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2756 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2761 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2762 if (! IS_OSPF_ABR (area
->ospf
))
2763 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2765 else if (area
->NSSATranslatorState
)
2767 vty_out (vty
, " We are an ABR and ");
2768 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2769 vty_out (vty
, "the NSSA Elected Translator. %s",
2771 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2772 vty_out (vty
, "always an NSSA Translator. %s",
2777 vty_out (vty
, " We are an ABR, but ");
2778 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2779 vty_out (vty
, "not the NSSA Elected Translator. %s",
2782 vty_out (vty
, "never an NSSA Translator. %s",
2788 /* Stub-router state for this area */
2789 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2791 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2795 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2796 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2797 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2798 if (area
->t_stub_router
)
2800 struct timeval result
;
2801 unsigned long time_store
= 0;
2802 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
2803 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2804 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2809 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2811 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2812 vty_out (vty
, " Administratively activated (indefinitely)%s",
2814 if (area
->t_stub_router
)
2815 vty_out (vty
, " Active from startup, %s remaining%s",
2816 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2817 sizeof(timebuf
)), VTY_NEWLINE
);
2823 /* Show number of fully adjacent neighbors. */
2824 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2826 /* Show authentication type. */
2827 if (area
->auth_type
== OSPF_AUTH_NULL
)
2828 json_object_string_add(json_area
, "authentication", "authenticationNone");
2829 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2830 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2831 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2832 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2834 if (!OSPF_IS_AREA_BACKBONE (area
))
2835 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2837 /* Show SPF calculation times. */
2838 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2839 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2840 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2841 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2842 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2843 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2844 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2845 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2846 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2847 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2848 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2849 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2853 /* Show number of fully adjacent neighbors. */
2854 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2855 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2857 /* Show authentication type. */
2858 vty_out (vty
, " Area has ");
2859 if (area
->auth_type
== OSPF_AUTH_NULL
)
2860 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2861 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2862 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2863 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2864 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2866 if (!OSPF_IS_AREA_BACKBONE (area
))
2867 vty_out (vty
, " Number of full virtual adjacencies going through"
2868 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2870 /* Show SPF calculation times. */
2871 vty_out (vty
, " SPF algorithm executed %d times%s",
2872 area
->spf_calculation
, VTY_NEWLINE
);
2874 /* Show number of LSA. */
2875 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2876 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2877 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2878 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2879 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2880 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2881 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2882 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2883 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2884 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2885 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2886 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2887 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2888 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2889 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2890 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2895 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2896 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2897 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2898 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2902 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2903 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2904 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2905 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2906 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2907 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2911 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2913 vty_out (vty
, "%s", VTY_NEWLINE
);
2917 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2919 struct listnode
*node
, *nnode
;
2920 struct ospf_area
* area
;
2921 struct timeval result
;
2922 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2923 json_object
*json
= NULL
;
2924 json_object
*json_areas
= NULL
;
2928 json
= json_object_new_object();
2929 json_areas
= json_object_new_object();
2936 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2940 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2941 VTY_NEWLINE
, VTY_NEWLINE
);
2945 /* Show Router ID. */
2948 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2952 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2953 inet_ntoa (ospf
->router_id
),
2957 /* Graceful shutdown */
2958 if (ospf
->t_deferred_shutdown
)
2962 unsigned long time_store
= 0;
2963 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
2964 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2965 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2969 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2970 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2971 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2975 /* Show capability. */
2978 json_object_boolean_true_add(json
, "tosRoutesOnly");
2979 json_object_boolean_true_add(json
, "rfc2328Conform");
2980 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2982 json_object_boolean_true_add(json
, "rfc1583Compatibility");
2987 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
2988 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
2989 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
2990 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
2991 "enabled" : "disabled", VTY_NEWLINE
);
2996 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
2998 json_object_boolean_true_add(json
, "opaqueCapable");
3003 vty_out (vty
, " OpaqueCapability flag is %s%s",
3004 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3008 /* Show stub-router configuration */
3009 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3010 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3014 json_object_boolean_true_add(json
, "stubAdvertisement");
3015 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3016 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3017 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3018 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3022 vty_out (vty
, " Stub router advertisement is configured%s",
3024 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3025 vty_out (vty
, " Enabled for %us after start-up%s",
3026 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3027 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3028 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3029 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3033 /* Show SPF timers. */
3036 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3037 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3038 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3039 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3043 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3044 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3045 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3046 " Hold time multiplier is currently %d%s",
3047 ospf
->spf_delay
, VTY_NEWLINE
,
3048 ospf
->spf_holdtime
, VTY_NEWLINE
,
3049 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3050 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3055 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3057 unsigned long time_store
= 0;
3059 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3060 result
= tv_sub (result
, recent_relative_time());
3061 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3062 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3064 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3065 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3068 json_object_boolean_true_add(json
, "spfHasNotRun");
3072 vty_out (vty
, " SPF algorithm ");
3073 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3075 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3076 vty_out (vty
, "last executed %s ago%s",
3077 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3079 vty_out (vty
, " Last SPF duration %s%s",
3080 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3084 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3089 struct timeval temp_time
;
3090 unsigned long time_store
= 0;
3092 if (ospf
->t_spf_calc
)
3094 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3095 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3096 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3099 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3100 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3101 /* Show write multiplier values */
3102 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3103 /* Show refresh parameters. */
3104 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3108 vty_out (vty
, " SPF timer %s%s%s",
3109 (ospf
->t_spf_calc
? "due in " : "is "),
3110 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3113 vty_out (vty
, " LSA minimum interval %d msecs%s",
3114 ospf
->min_ls_interval
, VTY_NEWLINE
);
3115 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3116 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3118 /* Show write multiplier values */
3119 vty_out (vty
, " Write Multiplier set to %d %s",
3120 ospf
->write_oi_count
, VTY_NEWLINE
);
3122 /* Show refresh parameters. */
3123 vty_out (vty
, " Refresh timer %d secs%s",
3124 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3127 /* Show ABR/ASBR flags. */
3128 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3131 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3133 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3134 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3136 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3139 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3141 vty_out (vty
, " This router is an ASBR "
3142 "(injecting external routing information)%s", VTY_NEWLINE
);
3145 /* Show Number of AS-external-LSAs. */
3148 json_object_int_add(json
, "lsaExternalCounter",
3149 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3150 json_object_int_add(json
, "lsaExternalChecksum",
3151 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3155 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3156 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3157 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3162 json_object_int_add(json
, "lsaAsopaqueCounter",
3163 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3164 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3165 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3169 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3170 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3171 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3174 /* Show number of areas attached. */
3176 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3178 vty_out (vty
, " Number of areas attached to this router: %d%s",
3179 listcount (ospf
->areas
), VTY_NEWLINE
);
3181 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3183 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3186 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3188 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3193 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3195 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3198 /* Show each area status. */
3199 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3200 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3204 json_object_object_add(json
, "areas", json_areas
);
3205 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3206 json_object_free(json
);
3209 vty_out (vty
, "%s",VTY_NEWLINE
);
3214 DEFUN (show_ip_ospf
,
3216 "show ip ospf [json]",
3219 "OSPF information\n"
3223 u_char uj
= use_json(argc
, argv
);
3225 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3228 return (show_ip_ospf_common(vty
, ospf
, uj
));
3231 DEFUN (show_ip_ospf_instance
,
3232 show_ip_ospf_instance_cmd
,
3233 "show ip ospf (1-65535) [json]",
3236 "OSPF information\n"
3242 u_short instance
= 0;
3243 u_char uj
= use_json(argc
, argv
);
3245 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3246 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3249 return (show_ip_ospf_common(vty
, ospf
, uj
));
3253 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3254 json_object
*json_interface_sub
, u_char use_json
)
3257 struct ospf_neighbor
*nbr
;
3258 struct route_node
*rn
;
3260 /* Is interface up? */
3263 is_up
= if_is_operative(ifp
);
3265 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3267 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3269 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3270 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3271 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3272 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3276 vty_out (vty
, "%s is %s%s", ifp
->name
,
3277 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3278 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3279 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3283 /* Is interface OSPF enabled? */
3286 if (ospf_oi_count(ifp
) == 0)
3288 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3293 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3297 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3301 if (ospf_oi_count(ifp
) == 0)
3303 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3308 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3314 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3316 struct ospf_interface
*oi
= rn
->info
;
3321 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3324 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3326 vty_out (vty
, " This interface is UNNUMBERED,");
3330 /* Show OSPF interface information. */
3333 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3334 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3337 vty_out (vty
, " Internet Address %s/%d,",
3338 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3340 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3342 struct in_addr
*dest
;
3345 if (CONNECTED_PEER(oi
->connected
)
3346 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3351 /* For Vlinks, showing the peer address is probably more
3352 * * * * * informative than the local interface that is being used
3354 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3355 dest
= &oi
->vl_data
->peer_addr
;
3357 dest
= &oi
->connected
->destination
->u
.prefix4
;
3361 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3362 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3363 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3365 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3368 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3373 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3374 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3375 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3376 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3377 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3378 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3379 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3380 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3381 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3385 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3388 vty_out (vty
, " MTU mismatch detection:%s%s",
3389 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3391 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3392 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3393 oi
->output_cost
, VTY_NEWLINE
);
3395 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3396 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3397 PRIORITY (oi
), VTY_NEWLINE
);
3400 /* Show DR information. */
3401 if (DR (oi
).s_addr
== 0)
3404 vty_out (vty
, " No backup designated router on this network%s",
3409 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3413 vty_out (vty
, " No backup designated router on this network%s",
3420 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3421 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3425 vty_out (vty
, " Backup Designated Router (ID) %s,",
3426 inet_ntoa (nbr
->router_id
));
3427 vty_out (vty
, " Interface Address %s%s",
3428 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3433 /* Next network-LSA sequence number we'll use, if we're elected DR */
3434 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3437 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3439 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3440 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3445 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3446 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3448 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3449 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3450 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3451 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3456 vty_out (vty
, " Multicast group memberships:");
3457 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3458 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3460 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3461 vty_out (vty
, " OSPFAllRouters");
3462 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3463 vty_out (vty
, " OSPFDesignatedRouters");
3466 vty_out (vty
, " <None>");
3467 vty_out (vty
, "%s", VTY_NEWLINE
);
3472 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3473 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3475 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3476 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3477 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3478 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3482 vty_out (vty
, " Timer intervals configured,");
3483 vty_out (vty
, " Hello ");
3484 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3485 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3487 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3488 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3489 OSPF_IF_PARAM (oi
, v_wait
),
3490 OSPF_IF_PARAM (oi
, v_wait
),
3491 OSPF_IF_PARAM (oi
, retransmit_interval
),
3495 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3497 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3500 struct timeval result
;
3501 unsigned long time_store
= 0;
3503 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3509 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3510 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3513 vty_out (vty
, " Hello due in %s%s",
3514 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3517 else /* passive-interface is set */
3520 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3522 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3527 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3528 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3531 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3532 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3534 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3539 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3540 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3542 struct interface
*ifp
;
3543 struct listnode
*node
;
3544 json_object
*json
= NULL
;
3545 json_object
*json_interface_sub
= NULL
;
3549 json
= json_object_new_object();
3550 json_interface_sub
= json_object_new_object();
3556 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3558 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3559 VTY_NEWLINE
, VTY_NEWLINE
);
3562 if (argc
== (iface_argv
+ 1))
3564 /* Show All Interfaces.*/
3565 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3567 if (ospf_oi_count(ifp
))
3569 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3571 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3575 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3579 json
= json_object_new_object();
3580 json_interface_sub
= json_object_new_object ();
3583 /* Show All Interfaces. */
3584 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3586 if (ospf_oi_count(ifp
))
3588 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3590 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3596 /* Interface name is specified. */
3597 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3600 json_object_boolean_true_add(json
, "noSuchIface");
3602 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3606 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3608 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3614 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3615 json_object_free(json
);
3618 vty_out (vty
, "%s", VTY_NEWLINE
);
3623 DEFUN (show_ip_ospf_interface
,
3624 show_ip_ospf_interface_cmd
,
3625 "show ip ospf interface [INTERFACE] [json]",
3628 "OSPF information\n"
3629 "Interface information\n"
3634 u_char uj
= use_json(argc
, argv
);
3636 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3639 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3642 DEFUN (show_ip_ospf_instance_interface
,
3643 show_ip_ospf_instance_interface_cmd
,
3644 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3647 "OSPF information\n"
3649 "Interface information\n"
3655 u_short instance
= 0;
3656 u_char uj
= use_json(argc
, argv
);
3658 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3659 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3662 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3666 show_ip_ospf_neighbour_header (struct vty
*vty
)
3668 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3670 "Neighbor ID", "Pri", "State", "Dead Time",
3671 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3676 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3678 struct route_node
*rn
;
3679 struct ospf_neighbor
*nbr
;
3681 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3682 json_object
*json_neighbor
= NULL
;
3684 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3686 if ((nbr
= rn
->info
))
3688 /* Do not show myself. */
3689 if (nbr
!= oi
->nbr_self
)
3691 /* Down state is not shown. */
3692 if (nbr
->state
!= NSM_Down
)
3696 json_neighbor
= json_object_new_object();
3697 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3699 struct timeval result
;
3700 unsigned long time_store
= 0;
3702 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3703 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3705 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3706 json_object_string_add (json_neighbor
, "state", msgbuf
);
3707 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3708 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3709 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3710 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3711 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3712 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3713 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3714 json_object_object_add(json
, "neighbor", json_neighbor
);
3716 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3720 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3722 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3723 vty_out (vty
, "%-15s %3d %-15s ",
3727 vty_out (vty
, "%-15s %3d %-15s ",
3728 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3731 vty_out (vty
, "%9s ",
3732 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3734 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3735 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3736 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3737 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3747 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3749 struct ospf_interface
*oi
;
3750 struct listnode
*node
;
3751 json_object
*json
= NULL
;
3754 json
= json_object_new_object();
3756 show_ip_ospf_neighbour_header (vty
);
3761 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3763 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3764 VTY_NEWLINE
, VTY_NEWLINE
);
3767 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3768 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3772 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3773 json_object_free(json
);
3776 vty_out (vty
, "%s", VTY_NEWLINE
);
3781 DEFUN (show_ip_ospf_neighbor
,
3782 show_ip_ospf_neighbor_cmd
,
3783 "show ip ospf neighbor [json]",
3786 "OSPF information\n"
3791 u_char uj
= use_json(argc
, argv
);
3793 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3796 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3800 DEFUN (show_ip_ospf_instance_neighbor
,
3801 show_ip_ospf_instance_neighbor_cmd
,
3802 "show ip ospf (1-65535) neighbor [json]",
3805 "OSPF information\n"
3812 u_short instance
= 0;
3813 u_char uj
= use_json(argc
, argv
);
3815 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3816 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3819 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3823 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3825 struct listnode
*node
;
3826 struct ospf_interface
*oi
;
3827 json_object
*json
= NULL
;
3828 json_object
*json_neighbor_sub
= NULL
;
3832 json
= json_object_new_object();
3833 json_neighbor_sub
= json_object_new_object();
3836 show_ip_ospf_neighbour_header (vty
);
3841 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3843 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3844 VTY_NEWLINE
, VTY_NEWLINE
);
3847 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3849 struct listnode
*nbr_node
;
3850 struct ospf_nbr_nbma
*nbr_nbma
;
3852 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3854 /* print Down neighbor status */
3855 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3857 if (nbr_nbma
->nbr
== NULL
3858 || nbr_nbma
->nbr
->state
== NSM_Down
)
3862 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3863 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3864 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3865 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3866 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3867 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3868 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3872 vty_out (vty
, "%-15s %3d %-15s %9s ",
3873 "-", nbr_nbma
->priority
, "Down", "-");
3874 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3875 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3876 0, 0, 0, VTY_NEWLINE
);
3884 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3885 json_object_free(json
);
3888 vty_out (vty
, "%s", VTY_NEWLINE
);
3893 DEFUN (show_ip_ospf_neighbor_all
,
3894 show_ip_ospf_neighbor_all_cmd
,
3895 "show ip ospf neighbor all [json]",
3898 "OSPF information\n"
3900 "include down status neighbor\n"
3904 u_char uj
= use_json(argc
, argv
);
3906 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3909 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3912 DEFUN (show_ip_ospf_instance_neighbor_all
,
3913 show_ip_ospf_instance_neighbor_all_cmd
,
3914 "show ip ospf (1-65535) neighbor all [json]",
3917 "OSPF information\n"
3920 "include down status neighbor\n"
3925 u_short instance
= 0;
3926 u_char uj
= use_json(argc
, argv
);
3928 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3929 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3932 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3936 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3937 struct cmd_token
**argv
, u_char use_json
)
3939 struct interface
*ifp
;
3940 struct route_node
*rn
;
3941 json_object
*json
= NULL
;
3944 json
= json_object_new_object();
3946 show_ip_ospf_neighbour_header (vty
);
3951 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3953 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3954 VTY_NEWLINE
, VTY_NEWLINE
);
3957 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
3961 json_object_boolean_true_add(json
, "noSuchIface");
3963 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3967 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3969 struct ospf_interface
*oi
= rn
->info
;
3974 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3979 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3980 json_object_free(json
);
3983 vty_out (vty
, "%s", VTY_NEWLINE
);
3988 DEFUN (show_ip_ospf_neighbor_int
,
3989 show_ip_ospf_neighbor_int_cmd
,
3990 "show ip ospf neighbor IFNAME [json]",
3993 "OSPF information\n"
3999 u_char uj
= use_json(argc
, argv
);
4001 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4004 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4007 DEFUN (show_ip_ospf_instance_neighbor_int
,
4008 show_ip_ospf_instance_neighbor_int_cmd
,
4009 "show ip ospf (1-65535) neighbor IFNAME [json]",
4012 "OSPF information\n"
4020 u_short instance
= 0;
4021 u_char uj
= use_json(argc
, argv
);
4023 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4024 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4027 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4031 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4032 u_char use_json
, json_object
*json
)
4034 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4035 json_object
*json_sub
= NULL
;
4038 json_sub
= json_object_new_object();
4039 else /* Show neighbor ID. */
4040 vty_out (vty
, " Neighbor %s,", "-");
4042 /* Show interface address. */
4044 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4046 vty_out (vty
, " interface address %s%s",
4047 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4052 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4053 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4056 vty_out (vty
, " In the area %s via interface %s%s",
4057 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4059 /* Show neighbor priority and state. */
4062 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4063 json_object_string_add(json_sub
, "nbrState", "down");
4066 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4067 nbr_nbma
->priority
, "Down");
4069 /* Show state changes. */
4071 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4073 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4075 /* Show PollInterval */
4077 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4079 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4081 /* Show poll-interval timer. */
4084 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4085 unsigned long time_store
= 0;
4086 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4087 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4090 vty_out (vty
, " Poll timer due in %s%s",
4091 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4094 /* Show poll-interval timer thread. */
4097 if (nbr_nbma
->t_poll
!= NULL
)
4098 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4101 vty_out (vty
, " Thread Poll Timer %s%s",
4102 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4105 json_object_object_add(json
, "noNbrId", json_sub
);
4109 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4110 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4112 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4113 json_object
*json_sub
= NULL
;
4116 json_sub
= json_object_new_object();
4119 /* Show neighbor ID. */
4120 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4121 vty_out (vty
, " Neighbor %s,", "-");
4123 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4126 /* Show interface address. */
4128 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4130 vty_out (vty
, " interface address %s%s",
4131 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4136 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4137 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4140 vty_out (vty
, " In the area %s via interface %s%s",
4141 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4143 /* Show neighbor priority and state. */
4146 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4147 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4150 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4151 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4153 /* Show state changes. */
4155 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4157 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4159 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4161 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4164 unsigned long time_store
= 0;
4165 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4166 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4170 vty_out (vty
, " Most recent state change statistics:%s",
4172 vty_out (vty
, " Progressive change %s ago%s",
4173 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4178 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4180 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4183 unsigned long time_store
= 0;
4184 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4185 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4186 if (nbr
->last_regress_str
)
4187 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4191 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4192 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4193 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4198 /* Show Designated Rotuer ID. */
4200 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4202 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4204 /* Show Backup Designated Rotuer ID. */
4206 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4208 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4213 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4214 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4217 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4218 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4220 /* Show Router Dead interval timer. */
4223 if (nbr
->t_inactivity
)
4225 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4226 unsigned long time_store
= 0;
4227 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4228 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4231 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4234 vty_out (vty
, " Dead timer due in %s%s",
4235 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4238 /* Show Database Summary list. */
4240 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4242 vty_out (vty
, " Database Summary List %d%s",
4243 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4245 /* Show Link State Request list. */
4247 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4249 vty_out (vty
, " Link State Request List %ld%s",
4250 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4252 /* Show Link State Retransmission list. */
4254 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4256 vty_out (vty
, " Link State Retransmission List %ld%s",
4257 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4259 /* Show inactivity timer thread. */
4262 if (nbr
->t_inactivity
!= NULL
)
4263 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4266 vty_out (vty
, " Thread Inactivity Timer %s%s",
4267 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4269 /* Show Database Description retransmission thread. */
4272 if (nbr
->t_db_desc
!= NULL
)
4273 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4276 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4277 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4279 /* Show Link State Request Retransmission thread. */
4282 if (nbr
->t_ls_req
!= NULL
)
4283 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4286 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4287 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4289 /* Show Link State Update Retransmission thread. */
4292 if (nbr
->t_ls_upd
!= NULL
)
4293 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4296 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4297 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4301 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4302 json_object_object_add(json
, "noNbrId", json_sub
);
4304 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4307 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4311 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4312 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4314 struct listnode
*node
;
4315 struct ospf_neighbor
*nbr
;
4316 struct ospf_interface
*oi
;
4317 struct in_addr router_id
;
4319 json_object
*json
= NULL
;
4322 json
= json_object_new_object();
4327 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4329 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4330 VTY_NEWLINE
, VTY_NEWLINE
);
4333 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4337 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4341 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4343 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4345 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4351 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4352 json_object_free(json
);
4355 vty_out (vty
, "%s", VTY_NEWLINE
);
4360 DEFUN (show_ip_ospf_neighbor_id
,
4361 show_ip_ospf_neighbor_id_cmd
,
4362 "show ip ospf neighbor A.B.C.D [json]",
4365 "OSPF information\n"
4371 u_char uj
= use_json(argc
, argv
);
4373 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4376 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4379 DEFUN (show_ip_ospf_instance_neighbor_id
,
4380 show_ip_ospf_instance_neighbor_id_cmd
,
4381 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4384 "OSPF information\n"
4392 u_short instance
= 0;
4393 u_char uj
= use_json(argc
, argv
);
4395 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4396 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4399 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4403 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4405 struct ospf_interface
*oi
;
4406 struct listnode
*node
;
4407 json_object
*json
= NULL
;
4410 json
= json_object_new_object();
4415 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4417 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4418 VTY_NEWLINE
, VTY_NEWLINE
);
4421 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4423 struct route_node
*rn
;
4424 struct ospf_neighbor
*nbr
;
4426 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4428 if ((nbr
= rn
->info
))
4430 if (nbr
!= oi
->nbr_self
)
4432 if (nbr
->state
!= NSM_Down
)
4434 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4443 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4444 json_object_free(json
);
4447 vty_out (vty
, "%s", VTY_NEWLINE
);
4452 DEFUN (show_ip_ospf_neighbor_detail
,
4453 show_ip_ospf_neighbor_detail_cmd
,
4454 "show ip ospf neighbor detail [json]",
4457 "OSPF information\n"
4459 "detail of all neighbors\n"
4463 u_char uj
= use_json(argc
, argv
);
4465 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4468 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4471 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4472 show_ip_ospf_instance_neighbor_detail_cmd
,
4473 "show ip ospf (1-65535) neighbor detail [json]",
4476 "OSPF information\n"
4479 "detail of all neighbors\n"
4484 u_short instance
= 0;
4485 u_char uj
= use_json(argc
, argv
);
4487 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4488 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4491 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4495 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4497 struct listnode
*node
;
4498 struct ospf_interface
*oi
;
4499 json_object
*json
= NULL
;
4502 json
= json_object_new_object();
4507 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4509 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4510 VTY_NEWLINE
, VTY_NEWLINE
);
4513 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4515 struct route_node
*rn
;
4516 struct ospf_neighbor
*nbr
;
4517 struct ospf_nbr_nbma
*nbr_nbma
;
4519 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4520 if ((nbr
= rn
->info
))
4521 if (nbr
!= oi
->nbr_self
)
4522 if (nbr
->state
!= NSM_Down
)
4523 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4525 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4527 struct listnode
*nd
;
4529 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4531 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4532 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4539 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4540 json_object_free(json
);
4544 vty_out (vty
, "%s", VTY_NEWLINE
);
4550 DEFUN (show_ip_ospf_neighbor_detail_all
,
4551 show_ip_ospf_neighbor_detail_all_cmd
,
4552 "show ip ospf neighbor detail all [json]",
4555 "OSPF information\n"
4557 "detail of all neighbors\n"
4558 "include down status neighbor\n"
4562 u_char uj
= use_json(argc
, argv
);
4564 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4567 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4570 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4571 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4572 "show ip ospf (1-65535) neighbor detail all [json]",
4575 "OSPF information\n"
4578 "detail of all neighbors\n"
4579 "include down status neighbor\n"
4584 u_short instance
= 0;
4585 u_char uj
= use_json(argc
, argv
);
4587 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4588 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4591 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4595 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4596 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4598 struct ospf_interface
*oi
;
4599 struct interface
*ifp
;
4600 struct route_node
*rn
, *nrn
;
4601 struct ospf_neighbor
*nbr
;
4602 json_object
*json
= NULL
;
4605 json
= json_object_new_object();
4610 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4612 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4613 VTY_NEWLINE
, VTY_NEWLINE
);
4616 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4620 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4624 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4626 if ((oi
= rn
->info
))
4628 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4630 if ((nbr
= nrn
->info
))
4632 if (nbr
!= oi
->nbr_self
)
4634 if (nbr
->state
!= NSM_Down
)
4635 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4644 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4645 json_object_free(json
);
4648 vty_out (vty
, "%s", VTY_NEWLINE
);
4653 DEFUN (show_ip_ospf_neighbor_int_detail
,
4654 show_ip_ospf_neighbor_int_detail_cmd
,
4655 "show ip ospf neighbor IFNAME detail [json]",
4658 "OSPF information\n"
4661 "detail of all neighbors\n"
4665 u_char uj
= use_json(argc
, argv
);
4667 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4670 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4673 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4674 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4675 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4678 "OSPF information\n"
4682 "detail of all neighbors\n"
4687 u_short instance
= 0;
4688 u_char uj
= use_json(argc
, argv
);
4690 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4691 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4694 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4697 /* Show functions */
4699 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4701 struct router_lsa
*rl
;
4702 struct summary_lsa
*sl
;
4703 struct as_external_lsa
*asel
;
4704 struct prefix_ipv4 p
;
4707 /* If self option is set, check LSA self flag. */
4708 if (self
== 0 || IS_LSA_SELF (lsa
))
4710 /* LSA common part show. */
4711 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4712 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4713 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4714 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4715 /* LSA specific part show. */
4716 switch (lsa
->data
->type
)
4718 case OSPF_ROUTER_LSA
:
4719 rl
= (struct router_lsa
*) lsa
->data
;
4720 vty_out (vty
, " %-d", ntohs (rl
->links
));
4722 case OSPF_SUMMARY_LSA
:
4723 sl
= (struct summary_lsa
*) lsa
->data
;
4726 p
.prefix
= sl
->header
.id
;
4727 p
.prefixlen
= ip_masklen (sl
->mask
);
4728 apply_mask_ipv4 (&p
);
4730 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4732 case OSPF_AS_EXTERNAL_LSA
:
4733 case OSPF_AS_NSSA_LSA
:
4734 asel
= (struct as_external_lsa
*) lsa
->data
;
4737 p
.prefix
= asel
->header
.id
;
4738 p
.prefixlen
= ip_masklen (asel
->mask
);
4739 apply_mask_ipv4 (&p
);
4741 vty_out (vty
, " %s %s/%d [0x%lx]",
4742 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4743 inet_ntoa (p
.prefix
), p
.prefixlen
,
4744 (u_long
)ntohl (asel
->e
[0].route_tag
));
4746 case OSPF_NETWORK_LSA
:
4747 case OSPF_ASBR_SUMMARY_LSA
:
4748 case OSPF_OPAQUE_LINK_LSA
:
4749 case OSPF_OPAQUE_AREA_LSA
:
4750 case OSPF_OPAQUE_AS_LSA
:
4754 vty_out (vty
, VTY_NEWLINE
);
4760 static const char *show_database_desc
[] =
4763 "Router Link States",
4765 "Summary Link States",
4766 "ASBR-Summary Link States",
4767 "AS External Link States",
4768 "Group Membership LSA",
4769 "NSSA-external Link States",
4771 "Link-Local Opaque-LSA",
4772 "Area-Local Opaque-LSA",
4773 "AS-external Opaque-LSA",
4776 static const char *show_database_header
[] =
4779 "Link ID ADV Router Age Seq# CkSum Link count",
4780 "Link ID ADV Router Age Seq# CkSum",
4781 "Link ID ADV Router Age Seq# CkSum Route",
4782 "Link ID ADV Router Age Seq# CkSum",
4783 "Link ID ADV Router Age Seq# CkSum Route",
4784 " --- header for Group Member ----",
4785 "Link ID ADV Router Age Seq# CkSum Route",
4787 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4788 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4789 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4793 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4795 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4797 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4798 vty_out (vty
, " Options: 0x%-2x : %s%s",
4800 ospf_options_dump(lsa
->data
->options
),
4802 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4804 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4807 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4809 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4812 vty_out (vty
, " :%s%s%s%s",
4813 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4814 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4815 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4816 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4818 vty_out (vty
, "%s", VTY_NEWLINE
);
4820 vty_out (vty
, " LS Type: %s%s",
4821 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4822 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4823 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4824 vty_out (vty
, " Advertising Router: %s%s",
4825 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4826 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4828 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4830 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4833 const char *link_type_desc
[] =
4836 "another Router (point-to-point)",
4837 "a Transit Network",
4842 const char *link_id_desc
[] =
4845 "Neighboring Router ID",
4846 "Designated Router address",
4848 "Neighboring Router ID",
4851 const char *link_data_desc
[] =
4854 "Router Interface address",
4855 "Router Interface address",
4857 "Router Interface address",
4860 /* Show router-LSA each Link information. */
4862 show_ip_ospf_database_router_links (struct vty
*vty
,
4863 struct router_lsa
*rl
)
4868 len
= ntohs (rl
->header
.length
) - 4;
4869 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4871 type
= rl
->link
[i
].type
;
4873 vty_out (vty
, " Link connected to: %s%s",
4874 link_type_desc
[type
], VTY_NEWLINE
);
4875 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4876 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4877 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4878 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4879 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4880 vty_out (vty
, " TOS 0 Metric: %d%s",
4881 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4882 vty_out (vty
, "%s", VTY_NEWLINE
);
4886 /* Show router-LSA detail information. */
4888 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4892 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4894 show_ip_ospf_database_header (vty
, lsa
);
4896 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4897 VTY_NEWLINE
, VTY_NEWLINE
);
4899 show_ip_ospf_database_router_links (vty
, rl
);
4900 vty_out (vty
, "%s", VTY_NEWLINE
);
4906 /* Show network-LSA detail information. */
4908 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4914 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4916 show_ip_ospf_database_header (vty
, lsa
);
4918 vty_out (vty
, " Network Mask: /%d%s",
4919 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4921 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4923 for (i
= 0; length
> 0; i
++, length
-= 4)
4924 vty_out (vty
, " Attached Router: %s%s",
4925 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4927 vty_out (vty
, "%s", VTY_NEWLINE
);
4933 /* Show summary-LSA detail information. */
4935 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4939 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4941 show_ip_ospf_database_header (vty
, lsa
);
4943 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4945 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4947 vty_out (vty
, "%s", VTY_NEWLINE
);
4953 /* Show summary-ASBR-LSA detail information. */
4955 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4959 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4961 show_ip_ospf_database_header (vty
, lsa
);
4963 vty_out (vty
, " Network Mask: /%d%s",
4964 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4965 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4967 vty_out (vty
, "%s", VTY_NEWLINE
);
4973 /* Show AS-external-LSA detail information. */
4975 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4979 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4981 show_ip_ospf_database_header (vty
, lsa
);
4983 vty_out (vty
, " Network Mask: /%d%s",
4984 ip_masklen (al
->mask
), VTY_NEWLINE
);
4985 vty_out (vty
, " Metric Type: %s%s",
4986 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4987 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4988 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4989 vty_out (vty
, " Metric: %d%s",
4990 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4991 vty_out (vty
, " Forward Address: %s%s",
4992 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4994 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4995 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5002 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5004 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5006 /* show_ip_ospf_database_header (vty, lsa); */
5008 zlog_debug( " Network Mask: /%d%s",
5009 ip_masklen (al
->mask
), "\n");
5010 zlog_debug( " Metric Type: %s%s",
5011 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5012 "2 (Larger than any link state path)" : "1", "\n");
5013 zlog_debug( " TOS: 0%s", "\n");
5014 zlog_debug( " Metric: %d%s",
5015 GET_METRIC (al
->e
[0].metric
), "\n");
5016 zlog_debug( " Forward Address: %s%s",
5017 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5019 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5020 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5025 /* Show AS-NSSA-LSA detail information. */
5027 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5031 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5033 show_ip_ospf_database_header (vty
, lsa
);
5035 vty_out (vty
, " Network Mask: /%d%s",
5036 ip_masklen (al
->mask
), VTY_NEWLINE
);
5037 vty_out (vty
, " Metric Type: %s%s",
5038 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5039 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5040 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5041 vty_out (vty
, " Metric: %d%s",
5042 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5043 vty_out (vty
, " NSSA: Forward Address: %s%s",
5044 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5046 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5047 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5054 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5060 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5064 show_ip_ospf_database_header (vty
, lsa
);
5065 show_opaque_info_detail (vty
, lsa
);
5067 vty_out (vty
, "%s", VTY_NEWLINE
);
5072 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5075 show_router_lsa_detail
,
5076 show_network_lsa_detail
,
5077 show_summary_lsa_detail
,
5078 show_summary_asbr_lsa_detail
,
5079 show_as_external_lsa_detail
,
5081 show_as_nssa_lsa_detail
, /* almost same as external */
5083 show_opaque_lsa_detail
,
5084 show_opaque_lsa_detail
,
5085 show_opaque_lsa_detail
,
5089 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5090 struct in_addr
*adv_router
)
5092 memset (lp
, 0, sizeof (struct prefix_ls
));
5096 else if (adv_router
== NULL
)
5105 lp
->adv_router
= *adv_router
;
5110 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5111 struct in_addr
*id
, struct in_addr
*adv_router
)
5113 struct prefix_ls lp
;
5114 struct route_node
*rn
, *start
;
5115 struct ospf_lsa
*lsa
;
5117 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5118 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5121 route_lock_node (start
);
5122 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5123 if ((lsa
= rn
->info
))
5125 if (show_function
[lsa
->data
->type
] != NULL
)
5126 show_function
[lsa
->data
->type
] (vty
, lsa
);
5128 route_unlock_node (start
);
5132 /* Show detail LSA information
5133 -- if id is NULL then show all LSAs. */
5135 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5136 struct in_addr
*id
, struct in_addr
*adv_router
)
5138 struct listnode
*node
;
5139 struct ospf_area
*area
;
5143 case OSPF_AS_EXTERNAL_LSA
:
5144 case OSPF_OPAQUE_AS_LSA
:
5145 vty_out (vty
, " %s %s%s",
5146 show_database_desc
[type
],
5147 VTY_NEWLINE
, VTY_NEWLINE
);
5148 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5151 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5153 vty_out (vty
, "%s %s (Area %s)%s%s",
5154 VTY_NEWLINE
, show_database_desc
[type
],
5155 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5156 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5163 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5164 struct in_addr
*adv_router
)
5166 struct route_node
*rn
;
5167 struct ospf_lsa
*lsa
;
5169 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5170 if ((lsa
= rn
->info
))
5171 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5173 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5175 if (show_function
[lsa
->data
->type
] != NULL
)
5176 show_function
[lsa
->data
->type
] (vty
, lsa
);
5180 /* Show detail LSA information. */
5182 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5183 struct in_addr
*adv_router
)
5185 struct listnode
*node
;
5186 struct ospf_area
*area
;
5190 case OSPF_AS_EXTERNAL_LSA
:
5191 case OSPF_OPAQUE_AS_LSA
:
5192 vty_out (vty
, " %s %s%s",
5193 show_database_desc
[type
],
5194 VTY_NEWLINE
, VTY_NEWLINE
);
5195 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5199 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5201 vty_out (vty
, "%s %s (Area %s)%s%s",
5202 VTY_NEWLINE
, show_database_desc
[type
],
5203 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5204 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5212 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5214 struct ospf_lsa
*lsa
;
5215 struct route_node
*rn
;
5216 struct ospf_area
*area
;
5217 struct listnode
*node
;
5220 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5222 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5226 case OSPF_AS_EXTERNAL_LSA
:
5227 case OSPF_OPAQUE_AS_LSA
:
5232 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5233 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5235 vty_out (vty
, " %s (Area %s)%s%s",
5236 show_database_desc
[type
],
5237 ospf_area_desc_string (area
),
5238 VTY_NEWLINE
, VTY_NEWLINE
);
5239 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5241 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5242 show_lsa_summary (vty
, lsa
, self
);
5244 vty_out (vty
, "%s", VTY_NEWLINE
);
5249 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5253 case OSPF_AS_EXTERNAL_LSA
:
5254 case OSPF_OPAQUE_AS_LSA
:
5259 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5260 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5262 vty_out (vty
, " %s%s%s",
5263 show_database_desc
[type
],
5264 VTY_NEWLINE
, VTY_NEWLINE
);
5265 vty_out (vty
, "%s%s", show_database_header
[type
],
5268 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5269 show_lsa_summary (vty
, lsa
, self
);
5271 vty_out (vty
, "%s", VTY_NEWLINE
);
5275 vty_out (vty
, "%s", VTY_NEWLINE
);
5279 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5281 struct route_node
*rn
;
5283 vty_out (vty
, "%s MaxAge Link States:%s%s",
5284 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5286 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5288 struct ospf_lsa
*lsa
;
5290 if ((lsa
= rn
->info
) != NULL
)
5292 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5293 vty_out (vty
, "Link State ID: %s%s",
5294 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5295 vty_out (vty
, "Advertising Router: %s%s",
5296 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5297 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5298 vty_out (vty
, "%s", VTY_NEWLINE
);
5303 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5304 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5306 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5307 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5308 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5309 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5311 #define OSPF_LSA_TYPES_DESC \
5312 "ASBR summary link states\n" \
5313 "External link states\n" \
5314 "Network link states\n" \
5315 "Router link states\n" \
5316 "Network summary link states\n" \
5317 OSPF_LSA_TYPE_NSSA_DESC \
5318 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5319 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5320 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5323 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5324 int arg_base
, int argc
, struct cmd_token
**argv
)
5328 struct in_addr id
, adv_router
;
5331 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5334 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5335 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5338 if (argc
== arg_base
+ 4)
5340 show_ip_ospf_database_summary (vty
, ospf
, 0);
5344 /* Set database type to show. */
5345 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5346 type
= OSPF_ROUTER_LSA
;
5347 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5348 type
= OSPF_NETWORK_LSA
;
5349 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5350 type
= OSPF_AS_NSSA_LSA
;
5351 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5352 type
= OSPF_SUMMARY_LSA
;
5353 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5354 type
= OSPF_ASBR_SUMMARY_LSA
;
5355 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5356 type
= OSPF_AS_EXTERNAL_LSA
;
5357 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5359 show_ip_ospf_database_summary (vty
, ospf
, 1);
5362 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5364 show_ip_ospf_database_maxage (vty
, ospf
);
5367 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5368 type
= OSPF_OPAQUE_LINK_LSA
;
5369 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5370 type
= OSPF_OPAQUE_AREA_LSA
;
5371 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5372 type
= OSPF_OPAQUE_AS_LSA
;
5376 /* `show ip ospf database LSA'. */
5377 if (argc
== arg_base
+ 5)
5378 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5379 else if (argc
>= arg_base
+ 6)
5381 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5385 /* `show ip ospf database LSA ID'. */
5386 if (argc
== arg_base
+ 6)
5387 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5388 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5389 else if (argc
== arg_base
+ 7)
5391 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5392 adv_router
= ospf
->router_id
;
5395 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5399 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5406 DEFUN (show_ip_ospf_database_max
,
5407 show_ip_ospf_database_max_cmd
,
5408 "show ip ospf database <max-age|self-originate>",
5411 "OSPF information\n"
5412 "Database summary\n"
5413 "LSAs in MaxAge list\n"
5414 "Self-originated link states\n")
5418 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5421 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5424 DEFUN (show_ip_ospf_instance_database
,
5425 show_ip_ospf_instance_database_cmd
,
5426 "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>]]]",
5429 "OSPF information\n"
5431 "Database summary\n"
5433 "Link State ID (as an IP address)\n"
5434 "Self-originated link states\n"
5435 "Advertising Router link states\n"
5436 "Advertising Router (as an IP address)\n")
5439 u_short instance
= 0;
5442 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5444 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5445 ospf
= ospf_lookup_instance (instance
);
5448 ospf
= ospf_lookup();
5451 if (!ospf
|| !ospf
->oi_running
)
5454 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5457 DEFUN (show_ip_ospf_instance_database_max
,
5458 show_ip_ospf_instance_database_max_cmd
,
5459 "show ip ospf (1-65535) database <max-age|self-originate>",
5462 "OSPF information\n"
5464 "Database summary\n"
5465 "LSAs in MaxAge list\n"
5466 "Self-originated link states\n")
5470 u_short instance
= 0;
5472 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5474 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5477 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5482 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5483 int arg_base
, int argc
, struct cmd_token
**argv
)
5487 struct in_addr adv_router
;
5490 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5493 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5494 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5496 if (argc
!= arg_base
+ 7)
5499 /* Set database type to show. */
5500 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5501 type
= OSPF_ROUTER_LSA
;
5502 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5503 type
= OSPF_NETWORK_LSA
;
5504 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5505 type
= OSPF_AS_NSSA_LSA
;
5506 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5507 type
= OSPF_SUMMARY_LSA
;
5508 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5509 type
= OSPF_ASBR_SUMMARY_LSA
;
5510 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5511 type
= OSPF_AS_EXTERNAL_LSA
;
5512 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5513 type
= OSPF_OPAQUE_LINK_LSA
;
5514 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5515 type
= OSPF_OPAQUE_AREA_LSA
;
5516 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5517 type
= OSPF_OPAQUE_AS_LSA
;
5521 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5522 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5523 adv_router
= ospf
->router_id
;
5526 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5531 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5536 DEFUN (show_ip_ospf_database_type_adv_router
,
5537 show_ip_ospf_database_type_adv_router_cmd
,
5538 "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>",
5541 "OSPF information\n"
5542 "Database summary\n"
5544 "Advertising Router link states\n"
5545 "Advertising Router (as an IP address)\n"
5546 "Self-originated link states\n")
5550 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5553 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5556 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5557 show_ip_ospf_instance_database_type_adv_router_cmd
,
5558 "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>",
5561 "OSPF information\n"
5563 "Database summary\n"
5565 "Advertising Router link states\n"
5566 "Advertising Router (as an IP address)\n"
5567 "Self-originated link states\n")
5571 u_short instance
= 0;
5573 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5575 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5578 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5581 DEFUN (ip_ospf_authentication_args
,
5582 ip_ospf_authentication_args_addr_cmd
,
5583 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5585 "OSPF interface commands\n"
5586 "Enable authentication on this interface\n"
5587 "Use null authentication\n"
5588 "Use message-digest authentication\n"
5589 "Address of interface\n")
5591 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5592 int idx_encryption
= 3;
5594 struct in_addr addr
;
5596 struct ospf_if_params
*params
;
5598 params
= IF_DEF_PARAMS (ifp
);
5602 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5605 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5610 params
= ospf_get_if_params (ifp
, addr
);
5611 ospf_if_update_params (ifp
, addr
);
5614 /* Handle null authentication */
5615 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5617 SET_IF_PARAM (params
, auth_type
);
5618 params
->auth_type
= OSPF_AUTH_NULL
;
5622 /* Handle message-digest authentication */
5623 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5625 SET_IF_PARAM (params
, auth_type
);
5626 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5630 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5634 DEFUN (ip_ospf_authentication
,
5635 ip_ospf_authentication_addr_cmd
,
5636 "ip ospf authentication [A.B.C.D]",
5638 "OSPF interface commands\n"
5639 "Enable authentication on this interface\n"
5640 "Address of interface")
5642 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5644 struct in_addr addr
;
5646 struct ospf_if_params
*params
;
5648 params
= IF_DEF_PARAMS (ifp
);
5652 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5655 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5660 params
= ospf_get_if_params (ifp
, addr
);
5661 ospf_if_update_params (ifp
, addr
);
5664 SET_IF_PARAM (params
, auth_type
);
5665 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5670 DEFUN (no_ip_ospf_authentication_args
,
5671 no_ip_ospf_authentication_args_addr_cmd
,
5672 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5675 "OSPF interface commands\n"
5676 "Enable authentication on this interface\n"
5677 "Use null authentication\n"
5678 "Use message-digest authentication\n"
5679 "Address of interface")
5681 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5682 int idx_encryption
= 4;
5684 struct in_addr addr
;
5686 struct ospf_if_params
*params
;
5687 struct route_node
*rn
;
5690 params
= IF_DEF_PARAMS (ifp
);
5694 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5697 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5702 params
= ospf_lookup_if_params (ifp
, addr
);
5705 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5708 params
->auth_type
= OSPF_AUTH_NOTSET
;
5709 UNSET_IF_PARAM (params
, auth_type
);
5710 if (params
!= IF_DEF_PARAMS (ifp
))
5712 ospf_free_if_params (ifp
, addr
);
5713 ospf_if_update_params (ifp
, addr
);
5718 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5720 auth_type
= OSPF_AUTH_NULL
;
5722 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5724 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5728 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5732 * Here we have a case where the user has entered
5733 * 'no ip ospf authentication (null | message_digest )'
5734 * we need to find if we have any ip addresses underneath it that
5735 * correspond to the associated type.
5737 if (params
->auth_type
== auth_type
)
5739 params
->auth_type
= OSPF_AUTH_NOTSET
;
5740 UNSET_IF_PARAM (params
, auth_type
);
5743 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5745 if ((params
= rn
->info
))
5747 if (params
->auth_type
== auth_type
)
5749 params
->auth_type
= OSPF_AUTH_NOTSET
;
5750 UNSET_IF_PARAM (params
, auth_type
);
5751 if (params
!= IF_DEF_PARAMS (ifp
))
5753 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5754 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5764 DEFUN (no_ip_ospf_authentication
,
5765 no_ip_ospf_authentication_addr_cmd
,
5766 "no ip ospf authentication [A.B.C.D]",
5769 "OSPF interface commands\n"
5770 "Enable authentication on this interface\n"
5771 "Address of interface")
5773 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5775 struct in_addr addr
;
5777 struct ospf_if_params
*params
;
5778 struct route_node
*rn
;
5780 params
= IF_DEF_PARAMS (ifp
);
5784 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5787 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5792 params
= ospf_lookup_if_params (ifp
, addr
);
5795 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5799 params
->auth_type
= OSPF_AUTH_NOTSET
;
5800 UNSET_IF_PARAM (params
, auth_type
);
5801 if (params
!= IF_DEF_PARAMS (ifp
))
5803 ospf_free_if_params (ifp
, addr
);
5804 ospf_if_update_params (ifp
, addr
);
5810 * When a user enters 'no ip ospf authentication'
5811 * We should remove all authentication types from
5814 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5815 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5816 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5818 params
->auth_type
= OSPF_AUTH_NOTSET
;
5819 UNSET_IF_PARAM (params
, auth_type
);
5822 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5824 if ((params
= rn
->info
))
5827 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5828 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5829 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5831 params
->auth_type
= OSPF_AUTH_NOTSET
;
5832 UNSET_IF_PARAM (params
, auth_type
);
5833 if (params
!= IF_DEF_PARAMS (ifp
))
5835 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5836 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5847 DEFUN (ip_ospf_authentication_key
,
5848 ip_ospf_authentication_key_addr_cmd
,
5849 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5851 "OSPF interface commands\n"
5852 "Authentication password (key)\n"
5853 "The OSPF password (key)\n"
5854 "Address of interface")
5856 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5858 struct in_addr addr
;
5859 struct ospf_if_params
*params
;
5861 params
= IF_DEF_PARAMS (ifp
);
5863 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5865 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5867 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5872 params
= ospf_get_if_params (ifp
, addr
);
5873 ospf_if_update_params (ifp
, addr
);
5876 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5877 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5878 SET_IF_PARAM (params
, auth_simple
);
5883 DEFUN_HIDDEN (ospf_authentication_key
,
5884 ospf_authentication_key_cmd
,
5885 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5886 "OSPF interface commands\n"
5887 "Authentication password (key)\n"
5888 "The OSPF password (key)\n"
5889 "Address of interface\n")
5891 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5894 DEFUN (no_ip_ospf_authentication_key
,
5895 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5896 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5899 "OSPF interface commands\n"
5900 "Authentication password (key)\n"
5901 "The OSPF password (key)")
5903 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5905 struct in_addr addr
;
5906 struct ospf_if_params
*params
;
5907 params
= IF_DEF_PARAMS (ifp
);
5909 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5911 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5913 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5918 params
= ospf_lookup_if_params (ifp
, addr
);
5923 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5924 UNSET_IF_PARAM (params
, auth_simple
);
5926 if (params
!= IF_DEF_PARAMS (ifp
))
5928 ospf_free_if_params (ifp
, addr
);
5929 ospf_if_update_params (ifp
, addr
);
5935 DEFUN_HIDDEN (no_ospf_authentication_key
,
5936 no_ospf_authentication_key_authkey_addr_cmd
,
5937 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5939 "OSPF interface commands\n"
5940 "Authentication password (key)\n"
5941 "The OSPF password (key)")
5943 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5946 DEFUN (ip_ospf_message_digest_key
,
5947 ip_ospf_message_digest_key_cmd
,
5948 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5950 "OSPF interface commands\n"
5951 "Message digest authentication password (key)\n"
5953 "Use MD5 algorithm\n"
5954 "The OSPF password (key)\n"
5955 "Address of interface\n")
5957 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5958 struct crypt_key
*ck
;
5960 struct in_addr addr
;
5961 struct ospf_if_params
*params
;
5963 params
= IF_DEF_PARAMS (ifp
);
5966 argv_find (argv
, argc
, "(1-255)", &idx
);
5967 char *keyid
= argv
[idx
]->arg
;
5968 argv_find (argv
, argc
, "KEY", &idx
);
5969 char *cryptkey
= argv
[idx
]->arg
;
5971 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5973 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5975 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5980 params
= ospf_get_if_params (ifp
, addr
);
5981 ospf_if_update_params (ifp
, addr
);
5984 key_id
= strtol (keyid
, NULL
, 10);
5985 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5987 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5991 ck
= ospf_crypt_key_new ();
5992 ck
->key_id
= (u_char
) key_id
;
5993 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5994 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5996 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5997 SET_IF_PARAM (params
, auth_crypt
);
6002 DEFUN_HIDDEN (ospf_message_digest_key
,
6003 ospf_message_digest_key_cmd
,
6004 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6005 "OSPF interface commands\n"
6006 "Message digest authentication password (key)\n"
6008 "Use MD5 algorithm\n"
6009 "The OSPF password (key)\n"
6010 "Address of interface\n")
6012 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6015 DEFUN (no_ip_ospf_message_digest_key
,
6016 no_ip_ospf_message_digest_key_cmd
,
6017 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6020 "OSPF interface commands\n"
6021 "Message digest authentication password (key)\n"
6023 "Use MD5 algorithm\n"
6024 "The OSPF password (key)\n"
6025 "Address of interface\n")
6027 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6029 struct crypt_key
*ck
;
6031 struct in_addr addr
;
6032 struct ospf_if_params
*params
;
6033 params
= IF_DEF_PARAMS (ifp
);
6035 argv_find (argv
, argc
, "(1-255)", &idx
);
6036 char *keyid
= argv
[idx
]->arg
;
6038 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6040 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6042 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6047 params
= ospf_lookup_if_params (ifp
, addr
);
6052 key_id
= strtol (keyid
, NULL
, 10);
6053 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6056 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6060 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6062 if (params
!= IF_DEF_PARAMS (ifp
))
6064 ospf_free_if_params (ifp
, addr
);
6065 ospf_if_update_params (ifp
, addr
);
6071 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6072 no_ospf_message_digest_key_cmd
,
6073 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6075 "OSPF interface commands\n"
6076 "Message digest authentication password (key)\n"
6078 "Address of interface")
6080 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6083 DEFUN (ip_ospf_cost
,
6085 "ip ospf cost (1-65535) [A.B.C.D]",
6087 "OSPF interface commands\n"
6090 "Address of interface\n")
6092 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6095 struct in_addr addr
;
6096 struct ospf_if_params
*params
;
6097 params
= IF_DEF_PARAMS (ifp
);
6100 char *coststr
= NULL
, *ifaddr
= NULL
;
6101 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6102 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6104 cost
= strtol (coststr
, NULL
, 10);
6108 if(!inet_aton(ifaddr
, &addr
))
6110 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6115 params
= ospf_get_if_params (ifp
, addr
);
6116 ospf_if_update_params (ifp
, addr
);
6119 SET_IF_PARAM (params
, output_cost_cmd
);
6120 params
->output_cost_cmd
= cost
;
6122 ospf_if_recalculate_output_cost (ifp
);
6127 DEFUN_HIDDEN (ospf_cost
,
6129 "ospf cost (1-65535) [A.B.C.D]",
6130 "OSPF interface commands\n"
6133 "Address of interface\n")
6135 return ip_ospf_cost (self
, vty
, argc
, argv
);
6138 DEFUN (no_ip_ospf_cost
,
6139 no_ip_ospf_cost_cmd
,
6140 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6142 "OSPF interface commands\n"
6144 "Address of interface")
6146 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6148 struct in_addr addr
;
6149 struct ospf_if_params
*params
;
6151 params
= IF_DEF_PARAMS (ifp
);
6154 char *ifaddr
= NULL
;
6155 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6157 /* According to the semantics we are mimicking "no ip ospf cost N" is
6158 * always treated as "no ip ospf cost" regardless of the actual value
6159 * of N already configured for the interface. Thus ignore cost. */
6163 if (!inet_aton(ifaddr
, &addr
))
6165 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6170 params
= ospf_lookup_if_params (ifp
, addr
);
6175 UNSET_IF_PARAM (params
, output_cost_cmd
);
6177 if (params
!= IF_DEF_PARAMS (ifp
))
6179 ospf_free_if_params (ifp
, addr
);
6180 ospf_if_update_params (ifp
, addr
);
6183 ospf_if_recalculate_output_cost (ifp
);
6188 DEFUN_HIDDEN (no_ospf_cost
,
6190 "no ospf cost [(1-65535)] [A.B.C.D]",
6192 "OSPF interface commands\n"
6195 "Address of interface\n")
6197 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6201 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6203 struct route_node
*rn
;
6204 struct ospf_neighbor
*nbr
;
6206 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6207 if ((nbr
= rn
->info
))
6209 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6210 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6211 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6212 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6217 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6218 const char *nbr_str
,
6219 const char *fast_hello_str
)
6221 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6224 struct in_addr addr
;
6226 struct ospf_if_params
*params
;
6227 struct ospf_interface
*oi
;
6228 struct route_node
*rn
;
6230 params
= IF_DEF_PARAMS (ifp
);
6234 ret
= inet_aton(nbr_str
, &addr
);
6237 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6242 params
= ospf_get_if_params (ifp
, addr
);
6243 ospf_if_update_params (ifp
, addr
);
6248 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6251 /* reset fast_hello too, just to be sure */
6252 UNSET_IF_PARAM (params
, fast_hello
);
6253 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6255 else if (fast_hello_str
)
6257 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6259 /* 1s dead-interval with sub-second hellos desired */
6260 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6261 SET_IF_PARAM (params
, fast_hello
);
6262 params
->fast_hello
= hellomult
;
6266 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6271 SET_IF_PARAM (params
, v_wait
);
6272 params
->v_wait
= seconds
;
6274 /* Update timer values in neighbor structure. */
6278 if ((ospf
= ospf_lookup()))
6280 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6282 ospf_nbr_timer_update (oi
);
6287 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6288 if ((oi
= rn
->info
))
6289 ospf_nbr_timer_update (oi
);
6295 DEFUN (ip_ospf_dead_interval
,
6296 ip_ospf_dead_interval_cmd
,
6297 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6299 "OSPF interface commands\n"
6300 "Interval time after which a neighbor is declared down\n"
6302 "Address of interface\n")
6305 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6306 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6307 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6311 DEFUN_HIDDEN (ospf_dead_interval
,
6312 ospf_dead_interval_cmd
,
6313 "ospf dead-interval (1-65535) [A.B.C.D]",
6314 "OSPF interface commands\n"
6315 "Interval time after which a neighbor is declared down\n"
6317 "Address of interface\n")
6319 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6322 DEFUN (ip_ospf_dead_interval_minimal
,
6323 ip_ospf_dead_interval_minimal_addr_cmd
,
6324 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6326 "OSPF interface commands\n"
6327 "Interval time after which a neighbor is declared down\n"
6328 "Minimal 1s dead-interval with fast sub-second hellos\n"
6329 "Hello multiplier factor\n"
6330 "Number of Hellos to send each second\n"
6331 "Address of interface\n")
6336 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6338 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6341 DEFUN (no_ip_ospf_dead_interval
,
6342 no_ip_ospf_dead_interval_cmd
,
6343 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6346 "OSPF interface commands\n"
6347 "Interval time after which a neighbor is declared down\n"
6349 "Address of interface")
6351 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6352 int idx_ipv4
= argc
- 1;
6353 struct in_addr addr
;
6355 struct ospf_if_params
*params
;
6356 struct ospf_interface
*oi
;
6357 struct route_node
*rn
;
6359 params
= IF_DEF_PARAMS (ifp
);
6361 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6363 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6366 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6371 params
= ospf_lookup_if_params (ifp
, addr
);
6376 UNSET_IF_PARAM (params
, v_wait
);
6377 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6379 UNSET_IF_PARAM (params
, fast_hello
);
6380 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6382 if (params
!= IF_DEF_PARAMS (ifp
))
6384 ospf_free_if_params (ifp
, addr
);
6385 ospf_if_update_params (ifp
, addr
);
6388 /* Update timer values in neighbor structure. */
6393 if ((ospf
= ospf_lookup()))
6395 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6397 ospf_nbr_timer_update (oi
);
6402 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6403 if ((oi
= rn
->info
))
6404 ospf_nbr_timer_update (oi
);
6410 DEFUN_HIDDEN (no_ospf_dead_interval
,
6411 no_ospf_dead_interval_cmd
,
6412 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6414 "OSPF interface commands\n"
6415 "Interval time after which a neighbor is declared down\n"
6417 "Address of interface")
6419 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6422 DEFUN (ip_ospf_hello_interval
,
6423 ip_ospf_hello_interval_cmd
,
6424 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6426 "OSPF interface commands\n"
6427 "Time between HELLO packets\n"
6429 "Address of interface\n")
6431 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6433 struct in_addr addr
;
6434 struct ospf_if_params
*params
;
6435 params
= IF_DEF_PARAMS (ifp
);
6436 u_int32_t seconds
= 0;
6438 argv_find (argv
, argc
, "(1-65535)", &idx
);
6439 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6441 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6443 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6445 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6450 params
= ospf_get_if_params (ifp
, addr
);
6451 ospf_if_update_params (ifp
, addr
);
6454 SET_IF_PARAM (params
, v_hello
);
6455 params
->v_hello
= seconds
;
6460 DEFUN_HIDDEN (ospf_hello_interval
,
6461 ospf_hello_interval_cmd
,
6462 "ospf hello-interval (1-65535) [A.B.C.D]",
6463 "OSPF interface commands\n"
6464 "Time between HELLO packets\n"
6466 "Address of interface\n")
6468 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6471 DEFUN (no_ip_ospf_hello_interval
,
6472 no_ip_ospf_hello_interval_cmd
,
6473 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6476 "OSPF interface commands\n"
6477 "Time between HELLO packets\n" // ignored
6479 "Address of interface\n")
6481 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6483 struct in_addr addr
;
6484 struct ospf_if_params
*params
;
6485 params
= IF_DEF_PARAMS (ifp
);
6487 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6489 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6491 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6496 params
= ospf_lookup_if_params (ifp
, addr
);
6501 UNSET_IF_PARAM (params
, v_hello
);
6502 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6504 if (params
!= IF_DEF_PARAMS (ifp
))
6506 ospf_free_if_params (ifp
, addr
);
6507 ospf_if_update_params (ifp
, addr
);
6513 DEFUN_HIDDEN (no_ospf_hello_interval
,
6514 no_ospf_hello_interval_cmd
,
6515 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6517 "OSPF interface commands\n"
6518 "Time between HELLO packets\n" // ignored
6520 "Address of interface\n")
6522 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6525 DEFUN (ip_ospf_network
,
6526 ip_ospf_network_cmd
,
6527 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6529 "OSPF interface commands\n"
6531 "Specify OSPF broadcast multi-access network\n"
6532 "Specify OSPF NBMA network\n"
6533 "Specify OSPF point-to-multipoint network\n"
6534 "Specify OSPF point-to-point network\n")
6536 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6538 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6539 struct route_node
*rn
;
6541 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6543 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6547 if (argv_find (argv
, argc
, "broadcast", &idx
))
6548 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6549 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6550 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6551 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6552 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6553 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6554 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6556 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6559 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6561 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6563 struct ospf_interface
*oi
= rn
->info
;
6568 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6570 if (oi
->state
> ISM_Down
)
6572 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6573 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6580 DEFUN_HIDDEN (ospf_network
,
6582 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6583 "OSPF interface commands\n"
6585 "Specify OSPF broadcast multi-access network\n"
6586 "Specify OSPF NBMA network\n"
6587 "Specify OSPF point-to-multipoint network\n"
6588 "Specify OSPF point-to-point network\n")
6590 return ip_ospf_network (self
, vty
, argc
, argv
);
6593 DEFUN (no_ip_ospf_network
,
6594 no_ip_ospf_network_cmd
,
6595 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6598 "OSPF interface commands\n"
6600 "Specify OSPF broadcast multi-access network\n"
6601 "Specify OSPF NBMA network\n"
6602 "Specify OSPF point-to-multipoint network\n"
6603 "Specify OSPF point-to-point network\n")
6605 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6606 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6607 struct route_node
*rn
;
6609 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6611 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6614 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6616 struct ospf_interface
*oi
= rn
->info
;
6621 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6623 if (oi
->state
> ISM_Down
)
6625 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6626 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6633 DEFUN_HIDDEN (no_ospf_network
,
6634 no_ospf_network_cmd
,
6635 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6637 "OSPF interface commands\n"
6639 "Specify OSPF broadcast multi-access network\n"
6640 "Specify OSPF NBMA network\n"
6641 "Specify OSPF point-to-multipoint network\n"
6642 "Specify OSPF point-to-point network\n")
6644 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6647 DEFUN (ip_ospf_priority
,
6648 ip_ospf_priority_cmd
,
6649 "ip ospf priority (0-255) [A.B.C.D]",
6651 "OSPF interface commands\n"
6654 "Address of interface")
6656 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6659 struct route_node
*rn
;
6660 struct in_addr addr
;
6661 struct ospf_if_params
*params
;
6662 params
= IF_DEF_PARAMS (ifp
);
6664 argv_find (argv
, argc
, "(0-255)", &idx
);
6665 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6667 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6669 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6671 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6676 params
= ospf_get_if_params (ifp
, addr
);
6677 ospf_if_update_params (ifp
, addr
);
6680 SET_IF_PARAM (params
, priority
);
6681 params
->priority
= priority
;
6683 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6685 struct ospf_interface
*oi
= rn
->info
;
6690 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6692 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6693 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6700 DEFUN_HIDDEN (ospf_priority
,
6702 "ospf priority (0-255) [A.B.C.D]",
6703 "OSPF interface commands\n"
6706 "Address of interface")
6708 return ip_ospf_priority (self
, vty
, argc
, argv
);
6711 DEFUN (no_ip_ospf_priority
,
6712 no_ip_ospf_priority_cmd
,
6713 "no ip ospf priority [(0-255) [A.B.C.D]]",
6716 "OSPF interface commands\n"
6717 "Router priority\n" // ignored
6719 "Address of interface")
6721 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6723 struct route_node
*rn
;
6724 struct in_addr addr
;
6725 struct ospf_if_params
*params
;
6727 params
= IF_DEF_PARAMS (ifp
);
6729 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6731 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6733 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6738 params
= ospf_lookup_if_params (ifp
, addr
);
6743 UNSET_IF_PARAM (params
, priority
);
6744 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6746 if (params
!= IF_DEF_PARAMS (ifp
))
6748 ospf_free_if_params (ifp
, addr
);
6749 ospf_if_update_params (ifp
, addr
);
6752 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6754 struct ospf_interface
*oi
= rn
->info
;
6759 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6761 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6762 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6769 DEFUN_HIDDEN (no_ospf_priority
,
6770 no_ospf_priority_cmd
,
6771 "no ospf priority [(0-255) [A.B.C.D]]",
6773 "OSPF interface commands\n"
6776 "Address of interface")
6778 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6781 DEFUN (ip_ospf_retransmit_interval
,
6782 ip_ospf_retransmit_interval_addr_cmd
,
6783 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6785 "OSPF interface commands\n"
6786 "Time between retransmitting lost link state advertisements\n"
6788 "Address of interface")
6790 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6793 struct in_addr addr
;
6794 struct ospf_if_params
*params
;
6795 params
= IF_DEF_PARAMS (ifp
);
6797 argv_find (argv
, argc
, "(3-65535)", &idx
);
6798 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6800 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6802 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6804 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6809 params
= ospf_get_if_params (ifp
, addr
);
6810 ospf_if_update_params (ifp
, addr
);
6813 SET_IF_PARAM (params
, retransmit_interval
);
6814 params
->retransmit_interval
= seconds
;
6819 DEFUN_HIDDEN (ospf_retransmit_interval
,
6820 ospf_retransmit_interval_cmd
,
6821 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6822 "OSPF interface commands\n"
6823 "Time between retransmitting lost link state advertisements\n"
6825 "Address of interface")
6827 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6830 DEFUN (no_ip_ospf_retransmit_interval
,
6831 no_ip_ospf_retransmit_interval_addr_cmd
,
6832 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6835 "OSPF interface commands\n"
6836 "Time between retransmitting lost link state advertisements\n"
6838 "Address of interface\n")
6840 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6842 struct in_addr addr
;
6843 struct ospf_if_params
*params
;
6845 params
= IF_DEF_PARAMS (ifp
);
6847 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6849 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6851 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6856 params
= ospf_lookup_if_params (ifp
, addr
);
6861 UNSET_IF_PARAM (params
, retransmit_interval
);
6862 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6864 if (params
!= IF_DEF_PARAMS (ifp
))
6866 ospf_free_if_params (ifp
, addr
);
6867 ospf_if_update_params (ifp
, addr
);
6873 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6874 no_ospf_retransmit_interval_cmd
,
6875 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6877 "OSPF interface commands\n"
6878 "Time between retransmitting lost link state advertisements\n"
6880 "Address of interface\n")
6882 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6885 DEFUN (ip_ospf_transmit_delay
,
6886 ip_ospf_transmit_delay_addr_cmd
,
6887 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6889 "OSPF interface commands\n"
6890 "Link state transmit delay\n"
6892 "Address of interface")
6894 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6897 struct in_addr addr
;
6898 struct ospf_if_params
*params
;
6900 params
= IF_DEF_PARAMS (ifp
);
6901 argv_find (argv
, argc
, "(1-65535)", &idx
);
6902 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6904 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6906 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6908 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6913 params
= ospf_get_if_params (ifp
, addr
);
6914 ospf_if_update_params (ifp
, addr
);
6917 SET_IF_PARAM (params
, transmit_delay
);
6918 params
->transmit_delay
= seconds
;
6923 DEFUN_HIDDEN (ospf_transmit_delay
,
6924 ospf_transmit_delay_cmd
,
6925 "ospf transmit-delay (1-65535) [A.B.C.D]",
6926 "OSPF interface commands\n"
6927 "Link state transmit delay\n"
6929 "Address of interface")
6931 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6934 DEFUN (no_ip_ospf_transmit_delay
,
6935 no_ip_ospf_transmit_delay_addr_cmd
,
6936 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6939 "OSPF interface commands\n"
6940 "Link state transmit delay\n"
6941 "Address of interface")
6943 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6945 struct in_addr addr
;
6946 struct ospf_if_params
*params
;
6948 params
= IF_DEF_PARAMS (ifp
);
6950 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6952 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6954 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6959 params
= ospf_lookup_if_params (ifp
, addr
);
6964 UNSET_IF_PARAM (params
, transmit_delay
);
6965 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6967 if (params
!= IF_DEF_PARAMS (ifp
))
6969 ospf_free_if_params (ifp
, addr
);
6970 ospf_if_update_params (ifp
, addr
);
6977 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6978 no_ospf_transmit_delay_cmd
,
6979 "no ospf transmit-delay",
6981 "OSPF interface commands\n"
6982 "Link state transmit delay\n")
6984 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6987 DEFUN (ip_ospf_area
,
6989 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6991 "OSPF interface commands\n"
6993 "Enable OSPF on this interface\n"
6994 "OSPF area ID in IP address format\n"
6995 "OSPF area ID as a decimal value\n")
6997 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7000 struct in_addr area_id
;
7002 struct ospf_if_params
*params
;
7003 struct route_node
*rn
;
7004 u_short instance
= 0;
7006 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7007 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7008 char *areaid
= argv
[argc
- 1]->arg
;
7010 ospf
= ospf_lookup_instance (instance
);
7013 params
= IF_DEF_PARAMS (ifp
);
7014 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7016 ospf_interface_unset (ifp
);
7017 ospf
= ospf_lookup();
7018 ospf
->if_ospf_cli_count
--;
7023 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7026 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7030 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7032 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7036 params
= IF_DEF_PARAMS (ifp
);
7037 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7040 "Must remove previous area config before changing ospf area %s",
7045 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7047 if (rn
->info
!= NULL
)
7049 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7054 /* enable ospf on this interface with area_id */
7055 ospf_interface_set (ifp
, area_id
);
7056 ospf
->if_ospf_cli_count
++;
7061 DEFUN (no_ip_ospf_area
,
7062 no_ip_ospf_area_cmd
,
7063 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7066 "OSPF interface commands\n"
7068 "Disable OSPF on this interface\n"
7069 "OSPF area ID in IP address format\n"
7070 "OSPF area ID as a decimal value\n")
7072 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7075 struct ospf_if_params
*params
;
7076 u_short instance
= 0;
7078 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7079 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7081 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7084 params
= IF_DEF_PARAMS (ifp
);
7085 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7087 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7091 ospf_interface_unset (ifp
);
7092 ospf
->if_ospf_cli_count
--;
7096 DEFUN (ospf_redistribute_source
,
7097 ospf_redistribute_source_cmd
,
7098 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7100 FRR_REDIST_HELP_STR_OSPFD
7101 "Metric for redistributed routes\n"
7102 "OSPF default metric\n"
7103 "OSPF exterior metric type for redistributed routes\n"
7104 "Set OSPF External Type 1 metrics\n"
7105 "Set OSPF External Type 2 metrics\n"
7106 "Route map reference\n"
7107 "Pointer to route-map entries\n")
7109 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7110 int idx_protocol
= 1;
7114 struct ospf_redist
*red
;
7120 /* Get distribute source. */
7121 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7125 red
= ospf_redist_add(ospf
, source
, 0);
7127 /* Get metric value. */
7128 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7129 if (!str2metric (argv
[idx
]->arg
, &metric
))
7132 /* Get metric type. */
7133 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7134 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7138 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7139 ospf_routemap_set (red
, argv
[idx
]->arg
);
7142 ospf_routemap_unset (red
);
7144 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7147 DEFUN (no_ospf_redistribute_source
,
7148 no_ospf_redistribute_source_cmd
,
7149 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7152 FRR_REDIST_HELP_STR_OSPFD
7153 "Metric for redistributed routes\n"
7154 "OSPF default metric\n"
7155 "OSPF exterior metric type for redistributed routes\n"
7156 "Set OSPF External Type 1 metrics\n"
7157 "Set OSPF External Type 2 metrics\n"
7158 "Route map reference\n"
7159 "Pointer to route-map entries\n")
7161 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7162 int idx_protocol
= 2;
7164 struct ospf_redist
*red
;
7166 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7170 red
= ospf_redist_lookup(ospf
, source
, 0);
7174 ospf_routemap_unset (red
);
7175 return ospf_redistribute_unset (ospf
, source
, 0);
7178 DEFUN (ospf_redistribute_instance_source
,
7179 ospf_redistribute_instance_source_cmd
,
7180 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7182 "Open Shortest Path First\n"
7183 "Non-main Kernel Routing Table\n"
7184 "Instance ID/Table ID\n"
7185 "Metric for redistributed routes\n"
7186 "OSPF default metric\n"
7187 "OSPF exterior metric type for redistributed routes\n"
7188 "Set OSPF External Type 1 metrics\n"
7189 "Set OSPF External Type 2 metrics\n"
7190 "Route map reference\n"
7191 "Pointer to route-map entries\n")
7193 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7194 int idx_ospf_table
= 1;
7196 int idx_redist_param
= 3;
7201 struct ospf_redist
*red
;
7206 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7208 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7213 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7215 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7220 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7222 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7227 /* Get metric value. */
7228 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7229 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7232 /* Get metric type. */
7233 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7234 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7237 red
= ospf_redist_add(ospf
, source
, instance
);
7239 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7240 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7242 ospf_routemap_unset (red
);
7244 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7247 DEFUN (no_ospf_redistribute_instance_source
,
7248 no_ospf_redistribute_instance_source_cmd
,
7249 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7252 "Open Shortest Path First\n"
7253 "Non-main Kernel Routing Table\n"
7254 "Instance ID/Table Id\n"
7255 "Metric for redistributed routes\n"
7256 "OSPF default metric\n"
7257 "OSPF exterior metric type for redistributed routes\n"
7258 "Set OSPF External Type 1 metrics\n"
7259 "Set OSPF External Type 2 metrics\n"
7260 "Route map reference\n"
7261 "Pointer to route-map entries\n")
7263 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7264 int idx_ospf_table
= 2;
7267 struct ospf_redist
*red
;
7270 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7271 source
= ZEBRA_ROUTE_OSPF
;
7273 source
= ZEBRA_ROUTE_TABLE
;
7275 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7277 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7279 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7284 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7286 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7291 red
= ospf_redist_lookup(ospf
, source
, instance
);
7295 ospf_routemap_unset (red
);
7296 return ospf_redistribute_unset (ospf
, source
, instance
);
7299 DEFUN (ospf_distribute_list_out
,
7300 ospf_distribute_list_out_cmd
,
7301 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7302 "Filter networks in routing updates\n"
7303 "Access-list name\n"
7305 FRR_REDIST_HELP_STR_OSPFD
)
7307 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7311 char *proto
= argv
[argc
- 1]->text
;
7313 /* Get distribute source. */
7314 source
= proto_redistnum(AFI_IP
, proto
);
7318 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7321 DEFUN (no_ospf_distribute_list_out
,
7322 no_ospf_distribute_list_out_cmd
,
7323 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7325 "Filter networks in routing updates\n"
7326 "Access-list name\n"
7328 FRR_REDIST_HELP_STR_OSPFD
)
7330 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7334 char *proto
= argv
[argc
- 1]->text
;
7335 source
= proto_redistnum(AFI_IP
, proto
);
7339 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7342 /* Default information originate. */
7343 DEFUN (ospf_default_information_originate
,
7344 ospf_default_information_originate_cmd
,
7345 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7346 "Control distribution of default information\n"
7347 "Distribute a default route\n"
7348 "Always advertise default route\n"
7349 "OSPF default metric\n"
7351 "OSPF metric type for default routes\n"
7352 "Set OSPF External Type 1 metrics\n"
7353 "Set OSPF External Type 2 metrics\n"
7354 "Route map reference\n"
7355 "Pointer to route-map entries\n")
7357 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7358 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7361 struct ospf_redist
*red
;
7364 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7366 /* Check whether "always" was specified */
7367 if (argv_find (argv
, argc
, "always", &idx
))
7368 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7369 /* Get metric value */
7370 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7371 if (!str2metric (argv
[idx
]->arg
, &metric
))
7374 /* Get metric type. */
7375 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7376 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7380 else if (argv_find (argv
, argc
, "WORD", &idx
))
7381 ospf_routemap_set (red
, argv
[idx
]->arg
);
7383 ospf_routemap_unset (red
);
7385 return ospf_redistribute_default_set (ospf
, default_originate
,
7389 DEFUN (no_ospf_default_information_originate
,
7390 no_ospf_default_information_originate_cmd
,
7391 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7393 "Control distribution of default information\n"
7394 "Distribute a default route\n"
7395 "Always advertise default route\n"
7396 "OSPF default metric\n"
7398 "OSPF metric type for default routes\n"
7399 "Set OSPF External Type 1 metrics\n"
7400 "Set OSPF External Type 2 metrics\n"
7401 "Route map reference\n"
7402 "Pointer to route-map entries\n")
7404 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7405 struct prefix_ipv4 p
;
7406 struct ospf_external
*ext
;
7407 struct ospf_redist
*red
;
7410 p
.prefix
.s_addr
= 0;
7413 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7415 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7416 EXTERNAL_INFO (ext
)) {
7417 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7418 ospf_external_del (DEFAULT_ROUTE
, 0);
7421 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7425 ospf_routemap_unset (red
);
7426 return ospf_redistribute_default_unset (ospf
);
7429 DEFUN (ospf_default_metric
,
7430 ospf_default_metric_cmd
,
7431 "default-metric (0-16777214)",
7432 "Set metric of redistributed routes\n"
7435 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7439 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7442 ospf
->default_metric
= metric
;
7447 DEFUN (no_ospf_default_metric
,
7448 no_ospf_default_metric_cmd
,
7449 "no default-metric [(0-16777214)]",
7451 "Set metric of redistributed routes\n"
7454 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7456 ospf
->default_metric
= -1;
7462 DEFUN (ospf_distance
,
7465 "Define an administrative distance\n"
7466 "OSPF Administrative distance\n")
7468 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7471 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7476 DEFUN (no_ospf_distance
,
7477 no_ospf_distance_cmd
,
7478 "no distance (1-255)",
7480 "Define an administrative distance\n"
7481 "OSPF Administrative distance\n")
7483 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7485 ospf
->distance_all
= 0;
7490 DEFUN (no_ospf_distance_ospf
,
7491 no_ospf_distance_ospf_cmd
,
7492 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7494 "Define an administrative distance\n"
7495 "OSPF Administrative distance\n"
7496 "Intra-area routes\n"
7497 "Distance for intra-area routes\n"
7498 "Inter-area routes\n"
7499 "Distance for inter-area routes\n"
7501 "Distance for external routes\n")
7503 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7504 int idx_area_distance
= 3;
7515 if (argv
[idx_area_distance
]->arg
!= NULL
)
7516 ospf
->distance_intra
= 0;
7518 if (argv
[1] != NULL
)
7519 ospf
->distance_inter
= 0;
7521 if (argv
[2] != NULL
)
7522 ospf
->distance_external
= 0;
7524 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
7527 /* If no arguments are given, clear all distance information */
7528 ospf
->distance_intra
= 0;
7529 ospf
->distance_inter
= 0;
7530 ospf
->distance_external
= 0;
7535 DEFUN (ospf_distance_ospf
,
7536 ospf_distance_ospf_cmd
,
7537 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7538 "Define an administrative distance\n"
7539 "OSPF Administrative distance\n"
7540 "Intra-area routes\n"
7541 "Distance for intra-area routes\n"
7542 "Inter-area routes\n"
7543 "Distance for inter-area routes\n"
7545 "Distance for external routes\n")
7547 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7548 int idx_area_distance
= 2;
7550 if (argc
< 3) /* should not happen */
7553 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
7555 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
7560 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
7561 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
7563 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
7564 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
7566 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
7567 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
7573 DEFUN (ospf_distance_source
,
7574 ospf_distance_source_cmd
,
7575 "distance (1-255) A.B.C.D/M",
7576 "Administrative distance\n"
7578 "IP source prefix\n")
7580 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7582 int idx_ipv4_prefixlen
= 2;
7587 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7592 DEFUN (no_ospf_distance_source
,
7593 no_ospf_distance_source_cmd
,
7594 "no distance (1-255) A.B.C.D/M",
7596 "Administrative distance\n"
7598 "IP source prefix\n")
7600 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7602 int idx_ipv4_prefixlen
= 3;
7607 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7612 DEFUN (ospf_distance_source_access_list
,
7613 ospf_distance_source_access_list_cmd
,
7614 "distance (1-255) A.B.C.D/M WORD",
7615 "Administrative distance\n"
7617 "IP source prefix\n"
7618 "Access list name\n")
7620 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7622 int idx_ipv4_prefixlen
= 2;
7628 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7633 DEFUN (no_ospf_distance_source_access_list
,
7634 no_ospf_distance_source_access_list_cmd
,
7635 "no distance (1-255) A.B.C.D/M WORD",
7637 "Administrative distance\n"
7639 "IP source prefix\n"
7640 "Access list name\n")
7642 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7644 int idx_ipv4_prefixlen
= 3;
7650 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7656 DEFUN (ip_ospf_mtu_ignore
,
7657 ip_ospf_mtu_ignore_addr_cmd
,
7658 "ip ospf mtu-ignore [A.B.C.D]",
7660 "OSPF interface commands\n"
7661 "Disable MTU mismatch detection on this interface\n"
7662 "Address of interface")
7664 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7666 struct in_addr addr
;
7669 struct ospf_if_params
*params
;
7670 params
= IF_DEF_PARAMS (ifp
);
7674 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7677 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7681 params
= ospf_get_if_params (ifp
, addr
);
7682 ospf_if_update_params (ifp
, addr
);
7684 params
->mtu_ignore
= 1;
7685 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7686 SET_IF_PARAM (params
, mtu_ignore
);
7689 UNSET_IF_PARAM (params
, mtu_ignore
);
7690 if (params
!= IF_DEF_PARAMS (ifp
))
7692 ospf_free_if_params (ifp
, addr
);
7693 ospf_if_update_params (ifp
, addr
);
7699 DEFUN (no_ip_ospf_mtu_ignore
,
7700 no_ip_ospf_mtu_ignore_addr_cmd
,
7701 "no ip ospf mtu-ignore [A.B.C.D]",
7703 "OSPF interface commands\n"
7704 "Disable MTU mismatch detection on this interface\n"
7705 "Address of interface")
7707 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7709 struct in_addr addr
;
7712 struct ospf_if_params
*params
;
7713 params
= IF_DEF_PARAMS (ifp
);
7717 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7720 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7724 params
= ospf_get_if_params (ifp
, addr
);
7725 ospf_if_update_params (ifp
, addr
);
7727 params
->mtu_ignore
= 0;
7728 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7729 SET_IF_PARAM (params
, mtu_ignore
);
7732 UNSET_IF_PARAM (params
, mtu_ignore
);
7733 if (params
!= IF_DEF_PARAMS (ifp
))
7735 ospf_free_if_params (ifp
, addr
);
7736 ospf_if_update_params (ifp
, addr
);
7743 DEFUN (ospf_max_metric_router_lsa_admin
,
7744 ospf_max_metric_router_lsa_admin_cmd
,
7745 "max-metric router-lsa administrative",
7746 "OSPF maximum / infinite-distance metric\n"
7747 "Advertise own Router-LSA with infinite distance (stub router)\n"
7748 "Administratively applied, for an indefinite period\n")
7750 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7751 struct listnode
*ln
;
7752 struct ospf_area
*area
;
7754 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7756 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7758 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7759 ospf_router_lsa_update_area (area
);
7762 /* Allows for areas configured later to get the property */
7763 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7768 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7769 no_ospf_max_metric_router_lsa_admin_cmd
,
7770 "no max-metric router-lsa administrative",
7772 "OSPF maximum / infinite-distance metric\n"
7773 "Advertise own Router-LSA with infinite distance (stub router)\n"
7774 "Administratively applied, for an indefinite period\n")
7776 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7777 struct listnode
*ln
;
7778 struct ospf_area
*area
;
7780 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7782 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7784 /* Don't trample on the start-up stub timer */
7785 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7786 && !area
->t_stub_router
)
7788 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7789 ospf_router_lsa_update_area (area
);
7792 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7796 DEFUN (ospf_max_metric_router_lsa_startup
,
7797 ospf_max_metric_router_lsa_startup_cmd
,
7798 "max-metric router-lsa on-startup (5-86400)",
7799 "OSPF maximum / infinite-distance metric\n"
7800 "Advertise own Router-LSA with infinite distance (stub router)\n"
7801 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7802 "Time (seconds) to advertise self as stub-router\n")
7804 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7806 unsigned int seconds
;
7810 vty_out (vty
, "%% Must supply stub-router period");
7814 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7816 ospf
->stub_router_startup_time
= seconds
;
7821 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7822 no_ospf_max_metric_router_lsa_startup_cmd
,
7823 "no max-metric router-lsa on-startup [(5-86400)]",
7825 "OSPF maximum / infinite-distance metric\n"
7826 "Advertise own Router-LSA with infinite distance (stub router)\n"
7827 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7828 "Time (seconds) to advertise self as stub-router\n")
7830 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7831 struct listnode
*ln
;
7832 struct ospf_area
*area
;
7834 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7836 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7838 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7839 OSPF_TIMER_OFF (area
->t_stub_router
);
7841 /* Don't trample on admin stub routed */
7842 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7844 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7845 ospf_router_lsa_update_area (area
);
7852 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7853 ospf_max_metric_router_lsa_shutdown_cmd
,
7854 "max-metric router-lsa on-shutdown (5-100)",
7855 "OSPF maximum / infinite-distance metric\n"
7856 "Advertise own Router-LSA with infinite distance (stub router)\n"
7857 "Advertise stub-router prior to full shutdown of OSPF\n"
7858 "Time (seconds) to wait till full shutdown\n")
7860 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7862 unsigned int seconds
;
7866 vty_out (vty
, "%% Must supply stub-router shutdown period");
7870 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7872 ospf
->stub_router_shutdown_time
= seconds
;
7877 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7878 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7879 "no max-metric router-lsa on-shutdown [(5-100)]",
7881 "OSPF maximum / infinite-distance metric\n"
7882 "Advertise own Router-LSA with infinite distance (stub router)\n"
7883 "Advertise stub-router prior to full shutdown of OSPF\n"
7884 "Time (seconds) to wait till full shutdown\n")
7886 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7888 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7894 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7896 struct listnode
*ln
;
7897 struct ospf_area
*area
;
7899 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7900 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7901 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7902 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7903 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7904 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7905 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7907 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7909 vty_out (vty
, " max-metric router-lsa administrative%s",
7918 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7920 struct route_node
*rn
;
7921 struct ospf_route
*or;
7922 struct listnode
*pnode
, *pnnode
;
7923 struct ospf_path
*path
;
7925 vty_out (vty
, "============ OSPF network routing table ============%s",
7928 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7929 if ((or = rn
->info
) != NULL
)
7932 snprintf (buf1
, 19, "%s/%d",
7933 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7935 switch (or->path_type
)
7937 case OSPF_PATH_INTER_AREA
:
7938 if (or->type
== OSPF_DESTINATION_NETWORK
)
7939 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7940 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7941 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7942 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7944 case OSPF_PATH_INTRA_AREA
:
7945 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7946 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7952 if (or->type
== OSPF_DESTINATION_NETWORK
)
7953 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7955 if (if_lookup_by_index(path
->ifindex
))
7957 if (path
->nexthop
.s_addr
== 0)
7958 vty_out (vty
, "%24s directly attached to %s%s",
7959 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7961 vty_out (vty
, "%24s via %s, %s%s", "",
7962 inet_ntoa (path
->nexthop
),
7963 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7967 vty_out (vty
, "%s", VTY_NEWLINE
);
7971 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7973 struct route_node
*rn
;
7974 struct ospf_route
*or;
7975 struct listnode
*pnode
;
7976 struct listnode
*node
;
7977 struct ospf_path
*path
;
7979 vty_out (vty
, "============ OSPF router routing table =============%s",
7981 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7986 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7988 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7991 vty_out (vty
, "%24s", "");
7994 vty_out (vty
, "%s [%d] area: %s",
7995 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7996 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7998 vty_out (vty
, "%s%s%s",
7999 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
8000 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
8003 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8005 if (if_lookup_by_index(path
->ifindex
))
8007 if (path
->nexthop
.s_addr
== 0)
8008 vty_out (vty
, "%24s directly attached to %s%s",
8009 "", ifindex2ifname (path
->ifindex
),
8012 vty_out (vty
, "%24s via %s, %s%s", "",
8013 inet_ntoa (path
->nexthop
),
8014 ifindex2ifname (path
->ifindex
),
8020 vty_out (vty
, "%s", VTY_NEWLINE
);
8024 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8026 struct route_node
*rn
;
8027 struct ospf_route
*er
;
8028 struct listnode
*pnode
, *pnnode
;
8029 struct ospf_path
*path
;
8031 vty_out (vty
, "============ OSPF external routing table ===========%s",
8033 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8034 if ((er
= rn
->info
) != NULL
)
8037 snprintf (buf1
, 19, "%s/%d",
8038 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8040 switch (er
->path_type
)
8042 case OSPF_PATH_TYPE1_EXTERNAL
:
8043 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8044 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8046 case OSPF_PATH_TYPE2_EXTERNAL
:
8047 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8048 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8052 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8054 if (if_lookup_by_index(path
->ifindex
))
8056 if (path
->nexthop
.s_addr
== 0)
8057 vty_out (vty
, "%24s directly attached to %s%s",
8058 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8060 vty_out (vty
, "%24s via %s, %s%s", "",
8061 inet_ntoa (path
->nexthop
),
8062 ifindex2ifname (path
->ifindex
),
8067 vty_out (vty
, "%s", VTY_NEWLINE
);
8071 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8074 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8075 VTY_NEWLINE
, VTY_NEWLINE
);
8077 if (ospf
->new_table
== NULL
)
8079 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8083 /* Show Network routes.
8084 show_ip_ospf_route_network (vty, ospf->new_table); */
8086 /* Show Router routes. */
8087 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8089 vty_out (vty
, "%s", VTY_NEWLINE
);
8094 DEFUN (show_ip_ospf_border_routers
,
8095 show_ip_ospf_border_routers_cmd
,
8096 "show ip ospf border-routers",
8099 "OSPF information\n"
8100 "Show all the ABR's and ASBR's\n")
8104 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8107 return show_ip_ospf_border_routers_common(vty
, ospf
);
8110 DEFUN (show_ip_ospf_instance_border_routers
,
8111 show_ip_ospf_instance_border_routers_cmd
,
8112 "show ip ospf (1-65535) border-routers",
8115 "OSPF information\n"
8117 "Show all the ABR's and ASBR's\n")
8121 u_short instance
= 0;
8123 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8124 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8127 return show_ip_ospf_border_routers_common(vty
, ospf
);
8131 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8134 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8135 VTY_NEWLINE
, VTY_NEWLINE
);
8137 if (ospf
->new_table
== NULL
)
8139 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8143 /* Show Network routes. */
8144 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8146 /* Show Router routes. */
8147 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8149 /* Show AS External routes. */
8150 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8152 vty_out (vty
, "%s", VTY_NEWLINE
);
8157 DEFUN (show_ip_ospf_route
,
8158 show_ip_ospf_route_cmd
,
8159 "show ip ospf route",
8162 "OSPF information\n"
8163 "OSPF routing table\n")
8167 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8170 return show_ip_ospf_route_common(vty
, ospf
);
8173 DEFUN (show_ip_ospf_instance_route
,
8174 show_ip_ospf_instance_route_cmd
,
8175 "show ip ospf (1-65535) route",
8178 "OSPF information\n"
8180 "OSPF routing table\n")
8184 u_short instance
= 0;
8186 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8187 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8190 return show_ip_ospf_route_common(vty
, ospf
);
8193 const char *ospf_abr_type_str
[] =
8202 const char *ospf_shortcut_mode_str
[] =
8211 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8213 memset (buf
, 0, length
);
8215 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8216 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8218 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8222 const char *ospf_int_type_str
[] =
8224 "unknown", /* should never be used. */
8228 "point-to-multipoint",
8229 "virtual-link", /* should never be used. */
8233 /* Configuration write function for ospfd. */
8235 config_write_interface (struct vty
*vty
)
8237 struct listnode
*n1
, *n2
;
8238 struct interface
*ifp
;
8239 struct crypt_key
*ck
;
8241 struct route_node
*rn
= NULL
;
8242 struct ospf_if_params
*params
;
8243 struct ospf
*ospf
= ospf_lookup();
8245 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8247 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8250 if (ifp
->ifindex
== IFINDEX_DELETED
)
8253 vty_out (vty
, "!%s", VTY_NEWLINE
);
8254 vty_out (vty
, "interface %s%s", ifp
->name
,
8257 vty_out (vty
, " description %s%s", ifp
->desc
,
8262 params
= IF_DEF_PARAMS (ifp
);
8265 /* Interface Network print. */
8266 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8267 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8269 if (params
->type
!= ospf_default_iftype(ifp
))
8271 vty_out (vty
, " ip ospf network %s",
8272 ospf_int_type_str
[params
->type
]);
8273 if (params
!= IF_DEF_PARAMS (ifp
))
8274 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8275 vty_out (vty
, "%s", VTY_NEWLINE
);
8279 /* OSPF interface authentication print */
8280 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8281 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8283 const char *auth_str
;
8285 /* Translation tables are not that much help here due to syntax
8286 of the simple option */
8287 switch (params
->auth_type
)
8290 case OSPF_AUTH_NULL
:
8294 case OSPF_AUTH_SIMPLE
:
8298 case OSPF_AUTH_CRYPTOGRAPHIC
:
8299 auth_str
= " message-digest";
8307 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8308 if (params
!= IF_DEF_PARAMS (ifp
))
8309 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8310 vty_out (vty
, "%s", VTY_NEWLINE
);
8313 /* Simple Authentication Password print. */
8314 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8315 params
->auth_simple
[0] != '\0')
8317 vty_out (vty
, " ip ospf authentication-key %s",
8318 params
->auth_simple
);
8319 if (params
!= IF_DEF_PARAMS (ifp
))
8320 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8321 vty_out (vty
, "%s", VTY_NEWLINE
);
8324 /* Cryptographic Authentication Key print. */
8325 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8327 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8328 ck
->key_id
, ck
->auth_key
);
8329 if (params
!= IF_DEF_PARAMS (ifp
))
8330 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8331 vty_out (vty
, "%s", VTY_NEWLINE
);
8334 /* Interface Output Cost print. */
8335 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8337 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8338 if (params
!= IF_DEF_PARAMS (ifp
))
8339 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8340 vty_out (vty
, "%s", VTY_NEWLINE
);
8343 /* Hello Interval print. */
8344 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8345 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8347 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8348 if (params
!= IF_DEF_PARAMS (ifp
))
8349 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8350 vty_out (vty
, "%s", VTY_NEWLINE
);
8354 /* Router Dead Interval print. */
8355 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8356 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8358 vty_out (vty
, " ip ospf dead-interval ");
8361 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8362 vty_out (vty
, "minimal hello-multiplier %d",
8363 params
->fast_hello
);
8365 vty_out (vty
, "%u", params
->v_wait
);
8367 if (params
!= IF_DEF_PARAMS (ifp
))
8368 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8369 vty_out (vty
, "%s", VTY_NEWLINE
);
8372 /* Router Priority print. */
8373 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8374 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8376 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8377 if (params
!= IF_DEF_PARAMS (ifp
))
8378 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8379 vty_out (vty
, "%s", VTY_NEWLINE
);
8382 /* Retransmit Interval print. */
8383 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8384 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8386 vty_out (vty
, " ip ospf retransmit-interval %u",
8387 params
->retransmit_interval
);
8388 if (params
!= IF_DEF_PARAMS (ifp
))
8389 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8390 vty_out (vty
, "%s", VTY_NEWLINE
);
8393 /* Transmit Delay print. */
8394 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8395 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8397 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8398 if (params
!= IF_DEF_PARAMS (ifp
))
8399 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8400 vty_out (vty
, "%s", VTY_NEWLINE
);
8404 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8407 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8408 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8410 vty_out (vty
, " ip ospf area %s%s",
8411 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8416 ospf_bfd_write_config(vty
, params
);
8418 /* MTU ignore print. */
8419 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8420 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8422 if (params
->mtu_ignore
== 0)
8423 vty_out (vty
, " no ip ospf mtu-ignore");
8425 vty_out (vty
, " ip ospf mtu-ignore");
8426 if (params
!= IF_DEF_PARAMS (ifp
))
8427 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8428 vty_out (vty
, "%s", VTY_NEWLINE
);
8435 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8437 rn
= route_next (rn
);
8447 ospf_opaque_config_write_if (vty
, ifp
);
8454 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8456 struct route_node
*rn
;
8457 u_char buf
[INET_ADDRSTRLEN
];
8459 /* `network area' print. */
8460 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8463 struct ospf_network
*n
= rn
->info
;
8465 memset (buf
, 0, INET_ADDRSTRLEN
);
8467 /* Create Area ID string by specified Area ID format. */
8468 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8469 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8471 sprintf ((char *) buf
, "%lu",
8472 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8474 /* Network print. */
8475 vty_out (vty
, " network %s/%d area %s%s",
8476 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8484 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8486 struct listnode
*node
;
8487 struct ospf_area
*area
;
8488 u_char buf
[INET_ADDRSTRLEN
];
8490 /* Area configuration print. */
8491 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8493 struct route_node
*rn1
;
8495 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8497 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8499 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8500 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8502 vty_out (vty
, " area %s authentication message-digest%s",
8506 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8507 vty_out (vty
, " area %s shortcut %s%s", buf
,
8508 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8511 if ((area
->external_routing
== OSPF_AREA_STUB
)
8512 || (area
->external_routing
== OSPF_AREA_NSSA
)
8515 if (area
->external_routing
== OSPF_AREA_STUB
)
8516 vty_out (vty
, " area %s stub", buf
);
8517 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8519 vty_out (vty
, " area %s nssa", buf
);
8520 switch (area
->NSSATranslatorRole
)
8522 case OSPF_NSSA_ROLE_NEVER
:
8523 vty_out (vty
, " translate-never");
8525 case OSPF_NSSA_ROLE_ALWAYS
:
8526 vty_out (vty
, " translate-always");
8528 case OSPF_NSSA_ROLE_CANDIDATE
:
8530 vty_out (vty
, " translate-candidate");
8534 if (area
->no_summary
)
8535 vty_out (vty
, " no-summary");
8537 vty_out (vty
, "%s", VTY_NEWLINE
);
8539 if (area
->default_cost
!= 1)
8540 vty_out (vty
, " area %s default-cost %d%s", buf
,
8541 area
->default_cost
, VTY_NEWLINE
);
8544 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8547 struct ospf_area_range
*range
= rn1
->info
;
8549 vty_out (vty
, " area %s range %s/%d", buf
,
8550 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8552 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8553 vty_out (vty
, " cost %d", range
->cost_config
);
8555 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8556 vty_out (vty
, " not-advertise");
8558 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8559 vty_out (vty
, " substitute %s/%d",
8560 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8562 vty_out (vty
, "%s", VTY_NEWLINE
);
8565 if (EXPORT_NAME (area
))
8566 vty_out (vty
, " area %s export-list %s%s", buf
,
8567 EXPORT_NAME (area
), VTY_NEWLINE
);
8569 if (IMPORT_NAME (area
))
8570 vty_out (vty
, " area %s import-list %s%s", buf
,
8571 IMPORT_NAME (area
), VTY_NEWLINE
);
8573 if (PREFIX_NAME_IN (area
))
8574 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8575 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8577 if (PREFIX_NAME_OUT (area
))
8578 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8579 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8586 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8588 struct ospf_nbr_nbma
*nbr_nbma
;
8589 struct route_node
*rn
;
8591 /* Static Neighbor configuration print. */
8592 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8593 if ((nbr_nbma
= rn
->info
))
8595 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8597 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8598 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8600 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8601 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8603 vty_out (vty
, "%s", VTY_NEWLINE
);
8610 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8612 struct listnode
*node
;
8613 struct ospf_vl_data
*vl_data
;
8614 u_char buf
[INET_ADDRSTRLEN
];
8616 /* Virtual-Link print */
8617 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8619 struct listnode
*n2
;
8620 struct crypt_key
*ck
;
8621 struct ospf_interface
*oi
;
8623 if (vl_data
!= NULL
)
8625 memset (buf
, 0, INET_ADDRSTRLEN
);
8627 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8628 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8630 sprintf ((char *) buf
, "%lu",
8631 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8632 oi
= vl_data
->vl_oi
;
8635 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8636 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8637 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8638 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8639 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8641 inet_ntoa (vl_data
->vl_peer
),
8642 OSPF_IF_PARAM (oi
, v_hello
),
8643 OSPF_IF_PARAM (oi
, retransmit_interval
),
8644 OSPF_IF_PARAM (oi
, transmit_delay
),
8645 OSPF_IF_PARAM (oi
, v_wait
),
8648 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8649 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8651 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8652 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8654 inet_ntoa (vl_data
->vl_peer
),
8655 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8658 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8660 vty_out (vty
, " area %s virtual-link %s"
8661 " message-digest-key %d md5 %s%s",
8663 inet_ntoa (vl_data
->vl_peer
),
8664 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8674 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8678 /* redistribute print. */
8679 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8681 struct list
*red_list
;
8682 struct listnode
*node
;
8683 struct ospf_redist
*red
;
8685 red_list
= ospf
->redist
[type
];
8689 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8691 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8693 vty_out (vty
, " %d", red
->instance
);
8695 if (red
->dmetric
.value
>= 0)
8696 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8698 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8699 vty_out (vty
, " metric-type 1");
8701 if (ROUTEMAP_NAME (red
))
8702 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8704 vty_out (vty
, "%s", VTY_NEWLINE
);
8712 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8714 if (ospf
->default_metric
!= -1)
8715 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8721 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8724 struct ospf_redist
*red
;
8728 /* distribute-list print. */
8729 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8730 if (DISTRIBUTE_NAME (ospf
, type
))
8731 vty_out (vty
, " distribute-list %s out %s%s",
8732 DISTRIBUTE_NAME (ospf
, type
),
8733 zebra_route_string(type
), VTY_NEWLINE
);
8735 /* default-information print. */
8736 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8738 vty_out (vty
, " default-information originate");
8739 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8740 vty_out (vty
, " always");
8742 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8745 if (red
->dmetric
.value
>= 0)
8746 vty_out (vty
, " metric %d",
8747 red
->dmetric
.value
);
8748 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8749 vty_out (vty
, " metric-type 1");
8751 if (ROUTEMAP_NAME (red
))
8752 vty_out (vty
, " route-map %s",
8753 ROUTEMAP_NAME (red
));
8756 vty_out (vty
, "%s", VTY_NEWLINE
);
8765 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8767 struct route_node
*rn
;
8768 struct ospf_distance
*odistance
;
8770 if (ospf
->distance_all
)
8771 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8773 if (ospf
->distance_intra
8774 || ospf
->distance_inter
8775 || ospf
->distance_external
)
8777 vty_out (vty
, " distance ospf");
8779 if (ospf
->distance_intra
)
8780 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8781 if (ospf
->distance_inter
)
8782 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8783 if (ospf
->distance_external
)
8784 vty_out (vty
, " external %d", ospf
->distance_external
);
8786 vty_out (vty
, "%s", VTY_NEWLINE
);
8789 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8790 if ((odistance
= rn
->info
) != NULL
)
8792 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8793 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8794 odistance
->access_list
? odistance
->access_list
: "",
8800 /* OSPF configuration write function. */
8802 ospf_config_write (struct vty
*vty
)
8805 struct interface
*ifp
;
8806 struct ospf_interface
*oi
;
8807 struct listnode
*node
;
8810 ospf
= ospf_lookup ();
8811 if (ospf
!= NULL
&& ospf
->oi_running
)
8813 /* `router ospf' print. */
8815 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8817 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8821 if (!ospf
->networks
)
8824 /* Router ID print. */
8825 if (ospf
->router_id_static
.s_addr
!= 0)
8826 vty_out (vty
, " ospf router-id %s%s",
8827 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8829 /* ABR type print. */
8830 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8831 vty_out (vty
, " ospf abr-type %s%s",
8832 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8834 /* log-adjacency-changes flag print. */
8835 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8837 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8838 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8842 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8845 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8846 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8847 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8849 /* auto-cost reference-bandwidth configuration. */
8850 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8852 vty_out (vty
, "! Important: ensure reference bandwidth "
8853 "is consistent across all routers%s", VTY_NEWLINE
);
8854 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8855 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8858 /* SPF timers print. */
8859 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8860 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8861 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8862 vty_out (vty
, " timers throttle spf %d %d %d%s",
8863 ospf
->spf_delay
, ospf
->spf_holdtime
,
8864 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8866 /* LSA timers print. */
8867 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8868 vty_out (vty
, " timers throttle lsa all %d%s",
8869 ospf
->min_ls_interval
, VTY_NEWLINE
);
8870 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8871 vty_out (vty
, " timers lsa min-arrival %d%s",
8872 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8874 /* Write multiplier print. */
8875 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8876 vty_out (vty
, " ospf write-multiplier %d%s",
8877 ospf
->write_oi_count
, VTY_NEWLINE
);
8879 /* Max-metric router-lsa print */
8880 config_write_stub_router (vty
, ospf
);
8882 /* SPF refresh parameters print. */
8883 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8884 vty_out (vty
, " refresh timer %d%s",
8885 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8887 /* Redistribute information print. */
8888 config_write_ospf_redistribute (vty
, ospf
);
8890 /* passive-interface print. */
8891 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8892 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8894 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8895 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8896 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8897 ospf
->passive_interface_default
)
8899 vty_out (vty
, " %spassive-interface %s%s",
8900 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8901 ifp
->name
, VTY_NEWLINE
);
8903 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8905 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8907 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8910 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8913 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8916 vty_out (vty
, " %spassive-interface %s %s%s",
8917 oi
->params
->passive_interface
? "" : "no ",
8919 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8922 /* Network area print. */
8923 config_write_network_area (vty
, ospf
);
8925 /* Area config print. */
8926 config_write_ospf_area (vty
, ospf
);
8928 /* static neighbor print. */
8929 config_write_ospf_nbr_nbma (vty
, ospf
);
8931 /* Virtual-Link print. */
8932 config_write_virtual_link (vty
, ospf
);
8934 /* Default metric configuration. */
8935 config_write_ospf_default_metric (vty
, ospf
);
8937 /* Distribute-list and default-information print. */
8938 config_write_ospf_distribute (vty
, ospf
);
8940 /* Distance configuration. */
8941 config_write_ospf_distance (vty
, ospf
);
8943 ospf_opaque_config_write_router (vty
, ospf
);
8950 ospf_vty_show_init (void)
8952 /* "show ip ospf" commands. */
8953 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8955 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8957 /* "show ip ospf database" commands. */
8958 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8959 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8961 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8962 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8963 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8965 /* "show ip ospf interface" commands. */
8966 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8968 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8970 /* "show ip ospf neighbor" commands. */
8971 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8972 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8973 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8974 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8975 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8976 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8977 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8979 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8980 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8981 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8982 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8983 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8984 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8985 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8987 /* "show ip ospf route" commands. */
8988 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8989 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8991 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8992 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8996 /* ospfd's interface node. */
8997 static struct cmd_node interface_node
=
9004 /* Initialization of OSPF interface. */
9006 ospf_vty_if_init (void)
9008 /* Install interface node. */
9009 install_node (&interface_node
, config_write_interface
);
9012 /* "ip ospf authentication" commands. */
9013 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9014 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9015 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9016 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9017 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9018 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9019 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9021 /* "ip ospf message-digest-key" commands. */
9022 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9023 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9025 /* "ip ospf cost" commands. */
9026 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9027 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9029 /* "ip ospf mtu-ignore" commands. */
9030 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9031 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9033 /* "ip ospf dead-interval" commands. */
9034 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9035 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9036 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9038 /* "ip ospf hello-interval" commands. */
9039 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9040 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9042 /* "ip ospf network" commands. */
9043 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9044 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9046 /* "ip ospf priority" commands. */
9047 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9048 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9050 /* "ip ospf retransmit-interval" commands. */
9051 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9052 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9054 /* "ip ospf transmit-delay" commands. */
9055 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9056 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9058 /* "ip ospf area" commands. */
9059 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9060 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9062 /* These commands are compatibitliy for previous version. */
9063 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9064 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9065 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9066 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9067 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9068 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9069 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9070 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9071 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9072 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9073 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9074 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9075 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9076 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9077 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9078 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9079 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9083 ospf_vty_zebra_init (void)
9085 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9086 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9087 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9088 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9090 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9091 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9093 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9094 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9096 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9097 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9099 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9100 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9101 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9102 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9104 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9105 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9106 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9107 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9111 static struct cmd_node ospf_node
=
9114 "%s(config-router)# ",
9119 ospf_interface_clear (struct interface
*ifp
)
9121 if (!if_is_operative (ifp
)) return;
9123 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9124 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
9129 DEFUN (clear_ip_ospf_interface
,
9130 clear_ip_ospf_interface_cmd
,
9131 "clear ip ospf interface [IFNAME]",
9134 "OSPF information\n"
9135 "Interface information\n"
9139 struct interface
*ifp
;
9140 struct listnode
*node
;
9142 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9144 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9145 ospf_interface_clear(ifp
);
9147 else /* Interface name is specified. */
9149 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
9150 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9152 ospf_interface_clear(ifp
);
9159 ospf_vty_clear_init (void)
9161 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9165 /* Install OSPF related vty commands. */
9167 ospf_vty_init (void)
9169 /* Install ospf top node. */
9170 install_node (&ospf_node
, ospf_config_write
);
9172 /* "router ospf" commands. */
9173 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9174 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9177 install_default (OSPF_NODE
);
9179 /* "ospf router-id" commands. */
9180 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9181 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9182 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9184 /* "passive-interface" commands. */
9185 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9186 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9188 /* "ospf abr-type" commands. */
9189 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9190 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9192 /* "ospf log-adjacency-changes" commands. */
9193 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9194 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9195 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9196 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9198 /* "ospf rfc1583-compatible" commands. */
9199 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9200 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9201 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9202 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9204 /* "network area" commands. */
9205 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9206 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9208 /* "area authentication" commands. */
9209 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9210 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9211 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9213 /* "area range" commands. */
9214 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9215 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9216 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9217 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9218 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9219 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9221 /* "area virtual-link" commands. */
9222 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9223 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9224 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9225 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9236 /* "area stub" commands. */
9237 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9238 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9239 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9240 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9242 /* "area nssa" commands. */
9243 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9244 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9245 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9246 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9247 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9249 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9250 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9252 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9253 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9255 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9256 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9258 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9259 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9261 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9262 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9264 /* SPF timer commands */
9265 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9266 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9268 /* LSA timers commands */
9269 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9270 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9271 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9272 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9273 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9274 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9276 /* refresh timer commands */
9277 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9278 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9280 /* max-metric commands */
9281 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9282 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9283 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9284 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9285 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9286 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9288 /* reference bandwidth commands */
9289 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9290 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9292 /* "neighbor" commands. */
9293 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9294 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9295 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9296 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9298 /* write multiplier commands */
9299 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9300 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9301 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9302 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9304 /* Init interface related vty commands. */
9305 ospf_vty_if_init ();
9307 /* Init zebra related vty commands. */
9308 ospf_vty_zebra_init ();