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 after which a neighbor is declared dead\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
;
3100 json
= json_object_new_object();
3101 json_areas
= json_object_new_object();
3107 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3111 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3112 VTY_NEWLINE
, VTY_NEWLINE
);
3116 /* Show Router ID. */
3119 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3123 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3124 inet_ntoa (ospf
->router_id
),
3128 /* Graceful shutdown */
3129 if (ospf
->t_deferred_shutdown
)
3133 unsigned long time_store
= 0;
3134 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3135 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3136 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3140 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3141 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3142 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3146 /* Show capability. */
3149 json_object_boolean_true_add(json
, "tosRoutesOnly");
3150 json_object_boolean_true_add(json
, "rfc2328Conform");
3151 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3153 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3158 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3159 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3160 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3161 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3162 "enabled" : "disabled", VTY_NEWLINE
);
3167 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3169 json_object_boolean_true_add(json
, "opaqueCapable");
3174 vty_out (vty
, " OpaqueCapability flag is %s%s",
3175 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3179 /* Show stub-router configuration */
3180 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3181 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3185 json_object_boolean_true_add(json
, "stubAdvertisement");
3186 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3187 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3188 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3189 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3193 vty_out (vty
, " Stub router advertisement is configured%s",
3195 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3196 vty_out (vty
, " Enabled for %us after start-up%s",
3197 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3198 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3199 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3200 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3204 /* Show SPF timers. */
3207 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3208 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3209 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3210 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3214 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3215 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3216 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3217 " Hold time multiplier is currently %d%s",
3218 ospf
->spf_delay
, VTY_NEWLINE
,
3219 ospf
->spf_holdtime
, VTY_NEWLINE
,
3220 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3221 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3226 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3228 unsigned long time_store
= 0;
3230 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3231 result
= tv_sub (result
, recent_relative_time());
3232 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3233 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3235 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3236 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3239 json_object_boolean_true_add(json
, "spfHasNotRun");
3243 vty_out (vty
, " SPF algorithm ");
3244 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3246 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3247 vty_out (vty
, "last executed %s ago%s",
3248 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3250 vty_out (vty
, " Last SPF duration %s%s",
3251 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3255 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3260 struct timeval temp_time
;
3261 unsigned long time_store
= 0;
3263 if (ospf
->t_spf_calc
)
3265 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3266 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3267 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3270 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3271 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3272 /* Show write multiplier values */
3273 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3274 /* Show refresh parameters. */
3275 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3279 vty_out (vty
, " SPF timer %s%s%s",
3280 (ospf
->t_spf_calc
? "due in " : "is "),
3281 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3284 vty_out (vty
, " LSA minimum interval %d msecs%s",
3285 ospf
->min_ls_interval
, VTY_NEWLINE
);
3286 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3287 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3289 /* Show write multiplier values */
3290 vty_out (vty
, " Write Multiplier set to %d %s",
3291 ospf
->write_oi_count
, VTY_NEWLINE
);
3293 /* Show refresh parameters. */
3294 vty_out (vty
, " Refresh timer %d secs%s",
3295 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3298 /* Show ABR/ASBR flags. */
3299 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3302 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3304 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3305 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3307 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3310 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3312 vty_out (vty
, " This router is an ASBR "
3313 "(injecting external routing information)%s", VTY_NEWLINE
);
3316 /* Show Number of AS-external-LSAs. */
3319 json_object_int_add(json
, "lsaExternalCounter",
3320 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3321 json_object_int_add(json
, "lsaExternalChecksum",
3322 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3326 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3327 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3328 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3333 json_object_int_add(json
, "lsaAsopaqueCounter",
3334 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3335 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3336 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3340 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3341 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3342 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3345 /* Show number of areas attached. */
3347 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3349 vty_out (vty
, " Number of areas attached to this router: %d%s",
3350 listcount (ospf
->areas
), VTY_NEWLINE
);
3352 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3354 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3357 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3359 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3364 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3366 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3369 /* Show each area status. */
3370 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3371 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3375 json_object_object_add(json
, "areas", json_areas
);
3376 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3377 json_object_free(json
);
3380 vty_out (vty
, "%s",VTY_NEWLINE
);
3385 DEFUN (show_ip_ospf
,
3387 "show ip ospf [json]",
3390 "OSPF information\n"
3391 "JavaScript Object Notation\n")
3394 u_char uj
= use_json(argc
, argv
);
3396 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3399 return (show_ip_ospf_common(vty
, ospf
, uj
));
3402 DEFUN (show_ip_ospf_instance
,
3403 show_ip_ospf_instance_cmd
,
3404 "show ip ospf (1-65535) [json]",
3407 "OSPF information\n"
3409 "JavaScript Object Notation\n")
3413 u_short instance
= 0;
3414 u_char uj
= use_json(argc
, argv
);
3416 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3417 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3420 return (show_ip_ospf_common(vty
, ospf
, uj
));
3424 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3425 json_object
*json_interface_sub
, u_char use_json
)
3428 struct ospf_neighbor
*nbr
;
3429 struct route_node
*rn
;
3431 /* Is interface up? */
3434 is_up
= if_is_operative(ifp
);
3436 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3438 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3440 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3441 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3442 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3443 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3447 vty_out (vty
, "%s is %s%s", ifp
->name
,
3448 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3449 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3450 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3454 /* Is interface OSPF enabled? */
3457 if (ospf_oi_count(ifp
) == 0)
3459 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3464 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3468 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3472 if (ospf_oi_count(ifp
) == 0)
3474 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3479 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3485 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3487 struct ospf_interface
*oi
= rn
->info
;
3492 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3495 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3497 vty_out (vty
, " This interface is UNNUMBERED,");
3501 /* Show OSPF interface information. */
3504 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3505 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3508 vty_out (vty
, " Internet Address %s/%d,",
3509 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3511 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3513 struct in_addr
*dest
;
3516 if (CONNECTED_PEER(oi
->connected
)
3517 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3522 /* For Vlinks, showing the peer address is probably more
3523 * * * * * informative than the local interface that is being used
3525 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3526 dest
= &oi
->vl_data
->peer_addr
;
3528 dest
= &oi
->connected
->destination
->u
.prefix4
;
3532 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3533 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3534 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3536 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3539 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3544 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3545 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3546 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3547 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3548 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3549 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3550 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3551 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3552 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3556 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3559 vty_out (vty
, " MTU mismatch detection:%s%s",
3560 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3562 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3563 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3564 oi
->output_cost
, VTY_NEWLINE
);
3566 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3567 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3568 PRIORITY (oi
), VTY_NEWLINE
);
3571 /* Show DR information. */
3572 if (DR (oi
).s_addr
== 0)
3575 vty_out (vty
, " No backup designated router on this network%s",
3580 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3584 vty_out (vty
, " No backup designated router on this network%s",
3591 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3592 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3596 vty_out (vty
, " Backup Designated Router (ID) %s,",
3597 inet_ntoa (nbr
->router_id
));
3598 vty_out (vty
, " Interface Address %s%s",
3599 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3604 /* Next network-LSA sequence number we'll use, if we're elected DR */
3605 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3608 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3610 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3611 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3616 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3617 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3619 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3620 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3621 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3622 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3627 vty_out (vty
, " Multicast group memberships:");
3628 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3629 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3631 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3632 vty_out (vty
, " OSPFAllRouters");
3633 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3634 vty_out (vty
, " OSPFDesignatedRouters");
3637 vty_out (vty
, " <None>");
3638 vty_out (vty
, "%s", VTY_NEWLINE
);
3643 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3644 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3646 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3647 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3648 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3649 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3653 vty_out (vty
, " Timer intervals configured,");
3654 vty_out (vty
, " Hello ");
3655 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3656 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3658 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3659 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3660 OSPF_IF_PARAM (oi
, v_wait
),
3661 OSPF_IF_PARAM (oi
, v_wait
),
3662 OSPF_IF_PARAM (oi
, retransmit_interval
),
3666 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3668 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3671 struct timeval result
;
3672 unsigned long time_store
= 0;
3674 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3680 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3681 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3684 vty_out (vty
, " Hello due in %s%s",
3685 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3688 else /* passive-interface is set */
3691 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3693 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3698 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3699 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3702 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3703 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3705 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3710 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3711 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3713 struct interface
*ifp
;
3714 struct listnode
*node
;
3715 json_object
*json
= NULL
;
3716 json_object
*json_interface_sub
= NULL
;
3720 json
= json_object_new_object();
3721 json_interface_sub
= json_object_new_object();
3727 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3729 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3730 VTY_NEWLINE
, VTY_NEWLINE
);
3733 if (argc
== (iface_argv
+ 1))
3735 /* Show All Interfaces.*/
3736 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3738 if (ospf_oi_count(ifp
))
3740 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3742 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3746 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3750 json
= json_object_new_object();
3751 json_interface_sub
= json_object_new_object ();
3754 /* Show All Interfaces. */
3755 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3757 if (ospf_oi_count(ifp
))
3759 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3761 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3767 /* Interface name is specified. */
3768 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3771 json_object_boolean_true_add(json
, "noSuchIface");
3773 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3777 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3779 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3785 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3786 json_object_free(json
);
3789 vty_out (vty
, "%s", VTY_NEWLINE
);
3794 DEFUN (show_ip_ospf_interface
,
3795 show_ip_ospf_interface_cmd
,
3796 "show ip ospf interface [INTERFACE] [json]",
3799 "OSPF information\n"
3800 "Interface information\n"
3802 "JavaScript Object Notation\n")
3805 u_char uj
= use_json(argc
, argv
);
3807 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3810 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3813 DEFUN (show_ip_ospf_instance_interface
,
3814 show_ip_ospf_instance_interface_cmd
,
3815 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3818 "OSPF information\n"
3820 "Interface information\n"
3822 "JavaScript Object Notation\n")
3826 u_short instance
= 0;
3827 u_char uj
= use_json(argc
, argv
);
3829 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3830 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3833 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3837 show_ip_ospf_neighbour_header (struct vty
*vty
)
3839 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3841 "Neighbor ID", "Pri", "State", "Dead Time",
3842 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3847 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3849 struct route_node
*rn
;
3850 struct ospf_neighbor
*nbr
;
3852 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3853 json_object
*json_neighbor
= NULL
;
3855 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3857 if ((nbr
= rn
->info
))
3859 /* Do not show myself. */
3860 if (nbr
!= oi
->nbr_self
)
3862 /* Down state is not shown. */
3863 if (nbr
->state
!= NSM_Down
)
3867 json_neighbor
= json_object_new_object();
3868 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3870 struct timeval result
;
3871 unsigned long time_store
= 0;
3873 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3874 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3876 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3877 json_object_string_add (json_neighbor
, "state", msgbuf
);
3878 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3879 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3880 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3881 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3882 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3883 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3884 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3885 json_object_object_add(json
, "neighbor", json_neighbor
);
3887 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3891 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3893 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3894 vty_out (vty
, "%-15s %3d %-15s ",
3898 vty_out (vty
, "%-15s %3d %-15s ",
3899 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3902 vty_out (vty
, "%9s ",
3903 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3905 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3906 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3907 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3908 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3918 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3920 struct ospf_interface
*oi
;
3921 struct listnode
*node
;
3922 json_object
*json
= NULL
;
3925 json
= json_object_new_object();
3927 show_ip_ospf_neighbour_header (vty
);
3932 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3934 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3935 VTY_NEWLINE
, VTY_NEWLINE
);
3938 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3939 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3943 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3944 json_object_free(json
);
3947 vty_out (vty
, "%s", VTY_NEWLINE
);
3952 DEFUN (show_ip_ospf_neighbor
,
3953 show_ip_ospf_neighbor_cmd
,
3954 "show ip ospf neighbor [json]",
3957 "OSPF information\n"
3959 "JavaScript Object Notation\n")
3962 u_char uj
= use_json(argc
, argv
);
3964 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3967 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3971 DEFUN (show_ip_ospf_instance_neighbor
,
3972 show_ip_ospf_instance_neighbor_cmd
,
3973 "show ip ospf (1-65535) neighbor [json]",
3976 "OSPF information\n"
3979 "JavaScript Object Notation\n")
3983 u_short instance
= 0;
3984 u_char uj
= use_json(argc
, argv
);
3986 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3987 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3990 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3994 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3996 struct listnode
*node
;
3997 struct ospf_interface
*oi
;
3998 json_object
*json
= NULL
;
3999 json_object
*json_neighbor_sub
= NULL
;
4003 json
= json_object_new_object();
4004 json_neighbor_sub
= json_object_new_object();
4007 show_ip_ospf_neighbour_header (vty
);
4012 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4014 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4015 VTY_NEWLINE
, VTY_NEWLINE
);
4018 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4020 struct listnode
*nbr_node
;
4021 struct ospf_nbr_nbma
*nbr_nbma
;
4023 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4025 /* print Down neighbor status */
4026 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4028 if (nbr_nbma
->nbr
== NULL
4029 || nbr_nbma
->nbr
->state
== NSM_Down
)
4033 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4034 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4035 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4036 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4037 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4038 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4039 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4043 vty_out (vty
, "%-15s %3d %-15s %9s ",
4044 "-", nbr_nbma
->priority
, "Down", "-");
4045 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4046 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4047 0, 0, 0, VTY_NEWLINE
);
4055 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4056 json_object_free(json
);
4059 vty_out (vty
, "%s", VTY_NEWLINE
);
4064 DEFUN (show_ip_ospf_neighbor_all
,
4065 show_ip_ospf_neighbor_all_cmd
,
4066 "show ip ospf neighbor all [json]",
4069 "OSPF information\n"
4071 "include down status neighbor\n"
4072 "JavaScript Object Notation\n")
4075 u_char uj
= use_json(argc
, argv
);
4077 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4080 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4083 DEFUN (show_ip_ospf_instance_neighbor_all
,
4084 show_ip_ospf_instance_neighbor_all_cmd
,
4085 "show ip ospf (1-65535) neighbor all [json]",
4088 "OSPF information\n"
4091 "include down status neighbor\n"
4092 "JavaScript Object Notation\n")
4096 u_short instance
= 0;
4097 u_char uj
= use_json(argc
, argv
);
4099 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4100 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4103 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4107 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4108 struct cmd_token
**argv
, u_char use_json
)
4110 struct interface
*ifp
;
4111 struct route_node
*rn
;
4112 json_object
*json
= NULL
;
4115 json
= json_object_new_object();
4117 show_ip_ospf_neighbour_header (vty
);
4122 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4124 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4125 VTY_NEWLINE
, VTY_NEWLINE
);
4128 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4132 json_object_boolean_true_add(json
, "noSuchIface");
4134 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4138 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4140 struct ospf_interface
*oi
= rn
->info
;
4145 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4150 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4151 json_object_free(json
);
4154 vty_out (vty
, "%s", VTY_NEWLINE
);
4159 DEFUN (show_ip_ospf_neighbor_int
,
4160 show_ip_ospf_neighbor_int_cmd
,
4161 "show ip ospf neighbor IFNAME [json]",
4164 "OSPF information\n"
4167 "JavaScript Object Notation\n")
4170 u_char uj
= use_json(argc
, argv
);
4172 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4175 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4178 DEFUN (show_ip_ospf_instance_neighbor_int
,
4179 show_ip_ospf_instance_neighbor_int_cmd
,
4180 "show ip ospf (1-65535) neighbor IFNAME [json]",
4183 "OSPF information\n"
4187 "JavaScript Object Notation\n")
4191 u_short instance
= 0;
4192 u_char uj
= use_json(argc
, argv
);
4194 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4195 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4198 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4202 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4203 u_char use_json
, json_object
*json
)
4205 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4206 json_object
*json_sub
= NULL
;
4209 json_sub
= json_object_new_object();
4210 else /* Show neighbor ID. */
4211 vty_out (vty
, " Neighbor %s,", "-");
4213 /* Show interface address. */
4215 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4217 vty_out (vty
, " interface address %s%s",
4218 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4223 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4224 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4227 vty_out (vty
, " In the area %s via interface %s%s",
4228 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4230 /* Show neighbor priority and state. */
4233 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4234 json_object_string_add(json_sub
, "nbrState", "down");
4237 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4238 nbr_nbma
->priority
, "Down");
4240 /* Show state changes. */
4242 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4244 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4246 /* Show PollInterval */
4248 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4250 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4252 /* Show poll-interval timer. */
4255 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4256 unsigned long time_store
= 0;
4257 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4258 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4261 vty_out (vty
, " Poll timer due in %s%s",
4262 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4265 /* Show poll-interval timer thread. */
4268 if (nbr_nbma
->t_poll
!= NULL
)
4269 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4272 vty_out (vty
, " Thread Poll Timer %s%s",
4273 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4276 json_object_object_add(json
, "noNbrId", json_sub
);
4280 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4281 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4283 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4284 json_object
*json_sub
= NULL
;
4287 json_sub
= json_object_new_object();
4290 /* Show neighbor ID. */
4291 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4292 vty_out (vty
, " Neighbor %s,", "-");
4294 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4297 /* Show interface address. */
4299 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4301 vty_out (vty
, " interface address %s%s",
4302 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4307 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4308 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4311 vty_out (vty
, " In the area %s via interface %s%s",
4312 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4314 /* Show neighbor priority and state. */
4317 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4318 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4321 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4322 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4324 /* Show state changes. */
4326 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4328 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4330 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4332 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4335 unsigned long time_store
= 0;
4336 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4337 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4341 vty_out (vty
, " Most recent state change statistics:%s",
4343 vty_out (vty
, " Progressive change %s ago%s",
4344 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4349 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4351 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4354 unsigned long time_store
= 0;
4355 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4356 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4357 if (nbr
->last_regress_str
)
4358 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4362 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4363 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4364 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4369 /* Show Designated Rotuer ID. */
4371 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4373 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4375 /* Show Backup Designated Rotuer ID. */
4377 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4379 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4384 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4385 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4388 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4389 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4391 /* Show Router Dead interval timer. */
4394 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4395 unsigned long time_store
= 0;
4396 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4397 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4400 vty_out (vty
, " Dead timer due in %s%s",
4401 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4404 /* Show Database Summary list. */
4406 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4408 vty_out (vty
, " Database Summary List %d%s",
4409 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4411 /* Show Link State Request list. */
4413 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4415 vty_out (vty
, " Link State Request List %ld%s",
4416 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4418 /* Show Link State Retransmission list. */
4420 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4422 vty_out (vty
, " Link State Retransmission List %ld%s",
4423 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4425 /* Show inactivity timer thread. */
4428 if (nbr
->t_inactivity
!= NULL
)
4429 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4432 vty_out (vty
, " Thread Inactivity Timer %s%s",
4433 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4435 /* Show Database Description retransmission thread. */
4438 if (nbr
->t_db_desc
!= NULL
)
4439 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4442 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4443 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4445 /* Show Link State Request Retransmission thread. */
4448 if (nbr
->t_ls_req
!= NULL
)
4449 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4452 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4453 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4455 /* Show Link State Update Retransmission thread. */
4458 if (nbr
->t_ls_upd
!= NULL
)
4459 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4462 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4463 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4467 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4468 json_object_object_add(json
, "noNbrId", json_sub
);
4470 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4473 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4477 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4478 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4480 struct listnode
*node
;
4481 struct ospf_neighbor
*nbr
;
4482 struct ospf_interface
*oi
;
4483 struct in_addr router_id
;
4485 json_object
*json
= NULL
;
4488 json
= json_object_new_object();
4493 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4495 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4496 VTY_NEWLINE
, VTY_NEWLINE
);
4499 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4503 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4507 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4509 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4511 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4517 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4518 json_object_free(json
);
4521 vty_out (vty
, "%s", VTY_NEWLINE
);
4526 DEFUN (show_ip_ospf_neighbor_id
,
4527 show_ip_ospf_neighbor_id_cmd
,
4528 "show ip ospf neighbor A.B.C.D [json]",
4531 "OSPF information\n"
4534 "JavaScript Object Notation\n")
4537 u_char uj
= use_json(argc
, argv
);
4539 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4542 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4545 DEFUN (show_ip_ospf_instance_neighbor_id
,
4546 show_ip_ospf_instance_neighbor_id_cmd
,
4547 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4550 "OSPF information\n"
4554 "JavaScript Object Notation\n")
4558 u_short instance
= 0;
4559 u_char uj
= use_json(argc
, argv
);
4561 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4562 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4565 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4569 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4571 struct ospf_interface
*oi
;
4572 struct listnode
*node
;
4573 json_object
*json
= NULL
;
4576 json
= json_object_new_object();
4581 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4583 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4584 VTY_NEWLINE
, VTY_NEWLINE
);
4587 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4589 struct route_node
*rn
;
4590 struct ospf_neighbor
*nbr
;
4592 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4594 if ((nbr
= rn
->info
))
4596 if (nbr
!= oi
->nbr_self
)
4598 if (nbr
->state
!= NSM_Down
)
4600 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4609 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4610 json_object_free(json
);
4613 vty_out (vty
, "%s", VTY_NEWLINE
);
4618 DEFUN (show_ip_ospf_neighbor_detail
,
4619 show_ip_ospf_neighbor_detail_cmd
,
4620 "show ip ospf neighbor detail [json]",
4623 "OSPF information\n"
4625 "detail of all neighbors\n"
4626 "JavaScript Object Notation\n")
4629 u_char uj
= use_json(argc
, argv
);
4631 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4634 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4637 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4638 show_ip_ospf_instance_neighbor_detail_cmd
,
4639 "show ip ospf (1-65535) neighbor detail [json]",
4642 "OSPF information\n"
4645 "detail of all neighbors\n"
4646 "JavaScript Object Notation\n")
4650 u_short instance
= 0;
4651 u_char uj
= use_json(argc
, argv
);
4653 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4654 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4657 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4661 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4663 struct listnode
*node
;
4664 struct ospf_interface
*oi
;
4665 json_object
*json
= NULL
;
4668 json
= json_object_new_object();
4673 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4675 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4676 VTY_NEWLINE
, VTY_NEWLINE
);
4679 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4681 struct route_node
*rn
;
4682 struct ospf_neighbor
*nbr
;
4683 struct ospf_nbr_nbma
*nbr_nbma
;
4685 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4686 if ((nbr
= rn
->info
))
4687 if (nbr
!= oi
->nbr_self
)
4688 if (nbr
->state
!= NSM_Down
)
4689 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4691 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4693 struct listnode
*nd
;
4695 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4697 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4698 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4705 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4706 json_object_free(json
);
4710 vty_out (vty
, "%s", VTY_NEWLINE
);
4716 DEFUN (show_ip_ospf_neighbor_detail_all
,
4717 show_ip_ospf_neighbor_detail_all_cmd
,
4718 "show ip ospf neighbor detail all [json]",
4721 "OSPF information\n"
4723 "detail of all neighbors\n"
4724 "include down status neighbor\n"
4725 "JavaScript Object Notation\n")
4728 u_char uj
= use_json(argc
, argv
);
4730 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4733 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4736 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4737 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4738 "show ip ospf (1-65535) neighbor detail all [json]",
4741 "OSPF information\n"
4744 "detail of all neighbors\n"
4745 "include down status neighbor\n"
4746 "JavaScript Object Notation\n")
4750 u_short instance
= 0;
4751 u_char uj
= use_json(argc
, argv
);
4753 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4754 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4757 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4761 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4762 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4764 struct ospf_interface
*oi
;
4765 struct interface
*ifp
;
4766 struct route_node
*rn
, *nrn
;
4767 struct ospf_neighbor
*nbr
;
4768 json_object
*json
= NULL
;
4771 json
= json_object_new_object();
4776 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4778 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4779 VTY_NEWLINE
, VTY_NEWLINE
);
4782 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4786 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4790 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4792 if ((oi
= rn
->info
))
4794 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4796 if ((nbr
= nrn
->info
))
4798 if (nbr
!= oi
->nbr_self
)
4800 if (nbr
->state
!= NSM_Down
)
4801 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4810 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4811 json_object_free(json
);
4814 vty_out (vty
, "%s", VTY_NEWLINE
);
4819 DEFUN (show_ip_ospf_neighbor_int_detail
,
4820 show_ip_ospf_neighbor_int_detail_cmd
,
4821 "show ip ospf neighbor IFNAME detail [json]",
4824 "OSPF information\n"
4827 "detail of all neighbors\n"
4828 "JavaScript Object Notation\n")
4831 u_char uj
= use_json(argc
, argv
);
4833 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4836 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4839 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4840 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4841 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4844 "OSPF information\n"
4848 "detail of all neighbors\n"
4849 "JavaScript Object Notation\n")
4853 u_short instance
= 0;
4854 u_char uj
= use_json(argc
, argv
);
4856 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4857 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4860 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4863 /* Show functions */
4865 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4867 struct router_lsa
*rl
;
4868 struct summary_lsa
*sl
;
4869 struct as_external_lsa
*asel
;
4870 struct prefix_ipv4 p
;
4873 /* If self option is set, check LSA self flag. */
4874 if (self
== 0 || IS_LSA_SELF (lsa
))
4876 /* LSA common part show. */
4877 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4878 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4879 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4880 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4881 /* LSA specific part show. */
4882 switch (lsa
->data
->type
)
4884 case OSPF_ROUTER_LSA
:
4885 rl
= (struct router_lsa
*) lsa
->data
;
4886 vty_out (vty
, " %-d", ntohs (rl
->links
));
4888 case OSPF_SUMMARY_LSA
:
4889 sl
= (struct summary_lsa
*) lsa
->data
;
4892 p
.prefix
= sl
->header
.id
;
4893 p
.prefixlen
= ip_masklen (sl
->mask
);
4894 apply_mask_ipv4 (&p
);
4896 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4898 case OSPF_AS_EXTERNAL_LSA
:
4899 case OSPF_AS_NSSA_LSA
:
4900 asel
= (struct as_external_lsa
*) lsa
->data
;
4903 p
.prefix
= asel
->header
.id
;
4904 p
.prefixlen
= ip_masklen (asel
->mask
);
4905 apply_mask_ipv4 (&p
);
4907 vty_out (vty
, " %s %s/%d [0x%lx]",
4908 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4909 inet_ntoa (p
.prefix
), p
.prefixlen
,
4910 (u_long
)ntohl (asel
->e
[0].route_tag
));
4912 case OSPF_NETWORK_LSA
:
4913 case OSPF_ASBR_SUMMARY_LSA
:
4914 case OSPF_OPAQUE_LINK_LSA
:
4915 case OSPF_OPAQUE_AREA_LSA
:
4916 case OSPF_OPAQUE_AS_LSA
:
4920 vty_out (vty
, VTY_NEWLINE
);
4926 static const char *show_database_desc
[] =
4929 "Router Link States",
4931 "Summary Link States",
4932 "ASBR-Summary Link States",
4933 "AS External Link States",
4934 "Group Membership LSA",
4935 "NSSA-external Link States",
4937 "Link-Local Opaque-LSA",
4938 "Area-Local Opaque-LSA",
4939 "AS-external Opaque-LSA",
4942 static const char *show_database_header
[] =
4945 "Link ID ADV Router Age Seq# CkSum Link count",
4946 "Link ID ADV Router Age Seq# CkSum",
4947 "Link ID ADV Router Age Seq# CkSum Route",
4948 "Link ID ADV Router Age Seq# CkSum",
4949 "Link ID ADV Router Age Seq# CkSum Route",
4950 " --- header for Group Member ----",
4951 "Link ID ADV Router Age Seq# CkSum Route",
4953 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4954 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4955 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4959 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4961 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4963 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4964 vty_out (vty
, " Options: 0x%-2x : %s%s",
4966 ospf_options_dump(lsa
->data
->options
),
4968 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4970 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4973 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4975 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4978 vty_out (vty
, " :%s%s%s%s",
4979 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4980 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4981 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4982 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4984 vty_out (vty
, "%s", VTY_NEWLINE
);
4986 vty_out (vty
, " LS Type: %s%s",
4987 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4988 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4989 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4990 vty_out (vty
, " Advertising Router: %s%s",
4991 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4992 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4994 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4996 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4999 const char *link_type_desc
[] =
5002 "another Router (point-to-point)",
5003 "a Transit Network",
5008 const char *link_id_desc
[] =
5011 "Neighboring Router ID",
5012 "Designated Router address",
5014 "Neighboring Router ID",
5017 const char *link_data_desc
[] =
5020 "Router Interface address",
5021 "Router Interface address",
5023 "Router Interface address",
5026 /* Show router-LSA each Link information. */
5028 show_ip_ospf_database_router_links (struct vty
*vty
,
5029 struct router_lsa
*rl
)
5034 len
= ntohs (rl
->header
.length
) - 4;
5035 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5037 type
= rl
->link
[i
].type
;
5039 vty_out (vty
, " Link connected to: %s%s",
5040 link_type_desc
[type
], VTY_NEWLINE
);
5041 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5042 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5043 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5044 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5045 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5046 vty_out (vty
, " TOS 0 Metric: %d%s",
5047 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5048 vty_out (vty
, "%s", VTY_NEWLINE
);
5052 /* Show router-LSA detail information. */
5054 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5058 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5060 show_ip_ospf_database_header (vty
, lsa
);
5062 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5063 VTY_NEWLINE
, VTY_NEWLINE
);
5065 show_ip_ospf_database_router_links (vty
, rl
);
5066 vty_out (vty
, "%s", VTY_NEWLINE
);
5072 /* Show network-LSA detail information. */
5074 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5080 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5082 show_ip_ospf_database_header (vty
, lsa
);
5084 vty_out (vty
, " Network Mask: /%d%s",
5085 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5087 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5089 for (i
= 0; length
> 0; i
++, length
-= 4)
5090 vty_out (vty
, " Attached Router: %s%s",
5091 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5093 vty_out (vty
, "%s", VTY_NEWLINE
);
5099 /* Show summary-LSA detail information. */
5101 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5105 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5107 show_ip_ospf_database_header (vty
, lsa
);
5109 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5111 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5113 vty_out (vty
, "%s", VTY_NEWLINE
);
5119 /* Show summary-ASBR-LSA detail information. */
5121 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5125 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5127 show_ip_ospf_database_header (vty
, lsa
);
5129 vty_out (vty
, " Network Mask: /%d%s",
5130 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5131 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5133 vty_out (vty
, "%s", VTY_NEWLINE
);
5139 /* Show AS-external-LSA detail information. */
5141 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5145 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5147 show_ip_ospf_database_header (vty
, lsa
);
5149 vty_out (vty
, " Network Mask: /%d%s",
5150 ip_masklen (al
->mask
), VTY_NEWLINE
);
5151 vty_out (vty
, " Metric Type: %s%s",
5152 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5153 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5154 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5155 vty_out (vty
, " Metric: %d%s",
5156 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5157 vty_out (vty
, " Forward Address: %s%s",
5158 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5160 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5161 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5168 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5170 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5172 /* show_ip_ospf_database_header (vty, lsa); */
5174 zlog_debug( " Network Mask: /%d%s",
5175 ip_masklen (al
->mask
), "\n");
5176 zlog_debug( " Metric Type: %s%s",
5177 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5178 "2 (Larger than any link state path)" : "1", "\n");
5179 zlog_debug( " TOS: 0%s", "\n");
5180 zlog_debug( " Metric: %d%s",
5181 GET_METRIC (al
->e
[0].metric
), "\n");
5182 zlog_debug( " Forward Address: %s%s",
5183 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5185 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5186 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5191 /* Show AS-NSSA-LSA detail information. */
5193 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5197 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5199 show_ip_ospf_database_header (vty
, lsa
);
5201 vty_out (vty
, " Network Mask: /%d%s",
5202 ip_masklen (al
->mask
), VTY_NEWLINE
);
5203 vty_out (vty
, " Metric Type: %s%s",
5204 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5205 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5206 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5207 vty_out (vty
, " Metric: %d%s",
5208 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5209 vty_out (vty
, " NSSA: Forward Address: %s%s",
5210 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5212 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5213 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5220 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5226 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5230 show_ip_ospf_database_header (vty
, lsa
);
5231 show_opaque_info_detail (vty
, lsa
);
5233 vty_out (vty
, "%s", VTY_NEWLINE
);
5238 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5241 show_router_lsa_detail
,
5242 show_network_lsa_detail
,
5243 show_summary_lsa_detail
,
5244 show_summary_asbr_lsa_detail
,
5245 show_as_external_lsa_detail
,
5247 show_as_nssa_lsa_detail
, /* almost same as external */
5249 show_opaque_lsa_detail
,
5250 show_opaque_lsa_detail
,
5251 show_opaque_lsa_detail
,
5255 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5256 struct in_addr
*adv_router
)
5258 memset (lp
, 0, sizeof (struct prefix_ls
));
5262 else if (adv_router
== NULL
)
5271 lp
->adv_router
= *adv_router
;
5276 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5277 struct in_addr
*id
, struct in_addr
*adv_router
)
5279 struct prefix_ls lp
;
5280 struct route_node
*rn
, *start
;
5281 struct ospf_lsa
*lsa
;
5283 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5284 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5287 route_lock_node (start
);
5288 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5289 if ((lsa
= rn
->info
))
5291 if (show_function
[lsa
->data
->type
] != NULL
)
5292 show_function
[lsa
->data
->type
] (vty
, lsa
);
5294 route_unlock_node (start
);
5298 /* Show detail LSA information
5299 -- if id is NULL then show all LSAs. */
5301 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5302 struct in_addr
*id
, struct in_addr
*adv_router
)
5304 struct listnode
*node
;
5305 struct ospf_area
*area
;
5309 case OSPF_AS_EXTERNAL_LSA
:
5310 case OSPF_OPAQUE_AS_LSA
:
5311 vty_out (vty
, " %s %s%s",
5312 show_database_desc
[type
],
5313 VTY_NEWLINE
, VTY_NEWLINE
);
5314 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5317 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5319 vty_out (vty
, "%s %s (Area %s)%s%s",
5320 VTY_NEWLINE
, show_database_desc
[type
],
5321 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5322 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5329 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5330 struct in_addr
*adv_router
)
5332 struct route_node
*rn
;
5333 struct ospf_lsa
*lsa
;
5335 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5336 if ((lsa
= rn
->info
))
5337 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5339 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5341 if (show_function
[lsa
->data
->type
] != NULL
)
5342 show_function
[lsa
->data
->type
] (vty
, lsa
);
5346 /* Show detail LSA information. */
5348 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5349 struct in_addr
*adv_router
)
5351 struct listnode
*node
;
5352 struct ospf_area
*area
;
5356 case OSPF_AS_EXTERNAL_LSA
:
5357 case OSPF_OPAQUE_AS_LSA
:
5358 vty_out (vty
, " %s %s%s",
5359 show_database_desc
[type
],
5360 VTY_NEWLINE
, VTY_NEWLINE
);
5361 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5365 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5367 vty_out (vty
, "%s %s (Area %s)%s%s",
5368 VTY_NEWLINE
, show_database_desc
[type
],
5369 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5370 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5378 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5380 struct ospf_lsa
*lsa
;
5381 struct route_node
*rn
;
5382 struct ospf_area
*area
;
5383 struct listnode
*node
;
5386 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5388 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5392 case OSPF_AS_EXTERNAL_LSA
:
5393 case OSPF_OPAQUE_AS_LSA
:
5398 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5399 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5401 vty_out (vty
, " %s (Area %s)%s%s",
5402 show_database_desc
[type
],
5403 ospf_area_desc_string (area
),
5404 VTY_NEWLINE
, VTY_NEWLINE
);
5405 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5407 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5408 show_lsa_summary (vty
, lsa
, self
);
5410 vty_out (vty
, "%s", VTY_NEWLINE
);
5415 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5419 case OSPF_AS_EXTERNAL_LSA
:
5420 case OSPF_OPAQUE_AS_LSA
:
5425 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5426 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5428 vty_out (vty
, " %s%s%s",
5429 show_database_desc
[type
],
5430 VTY_NEWLINE
, VTY_NEWLINE
);
5431 vty_out (vty
, "%s%s", show_database_header
[type
],
5434 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5435 show_lsa_summary (vty
, lsa
, self
);
5437 vty_out (vty
, "%s", VTY_NEWLINE
);
5441 vty_out (vty
, "%s", VTY_NEWLINE
);
5445 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5447 struct route_node
*rn
;
5449 vty_out (vty
, "%s MaxAge Link States:%s%s",
5450 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5452 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5454 struct ospf_lsa
*lsa
;
5456 if ((lsa
= rn
->info
) != NULL
)
5458 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5459 vty_out (vty
, "Link State ID: %s%s",
5460 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5461 vty_out (vty
, "Advertising Router: %s%s",
5462 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5463 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5464 vty_out (vty
, "%s", VTY_NEWLINE
);
5469 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5470 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5472 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5473 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5474 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5475 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5477 #define OSPF_LSA_TYPES_DESC \
5478 "ASBR summary link states\n" \
5479 "External link states\n" \
5480 "Network link states\n" \
5481 "Router link states\n" \
5482 "Network summary link states\n" \
5483 OSPF_LSA_TYPE_NSSA_DESC \
5484 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5485 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5486 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5489 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5490 int arg_base
, int argc
, struct cmd_token
**argv
)
5494 struct in_addr id
, adv_router
;
5497 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5500 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5501 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5504 if (argc
== arg_base
+ 4)
5506 show_ip_ospf_database_summary (vty
, ospf
, 0);
5510 /* Set database type to show. */
5511 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5512 type
= OSPF_ROUTER_LSA
;
5513 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5514 type
= OSPF_NETWORK_LSA
;
5515 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5516 type
= OSPF_AS_NSSA_LSA
;
5517 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5518 type
= OSPF_SUMMARY_LSA
;
5519 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5520 type
= OSPF_ASBR_SUMMARY_LSA
;
5521 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5522 type
= OSPF_AS_EXTERNAL_LSA
;
5523 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5525 show_ip_ospf_database_summary (vty
, ospf
, 1);
5528 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5530 show_ip_ospf_database_maxage (vty
, ospf
);
5533 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5534 type
= OSPF_OPAQUE_LINK_LSA
;
5535 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5536 type
= OSPF_OPAQUE_AREA_LSA
;
5537 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5538 type
= OSPF_OPAQUE_AS_LSA
;
5542 /* `show ip ospf database LSA'. */
5543 if (argc
== arg_base
+ 5)
5544 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5545 else if (argc
>= arg_base
+ 6)
5547 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5551 /* `show ip ospf database LSA ID'. */
5552 if (argc
== arg_base
+ 6)
5553 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5554 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5555 else if (argc
== arg_base
+ 7)
5557 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5558 adv_router
= ospf
->router_id
;
5561 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5565 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5572 DEFUN (show_ip_ospf_database
,
5573 show_ip_ospf_database_cmd
,
5574 "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>]]]",
5577 "OSPF information\n"
5578 "Database summary\n"
5580 "Link State ID (as an IP address)\n"
5581 "Self-originated link states\n"
5582 "Advertising Router link states\n"
5583 "Advertising Router (as an IP address)\n")
5587 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5590 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5593 DEFUN (show_ip_ospf_database_max
,
5594 show_ip_ospf_database_max_cmd
,
5595 "show ip ospf database <max-age|self-originate>",
5598 "OSPF information\n"
5599 "Database summary\n"
5600 "LSAs in MaxAge list\n"
5601 "Self-originated link states\n")
5605 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5608 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5611 DEFUN (show_ip_ospf_instance_database
,
5612 show_ip_ospf_instance_database_cmd
,
5613 "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>]]]",
5616 "OSPF information\n"
5618 "Database summary\n"
5620 "Link State ID (as an IP address)\n"
5621 "Self-originated link states\n"
5622 "Advertising Router link states\n"
5623 "Advertising Router (as an IP address)\n")
5627 u_short instance
= 0;
5629 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5631 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5634 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5637 DEFUN (show_ip_ospf_instance_database_max
,
5638 show_ip_ospf_instance_database_max_cmd
,
5639 "show ip ospf (1-65535) database <max-age|self-originate>",
5642 "OSPF information\n"
5644 "Database summary\n"
5645 "LSAs in MaxAge list\n"
5646 "Self-originated link states\n")
5650 u_short instance
= 0;
5652 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5654 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5657 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5662 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5663 int arg_base
, int argc
, struct cmd_token
**argv
)
5667 struct in_addr adv_router
;
5670 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5673 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5674 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5676 if (argc
!= arg_base
+ 7)
5679 /* Set database type to show. */
5680 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5681 type
= OSPF_ROUTER_LSA
;
5682 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5683 type
= OSPF_NETWORK_LSA
;
5684 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5685 type
= OSPF_AS_NSSA_LSA
;
5686 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5687 type
= OSPF_SUMMARY_LSA
;
5688 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5689 type
= OSPF_ASBR_SUMMARY_LSA
;
5690 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5691 type
= OSPF_AS_EXTERNAL_LSA
;
5692 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5693 type
= OSPF_OPAQUE_LINK_LSA
;
5694 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5695 type
= OSPF_OPAQUE_AREA_LSA
;
5696 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5697 type
= OSPF_OPAQUE_AS_LSA
;
5701 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5702 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5703 adv_router
= ospf
->router_id
;
5706 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5711 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5716 DEFUN (show_ip_ospf_database_type_adv_router
,
5717 show_ip_ospf_database_type_adv_router_cmd
,
5718 "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>",
5721 "OSPF information\n"
5722 "Database summary\n"
5724 "Advertising Router link states\n"
5725 "Advertising Router (as an IP address)\n"
5726 "Self-originated link states\n")
5730 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5733 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5736 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5737 show_ip_ospf_instance_database_type_adv_router_cmd
,
5738 "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>",
5741 "OSPF information\n"
5743 "Database summary\n"
5745 "Advertising Router link states\n"
5746 "Advertising Router (as an IP address)\n")
5750 u_short instance
= 0;
5752 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5754 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5757 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5760 DEFUN (ip_ospf_authentication_args
,
5761 ip_ospf_authentication_args_addr_cmd
,
5762 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5764 "OSPF interface commands\n"
5765 "Enable authentication on this interface\n"
5766 "Use null authentication\n"
5767 "Use message-digest authentication\n"
5768 "Address of interface\n")
5770 int idx_encryption
= 3;
5772 struct interface
*ifp
;
5773 struct in_addr addr
;
5775 struct ospf_if_params
*params
;
5778 params
= IF_DEF_PARAMS (ifp
);
5782 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5785 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5790 params
= ospf_get_if_params (ifp
, addr
);
5791 ospf_if_update_params (ifp
, addr
);
5794 /* Handle null authentication */
5795 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5797 SET_IF_PARAM (params
, auth_type
);
5798 params
->auth_type
= OSPF_AUTH_NULL
;
5802 /* Handle message-digest authentication */
5803 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5805 SET_IF_PARAM (params
, auth_type
);
5806 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5810 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5814 DEFUN (ip_ospf_authentication
,
5815 ip_ospf_authentication_addr_cmd
,
5816 "ip ospf authentication [A.B.C.D]",
5818 "OSPF interface commands\n"
5819 "Enable authentication on this interface\n"
5820 "Address of interface")
5823 struct interface
*ifp
;
5824 struct in_addr addr
;
5826 struct ospf_if_params
*params
;
5829 params
= IF_DEF_PARAMS (ifp
);
5833 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5836 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5841 params
= ospf_get_if_params (ifp
, addr
);
5842 ospf_if_update_params (ifp
, addr
);
5845 SET_IF_PARAM (params
, auth_type
);
5846 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5851 DEFUN (no_ip_ospf_authentication_args
,
5852 no_ip_ospf_authentication_args_addr_cmd
,
5853 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5856 "OSPF interface commands\n"
5857 "Enable authentication on this interface\n"
5858 "Use null authentication\n"
5859 "Use message-digest authentication\n"
5860 "Address of interface")
5862 int idx_encryption
= 4;
5864 struct interface
*ifp
;
5865 struct in_addr addr
;
5867 struct ospf_if_params
*params
;
5868 struct route_node
*rn
;
5872 params
= IF_DEF_PARAMS (ifp
);
5876 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5879 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5884 params
= ospf_lookup_if_params (ifp
, addr
);
5887 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5890 params
->auth_type
= OSPF_AUTH_NOTSET
;
5891 UNSET_IF_PARAM (params
, auth_type
);
5892 if (params
!= IF_DEF_PARAMS (ifp
))
5894 ospf_free_if_params (ifp
, addr
);
5895 ospf_if_update_params (ifp
, addr
);
5900 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5902 auth_type
= OSPF_AUTH_NULL
;
5904 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5906 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5910 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5914 * Here we have a case where the user has entered
5915 * 'no ip ospf authentication (null | message_digest )'
5916 * we need to find if we have any ip addresses underneath it that
5917 * correspond to the associated type.
5919 if (params
->auth_type
== auth_type
)
5921 params
->auth_type
= OSPF_AUTH_NOTSET
;
5922 UNSET_IF_PARAM (params
, auth_type
);
5925 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5927 if ((params
= rn
->info
))
5929 if (params
->auth_type
== auth_type
)
5931 params
->auth_type
= OSPF_AUTH_NOTSET
;
5932 UNSET_IF_PARAM (params
, auth_type
);
5933 if (params
!= IF_DEF_PARAMS (ifp
))
5935 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5936 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5946 DEFUN (no_ip_ospf_authentication
,
5947 no_ip_ospf_authentication_addr_cmd
,
5948 "no ip ospf authentication [A.B.C.D]",
5951 "OSPF interface commands\n"
5952 "Enable authentication on this interface\n"
5953 "Address of interface")
5956 struct interface
*ifp
;
5957 struct in_addr addr
;
5959 struct ospf_if_params
*params
;
5960 struct route_node
*rn
;
5963 params
= IF_DEF_PARAMS (ifp
);
5967 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5970 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5975 params
= ospf_lookup_if_params (ifp
, addr
);
5978 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5982 params
->auth_type
= OSPF_AUTH_NOTSET
;
5983 UNSET_IF_PARAM (params
, auth_type
);
5984 if (params
!= IF_DEF_PARAMS (ifp
))
5986 ospf_free_if_params (ifp
, addr
);
5987 ospf_if_update_params (ifp
, addr
);
5993 * When a user enters 'no ip ospf authentication'
5994 * We should remove all authentication types from
5997 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5998 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5999 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6001 params
->auth_type
= OSPF_AUTH_NOTSET
;
6002 UNSET_IF_PARAM (params
, auth_type
);
6005 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6007 if ((params
= rn
->info
))
6010 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6011 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6012 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6014 params
->auth_type
= OSPF_AUTH_NOTSET
;
6015 UNSET_IF_PARAM (params
, auth_type
);
6016 if (params
!= IF_DEF_PARAMS (ifp
))
6018 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6019 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6029 DEFUN (ip_ospf_authentication_key
,
6030 ip_ospf_authentication_key_addr_cmd
,
6031 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6033 "OSPF interface commands\n"
6034 "Authentication password (key)\n"
6035 "The OSPF password (key)\n"
6036 "Address of interface")
6039 struct interface
*ifp
;
6040 struct in_addr addr
;
6042 struct ospf_if_params
*params
;
6045 params
= IF_DEF_PARAMS (ifp
);
6049 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6052 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6057 params
= ospf_get_if_params (ifp
, addr
);
6058 ospf_if_update_params (ifp
, addr
);
6061 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6062 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6063 SET_IF_PARAM (params
, auth_simple
);
6069 DEFUN_HIDDEN (ospf_authentication_key
,
6070 ospf_authentication_key_cmd
,
6071 "ospf authentication-key AUTH_KEY",
6072 "OSPF interface commands\n"
6073 "Authentication password (key)\n"
6074 "The OSPF password (key)")
6076 struct interface
*ifp
;
6077 struct ospf_if_params
*params
;
6080 params
= IF_DEF_PARAMS (ifp
);
6081 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6082 strncpy ((char *) params
->auth_simple
, argv
[2]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6083 SET_IF_PARAM (params
, auth_simple
);
6088 DEFUN (no_ospf_authentication_key
,
6089 no_ospf_authentication_key_authkey_addr_cmd
,
6090 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6092 "OSPF interface commands\n"
6093 "Authentication password (key)\n"
6094 "The OSPF password (key)")
6096 struct interface
*ifp
;
6097 struct in_addr addr
;
6098 struct ospf_if_params
*params
;
6102 params
= IF_DEF_PARAMS (ifp
);
6106 ret
= inet_aton(argv
[4]->arg
, &addr
);
6109 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6114 params
= ospf_lookup_if_params (ifp
, addr
);
6119 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6120 UNSET_IF_PARAM (params
, auth_simple
);
6122 if (params
!= IF_DEF_PARAMS (ifp
))
6124 ospf_free_if_params (ifp
, addr
);
6125 ospf_if_update_params (ifp
, addr
);
6131 DEFUN (no_ip_ospf_authentication_key
,
6132 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6133 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6136 "OSPF interface commands\n"
6137 "Authentication password (key)\n"
6138 "The OSPF password (key)")
6140 struct interface
*ifp
;
6141 struct in_addr addr
;
6142 struct ospf_if_params
*params
;
6146 params
= IF_DEF_PARAMS (ifp
);
6150 ret
= inet_aton(argv
[5]->arg
, &addr
);
6153 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6158 params
= ospf_lookup_if_params (ifp
, addr
);
6163 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6164 UNSET_IF_PARAM (params
, auth_simple
);
6166 if (params
!= IF_DEF_PARAMS (ifp
))
6168 ospf_free_if_params (ifp
, addr
);
6169 ospf_if_update_params (ifp
, addr
);
6175 DEFUN (ip_ospf_message_digest_key
,
6176 ip_ospf_message_digest_key_addr_cmd
,
6177 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6179 "OSPF interface commands\n"
6180 "Message digest authentication password (key)\n"
6182 "Use MD5 algorithm\n"
6183 "The OSPF password (key)"
6184 "Address of interface")
6188 struct interface
*ifp
;
6189 struct crypt_key
*ck
;
6191 struct in_addr addr
;
6193 struct ospf_if_params
*params
;
6196 params
= IF_DEF_PARAMS (ifp
);
6200 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6203 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6208 params
= ospf_get_if_params (ifp
, addr
);
6209 ospf_if_update_params (ifp
, addr
);
6212 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6213 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6215 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6219 ck
= ospf_crypt_key_new ();
6220 ck
->key_id
= (u_char
) key_id
;
6221 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6222 strncpy ((char *) ck
->auth_key
, argv
[idx_ipv4
]->arg
, OSPF_AUTH_MD5_SIZE
);
6224 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6225 SET_IF_PARAM (params
, auth_crypt
);
6231 DEFUN_HIDDEN (ospf_message_digest_key
,
6232 ospf_message_digest_key_cmd
,
6233 "ospf message-digest-key (1-255) md5 KEY",
6234 "OSPF interface commands\n"
6235 "Message digest authentication password (key)\n"
6237 "Use MD5 algorithm\n"
6238 "The OSPF password (key)")
6241 struct interface
*ifp
;
6242 struct crypt_key
*ck
;
6244 struct ospf_if_params
*params
;
6247 params
= IF_DEF_PARAMS (ifp
);
6248 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6249 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6251 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6255 ck
= ospf_crypt_key_new ();
6256 ck
->key_id
= (u_char
) key_id
;
6257 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6258 strncpy ((char *) ck
->auth_key
, argv
[idx_number
]->arg
, OSPF_AUTH_MD5_SIZE
);
6260 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6261 SET_IF_PARAM (params
, auth_crypt
);
6266 DEFUN (no_ip_ospf_message_digest_key_md5
,
6267 no_ip_ospf_message_digest_key_md5_addr_cmd
,
6268 "no ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6271 "OSPF interface commands\n"
6272 "Message digest authentication password (key)\n"
6274 "Use MD5 algorithm\n"
6275 "The OSPF password (key)"
6276 "Address of interface")
6279 struct interface
*ifp
;
6280 struct crypt_key
*ck
;
6282 struct in_addr addr
;
6284 struct ospf_if_params
*params
;
6287 params
= IF_DEF_PARAMS (ifp
);
6291 ret
= inet_aton(argv
[7]->arg
, &addr
);
6294 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6299 params
= ospf_lookup_if_params (ifp
, addr
);
6304 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6305 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6308 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6312 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6314 if (params
!= IF_DEF_PARAMS (ifp
))
6316 ospf_free_if_params (ifp
, addr
);
6317 ospf_if_update_params (ifp
, addr
);
6323 DEFUN (no_ospf_message_digest_key
,
6324 no_ospf_message_digest_key_addr_cmd
,
6325 "no ospf message-digest-key (1-255) [A.B.C.D]",
6327 "OSPF interface commands\n"
6328 "Message digest authentication password (key)\n"
6330 "Address of interface")
6334 struct interface
*ifp
;
6335 struct crypt_key
*ck
;
6337 struct in_addr addr
;
6339 struct ospf_if_params
*params
;
6342 params
= IF_DEF_PARAMS (ifp
);
6346 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6349 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6354 params
= ospf_lookup_if_params (ifp
, addr
);
6359 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6360 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6363 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6367 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6369 if (params
!= IF_DEF_PARAMS (ifp
))
6371 ospf_free_if_params (ifp
, addr
);
6372 ospf_if_update_params (ifp
, addr
);
6378 DEFUN (no_ip_ospf_message_digest_key
,
6379 no_ip_ospf_message_digest_key_addr_cmd
,
6380 "no ip ospf message-digest-key (1-255) [A.B.C.D]",
6383 "OSPF interface commands\n"
6384 "Message digest authentication password (key)\n"
6386 "Address of interface")
6390 struct interface
*ifp
;
6391 struct crypt_key
*ck
;
6393 struct in_addr addr
;
6395 struct ospf_if_params
*params
;
6398 params
= IF_DEF_PARAMS (ifp
);
6402 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6405 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6410 params
= ospf_lookup_if_params (ifp
, addr
);
6415 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6416 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6419 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6423 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6425 if (params
!= IF_DEF_PARAMS (ifp
))
6427 ospf_free_if_params (ifp
, addr
);
6428 ospf_if_update_params (ifp
, addr
);
6434 DEFUN (ip_ospf_cost
,
6435 ip_ospf_cost_u32_inet4_cmd
,
6436 "ip ospf cost (1-65535) [A.B.C.D]",
6438 "OSPF interface commands\n"
6441 "Address of interface")
6445 struct interface
*ifp
= vty
->index
;
6447 struct in_addr addr
;
6449 struct ospf_if_params
*params
;
6451 params
= IF_DEF_PARAMS (ifp
);
6453 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6455 /* cost range is <1-65535>. */
6456 if (cost
< 1 || cost
> 65535)
6458 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6464 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6467 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6472 params
= ospf_get_if_params (ifp
, addr
);
6473 ospf_if_update_params (ifp
, addr
);
6476 SET_IF_PARAM (params
, output_cost_cmd
);
6477 params
->output_cost_cmd
= cost
;
6479 ospf_if_recalculate_output_cost (ifp
);
6484 DEFUN_HIDDEN (ospf_cost
,
6485 ospf_cost_u32_inet4_cmd
,
6486 "ospf cost (1-65535) A.B.C.D",
6487 "OSPF interface commands\n"
6490 "Address of interface")
6494 struct interface
*ifp
= vty
->index
;
6496 struct in_addr addr
;
6498 struct ospf_if_params
*params
;
6500 params
= IF_DEF_PARAMS (ifp
);
6502 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6504 /* cost range is <1-65535>. */
6505 if (cost
< 1 || cost
> 65535)
6507 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6513 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6516 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6521 params
= ospf_get_if_params (ifp
, addr
);
6522 ospf_if_update_params (ifp
, addr
);
6525 SET_IF_PARAM (params
, output_cost_cmd
);
6526 params
->output_cost_cmd
= cost
;
6528 ospf_if_recalculate_output_cost (ifp
);
6533 DEFUN (no_ospf_cost
,
6534 no_ospf_cost_inet4_cmd
,
6535 "no ospf cost [A.B.C.D]",
6537 "OSPF interface commands\n"
6539 "Address of interface")
6542 struct interface
*ifp
= vty
->index
;
6543 struct in_addr addr
;
6545 struct ospf_if_params
*params
;
6548 params
= IF_DEF_PARAMS (ifp
);
6552 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6555 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6560 params
= ospf_lookup_if_params (ifp
, addr
);
6565 UNSET_IF_PARAM (params
, output_cost_cmd
);
6567 if (params
!= IF_DEF_PARAMS (ifp
))
6569 ospf_free_if_params (ifp
, addr
);
6570 ospf_if_update_params (ifp
, addr
);
6573 ospf_if_recalculate_output_cost (ifp
);
6578 DEFUN (no_ip_ospf_cost
,
6579 no_ip_ospf_cost_inet4_cmd
,
6580 "no ip ospf cost [A.B.C.D]",
6583 "OSPF interface commands\n"
6585 "Address of interface")
6588 struct interface
*ifp
= vty
->index
;
6589 struct in_addr addr
;
6591 struct ospf_if_params
*params
;
6594 params
= IF_DEF_PARAMS (ifp
);
6598 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6601 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6606 params
= ospf_lookup_if_params (ifp
, addr
);
6611 UNSET_IF_PARAM (params
, output_cost_cmd
);
6613 if (params
!= IF_DEF_PARAMS (ifp
))
6615 ospf_free_if_params (ifp
, addr
);
6616 ospf_if_update_params (ifp
, addr
);
6619 ospf_if_recalculate_output_cost (ifp
);
6624 DEFUN (no_ospf_cost2
,
6625 no_ospf_cost_u32_cmd
,
6626 "no ospf cost [(1-65535) [A.B.C.D]]",
6628 "OSPF interface commands\n"
6631 "Address of interface\n")
6635 struct interface
*ifp
= vty
->index
;
6636 struct in_addr addr
;
6639 struct ospf_if_params
*params
;
6642 params
= IF_DEF_PARAMS (ifp
);
6644 /* According to the semantics we are mimicking "no ip ospf cost N" is
6645 * always treated as "no ip ospf cost" regardless of the actual value
6646 * of N already configured for the interface. Thus the first argument
6647 * is always checked to be a number, but is ignored after that.
6649 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6650 if (cost
< 1 || cost
> 65535)
6652 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6658 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6661 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6666 params
= ospf_lookup_if_params (ifp
, addr
);
6671 UNSET_IF_PARAM (params
, output_cost_cmd
);
6673 if (params
!= IF_DEF_PARAMS (ifp
))
6675 ospf_free_if_params (ifp
, addr
);
6676 ospf_if_update_params (ifp
, addr
);
6679 ospf_if_recalculate_output_cost (ifp
);
6684 DEFUN (no_ip_ospf_cost2
,
6685 no_ip_ospf_cost_u32_cmd
,
6686 "no ip ospf cost (1-65535) [A.B.C.D]",
6689 "OSPF interface commands\n"
6692 "Address of interface\n")
6696 struct interface
*ifp
= vty
->index
;
6697 struct in_addr addr
;
6700 struct ospf_if_params
*params
;
6703 params
= IF_DEF_PARAMS (ifp
);
6705 /* According to the semantics we are mimicking "no ip ospf cost N" is
6706 * always treated as "no ip ospf cost" regardless of the actual value
6707 * of N already configured for the interface. Thus the first argument
6708 * is always checked to be a number, but is ignored after that.
6710 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6711 if (cost
< 1 || cost
> 65535)
6713 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6719 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6722 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6727 params
= ospf_lookup_if_params (ifp
, addr
);
6732 UNSET_IF_PARAM (params
, output_cost_cmd
);
6734 if (params
!= IF_DEF_PARAMS (ifp
))
6736 ospf_free_if_params (ifp
, addr
);
6737 ospf_if_update_params (ifp
, addr
);
6740 ospf_if_recalculate_output_cost (ifp
);
6749 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6751 struct route_node
*rn
;
6752 struct ospf_neighbor
*nbr
;
6754 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6755 if ((nbr
= rn
->info
))
6757 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6758 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6759 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6760 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6765 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6766 const char *nbr_str
,
6767 const char *fast_hello_str
)
6769 struct interface
*ifp
= vty
->index
;
6772 struct in_addr addr
;
6774 struct ospf_if_params
*params
;
6775 struct ospf_interface
*oi
;
6776 struct route_node
*rn
;
6778 params
= IF_DEF_PARAMS (ifp
);
6782 ret
= inet_aton(nbr_str
, &addr
);
6785 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6790 params
= ospf_get_if_params (ifp
, addr
);
6791 ospf_if_update_params (ifp
, addr
);
6796 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6799 /* reset fast_hello too, just to be sure */
6800 UNSET_IF_PARAM (params
, fast_hello
);
6801 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6803 else if (fast_hello_str
)
6805 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6807 /* 1s dead-interval with sub-second hellos desired */
6808 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6809 SET_IF_PARAM (params
, fast_hello
);
6810 params
->fast_hello
= hellomult
;
6814 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6819 SET_IF_PARAM (params
, v_wait
);
6820 params
->v_wait
= seconds
;
6822 /* Update timer values in neighbor structure. */
6826 if ((ospf
= ospf_lookup()))
6828 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6830 ospf_nbr_timer_update (oi
);
6835 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6836 if ((oi
= rn
->info
))
6837 ospf_nbr_timer_update (oi
);
6843 DEFUN (ip_ospf_dead_interval
,
6844 ip_ospf_dead_interval_addr_cmd
,
6845 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6847 "OSPF interface commands\n"
6848 "Interval after which a neighbor is declared dead\n"
6850 "Address of interface\n")
6855 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, argv
[idx_ipv4
]->arg
, NULL
);
6857 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, NULL
, NULL
);
6861 DEFUN_HIDDEN (ospf_dead_interval
,
6862 ospf_dead_interval_cmd
,
6863 "ospf dead-interval (1-65535)",
6864 "OSPF interface commands\n"
6865 "Interval after which a neighbor is declared dead\n"
6870 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, NULL
, NULL
);
6873 DEFUN (ip_ospf_dead_interval_minimal
,
6874 ip_ospf_dead_interval_minimal_addr_cmd
,
6875 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6877 "OSPF interface commands\n"
6878 "Interval after which a neighbor is declared dead\n"
6879 "Minimal 1s dead-interval with fast sub-second hellos\n"
6880 "Hello multiplier factor\n"
6881 "Number of Hellos to send each second\n"
6882 "Address of interface\n")
6887 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6889 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6892 DEFUN (no_ospf_dead_interval
,
6893 no_ospf_dead_interval_cmd
,
6894 "no ospf dead-interval",
6896 "OSPF interface commands\n"
6897 "Interval after which a neighbor is declared dead\n")
6899 struct interface
*ifp
= vty
->index
;
6900 struct ospf_if_params
*params
;
6903 params
= IF_DEF_PARAMS (ifp
);
6905 UNSET_IF_PARAM (params
, v_wait
);
6906 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6908 UNSET_IF_PARAM (params
, fast_hello
);
6909 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6914 DEFUN (no_ip_ospf_dead_interval
,
6915 no_ip_ospf_dead_interval_addr_cmd
,
6916 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6919 "OSPF interface commands\n"
6920 "Interval after which a neighbor is declared dead\n"
6922 "Address of interface")
6924 int idx_ipv4
= argc
- 1;
6925 struct interface
*ifp
= vty
->index
;
6926 struct in_addr addr
;
6928 struct ospf_if_params
*params
;
6929 struct ospf_interface
*oi
;
6930 struct route_node
*rn
;
6933 params
= IF_DEF_PARAMS (ifp
);
6935 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6937 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6940 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6945 params
= ospf_lookup_if_params (ifp
, addr
);
6950 UNSET_IF_PARAM (params
, v_wait
);
6951 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6953 UNSET_IF_PARAM (params
, fast_hello
);
6954 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6956 if (params
!= IF_DEF_PARAMS (ifp
))
6958 ospf_free_if_params (ifp
, addr
);
6959 ospf_if_update_params (ifp
, addr
);
6962 /* Update timer values in neighbor structure. */
6967 if ((ospf
= ospf_lookup()))
6969 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6971 ospf_nbr_timer_update (oi
);
6976 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6977 if ((oi
= rn
->info
))
6978 ospf_nbr_timer_update (oi
);
6984 DEFUN (ip_ospf_hello_interval
,
6985 ip_ospf_hello_interval_addr_cmd
,
6986 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6988 "OSPF interface commands\n"
6989 "Time between HELLO packets\n"
6991 "Address of interface")
6995 struct interface
*ifp
= vty
->index
;
6997 struct in_addr addr
;
6999 struct ospf_if_params
*params
;
7001 params
= IF_DEF_PARAMS (ifp
);
7003 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7005 /* HelloInterval range is <1-65535>. */
7006 if (seconds
< 1 || seconds
> 65535)
7008 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7014 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7017 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7022 params
= ospf_get_if_params (ifp
, addr
);
7023 ospf_if_update_params (ifp
, addr
);
7026 SET_IF_PARAM (params
, v_hello
);
7027 params
->v_hello
= seconds
;
7033 DEFUN_HIDDEN (ospf_hello_interval
,
7034 ospf_hello_interval_cmd
,
7035 "ospf hello-interval (1-65535)",
7036 "OSPF interface commands\n"
7037 "Time between HELLO packets\n"
7041 struct interface
*ifp
= vty
->index
;
7043 struct ospf_if_params
*params
;
7045 params
= IF_DEF_PARAMS (ifp
);
7047 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7049 /* HelloInterval range is <1-65535>. */
7050 if (seconds
< 1 || seconds
> 65535)
7052 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7056 SET_IF_PARAM (params
, v_hello
);
7057 params
->v_hello
= seconds
;
7062 DEFUN (no_ip_ospf_hello_interval
,
7063 no_ip_ospf_hello_interval_addr_cmd
,
7064 "no [ip] ospf hello-interval [(1-65535) [A.B.C.D]]",
7067 "OSPF interface commands\n"
7068 "Time between HELLO packets\n"
7070 "Address of interface")
7073 struct interface
*ifp
= vty
->index
;
7074 struct in_addr addr
;
7076 struct ospf_if_params
*params
;
7079 params
= IF_DEF_PARAMS (ifp
);
7081 if (strcmp (argv
[1]->arg
, "ip") == 0)
7084 if (argc
== idx_ipv4
+1)
7086 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7089 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7094 params
= ospf_lookup_if_params (ifp
, addr
);
7099 UNSET_IF_PARAM (params
, v_hello
);
7100 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7102 if (params
!= IF_DEF_PARAMS (ifp
))
7104 ospf_free_if_params (ifp
, addr
);
7105 ospf_if_update_params (ifp
, addr
);
7114 DEFUN (ip_ospf_network
,
7115 ip_ospf_network_cmd
,
7116 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7118 "OSPF interface commands\n"
7120 "Specify OSPF broadcast multi-access network\n"
7121 "Specify OSPF NBMA network\n"
7122 "Specify OSPF point-to-multipoint network\n"
7123 "Specify OSPF point-to-point network\n")
7125 int idx_network
= 3;
7126 struct interface
*ifp
= vty
->index
;
7127 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7128 struct route_node
*rn
;
7130 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7132 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7136 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
7137 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7138 else if (strncmp (argv
[idx_network
]->arg
, "n", 1) == 0)
7139 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7140 else if (strncmp (argv
[idx_network
]->arg
, "point-to-m", 10) == 0)
7141 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7142 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
7143 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7145 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7148 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7150 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7152 struct ospf_interface
*oi
= rn
->info
;
7157 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7159 if (oi
->state
> ISM_Down
)
7161 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7162 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7169 DEFUN_HIDDEN (ospf_network
,
7171 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7172 "OSPF interface commands\n"
7174 "Specify OSPF broadcast multi-access network\n"
7175 "Specify OSPF NBMA network\n"
7176 "Specify OSPF point-to-multipoint network\n"
7177 "Specify OSPF point-to-point network\n")
7179 int idx_network
= 2;
7180 struct interface
*ifp
= vty
->index
;
7181 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7182 struct route_node
*rn
;
7184 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7186 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7190 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
7191 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7192 else if (strncmp (argv
[idx_network
]->arg
, "n", 1) == 0)
7193 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7194 else if (strncmp (argv
[idx_network
]->arg
, "point-to-m", 10) == 0)
7195 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7196 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
7197 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7199 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7202 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7204 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7206 struct ospf_interface
*oi
= rn
->info
;
7211 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7213 if (oi
->state
> ISM_Down
)
7215 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7216 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7223 DEFUN (no_ospf_network
,
7224 no_ospf_network_cmd
,
7225 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7227 "OSPF interface commands\n"
7229 "Specify OSPF broadcast multi-access network\n"
7230 "Specify OSPF NBMA network\n"
7231 "Specify OSPF point-to-multipoint network\n"
7232 "Specify OSPF point-to-point network\n")
7234 struct interface
*ifp
= vty
->index
;
7235 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7236 struct route_node
*rn
;
7238 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7240 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7243 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7245 struct ospf_interface
*oi
= rn
->info
;
7250 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7252 if (oi
->state
> ISM_Down
)
7254 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7255 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7262 DEFUN (no_ip_ospf_network
,
7263 no_ip_ospf_network_cmd
,
7264 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7267 "OSPF interface commands\n"
7269 "Specify OSPF broadcast multi-access network\n"
7270 "Specify OSPF NBMA network\n"
7271 "Specify OSPF point-to-multipoint network\n"
7272 "Specify OSPF point-to-point network\n")
7274 struct interface
*ifp
= vty
->index
;
7275 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7276 struct route_node
*rn
;
7278 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7280 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7283 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7285 struct ospf_interface
*oi
= rn
->info
;
7290 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7292 if (oi
->state
> ISM_Down
)
7294 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7295 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7302 DEFUN (ip_ospf_priority
,
7303 ip_ospf_priority_addr_cmd
,
7304 "ip ospf priority (0-255) [A.B.C.D]",
7306 "OSPF interface commands\n"
7309 "Address of interface")
7313 struct interface
*ifp
= vty
->index
;
7315 struct route_node
*rn
;
7316 struct in_addr addr
;
7318 struct ospf_if_params
*params
;
7320 params
= IF_DEF_PARAMS (ifp
);
7322 priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7324 /* Router Priority range is <0-255>. */
7325 if (priority
< 0 || priority
> 255)
7327 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7333 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7336 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7341 params
= ospf_get_if_params (ifp
, addr
);
7342 ospf_if_update_params (ifp
, addr
);
7345 SET_IF_PARAM (params
, priority
);
7346 params
->priority
= priority
;
7348 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7350 struct ospf_interface
*oi
= rn
->info
;
7355 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7357 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7358 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7366 DEFUN_HIDDEN (ospf_priority
,
7368 "ospf priority (0-255)",
7369 "OSPF interface commands\n"
7374 struct interface
*ifp
= vty
->index
;
7376 struct route_node
*rn
;
7377 struct ospf_if_params
*params
;
7379 params
= IF_DEF_PARAMS (ifp
);
7381 priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7383 /* Router Priority range is <0-255>. */
7384 if (priority
< 0 || priority
> 255)
7386 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7390 SET_IF_PARAM (params
, priority
);
7391 params
->priority
= priority
;
7393 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7395 struct ospf_interface
*oi
= rn
->info
;
7401 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7403 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7404 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7411 DEFUN (no_ospf_priority
,
7412 no_ospf_priority_addr_cmd
,
7413 "no ospf priority [(0-255) [A.B.C.D]]",
7415 "OSPF interface commands\n"
7418 "Address of interface")
7421 struct interface
*ifp
= vty
->index
;
7422 struct route_node
*rn
;
7423 struct in_addr addr
;
7425 struct ospf_if_params
*params
;
7428 params
= IF_DEF_PARAMS (ifp
);
7432 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7435 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7440 params
= ospf_lookup_if_params (ifp
, addr
);
7445 UNSET_IF_PARAM (params
, priority
);
7446 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7448 if (params
!= IF_DEF_PARAMS (ifp
))
7450 ospf_free_if_params (ifp
, addr
);
7451 ospf_if_update_params (ifp
, addr
);
7454 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7456 struct ospf_interface
*oi
= rn
->info
;
7462 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7464 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7465 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7472 DEFUN (no_ip_ospf_priority
,
7473 no_ip_ospf_priority_addr_cmd
,
7474 "no ip ospf priority [(0-255) [A.B.C.D]]",
7477 "OSPF interface commands\n"
7480 "Address of interface")
7483 struct interface
*ifp
= vty
->index
;
7484 struct route_node
*rn
;
7485 struct in_addr addr
;
7487 struct ospf_if_params
*params
;
7490 params
= IF_DEF_PARAMS (ifp
);
7494 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7497 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7502 params
= ospf_lookup_if_params (ifp
, addr
);
7507 UNSET_IF_PARAM (params
, priority
);
7508 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7510 if (params
!= IF_DEF_PARAMS (ifp
))
7512 ospf_free_if_params (ifp
, addr
);
7513 ospf_if_update_params (ifp
, addr
);
7516 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7518 struct ospf_interface
*oi
= rn
->info
;
7524 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7526 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7527 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7535 DEFUN (ip_ospf_retransmit_interval
,
7536 ip_ospf_retransmit_interval_addr_cmd
,
7537 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
7539 "OSPF interface commands\n"
7540 "Time between retransmitting lost link state advertisements\n"
7542 "Address of interface")
7546 struct interface
*ifp
= vty
->index
;
7548 struct in_addr addr
;
7550 struct ospf_if_params
*params
;
7552 params
= IF_DEF_PARAMS (ifp
);
7553 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7555 /* Retransmit Interval range is <3-65535>. */
7556 if (seconds
< 3 || seconds
> 65535)
7558 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7565 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7568 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7573 params
= ospf_get_if_params (ifp
, addr
);
7574 ospf_if_update_params (ifp
, addr
);
7577 SET_IF_PARAM (params
, retransmit_interval
);
7578 params
->retransmit_interval
= seconds
;
7583 DEFUN_HIDDEN (ospf_retransmit_interval
,
7584 ospf_retransmit_interval_cmd
,
7585 "ospf retransmit-interval (3-65535)",
7586 "OSPF interface commands\n"
7587 "Time between retransmitting lost link state advertisements\n"
7591 struct interface
*ifp
= vty
->index
;
7593 struct ospf_if_params
*params
;
7595 params
= IF_DEF_PARAMS (ifp
);
7596 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7598 /* Retransmit Interval range is <3-65535>. */
7599 if (seconds
< 3 || seconds
> 65535)
7601 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7605 SET_IF_PARAM (params
, retransmit_interval
);
7606 params
->retransmit_interval
= seconds
;
7611 DEFUN (no_ospf_retransmit_interval
,
7612 no_ospf_retransmit_interval_cmd
,
7613 "no ospf retransmit-interval",
7615 "OSPF interface commands\n"
7616 "Time between retransmitting lost link state advertisements\n")
7618 struct interface
*ifp
= vty
->index
;
7619 struct ospf_if_params
*params
;
7622 params
= IF_DEF_PARAMS (ifp
);
7623 UNSET_IF_PARAM (params
, retransmit_interval
);
7624 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7629 DEFUN (no_ip_ospf_retransmit_interval
,
7630 no_ip_ospf_retransmit_interval_addr_cmd
,
7631 "no ip ospf retransmit-interval [<(3-65535) [A.B.C.D]|A.B.C.D>]",
7634 "OSPF interface commands\n"
7635 "Time between retransmitting lost link state advertisements\n"
7636 "Address of interface")
7638 struct interface
*ifp
= vty
->index
;
7639 struct in_addr addr
;
7641 struct ospf_if_params
*params
;
7645 params
= IF_DEF_PARAMS (ifp
);
7654 ret
= inet_aton(argv
[addr_index
]->arg
, &addr
);
7657 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7662 params
= ospf_lookup_if_params (ifp
, addr
);
7667 UNSET_IF_PARAM (params
, retransmit_interval
);
7668 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7670 if (params
!= IF_DEF_PARAMS (ifp
))
7672 ospf_free_if_params (ifp
, addr
);
7673 ospf_if_update_params (ifp
, addr
);
7680 DEFUN (ip_ospf_transmit_delay
,
7681 ip_ospf_transmit_delay_addr_cmd
,
7682 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7684 "OSPF interface commands\n"
7685 "Link state transmit delay\n"
7687 "Address of interface")
7691 struct interface
*ifp
= vty
->index
;
7693 struct in_addr addr
;
7695 struct ospf_if_params
*params
;
7697 params
= IF_DEF_PARAMS (ifp
);
7698 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7700 /* Transmit Delay range is <1-65535>. */
7701 if (seconds
< 1 || seconds
> 65535)
7703 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7709 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7712 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7717 params
= ospf_get_if_params (ifp
, addr
);
7718 ospf_if_update_params (ifp
, addr
);
7721 SET_IF_PARAM (params
, transmit_delay
);
7722 params
->transmit_delay
= seconds
;
7728 DEFUN_HIDDEN (ospf_transmit_delay
,
7729 ospf_transmit_delay_cmd
,
7730 "ospf transmit-delay (1-65535)",
7731 "OSPF interface commands\n"
7732 "Link state transmit delay\n"
7736 struct interface
*ifp
= vty
->index
;
7738 struct ospf_if_params
*params
;
7740 params
= IF_DEF_PARAMS (ifp
);
7741 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7743 /* Transmit Delay range is <1-65535>. */
7744 if (seconds
< 1 || seconds
> 65535)
7746 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7750 SET_IF_PARAM (params
, transmit_delay
);
7751 params
->transmit_delay
= seconds
;
7756 DEFUN (no_ip_ospf_transmit_delay
,
7757 no_ip_ospf_transmit_delay_addr_cmd
,
7758 "no ip ospf transmit-delay [<A.B.C.D|(1-65535) A.B.C.D>]",
7761 "OSPF interface commands\n"
7762 "Link state transmit delay\n"
7763 "Address of interface")
7765 struct interface
*ifp
= vty
->index
;
7766 struct in_addr addr
;
7768 struct ospf_if_params
*params
;
7772 params
= IF_DEF_PARAMS (ifp
);
7781 ret
= inet_aton(argv
[addr_index
]->arg
, &addr
);
7784 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7789 params
= ospf_lookup_if_params (ifp
, addr
);
7794 UNSET_IF_PARAM (params
, transmit_delay
);
7795 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7797 if (params
!= IF_DEF_PARAMS (ifp
))
7799 ospf_free_if_params (ifp
, addr
);
7800 ospf_if_update_params (ifp
, addr
);
7807 DEFUN (no_ospf_transmit_delay
,
7808 no_ospf_transmit_delay_cmd
,
7809 "no ospf transmit-delay",
7811 "OSPF interface commands\n"
7812 "Link state transmit delay\n")
7814 struct interface
*ifp
= vty
->index
;
7815 struct ospf_if_params
*params
;
7818 params
= IF_DEF_PARAMS (ifp
);
7820 UNSET_IF_PARAM (params
, transmit_delay
);
7821 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7826 DEFUN (no_ip_ospf_transmit_delay_sec
,
7827 no_ip_ospf_transmit_delay_sec_cmd
,
7828 "no ip ospf transmit-delay (1-65535)",
7831 "OSPF interface commands\n"
7832 "Link state transmit delay\n"
7834 "Address of interface")
7836 struct interface
*ifp
= vty
->index
;
7837 struct ospf_if_params
*params
;
7840 params
= IF_DEF_PARAMS (ifp
);
7842 UNSET_IF_PARAM (params
, transmit_delay
);
7843 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7848 DEFUN (ip_ospf_area
,
7850 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7852 "OSPF interface commands\n"
7854 "Enable OSPF on this interface\n"
7855 "OSPF area ID in IP address format\n"
7856 "OSPF area ID as a decimal value\n")
7858 int idx_ipv4_number
= 2;
7859 struct interface
*ifp
= vty
->index
;
7861 struct in_addr area_id
;
7863 struct ospf_if_params
*params
;
7864 struct route_node
*rn
;
7865 u_short instance
= 0;
7868 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_ipv4_number
]->arg
);
7870 ospf
= ospf_lookup_instance (instance
);
7873 params
= IF_DEF_PARAMS (ifp
);
7874 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7876 ospf_interface_unset (ifp
);
7877 ospf
= ospf_lookup();
7878 ospf
->if_ospf_cli_count
--;
7883 ret
= ospf_str2area_id (argv
[instance
? 4 : 3]->arg
, &area_id
, &format
);
7886 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7890 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7892 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7896 params
= IF_DEF_PARAMS (ifp
);
7897 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7900 "Must remove previous area config before changing ospf area %s",
7905 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7907 if (rn
->info
!= NULL
)
7909 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7914 /* enable ospf on this interface with area_id */
7915 ospf_interface_set (ifp
, area_id
);
7916 ospf
->if_ospf_cli_count
++;
7921 DEFUN (no_ip_ospf_area
,
7922 no_ip_ospf_area_cmd
,
7923 "no ip ospf area [<A.B.C.D|(0-4294967295)>]",
7926 "OSPF interface commands\n"
7927 "Disable OSPF on this interface\n"
7928 "OSPF area ID in IP address format\n"
7929 "OSPF area ID as a decimal value\n")
7931 struct interface
*ifp
= vty
->index
;
7933 struct ospf_if_params
*params
;
7934 u_short instance
= 0;
7936 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7939 params
= IF_DEF_PARAMS (ifp
);
7940 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7942 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
7946 ospf_interface_unset (ifp
);
7947 ospf
->if_ospf_cli_count
--;
7951 DEFUN (no_ip_ospf_instance_area
,
7952 no_ip_ospf_instance_area_cmd
,
7953 "no ip ospf (1-65535) area [<A.B.C.D|(0-4294967295)>]",
7956 "OSPF interface commands\n"
7958 "Disable OSPF on this interface\n")
7961 struct interface
*ifp
= vty
->index
;
7963 struct ospf_if_params
*params
;
7964 u_short instance
= 0;
7966 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
7968 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7971 params
= IF_DEF_PARAMS (ifp
);
7972 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7974 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
7978 ospf_interface_unset (ifp
);
7979 ospf
->if_ospf_cli_count
--;
7983 DEFUN (ospf_redistribute_source
,
7984 ospf_redistribute_source_cmd
,
7985 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7987 QUAGGA_REDIST_HELP_STR_OSPFD
7988 "Metric for redistributed routes\n"
7989 "OSPF default metric\n"
7990 "OSPF exterior metric type for redistributed routes\n"
7991 "Set OSPF External Type 1 metrics\n"
7992 "Set OSPF External Type 2 metrics\n"
7993 "Route map reference\n"
7994 "Pointer to route-map entries\n")
7996 int idx_protocol
= 1;
7997 int idx_redist_param
= 2;
7998 struct ospf
*ospf
= vty
->index
;
8002 struct ospf_redist
*red
;
8008 return CMD_WARNING
; /* should not happen */
8013 /* Get distribute source. */
8014 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
8015 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8018 /* Get metric value. */
8019 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8020 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8023 /* Get metric type. */
8024 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8025 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8028 red
= ospf_redist_add(ospf
, source
, 0);
8030 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8031 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8033 ospf_routemap_unset (red
);
8035 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
8038 DEFUN (no_ospf_redistribute_source
,
8039 no_ospf_redistribute_source_cmd
,
8040 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8043 QUAGGA_REDIST_HELP_STR_OSPFD
8044 "Metric for redistributed routes\n"
8045 "OSPF default metric\n"
8046 "OSPF exterior metric type for redistributed routes\n"
8047 "Set OSPF External Type 1 metrics\n"
8048 "Set OSPF External Type 2 metrics\n"
8049 "Route map reference\n"
8050 "Pointer to route-map entries\n")
8052 int idx_protocol
= 2;
8053 struct ospf
*ospf
= vty
->index
;
8055 struct ospf_redist
*red
;
8059 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
8060 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8063 red
= ospf_redist_lookup(ospf
, source
, 0);
8067 ospf_routemap_unset (red
);
8068 return ospf_redistribute_unset (ospf
, source
, 0);
8071 DEFUN (ospf_redistribute_instance_source
,
8072 ospf_redistribute_instance_source_cmd
,
8073 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8075 "Open Shortest Path First\n"
8076 "Non-main Kernel Routing Table\n"
8077 "Instance ID/Table ID\n"
8078 "Metric for redistributed routes\n"
8079 "OSPF default metric\n"
8080 "OSPF exterior metric type for redistributed routes\n"
8081 "Set OSPF External Type 1 metrics\n"
8082 "Set OSPF External Type 2 metrics\n"
8083 "Route map reference\n"
8084 "Pointer to route-map entries\n")
8086 int idx_ospf_table
= 1;
8088 int idx_redist_param
= 3;
8089 struct ospf
*ospf
= vty
->index
;
8094 struct ospf_redist
*red
;
8099 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8100 source
= ZEBRA_ROUTE_OSPF
;
8102 source
= ZEBRA_ROUTE_TABLE
;
8104 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
8109 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8111 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8116 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8118 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8123 /* Get metric value. */
8124 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8125 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8128 /* Get metric type. */
8129 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8130 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8133 red
= ospf_redist_add(ospf
, source
, instance
);
8135 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8136 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8138 ospf_routemap_unset (red
);
8140 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
8143 DEFUN (no_ospf_redistribute_instance_source
,
8144 no_ospf_redistribute_instance_source_cmd
,
8145 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8148 "Open Shortest Path First\n"
8149 "Non-main Kernel Routing Table\n"
8150 "Instance ID/Table Id\n"
8151 "Metric for redistributed routes\n"
8152 "OSPF default metric\n"
8153 "OSPF exterior metric type for redistributed routes\n"
8154 "Set OSPF External Type 1 metrics\n"
8155 "Set OSPF External Type 2 metrics\n"
8156 "Route map reference\n"
8157 "Pointer to route-map entries\n")
8159 int idx_ospf_table
= 2;
8161 struct ospf
*ospf
= vty
->index
;
8163 struct ospf_redist
*red
;
8169 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8170 source
= ZEBRA_ROUTE_OSPF
;
8172 source
= ZEBRA_ROUTE_TABLE
;
8174 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
8176 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8178 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8183 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8185 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8190 red
= ospf_redist_lookup(ospf
, source
, instance
);
8194 ospf_routemap_unset (red
);
8195 return ospf_redistribute_unset (ospf
, source
, instance
);
8198 DEFUN (ospf_distribute_list_out
,
8199 ospf_distribute_list_out_cmd
,
8200 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
8201 "Filter networks in routing updates\n"
8202 "Access-list name\n"
8204 QUAGGA_REDIST_HELP_STR_OSPFD
)
8207 struct ospf
*ospf
= vty
->index
;
8213 /* Get distribute source. */
8214 source
= proto_redistnum(AFI_IP
, argv
[4]->arg
);
8215 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8218 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
8221 DEFUN (no_ospf_distribute_list_out
,
8222 no_ospf_distribute_list_out_cmd
,
8223 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
8225 "Filter networks in routing updates\n"
8226 "Access-list name\n"
8228 QUAGGA_REDIST_HELP_STR_OSPFD
)
8231 struct ospf
*ospf
= vty
->index
;
8237 source
= proto_redistnum(AFI_IP
, argv
[5]->arg
);
8238 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8241 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
8244 /* Default information originate. */
8245 DEFUN (ospf_default_information_originate
,
8246 ospf_default_information_originate_cmd
,
8247 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8248 "Control distribution of default information\n"
8249 "Distribute a default route\n"
8250 "Always advertise default route\n"
8251 "OSPF default metric\n"
8253 "OSPF metric type for default routes\n"
8254 "Set OSPF External Type 1 metrics\n"
8255 "Set OSPF External Type 2 metrics\n"
8256 "Route map reference\n"
8257 "Pointer to route-map entries\n")
8259 int idx_redist_param
= 2;
8260 struct ospf
*ospf
= vty
->index
;
8261 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8264 struct ospf_redist
*red
;
8270 return CMD_WARNING
; /* this should not happen */
8272 /* Check whether "always" was specified */
8273 if (argv
[idx_redist_param
]->arg
!= NULL
)
8274 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8276 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8278 /* Get metric value. */
8279 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8280 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8283 /* Get metric type. */
8284 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8285 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8288 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8289 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8291 ospf_routemap_unset (red
);
8293 return ospf_redistribute_default_set (ospf
, default_originate
,
8297 DEFUN (no_ospf_default_information_originate
,
8298 no_ospf_default_information_originate_cmd
,
8299 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8301 "Control distribution of default information\n"
8302 "Distribute a default route\n"
8303 "Always advertise default route\n"
8304 "OSPF default metric\n"
8306 "OSPF metric type for default routes\n"
8307 "Set OSPF External Type 1 metrics\n"
8308 "Set OSPF External Type 2 metrics\n"
8309 "Route map reference\n"
8310 "Pointer to route-map entries\n")
8312 struct ospf
*ospf
= vty
->index
;
8313 struct prefix_ipv4 p
;
8314 struct ospf_external
*ext
;
8315 struct ospf_redist
*red
;
8321 p
.prefix
.s_addr
= 0;
8324 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
8326 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
8327 EXTERNAL_INFO (ext
)) {
8328 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
8329 ospf_external_del (DEFAULT_ROUTE
, 0);
8332 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8336 ospf_routemap_unset (red
);
8337 return ospf_redistribute_default_unset (ospf
);
8340 DEFUN (ospf_default_metric
,
8341 ospf_default_metric_cmd
,
8342 "default-metric (0-16777214)",
8343 "Set metric of redistributed routes\n"
8347 struct ospf
*ospf
= vty
->index
;
8353 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
8356 ospf
->default_metric
= metric
;
8361 DEFUN (no_ospf_default_metric
,
8362 no_ospf_default_metric_cmd
,
8363 "no default-metric [(0-16777214)]",
8365 "Set metric of redistributed routes\n"
8368 struct ospf
*ospf
= vty
->index
;
8373 ospf
->default_metric
= -1;
8379 DEFUN (ospf_distance
,
8382 "Define an administrative distance\n"
8383 "OSPF Administrative distance\n")
8386 struct ospf
*ospf
= vty
->index
;
8391 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
8396 DEFUN (no_ospf_distance
,
8397 no_ospf_distance_cmd
,
8398 "no distance (1-255)",
8400 "Define an administrative distance\n"
8401 "OSPF Administrative distance\n")
8403 struct ospf
*ospf
= vty
->index
;
8408 ospf
->distance_all
= 0;
8413 DEFUN (no_ospf_distance_ospf
,
8414 no_ospf_distance_ospf_cmd
,
8415 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
8417 "Define an administrative distance\n"
8418 "OSPF Administrative distance\n"
8419 "Intra-area routes\n"
8420 "Distance for intra-area routes\n"
8421 "Inter-area routes\n"
8422 "Distance for inter-area routes\n"
8424 "Distance for external routes\n")
8426 int idx_area_distance
= 3;
8427 struct ospf
*ospf
= vty
->index
;
8438 if (argv
[idx_area_distance
]->arg
!= NULL
)
8439 ospf
->distance_intra
= 0;
8441 if (argv
[1] != NULL
)
8442 ospf
->distance_inter
= 0;
8444 if (argv
[2] != NULL
)
8445 ospf
->distance_external
= 0;
8447 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
8450 /* If no arguments are given, clear all distance information */
8451 ospf
->distance_intra
= 0;
8452 ospf
->distance_inter
= 0;
8453 ospf
->distance_external
= 0;
8458 DEFUN (ospf_distance_ospf
,
8459 ospf_distance_ospf_cmd
,
8460 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
8461 "Define an administrative distance\n"
8462 "OSPF Administrative distance\n"
8463 "Intra-area routes\n"
8464 "Distance for intra-area routes\n"
8465 "Inter-area routes\n"
8466 "Distance for inter-area routes\n"
8468 "Distance for external routes\n")
8470 int idx_area_distance
= 2;
8471 struct ospf
*ospf
= vty
->index
;
8476 if (argc
< 3) /* should not happen */
8479 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
8481 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
8486 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
8487 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
8489 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
8490 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
8492 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
8493 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
8498 DEFUN (ospf_distance_source
,
8499 ospf_distance_source_cmd
,
8500 "distance (1-255) A.B.C.D/M",
8501 "Administrative distance\n"
8503 "IP source prefix\n")
8506 int idx_ipv4_prefixlen
= 2;
8507 struct ospf
*ospf
= vty
->index
;
8512 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8517 DEFUN (no_ospf_distance_source
,
8518 no_ospf_distance_source_cmd
,
8519 "no distance (1-255) A.B.C.D/M",
8521 "Administrative distance\n"
8523 "IP source prefix\n")
8526 int idx_ipv4_prefixlen
= 3;
8527 struct ospf
*ospf
= vty
->index
;
8532 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8537 DEFUN (ospf_distance_source_access_list
,
8538 ospf_distance_source_access_list_cmd
,
8539 "distance (1-255) A.B.C.D/M WORD",
8540 "Administrative distance\n"
8542 "IP source prefix\n"
8543 "Access list name\n")
8546 int idx_ipv4_prefixlen
= 2;
8548 struct ospf
*ospf
= vty
->index
;
8553 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8558 DEFUN (no_ospf_distance_source_access_list
,
8559 no_ospf_distance_source_access_list_cmd
,
8560 "no distance (1-255) A.B.C.D/M WORD",
8562 "Administrative distance\n"
8564 "IP source prefix\n"
8565 "Access list name\n")
8568 int idx_ipv4_prefixlen
= 3;
8570 struct ospf
*ospf
= vty
->index
;
8575 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8580 DEFUN (ip_ospf_mtu_ignore
,
8581 ip_ospf_mtu_ignore_addr_cmd
,
8582 "ip ospf mtu-ignore [A.B.C.D]",
8584 "OSPF interface commands\n"
8585 "Disable mtu mismatch detection\n"
8586 "Address of interface")
8589 struct interface
*ifp
= vty
->index
;
8590 struct in_addr addr
;
8593 struct ospf_if_params
*params
;
8594 params
= IF_DEF_PARAMS (ifp
);
8598 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8601 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8605 params
= ospf_get_if_params (ifp
, addr
);
8606 ospf_if_update_params (ifp
, addr
);
8608 params
->mtu_ignore
= 1;
8609 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8610 SET_IF_PARAM (params
, mtu_ignore
);
8613 UNSET_IF_PARAM (params
, mtu_ignore
);
8614 if (params
!= IF_DEF_PARAMS (ifp
))
8616 ospf_free_if_params (ifp
, addr
);
8617 ospf_if_update_params (ifp
, addr
);
8623 DEFUN (no_ip_ospf_mtu_ignore
,
8624 no_ip_ospf_mtu_ignore_addr_cmd
,
8625 "no ip ospf mtu-ignore [A.B.C.D]",
8627 "OSPF interface commands\n"
8628 "Disable mtu mismatch detection\n"
8629 "Address of interface")
8632 struct interface
*ifp
= vty
->index
;
8633 struct in_addr addr
;
8636 struct ospf_if_params
*params
;
8637 params
= IF_DEF_PARAMS (ifp
);
8641 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8644 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8648 params
= ospf_get_if_params (ifp
, addr
);
8649 ospf_if_update_params (ifp
, addr
);
8651 params
->mtu_ignore
= 0;
8652 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8653 SET_IF_PARAM (params
, mtu_ignore
);
8656 UNSET_IF_PARAM (params
, mtu_ignore
);
8657 if (params
!= IF_DEF_PARAMS (ifp
))
8659 ospf_free_if_params (ifp
, addr
);
8660 ospf_if_update_params (ifp
, addr
);
8667 DEFUN (ospf_max_metric_router_lsa_admin
,
8668 ospf_max_metric_router_lsa_admin_cmd
,
8669 "max-metric router-lsa administrative",
8670 "OSPF maximum / infinite-distance metric\n"
8671 "Advertise own Router-LSA with infinite distance (stub router)\n"
8672 "Administratively applied, for an indefinite period\n")
8674 struct listnode
*ln
;
8675 struct ospf_area
*area
;
8676 struct ospf
*ospf
= vty
->index
;
8681 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8683 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8685 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
8686 ospf_router_lsa_update_area (area
);
8689 /* Allows for areas configured later to get the property */
8690 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8695 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8696 no_ospf_max_metric_router_lsa_admin_cmd
,
8697 "no max-metric router-lsa administrative",
8699 "OSPF maximum / infinite-distance metric\n"
8700 "Advertise own Router-LSA with infinite distance (stub router)\n"
8701 "Administratively applied, for an indefinite period\n")
8703 struct listnode
*ln
;
8704 struct ospf_area
*area
;
8705 struct ospf
*ospf
= vty
->index
;
8710 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8712 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8714 /* Don't trample on the start-up stub timer */
8715 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8716 && !area
->t_stub_router
)
8718 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8719 ospf_router_lsa_update_area (area
);
8722 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8726 DEFUN (ospf_max_metric_router_lsa_startup
,
8727 ospf_max_metric_router_lsa_startup_cmd
,
8728 "max-metric router-lsa on-startup (5-86400)",
8729 "OSPF maximum / infinite-distance metric\n"
8730 "Advertise own Router-LSA with infinite distance (stub router)\n"
8731 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8732 "Time (seconds) to advertise self as stub-router\n")
8735 unsigned int seconds
;
8736 struct ospf
*ospf
= vty
->index
;
8743 vty_out (vty
, "%% Must supply stub-router period");
8747 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
8749 ospf
->stub_router_startup_time
= seconds
;
8754 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8755 no_ospf_max_metric_router_lsa_startup_cmd
,
8756 "no max-metric router-lsa on-startup [(5-86400)]",
8758 "OSPF maximum / infinite-distance metric\n"
8759 "Advertise own Router-LSA with infinite distance (stub router)\n"
8760 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8761 "Time (seconds) to advertise self as stub-router\n")
8763 struct listnode
*ln
;
8764 struct ospf_area
*area
;
8765 struct ospf
*ospf
= vty
->index
;
8770 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8772 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8774 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8775 OSPF_TIMER_OFF (area
->t_stub_router
);
8777 /* Don't trample on admin stub routed */
8778 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8780 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8781 ospf_router_lsa_update_area (area
);
8788 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8789 ospf_max_metric_router_lsa_shutdown_cmd
,
8790 "max-metric router-lsa on-shutdown (5-100)",
8791 "OSPF maximum / infinite-distance metric\n"
8792 "Advertise own Router-LSA with infinite distance (stub router)\n"
8793 "Advertise stub-router prior to full shutdown of OSPF\n"
8794 "Time (seconds) to wait till full shutdown\n")
8797 unsigned int seconds
;
8798 struct ospf
*ospf
= vty
->index
;
8805 vty_out (vty
, "%% Must supply stub-router shutdown period");
8809 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
8811 ospf
->stub_router_shutdown_time
= seconds
;
8816 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8817 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8818 "no max-metric router-lsa on-shutdown [(5-100)]",
8820 "OSPF maximum / infinite-distance metric\n"
8821 "Advertise own Router-LSA with infinite distance (stub router)\n"
8822 "Advertise stub-router prior to full shutdown of OSPF\n"
8823 "Time (seconds) to wait till full shutdown\n")
8825 struct ospf
*ospf
= vty
->index
;
8830 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8836 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8838 struct listnode
*ln
;
8839 struct ospf_area
*area
;
8841 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8842 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8843 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8844 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8845 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8846 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8847 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8849 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8851 vty_out (vty
, " max-metric router-lsa administrative%s",
8860 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8862 struct route_node
*rn
;
8863 struct ospf_route
*or;
8864 struct listnode
*pnode
, *pnnode
;
8865 struct ospf_path
*path
;
8867 vty_out (vty
, "============ OSPF network routing table ============%s",
8870 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8871 if ((or = rn
->info
) != NULL
)
8874 snprintf (buf1
, 19, "%s/%d",
8875 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8877 switch (or->path_type
)
8879 case OSPF_PATH_INTER_AREA
:
8880 if (or->type
== OSPF_DESTINATION_NETWORK
)
8881 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8882 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8883 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8884 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8886 case OSPF_PATH_INTRA_AREA
:
8887 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8888 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8894 if (or->type
== OSPF_DESTINATION_NETWORK
)
8895 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8897 if (if_lookup_by_index(path
->ifindex
))
8899 if (path
->nexthop
.s_addr
== 0)
8900 vty_out (vty
, "%24s directly attached to %s%s",
8901 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8903 vty_out (vty
, "%24s via %s, %s%s", "",
8904 inet_ntoa (path
->nexthop
),
8905 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8909 vty_out (vty
, "%s", VTY_NEWLINE
);
8913 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
8915 struct route_node
*rn
;
8916 struct ospf_route
*or;
8917 struct listnode
*pnode
;
8918 struct listnode
*node
;
8919 struct ospf_path
*path
;
8921 vty_out (vty
, "============ OSPF router routing table =============%s",
8923 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
8928 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
8930 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
8933 vty_out (vty
, "%24s", "");
8936 vty_out (vty
, "%s [%d] area: %s",
8937 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
8938 or->cost
, inet_ntoa (or->u
.std
.area_id
));
8940 vty_out (vty
, "%s%s%s",
8941 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
8942 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
8945 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8947 if (if_lookup_by_index(path
->ifindex
))
8949 if (path
->nexthop
.s_addr
== 0)
8950 vty_out (vty
, "%24s directly attached to %s%s",
8951 "", ifindex2ifname (path
->ifindex
),
8954 vty_out (vty
, "%24s via %s, %s%s", "",
8955 inet_ntoa (path
->nexthop
),
8956 ifindex2ifname (path
->ifindex
),
8962 vty_out (vty
, "%s", VTY_NEWLINE
);
8966 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8968 struct route_node
*rn
;
8969 struct ospf_route
*er
;
8970 struct listnode
*pnode
, *pnnode
;
8971 struct ospf_path
*path
;
8973 vty_out (vty
, "============ OSPF external routing table ===========%s",
8975 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8976 if ((er
= rn
->info
) != NULL
)
8979 snprintf (buf1
, 19, "%s/%d",
8980 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8982 switch (er
->path_type
)
8984 case OSPF_PATH_TYPE1_EXTERNAL
:
8985 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8986 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8988 case OSPF_PATH_TYPE2_EXTERNAL
:
8989 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8990 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8994 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8996 if (if_lookup_by_index(path
->ifindex
))
8998 if (path
->nexthop
.s_addr
== 0)
8999 vty_out (vty
, "%24s directly attached to %s%s",
9000 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9002 vty_out (vty
, "%24s via %s, %s%s", "",
9003 inet_ntoa (path
->nexthop
),
9004 ifindex2ifname (path
->ifindex
),
9009 vty_out (vty
, "%s", VTY_NEWLINE
);
9013 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
9016 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9017 VTY_NEWLINE
, VTY_NEWLINE
);
9019 if (ospf
->new_table
== NULL
)
9021 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9025 /* Show Network routes.
9026 show_ip_ospf_route_network (vty, ospf->new_table); */
9028 /* Show Router routes. */
9029 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9031 vty_out (vty
, "%s", VTY_NEWLINE
);
9036 DEFUN (show_ip_ospf_border_routers
,
9037 show_ip_ospf_border_routers_cmd
,
9038 "show ip ospf border-routers",
9041 "OSPF information\n"
9042 "Show all the ABR's and ASBR's\n")
9046 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9049 return show_ip_ospf_border_routers_common(vty
, ospf
);
9052 DEFUN (show_ip_ospf_instance_border_routers
,
9053 show_ip_ospf_instance_border_routers_cmd
,
9054 "show ip ospf (1-65535) border-routers",
9057 "OSPF information\n"
9059 "Show all the ABR's and ASBR's\n")
9063 u_short instance
= 0;
9065 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
9066 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9069 return show_ip_ospf_border_routers_common(vty
, ospf
);
9073 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
9076 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9077 VTY_NEWLINE
, VTY_NEWLINE
);
9079 if (ospf
->new_table
== NULL
)
9081 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9085 /* Show Network routes. */
9086 show_ip_ospf_route_network (vty
, ospf
->new_table
);
9088 /* Show Router routes. */
9089 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9091 /* Show AS External routes. */
9092 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
9094 vty_out (vty
, "%s", VTY_NEWLINE
);
9099 DEFUN (show_ip_ospf_route
,
9100 show_ip_ospf_route_cmd
,
9101 "show ip ospf route",
9104 "OSPF information\n"
9105 "OSPF routing table\n")
9109 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9112 return show_ip_ospf_route_common(vty
, ospf
);
9115 DEFUN (show_ip_ospf_instance_route
,
9116 show_ip_ospf_instance_route_cmd
,
9117 "show ip ospf (1-65535) route",
9120 "OSPF information\n"
9122 "OSPF routing table\n")
9126 u_short instance
= 0;
9128 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
9129 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9132 return show_ip_ospf_route_common(vty
, ospf
);
9135 const char *ospf_abr_type_str
[] =
9144 const char *ospf_shortcut_mode_str
[] =
9153 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
9155 memset (buf
, 0, length
);
9157 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9158 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
9160 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
9164 const char *ospf_int_type_str
[] =
9166 "unknown", /* should never be used. */
9170 "point-to-multipoint",
9171 "virtual-link", /* should never be used. */
9175 /* Configuration write function for ospfd. */
9177 config_write_interface (struct vty
*vty
)
9179 struct listnode
*n1
, *n2
;
9180 struct interface
*ifp
;
9181 struct crypt_key
*ck
;
9183 struct route_node
*rn
= NULL
;
9184 struct ospf_if_params
*params
;
9185 struct ospf
*ospf
= ospf_lookup();
9187 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
9189 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
9192 if (ifp
->ifindex
== IFINDEX_DELETED
)
9195 vty_out (vty
, "!%s", VTY_NEWLINE
);
9196 vty_out (vty
, "interface %s%s", ifp
->name
,
9199 vty_out (vty
, " description %s%s", ifp
->desc
,
9204 params
= IF_DEF_PARAMS (ifp
);
9207 /* Interface Network print. */
9208 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
9209 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
9211 if (params
->type
!= ospf_default_iftype(ifp
))
9213 vty_out (vty
, " ip ospf network %s",
9214 ospf_int_type_str
[params
->type
]);
9215 if (params
!= IF_DEF_PARAMS (ifp
))
9216 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9217 vty_out (vty
, "%s", VTY_NEWLINE
);
9221 /* OSPF interface authentication print */
9222 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
9223 params
->auth_type
!= OSPF_AUTH_NOTSET
)
9225 const char *auth_str
;
9227 /* Translation tables are not that much help here due to syntax
9228 of the simple option */
9229 switch (params
->auth_type
)
9232 case OSPF_AUTH_NULL
:
9236 case OSPF_AUTH_SIMPLE
:
9240 case OSPF_AUTH_CRYPTOGRAPHIC
:
9241 auth_str
= " message-digest";
9249 vty_out (vty
, " ip ospf authentication%s", auth_str
);
9250 if (params
!= IF_DEF_PARAMS (ifp
))
9251 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9252 vty_out (vty
, "%s", VTY_NEWLINE
);
9255 /* Simple Authentication Password print. */
9256 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
9257 params
->auth_simple
[0] != '\0')
9259 vty_out (vty
, " ip ospf authentication-key %s",
9260 params
->auth_simple
);
9261 if (params
!= IF_DEF_PARAMS (ifp
))
9262 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9263 vty_out (vty
, "%s", VTY_NEWLINE
);
9266 /* Cryptographic Authentication Key print. */
9267 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
9269 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
9270 ck
->key_id
, ck
->auth_key
);
9271 if (params
!= IF_DEF_PARAMS (ifp
))
9272 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9273 vty_out (vty
, "%s", VTY_NEWLINE
);
9276 /* Interface Output Cost print. */
9277 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
9279 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
9280 if (params
!= IF_DEF_PARAMS (ifp
))
9281 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9282 vty_out (vty
, "%s", VTY_NEWLINE
);
9285 /* Hello Interval print. */
9286 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
9287 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
9289 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
9290 if (params
!= IF_DEF_PARAMS (ifp
))
9291 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9292 vty_out (vty
, "%s", VTY_NEWLINE
);
9296 /* Router Dead Interval print. */
9297 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
9298 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
9300 vty_out (vty
, " ip ospf dead-interval ");
9303 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
9304 vty_out (vty
, "minimal hello-multiplier %d",
9305 params
->fast_hello
);
9307 vty_out (vty
, "%u", params
->v_wait
);
9309 if (params
!= IF_DEF_PARAMS (ifp
))
9310 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9311 vty_out (vty
, "%s", VTY_NEWLINE
);
9314 /* Router Priority print. */
9315 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
9316 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
9318 vty_out (vty
, " ip ospf priority %u", params
->priority
);
9319 if (params
!= IF_DEF_PARAMS (ifp
))
9320 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9321 vty_out (vty
, "%s", VTY_NEWLINE
);
9324 /* Retransmit Interval print. */
9325 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
9326 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
9328 vty_out (vty
, " ip ospf retransmit-interval %u",
9329 params
->retransmit_interval
);
9330 if (params
!= IF_DEF_PARAMS (ifp
))
9331 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9332 vty_out (vty
, "%s", VTY_NEWLINE
);
9335 /* Transmit Delay print. */
9336 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
9337 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
9339 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
9340 if (params
!= IF_DEF_PARAMS (ifp
))
9341 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9342 vty_out (vty
, "%s", VTY_NEWLINE
);
9346 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
9349 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
9350 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9352 vty_out (vty
, " ip ospf area %s%s",
9353 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9358 ospf_bfd_write_config(vty
, params
);
9360 /* MTU ignore print. */
9361 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
9362 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9364 if (params
->mtu_ignore
== 0)
9365 vty_out (vty
, " no ip ospf mtu-ignore");
9367 vty_out (vty
, " ip ospf mtu-ignore");
9368 if (params
!= IF_DEF_PARAMS (ifp
))
9369 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9370 vty_out (vty
, "%s", VTY_NEWLINE
);
9377 rn
= route_top (IF_OIFS_PARAMS (ifp
));
9379 rn
= route_next (rn
);
9389 ospf_opaque_config_write_if (vty
, ifp
);
9396 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
9398 struct route_node
*rn
;
9399 u_char buf
[INET_ADDRSTRLEN
];
9401 /* `network area' print. */
9402 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
9405 struct ospf_network
*n
= rn
->info
;
9407 memset (buf
, 0, INET_ADDRSTRLEN
);
9409 /* Create Area ID string by specified Area ID format. */
9410 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9411 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
9413 sprintf ((char *) buf
, "%lu",
9414 (unsigned long int) ntohl (n
->area_id
.s_addr
));
9416 /* Network print. */
9417 vty_out (vty
, " network %s/%d area %s%s",
9418 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9426 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
9428 struct listnode
*node
;
9429 struct ospf_area
*area
;
9430 u_char buf
[INET_ADDRSTRLEN
];
9432 /* Area configuration print. */
9433 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
9435 struct route_node
*rn1
;
9437 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
9439 if (area
->auth_type
!= OSPF_AUTH_NULL
)
9441 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9442 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
9444 vty_out (vty
, " area %s authentication message-digest%s",
9448 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9449 vty_out (vty
, " area %s shortcut %s%s", buf
,
9450 ospf_shortcut_mode_str
[area
->shortcut_configured
],
9453 if ((area
->external_routing
== OSPF_AREA_STUB
)
9454 || (area
->external_routing
== OSPF_AREA_NSSA
)
9457 if (area
->external_routing
== OSPF_AREA_STUB
)
9458 vty_out (vty
, " area %s stub", buf
);
9459 else if (area
->external_routing
== OSPF_AREA_NSSA
)
9461 vty_out (vty
, " area %s nssa", buf
);
9462 switch (area
->NSSATranslatorRole
)
9464 case OSPF_NSSA_ROLE_NEVER
:
9465 vty_out (vty
, " translate-never");
9467 case OSPF_NSSA_ROLE_ALWAYS
:
9468 vty_out (vty
, " translate-always");
9470 case OSPF_NSSA_ROLE_CANDIDATE
:
9472 vty_out (vty
, " translate-candidate");
9476 if (area
->no_summary
)
9477 vty_out (vty
, " no-summary");
9479 vty_out (vty
, "%s", VTY_NEWLINE
);
9481 if (area
->default_cost
!= 1)
9482 vty_out (vty
, " area %s default-cost %d%s", buf
,
9483 area
->default_cost
, VTY_NEWLINE
);
9486 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
9489 struct ospf_area_range
*range
= rn1
->info
;
9491 vty_out (vty
, " area %s range %s/%d", buf
,
9492 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
9494 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
9495 vty_out (vty
, " cost %d", range
->cost_config
);
9497 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
9498 vty_out (vty
, " not-advertise");
9500 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
9501 vty_out (vty
, " substitute %s/%d",
9502 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
9504 vty_out (vty
, "%s", VTY_NEWLINE
);
9507 if (EXPORT_NAME (area
))
9508 vty_out (vty
, " area %s export-list %s%s", buf
,
9509 EXPORT_NAME (area
), VTY_NEWLINE
);
9511 if (IMPORT_NAME (area
))
9512 vty_out (vty
, " area %s import-list %s%s", buf
,
9513 IMPORT_NAME (area
), VTY_NEWLINE
);
9515 if (PREFIX_NAME_IN (area
))
9516 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
9517 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
9519 if (PREFIX_NAME_OUT (area
))
9520 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
9521 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
9528 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
9530 struct ospf_nbr_nbma
*nbr_nbma
;
9531 struct route_node
*rn
;
9533 /* Static Neighbor configuration print. */
9534 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
9535 if ((nbr_nbma
= rn
->info
))
9537 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
9539 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9540 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
9542 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9543 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
9545 vty_out (vty
, "%s", VTY_NEWLINE
);
9552 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
9554 struct listnode
*node
;
9555 struct ospf_vl_data
*vl_data
;
9556 u_char buf
[INET_ADDRSTRLEN
];
9558 /* Virtual-Link print */
9559 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
9561 struct listnode
*n2
;
9562 struct crypt_key
*ck
;
9563 struct ospf_interface
*oi
;
9565 if (vl_data
!= NULL
)
9567 memset (buf
, 0, INET_ADDRSTRLEN
);
9569 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9570 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
9572 sprintf ((char *) buf
, "%lu",
9573 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
9574 oi
= vl_data
->vl_oi
;
9577 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
9578 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
9579 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
9580 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
9581 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9583 inet_ntoa (vl_data
->vl_peer
),
9584 OSPF_IF_PARAM (oi
, v_hello
),
9585 OSPF_IF_PARAM (oi
, retransmit_interval
),
9586 OSPF_IF_PARAM (oi
, transmit_delay
),
9587 OSPF_IF_PARAM (oi
, v_wait
),
9590 vty_out (vty
, " area %s virtual-link %s%s", buf
,
9591 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
9593 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
9594 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
9596 inet_ntoa (vl_data
->vl_peer
),
9597 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
9600 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
9602 vty_out (vty
, " area %s virtual-link %s"
9603 " message-digest-key %d md5 %s%s",
9605 inet_ntoa (vl_data
->vl_peer
),
9606 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
9616 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
9620 /* redistribute print. */
9621 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9623 struct list
*red_list
;
9624 struct listnode
*node
;
9625 struct ospf_redist
*red
;
9627 red_list
= ospf
->redist
[type
];
9631 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
9633 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
9635 vty_out (vty
, " %d", red
->instance
);
9637 if (red
->dmetric
.value
>= 0)
9638 vty_out (vty
, " metric %d", red
->dmetric
.value
);
9640 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9641 vty_out (vty
, " metric-type 1");
9643 if (ROUTEMAP_NAME (red
))
9644 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
9646 vty_out (vty
, "%s", VTY_NEWLINE
);
9654 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
9656 if (ospf
->default_metric
!= -1)
9657 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
9663 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
9666 struct ospf_redist
*red
;
9670 /* distribute-list print. */
9671 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9672 if (DISTRIBUTE_NAME (ospf
, type
))
9673 vty_out (vty
, " distribute-list %s out %s%s",
9674 DISTRIBUTE_NAME (ospf
, type
),
9675 zebra_route_string(type
), VTY_NEWLINE
);
9677 /* default-information print. */
9678 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
9680 vty_out (vty
, " default-information originate");
9681 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9682 vty_out (vty
, " always");
9684 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9687 if (red
->dmetric
.value
>= 0)
9688 vty_out (vty
, " metric %d",
9689 red
->dmetric
.value
);
9690 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9691 vty_out (vty
, " metric-type 1");
9693 if (ROUTEMAP_NAME (red
))
9694 vty_out (vty
, " route-map %s",
9695 ROUTEMAP_NAME (red
));
9698 vty_out (vty
, "%s", VTY_NEWLINE
);
9707 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9709 struct route_node
*rn
;
9710 struct ospf_distance
*odistance
;
9712 if (ospf
->distance_all
)
9713 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9715 if (ospf
->distance_intra
9716 || ospf
->distance_inter
9717 || ospf
->distance_external
)
9719 vty_out (vty
, " distance ospf");
9721 if (ospf
->distance_intra
)
9722 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9723 if (ospf
->distance_inter
)
9724 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9725 if (ospf
->distance_external
)
9726 vty_out (vty
, " external %d", ospf
->distance_external
);
9728 vty_out (vty
, "%s", VTY_NEWLINE
);
9731 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9732 if ((odistance
= rn
->info
) != NULL
)
9734 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9735 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9736 odistance
->access_list
? odistance
->access_list
: "",
9742 /* OSPF configuration write function. */
9744 ospf_config_write (struct vty
*vty
)
9747 struct interface
*ifp
;
9748 struct ospf_interface
*oi
;
9749 struct listnode
*node
;
9752 ospf
= ospf_lookup ();
9753 if (ospf
!= NULL
&& ospf
->oi_running
)
9755 /* `router ospf' print. */
9757 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9759 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9763 if (!ospf
->networks
)
9766 /* Router ID print. */
9767 if (ospf
->router_id_static
.s_addr
!= 0)
9768 vty_out (vty
, " ospf router-id %s%s",
9769 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9771 /* ABR type print. */
9772 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9773 vty_out (vty
, " ospf abr-type %s%s",
9774 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9776 /* log-adjacency-changes flag print. */
9777 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9779 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9780 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9784 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9787 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9788 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9789 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9791 /* auto-cost reference-bandwidth configuration. */
9792 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9794 vty_out (vty
, "! Important: ensure reference bandwidth "
9795 "is consistent across all routers%s", VTY_NEWLINE
);
9796 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9797 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9800 /* SPF timers print. */
9801 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9802 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9803 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9804 vty_out (vty
, " timers throttle spf %d %d %d%s",
9805 ospf
->spf_delay
, ospf
->spf_holdtime
,
9806 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9808 /* LSA timers print. */
9809 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9810 vty_out (vty
, " timers throttle lsa all %d%s",
9811 ospf
->min_ls_interval
, VTY_NEWLINE
);
9812 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9813 vty_out (vty
, " timers lsa min-arrival %d%s",
9814 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9816 /* Write multiplier print. */
9817 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9818 vty_out (vty
, " ospf write-multiplier %d%s",
9819 ospf
->write_oi_count
, VTY_NEWLINE
);
9821 /* Max-metric router-lsa print */
9822 config_write_stub_router (vty
, ospf
);
9824 /* SPF refresh parameters print. */
9825 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9826 vty_out (vty
, " refresh timer %d%s",
9827 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9829 /* Redistribute information print. */
9830 config_write_ospf_redistribute (vty
, ospf
);
9832 /* passive-interface print. */
9833 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9834 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9836 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9837 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9838 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9839 ospf
->passive_interface_default
)
9841 vty_out (vty
, " %spassive-interface %s%s",
9842 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9843 ifp
->name
, VTY_NEWLINE
);
9845 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9847 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9849 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9852 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9855 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9858 vty_out (vty
, " %spassive-interface %s %s%s",
9859 oi
->params
->passive_interface
? "" : "no ",
9861 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9864 /* Network area print. */
9865 config_write_network_area (vty
, ospf
);
9867 /* Area config print. */
9868 config_write_ospf_area (vty
, ospf
);
9870 /* static neighbor print. */
9871 config_write_ospf_nbr_nbma (vty
, ospf
);
9873 /* Virtual-Link print. */
9874 config_write_virtual_link (vty
, ospf
);
9876 /* Default metric configuration. */
9877 config_write_ospf_default_metric (vty
, ospf
);
9879 /* Distribute-list and default-information print. */
9880 config_write_ospf_distribute (vty
, ospf
);
9882 /* Distance configuration. */
9883 config_write_ospf_distance (vty
, ospf
);
9885 ospf_opaque_config_write_router (vty
, ospf
);
9892 ospf_vty_show_init (void)
9894 /* "show ip ospf" commands. */
9895 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9897 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9899 /* "show ip ospf database" commands. */
9900 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9901 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
9902 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9904 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
9905 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9906 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9908 /* "show ip ospf interface" commands. */
9909 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9911 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9913 /* "show ip ospf neighbor" commands. */
9914 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9915 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9916 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9917 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9918 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9919 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9920 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9922 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
9923 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
9924 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
9925 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
9926 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
9927 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
9928 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
9930 /* "show ip ospf route" commands. */
9931 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
9932 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
9934 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
9935 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9939 /* ospfd's interface node. */
9940 static struct cmd_node interface_node
=
9947 /* Initialization of OSPF interface. */
9949 ospf_vty_if_init (void)
9951 /* Install interface node. */
9952 install_node (&interface_node
, config_write_interface
);
9954 install_element (CONFIG_NODE
, &interface_cmd
);
9955 install_element (CONFIG_NODE
, &no_interface_cmd
);
9956 install_default (INTERFACE_NODE
);
9958 /* "description" commands. */
9959 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
9960 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
9962 /* "ip ospf authentication" commands. */
9963 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9964 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9965 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9966 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9967 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9968 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9969 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9971 /* "ip ospf message-digest-key" commands. */
9972 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_addr_cmd
);
9973 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_addr_cmd
);
9974 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_addr_cmd
);
9975 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_addr_cmd
);
9977 /* "ip ospf cost" commands. */
9978 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_inet4_cmd
);
9979 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_cmd
);
9980 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_inet4_cmd
);
9981 install_element (INTERFACE_NODE
, &no_ospf_cost_inet4_cmd
);
9982 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_cmd
);
9984 /* "ip ospf mtu-ignore" commands. */
9985 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9986 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9988 /* "ip ospf dead-interval" commands. */
9989 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_addr_cmd
);
9990 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9991 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_addr_cmd
);
9993 /* "ip ospf hello-interval" commands. */
9994 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_addr_cmd
);
9995 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_addr_cmd
);
9997 /* "ip ospf network" commands. */
9998 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9999 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10000 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
10002 /* "ip ospf priority" commands. */
10003 install_element (INTERFACE_NODE
, &ip_ospf_priority_addr_cmd
);
10004 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_addr_cmd
);
10005 install_element (INTERFACE_NODE
, &no_ospf_priority_addr_cmd
);
10007 /* "ip ospf retransmit-interval" commands. */
10008 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10009 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
10010 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10012 /* "ip ospf transmit-delay" commands. */
10013 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10014 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10015 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_cmd
);
10016 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10018 /* "ip ospf area" commands. */
10019 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
10020 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10021 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_cmd
);
10023 /* These commands are compatibitliy for previous version. */
10024 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10025 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10026 install_element (INTERFACE_NODE
, &ospf_cost_u32_inet4_cmd
);
10027 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10028 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10029 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
10030 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
10031 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10032 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10036 ospf_vty_zebra_init (void)
10038 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
10039 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10040 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10041 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10043 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10044 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10046 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
10047 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10049 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
10050 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
10052 install_element (OSPF_NODE
, &ospf_distance_cmd
);
10053 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
10054 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10055 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
10057 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10058 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10059 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10060 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10064 static struct cmd_node ospf_node
=
10067 "%s(config-router)# ",
10072 ospf_interface_clear (struct interface
*ifp
)
10074 if (!if_is_operative (ifp
)) return;
10076 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
10077 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
10079 ospf_if_reset(ifp
);
10082 DEFUN (clear_ip_ospf_interface
,
10083 clear_ip_ospf_interface_cmd
,
10084 "clear ip ospf interface [IFNAME]",
10087 "OSPF information\n"
10088 "Interface information\n"
10089 "Interface name\n")
10091 int idx_ifname
= 4;
10092 struct interface
*ifp
;
10093 struct listnode
*node
;
10095 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
10097 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
10098 ospf_interface_clear(ifp
);
10100 else /* Interface name is specified. */
10102 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
10103 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
10105 ospf_interface_clear(ifp
);
10108 return CMD_SUCCESS
;
10112 ospf_vty_clear_init (void)
10114 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10118 /* Install OSPF related vty commands. */
10120 ospf_vty_init (void)
10122 /* Install ospf top node. */
10123 install_node (&ospf_node
, ospf_config_write
);
10125 /* "router ospf" commands. */
10126 install_element (CONFIG_NODE
, &router_ospf_cmd
);
10127 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
10130 install_default (OSPF_NODE
);
10132 /* "ospf router-id" commands. */
10133 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
10134 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
10135 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
10137 /* "passive-interface" commands. */
10138 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10139 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10141 /* "ospf abr-type" commands. */
10142 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
10143 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
10145 /* "ospf log-adjacency-changes" commands. */
10146 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10147 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10148 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10149 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10151 /* "ospf rfc1583-compatible" commands. */
10152 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10153 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10154 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10155 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10157 /* "network area" commands. */
10158 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
10159 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
10161 /* "area authentication" commands. */
10162 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
10163 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
10164 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10166 /* "area range" commands. */
10167 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
10168 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
10169 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10170 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
10171 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10172 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10174 /* "area virtual-link" commands. */
10175 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
10176 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
10177 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10178 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
10189 /* "area stub" commands. */
10190 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10191 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
10192 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10193 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
10195 /* "area nssa" commands. */
10196 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
10197 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
10198 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10199 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10200 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10202 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
10203 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10205 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
10206 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10208 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
10209 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10211 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
10212 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10214 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
10215 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10217 /* SPF timer commands */
10218 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10219 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10221 /* LSA timers commands */
10222 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10223 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10224 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
10225 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
10226 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
10227 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
10229 /* refresh timer commands */
10230 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
10231 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10233 /* max-metric commands */
10234 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10235 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10236 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10237 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10238 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10239 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10241 /* reference bandwidth commands */
10242 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10243 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10245 /* "neighbor" commands. */
10246 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
10247 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10248 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
10249 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
10251 /* write multiplier commands */
10252 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
10253 install_element (OSPF_NODE
, &write_multiplier_cmd
);
10254 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10255 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
10257 /* Init interface related vty commands. */
10258 ospf_vty_if_init ();
10260 /* Init zebra related vty commands. */
10261 ospf_vty_zebra_init ();