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 [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)] [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)] [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)] [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)] ",
1167 VLINK_HELPSTR_IPADDR
1168 VLINK_HELPSTR_TIME_PARAM
1169 VLINK_HELPSTR_TIME_PARAM
1170 VLINK_HELPSTR_TIME_PARAM
1171 VLINK_HELPSTR_TIME_PARAM
)
1173 int idx_ipv4_number
= 1;
1175 struct ospf
*ospf
= vty
->index
;
1176 struct ospf_vl_config_data vl_config
;
1183 ospf_vl_config_data_init(&vl_config
, vty
);
1185 /* Read off first 2 parameters and check them */
1186 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &vl_config
.format
);
1189 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1193 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1196 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1203 /* Thats all folks! - BUGS B. strikes again!!!*/
1205 return ospf_vl_set (ospf
, &vl_config
);
1208 /* Deal with other parameters */
1209 for (i
=5; i
< argc
; i
++)
1212 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->arg, VTY_NEWLINE); */
1214 switch (argv
[i
]->arg
[0])
1218 /* Hello interval */
1220 vl_config
.hello_interval
= strtol (argv
[i
]->arg
, NULL
, 10);
1221 if (vl_config
.hello_interval
< 0)
1226 /* Retransmit Interval */
1228 vl_config
.retransmit_interval
= strtol (argv
[i
]->arg
, NULL
, 10);
1229 if (vl_config
.retransmit_interval
< 0)
1234 /* Transmit Delay */
1236 vl_config
.transmit_delay
= strtol (argv
[i
]->arg
, NULL
, 10);
1237 if (vl_config
.transmit_delay
< 0)
1244 vl_config
.dead_interval
= strtol (argv
[i
]->arg
, NULL
, 10);
1245 if (vl_config
.dead_interval
< 0)
1252 /* Action configuration */
1254 return ospf_vl_set (ospf
, &vl_config
);
1258 DEFUN (no_ospf_area_vlink
,
1259 no_ospf_area_vlink_cmd
,
1260 "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>]",
1262 VLINK_HELPSTR_IPADDR
1263 "Enable authentication on this virtual link\n" \
1264 "Use null authentication\n" \
1265 "Use message-digest authentication\n"
1266 "Message digest authentication password (key)\n" \
1268 "Use MD5 algorithm\n" \
1269 "The OSPF password (key)")
1271 int idx_ipv4_number
= 2;
1273 struct ospf
*ospf
= vty
->index
;
1274 struct ospf_area
*area
;
1275 struct ospf_vl_config_data vl_config
;
1276 struct ospf_vl_data
*vl_data
= NULL
;
1277 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1284 ospf_vl_config_data_init(&vl_config
, vty
);
1286 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1289 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1293 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1296 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1300 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1303 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1310 /* Basic VLink no command */
1311 /* Thats all folks! - BUGS B. strikes again!!!*/
1312 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1313 ospf_vl_delete (ospf
, vl_data
);
1315 ospf_area_check_free (ospf
, vl_config
.area_id
);
1320 /* If we are down here, we are reseting parameters */
1322 /* Deal with other parameters */
1323 for (i
=6; argc
; i
++)
1325 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1327 switch (argv
[i
]->arg
[0])
1331 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1333 /* authentication-key - this option can occur anywhere on
1334 command line. At start of command line
1335 must check for authentication option. */
1336 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1337 vl_config
.auth_key
= auth_key
;
1339 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1341 /* authentication - this option can only occur at start
1343 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1348 /* message-digest-key */
1349 /* Delete one key */
1351 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1352 if (vl_config
.crypto_key_id
< 0)
1354 vl_config
.md5_key
= NULL
;
1361 /* Action configuration */
1363 return ospf_vl_set (ospf
, &vl_config
);
1366 DEFUN (no_ospf_area_vlink_intervals
,
1367 no_ospf_area_vlink_intervals_cmd
,
1368 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)] [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)] [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)] [<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)]",
1369 VLINK_HELPSTR_IPADDR
1370 VLINK_HELPSTR_TIME_PARAM
1371 VLINK_HELPSTR_TIME_PARAM
1372 VLINK_HELPSTR_TIME_PARAM
1373 VLINK_HELPSTR_TIME_PARAM
)
1375 int idx_ipv4_number
= 2;
1377 struct ospf
*ospf
= vty
->index
;
1378 struct ospf_area
*area
;
1379 struct ospf_vl_config_data vl_config
;
1380 struct ospf_vl_data
*vl_data
= NULL
;
1387 ospf_vl_config_data_init(&vl_config
, vty
);
1389 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1392 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1396 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1399 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1403 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1406 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1413 /* Basic VLink no command */
1414 /* Thats all folks! - BUGS B. strikes again!!!*/
1415 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1416 ospf_vl_delete (ospf
, vl_data
);
1418 ospf_area_check_free (ospf
, vl_config
.area_id
);
1423 /* If we are down here, we are reseting parameters */
1425 /* Deal with other parameters */
1426 for (i
=6; i
< argc
; i
++)
1428 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i]->arg, VTY_NEWLINE); */
1430 switch (argv
[i
]->arg
[0])
1434 /* Hello interval */
1435 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1439 /* Retransmit Interval */
1440 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1444 /* Transmit Delay */
1445 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1451 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1457 /* Action configuration */
1459 return ospf_vl_set (ospf
, &vl_config
);
1462 DEFUN (ospf_area_shortcut
,
1463 ospf_area_shortcut_cmd
,
1464 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
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 the area's shortcutting mode\n"
1469 "Set default shortcutting behavior\n"
1470 "Enable shortcutting through the area\n"
1471 "Disable shortcutting through the area\n")
1473 int idx_ipv4_number
= 1;
1474 int idx_enable_disable
= 3;
1475 struct ospf
*ospf
= vty
->index
;
1476 struct ospf_area
*area
;
1477 struct in_addr area_id
;
1484 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1486 area
= ospf_area_get (ospf
, area_id
, format
);
1488 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1489 mode
= OSPF_SHORTCUT_DEFAULT
;
1490 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1491 mode
= OSPF_SHORTCUT_DISABLE
;
1492 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1493 mode
= OSPF_SHORTCUT_ENABLE
;
1497 ospf_area_shortcut_set (ospf
, area
, mode
);
1499 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1500 vty_out (vty
, "Shortcut area setting will take effect "
1501 "only when the router is configured as Shortcut ABR%s",
1507 DEFUN (no_ospf_area_shortcut
,
1508 no_ospf_area_shortcut_cmd
,
1509 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1511 "OSPF area parameters\n"
1512 "OSPF area ID in IP address format\n"
1513 "OSPF area ID as a decimal value\n"
1514 "Deconfigure the area's shortcutting mode\n"
1515 "Deconfigure enabled shortcutting through the area\n"
1516 "Deconfigure disabled shortcutting through the area\n")
1518 int idx_ipv4_number
= 2;
1519 struct ospf
*ospf
= vty
->index
;
1520 struct ospf_area
*area
;
1521 struct in_addr area_id
;
1527 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1529 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1533 ospf_area_shortcut_unset (ospf
, area
);
1539 DEFUN (ospf_area_stub
,
1541 "area <A.B.C.D|(0-4294967295)> stub",
1542 "OSPF area parameters\n"
1543 "OSPF area ID in IP address format\n"
1544 "OSPF area ID as a decimal value\n"
1545 "Configure OSPF area as stub\n")
1547 int idx_ipv4_number
= 1;
1548 struct ospf
*ospf
= vty
->index
;
1549 struct in_addr area_id
;
1555 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1557 ret
= ospf_area_stub_set (ospf
, area_id
);
1560 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1565 ospf_area_no_summary_unset (ospf
, area_id
);
1570 DEFUN (ospf_area_stub_no_summary
,
1571 ospf_area_stub_no_summary_cmd
,
1572 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1573 "OSPF stub parameters\n"
1574 "OSPF area ID in IP address format\n"
1575 "OSPF area ID as a decimal value\n"
1576 "Configure OSPF area as stub\n"
1577 "Do not inject inter-area routes into stub\n")
1579 int idx_ipv4_number
= 1;
1580 struct ospf
*ospf
= vty
->index
;
1581 struct in_addr area_id
;
1587 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1589 ret
= ospf_area_stub_set (ospf
, area_id
);
1592 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1597 ospf_area_no_summary_set (ospf
, area_id
);
1602 DEFUN (no_ospf_area_stub
,
1603 no_ospf_area_stub_cmd
,
1604 "no area <A.B.C.D|(0-4294967295)> stub",
1606 "OSPF area parameters\n"
1607 "OSPF area ID in IP address format\n"
1608 "OSPF area ID as a decimal value\n"
1609 "Configure OSPF area as stub\n")
1611 int idx_ipv4_number
= 2;
1612 struct ospf
*ospf
= vty
->index
;
1613 struct in_addr area_id
;
1619 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1621 ospf_area_stub_unset (ospf
, area_id
);
1622 ospf_area_no_summary_unset (ospf
, area_id
);
1627 DEFUN (no_ospf_area_stub_no_summary
,
1628 no_ospf_area_stub_no_summary_cmd
,
1629 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1631 "OSPF area parameters\n"
1632 "OSPF area ID in IP address format\n"
1633 "OSPF area ID as a decimal value\n"
1634 "Configure OSPF area as stub\n"
1635 "Do not inject inter-area routes into area\n")
1637 int idx_ipv4_number
= 2;
1638 struct ospf
*ospf
= vty
->index
;
1639 struct in_addr area_id
;
1645 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1646 ospf_area_no_summary_unset (ospf
, area_id
);
1652 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1655 struct ospf
*ospf
= vty
->index
;
1656 struct in_addr area_id
;
1662 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1664 ret
= ospf_area_nssa_set (ospf
, area_id
);
1667 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1674 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1675 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1676 OSPF_NSSA_ROLE_CANDIDATE
);
1677 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1678 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1679 OSPF_NSSA_ROLE_NEVER
);
1680 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1681 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1682 OSPF_NSSA_ROLE_ALWAYS
);
1686 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1687 OSPF_NSSA_ROLE_CANDIDATE
);
1691 ospf_area_no_summary_set (ospf
, area_id
);
1693 ospf_area_no_summary_unset (ospf
, area_id
);
1695 ospf_schedule_abr_task (ospf
);
1700 DEFUN (ospf_area_nssa_translate_no_summary
,
1701 ospf_area_nssa_translate_no_summary_cmd
,
1702 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1703 "OSPF area parameters\n"
1704 "OSPF area ID in IP address format\n"
1705 "OSPF area ID as a decimal value\n"
1706 "Configure OSPF area as nssa\n"
1707 "Configure NSSA-ABR for translate election (default)\n"
1708 "Configure NSSA-ABR to never translate\n"
1709 "Configure NSSA-ABR to always translate\n"
1710 "Do not inject inter-area routes into nssa\n")
1712 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1715 DEFUN (ospf_area_nssa_translate
,
1716 ospf_area_nssa_translate_cmd
,
1717 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1718 "OSPF area parameters\n"
1719 "OSPF area ID in IP address format\n"
1720 "OSPF area ID as a decimal value\n"
1721 "Configure OSPF area as nssa\n"
1722 "Configure NSSA-ABR for translate election (default)\n"
1723 "Configure NSSA-ABR to never translate\n"
1724 "Configure NSSA-ABR to always translate\n")
1726 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1729 DEFUN (ospf_area_nssa
,
1731 "area <A.B.C.D|(0-4294967295)> nssa",
1732 "OSPF area parameters\n"
1733 "OSPF area ID in IP address format\n"
1734 "OSPF area ID as a decimal value\n"
1735 "Configure OSPF area as nssa\n")
1737 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1740 DEFUN (ospf_area_nssa_no_summary
,
1741 ospf_area_nssa_no_summary_cmd
,
1742 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1743 "OSPF area parameters\n"
1744 "OSPF area ID in IP address format\n"
1745 "OSPF area ID as a decimal value\n"
1746 "Configure OSPF area as nssa\n"
1747 "Do not inject inter-area routes into nssa\n")
1749 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1752 DEFUN (no_ospf_area_nssa
,
1753 no_ospf_area_nssa_cmd
,
1754 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1756 "OSPF area parameters\n"
1757 "OSPF area ID in IP address format\n"
1758 "OSPF area ID as a decimal value\n"
1759 "Configure OSPF area as nssa\n"
1760 "Configure NSSA-ABR for translate election (default)\n"
1761 "Configure NSSA-ABR to never translate\n"
1762 "Configure NSSA-ABR to always translate\n"
1763 "Do not inject inter-area routes into nssa\n")
1765 int idx_ipv4_number
= 2;
1766 struct ospf
*ospf
= vty
->index
;
1767 struct in_addr area_id
;
1773 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1775 ospf_area_nssa_unset (ospf
, area_id
);
1776 ospf_area_no_summary_unset (ospf
, area_id
);
1778 ospf_schedule_abr_task (ospf
);
1784 DEFUN (ospf_area_default_cost
,
1785 ospf_area_default_cost_cmd
,
1786 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1787 "OSPF area parameters\n"
1788 "OSPF area ID in IP address format\n"
1789 "OSPF area ID as a decimal value\n"
1790 "Set the summary-default cost of a NSSA or stub area\n"
1791 "Stub's advertised default summary cost\n")
1793 int idx_ipv4_number
= 1;
1795 struct ospf
*ospf
= vty
->index
;
1796 struct ospf_area
*area
;
1797 struct in_addr area_id
;
1800 struct prefix_ipv4 p
;
1805 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1806 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1808 area
= ospf_area_get (ospf
, area_id
, format
);
1810 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1812 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1816 area
->default_cost
= cost
;
1819 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1821 if (IS_DEBUG_OSPF_EVENT
)
1822 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1823 "announcing 0.0.0.0/0 to area %s",
1824 inet_ntoa (area
->area_id
));
1825 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1830 DEFUN (no_ospf_area_default_cost
,
1831 no_ospf_area_default_cost_cmd
,
1832 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1834 "OSPF area parameters\n"
1835 "OSPF area ID in IP address format\n"
1836 "OSPF area ID as a decimal value\n"
1837 "Set the summary-default cost of a NSSA or stub area\n"
1838 "Stub's advertised default summary cost\n")
1840 int idx_ipv4_number
= 2;
1842 struct ospf
*ospf
= vty
->index
;
1843 struct ospf_area
*area
;
1844 struct in_addr area_id
;
1846 struct prefix_ipv4 p
;
1851 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1852 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1854 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1858 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1860 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1864 area
->default_cost
= 1;
1867 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1869 if (IS_DEBUG_OSPF_EVENT
)
1870 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1871 "announcing 0.0.0.0/0 to area %s",
1872 inet_ntoa (area
->area_id
));
1873 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1876 ospf_area_check_free (ospf
, area_id
);
1881 DEFUN (ospf_area_export_list
,
1882 ospf_area_export_list_cmd
,
1883 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1884 "OSPF area parameters\n"
1885 "OSPF area ID in IP address format\n"
1886 "OSPF area ID as a decimal value\n"
1887 "Set the filter for networks announced to other areas\n"
1888 "Name of the access-list\n")
1890 int idx_ipv4_number
= 1;
1891 struct ospf
*ospf
= vty
->index
;
1892 struct ospf_area
*area
;
1893 struct in_addr area_id
;
1899 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1901 area
= ospf_area_get (ospf
, area_id
, format
);
1902 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1907 DEFUN (no_ospf_area_export_list
,
1908 no_ospf_area_export_list_cmd
,
1909 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1911 "OSPF area parameters\n"
1912 "OSPF area ID in IP address format\n"
1913 "OSPF area ID as a decimal value\n"
1914 "Unset the filter for networks announced to other areas\n"
1915 "Name of the access-list\n")
1917 int idx_ipv4_number
= 2;
1918 struct ospf
*ospf
= vty
->index
;
1919 struct ospf_area
*area
;
1920 struct in_addr area_id
;
1926 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1928 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1932 ospf_area_export_list_unset (ospf
, area
);
1938 DEFUN (ospf_area_import_list
,
1939 ospf_area_import_list_cmd
,
1940 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1941 "OSPF area parameters\n"
1942 "OSPF area ID in IP address format\n"
1943 "OSPF area ID as a decimal value\n"
1944 "Set the filter for networks from other areas announced to the specified one\n"
1945 "Name of the access-list\n")
1947 int idx_ipv4_number
= 1;
1948 struct ospf
*ospf
= vty
->index
;
1949 struct ospf_area
*area
;
1950 struct in_addr area_id
;
1956 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1958 area
= ospf_area_get (ospf
, area_id
, format
);
1959 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1964 DEFUN (no_ospf_area_import_list
,
1965 no_ospf_area_import_list_cmd
,
1966 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1968 "OSPF area parameters\n"
1969 "OSPF area ID in IP address format\n"
1970 "OSPF area ID as a decimal value\n"
1971 "Unset the filter for networks announced to other areas\n"
1972 "Name of the access-list\n")
1974 int idx_ipv4_number
= 2;
1975 struct ospf
*ospf
= vty
->index
;
1976 struct ospf_area
*area
;
1977 struct in_addr area_id
;
1983 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1985 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1989 ospf_area_import_list_unset (ospf
, area
);
1994 DEFUN (ospf_area_filter_list
,
1995 ospf_area_filter_list_cmd
,
1996 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1997 "OSPF area parameters\n"
1998 "OSPF area ID in IP address format\n"
1999 "OSPF area ID as a decimal value\n"
2000 "Filter networks between OSPF areas\n"
2001 "Filter prefixes between OSPF areas\n"
2002 "Name of an IP prefix-list\n"
2003 "Filter networks sent to this area\n"
2004 "Filter networks sent from this area\n")
2006 int idx_ipv4_number
= 1;
2009 struct ospf
*ospf
= vty
->index
;
2010 struct ospf_area
*area
;
2011 struct in_addr area_id
;
2012 struct prefix_list
*plist
;
2018 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2020 area
= ospf_area_get (ospf
, area_id
, format
);
2021 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
2022 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
2024 PREFIX_LIST_IN (area
) = plist
;
2025 if (PREFIX_NAME_IN (area
))
2026 free (PREFIX_NAME_IN (area
));
2028 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
2029 ospf_schedule_abr_task (ospf
);
2033 PREFIX_LIST_OUT (area
) = plist
;
2034 if (PREFIX_NAME_OUT (area
))
2035 free (PREFIX_NAME_OUT (area
));
2037 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
2038 ospf_schedule_abr_task (ospf
);
2044 DEFUN (no_ospf_area_filter_list
,
2045 no_ospf_area_filter_list_cmd
,
2046 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
2048 "OSPF area parameters\n"
2049 "OSPF area ID in IP address format\n"
2050 "OSPF area ID as a decimal value\n"
2051 "Filter networks between OSPF areas\n"
2052 "Filter prefixes between OSPF areas\n"
2053 "Name of an IP prefix-list\n"
2054 "Filter networks sent to this area\n"
2055 "Filter networks sent from this area\n")
2057 int idx_ipv4_number
= 2;
2060 struct ospf
*ospf
= vty
->index
;
2061 struct ospf_area
*area
;
2062 struct in_addr area_id
;
2068 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2070 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
2073 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
2075 if (PREFIX_NAME_IN (area
))
2076 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
2079 PREFIX_LIST_IN (area
) = NULL
;
2080 if (PREFIX_NAME_IN (area
))
2081 free (PREFIX_NAME_IN (area
));
2083 PREFIX_NAME_IN (area
) = NULL
;
2085 ospf_schedule_abr_task (ospf
);
2089 if (PREFIX_NAME_OUT (area
))
2090 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
2093 PREFIX_LIST_OUT (area
) = NULL
;
2094 if (PREFIX_NAME_OUT (area
))
2095 free (PREFIX_NAME_OUT (area
));
2097 PREFIX_NAME_OUT (area
) = NULL
;
2099 ospf_schedule_abr_task (ospf
);
2106 DEFUN (ospf_area_authentication_message_digest
,
2107 ospf_area_authentication_message_digest_cmd
,
2108 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
2109 "OSPF area parameters\n"
2110 "OSPF area ID in IP address format\n"
2111 "OSPF area ID as a decimal value\n"
2112 "Enable authentication\n"
2113 "Use message-digest authentication\n")
2115 int idx_ipv4_number
= 1;
2116 struct ospf
*ospf
= vty
->index
;
2117 struct ospf_area
*area
;
2118 struct in_addr area_id
;
2124 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2126 area
= ospf_area_get (ospf
, area_id
, format
);
2127 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
2132 DEFUN (ospf_area_authentication
,
2133 ospf_area_authentication_cmd
,
2134 "area <A.B.C.D|(0-4294967295)> authentication",
2135 "OSPF area parameters\n"
2136 "OSPF area ID in IP address format\n"
2137 "OSPF area ID as a decimal value\n"
2138 "Enable authentication\n")
2140 int idx_ipv4_number
= 1;
2141 struct ospf
*ospf
= vty
->index
;
2142 struct ospf_area
*area
;
2143 struct in_addr area_id
;
2149 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2151 area
= ospf_area_get (ospf
, area_id
, format
);
2152 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2157 DEFUN (no_ospf_area_authentication
,
2158 no_ospf_area_authentication_cmd
,
2159 "no area <A.B.C.D|(0-4294967295)> authentication",
2161 "OSPF area parameters\n"
2162 "OSPF area ID in IP address format\n"
2163 "OSPF area ID as a decimal value\n"
2164 "Enable authentication\n")
2166 int idx_ipv4_number
= 2;
2167 struct ospf
*ospf
= vty
->index
;
2168 struct ospf_area
*area
;
2169 struct in_addr area_id
;
2175 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2177 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2181 area
->auth_type
= OSPF_AUTH_NULL
;
2183 ospf_area_check_free (ospf
, area_id
);
2189 DEFUN (ospf_abr_type
,
2191 "ospf abr-type <cisco|ibm|shortcut|standard>",
2192 "OSPF specific commands\n"
2193 "Set OSPF ABR type\n"
2194 "Alternative ABR, cisco implementation\n"
2195 "Alternative ABR, IBM implementation\n"
2197 "Standard behavior (RFC2328)\n")
2200 struct ospf
*ospf
= vty
->index
;
2201 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2206 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2207 abr_type
= OSPF_ABR_CISCO
;
2208 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2209 abr_type
= OSPF_ABR_IBM
;
2210 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2211 abr_type
= OSPF_ABR_SHORTCUT
;
2212 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2213 abr_type
= OSPF_ABR_STAND
;
2217 /* If ABR type value is changed, schedule ABR task. */
2218 if (ospf
->abr_type
!= abr_type
)
2220 ospf
->abr_type
= abr_type
;
2221 ospf_schedule_abr_task (ospf
);
2227 DEFUN (no_ospf_abr_type
,
2228 no_ospf_abr_type_cmd
,
2229 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2231 "OSPF specific commands\n"
2232 "Set OSPF ABR type\n"
2233 "Alternative ABR, cisco implementation\n"
2234 "Alternative ABR, IBM implementation\n"
2238 struct ospf
*ospf
= vty
->index
;
2239 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2244 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2245 abr_type
= OSPF_ABR_CISCO
;
2246 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2247 abr_type
= OSPF_ABR_IBM
;
2248 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2249 abr_type
= OSPF_ABR_SHORTCUT
;
2250 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2251 abr_type
= OSPF_ABR_STAND
;
2255 /* If ABR type value is changed, schedule ABR task. */
2256 if (ospf
->abr_type
== abr_type
)
2258 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2259 ospf_schedule_abr_task (ospf
);
2265 DEFUN (ospf_log_adjacency_changes
,
2266 ospf_log_adjacency_changes_cmd
,
2267 "log-adjacency-changes",
2268 "Log changes in adjacency state\n")
2270 struct ospf
*ospf
= vty
->index
;
2275 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2276 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2280 DEFUN (ospf_log_adjacency_changes_detail
,
2281 ospf_log_adjacency_changes_detail_cmd
,
2282 "log-adjacency-changes detail",
2283 "Log changes in adjacency state\n"
2284 "Log all state changes\n")
2286 struct ospf
*ospf
= vty
->index
;
2291 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2292 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2296 DEFUN (no_ospf_log_adjacency_changes
,
2297 no_ospf_log_adjacency_changes_cmd
,
2298 "no log-adjacency-changes",
2300 "Log changes in adjacency state\n")
2302 struct ospf
*ospf
= vty
->index
;
2307 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2308 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2312 DEFUN (no_ospf_log_adjacency_changes_detail
,
2313 no_ospf_log_adjacency_changes_detail_cmd
,
2314 "no log-adjacency-changes detail",
2316 "Log changes in adjacency state\n"
2317 "Log all state changes\n")
2319 struct ospf
*ospf
= vty
->index
;
2324 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2325 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2329 DEFUN (ospf_compatible_rfc1583
,
2330 ospf_compatible_rfc1583_cmd
,
2331 "compatible rfc1583",
2332 "OSPF compatibility list\n"
2333 "compatible with RFC 1583\n")
2335 struct ospf
*ospf
= vty
->index
;
2340 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2342 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2343 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2348 DEFUN (no_ospf_compatible_rfc1583
,
2349 no_ospf_compatible_rfc1583_cmd
,
2350 "no compatible rfc1583",
2352 "OSPF compatibility list\n"
2353 "compatible with RFC 1583\n")
2355 struct ospf
*ospf
= vty
->index
;
2360 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2362 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2363 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2368 ALIAS (ospf_compatible_rfc1583
,
2369 ospf_rfc1583_flag_cmd
,
2370 "ospf rfc1583compatibility",
2371 "OSPF specific commands\n"
2372 "Enable the RFC1583Compatibility flag\n")
2374 ALIAS (no_ospf_compatible_rfc1583
,
2375 no_ospf_rfc1583_flag_cmd
,
2376 "no ospf rfc1583compatibility",
2378 "OSPF specific commands\n"
2379 "Disable the RFC1583Compatibility flag\n")
2382 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2386 struct ospf
*ospf
= vty
->index
;
2391 ospf
->spf_delay
= delay
;
2392 ospf
->spf_holdtime
= hold
;
2393 ospf
->spf_max_holdtime
= max
;
2398 DEFUN (ospf_timers_min_ls_interval
,
2399 ospf_timers_min_ls_interval_cmd
,
2400 "timers throttle lsa all (0-5000)",
2401 "Adjust routing timers\n"
2402 "Throttling adaptive timer\n"
2403 "LSA delay between transmissions\n"
2405 "Delay (msec) between sending LSAs\n")
2408 struct ospf
*ospf
= vty
->index
;
2409 unsigned int interval
;
2416 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2420 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2422 ospf
->min_ls_interval
= interval
;
2427 DEFUN (no_ospf_timers_min_ls_interval
,
2428 no_ospf_timers_min_ls_interval_cmd
,
2429 "no timers throttle lsa all [(0-5000)]",
2431 "Adjust routing timers\n"
2432 "Throttling adaptive timer\n"
2433 "LSA delay between transmissions\n"
2435 "Delay (msec) between sending LSAs\n")
2437 struct ospf
*ospf
= vty
->index
;
2438 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2444 DEFUN (ospf_timers_min_ls_arrival
,
2445 ospf_timers_min_ls_arrival_cmd
,
2446 "timers lsa arrival (0-1000)",
2447 "Adjust routing timers\n"
2448 "Throttling link state advertisement delays\n"
2449 "OSPF minimum arrival interval delay\n"
2450 "Delay (msec) between accepted LSAs\n")
2453 struct ospf
*ospf
= vty
->index
;
2454 unsigned int arrival
;
2461 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2465 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2467 ospf
->min_ls_arrival
= arrival
;
2472 DEFUN (no_ospf_timers_min_ls_arrival
,
2473 no_ospf_timers_min_ls_arrival_cmd
,
2474 "no timers lsa arrival [(0-1000)]",
2476 "Adjust routing timers\n"
2477 "Throttling link state advertisement delays\n"
2478 "OSPF minimum arrival interval delay\n"
2479 "Delay (msec) between accepted LSAs\n")
2481 struct ospf
*ospf
= vty
->index
;
2486 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2492 DEFUN (ospf_timers_throttle_spf
,
2493 ospf_timers_throttle_spf_cmd
,
2494 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2495 "Adjust routing timers\n"
2496 "Throttling adaptive timer\n"
2498 "Delay (msec) from first change received till SPF calculation\n"
2499 "Initial hold time (msec) between consecutive SPF calculations\n"
2500 "Maximum hold time (msec)\n")
2503 int idx_number_2
= 4;
2504 int idx_number_3
= 5;
2505 unsigned int delay
, hold
, max
;
2509 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2513 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2514 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2515 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2517 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2520 DEFUN (no_ospf_timers_throttle_spf
,
2521 no_ospf_timers_throttle_spf_cmd
,
2522 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2524 "Adjust routing timers\n"
2525 "Throttling adaptive timer\n"
2527 "Delay (msec) from first change received till SPF calculation\n"
2528 "Initial hold time (msec) between consecutive SPF calculations\n"
2529 "Maximum hold time (msec)\n")
2531 return ospf_timers_spf_set (vty
,
2532 OSPF_SPF_DELAY_DEFAULT
,
2533 OSPF_SPF_HOLDTIME_DEFAULT
,
2534 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2538 DEFUN (ospf_timers_lsa
,
2539 ospf_timers_lsa_cmd
,
2540 "timers lsa min-arrival (0-600000)",
2541 "Adjust routing timers\n"
2543 "Minimum delay in receiving new version of a LSA\n"
2544 "Delay in milliseconds\n")
2547 unsigned int minarrival
;
2548 struct ospf
*ospf
= vty
->index
;
2555 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2559 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2561 ospf
->min_ls_arrival
= minarrival
;
2566 DEFUN (no_ospf_timers_lsa
,
2567 no_ospf_timers_lsa_cmd
,
2568 "no timers lsa min-arrival [(0-600000)]",
2570 "Adjust routing timers\n"
2572 "Minimum delay in receiving new version of a LSA\n"
2573 "Delay in milliseconds\n")
2575 unsigned int minarrival
;
2576 struct ospf
*ospf
= vty
->index
;
2583 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2585 if (ospf
->min_ls_arrival
!= minarrival
||
2586 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2590 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2595 DEFUN (ospf_neighbor
,
2597 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2599 "Neighbor IP address\n"
2600 "Neighbor Priority\n"
2602 "Dead Neighbor Polling interval\n"
2608 struct ospf
*ospf
= vty
->index
;
2609 struct in_addr nbr_addr
;
2610 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2611 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2616 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2619 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2622 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2624 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2627 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2630 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2635 DEFUN (ospf_neighbor_poll_interval
,
2636 ospf_neighbor_poll_interval_cmd
,
2637 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2639 "Neighbor IP address\n"
2640 "Dead Neighbor Polling interval\n"
2642 "OSPF priority of non-broadcast neighbor\n"
2648 struct ospf
*ospf
= vty
->index
;
2649 struct in_addr nbr_addr
;
2650 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2651 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2656 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2658 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2661 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2663 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2664 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2667 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2672 DEFUN (no_ospf_neighbor
,
2673 no_ospf_neighbor_cmd
,
2674 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2677 "Neighbor IP address\n"
2678 "Neighbor Priority\n"
2680 "Dead Neighbor Polling interval\n"
2684 struct ospf
*ospf
= vty
->index
;
2685 struct in_addr nbr_addr
;
2690 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2692 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2697 DEFUN (no_ospf_neighbor_poll
,
2698 no_ospf_neighbor_poll_cmd
,
2699 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2702 "Neighbor IP address\n"
2703 "Dead Neighbor Polling interval\n"
2705 "Neighbor Priority\n"
2709 struct ospf
*ospf
= vty
->index
;
2710 struct in_addr nbr_addr
;
2715 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2717 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2722 DEFUN (ospf_refresh_timer
,
2723 ospf_refresh_timer_cmd
,
2724 "refresh timer (10-1800)",
2725 "Adjust refresh parameters\n"
2726 "Set refresh timer\n"
2727 "Timer value in seconds\n")
2730 struct ospf
*ospf
= vty
->index
;
2731 unsigned int interval
;
2736 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2737 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2739 ospf_timers_refresh_set (ospf
, interval
);
2744 DEFUN (no_ospf_refresh_timer
,
2745 no_ospf_refresh_timer_val_cmd
,
2746 "no refresh timer [(10-1800)]",
2747 "Adjust refresh parameters\n"
2748 "Unset refresh timer\n"
2749 "Timer value in seconds\n")
2752 struct ospf
*ospf
= vty
->index
;
2753 unsigned int interval
;
2760 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2762 if (ospf
->lsa_refresh_interval
!= interval
||
2763 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2767 ospf_timers_refresh_unset (ospf
);
2773 DEFUN (ospf_auto_cost_reference_bandwidth
,
2774 ospf_auto_cost_reference_bandwidth_cmd
,
2775 "auto-cost reference-bandwidth (1-4294967)",
2776 "Calculate OSPF interface cost according to bandwidth\n"
2777 "Use reference bandwidth method to assign OSPF cost\n"
2778 "The reference bandwidth in terms of Mbits per second\n")
2781 struct ospf
*ospf
= vty
->index
;
2783 struct listnode
*node
;
2784 struct interface
*ifp
;
2789 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2790 if (refbw
< 1 || refbw
> 4294967)
2792 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2796 /* If reference bandwidth is changed. */
2797 if ((refbw
) == ospf
->ref_bandwidth
)
2800 ospf
->ref_bandwidth
= refbw
;
2801 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2802 ospf_if_recalculate_output_cost (ifp
);
2807 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2808 no_ospf_auto_cost_reference_bandwidth_cmd
,
2809 "no auto-cost reference-bandwidth [(1-4294967)]",
2811 "Calculate OSPF interface cost according to bandwidth\n"
2812 "Use reference bandwidth method to assign OSPF cost\n"
2813 "The reference bandwidth in terms of Mbits per second\n")
2815 struct ospf
*ospf
= vty
->index
;
2816 struct listnode
*node
, *nnode
;
2817 struct interface
*ifp
;
2822 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2825 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2826 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2827 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2829 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2830 ospf_if_recalculate_output_cost (ifp
);
2835 DEFUN (ospf_write_multiplier
,
2836 ospf_write_multiplier_cmd
,
2837 "ospf write-multiplier (1-100)",
2838 "OSPF specific commands\n"
2839 "Write multiplier\n"
2840 "Maximum number of interface serviced per write\n")
2843 struct ospf
*ospf
= vty
->index
;
2844 u_int32_t write_oi_count
;
2854 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2855 if (write_oi_count
< 1 || write_oi_count
> 100)
2857 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2861 ospf
->write_oi_count
= write_oi_count
;
2865 ALIAS (ospf_write_multiplier
,
2866 write_multiplier_cmd
,
2867 "write-multiplier (1-100)",
2868 "Write multiplier\n"
2869 "Maximum number of interface serviced per write\n")
2871 DEFUN (no_ospf_write_multiplier
,
2872 no_ospf_write_multiplier_cmd
,
2873 "no ospf write-multiplier (1-100)",
2875 "OSPF specific commands\n"
2876 "Write multiplier\n"
2877 "Maximum number of interface serviced per write\n")
2879 struct ospf
*ospf
= vty
->index
;
2884 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2888 ALIAS (no_ospf_write_multiplier
,
2889 no_write_multiplier_cmd
,
2890 "no write-multiplier (1-100)",
2892 "Write multiplier\n"
2893 "Maximum number of interface serviced per write\n")
2895 const char *ospf_abr_type_descr_str
[] =
2898 "Standard (RFC2328)",
2900 "Alternative Cisco",
2901 "Alternative Shortcut"
2904 const char *ospf_shortcut_mode_descr_str
[] =
2912 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2914 json_object
*json_area
= NULL
;
2917 json_area
= json_object_new_object();
2921 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2923 /* Show Area type/mode. */
2924 if (OSPF_IS_AREA_BACKBONE (area
))
2927 json_object_boolean_true_add(json_area
, "backbone");
2929 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2935 if (area
->external_routing
== OSPF_AREA_STUB
)
2937 if (area
->no_summary
)
2938 json_object_boolean_true_add(json_area
, "stubNoSummary");
2939 if (area
->shortcut_configured
)
2940 json_object_boolean_true_add(json_area
, "stubShortcut");
2942 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2944 if (area
->no_summary
)
2945 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2946 if (area
->shortcut_configured
)
2947 json_object_boolean_true_add(json_area
, "nssaShortcut");
2950 json_object_string_add(json_area
,"shortcuttingMode",
2951 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2952 if (area
->shortcut_capability
)
2953 json_object_boolean_true_add(json_area
,"sBitConcensus");
2957 if (area
->external_routing
== OSPF_AREA_STUB
)
2958 vty_out (vty
, " (Stub%s%s)",
2959 area
->no_summary
? ", no summary" : "",
2960 area
->shortcut_configured
? "; " : "");
2961 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2962 vty_out (vty
, " (NSSA%s%s)",
2963 area
->no_summary
? ", no summary" : "",
2964 area
->shortcut_configured
? "; " : "");
2966 vty_out (vty
, "%s", VTY_NEWLINE
);
2967 vty_out (vty
, " Shortcutting mode: %s",
2968 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2969 vty_out (vty
, ", S-bit consensus: %s%s",
2970 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2974 /* Show number of interfaces */
2977 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2978 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2981 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2982 "Active: %d%s", listcount (area
->oiflist
),
2983 area
->act_ints
, VTY_NEWLINE
);
2985 if (area
->external_routing
== OSPF_AREA_NSSA
)
2989 json_object_boolean_true_add(json_area
, "nssa");
2990 if (! IS_OSPF_ABR (area
->ospf
))
2991 json_object_boolean_false_add(json_area
, "abr");
2992 else if (area
->NSSATranslatorState
)
2994 json_object_boolean_true_add(json_area
, "abr");
2995 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2996 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2997 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2998 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
3002 json_object_boolean_true_add(json_area
, "abr");
3003 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3004 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
3006 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
3011 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
3012 if (! IS_OSPF_ABR (area
->ospf
))
3013 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
3015 else if (area
->NSSATranslatorState
)
3017 vty_out (vty
, " We are an ABR and ");
3018 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3019 vty_out (vty
, "the NSSA Elected Translator. %s",
3021 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3022 vty_out (vty
, "always an NSSA Translator. %s",
3027 vty_out (vty
, " We are an ABR, but ");
3028 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3029 vty_out (vty
, "not the NSSA Elected Translator. %s",
3032 vty_out (vty
, "never an NSSA Translator. %s",
3038 /* Stub-router state for this area */
3039 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
3041 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3045 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
3046 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3047 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
3048 if (area
->t_stub_router
)
3050 struct timeval result
;
3051 unsigned long time_store
= 0;
3052 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
3053 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3054 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
3059 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
3061 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3062 vty_out (vty
, " Administratively activated (indefinitely)%s",
3064 if (area
->t_stub_router
)
3065 vty_out (vty
, " Active from startup, %s remaining%s",
3066 ospf_timer_dump (area
->t_stub_router
, timebuf
,
3067 sizeof(timebuf
)), VTY_NEWLINE
);
3073 /* Show number of fully adjacent neighbors. */
3074 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
3076 /* Show authentication type. */
3077 if (area
->auth_type
== OSPF_AUTH_NULL
)
3078 json_object_string_add(json_area
, "authentication", "authenticationNone");
3079 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3080 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
3081 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3082 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
3084 if (!OSPF_IS_AREA_BACKBONE (area
))
3085 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
3087 /* Show SPF calculation times. */
3088 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
3089 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
3090 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
3091 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
3092 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
3093 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
3094 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
3095 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
3096 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3097 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3098 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3099 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3103 /* Show number of fully adjacent neighbors. */
3104 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
3105 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
3107 /* Show authentication type. */
3108 vty_out (vty
, " Area has ");
3109 if (area
->auth_type
== OSPF_AUTH_NULL
)
3110 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
3111 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3112 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
3113 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3114 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
3116 if (!OSPF_IS_AREA_BACKBONE (area
))
3117 vty_out (vty
, " Number of full virtual adjacencies going through"
3118 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
3120 /* Show SPF calculation times. */
3121 vty_out (vty
, " SPF algorithm executed %d times%s",
3122 area
->spf_calculation
, VTY_NEWLINE
);
3124 /* Show number of LSA. */
3125 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
3126 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3127 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
3128 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
3129 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3130 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
3131 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
3132 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3133 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
3134 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
3135 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3136 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3137 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
3138 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3139 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
3140 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
3145 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3146 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3147 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3148 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3152 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3153 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3154 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
3155 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3156 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3157 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
3161 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
3163 vty_out (vty
, "%s", VTY_NEWLINE
);
3167 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3169 struct listnode
*node
, *nnode
;
3170 struct ospf_area
* area
;
3171 struct timeval result
;
3172 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3173 json_object
*json
= NULL
;
3174 json_object
*json_areas
= NULL
;
3177 json
= json_object_new_object();
3178 json_areas
= json_object_new_object();
3184 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3188 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3189 VTY_NEWLINE
, VTY_NEWLINE
);
3193 /* Show Router ID. */
3196 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3200 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3201 inet_ntoa (ospf
->router_id
),
3205 /* Graceful shutdown */
3206 if (ospf
->t_deferred_shutdown
)
3210 unsigned long time_store
= 0;
3211 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3212 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3213 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3217 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3218 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3219 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3223 /* Show capability. */
3226 json_object_boolean_true_add(json
, "tosRoutesOnly");
3227 json_object_boolean_true_add(json
, "rfc2328Conform");
3228 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3230 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3235 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3236 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3237 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3238 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3239 "enabled" : "disabled", VTY_NEWLINE
);
3244 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3246 json_object_boolean_true_add(json
, "opaqueCapable");
3251 vty_out (vty
, " OpaqueCapability flag is %s%s",
3252 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3256 /* Show stub-router configuration */
3257 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3258 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3262 json_object_boolean_true_add(json
, "stubAdvertisement");
3263 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3264 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3265 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3266 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3270 vty_out (vty
, " Stub router advertisement is configured%s",
3272 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3273 vty_out (vty
, " Enabled for %us after start-up%s",
3274 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3275 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3276 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3277 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3281 /* Show SPF timers. */
3284 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3285 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3286 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3287 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3291 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3292 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3293 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3294 " Hold time multiplier is currently %d%s",
3295 ospf
->spf_delay
, VTY_NEWLINE
,
3296 ospf
->spf_holdtime
, VTY_NEWLINE
,
3297 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3298 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3303 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3305 unsigned long time_store
= 0;
3307 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3308 result
= tv_sub (result
, recent_relative_time());
3309 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3310 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3312 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3313 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3316 json_object_boolean_true_add(json
, "spfHasNotRun");
3320 vty_out (vty
, " SPF algorithm ");
3321 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3323 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3324 vty_out (vty
, "last executed %s ago%s",
3325 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3327 vty_out (vty
, " Last SPF duration %s%s",
3328 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3332 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3337 struct timeval temp_time
;
3338 unsigned long time_store
= 0;
3340 if (ospf
->t_spf_calc
)
3342 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3343 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3344 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3347 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3348 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3349 /* Show write multiplier values */
3350 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3351 /* Show refresh parameters. */
3352 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3356 vty_out (vty
, " SPF timer %s%s%s",
3357 (ospf
->t_spf_calc
? "due in " : "is "),
3358 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3361 vty_out (vty
, " LSA minimum interval %d msecs%s",
3362 ospf
->min_ls_interval
, VTY_NEWLINE
);
3363 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3364 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3366 /* Show write multiplier values */
3367 vty_out (vty
, " Write Multiplier set to %d %s",
3368 ospf
->write_oi_count
, VTY_NEWLINE
);
3370 /* Show refresh parameters. */
3371 vty_out (vty
, " Refresh timer %d secs%s",
3372 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3375 /* Show ABR/ASBR flags. */
3376 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3379 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3381 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3382 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3384 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3387 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3389 vty_out (vty
, " This router is an ASBR "
3390 "(injecting external routing information)%s", VTY_NEWLINE
);
3393 /* Show Number of AS-external-LSAs. */
3396 json_object_int_add(json
, "lsaExternalCounter",
3397 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3398 json_object_int_add(json
, "lsaExternalChecksum",
3399 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3403 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3404 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3405 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3410 json_object_int_add(json
, "lsaAsopaqueCounter",
3411 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3412 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3413 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3417 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3418 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3419 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3422 /* Show number of areas attached. */
3424 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3426 vty_out (vty
, " Number of areas attached to this router: %d%s",
3427 listcount (ospf
->areas
), VTY_NEWLINE
);
3429 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3431 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3434 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3436 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3441 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3443 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3446 /* Show each area status. */
3447 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3448 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3452 json_object_object_add(json
, "areas", json_areas
);
3453 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3454 json_object_free(json
);
3457 vty_out (vty
, "%s",VTY_NEWLINE
);
3462 DEFUN (show_ip_ospf
,
3464 "show ip ospf [json]",
3467 "OSPF information\n"
3468 "JavaScript Object Notation\n")
3471 u_char uj
= use_json(argc
, argv
);
3473 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3476 return (show_ip_ospf_common(vty
, ospf
, uj
));
3479 DEFUN (show_ip_ospf_instance
,
3480 show_ip_ospf_instance_cmd
,
3481 "show ip ospf (1-65535) [json]",
3484 "OSPF information\n"
3486 "JavaScript Object Notation\n")
3490 u_short instance
= 0;
3491 u_char uj
= use_json(argc
, argv
);
3493 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3494 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3497 return (show_ip_ospf_common(vty
, ospf
, uj
));
3501 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3502 json_object
*json_interface_sub
, u_char use_json
)
3505 struct ospf_neighbor
*nbr
;
3506 struct route_node
*rn
;
3508 /* Is interface up? */
3511 is_up
= if_is_operative(ifp
);
3513 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3515 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3517 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3518 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3519 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3520 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3524 vty_out (vty
, "%s is %s%s", ifp
->name
,
3525 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3526 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3527 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3531 /* Is interface OSPF enabled? */
3534 if (ospf_oi_count(ifp
) == 0)
3536 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3541 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3545 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3549 if (ospf_oi_count(ifp
) == 0)
3551 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3556 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3562 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3564 struct ospf_interface
*oi
= rn
->info
;
3569 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3572 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3574 vty_out (vty
, " This interface is UNNUMBERED,");
3578 /* Show OSPF interface information. */
3581 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3582 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3585 vty_out (vty
, " Internet Address %s/%d,",
3586 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3588 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3590 struct in_addr
*dest
;
3593 if (CONNECTED_PEER(oi
->connected
)
3594 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3599 /* For Vlinks, showing the peer address is probably more
3600 * * * * * informative than the local interface that is being used
3602 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3603 dest
= &oi
->vl_data
->peer_addr
;
3605 dest
= &oi
->connected
->destination
->u
.prefix4
;
3609 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3610 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3611 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3613 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3616 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3621 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3622 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3623 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3624 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3625 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3626 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3627 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3628 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3629 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3633 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3636 vty_out (vty
, " MTU mismatch detection:%s%s",
3637 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3639 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3640 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3641 oi
->output_cost
, VTY_NEWLINE
);
3643 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3644 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3645 PRIORITY (oi
), VTY_NEWLINE
);
3648 /* Show DR information. */
3649 if (DR (oi
).s_addr
== 0)
3652 vty_out (vty
, " No backup designated router on this network%s",
3657 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3661 vty_out (vty
, " No backup designated router on this network%s",
3668 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3669 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3673 vty_out (vty
, " Backup Designated Router (ID) %s,",
3674 inet_ntoa (nbr
->router_id
));
3675 vty_out (vty
, " Interface Address %s%s",
3676 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3681 /* Next network-LSA sequence number we'll use, if we're elected DR */
3682 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3685 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3687 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3688 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3693 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3694 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3696 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3697 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3698 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3699 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3704 vty_out (vty
, " Multicast group memberships:");
3705 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3706 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3708 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3709 vty_out (vty
, " OSPFAllRouters");
3710 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3711 vty_out (vty
, " OSPFDesignatedRouters");
3714 vty_out (vty
, " <None>");
3715 vty_out (vty
, "%s", VTY_NEWLINE
);
3720 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3721 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3723 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3724 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3725 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3726 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3730 vty_out (vty
, " Timer intervals configured,");
3731 vty_out (vty
, " Hello ");
3732 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3733 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3735 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3736 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3737 OSPF_IF_PARAM (oi
, v_wait
),
3738 OSPF_IF_PARAM (oi
, v_wait
),
3739 OSPF_IF_PARAM (oi
, retransmit_interval
),
3743 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3745 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3748 struct timeval result
;
3749 unsigned long time_store
= 0;
3751 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3757 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3758 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3761 vty_out (vty
, " Hello due in %s%s",
3762 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3765 else /* passive-interface is set */
3768 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3770 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3775 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3776 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3779 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3780 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3782 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3787 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3788 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3790 struct interface
*ifp
;
3791 struct listnode
*node
;
3792 json_object
*json
= NULL
;
3793 json_object
*json_interface_sub
= NULL
;
3797 json
= json_object_new_object();
3798 json_interface_sub
= json_object_new_object();
3804 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3806 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3807 VTY_NEWLINE
, VTY_NEWLINE
);
3810 if (argc
== (iface_argv
+ 1))
3812 /* Show All Interfaces.*/
3813 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3815 if (ospf_oi_count(ifp
))
3817 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3819 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3823 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3827 json
= json_object_new_object();
3828 json_interface_sub
= json_object_new_object ();
3831 /* Show All Interfaces. */
3832 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3834 if (ospf_oi_count(ifp
))
3836 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3838 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3844 /* Interface name is specified. */
3845 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3848 json_object_boolean_true_add(json
, "noSuchIface");
3850 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3854 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3856 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3862 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3863 json_object_free(json
);
3866 vty_out (vty
, "%s", VTY_NEWLINE
);
3871 DEFUN (show_ip_ospf_interface
,
3872 show_ip_ospf_interface_cmd
,
3873 "show ip ospf interface [INTERFACE] [json]",
3876 "OSPF information\n"
3877 "Interface information\n"
3879 "JavaScript Object Notation\n")
3882 u_char uj
= use_json(argc
, argv
);
3884 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3887 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3890 DEFUN (show_ip_ospf_instance_interface
,
3891 show_ip_ospf_instance_interface_cmd
,
3892 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3895 "OSPF information\n"
3897 "Interface information\n"
3899 "JavaScript Object Notation\n")
3903 u_short instance
= 0;
3904 u_char uj
= use_json(argc
, argv
);
3906 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3907 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3910 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3914 show_ip_ospf_neighbour_header (struct vty
*vty
)
3916 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3918 "Neighbor ID", "Pri", "State", "Dead Time",
3919 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3924 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3926 struct route_node
*rn
;
3927 struct ospf_neighbor
*nbr
;
3929 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3930 json_object
*json_neighbor
= NULL
;
3932 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3934 if ((nbr
= rn
->info
))
3936 /* Do not show myself. */
3937 if (nbr
!= oi
->nbr_self
)
3939 /* Down state is not shown. */
3940 if (nbr
->state
!= NSM_Down
)
3944 json_neighbor
= json_object_new_object();
3945 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3947 struct timeval result
;
3948 unsigned long time_store
= 0;
3950 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3951 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3953 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3954 json_object_string_add (json_neighbor
, "state", msgbuf
);
3955 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3956 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3957 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3958 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3959 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3960 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3961 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3962 json_object_object_add(json
, "neighbor", json_neighbor
);
3964 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3968 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3970 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3971 vty_out (vty
, "%-15s %3d %-15s ",
3975 vty_out (vty
, "%-15s %3d %-15s ",
3976 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3979 vty_out (vty
, "%9s ",
3980 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3982 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3983 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3984 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3985 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3995 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3997 struct ospf_interface
*oi
;
3998 struct listnode
*node
;
3999 json_object
*json
= NULL
;
4002 json
= json_object_new_object();
4004 show_ip_ospf_neighbour_header (vty
);
4009 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4011 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4012 VTY_NEWLINE
, VTY_NEWLINE
);
4015 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4016 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4020 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4021 json_object_free(json
);
4024 vty_out (vty
, "%s", VTY_NEWLINE
);
4029 DEFUN (show_ip_ospf_neighbor
,
4030 show_ip_ospf_neighbor_cmd
,
4031 "show ip ospf neighbor [json]",
4034 "OSPF information\n"
4036 "JavaScript Object Notation\n")
4039 u_char uj
= use_json(argc
, argv
);
4041 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4044 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4048 DEFUN (show_ip_ospf_instance_neighbor
,
4049 show_ip_ospf_instance_neighbor_cmd
,
4050 "show ip ospf (1-65535) neighbor [json]",
4053 "OSPF information\n"
4056 "JavaScript Object Notation\n")
4060 u_short instance
= 0;
4061 u_char uj
= use_json(argc
, argv
);
4063 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4064 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4067 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4071 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4073 struct listnode
*node
;
4074 struct ospf_interface
*oi
;
4075 json_object
*json
= NULL
;
4076 json_object
*json_neighbor_sub
= NULL
;
4080 json
= json_object_new_object();
4081 json_neighbor_sub
= json_object_new_object();
4084 show_ip_ospf_neighbour_header (vty
);
4089 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4091 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4092 VTY_NEWLINE
, VTY_NEWLINE
);
4095 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4097 struct listnode
*nbr_node
;
4098 struct ospf_nbr_nbma
*nbr_nbma
;
4100 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4102 /* print Down neighbor status */
4103 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4105 if (nbr_nbma
->nbr
== NULL
4106 || nbr_nbma
->nbr
->state
== NSM_Down
)
4110 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4111 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4112 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4113 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4114 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4115 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4116 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4120 vty_out (vty
, "%-15s %3d %-15s %9s ",
4121 "-", nbr_nbma
->priority
, "Down", "-");
4122 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4123 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4124 0, 0, 0, VTY_NEWLINE
);
4132 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4133 json_object_free(json
);
4136 vty_out (vty
, "%s", VTY_NEWLINE
);
4141 DEFUN (show_ip_ospf_neighbor_all
,
4142 show_ip_ospf_neighbor_all_cmd
,
4143 "show ip ospf neighbor all [json]",
4146 "OSPF information\n"
4148 "include down status neighbor\n"
4149 "JavaScript Object Notation\n")
4152 u_char uj
= use_json(argc
, argv
);
4154 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4157 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4160 DEFUN (show_ip_ospf_instance_neighbor_all
,
4161 show_ip_ospf_instance_neighbor_all_cmd
,
4162 "show ip ospf (1-65535) neighbor all [json]",
4165 "OSPF information\n"
4168 "include down status neighbor\n"
4169 "JavaScript Object Notation\n")
4173 u_short instance
= 0;
4174 u_char uj
= use_json(argc
, argv
);
4176 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4177 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4180 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4184 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4185 struct cmd_token
**argv
, u_char use_json
)
4187 struct interface
*ifp
;
4188 struct route_node
*rn
;
4189 json_object
*json
= NULL
;
4192 json
= json_object_new_object();
4194 show_ip_ospf_neighbour_header (vty
);
4199 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4201 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4202 VTY_NEWLINE
, VTY_NEWLINE
);
4205 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4209 json_object_boolean_true_add(json
, "noSuchIface");
4211 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4215 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4217 struct ospf_interface
*oi
= rn
->info
;
4222 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4227 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4228 json_object_free(json
);
4231 vty_out (vty
, "%s", VTY_NEWLINE
);
4236 DEFUN (show_ip_ospf_neighbor_int
,
4237 show_ip_ospf_neighbor_int_cmd
,
4238 "show ip ospf neighbor IFNAME [json]",
4241 "OSPF information\n"
4244 "JavaScript Object Notation\n")
4247 u_char uj
= use_json(argc
, argv
);
4249 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4252 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4255 DEFUN (show_ip_ospf_instance_neighbor_int
,
4256 show_ip_ospf_instance_neighbor_int_cmd
,
4257 "show ip ospf (1-65535) neighbor IFNAME [json]",
4260 "OSPF information\n"
4264 "JavaScript Object Notation\n")
4268 u_short instance
= 0;
4269 u_char uj
= use_json(argc
, argv
);
4271 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4272 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4275 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4279 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4280 u_char use_json
, json_object
*json
)
4282 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4283 json_object
*json_sub
= NULL
;
4286 json_sub
= json_object_new_object();
4287 else /* Show neighbor ID. */
4288 vty_out (vty
, " Neighbor %s,", "-");
4290 /* Show interface address. */
4292 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4294 vty_out (vty
, " interface address %s%s",
4295 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4300 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4301 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4304 vty_out (vty
, " In the area %s via interface %s%s",
4305 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4307 /* Show neighbor priority and state. */
4310 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4311 json_object_string_add(json_sub
, "nbrState", "down");
4314 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4315 nbr_nbma
->priority
, "Down");
4317 /* Show state changes. */
4319 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4321 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4323 /* Show PollInterval */
4325 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4327 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4329 /* Show poll-interval timer. */
4332 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4333 unsigned long time_store
= 0;
4334 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4335 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4338 vty_out (vty
, " Poll timer due in %s%s",
4339 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4342 /* Show poll-interval timer thread. */
4345 if (nbr_nbma
->t_poll
!= NULL
)
4346 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4349 vty_out (vty
, " Thread Poll Timer %s%s",
4350 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4353 json_object_object_add(json
, "noNbrId", json_sub
);
4357 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4358 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4360 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4361 json_object
*json_sub
= NULL
;
4364 json_sub
= json_object_new_object();
4367 /* Show neighbor ID. */
4368 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4369 vty_out (vty
, " Neighbor %s,", "-");
4371 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4374 /* Show interface address. */
4376 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4378 vty_out (vty
, " interface address %s%s",
4379 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4384 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4385 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4388 vty_out (vty
, " In the area %s via interface %s%s",
4389 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4391 /* Show neighbor priority and state. */
4394 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4395 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4398 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4399 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4401 /* Show state changes. */
4403 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4405 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4407 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4409 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4412 unsigned long time_store
= 0;
4413 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4414 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4418 vty_out (vty
, " Most recent state change statistics:%s",
4420 vty_out (vty
, " Progressive change %s ago%s",
4421 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4426 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4428 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4431 unsigned long time_store
= 0;
4432 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4433 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4434 if (nbr
->last_regress_str
)
4435 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4439 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4440 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4441 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4446 /* Show Designated Rotuer ID. */
4448 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4450 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4452 /* Show Backup Designated Rotuer ID. */
4454 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4456 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4461 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4462 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4465 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4466 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4468 /* Show Router Dead interval timer. */
4471 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4472 unsigned long time_store
= 0;
4473 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4474 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4477 vty_out (vty
, " Dead timer due in %s%s",
4478 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4481 /* Show Database Summary list. */
4483 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4485 vty_out (vty
, " Database Summary List %d%s",
4486 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4488 /* Show Link State Request list. */
4490 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4492 vty_out (vty
, " Link State Request List %ld%s",
4493 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4495 /* Show Link State Retransmission list. */
4497 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4499 vty_out (vty
, " Link State Retransmission List %ld%s",
4500 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4502 /* Show inactivity timer thread. */
4505 if (nbr
->t_inactivity
!= NULL
)
4506 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4509 vty_out (vty
, " Thread Inactivity Timer %s%s",
4510 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4512 /* Show Database Description retransmission thread. */
4515 if (nbr
->t_db_desc
!= NULL
)
4516 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4519 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4520 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4522 /* Show Link State Request Retransmission thread. */
4525 if (nbr
->t_ls_req
!= NULL
)
4526 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4529 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4530 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4532 /* Show Link State Update Retransmission thread. */
4535 if (nbr
->t_ls_upd
!= NULL
)
4536 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4539 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4540 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4544 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4545 json_object_object_add(json
, "noNbrId", json_sub
);
4547 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4550 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4554 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4555 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4557 struct listnode
*node
;
4558 struct ospf_neighbor
*nbr
;
4559 struct ospf_interface
*oi
;
4560 struct in_addr router_id
;
4562 json_object
*json
= NULL
;
4565 json
= json_object_new_object();
4570 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4572 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4573 VTY_NEWLINE
, VTY_NEWLINE
);
4576 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4580 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4584 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4586 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4588 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4594 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4595 json_object_free(json
);
4598 vty_out (vty
, "%s", VTY_NEWLINE
);
4603 DEFUN (show_ip_ospf_neighbor_id
,
4604 show_ip_ospf_neighbor_id_cmd
,
4605 "show ip ospf neighbor A.B.C.D [json]",
4608 "OSPF information\n"
4611 "JavaScript Object Notation\n")
4614 u_char uj
= use_json(argc
, argv
);
4616 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4619 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4622 DEFUN (show_ip_ospf_instance_neighbor_id
,
4623 show_ip_ospf_instance_neighbor_id_cmd
,
4624 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4627 "OSPF information\n"
4631 "JavaScript Object Notation\n")
4635 u_short instance
= 0;
4636 u_char uj
= use_json(argc
, argv
);
4638 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4639 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4642 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4646 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4648 struct ospf_interface
*oi
;
4649 struct listnode
*node
;
4650 json_object
*json
= NULL
;
4653 json
= json_object_new_object();
4658 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4660 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4661 VTY_NEWLINE
, VTY_NEWLINE
);
4664 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4666 struct route_node
*rn
;
4667 struct ospf_neighbor
*nbr
;
4669 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4671 if ((nbr
= rn
->info
))
4673 if (nbr
!= oi
->nbr_self
)
4675 if (nbr
->state
!= NSM_Down
)
4677 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4686 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4687 json_object_free(json
);
4690 vty_out (vty
, "%s", VTY_NEWLINE
);
4695 DEFUN (show_ip_ospf_neighbor_detail
,
4696 show_ip_ospf_neighbor_detail_cmd
,
4697 "show ip ospf neighbor detail [json]",
4700 "OSPF information\n"
4702 "detail of all neighbors\n"
4703 "JavaScript Object Notation\n")
4706 u_char uj
= use_json(argc
, argv
);
4708 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4711 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4714 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4715 show_ip_ospf_instance_neighbor_detail_cmd
,
4716 "show ip ospf (1-65535) neighbor detail [json]",
4719 "OSPF information\n"
4722 "detail of all neighbors\n"
4723 "JavaScript Object Notation\n")
4727 u_short instance
= 0;
4728 u_char uj
= use_json(argc
, argv
);
4730 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4731 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4734 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4738 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4740 struct listnode
*node
;
4741 struct ospf_interface
*oi
;
4742 json_object
*json
= NULL
;
4745 json
= json_object_new_object();
4750 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4752 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4753 VTY_NEWLINE
, VTY_NEWLINE
);
4756 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4758 struct route_node
*rn
;
4759 struct ospf_neighbor
*nbr
;
4760 struct ospf_nbr_nbma
*nbr_nbma
;
4762 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4763 if ((nbr
= rn
->info
))
4764 if (nbr
!= oi
->nbr_self
)
4765 if (nbr
->state
!= NSM_Down
)
4766 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4768 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4770 struct listnode
*nd
;
4772 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4774 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4775 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4782 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4783 json_object_free(json
);
4787 vty_out (vty
, "%s", VTY_NEWLINE
);
4793 DEFUN (show_ip_ospf_neighbor_detail_all
,
4794 show_ip_ospf_neighbor_detail_all_cmd
,
4795 "show ip ospf neighbor detail all [json]",
4798 "OSPF information\n"
4800 "detail of all neighbors\n"
4801 "include down status neighbor\n"
4802 "JavaScript Object Notation\n")
4805 u_char uj
= use_json(argc
, argv
);
4807 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4810 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4813 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4814 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4815 "show ip ospf (1-65535) neighbor detail all [json]",
4818 "OSPF information\n"
4821 "detail of all neighbors\n"
4822 "include down status neighbor\n"
4823 "JavaScript Object Notation\n")
4827 u_short instance
= 0;
4828 u_char uj
= use_json(argc
, argv
);
4830 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4831 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4834 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4838 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4839 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4841 struct ospf_interface
*oi
;
4842 struct interface
*ifp
;
4843 struct route_node
*rn
, *nrn
;
4844 struct ospf_neighbor
*nbr
;
4845 json_object
*json
= NULL
;
4848 json
= json_object_new_object();
4853 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4855 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4856 VTY_NEWLINE
, VTY_NEWLINE
);
4859 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4863 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4867 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4869 if ((oi
= rn
->info
))
4871 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4873 if ((nbr
= nrn
->info
))
4875 if (nbr
!= oi
->nbr_self
)
4877 if (nbr
->state
!= NSM_Down
)
4878 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4887 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4888 json_object_free(json
);
4891 vty_out (vty
, "%s", VTY_NEWLINE
);
4896 DEFUN (show_ip_ospf_neighbor_int_detail
,
4897 show_ip_ospf_neighbor_int_detail_cmd
,
4898 "show ip ospf neighbor IFNAME detail [json]",
4901 "OSPF information\n"
4904 "detail of all neighbors\n"
4905 "JavaScript Object Notation\n")
4908 u_char uj
= use_json(argc
, argv
);
4910 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4913 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4916 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4917 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4918 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4921 "OSPF information\n"
4925 "detail of all neighbors\n"
4926 "JavaScript Object Notation\n")
4930 u_short instance
= 0;
4931 u_char uj
= use_json(argc
, argv
);
4933 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4934 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4937 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4940 /* Show functions */
4942 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4944 struct router_lsa
*rl
;
4945 struct summary_lsa
*sl
;
4946 struct as_external_lsa
*asel
;
4947 struct prefix_ipv4 p
;
4950 /* If self option is set, check LSA self flag. */
4951 if (self
== 0 || IS_LSA_SELF (lsa
))
4953 /* LSA common part show. */
4954 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4955 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4956 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4957 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4958 /* LSA specific part show. */
4959 switch (lsa
->data
->type
)
4961 case OSPF_ROUTER_LSA
:
4962 rl
= (struct router_lsa
*) lsa
->data
;
4963 vty_out (vty
, " %-d", ntohs (rl
->links
));
4965 case OSPF_SUMMARY_LSA
:
4966 sl
= (struct summary_lsa
*) lsa
->data
;
4969 p
.prefix
= sl
->header
.id
;
4970 p
.prefixlen
= ip_masklen (sl
->mask
);
4971 apply_mask_ipv4 (&p
);
4973 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4975 case OSPF_AS_EXTERNAL_LSA
:
4976 case OSPF_AS_NSSA_LSA
:
4977 asel
= (struct as_external_lsa
*) lsa
->data
;
4980 p
.prefix
= asel
->header
.id
;
4981 p
.prefixlen
= ip_masklen (asel
->mask
);
4982 apply_mask_ipv4 (&p
);
4984 vty_out (vty
, " %s %s/%d [0x%lx]",
4985 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4986 inet_ntoa (p
.prefix
), p
.prefixlen
,
4987 (u_long
)ntohl (asel
->e
[0].route_tag
));
4989 case OSPF_NETWORK_LSA
:
4990 case OSPF_ASBR_SUMMARY_LSA
:
4991 case OSPF_OPAQUE_LINK_LSA
:
4992 case OSPF_OPAQUE_AREA_LSA
:
4993 case OSPF_OPAQUE_AS_LSA
:
4997 vty_out (vty
, VTY_NEWLINE
);
5003 static const char *show_database_desc
[] =
5006 "Router Link States",
5008 "Summary Link States",
5009 "ASBR-Summary Link States",
5010 "AS External Link States",
5011 "Group Membership LSA",
5012 "NSSA-external Link States",
5014 "Link-Local Opaque-LSA",
5015 "Area-Local Opaque-LSA",
5016 "AS-external Opaque-LSA",
5019 static const char *show_database_header
[] =
5022 "Link ID ADV Router Age Seq# CkSum Link count",
5023 "Link ID ADV Router Age Seq# CkSum",
5024 "Link ID ADV Router Age Seq# CkSum Route",
5025 "Link ID ADV Router Age Seq# CkSum",
5026 "Link ID ADV Router Age Seq# CkSum Route",
5027 " --- header for Group Member ----",
5028 "Link ID ADV Router Age Seq# CkSum Route",
5030 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5031 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5032 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5036 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
5038 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
5040 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
5041 vty_out (vty
, " Options: 0x%-2x : %s%s",
5043 ospf_options_dump(lsa
->data
->options
),
5045 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
5047 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
5050 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
5052 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
5055 vty_out (vty
, " :%s%s%s%s",
5056 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
5057 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
5058 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
5059 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
5061 vty_out (vty
, "%s", VTY_NEWLINE
);
5063 vty_out (vty
, " LS Type: %s%s",
5064 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5065 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
5066 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5067 vty_out (vty
, " Advertising Router: %s%s",
5068 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5069 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5071 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5073 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5076 const char *link_type_desc
[] =
5079 "another Router (point-to-point)",
5080 "a Transit Network",
5085 const char *link_id_desc
[] =
5088 "Neighboring Router ID",
5089 "Designated Router address",
5091 "Neighboring Router ID",
5094 const char *link_data_desc
[] =
5097 "Router Interface address",
5098 "Router Interface address",
5100 "Router Interface address",
5103 /* Show router-LSA each Link information. */
5105 show_ip_ospf_database_router_links (struct vty
*vty
,
5106 struct router_lsa
*rl
)
5111 len
= ntohs (rl
->header
.length
) - 4;
5112 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5114 type
= rl
->link
[i
].type
;
5116 vty_out (vty
, " Link connected to: %s%s",
5117 link_type_desc
[type
], VTY_NEWLINE
);
5118 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5119 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5120 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5121 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5122 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5123 vty_out (vty
, " TOS 0 Metric: %d%s",
5124 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5125 vty_out (vty
, "%s", VTY_NEWLINE
);
5129 /* Show router-LSA detail information. */
5131 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5135 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5137 show_ip_ospf_database_header (vty
, lsa
);
5139 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5140 VTY_NEWLINE
, VTY_NEWLINE
);
5142 show_ip_ospf_database_router_links (vty
, rl
);
5143 vty_out (vty
, "%s", VTY_NEWLINE
);
5149 /* Show network-LSA detail information. */
5151 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5157 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5159 show_ip_ospf_database_header (vty
, lsa
);
5161 vty_out (vty
, " Network Mask: /%d%s",
5162 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5164 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5166 for (i
= 0; length
> 0; i
++, length
-= 4)
5167 vty_out (vty
, " Attached Router: %s%s",
5168 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5170 vty_out (vty
, "%s", VTY_NEWLINE
);
5176 /* Show summary-LSA detail information. */
5178 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5182 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5184 show_ip_ospf_database_header (vty
, lsa
);
5186 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5188 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5190 vty_out (vty
, "%s", VTY_NEWLINE
);
5196 /* Show summary-ASBR-LSA detail information. */
5198 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5202 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5204 show_ip_ospf_database_header (vty
, lsa
);
5206 vty_out (vty
, " Network Mask: /%d%s",
5207 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5208 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5210 vty_out (vty
, "%s", VTY_NEWLINE
);
5216 /* Show AS-external-LSA detail information. */
5218 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5222 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5224 show_ip_ospf_database_header (vty
, lsa
);
5226 vty_out (vty
, " Network Mask: /%d%s",
5227 ip_masklen (al
->mask
), VTY_NEWLINE
);
5228 vty_out (vty
, " Metric Type: %s%s",
5229 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5230 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5231 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5232 vty_out (vty
, " Metric: %d%s",
5233 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5234 vty_out (vty
, " Forward Address: %s%s",
5235 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5237 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5238 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5245 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5247 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5249 /* show_ip_ospf_database_header (vty, lsa); */
5251 zlog_debug( " Network Mask: /%d%s",
5252 ip_masklen (al
->mask
), "\n");
5253 zlog_debug( " Metric Type: %s%s",
5254 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5255 "2 (Larger than any link state path)" : "1", "\n");
5256 zlog_debug( " TOS: 0%s", "\n");
5257 zlog_debug( " Metric: %d%s",
5258 GET_METRIC (al
->e
[0].metric
), "\n");
5259 zlog_debug( " Forward Address: %s%s",
5260 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5262 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5263 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5268 /* Show AS-NSSA-LSA detail information. */
5270 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5274 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5276 show_ip_ospf_database_header (vty
, lsa
);
5278 vty_out (vty
, " Network Mask: /%d%s",
5279 ip_masklen (al
->mask
), VTY_NEWLINE
);
5280 vty_out (vty
, " Metric Type: %s%s",
5281 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5282 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5283 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5284 vty_out (vty
, " Metric: %d%s",
5285 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5286 vty_out (vty
, " NSSA: Forward Address: %s%s",
5287 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5289 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5290 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5297 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5303 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5307 show_ip_ospf_database_header (vty
, lsa
);
5308 show_opaque_info_detail (vty
, lsa
);
5310 vty_out (vty
, "%s", VTY_NEWLINE
);
5315 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5318 show_router_lsa_detail
,
5319 show_network_lsa_detail
,
5320 show_summary_lsa_detail
,
5321 show_summary_asbr_lsa_detail
,
5322 show_as_external_lsa_detail
,
5324 show_as_nssa_lsa_detail
, /* almost same as external */
5326 show_opaque_lsa_detail
,
5327 show_opaque_lsa_detail
,
5328 show_opaque_lsa_detail
,
5332 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5333 struct in_addr
*adv_router
)
5335 memset (lp
, 0, sizeof (struct prefix_ls
));
5339 else if (adv_router
== NULL
)
5348 lp
->adv_router
= *adv_router
;
5353 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5354 struct in_addr
*id
, struct in_addr
*adv_router
)
5356 struct prefix_ls lp
;
5357 struct route_node
*rn
, *start
;
5358 struct ospf_lsa
*lsa
;
5360 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5361 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5364 route_lock_node (start
);
5365 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5366 if ((lsa
= rn
->info
))
5368 if (show_function
[lsa
->data
->type
] != NULL
)
5369 show_function
[lsa
->data
->type
] (vty
, lsa
);
5371 route_unlock_node (start
);
5375 /* Show detail LSA information
5376 -- if id is NULL then show all LSAs. */
5378 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5379 struct in_addr
*id
, struct in_addr
*adv_router
)
5381 struct listnode
*node
;
5382 struct ospf_area
*area
;
5386 case OSPF_AS_EXTERNAL_LSA
:
5387 case OSPF_OPAQUE_AS_LSA
:
5388 vty_out (vty
, " %s %s%s",
5389 show_database_desc
[type
],
5390 VTY_NEWLINE
, VTY_NEWLINE
);
5391 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5394 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5396 vty_out (vty
, "%s %s (Area %s)%s%s",
5397 VTY_NEWLINE
, show_database_desc
[type
],
5398 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5399 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5406 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5407 struct in_addr
*adv_router
)
5409 struct route_node
*rn
;
5410 struct ospf_lsa
*lsa
;
5412 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5413 if ((lsa
= rn
->info
))
5414 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5416 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5418 if (show_function
[lsa
->data
->type
] != NULL
)
5419 show_function
[lsa
->data
->type
] (vty
, lsa
);
5423 /* Show detail LSA information. */
5425 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5426 struct in_addr
*adv_router
)
5428 struct listnode
*node
;
5429 struct ospf_area
*area
;
5433 case OSPF_AS_EXTERNAL_LSA
:
5434 case OSPF_OPAQUE_AS_LSA
:
5435 vty_out (vty
, " %s %s%s",
5436 show_database_desc
[type
],
5437 VTY_NEWLINE
, VTY_NEWLINE
);
5438 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5442 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5444 vty_out (vty
, "%s %s (Area %s)%s%s",
5445 VTY_NEWLINE
, show_database_desc
[type
],
5446 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5447 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5455 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5457 struct ospf_lsa
*lsa
;
5458 struct route_node
*rn
;
5459 struct ospf_area
*area
;
5460 struct listnode
*node
;
5463 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5465 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5469 case OSPF_AS_EXTERNAL_LSA
:
5470 case OSPF_OPAQUE_AS_LSA
:
5475 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5476 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5478 vty_out (vty
, " %s (Area %s)%s%s",
5479 show_database_desc
[type
],
5480 ospf_area_desc_string (area
),
5481 VTY_NEWLINE
, VTY_NEWLINE
);
5482 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5484 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5485 show_lsa_summary (vty
, lsa
, self
);
5487 vty_out (vty
, "%s", VTY_NEWLINE
);
5492 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5496 case OSPF_AS_EXTERNAL_LSA
:
5497 case OSPF_OPAQUE_AS_LSA
:
5502 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5503 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5505 vty_out (vty
, " %s%s%s",
5506 show_database_desc
[type
],
5507 VTY_NEWLINE
, VTY_NEWLINE
);
5508 vty_out (vty
, "%s%s", show_database_header
[type
],
5511 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5512 show_lsa_summary (vty
, lsa
, self
);
5514 vty_out (vty
, "%s", VTY_NEWLINE
);
5518 vty_out (vty
, "%s", VTY_NEWLINE
);
5522 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5524 struct route_node
*rn
;
5526 vty_out (vty
, "%s MaxAge Link States:%s%s",
5527 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5529 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5531 struct ospf_lsa
*lsa
;
5533 if ((lsa
= rn
->info
) != NULL
)
5535 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5536 vty_out (vty
, "Link State ID: %s%s",
5537 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5538 vty_out (vty
, "Advertising Router: %s%s",
5539 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5540 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5541 vty_out (vty
, "%s", VTY_NEWLINE
);
5546 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5547 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5549 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5550 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5551 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5552 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5554 #define OSPF_LSA_TYPES_DESC \
5555 "ASBR summary link states\n" \
5556 "External link states\n" \
5557 "Network link states\n" \
5558 "Router link states\n" \
5559 "Network summary link states\n" \
5560 OSPF_LSA_TYPE_NSSA_DESC \
5561 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5562 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5563 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5566 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5567 int arg_base
, int argc
, struct cmd_token
**argv
)
5571 struct in_addr id
, adv_router
;
5574 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5577 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5578 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5581 if (argc
== arg_base
+ 4)
5583 show_ip_ospf_database_summary (vty
, ospf
, 0);
5587 /* Set database type to show. */
5588 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5589 type
= OSPF_ROUTER_LSA
;
5590 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5591 type
= OSPF_NETWORK_LSA
;
5592 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5593 type
= OSPF_AS_NSSA_LSA
;
5594 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5595 type
= OSPF_SUMMARY_LSA
;
5596 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5597 type
= OSPF_ASBR_SUMMARY_LSA
;
5598 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5599 type
= OSPF_AS_EXTERNAL_LSA
;
5600 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5602 show_ip_ospf_database_summary (vty
, ospf
, 1);
5605 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5607 show_ip_ospf_database_maxage (vty
, ospf
);
5610 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5611 type
= OSPF_OPAQUE_LINK_LSA
;
5612 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5613 type
= OSPF_OPAQUE_AREA_LSA
;
5614 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5615 type
= OSPF_OPAQUE_AS_LSA
;
5619 /* `show ip ospf database LSA'. */
5620 if (argc
== arg_base
+ 5)
5621 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5622 else if (argc
>= arg_base
+ 6)
5624 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5628 /* `show ip ospf database LSA ID'. */
5629 if (argc
== arg_base
+ 6)
5630 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5631 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5632 else if (argc
== arg_base
+ 7)
5634 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5635 adv_router
= ospf
->router_id
;
5638 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5642 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5649 DEFUN (show_ip_ospf_database
,
5650 show_ip_ospf_database_cmd
,
5651 "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>]]]",
5654 "OSPF information\n"
5655 "Database summary\n"
5657 "Link State ID (as an IP address)\n"
5658 "Self-originated link states\n"
5659 "Advertising Router link states\n"
5660 "Advertising Router (as an IP address)\n")
5664 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5667 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5670 DEFUN (show_ip_ospf_database_max
,
5671 show_ip_ospf_database_max_cmd
,
5672 "show ip ospf database <max-age|self-originate>",
5675 "OSPF information\n"
5676 "Database summary\n"
5677 "LSAs in MaxAge list\n"
5678 "Self-originated link states\n")
5682 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5685 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5688 DEFUN (show_ip_ospf_instance_database
,
5689 show_ip_ospf_instance_database_cmd
,
5690 "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>]]]",
5693 "OSPF information\n"
5695 "Database summary\n"
5697 "Link State ID (as an IP address)\n"
5698 "Self-originated link states\n"
5699 "Advertising Router link states\n"
5700 "Advertising Router (as an IP address)\n")
5704 u_short instance
= 0;
5706 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5708 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5711 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5714 DEFUN (show_ip_ospf_instance_database_max
,
5715 show_ip_ospf_instance_database_max_cmd
,
5716 "show ip ospf (1-65535) database <max-age|self-originate>",
5719 "OSPF information\n"
5721 "Database summary\n"
5722 "LSAs in MaxAge list\n"
5723 "Self-originated link states\n")
5727 u_short instance
= 0;
5729 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5731 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5734 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5739 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5740 int arg_base
, int argc
, struct cmd_token
**argv
)
5744 struct in_addr adv_router
;
5747 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5750 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5751 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5753 if (argc
!= arg_base
+ 7)
5756 /* Set database type to show. */
5757 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5758 type
= OSPF_ROUTER_LSA
;
5759 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5760 type
= OSPF_NETWORK_LSA
;
5761 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5762 type
= OSPF_AS_NSSA_LSA
;
5763 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5764 type
= OSPF_SUMMARY_LSA
;
5765 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5766 type
= OSPF_ASBR_SUMMARY_LSA
;
5767 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5768 type
= OSPF_AS_EXTERNAL_LSA
;
5769 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5770 type
= OSPF_OPAQUE_LINK_LSA
;
5771 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5772 type
= OSPF_OPAQUE_AREA_LSA
;
5773 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5774 type
= OSPF_OPAQUE_AS_LSA
;
5778 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5779 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5780 adv_router
= ospf
->router_id
;
5783 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5788 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5793 DEFUN (show_ip_ospf_database_type_adv_router
,
5794 show_ip_ospf_database_type_adv_router_cmd
,
5795 "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>",
5798 "OSPF information\n"
5799 "Database summary\n"
5801 "Advertising Router link states\n"
5802 "Advertising Router (as an IP address)\n"
5803 "Self-originated link states\n")
5807 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5810 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5813 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5814 show_ip_ospf_instance_database_type_adv_router_cmd
,
5815 "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>",
5818 "OSPF information\n"
5820 "Database summary\n"
5822 "Advertising Router link states\n"
5823 "Advertising Router (as an IP address)\n")
5827 u_short instance
= 0;
5829 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5831 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5834 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5837 DEFUN (ip_ospf_authentication_args
,
5838 ip_ospf_authentication_args_addr_cmd
,
5839 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5841 "OSPF interface commands\n"
5842 "Enable authentication on this interface\n"
5843 "Use null authentication\n"
5844 "Use message-digest authentication\n"
5845 "Address of interface\n")
5847 int idx_encryption
= 3;
5849 struct interface
*ifp
;
5850 struct in_addr addr
;
5852 struct ospf_if_params
*params
;
5855 params
= IF_DEF_PARAMS (ifp
);
5859 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5862 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5867 params
= ospf_get_if_params (ifp
, addr
);
5868 ospf_if_update_params (ifp
, addr
);
5871 /* Handle null authentication */
5872 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5874 SET_IF_PARAM (params
, auth_type
);
5875 params
->auth_type
= OSPF_AUTH_NULL
;
5879 /* Handle message-digest authentication */
5880 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5882 SET_IF_PARAM (params
, auth_type
);
5883 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5887 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5891 DEFUN (ip_ospf_authentication
,
5892 ip_ospf_authentication_addr_cmd
,
5893 "ip ospf authentication [A.B.C.D]",
5895 "OSPF interface commands\n"
5896 "Enable authentication on this interface\n"
5897 "Address of interface")
5900 struct interface
*ifp
;
5901 struct in_addr addr
;
5903 struct ospf_if_params
*params
;
5906 params
= IF_DEF_PARAMS (ifp
);
5910 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5913 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5918 params
= ospf_get_if_params (ifp
, addr
);
5919 ospf_if_update_params (ifp
, addr
);
5922 SET_IF_PARAM (params
, auth_type
);
5923 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5928 DEFUN (no_ip_ospf_authentication_args
,
5929 no_ip_ospf_authentication_args_addr_cmd
,
5930 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5933 "OSPF interface commands\n"
5934 "Enable authentication on this interface\n"
5935 "Use null authentication\n"
5936 "Use message-digest authentication\n"
5937 "Address of interface")
5939 int idx_encryption
= 4;
5941 struct interface
*ifp
;
5942 struct in_addr addr
;
5944 struct ospf_if_params
*params
;
5945 struct route_node
*rn
;
5949 params
= IF_DEF_PARAMS (ifp
);
5953 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5956 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5961 params
= ospf_lookup_if_params (ifp
, addr
);
5964 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5967 params
->auth_type
= OSPF_AUTH_NOTSET
;
5968 UNSET_IF_PARAM (params
, auth_type
);
5969 if (params
!= IF_DEF_PARAMS (ifp
))
5971 ospf_free_if_params (ifp
, addr
);
5972 ospf_if_update_params (ifp
, addr
);
5977 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5979 auth_type
= OSPF_AUTH_NULL
;
5981 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5983 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5987 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5991 * Here we have a case where the user has entered
5992 * 'no ip ospf authentication (null | message_digest )'
5993 * we need to find if we have any ip addresses underneath it that
5994 * correspond to the associated type.
5996 if (params
->auth_type
== auth_type
)
5998 params
->auth_type
= OSPF_AUTH_NOTSET
;
5999 UNSET_IF_PARAM (params
, auth_type
);
6002 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6004 if ((params
= rn
->info
))
6006 if (params
->auth_type
== auth_type
)
6008 params
->auth_type
= OSPF_AUTH_NOTSET
;
6009 UNSET_IF_PARAM (params
, auth_type
);
6010 if (params
!= IF_DEF_PARAMS (ifp
))
6012 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6013 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6023 DEFUN (no_ip_ospf_authentication
,
6024 no_ip_ospf_authentication_addr_cmd
,
6025 "no ip ospf authentication [A.B.C.D]",
6028 "OSPF interface commands\n"
6029 "Enable authentication on this interface\n"
6030 "Address of interface")
6033 struct interface
*ifp
;
6034 struct in_addr addr
;
6036 struct ospf_if_params
*params
;
6037 struct route_node
*rn
;
6040 params
= IF_DEF_PARAMS (ifp
);
6044 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6047 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6052 params
= ospf_lookup_if_params (ifp
, addr
);
6055 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6059 params
->auth_type
= OSPF_AUTH_NOTSET
;
6060 UNSET_IF_PARAM (params
, auth_type
);
6061 if (params
!= IF_DEF_PARAMS (ifp
))
6063 ospf_free_if_params (ifp
, addr
);
6064 ospf_if_update_params (ifp
, addr
);
6070 * When a user enters 'no ip ospf authentication'
6071 * We should remove all authentication types from
6074 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6075 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6076 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6078 params
->auth_type
= OSPF_AUTH_NOTSET
;
6079 UNSET_IF_PARAM (params
, auth_type
);
6082 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6084 if ((params
= rn
->info
))
6087 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6088 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6089 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6091 params
->auth_type
= OSPF_AUTH_NOTSET
;
6092 UNSET_IF_PARAM (params
, auth_type
);
6093 if (params
!= IF_DEF_PARAMS (ifp
))
6095 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6096 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6106 DEFUN (ip_ospf_authentication_key
,
6107 ip_ospf_authentication_key_addr_cmd
,
6108 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6110 "OSPF interface commands\n"
6111 "Authentication password (key)\n"
6112 "The OSPF password (key)\n"
6113 "Address of interface")
6116 struct interface
*ifp
;
6117 struct in_addr addr
;
6119 struct ospf_if_params
*params
;
6122 params
= IF_DEF_PARAMS (ifp
);
6126 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6129 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6134 params
= ospf_get_if_params (ifp
, addr
);
6135 ospf_if_update_params (ifp
, addr
);
6138 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6139 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6140 SET_IF_PARAM (params
, auth_simple
);
6146 DEFUN_HIDDEN (ospf_authentication_key
,
6147 ospf_authentication_key_cmd
,
6148 "ospf authentication-key AUTH_KEY",
6149 "OSPF interface commands\n"
6150 "Authentication password (key)\n"
6151 "The OSPF password (key)")
6153 struct interface
*ifp
;
6154 struct ospf_if_params
*params
;
6157 params
= IF_DEF_PARAMS (ifp
);
6158 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6159 strncpy ((char *) params
->auth_simple
, argv
[2]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6160 SET_IF_PARAM (params
, auth_simple
);
6165 DEFUN (no_ospf_authentication_key
,
6166 no_ospf_authentication_key_authkey_addr_cmd
,
6167 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6169 "OSPF interface commands\n"
6170 "Authentication password (key)\n"
6171 "The OSPF password (key)")
6173 struct interface
*ifp
;
6174 struct in_addr addr
;
6175 struct ospf_if_params
*params
;
6179 params
= IF_DEF_PARAMS (ifp
);
6183 ret
= inet_aton(argv
[4]->arg
, &addr
);
6186 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6191 params
= ospf_lookup_if_params (ifp
, addr
);
6196 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6197 UNSET_IF_PARAM (params
, auth_simple
);
6199 if (params
!= IF_DEF_PARAMS (ifp
))
6201 ospf_free_if_params (ifp
, addr
);
6202 ospf_if_update_params (ifp
, addr
);
6208 DEFUN (no_ip_ospf_authentication_key
,
6209 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6210 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6213 "OSPF interface commands\n"
6214 "Authentication password (key)\n"
6215 "The OSPF password (key)")
6217 struct interface
*ifp
;
6218 struct in_addr addr
;
6219 struct ospf_if_params
*params
;
6223 params
= IF_DEF_PARAMS (ifp
);
6227 ret
= inet_aton(argv
[5]->arg
, &addr
);
6230 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6235 params
= ospf_lookup_if_params (ifp
, addr
);
6240 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6241 UNSET_IF_PARAM (params
, auth_simple
);
6243 if (params
!= IF_DEF_PARAMS (ifp
))
6245 ospf_free_if_params (ifp
, addr
);
6246 ospf_if_update_params (ifp
, addr
);
6252 DEFUN (ip_ospf_message_digest_key
,
6253 ip_ospf_message_digest_key_addr_cmd
,
6254 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6256 "OSPF interface commands\n"
6257 "Message digest authentication password (key)\n"
6259 "Use MD5 algorithm\n"
6260 "The OSPF password (key)"
6261 "Address of interface")
6265 struct interface
*ifp
;
6266 struct crypt_key
*ck
;
6268 struct in_addr addr
;
6270 struct ospf_if_params
*params
;
6273 params
= IF_DEF_PARAMS (ifp
);
6277 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6280 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6285 params
= ospf_get_if_params (ifp
, addr
);
6286 ospf_if_update_params (ifp
, addr
);
6289 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6290 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6292 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6296 ck
= ospf_crypt_key_new ();
6297 ck
->key_id
= (u_char
) key_id
;
6298 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6299 strncpy ((char *) ck
->auth_key
, argv
[idx_ipv4
]->arg
, OSPF_AUTH_MD5_SIZE
);
6301 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6302 SET_IF_PARAM (params
, auth_crypt
);
6308 DEFUN_HIDDEN (ospf_message_digest_key
,
6309 ospf_message_digest_key_cmd
,
6310 "ospf message-digest-key (1-255) md5 KEY",
6311 "OSPF interface commands\n"
6312 "Message digest authentication password (key)\n"
6314 "Use MD5 algorithm\n"
6315 "The OSPF password (key)")
6318 struct interface
*ifp
;
6319 struct crypt_key
*ck
;
6321 struct ospf_if_params
*params
;
6324 params
= IF_DEF_PARAMS (ifp
);
6325 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6326 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6328 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6332 ck
= ospf_crypt_key_new ();
6333 ck
->key_id
= (u_char
) key_id
;
6334 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6335 strncpy ((char *) ck
->auth_key
, argv
[idx_number
]->arg
, OSPF_AUTH_MD5_SIZE
);
6337 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6338 SET_IF_PARAM (params
, auth_crypt
);
6343 DEFUN (no_ip_ospf_message_digest_key_md5
,
6344 no_ip_ospf_message_digest_key_md5_addr_cmd
,
6345 "no ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6348 "OSPF interface commands\n"
6349 "Message digest authentication password (key)\n"
6351 "Use MD5 algorithm\n"
6352 "The OSPF password (key)"
6353 "Address of interface")
6356 struct interface
*ifp
;
6357 struct crypt_key
*ck
;
6359 struct in_addr addr
;
6361 struct ospf_if_params
*params
;
6364 params
= IF_DEF_PARAMS (ifp
);
6368 ret
= inet_aton(argv
[7]->arg
, &addr
);
6371 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6376 params
= ospf_lookup_if_params (ifp
, addr
);
6381 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6382 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6385 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6389 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6391 if (params
!= IF_DEF_PARAMS (ifp
))
6393 ospf_free_if_params (ifp
, addr
);
6394 ospf_if_update_params (ifp
, addr
);
6400 DEFUN (no_ospf_message_digest_key
,
6401 no_ospf_message_digest_key_addr_cmd
,
6402 "no ospf message-digest-key (1-255) [A.B.C.D]",
6404 "OSPF interface commands\n"
6405 "Message digest authentication password (key)\n"
6407 "Address of interface")
6411 struct interface
*ifp
;
6412 struct crypt_key
*ck
;
6414 struct in_addr addr
;
6416 struct ospf_if_params
*params
;
6419 params
= IF_DEF_PARAMS (ifp
);
6423 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6426 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6431 params
= ospf_lookup_if_params (ifp
, addr
);
6436 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6437 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6440 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6444 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6446 if (params
!= IF_DEF_PARAMS (ifp
))
6448 ospf_free_if_params (ifp
, addr
);
6449 ospf_if_update_params (ifp
, addr
);
6455 DEFUN (no_ip_ospf_message_digest_key
,
6456 no_ip_ospf_message_digest_key_addr_cmd
,
6457 "no ip ospf message-digest-key (1-255) [A.B.C.D]",
6460 "OSPF interface commands\n"
6461 "Message digest authentication password (key)\n"
6463 "Address of interface")
6467 struct interface
*ifp
;
6468 struct crypt_key
*ck
;
6470 struct in_addr addr
;
6472 struct ospf_if_params
*params
;
6475 params
= IF_DEF_PARAMS (ifp
);
6479 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6482 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6487 params
= ospf_lookup_if_params (ifp
, addr
);
6492 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6493 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6496 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6500 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6502 if (params
!= IF_DEF_PARAMS (ifp
))
6504 ospf_free_if_params (ifp
, addr
);
6505 ospf_if_update_params (ifp
, addr
);
6511 DEFUN (ip_ospf_cost
,
6512 ip_ospf_cost_u32_inet4_cmd
,
6513 "ip ospf cost (1-65535) [A.B.C.D]",
6515 "OSPF interface commands\n"
6518 "Address of interface")
6522 struct interface
*ifp
= vty
->index
;
6524 struct in_addr addr
;
6526 struct ospf_if_params
*params
;
6528 params
= IF_DEF_PARAMS (ifp
);
6530 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6532 /* cost range is <1-65535>. */
6533 if (cost
< 1 || cost
> 65535)
6535 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6541 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6544 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6549 params
= ospf_get_if_params (ifp
, addr
);
6550 ospf_if_update_params (ifp
, addr
);
6553 SET_IF_PARAM (params
, output_cost_cmd
);
6554 params
->output_cost_cmd
= cost
;
6556 ospf_if_recalculate_output_cost (ifp
);
6561 DEFUN_HIDDEN (ospf_cost
,
6562 ospf_cost_u32_inet4_cmd
,
6563 "ospf cost (1-65535) A.B.C.D",
6564 "OSPF interface commands\n"
6567 "Address of interface")
6571 struct interface
*ifp
= vty
->index
;
6573 struct in_addr addr
;
6575 struct ospf_if_params
*params
;
6577 params
= IF_DEF_PARAMS (ifp
);
6579 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6581 /* cost range is <1-65535>. */
6582 if (cost
< 1 || cost
> 65535)
6584 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6590 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6593 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6598 params
= ospf_get_if_params (ifp
, addr
);
6599 ospf_if_update_params (ifp
, addr
);
6602 SET_IF_PARAM (params
, output_cost_cmd
);
6603 params
->output_cost_cmd
= cost
;
6605 ospf_if_recalculate_output_cost (ifp
);
6610 DEFUN (no_ospf_cost
,
6611 no_ospf_cost_inet4_cmd
,
6612 "no ospf cost [A.B.C.D]",
6614 "OSPF interface commands\n"
6616 "Address of interface")
6619 struct interface
*ifp
= vty
->index
;
6620 struct in_addr addr
;
6622 struct ospf_if_params
*params
;
6625 params
= IF_DEF_PARAMS (ifp
);
6629 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6632 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6637 params
= ospf_lookup_if_params (ifp
, addr
);
6642 UNSET_IF_PARAM (params
, output_cost_cmd
);
6644 if (params
!= IF_DEF_PARAMS (ifp
))
6646 ospf_free_if_params (ifp
, addr
);
6647 ospf_if_update_params (ifp
, addr
);
6650 ospf_if_recalculate_output_cost (ifp
);
6655 DEFUN (no_ip_ospf_cost
,
6656 no_ip_ospf_cost_inet4_cmd
,
6657 "no ip ospf cost [A.B.C.D]",
6660 "OSPF interface commands\n"
6662 "Address of interface")
6665 struct interface
*ifp
= vty
->index
;
6666 struct in_addr addr
;
6668 struct ospf_if_params
*params
;
6671 params
= IF_DEF_PARAMS (ifp
);
6675 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6678 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6683 params
= ospf_lookup_if_params (ifp
, addr
);
6688 UNSET_IF_PARAM (params
, output_cost_cmd
);
6690 if (params
!= IF_DEF_PARAMS (ifp
))
6692 ospf_free_if_params (ifp
, addr
);
6693 ospf_if_update_params (ifp
, addr
);
6696 ospf_if_recalculate_output_cost (ifp
);
6701 DEFUN (no_ospf_cost2
,
6702 no_ospf_cost_u32_cmd
,
6703 "no ospf cost [(1-65535) [A.B.C.D]]",
6705 "OSPF interface commands\n"
6708 "Address of interface\n")
6712 struct interface
*ifp
= vty
->index
;
6713 struct in_addr addr
;
6716 struct ospf_if_params
*params
;
6719 params
= IF_DEF_PARAMS (ifp
);
6721 /* According to the semantics we are mimicking "no ip ospf cost N" is
6722 * always treated as "no ip ospf cost" regardless of the actual value
6723 * of N already configured for the interface. Thus the first argument
6724 * is always checked to be a number, but is ignored after that.
6726 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6727 if (cost
< 1 || cost
> 65535)
6729 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6735 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6738 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6743 params
= ospf_lookup_if_params (ifp
, addr
);
6748 UNSET_IF_PARAM (params
, output_cost_cmd
);
6750 if (params
!= IF_DEF_PARAMS (ifp
))
6752 ospf_free_if_params (ifp
, addr
);
6753 ospf_if_update_params (ifp
, addr
);
6756 ospf_if_recalculate_output_cost (ifp
);
6761 DEFUN (no_ip_ospf_cost2
,
6762 no_ip_ospf_cost_u32_cmd
,
6763 "no ip ospf cost (1-65535) [A.B.C.D]",
6766 "OSPF interface commands\n"
6769 "Address of interface\n")
6773 struct interface
*ifp
= vty
->index
;
6774 struct in_addr addr
;
6777 struct ospf_if_params
*params
;
6780 params
= IF_DEF_PARAMS (ifp
);
6782 /* According to the semantics we are mimicking "no ip ospf cost N" is
6783 * always treated as "no ip ospf cost" regardless of the actual value
6784 * of N already configured for the interface. Thus the first argument
6785 * is always checked to be a number, but is ignored after that.
6787 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6788 if (cost
< 1 || cost
> 65535)
6790 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6796 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6799 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6804 params
= ospf_lookup_if_params (ifp
, addr
);
6809 UNSET_IF_PARAM (params
, output_cost_cmd
);
6811 if (params
!= IF_DEF_PARAMS (ifp
))
6813 ospf_free_if_params (ifp
, addr
);
6814 ospf_if_update_params (ifp
, addr
);
6817 ospf_if_recalculate_output_cost (ifp
);
6826 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6828 struct route_node
*rn
;
6829 struct ospf_neighbor
*nbr
;
6831 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6832 if ((nbr
= rn
->info
))
6834 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6835 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6836 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6837 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6842 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6843 const char *nbr_str
,
6844 const char *fast_hello_str
)
6846 struct interface
*ifp
= vty
->index
;
6849 struct in_addr addr
;
6851 struct ospf_if_params
*params
;
6852 struct ospf_interface
*oi
;
6853 struct route_node
*rn
;
6855 params
= IF_DEF_PARAMS (ifp
);
6859 ret
= inet_aton(nbr_str
, &addr
);
6862 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6867 params
= ospf_get_if_params (ifp
, addr
);
6868 ospf_if_update_params (ifp
, addr
);
6873 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6876 /* reset fast_hello too, just to be sure */
6877 UNSET_IF_PARAM (params
, fast_hello
);
6878 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6880 else if (fast_hello_str
)
6882 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6884 /* 1s dead-interval with sub-second hellos desired */
6885 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6886 SET_IF_PARAM (params
, fast_hello
);
6887 params
->fast_hello
= hellomult
;
6891 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6896 SET_IF_PARAM (params
, v_wait
);
6897 params
->v_wait
= seconds
;
6899 /* Update timer values in neighbor structure. */
6903 if ((ospf
= ospf_lookup()))
6905 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6907 ospf_nbr_timer_update (oi
);
6912 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6913 if ((oi
= rn
->info
))
6914 ospf_nbr_timer_update (oi
);
6920 DEFUN (ip_ospf_dead_interval
,
6921 ip_ospf_dead_interval_addr_cmd
,
6922 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6924 "OSPF interface commands\n"
6925 "Interval after which a neighbor is declared dead\n"
6927 "Address of interface\n")
6932 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, argv
[idx_ipv4
]->arg
, NULL
);
6934 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, NULL
, NULL
);
6938 DEFUN_HIDDEN (ospf_dead_interval
,
6939 ospf_dead_interval_cmd
,
6940 "ospf dead-interval (1-65535)",
6941 "OSPF interface commands\n"
6942 "Interval after which a neighbor is declared dead\n"
6947 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, NULL
, NULL
);
6950 DEFUN (ip_ospf_dead_interval_minimal
,
6951 ip_ospf_dead_interval_minimal_addr_cmd
,
6952 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6954 "OSPF interface commands\n"
6955 "Interval after which a neighbor is declared dead\n"
6956 "Minimal 1s dead-interval with fast sub-second hellos\n"
6957 "Hello multiplier factor\n"
6958 "Number of Hellos to send each second\n"
6959 "Address of interface\n")
6964 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6966 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6969 DEFUN (no_ospf_dead_interval
,
6970 no_ospf_dead_interval_cmd
,
6971 "no ospf dead-interval",
6973 "OSPF interface commands\n"
6974 "Interval after which a neighbor is declared dead\n")
6976 struct interface
*ifp
= vty
->index
;
6977 struct ospf_if_params
*params
;
6980 params
= IF_DEF_PARAMS (ifp
);
6982 UNSET_IF_PARAM (params
, v_wait
);
6983 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6985 UNSET_IF_PARAM (params
, fast_hello
);
6986 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6991 DEFUN (no_ip_ospf_dead_interval
,
6992 no_ip_ospf_dead_interval_addr_cmd
,
6993 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6996 "OSPF interface commands\n"
6997 "Interval after which a neighbor is declared dead\n"
6999 "Address of interface")
7001 int idx_ipv4
= argc
- 1;
7002 struct interface
*ifp
= vty
->index
;
7003 struct in_addr addr
;
7005 struct ospf_if_params
*params
;
7006 struct ospf_interface
*oi
;
7007 struct route_node
*rn
;
7010 params
= IF_DEF_PARAMS (ifp
);
7012 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
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_lookup_if_params (ifp
, addr
);
7027 UNSET_IF_PARAM (params
, v_wait
);
7028 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7030 UNSET_IF_PARAM (params
, fast_hello
);
7031 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7033 if (params
!= IF_DEF_PARAMS (ifp
))
7035 ospf_free_if_params (ifp
, addr
);
7036 ospf_if_update_params (ifp
, addr
);
7039 /* Update timer values in neighbor structure. */
7044 if ((ospf
= ospf_lookup()))
7046 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
7048 ospf_nbr_timer_update (oi
);
7053 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7054 if ((oi
= rn
->info
))
7055 ospf_nbr_timer_update (oi
);
7061 DEFUN (ip_ospf_hello_interval
,
7062 ip_ospf_hello_interval_addr_cmd
,
7063 "ip ospf hello-interval (1-65535) [A.B.C.D]",
7065 "OSPF interface commands\n"
7066 "Time between HELLO packets\n"
7068 "Address of interface")
7072 struct interface
*ifp
= vty
->index
;
7074 struct in_addr addr
;
7076 struct ospf_if_params
*params
;
7078 params
= IF_DEF_PARAMS (ifp
);
7080 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7082 /* HelloInterval range is <1-65535>. */
7083 if (seconds
< 1 || seconds
> 65535)
7085 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7091 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7094 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7099 params
= ospf_get_if_params (ifp
, addr
);
7100 ospf_if_update_params (ifp
, addr
);
7103 SET_IF_PARAM (params
, v_hello
);
7104 params
->v_hello
= seconds
;
7110 DEFUN_HIDDEN (ospf_hello_interval
,
7111 ospf_hello_interval_cmd
,
7112 "ospf hello-interval (1-65535)",
7113 "OSPF interface commands\n"
7114 "Time between HELLO packets\n"
7118 struct interface
*ifp
= vty
->index
;
7120 struct ospf_if_params
*params
;
7122 params
= IF_DEF_PARAMS (ifp
);
7124 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7126 /* HelloInterval range is <1-65535>. */
7127 if (seconds
< 1 || seconds
> 65535)
7129 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7133 SET_IF_PARAM (params
, v_hello
);
7134 params
->v_hello
= seconds
;
7139 DEFUN (no_ip_ospf_hello_interval
,
7140 no_ip_ospf_hello_interval_addr_cmd
,
7141 "no [ip] ospf hello-interval [(1-65535) [A.B.C.D]]",
7144 "OSPF interface commands\n"
7145 "Time between HELLO packets\n"
7147 "Address of interface")
7150 struct interface
*ifp
= vty
->index
;
7151 struct in_addr addr
;
7153 struct ospf_if_params
*params
;
7156 params
= IF_DEF_PARAMS (ifp
);
7158 if (strcmp (argv
[1]->arg
, "ip") == 0)
7161 if (argc
== idx_ipv4
+1)
7163 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7166 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7171 params
= ospf_lookup_if_params (ifp
, addr
);
7176 UNSET_IF_PARAM (params
, v_hello
);
7177 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7179 if (params
!= IF_DEF_PARAMS (ifp
))
7181 ospf_free_if_params (ifp
, addr
);
7182 ospf_if_update_params (ifp
, addr
);
7191 DEFUN (ip_ospf_network
,
7192 ip_ospf_network_cmd
,
7193 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7195 "OSPF interface commands\n"
7197 "Specify OSPF broadcast multi-access network\n"
7198 "Specify OSPF NBMA network\n"
7199 "Specify OSPF point-to-multipoint network\n"
7200 "Specify OSPF point-to-point network\n")
7202 int idx_network
= 3;
7203 struct interface
*ifp
= vty
->index
;
7204 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7205 struct route_node
*rn
;
7207 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7209 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7213 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
7214 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7215 else if (strncmp (argv
[idx_network
]->arg
, "n", 1) == 0)
7216 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7217 else if (strncmp (argv
[idx_network
]->arg
, "point-to-m", 10) == 0)
7218 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7219 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
7220 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7222 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7225 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7227 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7229 struct ospf_interface
*oi
= rn
->info
;
7234 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7236 if (oi
->state
> ISM_Down
)
7238 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7239 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7246 DEFUN_HIDDEN (ospf_network
,
7248 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7249 "OSPF interface commands\n"
7251 "Specify OSPF broadcast multi-access network\n"
7252 "Specify OSPF NBMA network\n"
7253 "Specify OSPF point-to-multipoint network\n"
7254 "Specify OSPF point-to-point network\n")
7256 int idx_network
= 2;
7257 struct interface
*ifp
= vty
->index
;
7258 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7259 struct route_node
*rn
;
7261 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7263 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7267 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
7268 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7269 else if (strncmp (argv
[idx_network
]->arg
, "n", 1) == 0)
7270 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7271 else if (strncmp (argv
[idx_network
]->arg
, "point-to-m", 10) == 0)
7272 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7273 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
7274 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7276 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7279 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7281 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7283 struct ospf_interface
*oi
= rn
->info
;
7288 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7290 if (oi
->state
> ISM_Down
)
7292 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7293 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7300 DEFUN (no_ospf_network
,
7301 no_ospf_network_cmd
,
7302 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7304 "OSPF interface commands\n"
7306 "Specify OSPF broadcast multi-access network\n"
7307 "Specify OSPF NBMA network\n"
7308 "Specify OSPF point-to-multipoint network\n"
7309 "Specify OSPF point-to-point network\n")
7311 struct interface
*ifp
= vty
->index
;
7312 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7313 struct route_node
*rn
;
7315 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7317 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7320 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7322 struct ospf_interface
*oi
= rn
->info
;
7327 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7329 if (oi
->state
> ISM_Down
)
7331 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7332 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7339 DEFUN (no_ip_ospf_network
,
7340 no_ip_ospf_network_cmd
,
7341 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7344 "OSPF interface commands\n"
7346 "Specify OSPF broadcast multi-access network\n"
7347 "Specify OSPF NBMA network\n"
7348 "Specify OSPF point-to-multipoint network\n"
7349 "Specify OSPF point-to-point network\n")
7351 struct interface
*ifp
= vty
->index
;
7352 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7353 struct route_node
*rn
;
7355 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7357 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7360 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7362 struct ospf_interface
*oi
= rn
->info
;
7367 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7369 if (oi
->state
> ISM_Down
)
7371 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7372 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7379 DEFUN (ip_ospf_priority
,
7380 ip_ospf_priority_addr_cmd
,
7381 "ip ospf priority (0-255) [A.B.C.D]",
7383 "OSPF interface commands\n"
7386 "Address of interface")
7390 struct interface
*ifp
= vty
->index
;
7392 struct route_node
*rn
;
7393 struct in_addr addr
;
7395 struct ospf_if_params
*params
;
7397 params
= IF_DEF_PARAMS (ifp
);
7399 priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7401 /* Router Priority range is <0-255>. */
7402 if (priority
< 0 || priority
> 255)
7404 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7410 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7413 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7418 params
= ospf_get_if_params (ifp
, addr
);
7419 ospf_if_update_params (ifp
, addr
);
7422 SET_IF_PARAM (params
, priority
);
7423 params
->priority
= priority
;
7425 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7427 struct ospf_interface
*oi
= rn
->info
;
7432 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7434 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7435 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7443 DEFUN_HIDDEN (ospf_priority
,
7445 "ospf priority (0-255)",
7446 "OSPF interface commands\n"
7451 struct interface
*ifp
= vty
->index
;
7453 struct route_node
*rn
;
7454 struct ospf_if_params
*params
;
7456 params
= IF_DEF_PARAMS (ifp
);
7458 priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7460 /* Router Priority range is <0-255>. */
7461 if (priority
< 0 || priority
> 255)
7463 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7467 SET_IF_PARAM (params
, priority
);
7468 params
->priority
= priority
;
7470 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7472 struct ospf_interface
*oi
= rn
->info
;
7478 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7480 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7481 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7488 DEFUN (no_ospf_priority
,
7489 no_ospf_priority_addr_cmd
,
7490 "no ospf priority [(0-255) [A.B.C.D]]",
7492 "OSPF interface commands\n"
7495 "Address of interface")
7498 struct interface
*ifp
= vty
->index
;
7499 struct route_node
*rn
;
7500 struct in_addr addr
;
7502 struct ospf_if_params
*params
;
7505 params
= IF_DEF_PARAMS (ifp
);
7509 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7512 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7517 params
= ospf_lookup_if_params (ifp
, addr
);
7522 UNSET_IF_PARAM (params
, priority
);
7523 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7525 if (params
!= IF_DEF_PARAMS (ifp
))
7527 ospf_free_if_params (ifp
, addr
);
7528 ospf_if_update_params (ifp
, addr
);
7531 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7533 struct ospf_interface
*oi
= rn
->info
;
7539 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7541 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7542 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7549 DEFUN (no_ip_ospf_priority
,
7550 no_ip_ospf_priority_addr_cmd
,
7551 "no ip ospf priority [(0-255) [A.B.C.D]]",
7554 "OSPF interface commands\n"
7557 "Address of interface")
7560 struct interface
*ifp
= vty
->index
;
7561 struct route_node
*rn
;
7562 struct in_addr addr
;
7564 struct ospf_if_params
*params
;
7567 params
= IF_DEF_PARAMS (ifp
);
7571 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7574 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7579 params
= ospf_lookup_if_params (ifp
, addr
);
7584 UNSET_IF_PARAM (params
, priority
);
7585 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7587 if (params
!= IF_DEF_PARAMS (ifp
))
7589 ospf_free_if_params (ifp
, addr
);
7590 ospf_if_update_params (ifp
, addr
);
7593 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7595 struct ospf_interface
*oi
= rn
->info
;
7601 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7603 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7604 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7612 DEFUN (ip_ospf_retransmit_interval
,
7613 ip_ospf_retransmit_interval_addr_cmd
,
7614 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
7616 "OSPF interface commands\n"
7617 "Time between retransmitting lost link state advertisements\n"
7619 "Address of interface")
7623 struct interface
*ifp
= vty
->index
;
7625 struct in_addr addr
;
7627 struct ospf_if_params
*params
;
7629 params
= IF_DEF_PARAMS (ifp
);
7630 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7632 /* Retransmit Interval range is <3-65535>. */
7633 if (seconds
< 3 || seconds
> 65535)
7635 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7642 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7645 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7650 params
= ospf_get_if_params (ifp
, addr
);
7651 ospf_if_update_params (ifp
, addr
);
7654 SET_IF_PARAM (params
, retransmit_interval
);
7655 params
->retransmit_interval
= seconds
;
7660 DEFUN_HIDDEN (ospf_retransmit_interval
,
7661 ospf_retransmit_interval_cmd
,
7662 "ospf retransmit-interval (3-65535)",
7663 "OSPF interface commands\n"
7664 "Time between retransmitting lost link state advertisements\n"
7668 struct interface
*ifp
= vty
->index
;
7670 struct ospf_if_params
*params
;
7672 params
= IF_DEF_PARAMS (ifp
);
7673 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7675 /* Retransmit Interval range is <3-65535>. */
7676 if (seconds
< 3 || seconds
> 65535)
7678 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7682 SET_IF_PARAM (params
, retransmit_interval
);
7683 params
->retransmit_interval
= seconds
;
7688 DEFUN (no_ospf_retransmit_interval
,
7689 no_ospf_retransmit_interval_cmd
,
7690 "no ospf retransmit-interval",
7692 "OSPF interface commands\n"
7693 "Time between retransmitting lost link state advertisements\n")
7695 struct interface
*ifp
= vty
->index
;
7696 struct ospf_if_params
*params
;
7699 params
= IF_DEF_PARAMS (ifp
);
7700 UNSET_IF_PARAM (params
, retransmit_interval
);
7701 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7706 DEFUN (no_ip_ospf_retransmit_interval
,
7707 no_ip_ospf_retransmit_interval_addr_cmd
,
7708 "no ip ospf retransmit-interval [<(3-65535) [A.B.C.D]|A.B.C.D>]",
7711 "OSPF interface commands\n"
7712 "Time between retransmitting lost link state advertisements\n"
7713 "Address of interface")
7715 struct interface
*ifp
= vty
->index
;
7716 struct in_addr addr
;
7718 struct ospf_if_params
*params
;
7722 params
= IF_DEF_PARAMS (ifp
);
7731 ret
= inet_aton(argv
[addr_index
]->arg
, &addr
);
7734 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7739 params
= ospf_lookup_if_params (ifp
, addr
);
7744 UNSET_IF_PARAM (params
, retransmit_interval
);
7745 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7747 if (params
!= IF_DEF_PARAMS (ifp
))
7749 ospf_free_if_params (ifp
, addr
);
7750 ospf_if_update_params (ifp
, addr
);
7757 DEFUN (ip_ospf_transmit_delay
,
7758 ip_ospf_transmit_delay_addr_cmd
,
7759 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7761 "OSPF interface commands\n"
7762 "Link state transmit delay\n"
7764 "Address of interface")
7768 struct interface
*ifp
= vty
->index
;
7770 struct in_addr addr
;
7772 struct ospf_if_params
*params
;
7774 params
= IF_DEF_PARAMS (ifp
);
7775 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7777 /* Transmit Delay range is <1-65535>. */
7778 if (seconds
< 1 || seconds
> 65535)
7780 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7786 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7789 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7794 params
= ospf_get_if_params (ifp
, addr
);
7795 ospf_if_update_params (ifp
, addr
);
7798 SET_IF_PARAM (params
, transmit_delay
);
7799 params
->transmit_delay
= seconds
;
7805 DEFUN_HIDDEN (ospf_transmit_delay
,
7806 ospf_transmit_delay_cmd
,
7807 "ospf transmit-delay (1-65535)",
7808 "OSPF interface commands\n"
7809 "Link state transmit delay\n"
7813 struct interface
*ifp
= vty
->index
;
7815 struct ospf_if_params
*params
;
7817 params
= IF_DEF_PARAMS (ifp
);
7818 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7820 /* Transmit Delay range is <1-65535>. */
7821 if (seconds
< 1 || seconds
> 65535)
7823 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7827 SET_IF_PARAM (params
, transmit_delay
);
7828 params
->transmit_delay
= seconds
;
7833 DEFUN (no_ip_ospf_transmit_delay
,
7834 no_ip_ospf_transmit_delay_addr_cmd
,
7835 "no ip ospf transmit-delay [<A.B.C.D|(1-65535) A.B.C.D>]",
7838 "OSPF interface commands\n"
7839 "Link state transmit delay\n"
7840 "Address of interface")
7842 struct interface
*ifp
= vty
->index
;
7843 struct in_addr addr
;
7845 struct ospf_if_params
*params
;
7849 params
= IF_DEF_PARAMS (ifp
);
7858 ret
= inet_aton(argv
[addr_index
]->arg
, &addr
);
7861 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7866 params
= ospf_lookup_if_params (ifp
, addr
);
7871 UNSET_IF_PARAM (params
, transmit_delay
);
7872 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7874 if (params
!= IF_DEF_PARAMS (ifp
))
7876 ospf_free_if_params (ifp
, addr
);
7877 ospf_if_update_params (ifp
, addr
);
7884 DEFUN (no_ospf_transmit_delay
,
7885 no_ospf_transmit_delay_cmd
,
7886 "no ospf transmit-delay",
7888 "OSPF interface commands\n"
7889 "Link state transmit delay\n")
7891 struct interface
*ifp
= vty
->index
;
7892 struct ospf_if_params
*params
;
7895 params
= IF_DEF_PARAMS (ifp
);
7897 UNSET_IF_PARAM (params
, transmit_delay
);
7898 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7903 DEFUN (no_ip_ospf_transmit_delay_sec
,
7904 no_ip_ospf_transmit_delay_sec_cmd
,
7905 "no ip ospf transmit-delay (1-65535)",
7908 "OSPF interface commands\n"
7909 "Link state transmit delay\n"
7911 "Address of interface")
7913 struct interface
*ifp
= vty
->index
;
7914 struct ospf_if_params
*params
;
7917 params
= IF_DEF_PARAMS (ifp
);
7919 UNSET_IF_PARAM (params
, transmit_delay
);
7920 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7925 DEFUN (ip_ospf_area
,
7927 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7929 "OSPF interface commands\n"
7931 "Enable OSPF on this interface\n"
7932 "OSPF area ID in IP address format\n"
7933 "OSPF area ID as a decimal value\n")
7935 int idx_ipv4_number
= 2;
7936 struct interface
*ifp
= vty
->index
;
7938 struct in_addr area_id
;
7940 struct ospf_if_params
*params
;
7941 struct route_node
*rn
;
7942 u_short instance
= 0;
7945 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_ipv4_number
]->arg
);
7947 ospf
= ospf_lookup_instance (instance
);
7950 params
= IF_DEF_PARAMS (ifp
);
7951 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7953 ospf_interface_unset (ifp
);
7954 ospf
= ospf_lookup();
7955 ospf
->if_ospf_cli_count
--;
7960 ret
= ospf_str2area_id (argv
[instance
? 4 : 3]->arg
, &area_id
, &format
);
7963 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7967 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7969 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7973 params
= IF_DEF_PARAMS (ifp
);
7974 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7977 "Must remove previous area config before changing ospf area %s",
7982 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7984 if (rn
->info
!= NULL
)
7986 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7991 /* enable ospf on this interface with area_id */
7992 ospf_interface_set (ifp
, area_id
);
7993 ospf
->if_ospf_cli_count
++;
7998 DEFUN (no_ip_ospf_area
,
7999 no_ip_ospf_area_cmd
,
8000 "no ip ospf area [<A.B.C.D|(0-4294967295)>]",
8003 "OSPF interface commands\n"
8004 "Disable OSPF on this interface\n"
8005 "OSPF area ID in IP address format\n"
8006 "OSPF area ID as a decimal value\n")
8008 struct interface
*ifp
= vty
->index
;
8010 struct ospf_if_params
*params
;
8011 u_short instance
= 0;
8013 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8016 params
= IF_DEF_PARAMS (ifp
);
8017 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8019 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8023 ospf_interface_unset (ifp
);
8024 ospf
->if_ospf_cli_count
--;
8028 DEFUN (no_ip_ospf_instance_area
,
8029 no_ip_ospf_instance_area_cmd
,
8030 "no ip ospf (1-65535) area [<A.B.C.D|(0-4294967295)>]",
8033 "OSPF interface commands\n"
8035 "Disable OSPF on this interface\n")
8038 struct interface
*ifp
= vty
->index
;
8040 struct ospf_if_params
*params
;
8041 u_short instance
= 0;
8043 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8045 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8048 params
= IF_DEF_PARAMS (ifp
);
8049 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8051 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8055 ospf_interface_unset (ifp
);
8056 ospf
->if_ospf_cli_count
--;
8060 DEFUN (ospf_redistribute_source
,
8061 ospf_redistribute_source_cmd
,
8062 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8064 QUAGGA_REDIST_HELP_STR_OSPFD
8065 "Metric for redistributed routes\n"
8066 "OSPF default metric\n"
8067 "OSPF exterior metric type for redistributed routes\n"
8068 "Set OSPF External Type 1 metrics\n"
8069 "Set OSPF External Type 2 metrics\n"
8070 "Route map reference\n"
8071 "Pointer to route-map entries\n")
8073 int idx_protocol
= 1;
8074 int idx_redist_param
= 2;
8075 struct ospf
*ospf
= vty
->index
;
8079 struct ospf_redist
*red
;
8085 return CMD_WARNING
; /* should not happen */
8090 /* Get distribute source. */
8091 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
8092 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8095 /* Get metric value. */
8096 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8097 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8100 /* Get metric type. */
8101 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8102 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8105 red
= ospf_redist_add(ospf
, source
, 0);
8107 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8108 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8110 ospf_routemap_unset (red
);
8112 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
8115 DEFUN (no_ospf_redistribute_source
,
8116 no_ospf_redistribute_source_cmd
,
8117 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8120 QUAGGA_REDIST_HELP_STR_OSPFD
8121 "Metric for redistributed routes\n"
8122 "OSPF default metric\n"
8123 "OSPF exterior metric type for redistributed routes\n"
8124 "Set OSPF External Type 1 metrics\n"
8125 "Set OSPF External Type 2 metrics\n"
8126 "Route map reference\n"
8127 "Pointer to route-map entries\n")
8129 int idx_protocol
= 2;
8130 struct ospf
*ospf
= vty
->index
;
8132 struct ospf_redist
*red
;
8136 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
8137 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8140 red
= ospf_redist_lookup(ospf
, source
, 0);
8144 ospf_routemap_unset (red
);
8145 return ospf_redistribute_unset (ospf
, source
, 0);
8148 DEFUN (ospf_redistribute_instance_source
,
8149 ospf_redistribute_instance_source_cmd
,
8150 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8152 "Open Shortest Path First\n"
8153 "Non-main Kernel Routing Table\n"
8154 "Instance ID/Table ID\n"
8155 "Metric for redistributed routes\n"
8156 "OSPF default metric\n"
8157 "OSPF exterior metric type for redistributed routes\n"
8158 "Set OSPF External Type 1 metrics\n"
8159 "Set OSPF External Type 2 metrics\n"
8160 "Route map reference\n"
8161 "Pointer to route-map entries\n")
8163 int idx_ospf_table
= 1;
8165 int idx_redist_param
= 3;
8166 struct ospf
*ospf
= vty
->index
;
8171 struct ospf_redist
*red
;
8176 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8177 source
= ZEBRA_ROUTE_OSPF
;
8179 source
= ZEBRA_ROUTE_TABLE
;
8181 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
8186 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8188 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8193 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8195 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8200 /* Get metric value. */
8201 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8202 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8205 /* Get metric type. */
8206 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8207 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8210 red
= ospf_redist_add(ospf
, source
, instance
);
8212 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8213 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8215 ospf_routemap_unset (red
);
8217 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
8220 DEFUN (no_ospf_redistribute_instance_source
,
8221 no_ospf_redistribute_instance_source_cmd
,
8222 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8225 "Open Shortest Path First\n"
8226 "Non-main Kernel Routing Table\n"
8227 "Instance ID/Table Id\n"
8228 "Metric for redistributed routes\n"
8229 "OSPF default metric\n"
8230 "OSPF exterior metric type for redistributed routes\n"
8231 "Set OSPF External Type 1 metrics\n"
8232 "Set OSPF External Type 2 metrics\n"
8233 "Route map reference\n"
8234 "Pointer to route-map entries\n")
8236 int idx_ospf_table
= 2;
8238 struct ospf
*ospf
= vty
->index
;
8240 struct ospf_redist
*red
;
8246 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8247 source
= ZEBRA_ROUTE_OSPF
;
8249 source
= ZEBRA_ROUTE_TABLE
;
8251 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
8253 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8255 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8260 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8262 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8267 red
= ospf_redist_lookup(ospf
, source
, instance
);
8271 ospf_routemap_unset (red
);
8272 return ospf_redistribute_unset (ospf
, source
, instance
);
8275 DEFUN (ospf_distribute_list_out
,
8276 ospf_distribute_list_out_cmd
,
8277 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
8278 "Filter networks in routing updates\n"
8279 "Access-list name\n"
8281 QUAGGA_REDIST_HELP_STR_OSPFD
)
8284 struct ospf
*ospf
= vty
->index
;
8290 /* Get distribute source. */
8291 source
= proto_redistnum(AFI_IP
, argv
[4]->arg
);
8292 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8295 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
8298 DEFUN (no_ospf_distribute_list_out
,
8299 no_ospf_distribute_list_out_cmd
,
8300 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
8302 "Filter networks in routing updates\n"
8303 "Access-list name\n"
8305 QUAGGA_REDIST_HELP_STR_OSPFD
)
8308 struct ospf
*ospf
= vty
->index
;
8314 source
= proto_redistnum(AFI_IP
, argv
[5]->arg
);
8315 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8318 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
8321 /* Default information originate. */
8322 DEFUN (ospf_default_information_originate
,
8323 ospf_default_information_originate_cmd
,
8324 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8325 "Control distribution of default information\n"
8326 "Distribute a default route\n"
8327 "Always advertise default route\n"
8328 "OSPF default metric\n"
8330 "OSPF metric type for default routes\n"
8331 "Set OSPF External Type 1 metrics\n"
8332 "Set OSPF External Type 2 metrics\n"
8333 "Route map reference\n"
8334 "Pointer to route-map entries\n")
8336 int idx_redist_param
= 2;
8337 struct ospf
*ospf
= vty
->index
;
8338 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8341 struct ospf_redist
*red
;
8347 return CMD_WARNING
; /* this should not happen */
8349 /* Check whether "always" was specified */
8350 if (argv
[idx_redist_param
]->arg
!= NULL
)
8351 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8353 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8355 /* Get metric value. */
8356 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8357 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8360 /* Get metric type. */
8361 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8362 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8365 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8366 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8368 ospf_routemap_unset (red
);
8370 return ospf_redistribute_default_set (ospf
, default_originate
,
8374 DEFUN (no_ospf_default_information_originate
,
8375 no_ospf_default_information_originate_cmd
,
8376 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8378 "Control distribution of default information\n"
8379 "Distribute a default route\n"
8380 "Always advertise default route\n"
8381 "OSPF default metric\n"
8383 "OSPF metric type for default routes\n"
8384 "Set OSPF External Type 1 metrics\n"
8385 "Set OSPF External Type 2 metrics\n"
8386 "Route map reference\n"
8387 "Pointer to route-map entries\n")
8389 struct ospf
*ospf
= vty
->index
;
8390 struct prefix_ipv4 p
;
8391 struct ospf_external
*ext
;
8392 struct ospf_redist
*red
;
8398 p
.prefix
.s_addr
= 0;
8401 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
8403 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
8404 EXTERNAL_INFO (ext
)) {
8405 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
8406 ospf_external_del (DEFAULT_ROUTE
, 0);
8409 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8413 ospf_routemap_unset (red
);
8414 return ospf_redistribute_default_unset (ospf
);
8417 DEFUN (ospf_default_metric
,
8418 ospf_default_metric_cmd
,
8419 "default-metric (0-16777214)",
8420 "Set metric of redistributed routes\n"
8424 struct ospf
*ospf
= vty
->index
;
8430 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
8433 ospf
->default_metric
= metric
;
8438 DEFUN (no_ospf_default_metric
,
8439 no_ospf_default_metric_cmd
,
8440 "no default-metric [(0-16777214)]",
8442 "Set metric of redistributed routes\n"
8445 struct ospf
*ospf
= vty
->index
;
8450 ospf
->default_metric
= -1;
8456 DEFUN (ospf_distance
,
8459 "Define an administrative distance\n"
8460 "OSPF Administrative distance\n")
8463 struct ospf
*ospf
= vty
->index
;
8468 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
8473 DEFUN (no_ospf_distance
,
8474 no_ospf_distance_cmd
,
8475 "no distance (1-255)",
8477 "Define an administrative distance\n"
8478 "OSPF Administrative distance\n")
8480 struct ospf
*ospf
= vty
->index
;
8485 ospf
->distance_all
= 0;
8490 DEFUN (no_ospf_distance_ospf
,
8491 no_ospf_distance_ospf_cmd
,
8492 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
8494 "Define an administrative distance\n"
8495 "OSPF Administrative distance\n"
8496 "Intra-area routes\n"
8497 "Distance for intra-area routes\n"
8498 "Inter-area routes\n"
8499 "Distance for inter-area routes\n"
8501 "Distance for external routes\n")
8503 int idx_area_distance
= 3;
8504 struct ospf
*ospf
= vty
->index
;
8515 if (argv
[idx_area_distance
]->arg
!= NULL
)
8516 ospf
->distance_intra
= 0;
8518 if (argv
[1] != NULL
)
8519 ospf
->distance_inter
= 0;
8521 if (argv
[2] != NULL
)
8522 ospf
->distance_external
= 0;
8524 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
8527 /* If no arguments are given, clear all distance information */
8528 ospf
->distance_intra
= 0;
8529 ospf
->distance_inter
= 0;
8530 ospf
->distance_external
= 0;
8535 DEFUN (ospf_distance_ospf
,
8536 ospf_distance_ospf_cmd
,
8537 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
8538 "Define an administrative distance\n"
8539 "OSPF Administrative distance\n"
8540 "Intra-area routes\n"
8541 "Distance for intra-area routes\n"
8542 "Inter-area routes\n"
8543 "Distance for inter-area routes\n"
8545 "Distance for external routes\n")
8547 int idx_area_distance
= 2;
8548 struct ospf
*ospf
= vty
->index
;
8553 if (argc
< 3) /* should not happen */
8556 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
8558 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
8563 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
8564 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
8566 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
8567 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
8569 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
8570 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
8575 DEFUN (ospf_distance_source
,
8576 ospf_distance_source_cmd
,
8577 "distance (1-255) A.B.C.D/M",
8578 "Administrative distance\n"
8580 "IP source prefix\n")
8583 int idx_ipv4_prefixlen
= 2;
8584 struct ospf
*ospf
= vty
->index
;
8589 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8594 DEFUN (no_ospf_distance_source
,
8595 no_ospf_distance_source_cmd
,
8596 "no distance (1-255) A.B.C.D/M",
8598 "Administrative distance\n"
8600 "IP source prefix\n")
8603 int idx_ipv4_prefixlen
= 3;
8604 struct ospf
*ospf
= vty
->index
;
8609 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8614 DEFUN (ospf_distance_source_access_list
,
8615 ospf_distance_source_access_list_cmd
,
8616 "distance (1-255) A.B.C.D/M WORD",
8617 "Administrative distance\n"
8619 "IP source prefix\n"
8620 "Access list name\n")
8623 int idx_ipv4_prefixlen
= 2;
8625 struct ospf
*ospf
= vty
->index
;
8630 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8635 DEFUN (no_ospf_distance_source_access_list
,
8636 no_ospf_distance_source_access_list_cmd
,
8637 "no distance (1-255) A.B.C.D/M WORD",
8639 "Administrative distance\n"
8641 "IP source prefix\n"
8642 "Access list name\n")
8645 int idx_ipv4_prefixlen
= 3;
8647 struct ospf
*ospf
= vty
->index
;
8652 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8657 DEFUN (ip_ospf_mtu_ignore
,
8658 ip_ospf_mtu_ignore_addr_cmd
,
8659 "ip ospf mtu-ignore [A.B.C.D]",
8661 "OSPF interface commands\n"
8662 "Disable mtu mismatch detection\n"
8663 "Address of interface")
8666 struct interface
*ifp
= vty
->index
;
8667 struct in_addr addr
;
8670 struct ospf_if_params
*params
;
8671 params
= IF_DEF_PARAMS (ifp
);
8675 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8678 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8682 params
= ospf_get_if_params (ifp
, addr
);
8683 ospf_if_update_params (ifp
, addr
);
8685 params
->mtu_ignore
= 1;
8686 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8687 SET_IF_PARAM (params
, mtu_ignore
);
8690 UNSET_IF_PARAM (params
, mtu_ignore
);
8691 if (params
!= IF_DEF_PARAMS (ifp
))
8693 ospf_free_if_params (ifp
, addr
);
8694 ospf_if_update_params (ifp
, addr
);
8700 DEFUN (no_ip_ospf_mtu_ignore
,
8701 no_ip_ospf_mtu_ignore_addr_cmd
,
8702 "no ip ospf mtu-ignore [A.B.C.D]",
8704 "OSPF interface commands\n"
8705 "Disable mtu mismatch detection\n"
8706 "Address of interface")
8709 struct interface
*ifp
= vty
->index
;
8710 struct in_addr addr
;
8713 struct ospf_if_params
*params
;
8714 params
= IF_DEF_PARAMS (ifp
);
8718 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8721 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8725 params
= ospf_get_if_params (ifp
, addr
);
8726 ospf_if_update_params (ifp
, addr
);
8728 params
->mtu_ignore
= 0;
8729 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8730 SET_IF_PARAM (params
, mtu_ignore
);
8733 UNSET_IF_PARAM (params
, mtu_ignore
);
8734 if (params
!= IF_DEF_PARAMS (ifp
))
8736 ospf_free_if_params (ifp
, addr
);
8737 ospf_if_update_params (ifp
, addr
);
8744 DEFUN (ospf_max_metric_router_lsa_admin
,
8745 ospf_max_metric_router_lsa_admin_cmd
,
8746 "max-metric router-lsa administrative",
8747 "OSPF maximum / infinite-distance metric\n"
8748 "Advertise own Router-LSA with infinite distance (stub router)\n"
8749 "Administratively applied, for an indefinite period\n")
8751 struct listnode
*ln
;
8752 struct ospf_area
*area
;
8753 struct ospf
*ospf
= vty
->index
;
8758 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8760 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8762 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
8763 ospf_router_lsa_update_area (area
);
8766 /* Allows for areas configured later to get the property */
8767 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8772 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8773 no_ospf_max_metric_router_lsa_admin_cmd
,
8774 "no max-metric router-lsa administrative",
8776 "OSPF maximum / infinite-distance metric\n"
8777 "Advertise own Router-LSA with infinite distance (stub router)\n"
8778 "Administratively applied, for an indefinite period\n")
8780 struct listnode
*ln
;
8781 struct ospf_area
*area
;
8782 struct ospf
*ospf
= vty
->index
;
8787 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8789 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8791 /* Don't trample on the start-up stub timer */
8792 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8793 && !area
->t_stub_router
)
8795 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8796 ospf_router_lsa_update_area (area
);
8799 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8803 DEFUN (ospf_max_metric_router_lsa_startup
,
8804 ospf_max_metric_router_lsa_startup_cmd
,
8805 "max-metric router-lsa on-startup (5-86400)",
8806 "OSPF maximum / infinite-distance metric\n"
8807 "Advertise own Router-LSA with infinite distance (stub router)\n"
8808 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8809 "Time (seconds) to advertise self as stub-router\n")
8812 unsigned int seconds
;
8813 struct ospf
*ospf
= vty
->index
;
8820 vty_out (vty
, "%% Must supply stub-router period");
8824 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
8826 ospf
->stub_router_startup_time
= seconds
;
8831 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8832 no_ospf_max_metric_router_lsa_startup_cmd
,
8833 "no max-metric router-lsa on-startup [(5-86400)]",
8835 "OSPF maximum / infinite-distance metric\n"
8836 "Advertise own Router-LSA with infinite distance (stub router)\n"
8837 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8838 "Time (seconds) to advertise self as stub-router\n")
8840 struct listnode
*ln
;
8841 struct ospf_area
*area
;
8842 struct ospf
*ospf
= vty
->index
;
8847 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8849 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8851 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8852 OSPF_TIMER_OFF (area
->t_stub_router
);
8854 /* Don't trample on admin stub routed */
8855 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8857 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8858 ospf_router_lsa_update_area (area
);
8865 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8866 ospf_max_metric_router_lsa_shutdown_cmd
,
8867 "max-metric router-lsa on-shutdown (5-100)",
8868 "OSPF maximum / infinite-distance metric\n"
8869 "Advertise own Router-LSA with infinite distance (stub router)\n"
8870 "Advertise stub-router prior to full shutdown of OSPF\n"
8871 "Time (seconds) to wait till full shutdown\n")
8874 unsigned int seconds
;
8875 struct ospf
*ospf
= vty
->index
;
8882 vty_out (vty
, "%% Must supply stub-router shutdown period");
8886 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
8888 ospf
->stub_router_shutdown_time
= seconds
;
8893 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8894 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8895 "no max-metric router-lsa on-shutdown [(5-100)]",
8897 "OSPF maximum / infinite-distance metric\n"
8898 "Advertise own Router-LSA with infinite distance (stub router)\n"
8899 "Advertise stub-router prior to full shutdown of OSPF\n"
8900 "Time (seconds) to wait till full shutdown\n")
8902 struct ospf
*ospf
= vty
->index
;
8907 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8913 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8915 struct listnode
*ln
;
8916 struct ospf_area
*area
;
8918 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8919 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8920 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8921 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8922 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8923 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8924 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8926 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8928 vty_out (vty
, " max-metric router-lsa administrative%s",
8937 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8939 struct route_node
*rn
;
8940 struct ospf_route
*or;
8941 struct listnode
*pnode
, *pnnode
;
8942 struct ospf_path
*path
;
8944 vty_out (vty
, "============ OSPF network routing table ============%s",
8947 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8948 if ((or = rn
->info
) != NULL
)
8951 snprintf (buf1
, 19, "%s/%d",
8952 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8954 switch (or->path_type
)
8956 case OSPF_PATH_INTER_AREA
:
8957 if (or->type
== OSPF_DESTINATION_NETWORK
)
8958 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8959 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8960 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8961 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8963 case OSPF_PATH_INTRA_AREA
:
8964 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8965 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8971 if (or->type
== OSPF_DESTINATION_NETWORK
)
8972 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8974 if (if_lookup_by_index(path
->ifindex
))
8976 if (path
->nexthop
.s_addr
== 0)
8977 vty_out (vty
, "%24s directly attached to %s%s",
8978 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8980 vty_out (vty
, "%24s via %s, %s%s", "",
8981 inet_ntoa (path
->nexthop
),
8982 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8986 vty_out (vty
, "%s", VTY_NEWLINE
);
8990 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
8992 struct route_node
*rn
;
8993 struct ospf_route
*or;
8994 struct listnode
*pnode
;
8995 struct listnode
*node
;
8996 struct ospf_path
*path
;
8998 vty_out (vty
, "============ OSPF router routing table =============%s",
9000 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
9005 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
9007 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
9010 vty_out (vty
, "%24s", "");
9013 vty_out (vty
, "%s [%d] area: %s",
9014 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
9015 or->cost
, inet_ntoa (or->u
.std
.area_id
));
9017 vty_out (vty
, "%s%s%s",
9018 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
9019 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
9022 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
9024 if (if_lookup_by_index(path
->ifindex
))
9026 if (path
->nexthop
.s_addr
== 0)
9027 vty_out (vty
, "%24s directly attached to %s%s",
9028 "", ifindex2ifname (path
->ifindex
),
9031 vty_out (vty
, "%24s via %s, %s%s", "",
9032 inet_ntoa (path
->nexthop
),
9033 ifindex2ifname (path
->ifindex
),
9039 vty_out (vty
, "%s", VTY_NEWLINE
);
9043 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
9045 struct route_node
*rn
;
9046 struct ospf_route
*er
;
9047 struct listnode
*pnode
, *pnnode
;
9048 struct ospf_path
*path
;
9050 vty_out (vty
, "============ OSPF external routing table ===========%s",
9052 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
9053 if ((er
= rn
->info
) != NULL
)
9056 snprintf (buf1
, 19, "%s/%d",
9057 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
9059 switch (er
->path_type
)
9061 case OSPF_PATH_TYPE1_EXTERNAL
:
9062 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
9063 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9065 case OSPF_PATH_TYPE2_EXTERNAL
:
9066 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
9067 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9071 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
9073 if (if_lookup_by_index(path
->ifindex
))
9075 if (path
->nexthop
.s_addr
== 0)
9076 vty_out (vty
, "%24s directly attached to %s%s",
9077 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9079 vty_out (vty
, "%24s via %s, %s%s", "",
9080 inet_ntoa (path
->nexthop
),
9081 ifindex2ifname (path
->ifindex
),
9086 vty_out (vty
, "%s", VTY_NEWLINE
);
9090 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
9093 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9094 VTY_NEWLINE
, VTY_NEWLINE
);
9096 if (ospf
->new_table
== NULL
)
9098 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9102 /* Show Network routes.
9103 show_ip_ospf_route_network (vty, ospf->new_table); */
9105 /* Show Router routes. */
9106 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9108 vty_out (vty
, "%s", VTY_NEWLINE
);
9113 DEFUN (show_ip_ospf_border_routers
,
9114 show_ip_ospf_border_routers_cmd
,
9115 "show ip ospf border-routers",
9118 "OSPF information\n"
9119 "Show all the ABR's and ASBR's\n")
9123 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9126 return show_ip_ospf_border_routers_common(vty
, ospf
);
9129 DEFUN (show_ip_ospf_instance_border_routers
,
9130 show_ip_ospf_instance_border_routers_cmd
,
9131 "show ip ospf (1-65535) border-routers",
9134 "OSPF information\n"
9136 "Show all the ABR's and ASBR's\n")
9140 u_short instance
= 0;
9142 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
9143 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9146 return show_ip_ospf_border_routers_common(vty
, ospf
);
9150 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
9153 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9154 VTY_NEWLINE
, VTY_NEWLINE
);
9156 if (ospf
->new_table
== NULL
)
9158 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9162 /* Show Network routes. */
9163 show_ip_ospf_route_network (vty
, ospf
->new_table
);
9165 /* Show Router routes. */
9166 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9168 /* Show AS External routes. */
9169 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
9171 vty_out (vty
, "%s", VTY_NEWLINE
);
9176 DEFUN (show_ip_ospf_route
,
9177 show_ip_ospf_route_cmd
,
9178 "show ip ospf route",
9181 "OSPF information\n"
9182 "OSPF routing table\n")
9186 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9189 return show_ip_ospf_route_common(vty
, ospf
);
9192 DEFUN (show_ip_ospf_instance_route
,
9193 show_ip_ospf_instance_route_cmd
,
9194 "show ip ospf (1-65535) route",
9197 "OSPF information\n"
9199 "OSPF routing table\n")
9203 u_short instance
= 0;
9205 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
9206 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9209 return show_ip_ospf_route_common(vty
, ospf
);
9212 const char *ospf_abr_type_str
[] =
9221 const char *ospf_shortcut_mode_str
[] =
9230 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
9232 memset (buf
, 0, length
);
9234 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9235 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
9237 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
9241 const char *ospf_int_type_str
[] =
9243 "unknown", /* should never be used. */
9247 "point-to-multipoint",
9248 "virtual-link", /* should never be used. */
9252 /* Configuration write function for ospfd. */
9254 config_write_interface (struct vty
*vty
)
9256 struct listnode
*n1
, *n2
;
9257 struct interface
*ifp
;
9258 struct crypt_key
*ck
;
9260 struct route_node
*rn
= NULL
;
9261 struct ospf_if_params
*params
;
9262 struct ospf
*ospf
= ospf_lookup();
9264 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
9266 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
9269 if (ifp
->ifindex
== IFINDEX_DELETED
)
9272 vty_out (vty
, "!%s", VTY_NEWLINE
);
9273 vty_out (vty
, "interface %s%s", ifp
->name
,
9276 vty_out (vty
, " description %s%s", ifp
->desc
,
9281 params
= IF_DEF_PARAMS (ifp
);
9284 /* Interface Network print. */
9285 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
9286 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
9288 if (params
->type
!= ospf_default_iftype(ifp
))
9290 vty_out (vty
, " ip ospf network %s",
9291 ospf_int_type_str
[params
->type
]);
9292 if (params
!= IF_DEF_PARAMS (ifp
))
9293 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9294 vty_out (vty
, "%s", VTY_NEWLINE
);
9298 /* OSPF interface authentication print */
9299 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
9300 params
->auth_type
!= OSPF_AUTH_NOTSET
)
9302 const char *auth_str
;
9304 /* Translation tables are not that much help here due to syntax
9305 of the simple option */
9306 switch (params
->auth_type
)
9309 case OSPF_AUTH_NULL
:
9313 case OSPF_AUTH_SIMPLE
:
9317 case OSPF_AUTH_CRYPTOGRAPHIC
:
9318 auth_str
= " message-digest";
9326 vty_out (vty
, " ip ospf authentication%s", auth_str
);
9327 if (params
!= IF_DEF_PARAMS (ifp
))
9328 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9329 vty_out (vty
, "%s", VTY_NEWLINE
);
9332 /* Simple Authentication Password print. */
9333 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
9334 params
->auth_simple
[0] != '\0')
9336 vty_out (vty
, " ip ospf authentication-key %s",
9337 params
->auth_simple
);
9338 if (params
!= IF_DEF_PARAMS (ifp
))
9339 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9340 vty_out (vty
, "%s", VTY_NEWLINE
);
9343 /* Cryptographic Authentication Key print. */
9344 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
9346 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
9347 ck
->key_id
, ck
->auth_key
);
9348 if (params
!= IF_DEF_PARAMS (ifp
))
9349 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9350 vty_out (vty
, "%s", VTY_NEWLINE
);
9353 /* Interface Output Cost print. */
9354 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
9356 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
9357 if (params
!= IF_DEF_PARAMS (ifp
))
9358 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9359 vty_out (vty
, "%s", VTY_NEWLINE
);
9362 /* Hello Interval print. */
9363 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
9364 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
9366 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
9367 if (params
!= IF_DEF_PARAMS (ifp
))
9368 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9369 vty_out (vty
, "%s", VTY_NEWLINE
);
9373 /* Router Dead Interval print. */
9374 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
9375 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
9377 vty_out (vty
, " ip ospf dead-interval ");
9380 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
9381 vty_out (vty
, "minimal hello-multiplier %d",
9382 params
->fast_hello
);
9384 vty_out (vty
, "%u", params
->v_wait
);
9386 if (params
!= IF_DEF_PARAMS (ifp
))
9387 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9388 vty_out (vty
, "%s", VTY_NEWLINE
);
9391 /* Router Priority print. */
9392 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
9393 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
9395 vty_out (vty
, " ip ospf priority %u", params
->priority
);
9396 if (params
!= IF_DEF_PARAMS (ifp
))
9397 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9398 vty_out (vty
, "%s", VTY_NEWLINE
);
9401 /* Retransmit Interval print. */
9402 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
9403 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
9405 vty_out (vty
, " ip ospf retransmit-interval %u",
9406 params
->retransmit_interval
);
9407 if (params
!= IF_DEF_PARAMS (ifp
))
9408 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9409 vty_out (vty
, "%s", VTY_NEWLINE
);
9412 /* Transmit Delay print. */
9413 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
9414 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
9416 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
9417 if (params
!= IF_DEF_PARAMS (ifp
))
9418 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9419 vty_out (vty
, "%s", VTY_NEWLINE
);
9423 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
9426 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
9427 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9429 vty_out (vty
, " ip ospf area %s%s",
9430 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9435 ospf_bfd_write_config(vty
, params
);
9437 /* MTU ignore print. */
9438 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
9439 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9441 if (params
->mtu_ignore
== 0)
9442 vty_out (vty
, " no ip ospf mtu-ignore");
9444 vty_out (vty
, " ip ospf mtu-ignore");
9445 if (params
!= IF_DEF_PARAMS (ifp
))
9446 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9447 vty_out (vty
, "%s", VTY_NEWLINE
);
9454 rn
= route_top (IF_OIFS_PARAMS (ifp
));
9456 rn
= route_next (rn
);
9466 ospf_opaque_config_write_if (vty
, ifp
);
9473 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
9475 struct route_node
*rn
;
9476 u_char buf
[INET_ADDRSTRLEN
];
9478 /* `network area' print. */
9479 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
9482 struct ospf_network
*n
= rn
->info
;
9484 memset (buf
, 0, INET_ADDRSTRLEN
);
9486 /* Create Area ID string by specified Area ID format. */
9487 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9488 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
9490 sprintf ((char *) buf
, "%lu",
9491 (unsigned long int) ntohl (n
->area_id
.s_addr
));
9493 /* Network print. */
9494 vty_out (vty
, " network %s/%d area %s%s",
9495 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9503 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
9505 struct listnode
*node
;
9506 struct ospf_area
*area
;
9507 u_char buf
[INET_ADDRSTRLEN
];
9509 /* Area configuration print. */
9510 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
9512 struct route_node
*rn1
;
9514 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
9516 if (area
->auth_type
!= OSPF_AUTH_NULL
)
9518 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9519 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
9521 vty_out (vty
, " area %s authentication message-digest%s",
9525 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9526 vty_out (vty
, " area %s shortcut %s%s", buf
,
9527 ospf_shortcut_mode_str
[area
->shortcut_configured
],
9530 if ((area
->external_routing
== OSPF_AREA_STUB
)
9531 || (area
->external_routing
== OSPF_AREA_NSSA
)
9534 if (area
->external_routing
== OSPF_AREA_STUB
)
9535 vty_out (vty
, " area %s stub", buf
);
9536 else if (area
->external_routing
== OSPF_AREA_NSSA
)
9538 vty_out (vty
, " area %s nssa", buf
);
9539 switch (area
->NSSATranslatorRole
)
9541 case OSPF_NSSA_ROLE_NEVER
:
9542 vty_out (vty
, " translate-never");
9544 case OSPF_NSSA_ROLE_ALWAYS
:
9545 vty_out (vty
, " translate-always");
9547 case OSPF_NSSA_ROLE_CANDIDATE
:
9549 vty_out (vty
, " translate-candidate");
9553 if (area
->no_summary
)
9554 vty_out (vty
, " no-summary");
9556 vty_out (vty
, "%s", VTY_NEWLINE
);
9558 if (area
->default_cost
!= 1)
9559 vty_out (vty
, " area %s default-cost %d%s", buf
,
9560 area
->default_cost
, VTY_NEWLINE
);
9563 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
9566 struct ospf_area_range
*range
= rn1
->info
;
9568 vty_out (vty
, " area %s range %s/%d", buf
,
9569 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
9571 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
9572 vty_out (vty
, " cost %d", range
->cost_config
);
9574 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
9575 vty_out (vty
, " not-advertise");
9577 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
9578 vty_out (vty
, " substitute %s/%d",
9579 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
9581 vty_out (vty
, "%s", VTY_NEWLINE
);
9584 if (EXPORT_NAME (area
))
9585 vty_out (vty
, " area %s export-list %s%s", buf
,
9586 EXPORT_NAME (area
), VTY_NEWLINE
);
9588 if (IMPORT_NAME (area
))
9589 vty_out (vty
, " area %s import-list %s%s", buf
,
9590 IMPORT_NAME (area
), VTY_NEWLINE
);
9592 if (PREFIX_NAME_IN (area
))
9593 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
9594 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
9596 if (PREFIX_NAME_OUT (area
))
9597 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
9598 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
9605 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
9607 struct ospf_nbr_nbma
*nbr_nbma
;
9608 struct route_node
*rn
;
9610 /* Static Neighbor configuration print. */
9611 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
9612 if ((nbr_nbma
= rn
->info
))
9614 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
9616 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9617 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
9619 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9620 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
9622 vty_out (vty
, "%s", VTY_NEWLINE
);
9629 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
9631 struct listnode
*node
;
9632 struct ospf_vl_data
*vl_data
;
9633 u_char buf
[INET_ADDRSTRLEN
];
9635 /* Virtual-Link print */
9636 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
9638 struct listnode
*n2
;
9639 struct crypt_key
*ck
;
9640 struct ospf_interface
*oi
;
9642 if (vl_data
!= NULL
)
9644 memset (buf
, 0, INET_ADDRSTRLEN
);
9646 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9647 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
9649 sprintf ((char *) buf
, "%lu",
9650 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
9651 oi
= vl_data
->vl_oi
;
9654 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
9655 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
9656 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
9657 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
9658 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9660 inet_ntoa (vl_data
->vl_peer
),
9661 OSPF_IF_PARAM (oi
, v_hello
),
9662 OSPF_IF_PARAM (oi
, retransmit_interval
),
9663 OSPF_IF_PARAM (oi
, transmit_delay
),
9664 OSPF_IF_PARAM (oi
, v_wait
),
9667 vty_out (vty
, " area %s virtual-link %s%s", buf
,
9668 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
9670 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
9671 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
9673 inet_ntoa (vl_data
->vl_peer
),
9674 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
9677 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
9679 vty_out (vty
, " area %s virtual-link %s"
9680 " message-digest-key %d md5 %s%s",
9682 inet_ntoa (vl_data
->vl_peer
),
9683 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
9693 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
9697 /* redistribute print. */
9698 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9700 struct list
*red_list
;
9701 struct listnode
*node
;
9702 struct ospf_redist
*red
;
9704 red_list
= ospf
->redist
[type
];
9708 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
9710 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
9712 vty_out (vty
, " %d", red
->instance
);
9714 if (red
->dmetric
.value
>= 0)
9715 vty_out (vty
, " metric %d", red
->dmetric
.value
);
9717 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9718 vty_out (vty
, " metric-type 1");
9720 if (ROUTEMAP_NAME (red
))
9721 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
9723 vty_out (vty
, "%s", VTY_NEWLINE
);
9731 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
9733 if (ospf
->default_metric
!= -1)
9734 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
9740 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
9743 struct ospf_redist
*red
;
9747 /* distribute-list print. */
9748 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9749 if (DISTRIBUTE_NAME (ospf
, type
))
9750 vty_out (vty
, " distribute-list %s out %s%s",
9751 DISTRIBUTE_NAME (ospf
, type
),
9752 zebra_route_string(type
), VTY_NEWLINE
);
9754 /* default-information print. */
9755 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
9757 vty_out (vty
, " default-information originate");
9758 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9759 vty_out (vty
, " always");
9761 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9764 if (red
->dmetric
.value
>= 0)
9765 vty_out (vty
, " metric %d",
9766 red
->dmetric
.value
);
9767 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9768 vty_out (vty
, " metric-type 1");
9770 if (ROUTEMAP_NAME (red
))
9771 vty_out (vty
, " route-map %s",
9772 ROUTEMAP_NAME (red
));
9775 vty_out (vty
, "%s", VTY_NEWLINE
);
9784 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9786 struct route_node
*rn
;
9787 struct ospf_distance
*odistance
;
9789 if (ospf
->distance_all
)
9790 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9792 if (ospf
->distance_intra
9793 || ospf
->distance_inter
9794 || ospf
->distance_external
)
9796 vty_out (vty
, " distance ospf");
9798 if (ospf
->distance_intra
)
9799 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9800 if (ospf
->distance_inter
)
9801 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9802 if (ospf
->distance_external
)
9803 vty_out (vty
, " external %d", ospf
->distance_external
);
9805 vty_out (vty
, "%s", VTY_NEWLINE
);
9808 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9809 if ((odistance
= rn
->info
) != NULL
)
9811 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9812 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9813 odistance
->access_list
? odistance
->access_list
: "",
9819 /* OSPF configuration write function. */
9821 ospf_config_write (struct vty
*vty
)
9824 struct interface
*ifp
;
9825 struct ospf_interface
*oi
;
9826 struct listnode
*node
;
9829 ospf
= ospf_lookup ();
9830 if (ospf
!= NULL
&& ospf
->oi_running
)
9832 /* `router ospf' print. */
9834 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9836 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9840 if (!ospf
->networks
)
9843 /* Router ID print. */
9844 if (ospf
->router_id_static
.s_addr
!= 0)
9845 vty_out (vty
, " ospf router-id %s%s",
9846 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9848 /* ABR type print. */
9849 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9850 vty_out (vty
, " ospf abr-type %s%s",
9851 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9853 /* log-adjacency-changes flag print. */
9854 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9856 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9857 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9861 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9864 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9865 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9866 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9868 /* auto-cost reference-bandwidth configuration. */
9869 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9871 vty_out (vty
, "! Important: ensure reference bandwidth "
9872 "is consistent across all routers%s", VTY_NEWLINE
);
9873 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9874 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9877 /* SPF timers print. */
9878 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9879 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9880 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9881 vty_out (vty
, " timers throttle spf %d %d %d%s",
9882 ospf
->spf_delay
, ospf
->spf_holdtime
,
9883 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9885 /* LSA timers print. */
9886 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9887 vty_out (vty
, " timers throttle lsa all %d%s",
9888 ospf
->min_ls_interval
, VTY_NEWLINE
);
9889 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9890 vty_out (vty
, " timers lsa min-arrival %d%s",
9891 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9893 /* Write multiplier print. */
9894 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9895 vty_out (vty
, " ospf write-multiplier %d%s",
9896 ospf
->write_oi_count
, VTY_NEWLINE
);
9898 /* Max-metric router-lsa print */
9899 config_write_stub_router (vty
, ospf
);
9901 /* SPF refresh parameters print. */
9902 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9903 vty_out (vty
, " refresh timer %d%s",
9904 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9906 /* Redistribute information print. */
9907 config_write_ospf_redistribute (vty
, ospf
);
9909 /* passive-interface print. */
9910 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9911 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9913 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9914 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9915 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9916 ospf
->passive_interface_default
)
9918 vty_out (vty
, " %spassive-interface %s%s",
9919 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9920 ifp
->name
, VTY_NEWLINE
);
9922 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9924 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9926 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9929 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9932 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9935 vty_out (vty
, " %spassive-interface %s %s%s",
9936 oi
->params
->passive_interface
? "" : "no ",
9938 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9941 /* Network area print. */
9942 config_write_network_area (vty
, ospf
);
9944 /* Area config print. */
9945 config_write_ospf_area (vty
, ospf
);
9947 /* static neighbor print. */
9948 config_write_ospf_nbr_nbma (vty
, ospf
);
9950 /* Virtual-Link print. */
9951 config_write_virtual_link (vty
, ospf
);
9953 /* Default metric configuration. */
9954 config_write_ospf_default_metric (vty
, ospf
);
9956 /* Distribute-list and default-information print. */
9957 config_write_ospf_distribute (vty
, ospf
);
9959 /* Distance configuration. */
9960 config_write_ospf_distance (vty
, ospf
);
9962 ospf_opaque_config_write_router (vty
, ospf
);
9969 ospf_vty_show_init (void)
9971 /* "show ip ospf" commands. */
9972 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9974 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9976 /* "show ip ospf database" commands. */
9977 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9978 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
9979 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9981 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
9982 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9983 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9985 /* "show ip ospf interface" commands. */
9986 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9988 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9990 /* "show ip ospf neighbor" commands. */
9991 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9992 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9993 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9994 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9995 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9996 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9997 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9999 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10000 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10001 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10002 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10003 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10004 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10005 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10007 /* "show ip ospf route" commands. */
10008 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
10009 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10011 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10012 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10016 /* ospfd's interface node. */
10017 static struct cmd_node interface_node
=
10024 /* Initialization of OSPF interface. */
10026 ospf_vty_if_init (void)
10028 /* Install interface node. */
10029 install_node (&interface_node
, config_write_interface
);
10031 install_element (CONFIG_NODE
, &interface_cmd
);
10032 install_element (CONFIG_NODE
, &no_interface_cmd
);
10033 install_default (INTERFACE_NODE
);
10035 /* "description" commands. */
10036 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
10037 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
10039 /* "ip ospf authentication" commands. */
10040 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10041 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10042 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
10043 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10044 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10045 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10046 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
10048 /* "ip ospf message-digest-key" commands. */
10049 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_addr_cmd
);
10050 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_addr_cmd
);
10051 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_addr_cmd
);
10052 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_addr_cmd
);
10054 /* "ip ospf cost" commands. */
10055 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_inet4_cmd
);
10056 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_cmd
);
10057 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_inet4_cmd
);
10058 install_element (INTERFACE_NODE
, &no_ospf_cost_inet4_cmd
);
10059 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_cmd
);
10061 /* "ip ospf mtu-ignore" commands. */
10062 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10063 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10065 /* "ip ospf dead-interval" commands. */
10066 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_addr_cmd
);
10067 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
10068 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_addr_cmd
);
10070 /* "ip ospf hello-interval" commands. */
10071 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_addr_cmd
);
10072 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_addr_cmd
);
10074 /* "ip ospf network" commands. */
10075 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
10076 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10077 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
10079 /* "ip ospf priority" commands. */
10080 install_element (INTERFACE_NODE
, &ip_ospf_priority_addr_cmd
);
10081 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_addr_cmd
);
10082 install_element (INTERFACE_NODE
, &no_ospf_priority_addr_cmd
);
10084 /* "ip ospf retransmit-interval" commands. */
10085 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10086 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
10087 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10089 /* "ip ospf transmit-delay" commands. */
10090 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10091 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10092 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_cmd
);
10093 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10095 /* "ip ospf area" commands. */
10096 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
10097 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10098 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_cmd
);
10100 /* These commands are compatibitliy for previous version. */
10101 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10102 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10103 install_element (INTERFACE_NODE
, &ospf_cost_u32_inet4_cmd
);
10104 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10105 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10106 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
10107 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
10108 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10109 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10113 ospf_vty_zebra_init (void)
10115 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
10116 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10117 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10118 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10120 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10121 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10123 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
10124 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10126 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
10127 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
10129 install_element (OSPF_NODE
, &ospf_distance_cmd
);
10130 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
10131 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10132 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
10134 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10135 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10136 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10137 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10141 static struct cmd_node ospf_node
=
10144 "%s(config-router)# ",
10149 ospf_interface_clear (struct interface
*ifp
)
10151 if (!if_is_operative (ifp
)) return;
10153 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
10154 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
10156 ospf_if_reset(ifp
);
10159 DEFUN (clear_ip_ospf_interface
,
10160 clear_ip_ospf_interface_cmd
,
10161 "clear ip ospf interface [IFNAME]",
10164 "OSPF information\n"
10165 "Interface information\n"
10166 "Interface name\n")
10168 int idx_ifname
= 4;
10169 struct interface
*ifp
;
10170 struct listnode
*node
;
10172 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
10174 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
10175 ospf_interface_clear(ifp
);
10177 else /* Interface name is specified. */
10179 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
10180 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
10182 ospf_interface_clear(ifp
);
10185 return CMD_SUCCESS
;
10189 ospf_vty_clear_init (void)
10191 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10195 /* Install OSPF related vty commands. */
10197 ospf_vty_init (void)
10199 /* Install ospf top node. */
10200 install_node (&ospf_node
, ospf_config_write
);
10202 /* "router ospf" commands. */
10203 install_element (CONFIG_NODE
, &router_ospf_cmd
);
10204 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
10207 install_default (OSPF_NODE
);
10209 /* "ospf router-id" commands. */
10210 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
10211 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
10212 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
10214 /* "passive-interface" commands. */
10215 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10216 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10218 /* "ospf abr-type" commands. */
10219 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
10220 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
10222 /* "ospf log-adjacency-changes" commands. */
10223 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10224 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10225 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10226 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10228 /* "ospf rfc1583-compatible" commands. */
10229 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10230 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10231 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10232 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10234 /* "network area" commands. */
10235 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
10236 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
10238 /* "area authentication" commands. */
10239 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
10240 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
10241 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10243 /* "area range" commands. */
10244 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
10245 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
10246 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10247 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
10248 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10249 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10251 /* "area virtual-link" commands. */
10252 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
10253 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
10254 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10255 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
10266 /* "area stub" commands. */
10267 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10268 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
10269 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10270 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
10272 /* "area nssa" commands. */
10273 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
10274 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
10275 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10276 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10277 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10279 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
10280 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10282 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
10283 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10285 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
10286 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10288 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
10289 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10291 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
10292 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10294 /* SPF timer commands */
10295 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10296 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10298 /* LSA timers commands */
10299 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10300 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10301 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
10302 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
10303 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
10304 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
10306 /* refresh timer commands */
10307 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
10308 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10310 /* max-metric commands */
10311 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10312 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10313 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10314 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10315 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10316 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10318 /* reference bandwidth commands */
10319 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10320 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10322 /* "neighbor" commands. */
10323 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
10324 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10325 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
10326 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
10328 /* write multiplier commands */
10329 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
10330 install_element (OSPF_NODE
, &write_multiplier_cmd
);
10331 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10332 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
10334 /* Init interface related vty commands. */
10335 ospf_vty_if_init ();
10337 /* Init zebra related vty commands. */
10338 ospf_vty_zebra_init ();