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
);
163 vty
->node
= OSPF_NODE
;
166 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
168 /* The following logic to set the vty->index is in place to be able
169 to ignore the commands which dont belong to this instance. */
170 if (ospf
->instance
!= instance
)
174 if (IS_DEBUG_OSPF_EVENT
)
175 zlog_debug ("Config command 'router ospf %d' received", instance
);
176 ospf
->oi_running
= 1;
178 ospf_router_id_update (ospf
);
184 DEFUN (no_router_ospf
,
186 "no router ospf [(1-65535)]",
188 "Enable a routing process\n"
189 "Start OSPF configuration\n"
193 u_short instance
= 0;
196 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
198 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
207 DEFUN (ospf_router_id
,
209 "ospf router-id A.B.C.D",
210 "OSPF specific commands\n"
211 "router-id for the OSPF process\n"
212 "OSPF router-id in IP address format\n")
215 struct ospf
*ospf
= vty
->index
;
216 struct listnode
*node
;
217 struct ospf_area
*area
;
218 struct in_addr router_id
;
224 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
227 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
231 ospf
->router_id_static
= router_id
;
233 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
236 vty_out (vty
, "For this router-id change to take effect,"
237 " save config and restart ospfd%s", VTY_NEWLINE
);
241 ospf_router_id_update (ospf
);
246 DEFUN_HIDDEN (ospf_router_id_old
,
247 ospf_router_id_old_cmd
,
249 "router-id for the OSPF process\n"
250 "OSPF router-id in IP address format\n")
253 struct ospf
*ospf
= vty
->index
;
254 struct listnode
*node
;
255 struct ospf_area
*area
;
256 struct in_addr router_id
;
262 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
265 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
269 ospf
->router_id_static
= router_id
;
271 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
274 vty_out (vty
, "For this router-id change to take effect,"
275 " save config and restart ospfd%s", VTY_NEWLINE
);
279 ospf_router_id_update (ospf
);
284 DEFUN (no_ospf_router_id
,
285 no_ospf_router_id_cmd
,
286 "no ospf router-id [A.B.C.D]",
288 "OSPF specific commands\n"
289 "router-id for the OSPF process\n"
290 "OSPF router-id in IP address format\n")
292 struct ospf
*ospf
= vty
->index
;
293 struct listnode
*node
;
294 struct ospf_area
*area
;
299 ospf
->router_id_static
.s_addr
= 0;
301 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
304 vty_out (vty
, "For this router-id change to take effect,"
305 " save config and restart ospfd%s", VTY_NEWLINE
);
309 ospf_router_id_update (ospf
);
316 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
319 struct interface
*ifp
;
320 struct ospf_interface
*oi
;
322 ospf
->passive_interface_default
= newval
;
324 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
327 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
328 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
330 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
332 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
333 UNSET_IF_PARAM (oi
->params
, passive_interface
);
334 /* update multicast memberships */
335 ospf_if_set_multicast(oi
);
340 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
341 struct ospf_if_params
*params
, u_char value
,
346 params
->passive_interface
= value
;
347 if (params
!= IF_DEF_PARAMS (ifp
))
349 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
350 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
352 dflt
= ospf
->passive_interface_default
;
355 SET_IF_PARAM (params
, passive_interface
);
357 UNSET_IF_PARAM (params
, passive_interface
);
359 ospf_free_if_params (ifp
, addr
);
360 ospf_if_update_params (ifp
, addr
);
365 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
366 struct ospf_if_params
*params
, u_char value
)
368 params
->passive_interface
= value
;
369 if (params
== IF_DEF_PARAMS (ifp
))
371 if (value
!= ospf
->passive_interface_default
)
372 SET_IF_PARAM (params
, passive_interface
);
374 UNSET_IF_PARAM (params
, passive_interface
);
378 DEFUN (ospf_passive_interface
,
379 ospf_passive_interface_addr_cmd
,
380 "passive-interface <IFNAME [A.B.C.D]|default>",
381 "Suppress routing updates on an interface\n"
383 "Suppress routing updates on interfaces by default\n")
386 struct interface
*ifp
;
387 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
389 struct ospf_if_params
*params
;
390 struct route_node
*rn
;
391 struct ospf
*ospf
= vty
->index
;
396 if (strcmp (argv
[1]->text
, "default") == 0)
398 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
402 ifp
= if_get_by_name (argv
[1]->arg
);
404 params
= IF_DEF_PARAMS (ifp
);
408 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
411 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
416 params
= ospf_get_if_params (ifp
, addr
);
417 ospf_if_update_params (ifp
, addr
);
418 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
419 OSPF_IF_PASSIVE
, addr
);
422 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
424 /* XXX We should call ospf_if_set_multicast on exactly those
425 * interfaces for which the passive property changed. It is too much
426 * work to determine this set, so we do this for every interface.
427 * This is safe and reasonable because ospf_if_set_multicast uses a
428 * record of joined groups to avoid systems calls if the desired
429 * memberships match the current memership.
432 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
434 struct ospf_interface
*oi
= rn
->info
;
436 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
437 ospf_if_set_multicast(oi
);
440 * XXX It is not clear what state transitions the interface needs to
441 * undergo when going from active to passive. Fixing this will
442 * require precise identification of interfaces having such a
449 DEFUN (no_ospf_passive_interface
,
450 no_ospf_passive_interface_addr_cmd
,
451 "no passive-interface <IFNAME [A.B.C.D]|default>",
453 "Allow routing updates on an interface\n"
455 "Allow routing updates on interfaces by default\n")
458 struct interface
*ifp
;
459 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
460 struct ospf_if_params
*params
;
462 struct route_node
*rn
;
463 struct ospf
*ospf
= vty
->index
;
468 if (strcmp (argv
[2]->text
, "default") == 0)
470 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
474 ifp
= if_get_by_name (argv
[2]->arg
);
476 params
= IF_DEF_PARAMS (ifp
);
480 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
483 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
488 params
= ospf_lookup_if_params (ifp
, addr
);
491 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
494 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
496 /* XXX We should call ospf_if_set_multicast on exactly those
497 * interfaces for which the passive property changed. It is too much
498 * work to determine this set, so we do this for every interface.
499 * This is safe and reasonable because ospf_if_set_multicast uses a
500 * record of joined groups to avoid systems calls if the desired
501 * memberships match the current memership.
503 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
505 struct ospf_interface
*oi
= rn
->info
;
507 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
508 ospf_if_set_multicast(oi
);
516 DEFUN (ospf_network_area
,
517 ospf_network_area_cmd
,
518 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
519 "Enable routing on an IP network\n"
520 "OSPF network prefix\n"
521 "Set the OSPF area ID\n"
522 "OSPF area ID in IP address format\n"
523 "OSPF area ID as a decimal value\n")
525 int idx_ipv4_prefixlen
= 1;
526 int idx_ipv4_number
= 3;
527 struct ospf
*ospf
= vty
->index
;
528 struct prefix_ipv4 p
;
529 struct in_addr area_id
;
537 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
542 if (ospf
->if_ospf_cli_count
> 0)
544 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
549 /* Get network prefix and Area ID. */
550 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
551 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
553 ret
= ospf_network_set (ospf
, &p
, area_id
);
556 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
563 DEFUN (no_ospf_network_area
,
564 no_ospf_network_area_cmd
,
565 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
567 "Enable routing on an IP network\n"
568 "OSPF network prefix\n"
569 "Set the OSPF area ID\n"
570 "OSPF area ID in IP address format\n"
571 "OSPF area ID as a decimal value\n")
573 int idx_ipv4_prefixlen
= 2;
574 int idx_ipv4_number
= 4;
575 struct ospf
*ospf
= (struct ospf
*) vty
->index
;
576 struct prefix_ipv4 p
;
577 struct in_addr area_id
;
585 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
590 /* Get network prefix and Area ID. */
591 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
592 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
594 ret
= ospf_network_unset (ospf
, &p
, area_id
);
597 vty_out (vty
, "Can't find specified network area configuration.%s",
605 DEFUN (ospf_area_range
,
607 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
608 "OSPF area parameters\n"
609 "OSPF area ID in IP address format\n"
610 "OSPF area ID as a decimal value\n"
611 "Summarize routes matching address/mask (border routers only)\n"
612 "Area range prefix\n"
613 "Advertise this range (default)\n"
614 "User specified metric for this range\n"
615 "Advertised metric for this range\n")
617 int idx_ipv4_number
= 1;
618 int idx_ipv4_prefixlen
= 3;
620 struct ospf
*ospf
= vty
->index
;
621 struct prefix_ipv4 p
;
622 struct in_addr area_id
;
629 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
630 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
632 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
635 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
636 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
642 DEFUN (ospf_area_range_cost
,
643 ospf_area_range_cost_cmd
,
644 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
645 "OSPF area parameters\n"
646 "OSPF area ID in IP address format\n"
647 "OSPF area ID as a decimal value\n"
648 "Summarize routes matching address/mask (border routers only)\n"
649 "Area range prefix\n"
650 "User specified metric for this range\n"
651 "Advertised metric for this range\n")
653 int idx_ipv4_number
= 1;
654 int idx_ipv4_prefixlen
= 3;
656 struct ospf
*ospf
= vty
->index
;
657 struct prefix_ipv4 p
;
658 struct in_addr area_id
;
665 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
666 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
668 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
670 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
671 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
676 DEFUN (ospf_area_range_not_advertise
,
677 ospf_area_range_not_advertise_cmd
,
678 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
679 "OSPF area parameters\n"
680 "OSPF area ID in IP address format\n"
681 "OSPF area ID as a decimal value\n"
682 "Summarize routes matching address/mask (border routers only)\n"
683 "Area range prefix\n"
684 "DoNotAdvertise this range\n")
686 int idx_ipv4_number
= 1;
687 int idx_ipv4_prefixlen
= 3;
688 struct ospf
*ospf
= vty
->index
;
689 struct prefix_ipv4 p
;
690 struct in_addr area_id
;
696 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
697 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
699 ospf_area_range_set (ospf
, area_id
, &p
, 0);
704 DEFUN (no_ospf_area_range
,
705 no_ospf_area_range_cmd
,
706 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)] | not-advertise>]",
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 "Advertise this range (default)\n"
714 "DoNotAdvertise this range\n")
716 int idx_ipv4_number
= 2;
717 int idx_ipv4_prefixlen
= 4;
718 struct ospf
*ospf
= vty
->index
;
719 struct prefix_ipv4 p
;
720 struct in_addr area_id
;
726 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
727 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
729 ospf_area_range_unset (ospf
, area_id
, &p
);
734 DEFUN (ospf_area_range_substitute
,
735 ospf_area_range_substitute_cmd
,
736 "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 int idx_ipv4_number
= 1;
746 int idx_ipv4_prefixlen
= 3;
747 int idx_ipv4_prefixlen_2
= 5;
748 struct ospf
*ospf
= vty
->index
;
749 struct prefix_ipv4 p
, s
;
750 struct in_addr area_id
;
756 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
757 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
758 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
760 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
765 DEFUN (no_ospf_area_range_substitute
,
766 no_ospf_area_range_substitute_cmd
,
767 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
769 "OSPF area parameters\n"
770 "OSPF area ID in IP address format\n"
771 "OSPF area ID as a decimal value\n"
772 "Summarize routes matching address/mask (border routers only)\n"
773 "Area range prefix\n"
774 "Announce area range as another prefix\n"
775 "Network prefix to be announced instead of range\n")
777 int idx_ipv4_number
= 2;
778 int idx_ipv4_prefixlen
= 4;
779 int idx_ipv4_prefixlen_2
= 6;
780 struct ospf
*ospf
= vty
->index
;
781 struct prefix_ipv4 p
, s
;
782 struct in_addr area_id
;
788 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
789 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
790 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
792 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
798 /* Command Handler Logic in VLink stuff is delicate!!
800 ALTER AT YOUR OWN RISK!!!!
802 Various dummy values are used to represent 'NoChange' state for
803 VLink configuration NOT being changed by a VLink command, and
804 special syntax is used within the command strings so that the
805 typed in command verbs can be seen in the configuration command
806 bacckend handler. This is to drastically reduce the verbeage
807 required to coe up with a reasonably compatible Cisco VLink command
809 - Matthew Grant <grantma@anathoth.gen.nz>
810 Wed, 21 Feb 2001 15:13:52 +1300
813 /* Configuration data for virtual links
815 struct ospf_vl_config_data
{
816 struct vty
*vty
; /* vty stuff */
817 struct in_addr area_id
; /* area ID from command line */
818 int format
; /* command line area ID format */
819 struct in_addr vl_peer
; /* command line vl_peer */
820 int auth_type
; /* Authehntication type, if given */
821 char *auth_key
; /* simple password if present */
822 int crypto_key_id
; /* Cryptographic key ID */
823 char *md5_key
; /* MD5 authentication key */
824 int hello_interval
; /* Obvious what these are... */
825 int retransmit_interval
;
831 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
834 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
835 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
836 vl_config
->vty
= vty
;
839 static struct ospf_vl_data
*
840 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
842 struct ospf_area
*area
;
843 struct ospf_vl_data
*vl_data
;
845 struct in_addr area_id
;
847 vty
= vl_config
->vty
;
848 area_id
= vl_config
->area_id
;
850 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
853 "Configuring VLs over the backbone is not allowed%s",
857 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
859 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
861 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
862 vty_out (vty
, "Area %s is %s%s",
864 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
867 vty_out (vty
, "Area %ld is %s%s",
868 (u_long
)ntohl (area_id
.s_addr
),
869 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
874 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
876 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
877 if (vl_data
->vl_oi
== NULL
)
879 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
880 ospf_vl_add (ospf
, vl_data
);
881 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
889 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
890 struct ospf_vl_config_data
*vl_config
)
892 struct crypt_key
*ck
;
894 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
896 vty
= vl_config
->vty
;
898 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
900 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
901 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
904 if (vl_config
->auth_key
)
906 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
907 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
908 OSPF_AUTH_SIMPLE_SIZE
);
910 else if (vl_config
->md5_key
)
912 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
915 vty_out (vty
, "OSPF: Key %d already exists%s",
916 vl_config
->crypto_key_id
, VTY_NEWLINE
);
919 ck
= ospf_crypt_key_new ();
920 ck
->key_id
= vl_config
->crypto_key_id
;
921 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
922 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
924 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
926 else if (vl_config
->crypto_key_id
!= 0)
930 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
931 vl_config
->crypto_key_id
) == NULL
)
933 vty_out (vty
, "OSPF: Key %d does not exist%s",
934 vl_config
->crypto_key_id
, VTY_NEWLINE
);
938 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
946 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
947 struct ospf_vl_config_data
*vl_config
)
949 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
950 /* Virtual Link data initialised to defaults, so only set
952 if (vl_config
->hello_interval
)
954 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
955 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
958 if (vl_config
->dead_interval
)
960 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
961 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
964 if (vl_config
->retransmit_interval
)
966 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
967 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
970 if (vl_config
->transmit_delay
)
972 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
973 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
980 /* The business end of all of the above */
982 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
984 struct ospf_vl_data
*vl_data
;
987 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
991 /* Process this one first as it can have a fatal result, which can
992 only logically occur if the virtual link exists already
993 Thus a command error does not result in a change to the
994 running configuration such as unexpectedly altered timer
996 ret
= ospf_vl_set_security (vl_data
, vl_config
);
997 if (ret
!= CMD_SUCCESS
)
1000 /* Set any time based parameters, these area already range checked */
1002 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
1003 if (ret
!= CMD_SUCCESS
)
1010 /* This stuff exists to make specifying all the alias commands A LOT simpler
1012 #define VLINK_HELPSTR_IPADDR \
1013 "OSPF area parameters\n" \
1014 "OSPF area ID in IP address format\n" \
1015 "OSPF area ID as a decimal value\n" \
1016 "Configure a virtual link\n" \
1017 "Router ID of the remote ABR\n"
1019 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1020 "Enable authentication on this virtual link\n" \
1023 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1024 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1025 "Use null authentication\n" \
1026 "Use message-digest authentication\n"
1028 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
1029 "Time between HELLO packets\n" \
1030 "Time between retransmitting lost link state advertisements\n" \
1031 "Link state transmit delay\n" \
1032 "Interval time after which a neighbor is declared down\n"
1034 #define VLINK_HELPSTR_TIME_PARAM \
1035 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1038 #define VLINK_HELPSTR_AUTH_SIMPLE \
1039 "Authentication password (key)\n" \
1040 "The OSPF password (key)"
1042 #define VLINK_HELPSTR_AUTH_MD5 \
1043 "Message digest authentication password (key)\n" \
1046 "Use MD5 algorithm\n" \
1047 "The OSPF password (key)"
1049 DEFUN (ospf_area_vlink
,
1050 ospf_area_vlink_cmd
,
1051 "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>]",
1052 VLINK_HELPSTR_IPADDR
1053 "Enable authentication on this virtual link\n" \
1054 "Use null authentication\n" \
1055 "Use message-digest authentication\n"
1056 "Message digest authentication password (key)\n" \
1058 "Use MD5 algorithm\n" \
1059 "The OSPF password (key)")
1061 int idx_ipv4_number
= 1;
1063 struct ospf
*ospf
= vty
->index
;
1064 struct ospf_vl_config_data vl_config
;
1065 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1066 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1073 ospf_vl_config_data_init(&vl_config
, vty
);
1075 /* Read off first 2 parameters and check them */
1076 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &vl_config
.format
);
1079 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1083 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1086 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1093 /* Thats all folks! - BUGS B. strikes again!!!*/
1095 return ospf_vl_set (ospf
, &vl_config
);
1098 /* Deal with other parameters */
1099 for (i
=5; i
< argc
; i
++)
1102 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1104 switch (argv
[i
]->arg
[0])
1108 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1110 /* authentication-key - this option can occur anywhere on
1111 command line. At start of command line
1112 must check for authentication option. */
1113 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1114 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1115 vl_config
.auth_key
= auth_key
;
1118 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1120 /* authentication - this option can only occur at start
1122 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1125 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1127 /* "authentication null" */
1128 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1131 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1132 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1134 /* "authentication message-digest" */
1135 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1143 /* message-digest-key */
1145 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1146 if (vl_config
.crypto_key_id
< 0)
1149 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1150 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1151 vl_config
.md5_key
= md5_key
;
1158 /* Action configuration */
1160 return ospf_vl_set (ospf
, &vl_config
);
1164 DEFUN (ospf_area_vlink_intervals
,
1165 ospf_area_vlink_intervals_cmd
,
1166 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1167 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1168 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1169 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1170 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1172 VLINK_HELPSTR_IPADDR
1173 VLINK_HELPSTR_TIME_PARAM
1174 VLINK_HELPSTR_TIME_PARAM
1175 VLINK_HELPSTR_TIME_PARAM
1176 VLINK_HELPSTR_TIME_PARAM
)
1178 struct ospf
*ospf
= vty
->index
;
1179 struct ospf_vl_config_data vl_config
;
1185 ospf_vl_config_data_init(&vl_config
, vty
);
1187 char *area_id
= argv
[1]->arg
;
1188 char *router_id
= argv
[3]->arg
;
1190 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1193 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1197 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1200 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1203 for (unsigned int i
= 0; i
< 4; i
++)
1206 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1207 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1208 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1209 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1210 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1211 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1212 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1213 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1216 /* Action configuration */
1217 return ospf_vl_set (ospf
, &vl_config
);
1220 DEFUN (no_ospf_area_vlink
,
1221 no_ospf_area_vlink_cmd
,
1222 "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>]",
1224 VLINK_HELPSTR_IPADDR
1225 "Enable authentication on this virtual link\n" \
1226 "Use null authentication\n" \
1227 "Use message-digest authentication\n"
1228 "Message digest authentication password (key)\n" \
1230 "Use MD5 algorithm\n" \
1231 "The OSPF password (key)")
1233 int idx_ipv4_number
= 2;
1235 struct ospf
*ospf
= vty
->index
;
1236 struct ospf_area
*area
;
1237 struct ospf_vl_config_data vl_config
;
1238 struct ospf_vl_data
*vl_data
= NULL
;
1239 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1246 ospf_vl_config_data_init(&vl_config
, vty
);
1248 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1251 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1255 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1258 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1262 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1265 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1272 /* Basic VLink no command */
1273 /* Thats all folks! - BUGS B. strikes again!!!*/
1274 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1275 ospf_vl_delete (ospf
, vl_data
);
1277 ospf_area_check_free (ospf
, vl_config
.area_id
);
1282 /* If we are down here, we are reseting parameters */
1284 /* Deal with other parameters */
1285 for (i
=6; argc
; i
++)
1287 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1289 switch (argv
[i
]->arg
[0])
1293 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1295 /* authentication-key - this option can occur anywhere on
1296 command line. At start of command line
1297 must check for authentication option. */
1298 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1299 vl_config
.auth_key
= auth_key
;
1301 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1303 /* authentication - this option can only occur at start
1305 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1310 /* message-digest-key */
1311 /* Delete one key */
1313 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1314 if (vl_config
.crypto_key_id
< 0)
1316 vl_config
.md5_key
= NULL
;
1323 /* Action configuration */
1325 return ospf_vl_set (ospf
, &vl_config
);
1328 DEFUN (no_ospf_area_vlink_intervals
,
1329 no_ospf_area_vlink_intervals_cmd
,
1330 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1331 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1332 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1333 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1334 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1336 VLINK_HELPSTR_IPADDR
1337 VLINK_HELPSTR_TIME_PARAM
1338 VLINK_HELPSTR_TIME_PARAM
1339 VLINK_HELPSTR_TIME_PARAM
1340 VLINK_HELPSTR_TIME_PARAM
)
1342 struct ospf
*ospf
= vty
->index
;
1343 struct ospf_vl_config_data vl_config
;
1349 ospf_vl_config_data_init(&vl_config
, vty
);
1351 char *area_id
= argv
[2]->arg
;
1352 char *router_id
= argv
[4]->arg
;
1354 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1357 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1361 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1364 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1368 for (unsigned int i
= 0; i
< 4; i
++)
1371 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1372 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1373 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1374 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1375 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1376 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1377 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1378 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1381 /* Action configuration */
1382 return ospf_vl_set (ospf
, &vl_config
);
1385 DEFUN (ospf_area_shortcut
,
1386 ospf_area_shortcut_cmd
,
1387 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1388 "OSPF area parameters\n"
1389 "OSPF area ID in IP address format\n"
1390 "OSPF area ID as a decimal value\n"
1391 "Configure the area's shortcutting mode\n"
1392 "Set default shortcutting behavior\n"
1393 "Enable shortcutting through the area\n"
1394 "Disable shortcutting through the area\n")
1396 int idx_ipv4_number
= 1;
1397 int idx_enable_disable
= 3;
1398 struct ospf
*ospf
= vty
->index
;
1399 struct ospf_area
*area
;
1400 struct in_addr area_id
;
1407 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1409 area
= ospf_area_get (ospf
, area_id
, format
);
1411 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1412 mode
= OSPF_SHORTCUT_DEFAULT
;
1413 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1414 mode
= OSPF_SHORTCUT_DISABLE
;
1415 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1416 mode
= OSPF_SHORTCUT_ENABLE
;
1420 ospf_area_shortcut_set (ospf
, area
, mode
);
1422 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1423 vty_out (vty
, "Shortcut area setting will take effect "
1424 "only when the router is configured as Shortcut ABR%s",
1430 DEFUN (no_ospf_area_shortcut
,
1431 no_ospf_area_shortcut_cmd
,
1432 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1434 "OSPF area parameters\n"
1435 "OSPF area ID in IP address format\n"
1436 "OSPF area ID as a decimal value\n"
1437 "Deconfigure the area's shortcutting mode\n"
1438 "Deconfigure enabled shortcutting through the area\n"
1439 "Deconfigure disabled shortcutting through the area\n")
1441 int idx_ipv4_number
= 2;
1442 struct ospf
*ospf
= vty
->index
;
1443 struct ospf_area
*area
;
1444 struct in_addr area_id
;
1450 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1452 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1456 ospf_area_shortcut_unset (ospf
, area
);
1462 DEFUN (ospf_area_stub
,
1464 "area <A.B.C.D|(0-4294967295)> stub",
1465 "OSPF area parameters\n"
1466 "OSPF area ID in IP address format\n"
1467 "OSPF area ID as a decimal value\n"
1468 "Configure OSPF area as stub\n")
1470 int idx_ipv4_number
= 1;
1471 struct ospf
*ospf
= vty
->index
;
1472 struct in_addr area_id
;
1478 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1480 ret
= ospf_area_stub_set (ospf
, area_id
);
1483 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1488 ospf_area_no_summary_unset (ospf
, area_id
);
1493 DEFUN (ospf_area_stub_no_summary
,
1494 ospf_area_stub_no_summary_cmd
,
1495 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1496 "OSPF stub parameters\n"
1497 "OSPF area ID in IP address format\n"
1498 "OSPF area ID as a decimal value\n"
1499 "Configure OSPF area as stub\n"
1500 "Do not inject inter-area routes into stub\n")
1502 int idx_ipv4_number
= 1;
1503 struct ospf
*ospf
= vty
->index
;
1504 struct in_addr area_id
;
1510 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1512 ret
= ospf_area_stub_set (ospf
, area_id
);
1515 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1520 ospf_area_no_summary_set (ospf
, area_id
);
1525 DEFUN (no_ospf_area_stub
,
1526 no_ospf_area_stub_cmd
,
1527 "no area <A.B.C.D|(0-4294967295)> stub",
1529 "OSPF area parameters\n"
1530 "OSPF area ID in IP address format\n"
1531 "OSPF area ID as a decimal value\n"
1532 "Configure OSPF area as stub\n")
1534 int idx_ipv4_number
= 2;
1535 struct ospf
*ospf
= vty
->index
;
1536 struct in_addr area_id
;
1542 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1544 ospf_area_stub_unset (ospf
, area_id
);
1545 ospf_area_no_summary_unset (ospf
, area_id
);
1550 DEFUN (no_ospf_area_stub_no_summary
,
1551 no_ospf_area_stub_no_summary_cmd
,
1552 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1554 "OSPF area parameters\n"
1555 "OSPF area ID in IP address format\n"
1556 "OSPF area ID as a decimal value\n"
1557 "Configure OSPF area as stub\n"
1558 "Do not inject inter-area routes into area\n")
1560 int idx_ipv4_number
= 2;
1561 struct ospf
*ospf
= vty
->index
;
1562 struct in_addr area_id
;
1568 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1569 ospf_area_no_summary_unset (ospf
, area_id
);
1575 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1578 struct ospf
*ospf
= vty
->index
;
1579 struct in_addr area_id
;
1585 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1587 ret
= ospf_area_nssa_set (ospf
, area_id
);
1590 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1597 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1598 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1599 OSPF_NSSA_ROLE_CANDIDATE
);
1600 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1601 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1602 OSPF_NSSA_ROLE_NEVER
);
1603 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1604 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1605 OSPF_NSSA_ROLE_ALWAYS
);
1609 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1610 OSPF_NSSA_ROLE_CANDIDATE
);
1614 ospf_area_no_summary_set (ospf
, area_id
);
1616 ospf_area_no_summary_unset (ospf
, area_id
);
1618 ospf_schedule_abr_task (ospf
);
1623 DEFUN (ospf_area_nssa_translate_no_summary
,
1624 ospf_area_nssa_translate_no_summary_cmd
,
1625 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1626 "OSPF area parameters\n"
1627 "OSPF area ID in IP address format\n"
1628 "OSPF area ID as a decimal value\n"
1629 "Configure OSPF area as nssa\n"
1630 "Configure NSSA-ABR for translate election (default)\n"
1631 "Configure NSSA-ABR to never translate\n"
1632 "Configure NSSA-ABR to always translate\n"
1633 "Do not inject inter-area routes into nssa\n")
1635 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1638 DEFUN (ospf_area_nssa_translate
,
1639 ospf_area_nssa_translate_cmd
,
1640 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1641 "OSPF area parameters\n"
1642 "OSPF area ID in IP address format\n"
1643 "OSPF area ID as a decimal value\n"
1644 "Configure OSPF area as nssa\n"
1645 "Configure NSSA-ABR for translate election (default)\n"
1646 "Configure NSSA-ABR to never translate\n"
1647 "Configure NSSA-ABR to always translate\n")
1649 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1652 DEFUN (ospf_area_nssa
,
1654 "area <A.B.C.D|(0-4294967295)> nssa",
1655 "OSPF area parameters\n"
1656 "OSPF area ID in IP address format\n"
1657 "OSPF area ID as a decimal value\n"
1658 "Configure OSPF area as nssa\n")
1660 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1663 DEFUN (ospf_area_nssa_no_summary
,
1664 ospf_area_nssa_no_summary_cmd
,
1665 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1666 "OSPF area parameters\n"
1667 "OSPF area ID in IP address format\n"
1668 "OSPF area ID as a decimal value\n"
1669 "Configure OSPF area as nssa\n"
1670 "Do not inject inter-area routes into nssa\n")
1672 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1675 DEFUN (no_ospf_area_nssa
,
1676 no_ospf_area_nssa_cmd
,
1677 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1679 "OSPF area parameters\n"
1680 "OSPF area ID in IP address format\n"
1681 "OSPF area ID as a decimal value\n"
1682 "Configure OSPF area as nssa\n"
1683 "Configure NSSA-ABR for translate election (default)\n"
1684 "Configure NSSA-ABR to never translate\n"
1685 "Configure NSSA-ABR to always translate\n"
1686 "Do not inject inter-area routes into nssa\n")
1688 int idx_ipv4_number
= 2;
1689 struct ospf
*ospf
= vty
->index
;
1690 struct in_addr area_id
;
1696 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1698 ospf_area_nssa_unset (ospf
, area_id
);
1699 ospf_area_no_summary_unset (ospf
, area_id
);
1701 ospf_schedule_abr_task (ospf
);
1707 DEFUN (ospf_area_default_cost
,
1708 ospf_area_default_cost_cmd
,
1709 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1710 "OSPF area parameters\n"
1711 "OSPF area ID in IP address format\n"
1712 "OSPF area ID as a decimal value\n"
1713 "Set the summary-default cost of a NSSA or stub area\n"
1714 "Stub's advertised default summary cost\n")
1716 int idx_ipv4_number
= 1;
1718 struct ospf
*ospf
= vty
->index
;
1719 struct ospf_area
*area
;
1720 struct in_addr area_id
;
1723 struct prefix_ipv4 p
;
1728 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1729 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1731 area
= ospf_area_get (ospf
, area_id
, format
);
1733 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1735 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1739 area
->default_cost
= cost
;
1742 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1744 if (IS_DEBUG_OSPF_EVENT
)
1745 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1746 "announcing 0.0.0.0/0 to area %s",
1747 inet_ntoa (area
->area_id
));
1748 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1753 DEFUN (no_ospf_area_default_cost
,
1754 no_ospf_area_default_cost_cmd
,
1755 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1757 "OSPF area parameters\n"
1758 "OSPF area ID in IP address format\n"
1759 "OSPF area ID as a decimal value\n"
1760 "Set the summary-default cost of a NSSA or stub area\n"
1761 "Stub's advertised default summary cost\n")
1763 int idx_ipv4_number
= 2;
1765 struct ospf
*ospf
= vty
->index
;
1766 struct ospf_area
*area
;
1767 struct in_addr area_id
;
1769 struct prefix_ipv4 p
;
1774 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1775 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1777 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1781 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1783 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1787 area
->default_cost
= 1;
1790 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1792 if (IS_DEBUG_OSPF_EVENT
)
1793 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1794 "announcing 0.0.0.0/0 to area %s",
1795 inet_ntoa (area
->area_id
));
1796 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1799 ospf_area_check_free (ospf
, area_id
);
1804 DEFUN (ospf_area_export_list
,
1805 ospf_area_export_list_cmd
,
1806 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1807 "OSPF area parameters\n"
1808 "OSPF area ID in IP address format\n"
1809 "OSPF area ID as a decimal value\n"
1810 "Set the filter for networks announced to other areas\n"
1811 "Name of the access-list\n")
1813 int idx_ipv4_number
= 1;
1814 struct ospf
*ospf
= vty
->index
;
1815 struct ospf_area
*area
;
1816 struct in_addr area_id
;
1822 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1824 area
= ospf_area_get (ospf
, area_id
, format
);
1825 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1830 DEFUN (no_ospf_area_export_list
,
1831 no_ospf_area_export_list_cmd
,
1832 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1834 "OSPF area parameters\n"
1835 "OSPF area ID in IP address format\n"
1836 "OSPF area ID as a decimal value\n"
1837 "Unset the filter for networks announced to other areas\n"
1838 "Name of the access-list\n")
1840 int idx_ipv4_number
= 2;
1841 struct ospf
*ospf
= vty
->index
;
1842 struct ospf_area
*area
;
1843 struct in_addr area_id
;
1849 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1851 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1855 ospf_area_export_list_unset (ospf
, area
);
1861 DEFUN (ospf_area_import_list
,
1862 ospf_area_import_list_cmd
,
1863 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1864 "OSPF area parameters\n"
1865 "OSPF area ID in IP address format\n"
1866 "OSPF area ID as a decimal value\n"
1867 "Set the filter for networks from other areas announced to the specified one\n"
1868 "Name of the access-list\n")
1870 int idx_ipv4_number
= 1;
1871 struct ospf
*ospf
= vty
->index
;
1872 struct ospf_area
*area
;
1873 struct in_addr area_id
;
1879 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1881 area
= ospf_area_get (ospf
, area_id
, format
);
1882 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1887 DEFUN (no_ospf_area_import_list
,
1888 no_ospf_area_import_list_cmd
,
1889 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1891 "OSPF area parameters\n"
1892 "OSPF area ID in IP address format\n"
1893 "OSPF area ID as a decimal value\n"
1894 "Unset the filter for networks announced to other areas\n"
1895 "Name of the access-list\n")
1897 int idx_ipv4_number
= 2;
1898 struct ospf
*ospf
= vty
->index
;
1899 struct ospf_area
*area
;
1900 struct in_addr area_id
;
1906 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1908 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1912 ospf_area_import_list_unset (ospf
, area
);
1917 DEFUN (ospf_area_filter_list
,
1918 ospf_area_filter_list_cmd
,
1919 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1920 "OSPF area parameters\n"
1921 "OSPF area ID in IP address format\n"
1922 "OSPF area ID as a decimal value\n"
1923 "Filter networks between OSPF areas\n"
1924 "Filter prefixes between OSPF areas\n"
1925 "Name of an IP prefix-list\n"
1926 "Filter networks sent to this area\n"
1927 "Filter networks sent from this area\n")
1929 int idx_ipv4_number
= 1;
1932 struct ospf
*ospf
= vty
->index
;
1933 struct ospf_area
*area
;
1934 struct in_addr area_id
;
1935 struct prefix_list
*plist
;
1941 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1943 area
= ospf_area_get (ospf
, area_id
, format
);
1944 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1945 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1947 PREFIX_LIST_IN (area
) = plist
;
1948 if (PREFIX_NAME_IN (area
))
1949 free (PREFIX_NAME_IN (area
));
1951 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1952 ospf_schedule_abr_task (ospf
);
1956 PREFIX_LIST_OUT (area
) = plist
;
1957 if (PREFIX_NAME_OUT (area
))
1958 free (PREFIX_NAME_OUT (area
));
1960 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1961 ospf_schedule_abr_task (ospf
);
1967 DEFUN (no_ospf_area_filter_list
,
1968 no_ospf_area_filter_list_cmd
,
1969 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1971 "OSPF area parameters\n"
1972 "OSPF area ID in IP address format\n"
1973 "OSPF area ID as a decimal value\n"
1974 "Filter networks between OSPF areas\n"
1975 "Filter prefixes between OSPF areas\n"
1976 "Name of an IP prefix-list\n"
1977 "Filter networks sent to this area\n"
1978 "Filter networks sent from this area\n")
1980 int idx_ipv4_number
= 2;
1983 struct ospf
*ospf
= vty
->index
;
1984 struct ospf_area
*area
;
1985 struct in_addr area_id
;
1991 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1993 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1996 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1998 if (PREFIX_NAME_IN (area
))
1999 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
2002 PREFIX_LIST_IN (area
) = NULL
;
2003 if (PREFIX_NAME_IN (area
))
2004 free (PREFIX_NAME_IN (area
));
2006 PREFIX_NAME_IN (area
) = NULL
;
2008 ospf_schedule_abr_task (ospf
);
2012 if (PREFIX_NAME_OUT (area
))
2013 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
2016 PREFIX_LIST_OUT (area
) = NULL
;
2017 if (PREFIX_NAME_OUT (area
))
2018 free (PREFIX_NAME_OUT (area
));
2020 PREFIX_NAME_OUT (area
) = NULL
;
2022 ospf_schedule_abr_task (ospf
);
2029 DEFUN (ospf_area_authentication_message_digest
,
2030 ospf_area_authentication_message_digest_cmd
,
2031 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
2032 "OSPF area parameters\n"
2033 "OSPF area ID in IP address format\n"
2034 "OSPF area ID as a decimal value\n"
2035 "Enable authentication\n"
2036 "Use message-digest authentication\n")
2038 int idx_ipv4_number
= 1;
2039 struct ospf
*ospf
= vty
->index
;
2040 struct ospf_area
*area
;
2041 struct in_addr area_id
;
2047 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2049 area
= ospf_area_get (ospf
, area_id
, format
);
2050 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
2055 DEFUN (ospf_area_authentication
,
2056 ospf_area_authentication_cmd
,
2057 "area <A.B.C.D|(0-4294967295)> authentication",
2058 "OSPF area parameters\n"
2059 "OSPF area ID in IP address format\n"
2060 "OSPF area ID as a decimal value\n"
2061 "Enable authentication\n")
2063 int idx_ipv4_number
= 1;
2064 struct ospf
*ospf
= vty
->index
;
2065 struct ospf_area
*area
;
2066 struct in_addr area_id
;
2072 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2074 area
= ospf_area_get (ospf
, area_id
, format
);
2075 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2080 DEFUN (no_ospf_area_authentication
,
2081 no_ospf_area_authentication_cmd
,
2082 "no area <A.B.C.D|(0-4294967295)> authentication",
2084 "OSPF area parameters\n"
2085 "OSPF area ID in IP address format\n"
2086 "OSPF area ID as a decimal value\n"
2087 "Enable authentication\n")
2089 int idx_ipv4_number
= 2;
2090 struct ospf
*ospf
= vty
->index
;
2091 struct ospf_area
*area
;
2092 struct in_addr area_id
;
2098 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2100 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2104 area
->auth_type
= OSPF_AUTH_NULL
;
2106 ospf_area_check_free (ospf
, area_id
);
2112 DEFUN (ospf_abr_type
,
2114 "ospf abr-type <cisco|ibm|shortcut|standard>",
2115 "OSPF specific commands\n"
2116 "Set OSPF ABR type\n"
2117 "Alternative ABR, cisco implementation\n"
2118 "Alternative ABR, IBM implementation\n"
2120 "Standard behavior (RFC2328)\n")
2123 struct ospf
*ospf
= vty
->index
;
2124 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2129 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2130 abr_type
= OSPF_ABR_CISCO
;
2131 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2132 abr_type
= OSPF_ABR_IBM
;
2133 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2134 abr_type
= OSPF_ABR_SHORTCUT
;
2135 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2136 abr_type
= OSPF_ABR_STAND
;
2140 /* If ABR type value is changed, schedule ABR task. */
2141 if (ospf
->abr_type
!= abr_type
)
2143 ospf
->abr_type
= abr_type
;
2144 ospf_schedule_abr_task (ospf
);
2150 DEFUN (no_ospf_abr_type
,
2151 no_ospf_abr_type_cmd
,
2152 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2154 "OSPF specific commands\n"
2155 "Set OSPF ABR type\n"
2156 "Alternative ABR, cisco implementation\n"
2157 "Alternative ABR, IBM implementation\n"
2161 struct ospf
*ospf
= vty
->index
;
2162 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2167 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2168 abr_type
= OSPF_ABR_CISCO
;
2169 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2170 abr_type
= OSPF_ABR_IBM
;
2171 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2172 abr_type
= OSPF_ABR_SHORTCUT
;
2173 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2174 abr_type
= OSPF_ABR_STAND
;
2178 /* If ABR type value is changed, schedule ABR task. */
2179 if (ospf
->abr_type
== abr_type
)
2181 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2182 ospf_schedule_abr_task (ospf
);
2188 DEFUN (ospf_log_adjacency_changes
,
2189 ospf_log_adjacency_changes_cmd
,
2190 "log-adjacency-changes",
2191 "Log changes in adjacency state\n")
2193 struct ospf
*ospf
= vty
->index
;
2198 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2199 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2203 DEFUN (ospf_log_adjacency_changes_detail
,
2204 ospf_log_adjacency_changes_detail_cmd
,
2205 "log-adjacency-changes detail",
2206 "Log changes in adjacency state\n"
2207 "Log all state changes\n")
2209 struct ospf
*ospf
= vty
->index
;
2214 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2215 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2219 DEFUN (no_ospf_log_adjacency_changes
,
2220 no_ospf_log_adjacency_changes_cmd
,
2221 "no log-adjacency-changes",
2223 "Log changes in adjacency state\n")
2225 struct ospf
*ospf
= vty
->index
;
2230 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2231 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2235 DEFUN (no_ospf_log_adjacency_changes_detail
,
2236 no_ospf_log_adjacency_changes_detail_cmd
,
2237 "no log-adjacency-changes detail",
2239 "Log changes in adjacency state\n"
2240 "Log all state changes\n")
2242 struct ospf
*ospf
= vty
->index
;
2247 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2248 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2252 DEFUN (ospf_compatible_rfc1583
,
2253 ospf_compatible_rfc1583_cmd
,
2254 "compatible rfc1583",
2255 "OSPF compatibility list\n"
2256 "compatible with RFC 1583\n")
2258 struct ospf
*ospf
= vty
->index
;
2263 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2265 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2266 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2271 DEFUN (no_ospf_compatible_rfc1583
,
2272 no_ospf_compatible_rfc1583_cmd
,
2273 "no compatible rfc1583",
2275 "OSPF compatibility list\n"
2276 "compatible with RFC 1583\n")
2278 struct ospf
*ospf
= vty
->index
;
2283 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2285 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2286 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2291 ALIAS (ospf_compatible_rfc1583
,
2292 ospf_rfc1583_flag_cmd
,
2293 "ospf rfc1583compatibility",
2294 "OSPF specific commands\n"
2295 "Enable the RFC1583Compatibility flag\n")
2297 ALIAS (no_ospf_compatible_rfc1583
,
2298 no_ospf_rfc1583_flag_cmd
,
2299 "no ospf rfc1583compatibility",
2301 "OSPF specific commands\n"
2302 "Disable the RFC1583Compatibility flag\n")
2305 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2309 struct ospf
*ospf
= vty
->index
;
2314 ospf
->spf_delay
= delay
;
2315 ospf
->spf_holdtime
= hold
;
2316 ospf
->spf_max_holdtime
= max
;
2321 DEFUN (ospf_timers_min_ls_interval
,
2322 ospf_timers_min_ls_interval_cmd
,
2323 "timers throttle lsa all (0-5000)",
2324 "Adjust routing timers\n"
2325 "Throttling adaptive timer\n"
2326 "LSA delay between transmissions\n"
2328 "Delay (msec) between sending LSAs\n")
2331 struct ospf
*ospf
= vty
->index
;
2332 unsigned int interval
;
2339 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2343 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2345 ospf
->min_ls_interval
= interval
;
2350 DEFUN (no_ospf_timers_min_ls_interval
,
2351 no_ospf_timers_min_ls_interval_cmd
,
2352 "no timers throttle lsa all [(0-5000)]",
2354 "Adjust routing timers\n"
2355 "Throttling adaptive timer\n"
2356 "LSA delay between transmissions\n"
2358 "Delay (msec) between sending LSAs\n")
2360 struct ospf
*ospf
= vty
->index
;
2361 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2367 DEFUN (ospf_timers_min_ls_arrival
,
2368 ospf_timers_min_ls_arrival_cmd
,
2369 "timers lsa arrival (0-1000)",
2370 "Adjust routing timers\n"
2371 "Throttling link state advertisement delays\n"
2372 "OSPF minimum arrival interval delay\n"
2373 "Delay (msec) between accepted LSAs\n")
2376 struct ospf
*ospf
= vty
->index
;
2377 unsigned int arrival
;
2384 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2388 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2390 ospf
->min_ls_arrival
= arrival
;
2395 DEFUN (no_ospf_timers_min_ls_arrival
,
2396 no_ospf_timers_min_ls_arrival_cmd
,
2397 "no timers lsa arrival [(0-1000)]",
2399 "Adjust routing timers\n"
2400 "Throttling link state advertisement delays\n"
2401 "OSPF minimum arrival interval delay\n"
2402 "Delay (msec) between accepted LSAs\n")
2404 struct ospf
*ospf
= vty
->index
;
2409 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2415 DEFUN (ospf_timers_throttle_spf
,
2416 ospf_timers_throttle_spf_cmd
,
2417 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2418 "Adjust routing timers\n"
2419 "Throttling adaptive timer\n"
2421 "Delay (msec) from first change received till SPF calculation\n"
2422 "Initial hold time (msec) between consecutive SPF calculations\n"
2423 "Maximum hold time (msec)\n")
2426 int idx_number_2
= 4;
2427 int idx_number_3
= 5;
2428 unsigned int delay
, hold
, max
;
2432 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2436 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2437 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2438 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2440 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2443 DEFUN (no_ospf_timers_throttle_spf
,
2444 no_ospf_timers_throttle_spf_cmd
,
2445 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2447 "Adjust routing timers\n"
2448 "Throttling adaptive timer\n"
2450 "Delay (msec) from first change received till SPF calculation\n"
2451 "Initial hold time (msec) between consecutive SPF calculations\n"
2452 "Maximum hold time (msec)\n")
2454 return ospf_timers_spf_set (vty
,
2455 OSPF_SPF_DELAY_DEFAULT
,
2456 OSPF_SPF_HOLDTIME_DEFAULT
,
2457 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2461 DEFUN (ospf_timers_lsa
,
2462 ospf_timers_lsa_cmd
,
2463 "timers lsa min-arrival (0-600000)",
2464 "Adjust routing timers\n"
2466 "Minimum delay in receiving new version of a LSA\n"
2467 "Delay in milliseconds\n")
2470 unsigned int minarrival
;
2471 struct ospf
*ospf
= vty
->index
;
2478 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2482 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2484 ospf
->min_ls_arrival
= minarrival
;
2489 DEFUN (no_ospf_timers_lsa
,
2490 no_ospf_timers_lsa_cmd
,
2491 "no timers lsa min-arrival [(0-600000)]",
2493 "Adjust routing timers\n"
2495 "Minimum delay in receiving new version of a LSA\n"
2496 "Delay in milliseconds\n")
2498 unsigned int minarrival
;
2499 struct ospf
*ospf
= vty
->index
;
2506 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2508 if (ospf
->min_ls_arrival
!= minarrival
||
2509 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2513 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2518 DEFUN (ospf_neighbor
,
2520 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2522 "Neighbor IP address\n"
2523 "Neighbor Priority\n"
2525 "Dead Neighbor Polling interval\n"
2531 struct ospf
*ospf
= vty
->index
;
2532 struct in_addr nbr_addr
;
2533 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2534 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2539 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2542 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2545 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2547 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2550 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2553 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2558 DEFUN (ospf_neighbor_poll_interval
,
2559 ospf_neighbor_poll_interval_cmd
,
2560 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2562 "Neighbor IP address\n"
2563 "Dead Neighbor Polling interval\n"
2565 "OSPF priority of non-broadcast neighbor\n"
2571 struct ospf
*ospf
= vty
->index
;
2572 struct in_addr nbr_addr
;
2573 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2574 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2579 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2581 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2584 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2586 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2587 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2590 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2595 DEFUN (no_ospf_neighbor
,
2596 no_ospf_neighbor_cmd
,
2597 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2600 "Neighbor IP address\n"
2601 "Neighbor Priority\n"
2603 "Dead Neighbor Polling interval\n"
2607 struct ospf
*ospf
= vty
->index
;
2608 struct in_addr nbr_addr
;
2613 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2615 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2620 DEFUN (no_ospf_neighbor_poll
,
2621 no_ospf_neighbor_poll_cmd
,
2622 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2625 "Neighbor IP address\n"
2626 "Dead Neighbor Polling interval\n"
2628 "Neighbor Priority\n"
2632 struct ospf
*ospf
= vty
->index
;
2633 struct in_addr nbr_addr
;
2638 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2640 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2645 DEFUN (ospf_refresh_timer
,
2646 ospf_refresh_timer_cmd
,
2647 "refresh timer (10-1800)",
2648 "Adjust refresh parameters\n"
2649 "Set refresh timer\n"
2650 "Timer value in seconds\n")
2653 struct ospf
*ospf
= vty
->index
;
2654 unsigned int interval
;
2659 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2660 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2662 ospf_timers_refresh_set (ospf
, interval
);
2667 DEFUN (no_ospf_refresh_timer
,
2668 no_ospf_refresh_timer_val_cmd
,
2669 "no refresh timer [(10-1800)]",
2670 "Adjust refresh parameters\n"
2671 "Unset refresh timer\n"
2672 "Timer value in seconds\n")
2675 struct ospf
*ospf
= vty
->index
;
2676 unsigned int interval
;
2683 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2685 if (ospf
->lsa_refresh_interval
!= interval
||
2686 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2690 ospf_timers_refresh_unset (ospf
);
2696 DEFUN (ospf_auto_cost_reference_bandwidth
,
2697 ospf_auto_cost_reference_bandwidth_cmd
,
2698 "auto-cost reference-bandwidth (1-4294967)",
2699 "Calculate OSPF interface cost according to bandwidth\n"
2700 "Use reference bandwidth method to assign OSPF cost\n"
2701 "The reference bandwidth in terms of Mbits per second\n")
2704 struct ospf
*ospf
= vty
->index
;
2706 struct listnode
*node
;
2707 struct interface
*ifp
;
2712 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2713 if (refbw
< 1 || refbw
> 4294967)
2715 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2719 /* If reference bandwidth is changed. */
2720 if ((refbw
) == ospf
->ref_bandwidth
)
2723 ospf
->ref_bandwidth
= refbw
;
2724 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2725 ospf_if_recalculate_output_cost (ifp
);
2730 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2731 no_ospf_auto_cost_reference_bandwidth_cmd
,
2732 "no auto-cost reference-bandwidth [(1-4294967)]",
2734 "Calculate OSPF interface cost according to bandwidth\n"
2735 "Use reference bandwidth method to assign OSPF cost\n"
2736 "The reference bandwidth in terms of Mbits per second\n")
2738 struct ospf
*ospf
= vty
->index
;
2739 struct listnode
*node
, *nnode
;
2740 struct interface
*ifp
;
2745 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2748 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2749 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2750 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2752 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2753 ospf_if_recalculate_output_cost (ifp
);
2758 DEFUN (ospf_write_multiplier
,
2759 ospf_write_multiplier_cmd
,
2760 "ospf write-multiplier (1-100)",
2761 "OSPF specific commands\n"
2762 "Write multiplier\n"
2763 "Maximum number of interface serviced per write\n")
2766 struct ospf
*ospf
= vty
->index
;
2767 u_int32_t write_oi_count
;
2777 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2778 if (write_oi_count
< 1 || write_oi_count
> 100)
2780 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2784 ospf
->write_oi_count
= write_oi_count
;
2788 ALIAS (ospf_write_multiplier
,
2789 write_multiplier_cmd
,
2790 "write-multiplier (1-100)",
2791 "Write multiplier\n"
2792 "Maximum number of interface serviced per write\n")
2794 DEFUN (no_ospf_write_multiplier
,
2795 no_ospf_write_multiplier_cmd
,
2796 "no ospf write-multiplier (1-100)",
2798 "OSPF specific commands\n"
2799 "Write multiplier\n"
2800 "Maximum number of interface serviced per write\n")
2802 struct ospf
*ospf
= vty
->index
;
2807 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2811 ALIAS (no_ospf_write_multiplier
,
2812 no_write_multiplier_cmd
,
2813 "no write-multiplier (1-100)",
2815 "Write multiplier\n"
2816 "Maximum number of interface serviced per write\n")
2818 const char *ospf_abr_type_descr_str
[] =
2821 "Standard (RFC2328)",
2823 "Alternative Cisco",
2824 "Alternative Shortcut"
2827 const char *ospf_shortcut_mode_descr_str
[] =
2835 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2837 json_object
*json_area
= NULL
;
2840 json_area
= json_object_new_object();
2844 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2846 /* Show Area type/mode. */
2847 if (OSPF_IS_AREA_BACKBONE (area
))
2850 json_object_boolean_true_add(json_area
, "backbone");
2852 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2858 if (area
->external_routing
== OSPF_AREA_STUB
)
2860 if (area
->no_summary
)
2861 json_object_boolean_true_add(json_area
, "stubNoSummary");
2862 if (area
->shortcut_configured
)
2863 json_object_boolean_true_add(json_area
, "stubShortcut");
2865 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2867 if (area
->no_summary
)
2868 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2869 if (area
->shortcut_configured
)
2870 json_object_boolean_true_add(json_area
, "nssaShortcut");
2873 json_object_string_add(json_area
,"shortcuttingMode",
2874 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2875 if (area
->shortcut_capability
)
2876 json_object_boolean_true_add(json_area
,"sBitConcensus");
2880 if (area
->external_routing
== OSPF_AREA_STUB
)
2881 vty_out (vty
, " (Stub%s%s)",
2882 area
->no_summary
? ", no summary" : "",
2883 area
->shortcut_configured
? "; " : "");
2884 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2885 vty_out (vty
, " (NSSA%s%s)",
2886 area
->no_summary
? ", no summary" : "",
2887 area
->shortcut_configured
? "; " : "");
2889 vty_out (vty
, "%s", VTY_NEWLINE
);
2890 vty_out (vty
, " Shortcutting mode: %s",
2891 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2892 vty_out (vty
, ", S-bit consensus: %s%s",
2893 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2897 /* Show number of interfaces */
2900 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2901 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2904 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2905 "Active: %d%s", listcount (area
->oiflist
),
2906 area
->act_ints
, VTY_NEWLINE
);
2908 if (area
->external_routing
== OSPF_AREA_NSSA
)
2912 json_object_boolean_true_add(json_area
, "nssa");
2913 if (! IS_OSPF_ABR (area
->ospf
))
2914 json_object_boolean_false_add(json_area
, "abr");
2915 else if (area
->NSSATranslatorState
)
2917 json_object_boolean_true_add(json_area
, "abr");
2918 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2919 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2920 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2921 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2925 json_object_boolean_true_add(json_area
, "abr");
2926 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2927 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2929 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2934 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2935 if (! IS_OSPF_ABR (area
->ospf
))
2936 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2938 else if (area
->NSSATranslatorState
)
2940 vty_out (vty
, " We are an ABR and ");
2941 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2942 vty_out (vty
, "the NSSA Elected Translator. %s",
2944 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2945 vty_out (vty
, "always an NSSA Translator. %s",
2950 vty_out (vty
, " We are an ABR, but ");
2951 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2952 vty_out (vty
, "not the NSSA Elected Translator. %s",
2955 vty_out (vty
, "never an NSSA Translator. %s",
2961 /* Stub-router state for this area */
2962 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2964 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2968 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2969 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2970 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2971 if (area
->t_stub_router
)
2973 struct timeval result
;
2974 unsigned long time_store
= 0;
2975 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
2976 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2977 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2982 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2984 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2985 vty_out (vty
, " Administratively activated (indefinitely)%s",
2987 if (area
->t_stub_router
)
2988 vty_out (vty
, " Active from startup, %s remaining%s",
2989 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2990 sizeof(timebuf
)), VTY_NEWLINE
);
2996 /* Show number of fully adjacent neighbors. */
2997 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2999 /* Show authentication type. */
3000 if (area
->auth_type
== OSPF_AUTH_NULL
)
3001 json_object_string_add(json_area
, "authentication", "authenticationNone");
3002 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3003 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
3004 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3005 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
3007 if (!OSPF_IS_AREA_BACKBONE (area
))
3008 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
3010 /* Show SPF calculation times. */
3011 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
3012 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
3013 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
3014 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
3015 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
3016 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
3017 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
3018 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
3019 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3020 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3021 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3022 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3026 /* Show number of fully adjacent neighbors. */
3027 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
3028 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
3030 /* Show authentication type. */
3031 vty_out (vty
, " Area has ");
3032 if (area
->auth_type
== OSPF_AUTH_NULL
)
3033 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
3034 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3035 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
3036 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3037 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
3039 if (!OSPF_IS_AREA_BACKBONE (area
))
3040 vty_out (vty
, " Number of full virtual adjacencies going through"
3041 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
3043 /* Show SPF calculation times. */
3044 vty_out (vty
, " SPF algorithm executed %d times%s",
3045 area
->spf_calculation
, VTY_NEWLINE
);
3047 /* Show number of LSA. */
3048 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
3049 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3050 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
3051 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
3052 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3053 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
3054 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
3055 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3056 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
3057 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
3058 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3059 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3060 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
3061 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3062 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
3063 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
3068 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3069 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3070 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3071 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3075 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3076 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3077 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
3078 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3079 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3080 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
3084 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
3086 vty_out (vty
, "%s", VTY_NEWLINE
);
3090 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3092 struct listnode
*node
, *nnode
;
3093 struct ospf_area
* area
;
3094 struct timeval result
;
3095 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3096 json_object
*json
= NULL
;
3097 json_object
*json_areas
= NULL
;
3101 json
= json_object_new_object();
3102 json_areas
= json_object_new_object();
3109 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3113 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3114 VTY_NEWLINE
, VTY_NEWLINE
);
3118 /* Show Router ID. */
3121 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3125 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3126 inet_ntoa (ospf
->router_id
),
3130 /* Graceful shutdown */
3131 if (ospf
->t_deferred_shutdown
)
3135 unsigned long time_store
= 0;
3136 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3137 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3138 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3142 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3143 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3144 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3148 /* Show capability. */
3151 json_object_boolean_true_add(json
, "tosRoutesOnly");
3152 json_object_boolean_true_add(json
, "rfc2328Conform");
3153 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3155 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3160 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3161 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3162 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3163 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3164 "enabled" : "disabled", VTY_NEWLINE
);
3169 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3171 json_object_boolean_true_add(json
, "opaqueCapable");
3176 vty_out (vty
, " OpaqueCapability flag is %s%s",
3177 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3181 /* Show stub-router configuration */
3182 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3183 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3187 json_object_boolean_true_add(json
, "stubAdvertisement");
3188 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3189 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3190 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3191 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3195 vty_out (vty
, " Stub router advertisement is configured%s",
3197 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3198 vty_out (vty
, " Enabled for %us after start-up%s",
3199 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3200 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3201 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3202 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3206 /* Show SPF timers. */
3209 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3210 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3211 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3212 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3216 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3217 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3218 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3219 " Hold time multiplier is currently %d%s",
3220 ospf
->spf_delay
, VTY_NEWLINE
,
3221 ospf
->spf_holdtime
, VTY_NEWLINE
,
3222 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3223 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3228 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3230 unsigned long time_store
= 0;
3232 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3233 result
= tv_sub (result
, recent_relative_time());
3234 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3235 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3237 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3238 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3241 json_object_boolean_true_add(json
, "spfHasNotRun");
3245 vty_out (vty
, " SPF algorithm ");
3246 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3248 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3249 vty_out (vty
, "last executed %s ago%s",
3250 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3252 vty_out (vty
, " Last SPF duration %s%s",
3253 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3257 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3262 struct timeval temp_time
;
3263 unsigned long time_store
= 0;
3265 if (ospf
->t_spf_calc
)
3267 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3268 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3269 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3272 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3273 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3274 /* Show write multiplier values */
3275 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3276 /* Show refresh parameters. */
3277 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3281 vty_out (vty
, " SPF timer %s%s%s",
3282 (ospf
->t_spf_calc
? "due in " : "is "),
3283 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3286 vty_out (vty
, " LSA minimum interval %d msecs%s",
3287 ospf
->min_ls_interval
, VTY_NEWLINE
);
3288 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3289 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3291 /* Show write multiplier values */
3292 vty_out (vty
, " Write Multiplier set to %d %s",
3293 ospf
->write_oi_count
, VTY_NEWLINE
);
3295 /* Show refresh parameters. */
3296 vty_out (vty
, " Refresh timer %d secs%s",
3297 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3300 /* Show ABR/ASBR flags. */
3301 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3304 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3306 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3307 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3309 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3312 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3314 vty_out (vty
, " This router is an ASBR "
3315 "(injecting external routing information)%s", VTY_NEWLINE
);
3318 /* Show Number of AS-external-LSAs. */
3321 json_object_int_add(json
, "lsaExternalCounter",
3322 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3323 json_object_int_add(json
, "lsaExternalChecksum",
3324 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3328 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3329 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3330 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3335 json_object_int_add(json
, "lsaAsopaqueCounter",
3336 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3337 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3338 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3342 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3343 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3344 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3347 /* Show number of areas attached. */
3349 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3351 vty_out (vty
, " Number of areas attached to this router: %d%s",
3352 listcount (ospf
->areas
), VTY_NEWLINE
);
3354 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3356 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3359 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3361 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3366 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3368 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3371 /* Show each area status. */
3372 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3373 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3377 json_object_object_add(json
, "areas", json_areas
);
3378 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3379 json_object_free(json
);
3382 vty_out (vty
, "%s",VTY_NEWLINE
);
3387 DEFUN (show_ip_ospf
,
3389 "show ip ospf [json]",
3392 "OSPF information\n"
3393 "JavaScript Object Notation\n")
3396 u_char uj
= use_json(argc
, argv
);
3398 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3401 return (show_ip_ospf_common(vty
, ospf
, uj
));
3404 DEFUN (show_ip_ospf_instance
,
3405 show_ip_ospf_instance_cmd
,
3406 "show ip ospf (1-65535) [json]",
3409 "OSPF information\n"
3411 "JavaScript Object Notation\n")
3415 u_short instance
= 0;
3416 u_char uj
= use_json(argc
, argv
);
3418 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3419 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3422 return (show_ip_ospf_common(vty
, ospf
, uj
));
3426 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3427 json_object
*json_interface_sub
, u_char use_json
)
3430 struct ospf_neighbor
*nbr
;
3431 struct route_node
*rn
;
3433 /* Is interface up? */
3436 is_up
= if_is_operative(ifp
);
3438 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3440 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3442 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3443 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3444 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3445 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3449 vty_out (vty
, "%s is %s%s", ifp
->name
,
3450 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3451 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3452 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3456 /* Is interface OSPF enabled? */
3459 if (ospf_oi_count(ifp
) == 0)
3461 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3466 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3470 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3474 if (ospf_oi_count(ifp
) == 0)
3476 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3481 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3487 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3489 struct ospf_interface
*oi
= rn
->info
;
3494 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3497 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3499 vty_out (vty
, " This interface is UNNUMBERED,");
3503 /* Show OSPF interface information. */
3506 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3507 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3510 vty_out (vty
, " Internet Address %s/%d,",
3511 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3513 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3515 struct in_addr
*dest
;
3518 if (CONNECTED_PEER(oi
->connected
)
3519 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3524 /* For Vlinks, showing the peer address is probably more
3525 * * * * * informative than the local interface that is being used
3527 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3528 dest
= &oi
->vl_data
->peer_addr
;
3530 dest
= &oi
->connected
->destination
->u
.prefix4
;
3534 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3535 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3536 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3538 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3541 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3546 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3547 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3548 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3549 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3550 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3551 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3552 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3553 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3554 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3558 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3561 vty_out (vty
, " MTU mismatch detection:%s%s",
3562 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3564 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3565 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3566 oi
->output_cost
, VTY_NEWLINE
);
3568 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3569 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3570 PRIORITY (oi
), VTY_NEWLINE
);
3573 /* Show DR information. */
3574 if (DR (oi
).s_addr
== 0)
3577 vty_out (vty
, " No backup designated router on this network%s",
3582 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3586 vty_out (vty
, " No backup designated router on this network%s",
3593 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3594 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3598 vty_out (vty
, " Backup Designated Router (ID) %s,",
3599 inet_ntoa (nbr
->router_id
));
3600 vty_out (vty
, " Interface Address %s%s",
3601 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3606 /* Next network-LSA sequence number we'll use, if we're elected DR */
3607 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3610 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3612 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3613 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3618 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3619 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3621 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3622 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3623 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3624 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3629 vty_out (vty
, " Multicast group memberships:");
3630 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3631 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3633 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3634 vty_out (vty
, " OSPFAllRouters");
3635 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3636 vty_out (vty
, " OSPFDesignatedRouters");
3639 vty_out (vty
, " <None>");
3640 vty_out (vty
, "%s", VTY_NEWLINE
);
3645 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3646 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3648 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3649 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3650 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3651 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3655 vty_out (vty
, " Timer intervals configured,");
3656 vty_out (vty
, " Hello ");
3657 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3658 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3660 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3661 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3662 OSPF_IF_PARAM (oi
, v_wait
),
3663 OSPF_IF_PARAM (oi
, v_wait
),
3664 OSPF_IF_PARAM (oi
, retransmit_interval
),
3668 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3670 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3673 struct timeval result
;
3674 unsigned long time_store
= 0;
3676 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3682 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3683 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3686 vty_out (vty
, " Hello due in %s%s",
3687 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3690 else /* passive-interface is set */
3693 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3695 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3700 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3701 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3704 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3705 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3707 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3712 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3713 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3715 struct interface
*ifp
;
3716 struct listnode
*node
;
3717 json_object
*json
= NULL
;
3718 json_object
*json_interface_sub
= NULL
;
3722 json
= json_object_new_object();
3723 json_interface_sub
= json_object_new_object();
3729 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3731 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3732 VTY_NEWLINE
, VTY_NEWLINE
);
3735 if (argc
== (iface_argv
+ 1))
3737 /* Show All Interfaces.*/
3738 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3740 if (ospf_oi_count(ifp
))
3742 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3744 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3748 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3752 json
= json_object_new_object();
3753 json_interface_sub
= json_object_new_object ();
3756 /* Show All Interfaces. */
3757 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3759 if (ospf_oi_count(ifp
))
3761 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3763 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3769 /* Interface name is specified. */
3770 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3773 json_object_boolean_true_add(json
, "noSuchIface");
3775 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3779 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3781 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3787 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3788 json_object_free(json
);
3791 vty_out (vty
, "%s", VTY_NEWLINE
);
3796 DEFUN (show_ip_ospf_interface
,
3797 show_ip_ospf_interface_cmd
,
3798 "show ip ospf interface [INTERFACE] [json]",
3801 "OSPF information\n"
3802 "Interface information\n"
3804 "JavaScript Object Notation\n")
3807 u_char uj
= use_json(argc
, argv
);
3809 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3812 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3815 DEFUN (show_ip_ospf_instance_interface
,
3816 show_ip_ospf_instance_interface_cmd
,
3817 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3820 "OSPF information\n"
3822 "Interface information\n"
3824 "JavaScript Object Notation\n")
3828 u_short instance
= 0;
3829 u_char uj
= use_json(argc
, argv
);
3831 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3832 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3835 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3839 show_ip_ospf_neighbour_header (struct vty
*vty
)
3841 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3843 "Neighbor ID", "Pri", "State", "Dead Time",
3844 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3849 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3851 struct route_node
*rn
;
3852 struct ospf_neighbor
*nbr
;
3854 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3855 json_object
*json_neighbor
= NULL
;
3857 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3859 if ((nbr
= rn
->info
))
3861 /* Do not show myself. */
3862 if (nbr
!= oi
->nbr_self
)
3864 /* Down state is not shown. */
3865 if (nbr
->state
!= NSM_Down
)
3869 json_neighbor
= json_object_new_object();
3870 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3872 struct timeval result
;
3873 unsigned long time_store
= 0;
3875 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3876 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3878 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3879 json_object_string_add (json_neighbor
, "state", msgbuf
);
3880 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3881 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3882 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3883 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3884 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3885 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3886 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3887 json_object_object_add(json
, "neighbor", json_neighbor
);
3889 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3893 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3895 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3896 vty_out (vty
, "%-15s %3d %-15s ",
3900 vty_out (vty
, "%-15s %3d %-15s ",
3901 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3904 vty_out (vty
, "%9s ",
3905 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3907 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3908 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3909 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3910 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3920 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3922 struct ospf_interface
*oi
;
3923 struct listnode
*node
;
3924 json_object
*json
= NULL
;
3927 json
= json_object_new_object();
3929 show_ip_ospf_neighbour_header (vty
);
3934 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3936 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3937 VTY_NEWLINE
, VTY_NEWLINE
);
3940 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3941 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3945 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3946 json_object_free(json
);
3949 vty_out (vty
, "%s", VTY_NEWLINE
);
3954 DEFUN (show_ip_ospf_neighbor
,
3955 show_ip_ospf_neighbor_cmd
,
3956 "show ip ospf neighbor [json]",
3959 "OSPF information\n"
3961 "JavaScript Object Notation\n")
3964 u_char uj
= use_json(argc
, argv
);
3966 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3969 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3973 DEFUN (show_ip_ospf_instance_neighbor
,
3974 show_ip_ospf_instance_neighbor_cmd
,
3975 "show ip ospf (1-65535) neighbor [json]",
3978 "OSPF information\n"
3981 "JavaScript Object Notation\n")
3985 u_short instance
= 0;
3986 u_char uj
= use_json(argc
, argv
);
3988 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3989 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3992 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3996 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3998 struct listnode
*node
;
3999 struct ospf_interface
*oi
;
4000 json_object
*json
= NULL
;
4001 json_object
*json_neighbor_sub
= NULL
;
4005 json
= json_object_new_object();
4006 json_neighbor_sub
= json_object_new_object();
4009 show_ip_ospf_neighbour_header (vty
);
4014 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4016 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4017 VTY_NEWLINE
, VTY_NEWLINE
);
4020 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4022 struct listnode
*nbr_node
;
4023 struct ospf_nbr_nbma
*nbr_nbma
;
4025 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4027 /* print Down neighbor status */
4028 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4030 if (nbr_nbma
->nbr
== NULL
4031 || nbr_nbma
->nbr
->state
== NSM_Down
)
4035 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4036 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4037 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4038 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4039 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4040 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4041 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4045 vty_out (vty
, "%-15s %3d %-15s %9s ",
4046 "-", nbr_nbma
->priority
, "Down", "-");
4047 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4048 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4049 0, 0, 0, VTY_NEWLINE
);
4057 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4058 json_object_free(json
);
4061 vty_out (vty
, "%s", VTY_NEWLINE
);
4066 DEFUN (show_ip_ospf_neighbor_all
,
4067 show_ip_ospf_neighbor_all_cmd
,
4068 "show ip ospf neighbor all [json]",
4071 "OSPF information\n"
4073 "include down status neighbor\n"
4074 "JavaScript Object Notation\n")
4077 u_char uj
= use_json(argc
, argv
);
4079 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4082 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4085 DEFUN (show_ip_ospf_instance_neighbor_all
,
4086 show_ip_ospf_instance_neighbor_all_cmd
,
4087 "show ip ospf (1-65535) neighbor all [json]",
4090 "OSPF information\n"
4093 "include down status neighbor\n"
4094 "JavaScript Object Notation\n")
4098 u_short instance
= 0;
4099 u_char uj
= use_json(argc
, argv
);
4101 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4102 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4105 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4109 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4110 struct cmd_token
**argv
, u_char use_json
)
4112 struct interface
*ifp
;
4113 struct route_node
*rn
;
4114 json_object
*json
= NULL
;
4117 json
= json_object_new_object();
4119 show_ip_ospf_neighbour_header (vty
);
4124 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4126 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4127 VTY_NEWLINE
, VTY_NEWLINE
);
4130 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4134 json_object_boolean_true_add(json
, "noSuchIface");
4136 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4140 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4142 struct ospf_interface
*oi
= rn
->info
;
4147 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4152 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4153 json_object_free(json
);
4156 vty_out (vty
, "%s", VTY_NEWLINE
);
4161 DEFUN (show_ip_ospf_neighbor_int
,
4162 show_ip_ospf_neighbor_int_cmd
,
4163 "show ip ospf neighbor IFNAME [json]",
4166 "OSPF information\n"
4169 "JavaScript Object Notation\n")
4172 u_char uj
= use_json(argc
, argv
);
4174 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4177 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4180 DEFUN (show_ip_ospf_instance_neighbor_int
,
4181 show_ip_ospf_instance_neighbor_int_cmd
,
4182 "show ip ospf (1-65535) neighbor IFNAME [json]",
4185 "OSPF information\n"
4189 "JavaScript Object Notation\n")
4193 u_short instance
= 0;
4194 u_char uj
= use_json(argc
, argv
);
4196 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4197 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4200 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4204 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4205 u_char use_json
, json_object
*json
)
4207 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4208 json_object
*json_sub
= NULL
;
4211 json_sub
= json_object_new_object();
4212 else /* Show neighbor ID. */
4213 vty_out (vty
, " Neighbor %s,", "-");
4215 /* Show interface address. */
4217 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4219 vty_out (vty
, " interface address %s%s",
4220 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4225 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4226 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4229 vty_out (vty
, " In the area %s via interface %s%s",
4230 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4232 /* Show neighbor priority and state. */
4235 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4236 json_object_string_add(json_sub
, "nbrState", "down");
4239 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4240 nbr_nbma
->priority
, "Down");
4242 /* Show state changes. */
4244 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4246 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4248 /* Show PollInterval */
4250 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4252 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4254 /* Show poll-interval timer. */
4257 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4258 unsigned long time_store
= 0;
4259 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4260 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4263 vty_out (vty
, " Poll timer due in %s%s",
4264 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4267 /* Show poll-interval timer thread. */
4270 if (nbr_nbma
->t_poll
!= NULL
)
4271 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4274 vty_out (vty
, " Thread Poll Timer %s%s",
4275 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4278 json_object_object_add(json
, "noNbrId", json_sub
);
4282 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4283 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4285 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4286 json_object
*json_sub
= NULL
;
4289 json_sub
= json_object_new_object();
4292 /* Show neighbor ID. */
4293 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4294 vty_out (vty
, " Neighbor %s,", "-");
4296 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4299 /* Show interface address. */
4301 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4303 vty_out (vty
, " interface address %s%s",
4304 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4309 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4310 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4313 vty_out (vty
, " In the area %s via interface %s%s",
4314 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4316 /* Show neighbor priority and state. */
4319 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4320 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4323 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4324 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4326 /* Show state changes. */
4328 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4330 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4332 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4334 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4337 unsigned long time_store
= 0;
4338 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4339 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4343 vty_out (vty
, " Most recent state change statistics:%s",
4345 vty_out (vty
, " Progressive change %s ago%s",
4346 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4351 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4353 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4356 unsigned long time_store
= 0;
4357 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4358 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4359 if (nbr
->last_regress_str
)
4360 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4364 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4365 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4366 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4371 /* Show Designated Rotuer ID. */
4373 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4375 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4377 /* Show Backup Designated Rotuer ID. */
4379 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4381 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4386 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4387 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4390 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4391 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4393 /* Show Router Dead interval timer. */
4396 if (nbr
->t_inactivity
)
4398 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4399 unsigned long time_store
= 0;
4400 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4401 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4404 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4407 vty_out (vty
, " Dead timer due in %s%s",
4408 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4411 /* Show Database Summary list. */
4413 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4415 vty_out (vty
, " Database Summary List %d%s",
4416 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4418 /* Show Link State Request list. */
4420 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4422 vty_out (vty
, " Link State Request List %ld%s",
4423 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4425 /* Show Link State Retransmission list. */
4427 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4429 vty_out (vty
, " Link State Retransmission List %ld%s",
4430 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4432 /* Show inactivity timer thread. */
4435 if (nbr
->t_inactivity
!= NULL
)
4436 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4439 vty_out (vty
, " Thread Inactivity Timer %s%s",
4440 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4442 /* Show Database Description retransmission thread. */
4445 if (nbr
->t_db_desc
!= NULL
)
4446 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4449 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4450 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4452 /* Show Link State Request Retransmission thread. */
4455 if (nbr
->t_ls_req
!= NULL
)
4456 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4459 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4460 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4462 /* Show Link State Update Retransmission thread. */
4465 if (nbr
->t_ls_upd
!= NULL
)
4466 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4469 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4470 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4474 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4475 json_object_object_add(json
, "noNbrId", json_sub
);
4477 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4480 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4484 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4485 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4487 struct listnode
*node
;
4488 struct ospf_neighbor
*nbr
;
4489 struct ospf_interface
*oi
;
4490 struct in_addr router_id
;
4492 json_object
*json
= NULL
;
4495 json
= json_object_new_object();
4500 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4502 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4503 VTY_NEWLINE
, VTY_NEWLINE
);
4506 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4510 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4514 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4516 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4518 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4524 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4525 json_object_free(json
);
4528 vty_out (vty
, "%s", VTY_NEWLINE
);
4533 DEFUN (show_ip_ospf_neighbor_id
,
4534 show_ip_ospf_neighbor_id_cmd
,
4535 "show ip ospf neighbor A.B.C.D [json]",
4538 "OSPF information\n"
4541 "JavaScript Object Notation\n")
4544 u_char uj
= use_json(argc
, argv
);
4546 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4549 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4552 DEFUN (show_ip_ospf_instance_neighbor_id
,
4553 show_ip_ospf_instance_neighbor_id_cmd
,
4554 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4557 "OSPF information\n"
4561 "JavaScript Object Notation\n")
4565 u_short instance
= 0;
4566 u_char uj
= use_json(argc
, argv
);
4568 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4569 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4572 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4576 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4578 struct ospf_interface
*oi
;
4579 struct listnode
*node
;
4580 json_object
*json
= NULL
;
4583 json
= json_object_new_object();
4588 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4590 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4591 VTY_NEWLINE
, VTY_NEWLINE
);
4594 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4596 struct route_node
*rn
;
4597 struct ospf_neighbor
*nbr
;
4599 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4601 if ((nbr
= rn
->info
))
4603 if (nbr
!= oi
->nbr_self
)
4605 if (nbr
->state
!= NSM_Down
)
4607 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4616 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4617 json_object_free(json
);
4620 vty_out (vty
, "%s", VTY_NEWLINE
);
4625 DEFUN (show_ip_ospf_neighbor_detail
,
4626 show_ip_ospf_neighbor_detail_cmd
,
4627 "show ip ospf neighbor detail [json]",
4630 "OSPF information\n"
4632 "detail of all neighbors\n"
4633 "JavaScript Object Notation\n")
4636 u_char uj
= use_json(argc
, argv
);
4638 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4641 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4644 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4645 show_ip_ospf_instance_neighbor_detail_cmd
,
4646 "show ip ospf (1-65535) neighbor detail [json]",
4649 "OSPF information\n"
4652 "detail of all neighbors\n"
4653 "JavaScript Object Notation\n")
4657 u_short instance
= 0;
4658 u_char uj
= use_json(argc
, argv
);
4660 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4661 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4664 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4668 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4670 struct listnode
*node
;
4671 struct ospf_interface
*oi
;
4672 json_object
*json
= NULL
;
4675 json
= json_object_new_object();
4680 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4682 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4683 VTY_NEWLINE
, VTY_NEWLINE
);
4686 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4688 struct route_node
*rn
;
4689 struct ospf_neighbor
*nbr
;
4690 struct ospf_nbr_nbma
*nbr_nbma
;
4692 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4693 if ((nbr
= rn
->info
))
4694 if (nbr
!= oi
->nbr_self
)
4695 if (nbr
->state
!= NSM_Down
)
4696 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4698 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4700 struct listnode
*nd
;
4702 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4704 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4705 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4712 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4713 json_object_free(json
);
4717 vty_out (vty
, "%s", VTY_NEWLINE
);
4723 DEFUN (show_ip_ospf_neighbor_detail_all
,
4724 show_ip_ospf_neighbor_detail_all_cmd
,
4725 "show ip ospf neighbor detail all [json]",
4728 "OSPF information\n"
4730 "detail of all neighbors\n"
4731 "include down status neighbor\n"
4732 "JavaScript Object Notation\n")
4735 u_char uj
= use_json(argc
, argv
);
4737 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4740 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4743 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4744 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4745 "show ip ospf (1-65535) neighbor detail all [json]",
4748 "OSPF information\n"
4751 "detail of all neighbors\n"
4752 "include down status neighbor\n"
4753 "JavaScript Object Notation\n")
4757 u_short instance
= 0;
4758 u_char uj
= use_json(argc
, argv
);
4760 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4761 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4764 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4768 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4769 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4771 struct ospf_interface
*oi
;
4772 struct interface
*ifp
;
4773 struct route_node
*rn
, *nrn
;
4774 struct ospf_neighbor
*nbr
;
4775 json_object
*json
= NULL
;
4778 json
= json_object_new_object();
4783 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4785 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4786 VTY_NEWLINE
, VTY_NEWLINE
);
4789 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4793 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4797 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4799 if ((oi
= rn
->info
))
4801 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4803 if ((nbr
= nrn
->info
))
4805 if (nbr
!= oi
->nbr_self
)
4807 if (nbr
->state
!= NSM_Down
)
4808 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4817 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4818 json_object_free(json
);
4821 vty_out (vty
, "%s", VTY_NEWLINE
);
4826 DEFUN (show_ip_ospf_neighbor_int_detail
,
4827 show_ip_ospf_neighbor_int_detail_cmd
,
4828 "show ip ospf neighbor IFNAME detail [json]",
4831 "OSPF information\n"
4834 "detail of all neighbors\n"
4835 "JavaScript Object Notation\n")
4838 u_char uj
= use_json(argc
, argv
);
4840 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4843 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4846 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4847 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4848 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4851 "OSPF information\n"
4855 "detail of all neighbors\n"
4856 "JavaScript Object Notation\n")
4860 u_short instance
= 0;
4861 u_char uj
= use_json(argc
, argv
);
4863 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4864 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4867 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4870 /* Show functions */
4872 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4874 struct router_lsa
*rl
;
4875 struct summary_lsa
*sl
;
4876 struct as_external_lsa
*asel
;
4877 struct prefix_ipv4 p
;
4880 /* If self option is set, check LSA self flag. */
4881 if (self
== 0 || IS_LSA_SELF (lsa
))
4883 /* LSA common part show. */
4884 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4885 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4886 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4887 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4888 /* LSA specific part show. */
4889 switch (lsa
->data
->type
)
4891 case OSPF_ROUTER_LSA
:
4892 rl
= (struct router_lsa
*) lsa
->data
;
4893 vty_out (vty
, " %-d", ntohs (rl
->links
));
4895 case OSPF_SUMMARY_LSA
:
4896 sl
= (struct summary_lsa
*) lsa
->data
;
4899 p
.prefix
= sl
->header
.id
;
4900 p
.prefixlen
= ip_masklen (sl
->mask
);
4901 apply_mask_ipv4 (&p
);
4903 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4905 case OSPF_AS_EXTERNAL_LSA
:
4906 case OSPF_AS_NSSA_LSA
:
4907 asel
= (struct as_external_lsa
*) lsa
->data
;
4910 p
.prefix
= asel
->header
.id
;
4911 p
.prefixlen
= ip_masklen (asel
->mask
);
4912 apply_mask_ipv4 (&p
);
4914 vty_out (vty
, " %s %s/%d [0x%lx]",
4915 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4916 inet_ntoa (p
.prefix
), p
.prefixlen
,
4917 (u_long
)ntohl (asel
->e
[0].route_tag
));
4919 case OSPF_NETWORK_LSA
:
4920 case OSPF_ASBR_SUMMARY_LSA
:
4921 case OSPF_OPAQUE_LINK_LSA
:
4922 case OSPF_OPAQUE_AREA_LSA
:
4923 case OSPF_OPAQUE_AS_LSA
:
4927 vty_out (vty
, VTY_NEWLINE
);
4933 static const char *show_database_desc
[] =
4936 "Router Link States",
4938 "Summary Link States",
4939 "ASBR-Summary Link States",
4940 "AS External Link States",
4941 "Group Membership LSA",
4942 "NSSA-external Link States",
4944 "Link-Local Opaque-LSA",
4945 "Area-Local Opaque-LSA",
4946 "AS-external Opaque-LSA",
4949 static const char *show_database_header
[] =
4952 "Link ID ADV Router Age Seq# CkSum Link count",
4953 "Link ID ADV Router Age Seq# CkSum",
4954 "Link ID ADV Router Age Seq# CkSum Route",
4955 "Link ID ADV Router Age Seq# CkSum",
4956 "Link ID ADV Router Age Seq# CkSum Route",
4957 " --- header for Group Member ----",
4958 "Link ID ADV Router Age Seq# CkSum Route",
4960 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4961 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4962 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4966 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4968 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4970 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4971 vty_out (vty
, " Options: 0x%-2x : %s%s",
4973 ospf_options_dump(lsa
->data
->options
),
4975 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4977 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4980 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4982 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4985 vty_out (vty
, " :%s%s%s%s",
4986 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4987 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4988 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4989 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4991 vty_out (vty
, "%s", VTY_NEWLINE
);
4993 vty_out (vty
, " LS Type: %s%s",
4994 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4995 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4996 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4997 vty_out (vty
, " Advertising Router: %s%s",
4998 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4999 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5001 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5003 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5006 const char *link_type_desc
[] =
5009 "another Router (point-to-point)",
5010 "a Transit Network",
5015 const char *link_id_desc
[] =
5018 "Neighboring Router ID",
5019 "Designated Router address",
5021 "Neighboring Router ID",
5024 const char *link_data_desc
[] =
5027 "Router Interface address",
5028 "Router Interface address",
5030 "Router Interface address",
5033 /* Show router-LSA each Link information. */
5035 show_ip_ospf_database_router_links (struct vty
*vty
,
5036 struct router_lsa
*rl
)
5041 len
= ntohs (rl
->header
.length
) - 4;
5042 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5044 type
= rl
->link
[i
].type
;
5046 vty_out (vty
, " Link connected to: %s%s",
5047 link_type_desc
[type
], VTY_NEWLINE
);
5048 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5049 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5050 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5051 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5052 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5053 vty_out (vty
, " TOS 0 Metric: %d%s",
5054 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5055 vty_out (vty
, "%s", VTY_NEWLINE
);
5059 /* Show router-LSA detail information. */
5061 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5065 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5067 show_ip_ospf_database_header (vty
, lsa
);
5069 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5070 VTY_NEWLINE
, VTY_NEWLINE
);
5072 show_ip_ospf_database_router_links (vty
, rl
);
5073 vty_out (vty
, "%s", VTY_NEWLINE
);
5079 /* Show network-LSA detail information. */
5081 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5087 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5089 show_ip_ospf_database_header (vty
, lsa
);
5091 vty_out (vty
, " Network Mask: /%d%s",
5092 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5094 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5096 for (i
= 0; length
> 0; i
++, length
-= 4)
5097 vty_out (vty
, " Attached Router: %s%s",
5098 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5100 vty_out (vty
, "%s", VTY_NEWLINE
);
5106 /* Show summary-LSA detail information. */
5108 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5112 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5114 show_ip_ospf_database_header (vty
, lsa
);
5116 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5118 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5120 vty_out (vty
, "%s", VTY_NEWLINE
);
5126 /* Show summary-ASBR-LSA detail information. */
5128 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5132 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5134 show_ip_ospf_database_header (vty
, lsa
);
5136 vty_out (vty
, " Network Mask: /%d%s",
5137 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5138 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5140 vty_out (vty
, "%s", VTY_NEWLINE
);
5146 /* Show AS-external-LSA detail information. */
5148 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5152 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5154 show_ip_ospf_database_header (vty
, lsa
);
5156 vty_out (vty
, " Network Mask: /%d%s",
5157 ip_masklen (al
->mask
), VTY_NEWLINE
);
5158 vty_out (vty
, " Metric Type: %s%s",
5159 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5160 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5161 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5162 vty_out (vty
, " Metric: %d%s",
5163 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5164 vty_out (vty
, " Forward Address: %s%s",
5165 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5167 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5168 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5175 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5177 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5179 /* show_ip_ospf_database_header (vty, lsa); */
5181 zlog_debug( " Network Mask: /%d%s",
5182 ip_masklen (al
->mask
), "\n");
5183 zlog_debug( " Metric Type: %s%s",
5184 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5185 "2 (Larger than any link state path)" : "1", "\n");
5186 zlog_debug( " TOS: 0%s", "\n");
5187 zlog_debug( " Metric: %d%s",
5188 GET_METRIC (al
->e
[0].metric
), "\n");
5189 zlog_debug( " Forward Address: %s%s",
5190 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5192 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5193 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5198 /* Show AS-NSSA-LSA detail information. */
5200 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5204 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5206 show_ip_ospf_database_header (vty
, lsa
);
5208 vty_out (vty
, " Network Mask: /%d%s",
5209 ip_masklen (al
->mask
), VTY_NEWLINE
);
5210 vty_out (vty
, " Metric Type: %s%s",
5211 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5212 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5213 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5214 vty_out (vty
, " Metric: %d%s",
5215 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5216 vty_out (vty
, " NSSA: Forward Address: %s%s",
5217 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5219 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5220 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5227 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5233 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5237 show_ip_ospf_database_header (vty
, lsa
);
5238 show_opaque_info_detail (vty
, lsa
);
5240 vty_out (vty
, "%s", VTY_NEWLINE
);
5245 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5248 show_router_lsa_detail
,
5249 show_network_lsa_detail
,
5250 show_summary_lsa_detail
,
5251 show_summary_asbr_lsa_detail
,
5252 show_as_external_lsa_detail
,
5254 show_as_nssa_lsa_detail
, /* almost same as external */
5256 show_opaque_lsa_detail
,
5257 show_opaque_lsa_detail
,
5258 show_opaque_lsa_detail
,
5262 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5263 struct in_addr
*adv_router
)
5265 memset (lp
, 0, sizeof (struct prefix_ls
));
5269 else if (adv_router
== NULL
)
5278 lp
->adv_router
= *adv_router
;
5283 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5284 struct in_addr
*id
, struct in_addr
*adv_router
)
5286 struct prefix_ls lp
;
5287 struct route_node
*rn
, *start
;
5288 struct ospf_lsa
*lsa
;
5290 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5291 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5294 route_lock_node (start
);
5295 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5296 if ((lsa
= rn
->info
))
5298 if (show_function
[lsa
->data
->type
] != NULL
)
5299 show_function
[lsa
->data
->type
] (vty
, lsa
);
5301 route_unlock_node (start
);
5305 /* Show detail LSA information
5306 -- if id is NULL then show all LSAs. */
5308 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5309 struct in_addr
*id
, struct in_addr
*adv_router
)
5311 struct listnode
*node
;
5312 struct ospf_area
*area
;
5316 case OSPF_AS_EXTERNAL_LSA
:
5317 case OSPF_OPAQUE_AS_LSA
:
5318 vty_out (vty
, " %s %s%s",
5319 show_database_desc
[type
],
5320 VTY_NEWLINE
, VTY_NEWLINE
);
5321 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5324 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5326 vty_out (vty
, "%s %s (Area %s)%s%s",
5327 VTY_NEWLINE
, show_database_desc
[type
],
5328 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5329 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5336 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5337 struct in_addr
*adv_router
)
5339 struct route_node
*rn
;
5340 struct ospf_lsa
*lsa
;
5342 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5343 if ((lsa
= rn
->info
))
5344 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5346 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5348 if (show_function
[lsa
->data
->type
] != NULL
)
5349 show_function
[lsa
->data
->type
] (vty
, lsa
);
5353 /* Show detail LSA information. */
5355 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5356 struct in_addr
*adv_router
)
5358 struct listnode
*node
;
5359 struct ospf_area
*area
;
5363 case OSPF_AS_EXTERNAL_LSA
:
5364 case OSPF_OPAQUE_AS_LSA
:
5365 vty_out (vty
, " %s %s%s",
5366 show_database_desc
[type
],
5367 VTY_NEWLINE
, VTY_NEWLINE
);
5368 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5372 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5374 vty_out (vty
, "%s %s (Area %s)%s%s",
5375 VTY_NEWLINE
, show_database_desc
[type
],
5376 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5377 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5385 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5387 struct ospf_lsa
*lsa
;
5388 struct route_node
*rn
;
5389 struct ospf_area
*area
;
5390 struct listnode
*node
;
5393 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5395 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5399 case OSPF_AS_EXTERNAL_LSA
:
5400 case OSPF_OPAQUE_AS_LSA
:
5405 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5406 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5408 vty_out (vty
, " %s (Area %s)%s%s",
5409 show_database_desc
[type
],
5410 ospf_area_desc_string (area
),
5411 VTY_NEWLINE
, VTY_NEWLINE
);
5412 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5414 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5415 show_lsa_summary (vty
, lsa
, self
);
5417 vty_out (vty
, "%s", VTY_NEWLINE
);
5422 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5426 case OSPF_AS_EXTERNAL_LSA
:
5427 case OSPF_OPAQUE_AS_LSA
:
5432 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5433 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5435 vty_out (vty
, " %s%s%s",
5436 show_database_desc
[type
],
5437 VTY_NEWLINE
, VTY_NEWLINE
);
5438 vty_out (vty
, "%s%s", show_database_header
[type
],
5441 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5442 show_lsa_summary (vty
, lsa
, self
);
5444 vty_out (vty
, "%s", VTY_NEWLINE
);
5448 vty_out (vty
, "%s", VTY_NEWLINE
);
5452 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5454 struct route_node
*rn
;
5456 vty_out (vty
, "%s MaxAge Link States:%s%s",
5457 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5459 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5461 struct ospf_lsa
*lsa
;
5463 if ((lsa
= rn
->info
) != NULL
)
5465 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5466 vty_out (vty
, "Link State ID: %s%s",
5467 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5468 vty_out (vty
, "Advertising Router: %s%s",
5469 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5470 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5471 vty_out (vty
, "%s", VTY_NEWLINE
);
5476 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5477 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5479 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5480 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5481 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5482 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5484 #define OSPF_LSA_TYPES_DESC \
5485 "ASBR summary link states\n" \
5486 "External link states\n" \
5487 "Network link states\n" \
5488 "Router link states\n" \
5489 "Network summary link states\n" \
5490 OSPF_LSA_TYPE_NSSA_DESC \
5491 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5492 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5493 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5496 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5497 int arg_base
, int argc
, struct cmd_token
**argv
)
5501 struct in_addr id
, adv_router
;
5504 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5507 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5508 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5511 if (argc
== arg_base
+ 4)
5513 show_ip_ospf_database_summary (vty
, ospf
, 0);
5517 /* Set database type to show. */
5518 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5519 type
= OSPF_ROUTER_LSA
;
5520 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5521 type
= OSPF_NETWORK_LSA
;
5522 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5523 type
= OSPF_AS_NSSA_LSA
;
5524 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5525 type
= OSPF_SUMMARY_LSA
;
5526 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5527 type
= OSPF_ASBR_SUMMARY_LSA
;
5528 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5529 type
= OSPF_AS_EXTERNAL_LSA
;
5530 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5532 show_ip_ospf_database_summary (vty
, ospf
, 1);
5535 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5537 show_ip_ospf_database_maxage (vty
, ospf
);
5540 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5541 type
= OSPF_OPAQUE_LINK_LSA
;
5542 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5543 type
= OSPF_OPAQUE_AREA_LSA
;
5544 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5545 type
= OSPF_OPAQUE_AS_LSA
;
5549 /* `show ip ospf database LSA'. */
5550 if (argc
== arg_base
+ 5)
5551 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5552 else if (argc
>= arg_base
+ 6)
5554 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5558 /* `show ip ospf database LSA ID'. */
5559 if (argc
== arg_base
+ 6)
5560 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5561 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5562 else if (argc
== arg_base
+ 7)
5564 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5565 adv_router
= ospf
->router_id
;
5568 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5572 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5579 DEFUN (show_ip_ospf_database
,
5580 show_ip_ospf_database_cmd
,
5581 "show ip ospf 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>]]]",
5584 "OSPF information\n"
5585 "Database summary\n"
5587 "Link State ID (as an IP address)\n"
5588 "Self-originated link states\n"
5589 "Advertising Router link states\n"
5590 "Advertising Router (as an IP address)\n")
5594 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5597 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5600 DEFUN (show_ip_ospf_database_max
,
5601 show_ip_ospf_database_max_cmd
,
5602 "show ip ospf database <max-age|self-originate>",
5605 "OSPF information\n"
5606 "Database summary\n"
5607 "LSAs in MaxAge list\n"
5608 "Self-originated link states\n")
5612 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5615 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5618 DEFUN (show_ip_ospf_instance_database
,
5619 show_ip_ospf_instance_database_cmd
,
5620 "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>]]]",
5623 "OSPF information\n"
5625 "Database summary\n"
5627 "Link State ID (as an IP address)\n"
5628 "Self-originated link states\n"
5629 "Advertising Router link states\n"
5630 "Advertising Router (as an IP address)\n")
5634 u_short instance
= 0;
5636 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5638 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5641 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5644 DEFUN (show_ip_ospf_instance_database_max
,
5645 show_ip_ospf_instance_database_max_cmd
,
5646 "show ip ospf (1-65535) database <max-age|self-originate>",
5649 "OSPF information\n"
5651 "Database summary\n"
5652 "LSAs in MaxAge list\n"
5653 "Self-originated link states\n")
5657 u_short instance
= 0;
5659 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5661 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5664 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5669 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5670 int arg_base
, int argc
, struct cmd_token
**argv
)
5674 struct in_addr adv_router
;
5677 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5680 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5681 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5683 if (argc
!= arg_base
+ 7)
5686 /* Set database type to show. */
5687 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5688 type
= OSPF_ROUTER_LSA
;
5689 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5690 type
= OSPF_NETWORK_LSA
;
5691 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5692 type
= OSPF_AS_NSSA_LSA
;
5693 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5694 type
= OSPF_SUMMARY_LSA
;
5695 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5696 type
= OSPF_ASBR_SUMMARY_LSA
;
5697 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5698 type
= OSPF_AS_EXTERNAL_LSA
;
5699 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5700 type
= OSPF_OPAQUE_LINK_LSA
;
5701 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5702 type
= OSPF_OPAQUE_AREA_LSA
;
5703 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5704 type
= OSPF_OPAQUE_AS_LSA
;
5708 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5709 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5710 adv_router
= ospf
->router_id
;
5713 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5718 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5723 DEFUN (show_ip_ospf_database_type_adv_router
,
5724 show_ip_ospf_database_type_adv_router_cmd
,
5725 "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>",
5728 "OSPF information\n"
5729 "Database summary\n"
5731 "Advertising Router link states\n"
5732 "Advertising Router (as an IP address)\n"
5733 "Self-originated link states\n")
5737 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5740 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5743 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5744 show_ip_ospf_instance_database_type_adv_router_cmd
,
5745 "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>",
5748 "OSPF information\n"
5750 "Database summary\n"
5752 "Advertising Router link states\n"
5753 "Advertising Router (as an IP address)\n")
5757 u_short instance
= 0;
5759 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5761 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5764 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5767 DEFUN (ip_ospf_authentication_args
,
5768 ip_ospf_authentication_args_addr_cmd
,
5769 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5771 "OSPF interface commands\n"
5772 "Enable authentication on this interface\n"
5773 "Use null authentication\n"
5774 "Use message-digest authentication\n"
5775 "Address of interface\n")
5777 int idx_encryption
= 3;
5779 struct interface
*ifp
;
5780 struct in_addr addr
;
5782 struct ospf_if_params
*params
;
5785 params
= IF_DEF_PARAMS (ifp
);
5789 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5792 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5797 params
= ospf_get_if_params (ifp
, addr
);
5798 ospf_if_update_params (ifp
, addr
);
5801 /* Handle null authentication */
5802 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5804 SET_IF_PARAM (params
, auth_type
);
5805 params
->auth_type
= OSPF_AUTH_NULL
;
5809 /* Handle message-digest authentication */
5810 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5812 SET_IF_PARAM (params
, auth_type
);
5813 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5817 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5821 DEFUN (ip_ospf_authentication
,
5822 ip_ospf_authentication_addr_cmd
,
5823 "ip ospf authentication [A.B.C.D]",
5825 "OSPF interface commands\n"
5826 "Enable authentication on this interface\n"
5827 "Address of interface")
5830 struct interface
*ifp
;
5831 struct in_addr addr
;
5833 struct ospf_if_params
*params
;
5836 params
= IF_DEF_PARAMS (ifp
);
5840 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5843 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5848 params
= ospf_get_if_params (ifp
, addr
);
5849 ospf_if_update_params (ifp
, addr
);
5852 SET_IF_PARAM (params
, auth_type
);
5853 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5858 DEFUN (no_ip_ospf_authentication_args
,
5859 no_ip_ospf_authentication_args_addr_cmd
,
5860 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5863 "OSPF interface commands\n"
5864 "Enable authentication on this interface\n"
5865 "Use null authentication\n"
5866 "Use message-digest authentication\n"
5867 "Address of interface")
5869 int idx_encryption
= 4;
5871 struct interface
*ifp
;
5872 struct in_addr addr
;
5874 struct ospf_if_params
*params
;
5875 struct route_node
*rn
;
5879 params
= IF_DEF_PARAMS (ifp
);
5883 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5886 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5891 params
= ospf_lookup_if_params (ifp
, addr
);
5894 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5897 params
->auth_type
= OSPF_AUTH_NOTSET
;
5898 UNSET_IF_PARAM (params
, auth_type
);
5899 if (params
!= IF_DEF_PARAMS (ifp
))
5901 ospf_free_if_params (ifp
, addr
);
5902 ospf_if_update_params (ifp
, addr
);
5907 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5909 auth_type
= OSPF_AUTH_NULL
;
5911 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5913 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5917 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5921 * Here we have a case where the user has entered
5922 * 'no ip ospf authentication (null | message_digest )'
5923 * we need to find if we have any ip addresses underneath it that
5924 * correspond to the associated type.
5926 if (params
->auth_type
== auth_type
)
5928 params
->auth_type
= OSPF_AUTH_NOTSET
;
5929 UNSET_IF_PARAM (params
, auth_type
);
5932 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5934 if ((params
= rn
->info
))
5936 if (params
->auth_type
== auth_type
)
5938 params
->auth_type
= OSPF_AUTH_NOTSET
;
5939 UNSET_IF_PARAM (params
, auth_type
);
5940 if (params
!= IF_DEF_PARAMS (ifp
))
5942 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5943 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5953 DEFUN (no_ip_ospf_authentication
,
5954 no_ip_ospf_authentication_addr_cmd
,
5955 "no ip ospf authentication [A.B.C.D]",
5958 "OSPF interface commands\n"
5959 "Enable authentication on this interface\n"
5960 "Address of interface")
5963 struct interface
*ifp
;
5964 struct in_addr addr
;
5966 struct ospf_if_params
*params
;
5967 struct route_node
*rn
;
5970 params
= IF_DEF_PARAMS (ifp
);
5974 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5977 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5982 params
= ospf_lookup_if_params (ifp
, addr
);
5985 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5989 params
->auth_type
= OSPF_AUTH_NOTSET
;
5990 UNSET_IF_PARAM (params
, auth_type
);
5991 if (params
!= IF_DEF_PARAMS (ifp
))
5993 ospf_free_if_params (ifp
, addr
);
5994 ospf_if_update_params (ifp
, addr
);
6000 * When a user enters 'no ip ospf authentication'
6001 * We should remove all authentication types from
6004 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6005 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6006 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6008 params
->auth_type
= OSPF_AUTH_NOTSET
;
6009 UNSET_IF_PARAM (params
, auth_type
);
6012 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6014 if ((params
= rn
->info
))
6017 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6018 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6019 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6021 params
->auth_type
= OSPF_AUTH_NOTSET
;
6022 UNSET_IF_PARAM (params
, auth_type
);
6023 if (params
!= IF_DEF_PARAMS (ifp
))
6025 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6026 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6037 DEFUN (ip_ospf_authentication_key
,
6038 ip_ospf_authentication_key_addr_cmd
,
6039 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6041 "OSPF interface commands\n"
6042 "Authentication password (key)\n"
6043 "The OSPF password (key)\n"
6044 "Address of interface")
6047 struct interface
*ifp
;
6048 struct in_addr addr
;
6049 struct ospf_if_params
*params
;
6052 params
= IF_DEF_PARAMS (ifp
);
6054 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6056 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6058 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6063 params
= ospf_get_if_params (ifp
, addr
);
6064 ospf_if_update_params (ifp
, addr
);
6067 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6068 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6069 SET_IF_PARAM (params
, auth_simple
);
6074 DEFUN_HIDDEN (ospf_authentication_key
,
6075 ospf_authentication_key_cmd
,
6076 "ospf authentication-key AUTH_KEY [A.B.C.D]",
6077 "OSPF interface commands\n"
6078 "Authentication password (key)\n"
6079 "The OSPF password (key)\n"
6080 "Address of interface\n")
6082 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
6085 DEFUN (no_ip_ospf_authentication_key
,
6086 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6087 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6090 "OSPF interface commands\n"
6091 "Authentication password (key)\n"
6092 "The OSPF password (key)")
6095 struct interface
*ifp
;
6096 struct in_addr addr
;
6097 struct ospf_if_params
*params
;
6099 params
= IF_DEF_PARAMS (ifp
);
6101 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6103 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6105 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6110 params
= ospf_lookup_if_params (ifp
, addr
);
6115 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6116 UNSET_IF_PARAM (params
, auth_simple
);
6118 if (params
!= IF_DEF_PARAMS (ifp
))
6120 ospf_free_if_params (ifp
, addr
);
6121 ospf_if_update_params (ifp
, addr
);
6127 DEFUN_HIDDEN (no_ospf_authentication_key
,
6128 no_ospf_authentication_key_authkey_addr_cmd
,
6129 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6131 "OSPF interface commands\n"
6132 "Authentication password (key)\n"
6133 "The OSPF password (key)")
6135 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
6138 DEFUN (ip_ospf_message_digest_key
,
6139 ip_ospf_message_digest_key_cmd
,
6140 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6142 "OSPF interface commands\n"
6143 "Message digest authentication password (key)\n"
6145 "Use MD5 algorithm\n"
6146 "The OSPF password (key)\n"
6147 "Address of interface\n")
6149 struct interface
*ifp
;
6150 struct crypt_key
*ck
;
6152 struct in_addr addr
;
6153 struct ospf_if_params
*params
;
6156 params
= IF_DEF_PARAMS (ifp
);
6159 argv_find (argv
, argc
, "(1-255)", &idx
);
6160 char *keyid
= argv
[idx
]->arg
;
6161 argv_find (argv
, argc
, "KEY", &idx
);
6162 char *cryptkey
= argv
[idx
]->arg
;
6164 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6166 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6168 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6173 params
= ospf_get_if_params (ifp
, addr
);
6174 ospf_if_update_params (ifp
, addr
);
6177 key_id
= strtol (keyid
, NULL
, 10);
6178 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6180 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6184 ck
= ospf_crypt_key_new ();
6185 ck
->key_id
= (u_char
) key_id
;
6186 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6187 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6189 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6190 SET_IF_PARAM (params
, auth_crypt
);
6195 DEFUN_HIDDEN (ospf_message_digest_key
,
6196 ospf_message_digest_key_cmd
,
6197 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6198 "OSPF interface commands\n"
6199 "Message digest authentication password (key)\n"
6201 "Use MD5 algorithm\n"
6202 "The OSPF password (key)\n"
6203 "Address of interface\n")
6205 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6208 DEFUN (no_ip_ospf_message_digest_key
,
6209 no_ip_ospf_message_digest_key_cmd
,
6210 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6213 "OSPF interface commands\n"
6214 "Message digest authentication password (key)\n"
6216 "Use MD5 algorithm\n"
6217 "The OSPF password (key)\n"
6218 "Address of interface\n")
6221 struct interface
*ifp
;
6222 struct crypt_key
*ck
;
6224 struct in_addr addr
;
6225 struct ospf_if_params
*params
;
6227 params
= IF_DEF_PARAMS (ifp
);
6229 argv_find (argv
, argc
, "(1-255)", &idx
);
6230 char *keyid
= argv
[idx
]->arg
;
6232 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6234 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6236 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6241 params
= ospf_lookup_if_params (ifp
, addr
);
6246 key_id
= strtol (keyid
, NULL
, 10);
6247 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6250 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6254 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6256 if (params
!= IF_DEF_PARAMS (ifp
))
6258 ospf_free_if_params (ifp
, addr
);
6259 ospf_if_update_params (ifp
, addr
);
6265 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6266 no_ospf_message_digest_key_cmd
,
6267 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6269 "OSPF interface commands\n"
6270 "Message digest authentication password (key)\n"
6272 "Address of interface")
6274 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6277 DEFUN (ip_ospf_cost
,
6279 "ip ospf cost (1-65535) [A.B.C.D]",
6281 "OSPF interface commands\n"
6284 "Address of interface\n")
6287 struct interface
*ifp
= vty
->index
;
6289 struct in_addr addr
;
6290 struct ospf_if_params
*params
;
6291 params
= IF_DEF_PARAMS (ifp
);
6294 char *coststr
= NULL
, *ifaddr
= NULL
;
6295 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6296 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6298 cost
= strtol (coststr
, NULL
, 10);
6302 if(!inet_aton(ifaddr
, &addr
))
6304 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6309 params
= ospf_get_if_params (ifp
, addr
);
6310 ospf_if_update_params (ifp
, addr
);
6313 SET_IF_PARAM (params
, output_cost_cmd
);
6314 params
->output_cost_cmd
= cost
;
6316 ospf_if_recalculate_output_cost (ifp
);
6321 DEFUN_HIDDEN (ospf_cost
,
6323 "ospf cost (1-65535) [A.B.C.D]",
6324 "OSPF interface commands\n"
6327 "Address of interface\n")
6329 return ip_ospf_cost (self
, vty
, argc
, argv
);
6332 DEFUN (no_ip_ospf_cost
,
6333 no_ip_ospf_cost_cmd
,
6334 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6336 "OSPF interface commands\n"
6338 "Address of interface")
6341 struct interface
*ifp
= vty
->index
;
6342 struct in_addr addr
;
6343 struct ospf_if_params
*params
;
6346 params
= IF_DEF_PARAMS (ifp
);
6349 char *ifaddr
= NULL
;
6350 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6352 /* According to the semantics we are mimicking "no ip ospf cost N" is
6353 * always treated as "no ip ospf cost" regardless of the actual value
6354 * of N already configured for the interface. Thus ignore cost. */
6358 if (!inet_aton(ifaddr
, &addr
))
6360 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6365 params
= ospf_lookup_if_params (ifp
, addr
);
6370 UNSET_IF_PARAM (params
, output_cost_cmd
);
6372 if (params
!= IF_DEF_PARAMS (ifp
))
6374 ospf_free_if_params (ifp
, addr
);
6375 ospf_if_update_params (ifp
, addr
);
6378 ospf_if_recalculate_output_cost (ifp
);
6383 DEFUN_HIDDEN (no_ospf_cost
,
6385 "no ospf cost [(1-65535)] [A.B.C.D]",
6387 "OSPF interface commands\n"
6390 "Address of interface\n")
6392 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6396 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6398 struct route_node
*rn
;
6399 struct ospf_neighbor
*nbr
;
6401 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6402 if ((nbr
= rn
->info
))
6404 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6405 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6406 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6407 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6412 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6413 const char *nbr_str
,
6414 const char *fast_hello_str
)
6416 struct interface
*ifp
= vty
->index
;
6419 struct in_addr addr
;
6421 struct ospf_if_params
*params
;
6422 struct ospf_interface
*oi
;
6423 struct route_node
*rn
;
6425 params
= IF_DEF_PARAMS (ifp
);
6429 ret
= inet_aton(nbr_str
, &addr
);
6432 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6437 params
= ospf_get_if_params (ifp
, addr
);
6438 ospf_if_update_params (ifp
, addr
);
6443 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6446 /* reset fast_hello too, just to be sure */
6447 UNSET_IF_PARAM (params
, fast_hello
);
6448 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6450 else if (fast_hello_str
)
6452 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6454 /* 1s dead-interval with sub-second hellos desired */
6455 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6456 SET_IF_PARAM (params
, fast_hello
);
6457 params
->fast_hello
= hellomult
;
6461 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6466 SET_IF_PARAM (params
, v_wait
);
6467 params
->v_wait
= seconds
;
6469 /* Update timer values in neighbor structure. */
6473 if ((ospf
= ospf_lookup()))
6475 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6477 ospf_nbr_timer_update (oi
);
6482 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6483 if ((oi
= rn
->info
))
6484 ospf_nbr_timer_update (oi
);
6490 DEFUN (ip_ospf_dead_interval
,
6491 ip_ospf_dead_interval_cmd
,
6492 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6494 "OSPF interface commands\n"
6495 "Interval time after which a neighbor is declared down\n"
6497 "Address of interface\n")
6500 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6501 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6502 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6506 DEFUN_HIDDEN (ospf_dead_interval
,
6507 ospf_dead_interval_cmd
,
6508 "ospf dead-interval (1-65535) [A.B.C.D]",
6509 "OSPF interface commands\n"
6510 "Interval time after which a neighbor is declared down\n"
6512 "Address of interface\n")
6514 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6517 DEFUN (ip_ospf_dead_interval_minimal
,
6518 ip_ospf_dead_interval_minimal_addr_cmd
,
6519 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6521 "OSPF interface commands\n"
6522 "Interval time after which a neighbor is declared down\n"
6523 "Minimal 1s dead-interval with fast sub-second hellos\n"
6524 "Hello multiplier factor\n"
6525 "Number of Hellos to send each second\n"
6526 "Address of interface\n")
6531 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6533 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6536 DEFUN (no_ip_ospf_dead_interval
,
6537 no_ip_ospf_dead_interval_cmd
,
6538 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6541 "OSPF interface commands\n"
6542 "Interval time after which a neighbor is declared down\n"
6544 "Address of interface")
6546 int idx_ipv4
= argc
- 1;
6547 struct interface
*ifp
= vty
->index
;
6548 struct in_addr addr
;
6550 struct ospf_if_params
*params
;
6551 struct ospf_interface
*oi
;
6552 struct route_node
*rn
;
6555 params
= IF_DEF_PARAMS (ifp
);
6557 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6559 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6562 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6567 params
= ospf_lookup_if_params (ifp
, addr
);
6572 UNSET_IF_PARAM (params
, v_wait
);
6573 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6575 UNSET_IF_PARAM (params
, fast_hello
);
6576 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6578 if (params
!= IF_DEF_PARAMS (ifp
))
6580 ospf_free_if_params (ifp
, addr
);
6581 ospf_if_update_params (ifp
, addr
);
6584 /* Update timer values in neighbor structure. */
6589 if ((ospf
= ospf_lookup()))
6591 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6593 ospf_nbr_timer_update (oi
);
6598 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6599 if ((oi
= rn
->info
))
6600 ospf_nbr_timer_update (oi
);
6606 DEFUN_HIDDEN (no_ospf_dead_interval
,
6607 no_ospf_dead_interval_cmd
,
6608 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6610 "OSPF interface commands\n"
6611 "Interval time after which a neighbor is declared down\n"
6613 "Address of interface")
6615 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6618 DEFUN (ip_ospf_hello_interval
,
6619 ip_ospf_hello_interval_cmd
,
6620 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6622 "OSPF interface commands\n"
6623 "Time between HELLO packets\n"
6625 "Address of interface\n")
6628 struct interface
*ifp
= vty
->index
;
6629 struct in_addr addr
;
6630 struct ospf_if_params
*params
;
6631 params
= IF_DEF_PARAMS (ifp
);
6632 u_int32_t seconds
= 0;
6634 argv_find (argv
, argc
, "(1-65535)", &idx
);
6635 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6637 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6639 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6641 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6646 params
= ospf_get_if_params (ifp
, addr
);
6647 ospf_if_update_params (ifp
, addr
);
6650 SET_IF_PARAM (params
, v_hello
);
6651 params
->v_hello
= seconds
;
6656 DEFUN_HIDDEN (ospf_hello_interval
,
6657 ospf_hello_interval_cmd
,
6658 "ospf hello-interval (1-65535) [A.B.C.D]",
6659 "OSPF interface commands\n"
6660 "Time between HELLO packets\n"
6662 "Address of interface\n")
6664 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6667 DEFUN (no_ip_ospf_hello_interval
,
6668 no_ip_ospf_hello_interval_cmd
,
6669 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6672 "OSPF interface commands\n"
6673 "Time between HELLO packets\n" // ignored
6675 "Address of interface\n")
6678 struct interface
*ifp
= vty
->index
;
6679 struct in_addr addr
;
6680 struct ospf_if_params
*params
;
6681 params
= IF_DEF_PARAMS (ifp
);
6683 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6685 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6687 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6692 params
= ospf_lookup_if_params (ifp
, addr
);
6697 UNSET_IF_PARAM (params
, v_hello
);
6698 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6700 if (params
!= IF_DEF_PARAMS (ifp
))
6702 ospf_free_if_params (ifp
, addr
);
6703 ospf_if_update_params (ifp
, addr
);
6709 DEFUN_HIDDEN (no_ospf_hello_interval
,
6710 no_ospf_hello_interval_cmd
,
6711 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6713 "OSPF interface commands\n"
6714 "Time between HELLO packets\n" // ignored
6716 "Address of interface\n")
6718 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6721 DEFUN (ip_ospf_network
,
6722 ip_ospf_network_cmd
,
6723 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6725 "OSPF interface commands\n"
6727 "Specify OSPF broadcast multi-access network\n"
6728 "Specify OSPF NBMA network\n"
6729 "Specify OSPF point-to-multipoint network\n"
6730 "Specify OSPF point-to-point network\n")
6733 struct interface
*ifp
= vty
->index
;
6734 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6735 struct route_node
*rn
;
6737 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6739 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6743 if (argv_find (argv
, argc
, "broadcast", &idx
))
6744 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6745 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6746 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6747 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6748 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6749 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6750 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6752 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6755 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6757 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6759 struct ospf_interface
*oi
= rn
->info
;
6764 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6766 if (oi
->state
> ISM_Down
)
6768 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6769 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6776 DEFUN_HIDDEN (ospf_network
,
6778 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6779 "OSPF interface commands\n"
6781 "Specify OSPF broadcast multi-access network\n"
6782 "Specify OSPF NBMA network\n"
6783 "Specify OSPF point-to-multipoint network\n"
6784 "Specify OSPF point-to-point network\n")
6786 return ip_ospf_network (self
, vty
, argc
, argv
);
6789 DEFUN (no_ip_ospf_network
,
6790 no_ip_ospf_network_cmd
,
6791 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6794 "OSPF interface commands\n"
6796 "Specify OSPF broadcast multi-access network\n"
6797 "Specify OSPF NBMA network\n"
6798 "Specify OSPF point-to-multipoint network\n"
6799 "Specify OSPF point-to-point network\n")
6801 struct interface
*ifp
= vty
->index
;
6802 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6803 struct route_node
*rn
;
6805 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6807 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6810 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6812 struct ospf_interface
*oi
= rn
->info
;
6817 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6819 if (oi
->state
> ISM_Down
)
6821 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6822 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6829 DEFUN_HIDDEN (no_ospf_network
,
6830 no_ospf_network_cmd
,
6831 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6833 "OSPF interface commands\n"
6835 "Specify OSPF broadcast multi-access network\n"
6836 "Specify OSPF NBMA network\n"
6837 "Specify OSPF point-to-multipoint network\n"
6838 "Specify OSPF point-to-point network\n")
6840 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6843 DEFUN (ip_ospf_priority
,
6844 ip_ospf_priority_cmd
,
6845 "ip ospf priority (0-255) [A.B.C.D]",
6847 "OSPF interface commands\n"
6850 "Address of interface")
6853 struct interface
*ifp
= vty
->index
;
6855 struct route_node
*rn
;
6856 struct in_addr addr
;
6857 struct ospf_if_params
*params
;
6858 params
= IF_DEF_PARAMS (ifp
);
6860 argv_find (argv
, argc
, "(0-255)", &idx
);
6861 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6863 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6865 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6867 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6872 params
= ospf_get_if_params (ifp
, addr
);
6873 ospf_if_update_params (ifp
, addr
);
6876 SET_IF_PARAM (params
, priority
);
6877 params
->priority
= priority
;
6879 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6881 struct ospf_interface
*oi
= rn
->info
;
6886 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6888 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6889 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6896 DEFUN_HIDDEN (ospf_priority
,
6898 "ospf priority (0-255) [A.B.C.D]",
6899 "OSPF interface commands\n"
6903 return ip_ospf_priority (self
, vty
, argc
, argv
);
6906 DEFUN (no_ip_ospf_priority
,
6907 no_ip_ospf_priority_cmd
,
6908 "no ip ospf priority [(0-255) [A.B.C.D]]",
6911 "OSPF interface commands\n"
6912 "Router priority\n" // ignored
6914 "Address of interface")
6917 struct interface
*ifp
= vty
->index
;
6918 struct route_node
*rn
;
6919 struct in_addr addr
;
6920 struct ospf_if_params
*params
;
6923 params
= IF_DEF_PARAMS (ifp
);
6925 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6927 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6929 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6934 params
= ospf_lookup_if_params (ifp
, addr
);
6939 UNSET_IF_PARAM (params
, priority
);
6940 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6942 if (params
!= IF_DEF_PARAMS (ifp
))
6944 ospf_free_if_params (ifp
, addr
);
6945 ospf_if_update_params (ifp
, addr
);
6948 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6950 struct ospf_interface
*oi
= rn
->info
;
6955 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6957 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6958 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6965 DEFUN_HIDDEN (no_ospf_priority
,
6966 no_ospf_priority_cmd
,
6967 "no ospf priority [(0-255) [A.B.C.D]]",
6969 "OSPF interface commands\n"
6972 "Address of interface")
6974 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6977 DEFUN (ip_ospf_retransmit_interval
,
6978 ip_ospf_retransmit_interval_addr_cmd
,
6979 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6981 "OSPF interface commands\n"
6982 "Time between retransmitting lost link state advertisements\n"
6984 "Address of interface")
6987 struct interface
*ifp
= vty
->index
;
6989 struct in_addr addr
;
6990 struct ospf_if_params
*params
;
6991 params
= IF_DEF_PARAMS (ifp
);
6993 argv_find (argv
, argc
, "(3-65535)", &idx
);
6994 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6996 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6998 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7000 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7005 params
= ospf_get_if_params (ifp
, addr
);
7006 ospf_if_update_params (ifp
, addr
);
7009 SET_IF_PARAM (params
, retransmit_interval
);
7010 params
->retransmit_interval
= seconds
;
7015 DEFUN_HIDDEN (ospf_retransmit_interval
,
7016 ospf_retransmit_interval_cmd
,
7017 "ospf retransmit-interval (3-65535) [A.B.C.D]",
7018 "OSPF interface commands\n"
7019 "Time between retransmitting lost link state advertisements\n"
7022 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
7025 DEFUN (no_ip_ospf_retransmit_interval
,
7026 no_ip_ospf_retransmit_interval_addr_cmd
,
7027 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7030 "OSPF interface commands\n"
7031 "Time between retransmitting lost link state advertisements\n" //ignored
7032 "Address of interface\n")
7035 struct interface
*ifp
= vty
->index
;
7036 struct in_addr addr
;
7037 struct ospf_if_params
*params
;
7040 params
= IF_DEF_PARAMS (ifp
);
7042 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7044 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7046 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7051 params
= ospf_lookup_if_params (ifp
, addr
);
7056 UNSET_IF_PARAM (params
, retransmit_interval
);
7057 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7059 if (params
!= IF_DEF_PARAMS (ifp
))
7061 ospf_free_if_params (ifp
, addr
);
7062 ospf_if_update_params (ifp
, addr
);
7068 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
7069 no_ospf_retransmit_interval_cmd
,
7070 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7072 "OSPF interface commands\n"
7073 "Time between retransmitting lost link state advertisements\n")
7075 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
7078 DEFUN (ip_ospf_transmit_delay
,
7079 ip_ospf_transmit_delay_addr_cmd
,
7080 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7082 "OSPF interface commands\n"
7083 "Link state transmit delay\n"
7085 "Address of interface")
7088 struct interface
*ifp
= vty
->index
;
7090 struct in_addr addr
;
7091 struct ospf_if_params
*params
;
7093 params
= IF_DEF_PARAMS (ifp
);
7094 argv_find (argv
, argc
, "(1-65535)", &idx
);
7095 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
7097 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7099 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7101 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7106 params
= ospf_get_if_params (ifp
, addr
);
7107 ospf_if_update_params (ifp
, addr
);
7110 SET_IF_PARAM (params
, transmit_delay
);
7111 params
->transmit_delay
= seconds
;
7116 DEFUN_HIDDEN (ospf_transmit_delay
,
7117 ospf_transmit_delay_cmd
,
7118 "ospf transmit-delay (1-65535) [A.B.C.D]",
7119 "OSPF interface commands\n"
7120 "Link state transmit delay\n"
7123 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
7126 DEFUN (no_ip_ospf_transmit_delay
,
7127 no_ip_ospf_transmit_delay_addr_cmd
,
7128 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
7131 "OSPF interface commands\n"
7132 "Link state transmit delay\n"
7133 "Address of interface")
7136 struct interface
*ifp
= vty
->index
;
7137 struct in_addr addr
;
7138 struct ospf_if_params
*params
;
7141 params
= IF_DEF_PARAMS (ifp
);
7143 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7145 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7147 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7152 params
= ospf_lookup_if_params (ifp
, addr
);
7157 UNSET_IF_PARAM (params
, transmit_delay
);
7158 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7160 if (params
!= IF_DEF_PARAMS (ifp
))
7162 ospf_free_if_params (ifp
, addr
);
7163 ospf_if_update_params (ifp
, addr
);
7170 DEFUN_HIDDEN (no_ospf_transmit_delay
,
7171 no_ospf_transmit_delay_cmd
,
7172 "no ospf transmit-delay",
7174 "OSPF interface commands\n"
7175 "Link state transmit delay\n")
7177 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
7180 DEFUN (ip_ospf_area
,
7182 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7184 "OSPF interface commands\n"
7186 "Enable OSPF on this interface\n"
7187 "OSPF area ID in IP address format\n"
7188 "OSPF area ID as a decimal value\n")
7191 struct interface
*ifp
= vty
->index
;
7193 struct in_addr area_id
;
7195 struct ospf_if_params
*params
;
7196 struct route_node
*rn
;
7197 u_short instance
= 0;
7199 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7200 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7201 char *areaid
= argv
[argc
- 1]->arg
;
7203 ospf
= ospf_lookup_instance (instance
);
7206 params
= IF_DEF_PARAMS (ifp
);
7207 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7209 ospf_interface_unset (ifp
);
7210 ospf
= ospf_lookup();
7211 ospf
->if_ospf_cli_count
--;
7216 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7219 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7223 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7225 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7229 params
= IF_DEF_PARAMS (ifp
);
7230 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7233 "Must remove previous area config before changing ospf area %s",
7238 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7240 if (rn
->info
!= NULL
)
7242 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7247 /* enable ospf on this interface with area_id */
7248 ospf_interface_set (ifp
, area_id
);
7249 ospf
->if_ospf_cli_count
++;
7254 DEFUN (no_ip_ospf_area
,
7255 no_ip_ospf_area_cmd
,
7256 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7259 "OSPF interface commands\n"
7260 "Disable OSPF on this interface\n"
7261 "OSPF area ID in IP address format\n"
7262 "OSPF area ID as a decimal value\n")
7265 struct interface
*ifp
= vty
->index
;
7267 struct ospf_if_params
*params
;
7268 u_short instance
= 0;
7270 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7271 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7273 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7276 params
= IF_DEF_PARAMS (ifp
);
7277 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7279 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7283 ospf_interface_unset (ifp
);
7284 ospf
->if_ospf_cli_count
--;
7288 DEFUN (ospf_redistribute_source
,
7289 ospf_redistribute_source_cmd
,
7290 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7292 QUAGGA_REDIST_HELP_STR_OSPFD
7293 "Metric for redistributed routes\n"
7294 "OSPF default metric\n"
7295 "OSPF exterior metric type for redistributed routes\n"
7296 "Set OSPF External Type 1 metrics\n"
7297 "Set OSPF External Type 2 metrics\n"
7298 "Route map reference\n"
7299 "Pointer to route-map entries\n")
7301 int idx_protocol
= 1;
7302 int idx_redist_param
= 2;
7303 struct ospf
*ospf
= vty
->index
;
7307 struct ospf_redist
*red
;
7313 return CMD_WARNING
; /* should not happen */
7318 /* Get distribute source. */
7319 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
7320 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7323 /* Get metric value. */
7324 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7325 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7328 /* Get metric type. */
7329 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7330 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7333 red
= ospf_redist_add(ospf
, source
, 0);
7335 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7336 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7338 ospf_routemap_unset (red
);
7340 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7343 DEFUN (no_ospf_redistribute_source
,
7344 no_ospf_redistribute_source_cmd
,
7345 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7348 QUAGGA_REDIST_HELP_STR_OSPFD
7349 "Metric for redistributed routes\n"
7350 "OSPF default metric\n"
7351 "OSPF exterior metric type for redistributed 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 int idx_protocol
= 2;
7358 struct ospf
*ospf
= vty
->index
;
7360 struct ospf_redist
*red
;
7364 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
7365 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7368 red
= ospf_redist_lookup(ospf
, source
, 0);
7372 ospf_routemap_unset (red
);
7373 return ospf_redistribute_unset (ospf
, source
, 0);
7376 DEFUN (ospf_redistribute_instance_source
,
7377 ospf_redistribute_instance_source_cmd
,
7378 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7380 "Open Shortest Path First\n"
7381 "Non-main Kernel Routing Table\n"
7382 "Instance ID/Table ID\n"
7383 "Metric for redistributed routes\n"
7384 "OSPF default metric\n"
7385 "OSPF exterior metric type for redistributed routes\n"
7386 "Set OSPF External Type 1 metrics\n"
7387 "Set OSPF External Type 2 metrics\n"
7388 "Route map reference\n"
7389 "Pointer to route-map entries\n")
7391 int idx_ospf_table
= 1;
7393 int idx_redist_param
= 3;
7394 struct ospf
*ospf
= vty
->index
;
7399 struct ospf_redist
*red
;
7404 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7405 source
= ZEBRA_ROUTE_OSPF
;
7407 source
= ZEBRA_ROUTE_TABLE
;
7409 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7414 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7416 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7421 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7423 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7428 /* Get metric value. */
7429 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7430 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7433 /* Get metric type. */
7434 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7435 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7438 red
= ospf_redist_add(ospf
, source
, instance
);
7440 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7441 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7443 ospf_routemap_unset (red
);
7445 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7448 DEFUN (no_ospf_redistribute_instance_source
,
7449 no_ospf_redistribute_instance_source_cmd
,
7450 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7453 "Open Shortest Path First\n"
7454 "Non-main Kernel Routing Table\n"
7455 "Instance ID/Table Id\n"
7456 "Metric for redistributed routes\n"
7457 "OSPF default metric\n"
7458 "OSPF exterior metric type for redistributed routes\n"
7459 "Set OSPF External Type 1 metrics\n"
7460 "Set OSPF External Type 2 metrics\n"
7461 "Route map reference\n"
7462 "Pointer to route-map entries\n")
7464 int idx_ospf_table
= 2;
7466 struct ospf
*ospf
= vty
->index
;
7468 struct ospf_redist
*red
;
7474 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7475 source
= ZEBRA_ROUTE_OSPF
;
7477 source
= ZEBRA_ROUTE_TABLE
;
7479 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7481 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7483 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7488 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7490 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7495 red
= ospf_redist_lookup(ospf
, source
, instance
);
7499 ospf_routemap_unset (red
);
7500 return ospf_redistribute_unset (ospf
, source
, instance
);
7503 DEFUN (ospf_distribute_list_out
,
7504 ospf_distribute_list_out_cmd
,
7505 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7506 "Filter networks in routing updates\n"
7507 "Access-list name\n"
7509 QUAGGA_REDIST_HELP_STR_OSPFD
)
7512 struct ospf
*ospf
= vty
->index
;
7518 /* Get distribute source. */
7519 source
= proto_redistnum(AFI_IP
, argv
[4]->arg
);
7520 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7523 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7526 DEFUN (no_ospf_distribute_list_out
,
7527 no_ospf_distribute_list_out_cmd
,
7528 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7530 "Filter networks in routing updates\n"
7531 "Access-list name\n"
7533 QUAGGA_REDIST_HELP_STR_OSPFD
)
7536 struct ospf
*ospf
= vty
->index
;
7542 source
= proto_redistnum(AFI_IP
, argv
[5]->arg
);
7543 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7546 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7549 /* Default information originate. */
7550 DEFUN (ospf_default_information_originate
,
7551 ospf_default_information_originate_cmd
,
7552 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7553 "Control distribution of default information\n"
7554 "Distribute a default route\n"
7555 "Always advertise default route\n"
7556 "OSPF default metric\n"
7558 "OSPF metric type for default routes\n"
7559 "Set OSPF External Type 1 metrics\n"
7560 "Set OSPF External Type 2 metrics\n"
7561 "Route map reference\n"
7562 "Pointer to route-map entries\n")
7564 int idx_redist_param
= 2;
7565 struct ospf
*ospf
= vty
->index
;
7566 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7569 struct ospf_redist
*red
;
7575 return CMD_WARNING
; /* this should not happen */
7577 /* Check whether "always" was specified */
7578 if (argv
[idx_redist_param
]->arg
!= NULL
)
7579 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7581 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7583 /* Get metric value. */
7584 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7585 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7588 /* Get metric type. */
7589 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7590 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7593 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7594 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7596 ospf_routemap_unset (red
);
7598 return ospf_redistribute_default_set (ospf
, default_originate
,
7602 DEFUN (no_ospf_default_information_originate
,
7603 no_ospf_default_information_originate_cmd
,
7604 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7606 "Control distribution of default information\n"
7607 "Distribute a default route\n"
7608 "Always advertise default route\n"
7609 "OSPF default metric\n"
7611 "OSPF metric type for default routes\n"
7612 "Set OSPF External Type 1 metrics\n"
7613 "Set OSPF External Type 2 metrics\n"
7614 "Route map reference\n"
7615 "Pointer to route-map entries\n")
7617 struct ospf
*ospf
= vty
->index
;
7618 struct prefix_ipv4 p
;
7619 struct ospf_external
*ext
;
7620 struct ospf_redist
*red
;
7626 p
.prefix
.s_addr
= 0;
7629 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7631 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7632 EXTERNAL_INFO (ext
)) {
7633 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7634 ospf_external_del (DEFAULT_ROUTE
, 0);
7637 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7641 ospf_routemap_unset (red
);
7642 return ospf_redistribute_default_unset (ospf
);
7645 DEFUN (ospf_default_metric
,
7646 ospf_default_metric_cmd
,
7647 "default-metric (0-16777214)",
7648 "Set metric of redistributed routes\n"
7652 struct ospf
*ospf
= vty
->index
;
7658 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7661 ospf
->default_metric
= metric
;
7666 DEFUN (no_ospf_default_metric
,
7667 no_ospf_default_metric_cmd
,
7668 "no default-metric [(0-16777214)]",
7670 "Set metric of redistributed routes\n"
7673 struct ospf
*ospf
= vty
->index
;
7678 ospf
->default_metric
= -1;
7684 DEFUN (ospf_distance
,
7687 "Define an administrative distance\n"
7688 "OSPF Administrative distance\n")
7691 struct ospf
*ospf
= vty
->index
;
7696 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7701 DEFUN (no_ospf_distance
,
7702 no_ospf_distance_cmd
,
7703 "no distance (1-255)",
7705 "Define an administrative distance\n"
7706 "OSPF Administrative distance\n")
7708 struct ospf
*ospf
= vty
->index
;
7713 ospf
->distance_all
= 0;
7718 DEFUN (no_ospf_distance_ospf
,
7719 no_ospf_distance_ospf_cmd
,
7720 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7722 "Define an administrative distance\n"
7723 "OSPF Administrative distance\n"
7724 "Intra-area routes\n"
7725 "Distance for intra-area routes\n"
7726 "Inter-area routes\n"
7727 "Distance for inter-area routes\n"
7729 "Distance for external routes\n")
7731 int idx_area_distance
= 3;
7732 struct ospf
*ospf
= vty
->index
;
7743 if (argv
[idx_area_distance
]->arg
!= NULL
)
7744 ospf
->distance_intra
= 0;
7746 if (argv
[1] != NULL
)
7747 ospf
->distance_inter
= 0;
7749 if (argv
[2] != NULL
)
7750 ospf
->distance_external
= 0;
7752 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
7755 /* If no arguments are given, clear all distance information */
7756 ospf
->distance_intra
= 0;
7757 ospf
->distance_inter
= 0;
7758 ospf
->distance_external
= 0;
7763 DEFUN (ospf_distance_ospf
,
7764 ospf_distance_ospf_cmd
,
7765 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7766 "Define an administrative distance\n"
7767 "OSPF Administrative distance\n"
7768 "Intra-area routes\n"
7769 "Distance for intra-area routes\n"
7770 "Inter-area routes\n"
7771 "Distance for inter-area routes\n"
7773 "Distance for external routes\n")
7775 int idx_area_distance
= 2;
7776 struct ospf
*ospf
= vty
->index
;
7781 if (argc
< 3) /* should not happen */
7784 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
7786 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
7791 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
7792 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
7794 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
7795 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
7797 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
7798 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
7803 DEFUN (ospf_distance_source
,
7804 ospf_distance_source_cmd
,
7805 "distance (1-255) A.B.C.D/M",
7806 "Administrative distance\n"
7808 "IP source prefix\n")
7811 int idx_ipv4_prefixlen
= 2;
7812 struct ospf
*ospf
= vty
->index
;
7817 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7822 DEFUN (no_ospf_distance_source
,
7823 no_ospf_distance_source_cmd
,
7824 "no distance (1-255) A.B.C.D/M",
7826 "Administrative distance\n"
7828 "IP source prefix\n")
7831 int idx_ipv4_prefixlen
= 3;
7832 struct ospf
*ospf
= vty
->index
;
7837 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7842 DEFUN (ospf_distance_source_access_list
,
7843 ospf_distance_source_access_list_cmd
,
7844 "distance (1-255) A.B.C.D/M WORD",
7845 "Administrative distance\n"
7847 "IP source prefix\n"
7848 "Access list name\n")
7851 int idx_ipv4_prefixlen
= 2;
7853 struct ospf
*ospf
= vty
->index
;
7858 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7863 DEFUN (no_ospf_distance_source_access_list
,
7864 no_ospf_distance_source_access_list_cmd
,
7865 "no distance (1-255) A.B.C.D/M WORD",
7867 "Administrative distance\n"
7869 "IP source prefix\n"
7870 "Access list name\n")
7873 int idx_ipv4_prefixlen
= 3;
7875 struct ospf
*ospf
= vty
->index
;
7880 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7885 DEFUN (ip_ospf_mtu_ignore
,
7886 ip_ospf_mtu_ignore_addr_cmd
,
7887 "ip ospf mtu-ignore [A.B.C.D]",
7889 "OSPF interface commands\n"
7890 "Disable MTU mismatch detection on this interface\n"
7891 "Address of interface")
7894 struct interface
*ifp
= vty
->index
;
7895 struct in_addr addr
;
7898 struct ospf_if_params
*params
;
7899 params
= IF_DEF_PARAMS (ifp
);
7903 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7906 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7910 params
= ospf_get_if_params (ifp
, addr
);
7911 ospf_if_update_params (ifp
, addr
);
7913 params
->mtu_ignore
= 1;
7914 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7915 SET_IF_PARAM (params
, mtu_ignore
);
7918 UNSET_IF_PARAM (params
, mtu_ignore
);
7919 if (params
!= IF_DEF_PARAMS (ifp
))
7921 ospf_free_if_params (ifp
, addr
);
7922 ospf_if_update_params (ifp
, addr
);
7928 DEFUN (no_ip_ospf_mtu_ignore
,
7929 no_ip_ospf_mtu_ignore_addr_cmd
,
7930 "no ip ospf mtu-ignore [A.B.C.D]",
7932 "OSPF interface commands\n"
7933 "Disable MTU mismatch detection on this interface\n"
7934 "Address of interface")
7937 struct interface
*ifp
= vty
->index
;
7938 struct in_addr addr
;
7941 struct ospf_if_params
*params
;
7942 params
= IF_DEF_PARAMS (ifp
);
7946 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7949 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7953 params
= ospf_get_if_params (ifp
, addr
);
7954 ospf_if_update_params (ifp
, addr
);
7956 params
->mtu_ignore
= 0;
7957 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7958 SET_IF_PARAM (params
, mtu_ignore
);
7961 UNSET_IF_PARAM (params
, mtu_ignore
);
7962 if (params
!= IF_DEF_PARAMS (ifp
))
7964 ospf_free_if_params (ifp
, addr
);
7965 ospf_if_update_params (ifp
, addr
);
7972 DEFUN (ospf_max_metric_router_lsa_admin
,
7973 ospf_max_metric_router_lsa_admin_cmd
,
7974 "max-metric router-lsa administrative",
7975 "OSPF maximum / infinite-distance metric\n"
7976 "Advertise own Router-LSA with infinite distance (stub router)\n"
7977 "Administratively applied, for an indefinite period\n")
7979 struct listnode
*ln
;
7980 struct ospf_area
*area
;
7981 struct ospf
*ospf
= vty
->index
;
7986 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7988 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7990 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7991 ospf_router_lsa_update_area (area
);
7994 /* Allows for areas configured later to get the property */
7995 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8000 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8001 no_ospf_max_metric_router_lsa_admin_cmd
,
8002 "no max-metric router-lsa administrative",
8004 "OSPF maximum / infinite-distance metric\n"
8005 "Advertise own Router-LSA with infinite distance (stub router)\n"
8006 "Administratively applied, for an indefinite period\n")
8008 struct listnode
*ln
;
8009 struct ospf_area
*area
;
8010 struct ospf
*ospf
= vty
->index
;
8015 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8017 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8019 /* Don't trample on the start-up stub timer */
8020 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8021 && !area
->t_stub_router
)
8023 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8024 ospf_router_lsa_update_area (area
);
8027 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8031 DEFUN (ospf_max_metric_router_lsa_startup
,
8032 ospf_max_metric_router_lsa_startup_cmd
,
8033 "max-metric router-lsa on-startup (5-86400)",
8034 "OSPF maximum / infinite-distance metric\n"
8035 "Advertise own Router-LSA with infinite distance (stub router)\n"
8036 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8037 "Time (seconds) to advertise self as stub-router\n")
8040 unsigned int seconds
;
8041 struct ospf
*ospf
= vty
->index
;
8048 vty_out (vty
, "%% Must supply stub-router period");
8052 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
8054 ospf
->stub_router_startup_time
= seconds
;
8059 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8060 no_ospf_max_metric_router_lsa_startup_cmd
,
8061 "no max-metric router-lsa on-startup [(5-86400)]",
8063 "OSPF maximum / infinite-distance metric\n"
8064 "Advertise own Router-LSA with infinite distance (stub router)\n"
8065 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8066 "Time (seconds) to advertise self as stub-router\n")
8068 struct listnode
*ln
;
8069 struct ospf_area
*area
;
8070 struct ospf
*ospf
= vty
->index
;
8075 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8077 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8079 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8080 OSPF_TIMER_OFF (area
->t_stub_router
);
8082 /* Don't trample on admin stub routed */
8083 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8085 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8086 ospf_router_lsa_update_area (area
);
8093 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8094 ospf_max_metric_router_lsa_shutdown_cmd
,
8095 "max-metric router-lsa on-shutdown (5-100)",
8096 "OSPF maximum / infinite-distance metric\n"
8097 "Advertise own Router-LSA with infinite distance (stub router)\n"
8098 "Advertise stub-router prior to full shutdown of OSPF\n"
8099 "Time (seconds) to wait till full shutdown\n")
8102 unsigned int seconds
;
8103 struct ospf
*ospf
= vty
->index
;
8110 vty_out (vty
, "%% Must supply stub-router shutdown period");
8114 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
8116 ospf
->stub_router_shutdown_time
= seconds
;
8121 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8122 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8123 "no max-metric router-lsa on-shutdown [(5-100)]",
8125 "OSPF maximum / infinite-distance metric\n"
8126 "Advertise own Router-LSA with infinite distance (stub router)\n"
8127 "Advertise stub-router prior to full shutdown of OSPF\n"
8128 "Time (seconds) to wait till full shutdown\n")
8130 struct ospf
*ospf
= vty
->index
;
8135 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8141 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8143 struct listnode
*ln
;
8144 struct ospf_area
*area
;
8146 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8147 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8148 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8149 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8150 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8151 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8152 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8154 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8156 vty_out (vty
, " max-metric router-lsa administrative%s",
8165 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8167 struct route_node
*rn
;
8168 struct ospf_route
*or;
8169 struct listnode
*pnode
, *pnnode
;
8170 struct ospf_path
*path
;
8172 vty_out (vty
, "============ OSPF network routing table ============%s",
8175 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8176 if ((or = rn
->info
) != NULL
)
8179 snprintf (buf1
, 19, "%s/%d",
8180 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8182 switch (or->path_type
)
8184 case OSPF_PATH_INTER_AREA
:
8185 if (or->type
== OSPF_DESTINATION_NETWORK
)
8186 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8187 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8188 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8189 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8191 case OSPF_PATH_INTRA_AREA
:
8192 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8193 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8199 if (or->type
== OSPF_DESTINATION_NETWORK
)
8200 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8202 if (if_lookup_by_index(path
->ifindex
))
8204 if (path
->nexthop
.s_addr
== 0)
8205 vty_out (vty
, "%24s directly attached to %s%s",
8206 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8208 vty_out (vty
, "%24s via %s, %s%s", "",
8209 inet_ntoa (path
->nexthop
),
8210 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8214 vty_out (vty
, "%s", VTY_NEWLINE
);
8218 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
8220 struct route_node
*rn
;
8221 struct ospf_route
*or;
8222 struct listnode
*pnode
;
8223 struct listnode
*node
;
8224 struct ospf_path
*path
;
8226 vty_out (vty
, "============ OSPF router routing table =============%s",
8228 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
8233 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
8235 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
8238 vty_out (vty
, "%24s", "");
8241 vty_out (vty
, "%s [%d] area: %s",
8242 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
8243 or->cost
, inet_ntoa (or->u
.std
.area_id
));
8245 vty_out (vty
, "%s%s%s",
8246 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
8247 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
8250 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8252 if (if_lookup_by_index(path
->ifindex
))
8254 if (path
->nexthop
.s_addr
== 0)
8255 vty_out (vty
, "%24s directly attached to %s%s",
8256 "", ifindex2ifname (path
->ifindex
),
8259 vty_out (vty
, "%24s via %s, %s%s", "",
8260 inet_ntoa (path
->nexthop
),
8261 ifindex2ifname (path
->ifindex
),
8267 vty_out (vty
, "%s", VTY_NEWLINE
);
8271 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8273 struct route_node
*rn
;
8274 struct ospf_route
*er
;
8275 struct listnode
*pnode
, *pnnode
;
8276 struct ospf_path
*path
;
8278 vty_out (vty
, "============ OSPF external routing table ===========%s",
8280 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8281 if ((er
= rn
->info
) != NULL
)
8284 snprintf (buf1
, 19, "%s/%d",
8285 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8287 switch (er
->path_type
)
8289 case OSPF_PATH_TYPE1_EXTERNAL
:
8290 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8291 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8293 case OSPF_PATH_TYPE2_EXTERNAL
:
8294 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8295 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8299 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8301 if (if_lookup_by_index(path
->ifindex
))
8303 if (path
->nexthop
.s_addr
== 0)
8304 vty_out (vty
, "%24s directly attached to %s%s",
8305 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8307 vty_out (vty
, "%24s via %s, %s%s", "",
8308 inet_ntoa (path
->nexthop
),
8309 ifindex2ifname (path
->ifindex
),
8314 vty_out (vty
, "%s", VTY_NEWLINE
);
8318 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8321 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8322 VTY_NEWLINE
, VTY_NEWLINE
);
8324 if (ospf
->new_table
== NULL
)
8326 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8330 /* Show Network routes.
8331 show_ip_ospf_route_network (vty, ospf->new_table); */
8333 /* Show Router routes. */
8334 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8336 vty_out (vty
, "%s", VTY_NEWLINE
);
8341 DEFUN (show_ip_ospf_border_routers
,
8342 show_ip_ospf_border_routers_cmd
,
8343 "show ip ospf border-routers",
8346 "OSPF information\n"
8347 "Show all the ABR's and ASBR's\n")
8351 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8354 return show_ip_ospf_border_routers_common(vty
, ospf
);
8357 DEFUN (show_ip_ospf_instance_border_routers
,
8358 show_ip_ospf_instance_border_routers_cmd
,
8359 "show ip ospf (1-65535) border-routers",
8362 "OSPF information\n"
8364 "Show all the ABR's and ASBR's\n")
8368 u_short instance
= 0;
8370 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8371 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8374 return show_ip_ospf_border_routers_common(vty
, ospf
);
8378 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8381 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8382 VTY_NEWLINE
, VTY_NEWLINE
);
8384 if (ospf
->new_table
== NULL
)
8386 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8390 /* Show Network routes. */
8391 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8393 /* Show Router routes. */
8394 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8396 /* Show AS External routes. */
8397 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8399 vty_out (vty
, "%s", VTY_NEWLINE
);
8404 DEFUN (show_ip_ospf_route
,
8405 show_ip_ospf_route_cmd
,
8406 "show ip ospf route",
8409 "OSPF information\n"
8410 "OSPF routing table\n")
8414 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8417 return show_ip_ospf_route_common(vty
, ospf
);
8420 DEFUN (show_ip_ospf_instance_route
,
8421 show_ip_ospf_instance_route_cmd
,
8422 "show ip ospf (1-65535) route",
8425 "OSPF information\n"
8427 "OSPF routing table\n")
8431 u_short instance
= 0;
8433 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8434 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8437 return show_ip_ospf_route_common(vty
, ospf
);
8440 const char *ospf_abr_type_str
[] =
8449 const char *ospf_shortcut_mode_str
[] =
8458 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8460 memset (buf
, 0, length
);
8462 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8463 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8465 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8469 const char *ospf_int_type_str
[] =
8471 "unknown", /* should never be used. */
8475 "point-to-multipoint",
8476 "virtual-link", /* should never be used. */
8480 /* Configuration write function for ospfd. */
8482 config_write_interface (struct vty
*vty
)
8484 struct listnode
*n1
, *n2
;
8485 struct interface
*ifp
;
8486 struct crypt_key
*ck
;
8488 struct route_node
*rn
= NULL
;
8489 struct ospf_if_params
*params
;
8490 struct ospf
*ospf
= ospf_lookup();
8492 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8494 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8497 if (ifp
->ifindex
== IFINDEX_DELETED
)
8500 vty_out (vty
, "!%s", VTY_NEWLINE
);
8501 vty_out (vty
, "interface %s%s", ifp
->name
,
8504 vty_out (vty
, " description %s%s", ifp
->desc
,
8509 params
= IF_DEF_PARAMS (ifp
);
8512 /* Interface Network print. */
8513 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8514 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8516 if (params
->type
!= ospf_default_iftype(ifp
))
8518 vty_out (vty
, " ip ospf network %s",
8519 ospf_int_type_str
[params
->type
]);
8520 if (params
!= IF_DEF_PARAMS (ifp
))
8521 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8522 vty_out (vty
, "%s", VTY_NEWLINE
);
8526 /* OSPF interface authentication print */
8527 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8528 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8530 const char *auth_str
;
8532 /* Translation tables are not that much help here due to syntax
8533 of the simple option */
8534 switch (params
->auth_type
)
8537 case OSPF_AUTH_NULL
:
8541 case OSPF_AUTH_SIMPLE
:
8545 case OSPF_AUTH_CRYPTOGRAPHIC
:
8546 auth_str
= " message-digest";
8554 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8555 if (params
!= IF_DEF_PARAMS (ifp
))
8556 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8557 vty_out (vty
, "%s", VTY_NEWLINE
);
8560 /* Simple Authentication Password print. */
8561 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8562 params
->auth_simple
[0] != '\0')
8564 vty_out (vty
, " ip ospf authentication-key %s",
8565 params
->auth_simple
);
8566 if (params
!= IF_DEF_PARAMS (ifp
))
8567 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8568 vty_out (vty
, "%s", VTY_NEWLINE
);
8571 /* Cryptographic Authentication Key print. */
8572 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8574 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8575 ck
->key_id
, ck
->auth_key
);
8576 if (params
!= IF_DEF_PARAMS (ifp
))
8577 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8578 vty_out (vty
, "%s", VTY_NEWLINE
);
8581 /* Interface Output Cost print. */
8582 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8584 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8585 if (params
!= IF_DEF_PARAMS (ifp
))
8586 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8587 vty_out (vty
, "%s", VTY_NEWLINE
);
8590 /* Hello Interval print. */
8591 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8592 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8594 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8595 if (params
!= IF_DEF_PARAMS (ifp
))
8596 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8597 vty_out (vty
, "%s", VTY_NEWLINE
);
8601 /* Router Dead Interval print. */
8602 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8603 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8605 vty_out (vty
, " ip ospf dead-interval ");
8608 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8609 vty_out (vty
, "minimal hello-multiplier %d",
8610 params
->fast_hello
);
8612 vty_out (vty
, "%u", params
->v_wait
);
8614 if (params
!= IF_DEF_PARAMS (ifp
))
8615 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8616 vty_out (vty
, "%s", VTY_NEWLINE
);
8619 /* Router Priority print. */
8620 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8621 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8623 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8624 if (params
!= IF_DEF_PARAMS (ifp
))
8625 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8626 vty_out (vty
, "%s", VTY_NEWLINE
);
8629 /* Retransmit Interval print. */
8630 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8631 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8633 vty_out (vty
, " ip ospf retransmit-interval %u",
8634 params
->retransmit_interval
);
8635 if (params
!= IF_DEF_PARAMS (ifp
))
8636 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8637 vty_out (vty
, "%s", VTY_NEWLINE
);
8640 /* Transmit Delay print. */
8641 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8642 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8644 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8645 if (params
!= IF_DEF_PARAMS (ifp
))
8646 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8647 vty_out (vty
, "%s", VTY_NEWLINE
);
8651 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8654 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8655 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8657 vty_out (vty
, " ip ospf area %s%s",
8658 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8663 ospf_bfd_write_config(vty
, params
);
8665 /* MTU ignore print. */
8666 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8667 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8669 if (params
->mtu_ignore
== 0)
8670 vty_out (vty
, " no ip ospf mtu-ignore");
8672 vty_out (vty
, " ip ospf mtu-ignore");
8673 if (params
!= IF_DEF_PARAMS (ifp
))
8674 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8675 vty_out (vty
, "%s", VTY_NEWLINE
);
8682 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8684 rn
= route_next (rn
);
8694 ospf_opaque_config_write_if (vty
, ifp
);
8701 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8703 struct route_node
*rn
;
8704 u_char buf
[INET_ADDRSTRLEN
];
8706 /* `network area' print. */
8707 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8710 struct ospf_network
*n
= rn
->info
;
8712 memset (buf
, 0, INET_ADDRSTRLEN
);
8714 /* Create Area ID string by specified Area ID format. */
8715 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8716 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8718 sprintf ((char *) buf
, "%lu",
8719 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8721 /* Network print. */
8722 vty_out (vty
, " network %s/%d area %s%s",
8723 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8731 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8733 struct listnode
*node
;
8734 struct ospf_area
*area
;
8735 u_char buf
[INET_ADDRSTRLEN
];
8737 /* Area configuration print. */
8738 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8740 struct route_node
*rn1
;
8742 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8744 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8746 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8747 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8749 vty_out (vty
, " area %s authentication message-digest%s",
8753 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8754 vty_out (vty
, " area %s shortcut %s%s", buf
,
8755 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8758 if ((area
->external_routing
== OSPF_AREA_STUB
)
8759 || (area
->external_routing
== OSPF_AREA_NSSA
)
8762 if (area
->external_routing
== OSPF_AREA_STUB
)
8763 vty_out (vty
, " area %s stub", buf
);
8764 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8766 vty_out (vty
, " area %s nssa", buf
);
8767 switch (area
->NSSATranslatorRole
)
8769 case OSPF_NSSA_ROLE_NEVER
:
8770 vty_out (vty
, " translate-never");
8772 case OSPF_NSSA_ROLE_ALWAYS
:
8773 vty_out (vty
, " translate-always");
8775 case OSPF_NSSA_ROLE_CANDIDATE
:
8777 vty_out (vty
, " translate-candidate");
8781 if (area
->no_summary
)
8782 vty_out (vty
, " no-summary");
8784 vty_out (vty
, "%s", VTY_NEWLINE
);
8786 if (area
->default_cost
!= 1)
8787 vty_out (vty
, " area %s default-cost %d%s", buf
,
8788 area
->default_cost
, VTY_NEWLINE
);
8791 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8794 struct ospf_area_range
*range
= rn1
->info
;
8796 vty_out (vty
, " area %s range %s/%d", buf
,
8797 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8799 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8800 vty_out (vty
, " cost %d", range
->cost_config
);
8802 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8803 vty_out (vty
, " not-advertise");
8805 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8806 vty_out (vty
, " substitute %s/%d",
8807 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8809 vty_out (vty
, "%s", VTY_NEWLINE
);
8812 if (EXPORT_NAME (area
))
8813 vty_out (vty
, " area %s export-list %s%s", buf
,
8814 EXPORT_NAME (area
), VTY_NEWLINE
);
8816 if (IMPORT_NAME (area
))
8817 vty_out (vty
, " area %s import-list %s%s", buf
,
8818 IMPORT_NAME (area
), VTY_NEWLINE
);
8820 if (PREFIX_NAME_IN (area
))
8821 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8822 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8824 if (PREFIX_NAME_OUT (area
))
8825 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8826 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8833 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8835 struct ospf_nbr_nbma
*nbr_nbma
;
8836 struct route_node
*rn
;
8838 /* Static Neighbor configuration print. */
8839 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8840 if ((nbr_nbma
= rn
->info
))
8842 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8844 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8845 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8847 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8848 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8850 vty_out (vty
, "%s", VTY_NEWLINE
);
8857 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8859 struct listnode
*node
;
8860 struct ospf_vl_data
*vl_data
;
8861 u_char buf
[INET_ADDRSTRLEN
];
8863 /* Virtual-Link print */
8864 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8866 struct listnode
*n2
;
8867 struct crypt_key
*ck
;
8868 struct ospf_interface
*oi
;
8870 if (vl_data
!= NULL
)
8872 memset (buf
, 0, INET_ADDRSTRLEN
);
8874 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8875 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8877 sprintf ((char *) buf
, "%lu",
8878 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8879 oi
= vl_data
->vl_oi
;
8882 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8883 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8884 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8885 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8886 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8888 inet_ntoa (vl_data
->vl_peer
),
8889 OSPF_IF_PARAM (oi
, v_hello
),
8890 OSPF_IF_PARAM (oi
, retransmit_interval
),
8891 OSPF_IF_PARAM (oi
, transmit_delay
),
8892 OSPF_IF_PARAM (oi
, v_wait
),
8895 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8896 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8898 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8899 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8901 inet_ntoa (vl_data
->vl_peer
),
8902 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8905 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8907 vty_out (vty
, " area %s virtual-link %s"
8908 " message-digest-key %d md5 %s%s",
8910 inet_ntoa (vl_data
->vl_peer
),
8911 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8921 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8925 /* redistribute print. */
8926 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8928 struct list
*red_list
;
8929 struct listnode
*node
;
8930 struct ospf_redist
*red
;
8932 red_list
= ospf
->redist
[type
];
8936 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8938 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8940 vty_out (vty
, " %d", red
->instance
);
8942 if (red
->dmetric
.value
>= 0)
8943 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8945 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8946 vty_out (vty
, " metric-type 1");
8948 if (ROUTEMAP_NAME (red
))
8949 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8951 vty_out (vty
, "%s", VTY_NEWLINE
);
8959 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8961 if (ospf
->default_metric
!= -1)
8962 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8968 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8971 struct ospf_redist
*red
;
8975 /* distribute-list print. */
8976 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8977 if (DISTRIBUTE_NAME (ospf
, type
))
8978 vty_out (vty
, " distribute-list %s out %s%s",
8979 DISTRIBUTE_NAME (ospf
, type
),
8980 zebra_route_string(type
), VTY_NEWLINE
);
8982 /* default-information print. */
8983 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8985 vty_out (vty
, " default-information originate");
8986 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8987 vty_out (vty
, " always");
8989 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8992 if (red
->dmetric
.value
>= 0)
8993 vty_out (vty
, " metric %d",
8994 red
->dmetric
.value
);
8995 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8996 vty_out (vty
, " metric-type 1");
8998 if (ROUTEMAP_NAME (red
))
8999 vty_out (vty
, " route-map %s",
9000 ROUTEMAP_NAME (red
));
9003 vty_out (vty
, "%s", VTY_NEWLINE
);
9012 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9014 struct route_node
*rn
;
9015 struct ospf_distance
*odistance
;
9017 if (ospf
->distance_all
)
9018 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9020 if (ospf
->distance_intra
9021 || ospf
->distance_inter
9022 || ospf
->distance_external
)
9024 vty_out (vty
, " distance ospf");
9026 if (ospf
->distance_intra
)
9027 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9028 if (ospf
->distance_inter
)
9029 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9030 if (ospf
->distance_external
)
9031 vty_out (vty
, " external %d", ospf
->distance_external
);
9033 vty_out (vty
, "%s", VTY_NEWLINE
);
9036 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9037 if ((odistance
= rn
->info
) != NULL
)
9039 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9040 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9041 odistance
->access_list
? odistance
->access_list
: "",
9047 /* OSPF configuration write function. */
9049 ospf_config_write (struct vty
*vty
)
9052 struct interface
*ifp
;
9053 struct ospf_interface
*oi
;
9054 struct listnode
*node
;
9057 ospf
= ospf_lookup ();
9058 if (ospf
!= NULL
&& ospf
->oi_running
)
9060 /* `router ospf' print. */
9062 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9064 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9068 if (!ospf
->networks
)
9071 /* Router ID print. */
9072 if (ospf
->router_id_static
.s_addr
!= 0)
9073 vty_out (vty
, " ospf router-id %s%s",
9074 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9076 /* ABR type print. */
9077 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9078 vty_out (vty
, " ospf abr-type %s%s",
9079 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9081 /* log-adjacency-changes flag print. */
9082 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9084 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9085 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9089 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9092 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9093 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9094 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9096 /* auto-cost reference-bandwidth configuration. */
9097 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9099 vty_out (vty
, "! Important: ensure reference bandwidth "
9100 "is consistent across all routers%s", VTY_NEWLINE
);
9101 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9102 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9105 /* SPF timers print. */
9106 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9107 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9108 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9109 vty_out (vty
, " timers throttle spf %d %d %d%s",
9110 ospf
->spf_delay
, ospf
->spf_holdtime
,
9111 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9113 /* LSA timers print. */
9114 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9115 vty_out (vty
, " timers throttle lsa all %d%s",
9116 ospf
->min_ls_interval
, VTY_NEWLINE
);
9117 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9118 vty_out (vty
, " timers lsa min-arrival %d%s",
9119 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9121 /* Write multiplier print. */
9122 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9123 vty_out (vty
, " ospf write-multiplier %d%s",
9124 ospf
->write_oi_count
, VTY_NEWLINE
);
9126 /* Max-metric router-lsa print */
9127 config_write_stub_router (vty
, ospf
);
9129 /* SPF refresh parameters print. */
9130 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9131 vty_out (vty
, " refresh timer %d%s",
9132 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9134 /* Redistribute information print. */
9135 config_write_ospf_redistribute (vty
, ospf
);
9137 /* passive-interface print. */
9138 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9139 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9141 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9142 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9143 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9144 ospf
->passive_interface_default
)
9146 vty_out (vty
, " %spassive-interface %s%s",
9147 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9148 ifp
->name
, VTY_NEWLINE
);
9150 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9152 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9154 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9157 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9160 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9163 vty_out (vty
, " %spassive-interface %s %s%s",
9164 oi
->params
->passive_interface
? "" : "no ",
9166 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9169 /* Network area print. */
9170 config_write_network_area (vty
, ospf
);
9172 /* Area config print. */
9173 config_write_ospf_area (vty
, ospf
);
9175 /* static neighbor print. */
9176 config_write_ospf_nbr_nbma (vty
, ospf
);
9178 /* Virtual-Link print. */
9179 config_write_virtual_link (vty
, ospf
);
9181 /* Default metric configuration. */
9182 config_write_ospf_default_metric (vty
, ospf
);
9184 /* Distribute-list and default-information print. */
9185 config_write_ospf_distribute (vty
, ospf
);
9187 /* Distance configuration. */
9188 config_write_ospf_distance (vty
, ospf
);
9190 ospf_opaque_config_write_router (vty
, ospf
);
9197 ospf_vty_show_init (void)
9199 /* "show ip ospf" commands. */
9200 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9202 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9204 /* "show ip ospf database" commands. */
9205 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9206 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
9207 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9209 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
9210 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9211 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9213 /* "show ip ospf interface" commands. */
9214 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9216 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9218 /* "show ip ospf neighbor" commands. */
9219 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9220 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9221 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9222 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9223 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9224 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9225 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9227 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
9228 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
9229 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
9230 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
9231 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
9232 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
9233 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
9235 /* "show ip ospf route" commands. */
9236 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
9237 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
9239 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
9240 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9244 /* ospfd's interface node. */
9245 static struct cmd_node interface_node
=
9252 /* Initialization of OSPF interface. */
9254 ospf_vty_if_init (void)
9256 /* Install interface node. */
9257 install_node (&interface_node
, config_write_interface
);
9259 install_element (CONFIG_NODE
, &interface_cmd
);
9260 install_element (CONFIG_NODE
, &no_interface_cmd
);
9261 install_default (INTERFACE_NODE
);
9263 /* "description" commands. */
9264 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
9265 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
9267 /* "ip ospf authentication" commands. */
9268 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9269 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9270 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9271 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9272 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9273 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9274 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9276 /* "ip ospf message-digest-key" commands. */
9277 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9278 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9280 /* "ip ospf cost" commands. */
9281 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9282 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9284 /* "ip ospf mtu-ignore" commands. */
9285 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9286 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9288 /* "ip ospf dead-interval" commands. */
9289 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9290 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9291 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9293 /* "ip ospf hello-interval" commands. */
9294 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9295 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9297 /* "ip ospf network" commands. */
9298 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9299 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9301 /* "ip ospf priority" commands. */
9302 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9303 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9305 /* "ip ospf retransmit-interval" commands. */
9306 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9307 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9309 /* "ip ospf transmit-delay" commands. */
9310 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9311 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9313 /* "ip ospf area" commands. */
9314 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9315 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9317 /* These commands are compatibitliy for previous version. */
9318 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9319 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9320 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9321 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9322 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9323 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9324 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9325 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9326 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9327 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9328 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9329 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9330 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9331 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9332 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9333 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9334 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9338 ospf_vty_zebra_init (void)
9340 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9341 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9342 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9343 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9345 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9346 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9348 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9349 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9351 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9352 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9354 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9355 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9356 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9357 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9359 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9360 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9361 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9362 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9366 static struct cmd_node ospf_node
=
9369 "%s(config-router)# ",
9374 ospf_interface_clear (struct interface
*ifp
)
9376 if (!if_is_operative (ifp
)) return;
9378 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9379 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
9384 DEFUN (clear_ip_ospf_interface
,
9385 clear_ip_ospf_interface_cmd
,
9386 "clear ip ospf interface [IFNAME]",
9389 "OSPF information\n"
9390 "Interface information\n"
9394 struct interface
*ifp
;
9395 struct listnode
*node
;
9397 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9399 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9400 ospf_interface_clear(ifp
);
9402 else /* Interface name is specified. */
9404 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
9405 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9407 ospf_interface_clear(ifp
);
9414 ospf_vty_clear_init (void)
9416 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9420 /* Install OSPF related vty commands. */
9422 ospf_vty_init (void)
9424 /* Install ospf top node. */
9425 install_node (&ospf_node
, ospf_config_write
);
9427 /* "router ospf" commands. */
9428 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9429 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9432 install_default (OSPF_NODE
);
9434 /* "ospf router-id" commands. */
9435 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9436 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9437 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9439 /* "passive-interface" commands. */
9440 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9441 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9443 /* "ospf abr-type" commands. */
9444 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9445 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9447 /* "ospf log-adjacency-changes" commands. */
9448 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9449 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9450 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9451 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9453 /* "ospf rfc1583-compatible" commands. */
9454 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9455 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9456 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9457 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9459 /* "network area" commands. */
9460 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9461 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9463 /* "area authentication" commands. */
9464 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9465 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9466 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9468 /* "area range" commands. */
9469 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9470 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9471 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9472 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9473 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9474 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9476 /* "area virtual-link" commands. */
9477 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9478 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9479 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9480 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9491 /* "area stub" commands. */
9492 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9493 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9494 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9495 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9497 /* "area nssa" commands. */
9498 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9499 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9500 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9501 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9502 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9504 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9505 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9507 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9508 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9510 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9511 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9513 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9514 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9516 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9517 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9519 /* SPF timer commands */
9520 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9521 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9523 /* LSA timers commands */
9524 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9525 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9526 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9527 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9528 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9529 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9531 /* refresh timer commands */
9532 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9533 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9535 /* max-metric commands */
9536 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9537 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9538 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9539 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9540 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9541 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9543 /* reference bandwidth commands */
9544 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9545 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9547 /* "neighbor" commands. */
9548 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9549 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9550 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9551 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9553 /* write multiplier commands */
9554 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9555 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9556 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9557 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9559 /* Init interface related vty commands. */
9560 ospf_vty_if_init ();
9562 /* Init zebra related vty commands. */
9563 ospf_vty_zebra_init ();