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 (oi
->type
== OSPF_IFTYPE_NBMA
&& 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")
5806 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5809 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5812 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5813 show_ip_ospf_instance_database_type_adv_router_cmd
,
5814 "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>",
5817 "OSPF information\n"
5819 "Database summary\n"
5821 "Advertising Router link states\n"
5822 "Advertising Router (as an IP address)\n")
5826 u_short instance
= 0;
5828 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5830 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5833 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5836 DEFUN (ip_ospf_authentication_args
,
5837 ip_ospf_authentication_args_addr_cmd
,
5838 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5840 "OSPF interface commands\n"
5841 "Enable authentication on this interface\n"
5842 "Use null authentication\n"
5843 "Use message-digest authentication\n"
5844 "Address of interface\n")
5846 int idx_encryption
= 3;
5848 struct interface
*ifp
;
5849 struct in_addr addr
;
5851 struct ospf_if_params
*params
;
5854 params
= IF_DEF_PARAMS (ifp
);
5858 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5861 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5866 params
= ospf_get_if_params (ifp
, addr
);
5867 ospf_if_update_params (ifp
, addr
);
5870 /* Handle null authentication */
5871 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5873 SET_IF_PARAM (params
, auth_type
);
5874 params
->auth_type
= OSPF_AUTH_NULL
;
5878 /* Handle message-digest authentication */
5879 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5881 SET_IF_PARAM (params
, auth_type
);
5882 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5886 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5890 DEFUN (ip_ospf_authentication
,
5891 ip_ospf_authentication_addr_cmd
,
5892 "ip ospf authentication [A.B.C.D]",
5894 "OSPF interface commands\n"
5895 "Enable authentication on this interface\n"
5896 "Address of interface")
5899 struct interface
*ifp
;
5900 struct in_addr addr
;
5902 struct ospf_if_params
*params
;
5905 params
= IF_DEF_PARAMS (ifp
);
5909 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5912 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5917 params
= ospf_get_if_params (ifp
, addr
);
5918 ospf_if_update_params (ifp
, addr
);
5921 SET_IF_PARAM (params
, auth_type
);
5922 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5927 DEFUN (no_ip_ospf_authentication_args
,
5928 no_ip_ospf_authentication_args_addr_cmd
,
5929 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5932 "OSPF interface commands\n"
5933 "Enable authentication on this interface\n"
5934 "Use null authentication\n"
5935 "Use message-digest authentication\n"
5936 "Address of interface")
5938 int idx_encryption
= 4;
5940 struct interface
*ifp
;
5941 struct in_addr addr
;
5943 struct ospf_if_params
*params
;
5944 struct route_node
*rn
;
5948 params
= IF_DEF_PARAMS (ifp
);
5952 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5955 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5960 params
= ospf_lookup_if_params (ifp
, addr
);
5963 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5966 params
->auth_type
= OSPF_AUTH_NOTSET
;
5967 UNSET_IF_PARAM (params
, auth_type
);
5968 if (params
!= IF_DEF_PARAMS (ifp
))
5970 ospf_free_if_params (ifp
, addr
);
5971 ospf_if_update_params (ifp
, addr
);
5976 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5978 auth_type
= OSPF_AUTH_NULL
;
5980 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5982 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5986 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5990 * Here we have a case where the user has entered
5991 * 'no ip ospf authentication (null | message_digest )'
5992 * we need to find if we have any ip addresses underneath it that
5993 * correspond to the associated type.
5995 if (params
->auth_type
== auth_type
)
5997 params
->auth_type
= OSPF_AUTH_NOTSET
;
5998 UNSET_IF_PARAM (params
, auth_type
);
6001 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6003 if ((params
= rn
->info
))
6005 if (params
->auth_type
== auth_type
)
6007 params
->auth_type
= OSPF_AUTH_NOTSET
;
6008 UNSET_IF_PARAM (params
, auth_type
);
6009 if (params
!= IF_DEF_PARAMS (ifp
))
6011 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6012 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6022 DEFUN (no_ip_ospf_authentication
,
6023 no_ip_ospf_authentication_addr_cmd
,
6024 "no ip ospf authentication [A.B.C.D]",
6027 "OSPF interface commands\n"
6028 "Enable authentication on this interface\n"
6029 "Address of interface")
6032 struct interface
*ifp
;
6033 struct in_addr addr
;
6035 struct ospf_if_params
*params
;
6036 struct route_node
*rn
;
6039 params
= IF_DEF_PARAMS (ifp
);
6043 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6046 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6051 params
= ospf_lookup_if_params (ifp
, addr
);
6054 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6058 params
->auth_type
= OSPF_AUTH_NOTSET
;
6059 UNSET_IF_PARAM (params
, auth_type
);
6060 if (params
!= IF_DEF_PARAMS (ifp
))
6062 ospf_free_if_params (ifp
, addr
);
6063 ospf_if_update_params (ifp
, addr
);
6069 * When a user enters 'no ip ospf authentication'
6070 * We should remove all authentication types from
6073 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6074 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6075 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6077 params
->auth_type
= OSPF_AUTH_NOTSET
;
6078 UNSET_IF_PARAM (params
, auth_type
);
6081 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6083 if ((params
= rn
->info
))
6086 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6087 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6088 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6090 params
->auth_type
= OSPF_AUTH_NOTSET
;
6091 UNSET_IF_PARAM (params
, auth_type
);
6092 if (params
!= IF_DEF_PARAMS (ifp
))
6094 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6095 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6105 DEFUN (ip_ospf_authentication_key
,
6106 ip_ospf_authentication_key_addr_cmd
,
6107 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6109 "OSPF interface commands\n"
6110 "Authentication password (key)\n"
6111 "The OSPF password (key)\n"
6112 "Address of interface")
6115 struct interface
*ifp
;
6116 struct in_addr addr
;
6118 struct ospf_if_params
*params
;
6121 params
= IF_DEF_PARAMS (ifp
);
6125 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6128 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6133 params
= ospf_get_if_params (ifp
, addr
);
6134 ospf_if_update_params (ifp
, addr
);
6137 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6138 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6139 SET_IF_PARAM (params
, auth_simple
);
6145 DEFUN_HIDDEN (ospf_authentication_key
,
6146 ospf_authentication_key_cmd
,
6147 "ospf authentication-key AUTH_KEY",
6148 "OSPF interface commands\n"
6149 "Authentication password (key)\n"
6150 "The OSPF password (key)")
6152 struct interface
*ifp
;
6153 struct ospf_if_params
*params
;
6156 params
= IF_DEF_PARAMS (ifp
);
6157 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6158 strncpy ((char *) params
->auth_simple
, argv
[2]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6159 SET_IF_PARAM (params
, auth_simple
);
6164 DEFUN (no_ospf_authentication_key
,
6165 no_ospf_authentication_key_authkey_addr_cmd
,
6166 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6168 "OSPF interface commands\n"
6169 "Authentication password (key)\n"
6170 "The OSPF password (key)")
6172 struct interface
*ifp
;
6173 struct in_addr addr
;
6174 struct ospf_if_params
*params
;
6178 params
= IF_DEF_PARAMS (ifp
);
6182 ret
= inet_aton(argv
[4]->arg
, &addr
);
6185 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6190 params
= ospf_lookup_if_params (ifp
, addr
);
6195 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6196 UNSET_IF_PARAM (params
, auth_simple
);
6198 if (params
!= IF_DEF_PARAMS (ifp
))
6200 ospf_free_if_params (ifp
, addr
);
6201 ospf_if_update_params (ifp
, addr
);
6207 DEFUN (no_ip_ospf_authentication_key
,
6208 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6209 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6212 "OSPF interface commands\n"
6213 "Authentication password (key)\n"
6214 "The OSPF password (key)")
6216 struct interface
*ifp
;
6217 struct in_addr addr
;
6218 struct ospf_if_params
*params
;
6222 params
= IF_DEF_PARAMS (ifp
);
6226 ret
= inet_aton(argv
[5]->arg
, &addr
);
6229 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6234 params
= ospf_lookup_if_params (ifp
, addr
);
6239 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6240 UNSET_IF_PARAM (params
, auth_simple
);
6242 if (params
!= IF_DEF_PARAMS (ifp
))
6244 ospf_free_if_params (ifp
, addr
);
6245 ospf_if_update_params (ifp
, addr
);
6251 DEFUN (ip_ospf_message_digest_key
,
6252 ip_ospf_message_digest_key_addr_cmd
,
6253 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6255 "OSPF interface commands\n"
6256 "Message digest authentication password (key)\n"
6258 "Use MD5 algorithm\n"
6259 "The OSPF password (key)"
6260 "Address of interface")
6264 struct interface
*ifp
;
6265 struct crypt_key
*ck
;
6267 struct in_addr addr
;
6269 struct ospf_if_params
*params
;
6272 params
= IF_DEF_PARAMS (ifp
);
6276 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6279 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6284 params
= ospf_get_if_params (ifp
, addr
);
6285 ospf_if_update_params (ifp
, addr
);
6288 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6289 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6291 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6295 ck
= ospf_crypt_key_new ();
6296 ck
->key_id
= (u_char
) key_id
;
6297 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6298 strncpy ((char *) ck
->auth_key
, argv
[idx_ipv4
]->arg
, OSPF_AUTH_MD5_SIZE
);
6300 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6301 SET_IF_PARAM (params
, auth_crypt
);
6307 DEFUN_HIDDEN (ospf_message_digest_key
,
6308 ospf_message_digest_key_cmd
,
6309 "ospf message-digest-key (1-255) md5 KEY",
6310 "OSPF interface commands\n"
6311 "Message digest authentication password (key)\n"
6313 "Use MD5 algorithm\n"
6314 "The OSPF password (key)")
6317 struct interface
*ifp
;
6318 struct crypt_key
*ck
;
6320 struct ospf_if_params
*params
;
6323 params
= IF_DEF_PARAMS (ifp
);
6324 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6325 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6327 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6331 ck
= ospf_crypt_key_new ();
6332 ck
->key_id
= (u_char
) key_id
;
6333 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6334 strncpy ((char *) ck
->auth_key
, argv
[idx_number
]->arg
, OSPF_AUTH_MD5_SIZE
);
6336 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6337 SET_IF_PARAM (params
, auth_crypt
);
6342 DEFUN (no_ip_ospf_message_digest_key_md5
,
6343 no_ip_ospf_message_digest_key_md5_addr_cmd
,
6344 "no ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6347 "OSPF interface commands\n"
6348 "Message digest authentication password (key)\n"
6350 "Use MD5 algorithm\n"
6351 "The OSPF password (key)"
6352 "Address of interface")
6355 struct interface
*ifp
;
6356 struct crypt_key
*ck
;
6358 struct in_addr addr
;
6360 struct ospf_if_params
*params
;
6363 params
= IF_DEF_PARAMS (ifp
);
6367 ret
= inet_aton(argv
[7]->arg
, &addr
);
6370 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6375 params
= ospf_lookup_if_params (ifp
, addr
);
6380 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6381 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6384 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6388 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6390 if (params
!= IF_DEF_PARAMS (ifp
))
6392 ospf_free_if_params (ifp
, addr
);
6393 ospf_if_update_params (ifp
, addr
);
6399 DEFUN (no_ospf_message_digest_key
,
6400 no_ospf_message_digest_key_addr_cmd
,
6401 "no ospf message-digest-key (1-255) [A.B.C.D]",
6403 "OSPF interface commands\n"
6404 "Message digest authentication password (key)\n"
6406 "Address of interface")
6410 struct interface
*ifp
;
6411 struct crypt_key
*ck
;
6413 struct in_addr addr
;
6415 struct ospf_if_params
*params
;
6418 params
= IF_DEF_PARAMS (ifp
);
6422 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6425 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6430 params
= ospf_lookup_if_params (ifp
, addr
);
6435 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6436 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6439 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6443 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6445 if (params
!= IF_DEF_PARAMS (ifp
))
6447 ospf_free_if_params (ifp
, addr
);
6448 ospf_if_update_params (ifp
, addr
);
6454 DEFUN (no_ip_ospf_message_digest_key
,
6455 no_ip_ospf_message_digest_key_addr_cmd
,
6456 "no ip ospf message-digest-key (1-255) [A.B.C.D]",
6459 "OSPF interface commands\n"
6460 "Message digest authentication password (key)\n"
6462 "Address of interface")
6466 struct interface
*ifp
;
6467 struct crypt_key
*ck
;
6469 struct in_addr addr
;
6471 struct ospf_if_params
*params
;
6474 params
= IF_DEF_PARAMS (ifp
);
6478 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6481 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6486 params
= ospf_lookup_if_params (ifp
, addr
);
6491 key_id
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6492 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6495 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6499 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6501 if (params
!= IF_DEF_PARAMS (ifp
))
6503 ospf_free_if_params (ifp
, addr
);
6504 ospf_if_update_params (ifp
, addr
);
6510 DEFUN (ip_ospf_cost
,
6511 ip_ospf_cost_u32_inet4_cmd
,
6512 "ip ospf cost (1-65535) [A.B.C.D]",
6514 "OSPF interface commands\n"
6517 "Address of interface")
6521 struct interface
*ifp
= vty
->index
;
6523 struct in_addr addr
;
6525 struct ospf_if_params
*params
;
6527 params
= IF_DEF_PARAMS (ifp
);
6529 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6531 /* cost range is <1-65535>. */
6532 if (cost
< 1 || cost
> 65535)
6534 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6540 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6543 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6548 params
= ospf_get_if_params (ifp
, addr
);
6549 ospf_if_update_params (ifp
, addr
);
6552 SET_IF_PARAM (params
, output_cost_cmd
);
6553 params
->output_cost_cmd
= cost
;
6555 ospf_if_recalculate_output_cost (ifp
);
6560 DEFUN_HIDDEN (ospf_cost
,
6561 ospf_cost_u32_inet4_cmd
,
6562 "ospf cost (1-65535) A.B.C.D",
6563 "OSPF interface commands\n"
6566 "Address of interface")
6570 struct interface
*ifp
= vty
->index
;
6572 struct in_addr addr
;
6574 struct ospf_if_params
*params
;
6576 params
= IF_DEF_PARAMS (ifp
);
6578 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6580 /* cost range is <1-65535>. */
6581 if (cost
< 1 || cost
> 65535)
6583 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6589 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6592 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6597 params
= ospf_get_if_params (ifp
, addr
);
6598 ospf_if_update_params (ifp
, addr
);
6601 SET_IF_PARAM (params
, output_cost_cmd
);
6602 params
->output_cost_cmd
= cost
;
6604 ospf_if_recalculate_output_cost (ifp
);
6609 DEFUN (no_ospf_cost
,
6610 no_ospf_cost_inet4_cmd
,
6611 "no ospf cost [A.B.C.D]",
6613 "OSPF interface commands\n"
6615 "Address of interface")
6618 struct interface
*ifp
= vty
->index
;
6619 struct in_addr addr
;
6621 struct ospf_if_params
*params
;
6624 params
= IF_DEF_PARAMS (ifp
);
6628 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6631 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6636 params
= ospf_lookup_if_params (ifp
, addr
);
6641 UNSET_IF_PARAM (params
, output_cost_cmd
);
6643 if (params
!= IF_DEF_PARAMS (ifp
))
6645 ospf_free_if_params (ifp
, addr
);
6646 ospf_if_update_params (ifp
, addr
);
6649 ospf_if_recalculate_output_cost (ifp
);
6654 DEFUN (no_ip_ospf_cost
,
6655 no_ip_ospf_cost_inet4_cmd
,
6656 "no ip ospf cost [A.B.C.D]",
6659 "OSPF interface commands\n"
6661 "Address of interface")
6664 struct interface
*ifp
= vty
->index
;
6665 struct in_addr addr
;
6667 struct ospf_if_params
*params
;
6670 params
= IF_DEF_PARAMS (ifp
);
6674 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6677 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6682 params
= ospf_lookup_if_params (ifp
, addr
);
6687 UNSET_IF_PARAM (params
, output_cost_cmd
);
6689 if (params
!= IF_DEF_PARAMS (ifp
))
6691 ospf_free_if_params (ifp
, addr
);
6692 ospf_if_update_params (ifp
, addr
);
6695 ospf_if_recalculate_output_cost (ifp
);
6700 DEFUN (no_ospf_cost2
,
6701 no_ospf_cost_u32_cmd
,
6702 "no ospf cost [(1-65535) [A.B.C.D]]",
6704 "OSPF interface commands\n"
6707 "Address of interface\n")
6711 struct interface
*ifp
= vty
->index
;
6712 struct in_addr addr
;
6715 struct ospf_if_params
*params
;
6718 params
= IF_DEF_PARAMS (ifp
);
6720 /* According to the semantics we are mimicking "no ip ospf cost N" is
6721 * always treated as "no ip ospf cost" regardless of the actual value
6722 * of N already configured for the interface. Thus the first argument
6723 * is always checked to be a number, but is ignored after that.
6725 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6726 if (cost
< 1 || cost
> 65535)
6728 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6734 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6737 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6742 params
= ospf_lookup_if_params (ifp
, addr
);
6747 UNSET_IF_PARAM (params
, output_cost_cmd
);
6749 if (params
!= IF_DEF_PARAMS (ifp
))
6751 ospf_free_if_params (ifp
, addr
);
6752 ospf_if_update_params (ifp
, addr
);
6755 ospf_if_recalculate_output_cost (ifp
);
6760 DEFUN (no_ip_ospf_cost2
,
6761 no_ip_ospf_cost_u32_cmd
,
6762 "no ip ospf cost (1-65535) [A.B.C.D]",
6765 "OSPF interface commands\n"
6768 "Address of interface\n")
6772 struct interface
*ifp
= vty
->index
;
6773 struct in_addr addr
;
6776 struct ospf_if_params
*params
;
6779 params
= IF_DEF_PARAMS (ifp
);
6781 /* According to the semantics we are mimicking "no ip ospf cost N" is
6782 * always treated as "no ip ospf cost" regardless of the actual value
6783 * of N already configured for the interface. Thus the first argument
6784 * is always checked to be a number, but is ignored after that.
6786 cost
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
6787 if (cost
< 1 || cost
> 65535)
6789 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6795 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6798 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6803 params
= ospf_lookup_if_params (ifp
, addr
);
6808 UNSET_IF_PARAM (params
, output_cost_cmd
);
6810 if (params
!= IF_DEF_PARAMS (ifp
))
6812 ospf_free_if_params (ifp
, addr
);
6813 ospf_if_update_params (ifp
, addr
);
6816 ospf_if_recalculate_output_cost (ifp
);
6825 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6827 struct route_node
*rn
;
6828 struct ospf_neighbor
*nbr
;
6830 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6831 if ((nbr
= rn
->info
))
6833 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6834 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6835 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6836 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6841 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6842 const char *nbr_str
,
6843 const char *fast_hello_str
)
6845 struct interface
*ifp
= vty
->index
;
6848 struct in_addr addr
;
6850 struct ospf_if_params
*params
;
6851 struct ospf_interface
*oi
;
6852 struct route_node
*rn
;
6854 params
= IF_DEF_PARAMS (ifp
);
6858 ret
= inet_aton(nbr_str
, &addr
);
6861 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6866 params
= ospf_get_if_params (ifp
, addr
);
6867 ospf_if_update_params (ifp
, addr
);
6872 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6875 /* reset fast_hello too, just to be sure */
6876 UNSET_IF_PARAM (params
, fast_hello
);
6877 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6879 else if (fast_hello_str
)
6881 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6883 /* 1s dead-interval with sub-second hellos desired */
6884 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6885 SET_IF_PARAM (params
, fast_hello
);
6886 params
->fast_hello
= hellomult
;
6890 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6895 SET_IF_PARAM (params
, v_wait
);
6896 params
->v_wait
= seconds
;
6898 /* Update timer values in neighbor structure. */
6902 if ((ospf
= ospf_lookup()))
6904 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6906 ospf_nbr_timer_update (oi
);
6911 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6912 if ((oi
= rn
->info
))
6913 ospf_nbr_timer_update (oi
);
6919 DEFUN (ip_ospf_dead_interval
,
6920 ip_ospf_dead_interval_addr_cmd
,
6921 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6923 "OSPF interface commands\n"
6924 "Interval after which a neighbor is declared dead\n"
6926 "Address of interface\n")
6931 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, argv
[idx_ipv4
]->arg
, NULL
);
6933 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, NULL
, NULL
);
6937 DEFUN_HIDDEN (ospf_dead_interval
,
6938 ospf_dead_interval_cmd
,
6939 "ospf dead-interval (1-65535)",
6940 "OSPF interface commands\n"
6941 "Interval after which a neighbor is declared dead\n"
6946 return ospf_vty_dead_interval_set (vty
, argv
[idx_number
]->arg
, NULL
, NULL
);
6949 DEFUN (ip_ospf_dead_interval_minimal
,
6950 ip_ospf_dead_interval_minimal_addr_cmd
,
6951 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6953 "OSPF interface commands\n"
6954 "Interval after which a neighbor is declared dead\n"
6955 "Minimal 1s dead-interval with fast sub-second hellos\n"
6956 "Hello multiplier factor\n"
6957 "Number of Hellos to send each second\n"
6958 "Address of interface\n")
6963 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6965 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6968 DEFUN (no_ospf_dead_interval
,
6969 no_ospf_dead_interval_cmd
,
6970 "no ospf dead-interval",
6972 "OSPF interface commands\n"
6973 "Interval after which a neighbor is declared dead\n")
6975 struct interface
*ifp
= vty
->index
;
6976 struct ospf_if_params
*params
;
6979 params
= IF_DEF_PARAMS (ifp
);
6981 UNSET_IF_PARAM (params
, v_wait
);
6982 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6984 UNSET_IF_PARAM (params
, fast_hello
);
6985 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6990 DEFUN (no_ip_ospf_dead_interval
,
6991 no_ip_ospf_dead_interval_addr_cmd
,
6992 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6995 "OSPF interface commands\n"
6996 "Interval after which a neighbor is declared dead\n"
6998 "Address of interface")
7000 int idx_ipv4
= argc
- 1;
7001 struct interface
*ifp
= vty
->index
;
7002 struct in_addr addr
;
7004 struct ospf_if_params
*params
;
7005 struct ospf_interface
*oi
;
7006 struct route_node
*rn
;
7009 params
= IF_DEF_PARAMS (ifp
);
7011 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
7013 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7016 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7021 params
= ospf_lookup_if_params (ifp
, addr
);
7026 UNSET_IF_PARAM (params
, v_wait
);
7027 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7029 UNSET_IF_PARAM (params
, fast_hello
);
7030 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7032 if (params
!= IF_DEF_PARAMS (ifp
))
7034 ospf_free_if_params (ifp
, addr
);
7035 ospf_if_update_params (ifp
, addr
);
7038 /* Update timer values in neighbor structure. */
7043 if ((ospf
= ospf_lookup()))
7045 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
7047 ospf_nbr_timer_update (oi
);
7052 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7053 if ((oi
= rn
->info
))
7054 ospf_nbr_timer_update (oi
);
7060 DEFUN (ip_ospf_hello_interval
,
7061 ip_ospf_hello_interval_addr_cmd
,
7062 "ip ospf hello-interval (1-65535) [A.B.C.D]",
7064 "OSPF interface commands\n"
7065 "Time between HELLO packets\n"
7067 "Address of interface")
7071 struct interface
*ifp
= vty
->index
;
7073 struct in_addr addr
;
7075 struct ospf_if_params
*params
;
7077 params
= IF_DEF_PARAMS (ifp
);
7079 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7081 /* HelloInterval range is <1-65535>. */
7082 if (seconds
< 1 || seconds
> 65535)
7084 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7090 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7093 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7098 params
= ospf_get_if_params (ifp
, addr
);
7099 ospf_if_update_params (ifp
, addr
);
7102 SET_IF_PARAM (params
, v_hello
);
7103 params
->v_hello
= seconds
;
7109 DEFUN_HIDDEN (ospf_hello_interval
,
7110 ospf_hello_interval_cmd
,
7111 "ospf hello-interval (1-65535)",
7112 "OSPF interface commands\n"
7113 "Time between HELLO packets\n"
7117 struct interface
*ifp
= vty
->index
;
7119 struct ospf_if_params
*params
;
7121 params
= IF_DEF_PARAMS (ifp
);
7123 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7125 /* HelloInterval range is <1-65535>. */
7126 if (seconds
< 1 || seconds
> 65535)
7128 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7132 SET_IF_PARAM (params
, v_hello
);
7133 params
->v_hello
= seconds
;
7138 DEFUN (no_ip_ospf_hello_interval
,
7139 no_ip_ospf_hello_interval_addr_cmd
,
7140 "no [ip] ospf hello-interval [(1-65535) [A.B.C.D]]",
7143 "OSPF interface commands\n"
7144 "Time between HELLO packets\n"
7146 "Address of interface")
7149 struct interface
*ifp
= vty
->index
;
7150 struct in_addr addr
;
7152 struct ospf_if_params
*params
;
7155 params
= IF_DEF_PARAMS (ifp
);
7157 if (strcmp (argv
[1]->arg
, "ip") == 0)
7160 if (argc
== idx_ipv4
+1)
7162 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7165 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7170 params
= ospf_lookup_if_params (ifp
, addr
);
7175 UNSET_IF_PARAM (params
, v_hello
);
7176 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7178 if (params
!= IF_DEF_PARAMS (ifp
))
7180 ospf_free_if_params (ifp
, addr
);
7181 ospf_if_update_params (ifp
, addr
);
7190 DEFUN (ip_ospf_network
,
7191 ip_ospf_network_cmd
,
7192 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7194 "OSPF interface commands\n"
7196 "Specify OSPF broadcast multi-access network\n"
7197 "Specify OSPF NBMA network\n"
7198 "Specify OSPF point-to-multipoint network\n"
7199 "Specify OSPF point-to-point network\n")
7201 int idx_network
= 3;
7202 struct interface
*ifp
= vty
->index
;
7203 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7204 struct route_node
*rn
;
7206 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7208 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7212 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
7213 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7214 else if (strncmp (argv
[idx_network
]->arg
, "n", 1) == 0)
7215 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7216 else if (strncmp (argv
[idx_network
]->arg
, "point-to-m", 10) == 0)
7217 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7218 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
7219 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7221 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7224 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7226 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7228 struct ospf_interface
*oi
= rn
->info
;
7233 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7235 if (oi
->state
> ISM_Down
)
7237 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7238 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7245 DEFUN_HIDDEN (ospf_network
,
7247 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7248 "OSPF interface commands\n"
7250 "Specify OSPF broadcast multi-access network\n"
7251 "Specify OSPF NBMA network\n"
7252 "Specify OSPF point-to-multipoint network\n"
7253 "Specify OSPF point-to-point network\n")
7255 int idx_network
= 2;
7256 struct interface
*ifp
= vty
->index
;
7257 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7258 struct route_node
*rn
;
7260 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7262 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7266 if (strncmp (argv
[idx_network
]->arg
, "b", 1) == 0)
7267 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7268 else if (strncmp (argv
[idx_network
]->arg
, "n", 1) == 0)
7269 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7270 else if (strncmp (argv
[idx_network
]->arg
, "point-to-m", 10) == 0)
7271 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7272 else if (strncmp (argv
[idx_network
]->arg
, "point-to-p", 10) == 0)
7273 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7275 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7278 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7280 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7282 struct ospf_interface
*oi
= rn
->info
;
7287 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7289 if (oi
->state
> ISM_Down
)
7291 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7292 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7299 DEFUN (no_ospf_network
,
7300 no_ospf_network_cmd
,
7301 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7303 "OSPF interface commands\n"
7305 "Specify OSPF broadcast multi-access network\n"
7306 "Specify OSPF NBMA network\n"
7307 "Specify OSPF point-to-multipoint network\n"
7308 "Specify OSPF point-to-point network\n")
7310 struct interface
*ifp
= vty
->index
;
7311 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7312 struct route_node
*rn
;
7314 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7316 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7319 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7321 struct ospf_interface
*oi
= rn
->info
;
7326 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7328 if (oi
->state
> ISM_Down
)
7330 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7331 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7338 DEFUN (no_ip_ospf_network
,
7339 no_ip_ospf_network_cmd
,
7340 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7343 "OSPF interface commands\n"
7345 "Specify OSPF broadcast multi-access network\n"
7346 "Specify OSPF NBMA network\n"
7347 "Specify OSPF point-to-multipoint network\n"
7348 "Specify OSPF point-to-point network\n")
7350 struct interface
*ifp
= vty
->index
;
7351 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7352 struct route_node
*rn
;
7354 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7356 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7359 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7361 struct ospf_interface
*oi
= rn
->info
;
7366 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7368 if (oi
->state
> ISM_Down
)
7370 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7371 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7378 DEFUN (ip_ospf_priority
,
7379 ip_ospf_priority_addr_cmd
,
7380 "ip ospf priority (0-255) [A.B.C.D]",
7382 "OSPF interface commands\n"
7385 "Address of interface")
7389 struct interface
*ifp
= vty
->index
;
7391 struct route_node
*rn
;
7392 struct in_addr addr
;
7394 struct ospf_if_params
*params
;
7396 params
= IF_DEF_PARAMS (ifp
);
7398 priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7400 /* Router Priority range is <0-255>. */
7401 if (priority
< 0 || priority
> 255)
7403 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7409 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7412 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7417 params
= ospf_get_if_params (ifp
, addr
);
7418 ospf_if_update_params (ifp
, addr
);
7421 SET_IF_PARAM (params
, priority
);
7422 params
->priority
= priority
;
7424 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7426 struct ospf_interface
*oi
= rn
->info
;
7431 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7433 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7434 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7442 DEFUN_HIDDEN (ospf_priority
,
7444 "ospf priority (0-255)",
7445 "OSPF interface commands\n"
7450 struct interface
*ifp
= vty
->index
;
7452 struct route_node
*rn
;
7453 struct ospf_if_params
*params
;
7455 params
= IF_DEF_PARAMS (ifp
);
7457 priority
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7459 /* Router Priority range is <0-255>. */
7460 if (priority
< 0 || priority
> 255)
7462 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7466 SET_IF_PARAM (params
, priority
);
7467 params
->priority
= priority
;
7469 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7471 struct ospf_interface
*oi
= rn
->info
;
7477 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7479 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7480 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7487 DEFUN (no_ospf_priority
,
7488 no_ospf_priority_addr_cmd
,
7489 "no ospf priority [(0-255) [A.B.C.D]]",
7491 "OSPF interface commands\n"
7494 "Address of interface")
7497 struct interface
*ifp
= vty
->index
;
7498 struct route_node
*rn
;
7499 struct in_addr addr
;
7501 struct ospf_if_params
*params
;
7504 params
= IF_DEF_PARAMS (ifp
);
7508 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7511 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7516 params
= ospf_lookup_if_params (ifp
, addr
);
7521 UNSET_IF_PARAM (params
, priority
);
7522 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7524 if (params
!= IF_DEF_PARAMS (ifp
))
7526 ospf_free_if_params (ifp
, addr
);
7527 ospf_if_update_params (ifp
, addr
);
7530 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7532 struct ospf_interface
*oi
= rn
->info
;
7538 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7540 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7541 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7548 DEFUN (no_ip_ospf_priority
,
7549 no_ip_ospf_priority_addr_cmd
,
7550 "no ip ospf priority [(0-255) [A.B.C.D]]",
7553 "OSPF interface commands\n"
7556 "Address of interface")
7559 struct interface
*ifp
= vty
->index
;
7560 struct route_node
*rn
;
7561 struct in_addr addr
;
7563 struct ospf_if_params
*params
;
7566 params
= IF_DEF_PARAMS (ifp
);
7570 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7573 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7578 params
= ospf_lookup_if_params (ifp
, addr
);
7583 UNSET_IF_PARAM (params
, priority
);
7584 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7586 if (params
!= IF_DEF_PARAMS (ifp
))
7588 ospf_free_if_params (ifp
, addr
);
7589 ospf_if_update_params (ifp
, addr
);
7592 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7594 struct ospf_interface
*oi
= rn
->info
;
7600 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7602 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7603 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7611 DEFUN (ip_ospf_retransmit_interval
,
7612 ip_ospf_retransmit_interval_addr_cmd
,
7613 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
7615 "OSPF interface commands\n"
7616 "Time between retransmitting lost link state advertisements\n"
7618 "Address of interface")
7622 struct interface
*ifp
= vty
->index
;
7624 struct in_addr addr
;
7626 struct ospf_if_params
*params
;
7628 params
= IF_DEF_PARAMS (ifp
);
7629 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7631 /* Retransmit Interval range is <3-65535>. */
7632 if (seconds
< 3 || seconds
> 65535)
7634 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7641 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7644 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7649 params
= ospf_get_if_params (ifp
, addr
);
7650 ospf_if_update_params (ifp
, addr
);
7653 SET_IF_PARAM (params
, retransmit_interval
);
7654 params
->retransmit_interval
= seconds
;
7659 DEFUN_HIDDEN (ospf_retransmit_interval
,
7660 ospf_retransmit_interval_cmd
,
7661 "ospf retransmit-interval (3-65535)",
7662 "OSPF interface commands\n"
7663 "Time between retransmitting lost link state advertisements\n"
7667 struct interface
*ifp
= vty
->index
;
7669 struct ospf_if_params
*params
;
7671 params
= IF_DEF_PARAMS (ifp
);
7672 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7674 /* Retransmit Interval range is <3-65535>. */
7675 if (seconds
< 3 || seconds
> 65535)
7677 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7681 SET_IF_PARAM (params
, retransmit_interval
);
7682 params
->retransmit_interval
= seconds
;
7687 DEFUN (no_ospf_retransmit_interval
,
7688 no_ospf_retransmit_interval_cmd
,
7689 "no ospf retransmit-interval",
7691 "OSPF interface commands\n"
7692 "Time between retransmitting lost link state advertisements\n")
7694 struct interface
*ifp
= vty
->index
;
7695 struct ospf_if_params
*params
;
7698 params
= IF_DEF_PARAMS (ifp
);
7699 UNSET_IF_PARAM (params
, retransmit_interval
);
7700 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7705 DEFUN (no_ip_ospf_retransmit_interval
,
7706 no_ip_ospf_retransmit_interval_addr_cmd
,
7707 "no ip ospf retransmit-interval [<(3-65535) [A.B.C.D]|A.B.C.D>]",
7710 "OSPF interface commands\n"
7711 "Time between retransmitting lost link state advertisements\n"
7712 "Address of interface")
7714 struct interface
*ifp
= vty
->index
;
7715 struct in_addr addr
;
7717 struct ospf_if_params
*params
;
7721 params
= IF_DEF_PARAMS (ifp
);
7730 ret
= inet_aton(argv
[addr_index
]->arg
, &addr
);
7733 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7738 params
= ospf_lookup_if_params (ifp
, addr
);
7743 UNSET_IF_PARAM (params
, retransmit_interval
);
7744 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7746 if (params
!= IF_DEF_PARAMS (ifp
))
7748 ospf_free_if_params (ifp
, addr
);
7749 ospf_if_update_params (ifp
, addr
);
7756 DEFUN (ip_ospf_transmit_delay
,
7757 ip_ospf_transmit_delay_addr_cmd
,
7758 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7760 "OSPF interface commands\n"
7761 "Link state transmit delay\n"
7763 "Address of interface")
7767 struct interface
*ifp
= vty
->index
;
7769 struct in_addr addr
;
7771 struct ospf_if_params
*params
;
7773 params
= IF_DEF_PARAMS (ifp
);
7774 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7776 /* Transmit Delay range is <1-65535>. */
7777 if (seconds
< 1 || seconds
> 65535)
7779 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7785 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7788 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7793 params
= ospf_get_if_params (ifp
, addr
);
7794 ospf_if_update_params (ifp
, addr
);
7797 SET_IF_PARAM (params
, transmit_delay
);
7798 params
->transmit_delay
= seconds
;
7804 DEFUN_HIDDEN (ospf_transmit_delay
,
7805 ospf_transmit_delay_cmd
,
7806 "ospf transmit-delay (1-65535)",
7807 "OSPF interface commands\n"
7808 "Link state transmit delay\n"
7812 struct interface
*ifp
= vty
->index
;
7814 struct ospf_if_params
*params
;
7816 params
= IF_DEF_PARAMS (ifp
);
7817 seconds
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
7819 /* Transmit Delay range is <1-65535>. */
7820 if (seconds
< 1 || seconds
> 65535)
7822 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7826 SET_IF_PARAM (params
, transmit_delay
);
7827 params
->transmit_delay
= seconds
;
7832 DEFUN (no_ip_ospf_transmit_delay
,
7833 no_ip_ospf_transmit_delay_addr_cmd
,
7834 "no ip ospf transmit-delay [<A.B.C.D|(1-65535) A.B.C.D>]",
7837 "OSPF interface commands\n"
7838 "Link state transmit delay\n"
7839 "Address of interface")
7841 struct interface
*ifp
= vty
->index
;
7842 struct in_addr addr
;
7844 struct ospf_if_params
*params
;
7848 params
= IF_DEF_PARAMS (ifp
);
7857 ret
= inet_aton(argv
[addr_index
]->arg
, &addr
);
7860 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7865 params
= ospf_lookup_if_params (ifp
, addr
);
7870 UNSET_IF_PARAM (params
, transmit_delay
);
7871 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7873 if (params
!= IF_DEF_PARAMS (ifp
))
7875 ospf_free_if_params (ifp
, addr
);
7876 ospf_if_update_params (ifp
, addr
);
7883 DEFUN (no_ospf_transmit_delay
,
7884 no_ospf_transmit_delay_cmd
,
7885 "no ospf transmit-delay",
7887 "OSPF interface commands\n"
7888 "Link state transmit delay\n")
7890 struct interface
*ifp
= vty
->index
;
7891 struct ospf_if_params
*params
;
7894 params
= IF_DEF_PARAMS (ifp
);
7896 UNSET_IF_PARAM (params
, transmit_delay
);
7897 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7902 DEFUN (no_ip_ospf_transmit_delay_sec
,
7903 no_ip_ospf_transmit_delay_sec_cmd
,
7904 "no ip ospf transmit-delay (1-65535)",
7907 "OSPF interface commands\n"
7908 "Link state transmit delay\n"
7910 "Address of interface")
7912 struct interface
*ifp
= vty
->index
;
7913 struct ospf_if_params
*params
;
7916 params
= IF_DEF_PARAMS (ifp
);
7918 UNSET_IF_PARAM (params
, transmit_delay
);
7919 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7924 DEFUN (ip_ospf_area
,
7926 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7928 "OSPF interface commands\n"
7930 "Enable OSPF on this interface\n"
7931 "OSPF area ID in IP address format\n"
7932 "OSPF area ID as a decimal value\n")
7934 int idx_ipv4_number
= 2;
7935 struct interface
*ifp
= vty
->index
;
7937 struct in_addr area_id
;
7939 struct ospf_if_params
*params
;
7940 struct route_node
*rn
;
7941 u_short instance
= 0;
7944 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_ipv4_number
]->arg
);
7946 ospf
= ospf_lookup_instance (instance
);
7949 params
= IF_DEF_PARAMS (ifp
);
7950 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7952 ospf_interface_unset (ifp
);
7953 ospf
= ospf_lookup();
7954 ospf
->if_ospf_cli_count
--;
7959 ret
= ospf_str2area_id (argv
[instance
? 4 : 3]->arg
, &area_id
, &format
);
7962 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7966 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7968 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7972 params
= IF_DEF_PARAMS (ifp
);
7973 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7976 "Must remove previous area config before changing ospf area %s",
7981 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7983 if (rn
->info
!= NULL
)
7985 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7990 /* enable ospf on this interface with area_id */
7991 ospf_interface_set (ifp
, area_id
);
7992 ospf
->if_ospf_cli_count
++;
7997 DEFUN (no_ip_ospf_area
,
7998 no_ip_ospf_area_cmd
,
7999 "no ip ospf area [<A.B.C.D|(0-4294967295)>]",
8002 "OSPF interface commands\n"
8003 "Disable OSPF on this interface\n"
8004 "OSPF area ID in IP address format\n"
8005 "OSPF area ID as a decimal value\n")
8007 struct interface
*ifp
= vty
->index
;
8009 struct ospf_if_params
*params
;
8010 u_short instance
= 0;
8012 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8015 params
= IF_DEF_PARAMS (ifp
);
8016 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8018 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8022 ospf_interface_unset (ifp
);
8023 ospf
->if_ospf_cli_count
--;
8027 DEFUN (no_ip_ospf_instance_area
,
8028 no_ip_ospf_instance_area_cmd
,
8029 "no ip ospf (1-65535) area [<A.B.C.D|(0-4294967295)>]",
8032 "OSPF interface commands\n"
8034 "Disable OSPF on this interface\n")
8037 struct interface
*ifp
= vty
->index
;
8039 struct ospf_if_params
*params
;
8040 u_short instance
= 0;
8042 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8044 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8047 params
= IF_DEF_PARAMS (ifp
);
8048 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8050 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8054 ospf_interface_unset (ifp
);
8055 ospf
->if_ospf_cli_count
--;
8059 DEFUN (ospf_redistribute_source
,
8060 ospf_redistribute_source_cmd
,
8061 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8063 QUAGGA_REDIST_HELP_STR_OSPFD
8064 "Metric for redistributed routes\n"
8065 "OSPF default metric\n"
8066 "OSPF exterior metric type for redistributed routes\n"
8067 "Set OSPF External Type 1 metrics\n"
8068 "Set OSPF External Type 2 metrics\n"
8069 "Route map reference\n"
8070 "Pointer to route-map entries\n")
8072 int idx_protocol
= 1;
8073 int idx_redist_param
= 2;
8074 struct ospf
*ospf
= vty
->index
;
8078 struct ospf_redist
*red
;
8084 return CMD_WARNING
; /* should not happen */
8089 /* Get distribute source. */
8090 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
8091 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8094 /* Get metric value. */
8095 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8096 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8099 /* Get metric type. */
8100 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8101 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8104 red
= ospf_redist_add(ospf
, source
, 0);
8106 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8107 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8109 ospf_routemap_unset (red
);
8111 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
8114 DEFUN (no_ospf_redistribute_source
,
8115 no_ospf_redistribute_source_cmd
,
8116 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8119 QUAGGA_REDIST_HELP_STR_OSPFD
8120 "Metric for redistributed routes\n"
8121 "OSPF default metric\n"
8122 "OSPF exterior metric type for redistributed routes\n"
8123 "Set OSPF External Type 1 metrics\n"
8124 "Set OSPF External Type 2 metrics\n"
8125 "Route map reference\n"
8126 "Pointer to route-map entries\n")
8128 int idx_protocol
= 2;
8129 struct ospf
*ospf
= vty
->index
;
8131 struct ospf_redist
*red
;
8135 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
8136 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8139 red
= ospf_redist_lookup(ospf
, source
, 0);
8143 ospf_routemap_unset (red
);
8144 return ospf_redistribute_unset (ospf
, source
, 0);
8147 DEFUN (ospf_redistribute_instance_source
,
8148 ospf_redistribute_instance_source_cmd
,
8149 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8151 "Open Shortest Path First\n"
8152 "Non-main Kernel Routing Table\n"
8153 "Instance ID/Table ID\n"
8154 "Metric for redistributed routes\n"
8155 "OSPF default metric\n"
8156 "OSPF exterior metric type for redistributed routes\n"
8157 "Set OSPF External Type 1 metrics\n"
8158 "Set OSPF External Type 2 metrics\n"
8159 "Route map reference\n"
8160 "Pointer to route-map entries\n")
8162 int idx_ospf_table
= 1;
8164 int idx_redist_param
= 3;
8165 struct ospf
*ospf
= vty
->index
;
8170 struct ospf_redist
*red
;
8175 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8176 source
= ZEBRA_ROUTE_OSPF
;
8178 source
= ZEBRA_ROUTE_TABLE
;
8180 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
8185 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8187 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8192 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8194 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8199 /* Get metric value. */
8200 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8201 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8204 /* Get metric type. */
8205 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8206 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8209 red
= ospf_redist_add(ospf
, source
, instance
);
8211 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8212 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8214 ospf_routemap_unset (red
);
8216 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
8219 DEFUN (no_ospf_redistribute_instance_source
,
8220 no_ospf_redistribute_instance_source_cmd
,
8221 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8224 "Open Shortest Path First\n"
8225 "Non-main Kernel Routing Table\n"
8226 "Instance ID/Table Id\n"
8227 "Metric for redistributed routes\n"
8228 "OSPF default metric\n"
8229 "OSPF exterior metric type for redistributed routes\n"
8230 "Set OSPF External Type 1 metrics\n"
8231 "Set OSPF External Type 2 metrics\n"
8232 "Route map reference\n"
8233 "Pointer to route-map entries\n")
8235 int idx_ospf_table
= 2;
8237 struct ospf
*ospf
= vty
->index
;
8239 struct ospf_redist
*red
;
8245 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8246 source
= ZEBRA_ROUTE_OSPF
;
8248 source
= ZEBRA_ROUTE_TABLE
;
8250 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
8252 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8254 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8259 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8261 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8266 red
= ospf_redist_lookup(ospf
, source
, instance
);
8270 ospf_routemap_unset (red
);
8271 return ospf_redistribute_unset (ospf
, source
, instance
);
8274 DEFUN (ospf_distribute_list_out
,
8275 ospf_distribute_list_out_cmd
,
8276 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
8277 "Filter networks in routing updates\n"
8278 "Access-list name\n"
8280 QUAGGA_REDIST_HELP_STR_OSPFD
)
8283 struct ospf
*ospf
= vty
->index
;
8289 /* Get distribute source. */
8290 source
= proto_redistnum(AFI_IP
, argv
[4]->arg
);
8291 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8294 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
8297 DEFUN (no_ospf_distribute_list_out
,
8298 no_ospf_distribute_list_out_cmd
,
8299 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
8301 "Filter networks in routing updates\n"
8302 "Access-list name\n"
8304 QUAGGA_REDIST_HELP_STR_OSPFD
)
8307 struct ospf
*ospf
= vty
->index
;
8313 source
= proto_redistnum(AFI_IP
, argv
[5]->arg
);
8314 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8317 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
8320 /* Default information originate. */
8321 DEFUN (ospf_default_information_originate
,
8322 ospf_default_information_originate_cmd
,
8323 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8324 "Control distribution of default information\n"
8325 "Distribute a default route\n"
8326 "Always advertise default route\n"
8327 "OSPF default metric\n"
8329 "OSPF metric type for default routes\n"
8330 "Set OSPF External Type 1 metrics\n"
8331 "Set OSPF External Type 2 metrics\n"
8332 "Route map reference\n"
8333 "Pointer to route-map entries\n")
8335 int idx_redist_param
= 2;
8336 struct ospf
*ospf
= vty
->index
;
8337 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8340 struct ospf_redist
*red
;
8346 return CMD_WARNING
; /* this should not happen */
8348 /* Check whether "always" was specified */
8349 if (argv
[idx_redist_param
]->arg
!= NULL
)
8350 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8352 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8354 /* Get metric value. */
8355 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
8356 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
8359 /* Get metric type. */
8360 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
8361 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
8364 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
8365 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
8367 ospf_routemap_unset (red
);
8369 return ospf_redistribute_default_set (ospf
, default_originate
,
8373 DEFUN (no_ospf_default_information_originate
,
8374 no_ospf_default_information_originate_cmd
,
8375 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8377 "Control distribution of default information\n"
8378 "Distribute a default route\n"
8379 "Always advertise default route\n"
8380 "OSPF default metric\n"
8382 "OSPF metric type for default routes\n"
8383 "Set OSPF External Type 1 metrics\n"
8384 "Set OSPF External Type 2 metrics\n"
8385 "Route map reference\n"
8386 "Pointer to route-map entries\n")
8388 struct ospf
*ospf
= vty
->index
;
8389 struct prefix_ipv4 p
;
8390 struct ospf_external
*ext
;
8391 struct ospf_redist
*red
;
8397 p
.prefix
.s_addr
= 0;
8400 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
8402 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
8403 EXTERNAL_INFO (ext
)) {
8404 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
8405 ospf_external_del (DEFAULT_ROUTE
, 0);
8408 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8412 ospf_routemap_unset (red
);
8413 return ospf_redistribute_default_unset (ospf
);
8416 DEFUN (ospf_default_metric
,
8417 ospf_default_metric_cmd
,
8418 "default-metric (0-16777214)",
8419 "Set metric of redistributed routes\n"
8423 struct ospf
*ospf
= vty
->index
;
8429 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
8432 ospf
->default_metric
= metric
;
8437 DEFUN (no_ospf_default_metric
,
8438 no_ospf_default_metric_cmd
,
8439 "no default-metric [(0-16777214)]",
8441 "Set metric of redistributed routes\n"
8444 struct ospf
*ospf
= vty
->index
;
8449 ospf
->default_metric
= -1;
8455 DEFUN (ospf_distance
,
8458 "Define an administrative distance\n"
8459 "OSPF Administrative distance\n")
8462 struct ospf
*ospf
= vty
->index
;
8467 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
8472 DEFUN (no_ospf_distance
,
8473 no_ospf_distance_cmd
,
8474 "no distance (1-255)",
8476 "Define an administrative distance\n"
8477 "OSPF Administrative distance\n")
8479 struct ospf
*ospf
= vty
->index
;
8484 ospf
->distance_all
= 0;
8489 DEFUN (no_ospf_distance_ospf
,
8490 no_ospf_distance_ospf_cmd
,
8491 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
8493 "Define an administrative distance\n"
8494 "OSPF Administrative distance\n"
8495 "Intra-area routes\n"
8496 "Distance for intra-area routes\n"
8497 "Inter-area routes\n"
8498 "Distance for inter-area routes\n"
8500 "Distance for external routes\n")
8502 int idx_area_distance
= 3;
8503 struct ospf
*ospf
= vty
->index
;
8514 if (argv
[idx_area_distance
]->arg
!= NULL
)
8515 ospf
->distance_intra
= 0;
8517 if (argv
[1] != NULL
)
8518 ospf
->distance_inter
= 0;
8520 if (argv
[2] != NULL
)
8521 ospf
->distance_external
= 0;
8523 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
8526 /* If no arguments are given, clear all distance information */
8527 ospf
->distance_intra
= 0;
8528 ospf
->distance_inter
= 0;
8529 ospf
->distance_external
= 0;
8534 DEFUN (ospf_distance_ospf
,
8535 ospf_distance_ospf_cmd
,
8536 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
8537 "Define an administrative distance\n"
8538 "OSPF Administrative distance\n"
8539 "Intra-area routes\n"
8540 "Distance for intra-area routes\n"
8541 "Inter-area routes\n"
8542 "Distance for inter-area routes\n"
8544 "Distance for external routes\n")
8546 int idx_area_distance
= 2;
8547 struct ospf
*ospf
= vty
->index
;
8552 if (argc
< 3) /* should not happen */
8555 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
8557 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
8562 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
8563 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
8565 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
8566 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
8568 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
8569 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
8574 DEFUN (ospf_distance_source
,
8575 ospf_distance_source_cmd
,
8576 "distance (1-255) A.B.C.D/M",
8577 "Administrative distance\n"
8579 "IP source prefix\n")
8582 int idx_ipv4_prefixlen
= 2;
8583 struct ospf
*ospf
= vty
->index
;
8588 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8593 DEFUN (no_ospf_distance_source
,
8594 no_ospf_distance_source_cmd
,
8595 "no distance (1-255) A.B.C.D/M",
8597 "Administrative distance\n"
8599 "IP source prefix\n")
8602 int idx_ipv4_prefixlen
= 3;
8603 struct ospf
*ospf
= vty
->index
;
8608 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8613 DEFUN (ospf_distance_source_access_list
,
8614 ospf_distance_source_access_list_cmd
,
8615 "distance (1-255) A.B.C.D/M WORD",
8616 "Administrative distance\n"
8618 "IP source prefix\n"
8619 "Access list name\n")
8622 int idx_ipv4_prefixlen
= 2;
8624 struct ospf
*ospf
= vty
->index
;
8629 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8634 DEFUN (no_ospf_distance_source_access_list
,
8635 no_ospf_distance_source_access_list_cmd
,
8636 "no distance (1-255) A.B.C.D/M WORD",
8638 "Administrative distance\n"
8640 "IP source prefix\n"
8641 "Access list name\n")
8644 int idx_ipv4_prefixlen
= 3;
8646 struct ospf
*ospf
= vty
->index
;
8651 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8656 DEFUN (ip_ospf_mtu_ignore
,
8657 ip_ospf_mtu_ignore_addr_cmd
,
8658 "ip ospf mtu-ignore [A.B.C.D]",
8660 "OSPF interface commands\n"
8661 "Disable mtu mismatch detection\n"
8662 "Address of interface")
8665 struct interface
*ifp
= vty
->index
;
8666 struct in_addr addr
;
8669 struct ospf_if_params
*params
;
8670 params
= IF_DEF_PARAMS (ifp
);
8674 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8677 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8681 params
= ospf_get_if_params (ifp
, addr
);
8682 ospf_if_update_params (ifp
, addr
);
8684 params
->mtu_ignore
= 1;
8685 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8686 SET_IF_PARAM (params
, mtu_ignore
);
8689 UNSET_IF_PARAM (params
, mtu_ignore
);
8690 if (params
!= IF_DEF_PARAMS (ifp
))
8692 ospf_free_if_params (ifp
, addr
);
8693 ospf_if_update_params (ifp
, addr
);
8699 DEFUN (no_ip_ospf_mtu_ignore
,
8700 no_ip_ospf_mtu_ignore_addr_cmd
,
8701 "no ip ospf mtu-ignore [A.B.C.D]",
8703 "OSPF interface commands\n"
8704 "Disable mtu mismatch detection\n"
8705 "Address of interface")
8708 struct interface
*ifp
= vty
->index
;
8709 struct in_addr addr
;
8712 struct ospf_if_params
*params
;
8713 params
= IF_DEF_PARAMS (ifp
);
8717 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8720 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8724 params
= ospf_get_if_params (ifp
, addr
);
8725 ospf_if_update_params (ifp
, addr
);
8727 params
->mtu_ignore
= 0;
8728 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8729 SET_IF_PARAM (params
, mtu_ignore
);
8732 UNSET_IF_PARAM (params
, mtu_ignore
);
8733 if (params
!= IF_DEF_PARAMS (ifp
))
8735 ospf_free_if_params (ifp
, addr
);
8736 ospf_if_update_params (ifp
, addr
);
8743 DEFUN (ospf_max_metric_router_lsa_admin
,
8744 ospf_max_metric_router_lsa_admin_cmd
,
8745 "max-metric router-lsa administrative",
8746 "OSPF maximum / infinite-distance metric\n"
8747 "Advertise own Router-LSA with infinite distance (stub router)\n"
8748 "Administratively applied, for an indefinite period\n")
8750 struct listnode
*ln
;
8751 struct ospf_area
*area
;
8752 struct ospf
*ospf
= vty
->index
;
8757 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8759 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8761 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
8762 ospf_router_lsa_update_area (area
);
8765 /* Allows for areas configured later to get the property */
8766 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8771 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8772 no_ospf_max_metric_router_lsa_admin_cmd
,
8773 "no max-metric router-lsa administrative",
8775 "OSPF maximum / infinite-distance metric\n"
8776 "Advertise own Router-LSA with infinite distance (stub router)\n"
8777 "Administratively applied, for an indefinite period\n")
8779 struct listnode
*ln
;
8780 struct ospf_area
*area
;
8781 struct ospf
*ospf
= vty
->index
;
8786 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8788 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8790 /* Don't trample on the start-up stub timer */
8791 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8792 && !area
->t_stub_router
)
8794 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8795 ospf_router_lsa_update_area (area
);
8798 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8802 DEFUN (ospf_max_metric_router_lsa_startup
,
8803 ospf_max_metric_router_lsa_startup_cmd
,
8804 "max-metric router-lsa on-startup (5-86400)",
8805 "OSPF maximum / infinite-distance metric\n"
8806 "Advertise own Router-LSA with infinite distance (stub router)\n"
8807 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8808 "Time (seconds) to advertise self as stub-router\n")
8811 unsigned int seconds
;
8812 struct ospf
*ospf
= vty
->index
;
8819 vty_out (vty
, "%% Must supply stub-router period");
8823 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
8825 ospf
->stub_router_startup_time
= seconds
;
8830 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8831 no_ospf_max_metric_router_lsa_startup_cmd
,
8832 "no max-metric router-lsa on-startup [(5-86400)]",
8834 "OSPF maximum / infinite-distance metric\n"
8835 "Advertise own Router-LSA with infinite distance (stub router)\n"
8836 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8837 "Time (seconds) to advertise self as stub-router\n")
8839 struct listnode
*ln
;
8840 struct ospf_area
*area
;
8841 struct ospf
*ospf
= vty
->index
;
8846 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8848 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8850 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8851 OSPF_TIMER_OFF (area
->t_stub_router
);
8853 /* Don't trample on admin stub routed */
8854 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8856 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8857 ospf_router_lsa_update_area (area
);
8864 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8865 ospf_max_metric_router_lsa_shutdown_cmd
,
8866 "max-metric router-lsa on-shutdown (5-100)",
8867 "OSPF maximum / infinite-distance metric\n"
8868 "Advertise own Router-LSA with infinite distance (stub router)\n"
8869 "Advertise stub-router prior to full shutdown of OSPF\n"
8870 "Time (seconds) to wait till full shutdown\n")
8873 unsigned int seconds
;
8874 struct ospf
*ospf
= vty
->index
;
8881 vty_out (vty
, "%% Must supply stub-router shutdown period");
8885 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
8887 ospf
->stub_router_shutdown_time
= seconds
;
8892 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8893 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8894 "no max-metric router-lsa on-shutdown [(5-100)]",
8896 "OSPF maximum / infinite-distance metric\n"
8897 "Advertise own Router-LSA with infinite distance (stub router)\n"
8898 "Advertise stub-router prior to full shutdown of OSPF\n"
8899 "Time (seconds) to wait till full shutdown\n")
8901 struct ospf
*ospf
= vty
->index
;
8906 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8912 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8914 struct listnode
*ln
;
8915 struct ospf_area
*area
;
8917 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8918 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8919 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8920 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8921 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8922 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8923 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8925 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8927 vty_out (vty
, " max-metric router-lsa administrative%s",
8936 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8938 struct route_node
*rn
;
8939 struct ospf_route
*or;
8940 struct listnode
*pnode
, *pnnode
;
8941 struct ospf_path
*path
;
8943 vty_out (vty
, "============ OSPF network routing table ============%s",
8946 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8947 if ((or = rn
->info
) != NULL
)
8950 snprintf (buf1
, 19, "%s/%d",
8951 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8953 switch (or->path_type
)
8955 case OSPF_PATH_INTER_AREA
:
8956 if (or->type
== OSPF_DESTINATION_NETWORK
)
8957 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8958 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8959 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8960 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8962 case OSPF_PATH_INTRA_AREA
:
8963 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8964 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8970 if (or->type
== OSPF_DESTINATION_NETWORK
)
8971 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8973 if (if_lookup_by_index(path
->ifindex
))
8975 if (path
->nexthop
.s_addr
== 0)
8976 vty_out (vty
, "%24s directly attached to %s%s",
8977 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8979 vty_out (vty
, "%24s via %s, %s%s", "",
8980 inet_ntoa (path
->nexthop
),
8981 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8985 vty_out (vty
, "%s", VTY_NEWLINE
);
8989 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
8991 struct route_node
*rn
;
8992 struct ospf_route
*or;
8993 struct listnode
*pnode
;
8994 struct listnode
*node
;
8995 struct ospf_path
*path
;
8997 vty_out (vty
, "============ OSPF router routing table =============%s",
8999 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
9004 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
9006 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
9009 vty_out (vty
, "%24s", "");
9012 vty_out (vty
, "%s [%d] area: %s",
9013 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
9014 or->cost
, inet_ntoa (or->u
.std
.area_id
));
9016 vty_out (vty
, "%s%s%s",
9017 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
9018 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
9021 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
9023 if (if_lookup_by_index(path
->ifindex
))
9025 if (path
->nexthop
.s_addr
== 0)
9026 vty_out (vty
, "%24s directly attached to %s%s",
9027 "", ifindex2ifname (path
->ifindex
),
9030 vty_out (vty
, "%24s via %s, %s%s", "",
9031 inet_ntoa (path
->nexthop
),
9032 ifindex2ifname (path
->ifindex
),
9038 vty_out (vty
, "%s", VTY_NEWLINE
);
9042 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
9044 struct route_node
*rn
;
9045 struct ospf_route
*er
;
9046 struct listnode
*pnode
, *pnnode
;
9047 struct ospf_path
*path
;
9049 vty_out (vty
, "============ OSPF external routing table ===========%s",
9051 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
9052 if ((er
= rn
->info
) != NULL
)
9055 snprintf (buf1
, 19, "%s/%d",
9056 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
9058 switch (er
->path_type
)
9060 case OSPF_PATH_TYPE1_EXTERNAL
:
9061 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
9062 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9064 case OSPF_PATH_TYPE2_EXTERNAL
:
9065 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
9066 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9070 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
9072 if (if_lookup_by_index(path
->ifindex
))
9074 if (path
->nexthop
.s_addr
== 0)
9075 vty_out (vty
, "%24s directly attached to %s%s",
9076 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9078 vty_out (vty
, "%24s via %s, %s%s", "",
9079 inet_ntoa (path
->nexthop
),
9080 ifindex2ifname (path
->ifindex
),
9085 vty_out (vty
, "%s", VTY_NEWLINE
);
9089 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
9092 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9093 VTY_NEWLINE
, VTY_NEWLINE
);
9095 if (ospf
->new_table
== NULL
)
9097 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9101 /* Show Network routes.
9102 show_ip_ospf_route_network (vty, ospf->new_table); */
9104 /* Show Router routes. */
9105 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9107 vty_out (vty
, "%s", VTY_NEWLINE
);
9112 DEFUN (show_ip_ospf_border_routers
,
9113 show_ip_ospf_border_routers_cmd
,
9114 "show ip ospf border-routers",
9117 "OSPF information\n"
9118 "Show all the ABR's and ASBR's\n")
9122 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9125 return show_ip_ospf_border_routers_common(vty
, ospf
);
9128 DEFUN (show_ip_ospf_instance_border_routers
,
9129 show_ip_ospf_instance_border_routers_cmd
,
9130 "show ip ospf (1-65535) border-routers",
9133 "OSPF information\n"
9135 "Show all the ABR's and ASBR's\n")
9139 u_short instance
= 0;
9141 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
9142 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9145 return show_ip_ospf_border_routers_common(vty
, ospf
);
9149 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
9152 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9153 VTY_NEWLINE
, VTY_NEWLINE
);
9155 if (ospf
->new_table
== NULL
)
9157 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9161 /* Show Network routes. */
9162 show_ip_ospf_route_network (vty
, ospf
->new_table
);
9164 /* Show Router routes. */
9165 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9167 /* Show AS External routes. */
9168 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
9170 vty_out (vty
, "%s", VTY_NEWLINE
);
9175 DEFUN (show_ip_ospf_route
,
9176 show_ip_ospf_route_cmd
,
9177 "show ip ospf route",
9180 "OSPF information\n"
9181 "OSPF routing table\n")
9185 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9188 return show_ip_ospf_route_common(vty
, ospf
);
9191 DEFUN (show_ip_ospf_instance_route
,
9192 show_ip_ospf_instance_route_cmd
,
9193 "show ip ospf (1-65535) route",
9196 "OSPF information\n"
9198 "OSPF routing table\n")
9202 u_short instance
= 0;
9204 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
9205 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9208 return show_ip_ospf_route_common(vty
, ospf
);
9211 const char *ospf_abr_type_str
[] =
9220 const char *ospf_shortcut_mode_str
[] =
9229 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
9231 memset (buf
, 0, length
);
9233 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9234 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
9236 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
9240 const char *ospf_int_type_str
[] =
9242 "unknown", /* should never be used. */
9246 "point-to-multipoint",
9247 "virtual-link", /* should never be used. */
9251 /* Configuration write function for ospfd. */
9253 config_write_interface (struct vty
*vty
)
9255 struct listnode
*n1
, *n2
;
9256 struct interface
*ifp
;
9257 struct crypt_key
*ck
;
9259 struct route_node
*rn
= NULL
;
9260 struct ospf_if_params
*params
;
9261 struct ospf
*ospf
= ospf_lookup();
9263 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
9265 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
9268 if (ifp
->ifindex
== IFINDEX_DELETED
)
9271 vty_out (vty
, "!%s", VTY_NEWLINE
);
9272 vty_out (vty
, "interface %s%s", ifp
->name
,
9275 vty_out (vty
, " description %s%s", ifp
->desc
,
9280 params
= IF_DEF_PARAMS (ifp
);
9283 /* Interface Network print. */
9284 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
9285 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
9287 if (params
->type
!= ospf_default_iftype(ifp
))
9289 vty_out (vty
, " ip ospf network %s",
9290 ospf_int_type_str
[params
->type
]);
9291 if (params
!= IF_DEF_PARAMS (ifp
))
9292 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9293 vty_out (vty
, "%s", VTY_NEWLINE
);
9297 /* OSPF interface authentication print */
9298 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
9299 params
->auth_type
!= OSPF_AUTH_NOTSET
)
9301 const char *auth_str
;
9303 /* Translation tables are not that much help here due to syntax
9304 of the simple option */
9305 switch (params
->auth_type
)
9308 case OSPF_AUTH_NULL
:
9312 case OSPF_AUTH_SIMPLE
:
9316 case OSPF_AUTH_CRYPTOGRAPHIC
:
9317 auth_str
= " message-digest";
9325 vty_out (vty
, " ip ospf authentication%s", auth_str
);
9326 if (params
!= IF_DEF_PARAMS (ifp
))
9327 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9328 vty_out (vty
, "%s", VTY_NEWLINE
);
9331 /* Simple Authentication Password print. */
9332 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
9333 params
->auth_simple
[0] != '\0')
9335 vty_out (vty
, " ip ospf authentication-key %s",
9336 params
->auth_simple
);
9337 if (params
!= IF_DEF_PARAMS (ifp
))
9338 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9339 vty_out (vty
, "%s", VTY_NEWLINE
);
9342 /* Cryptographic Authentication Key print. */
9343 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
9345 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
9346 ck
->key_id
, ck
->auth_key
);
9347 if (params
!= IF_DEF_PARAMS (ifp
))
9348 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9349 vty_out (vty
, "%s", VTY_NEWLINE
);
9352 /* Interface Output Cost print. */
9353 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
9355 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
9356 if (params
!= IF_DEF_PARAMS (ifp
))
9357 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9358 vty_out (vty
, "%s", VTY_NEWLINE
);
9361 /* Hello Interval print. */
9362 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
9363 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
9365 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
9366 if (params
!= IF_DEF_PARAMS (ifp
))
9367 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9368 vty_out (vty
, "%s", VTY_NEWLINE
);
9372 /* Router Dead Interval print. */
9373 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
9374 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
9376 vty_out (vty
, " ip ospf dead-interval ");
9379 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
9380 vty_out (vty
, "minimal hello-multiplier %d",
9381 params
->fast_hello
);
9383 vty_out (vty
, "%u", params
->v_wait
);
9385 if (params
!= IF_DEF_PARAMS (ifp
))
9386 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9387 vty_out (vty
, "%s", VTY_NEWLINE
);
9390 /* Router Priority print. */
9391 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
9392 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
9394 vty_out (vty
, " ip ospf priority %u", params
->priority
);
9395 if (params
!= IF_DEF_PARAMS (ifp
))
9396 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9397 vty_out (vty
, "%s", VTY_NEWLINE
);
9400 /* Retransmit Interval print. */
9401 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
9402 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
9404 vty_out (vty
, " ip ospf retransmit-interval %u",
9405 params
->retransmit_interval
);
9406 if (params
!= IF_DEF_PARAMS (ifp
))
9407 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9408 vty_out (vty
, "%s", VTY_NEWLINE
);
9411 /* Transmit Delay print. */
9412 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
9413 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
9415 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
9416 if (params
!= IF_DEF_PARAMS (ifp
))
9417 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9418 vty_out (vty
, "%s", VTY_NEWLINE
);
9422 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
9425 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
9426 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9428 vty_out (vty
, " ip ospf area %s%s",
9429 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9434 ospf_bfd_write_config(vty
, params
);
9436 /* MTU ignore print. */
9437 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
9438 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9440 if (params
->mtu_ignore
== 0)
9441 vty_out (vty
, " no ip ospf mtu-ignore");
9443 vty_out (vty
, " ip ospf mtu-ignore");
9444 if (params
!= IF_DEF_PARAMS (ifp
))
9445 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9446 vty_out (vty
, "%s", VTY_NEWLINE
);
9453 rn
= route_top (IF_OIFS_PARAMS (ifp
));
9455 rn
= route_next (rn
);
9465 ospf_opaque_config_write_if (vty
, ifp
);
9472 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
9474 struct route_node
*rn
;
9475 u_char buf
[INET_ADDRSTRLEN
];
9477 /* `network area' print. */
9478 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
9481 struct ospf_network
*n
= rn
->info
;
9483 memset (buf
, 0, INET_ADDRSTRLEN
);
9485 /* Create Area ID string by specified Area ID format. */
9486 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9487 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
9489 sprintf ((char *) buf
, "%lu",
9490 (unsigned long int) ntohl (n
->area_id
.s_addr
));
9492 /* Network print. */
9493 vty_out (vty
, " network %s/%d area %s%s",
9494 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9502 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
9504 struct listnode
*node
;
9505 struct ospf_area
*area
;
9506 u_char buf
[INET_ADDRSTRLEN
];
9508 /* Area configuration print. */
9509 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
9511 struct route_node
*rn1
;
9513 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
9515 if (area
->auth_type
!= OSPF_AUTH_NULL
)
9517 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9518 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
9520 vty_out (vty
, " area %s authentication message-digest%s",
9524 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9525 vty_out (vty
, " area %s shortcut %s%s", buf
,
9526 ospf_shortcut_mode_str
[area
->shortcut_configured
],
9529 if ((area
->external_routing
== OSPF_AREA_STUB
)
9530 || (area
->external_routing
== OSPF_AREA_NSSA
)
9533 if (area
->external_routing
== OSPF_AREA_STUB
)
9534 vty_out (vty
, " area %s stub", buf
);
9535 else if (area
->external_routing
== OSPF_AREA_NSSA
)
9537 vty_out (vty
, " area %s nssa", buf
);
9538 switch (area
->NSSATranslatorRole
)
9540 case OSPF_NSSA_ROLE_NEVER
:
9541 vty_out (vty
, " translate-never");
9543 case OSPF_NSSA_ROLE_ALWAYS
:
9544 vty_out (vty
, " translate-always");
9546 case OSPF_NSSA_ROLE_CANDIDATE
:
9548 vty_out (vty
, " translate-candidate");
9552 if (area
->no_summary
)
9553 vty_out (vty
, " no-summary");
9555 vty_out (vty
, "%s", VTY_NEWLINE
);
9557 if (area
->default_cost
!= 1)
9558 vty_out (vty
, " area %s default-cost %d%s", buf
,
9559 area
->default_cost
, VTY_NEWLINE
);
9562 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
9565 struct ospf_area_range
*range
= rn1
->info
;
9567 vty_out (vty
, " area %s range %s/%d", buf
,
9568 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
9570 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
9571 vty_out (vty
, " cost %d", range
->cost_config
);
9573 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
9574 vty_out (vty
, " not-advertise");
9576 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
9577 vty_out (vty
, " substitute %s/%d",
9578 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
9580 vty_out (vty
, "%s", VTY_NEWLINE
);
9583 if (EXPORT_NAME (area
))
9584 vty_out (vty
, " area %s export-list %s%s", buf
,
9585 EXPORT_NAME (area
), VTY_NEWLINE
);
9587 if (IMPORT_NAME (area
))
9588 vty_out (vty
, " area %s import-list %s%s", buf
,
9589 IMPORT_NAME (area
), VTY_NEWLINE
);
9591 if (PREFIX_NAME_IN (area
))
9592 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
9593 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
9595 if (PREFIX_NAME_OUT (area
))
9596 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
9597 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
9604 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
9606 struct ospf_nbr_nbma
*nbr_nbma
;
9607 struct route_node
*rn
;
9609 /* Static Neighbor configuration print. */
9610 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
9611 if ((nbr_nbma
= rn
->info
))
9613 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
9615 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9616 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
9618 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9619 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
9621 vty_out (vty
, "%s", VTY_NEWLINE
);
9628 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
9630 struct listnode
*node
;
9631 struct ospf_vl_data
*vl_data
;
9632 u_char buf
[INET_ADDRSTRLEN
];
9634 /* Virtual-Link print */
9635 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
9637 struct listnode
*n2
;
9638 struct crypt_key
*ck
;
9639 struct ospf_interface
*oi
;
9641 if (vl_data
!= NULL
)
9643 memset (buf
, 0, INET_ADDRSTRLEN
);
9645 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9646 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
9648 sprintf ((char *) buf
, "%lu",
9649 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
9650 oi
= vl_data
->vl_oi
;
9653 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
9654 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
9655 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
9656 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
9657 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9659 inet_ntoa (vl_data
->vl_peer
),
9660 OSPF_IF_PARAM (oi
, v_hello
),
9661 OSPF_IF_PARAM (oi
, retransmit_interval
),
9662 OSPF_IF_PARAM (oi
, transmit_delay
),
9663 OSPF_IF_PARAM (oi
, v_wait
),
9666 vty_out (vty
, " area %s virtual-link %s%s", buf
,
9667 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
9669 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
9670 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
9672 inet_ntoa (vl_data
->vl_peer
),
9673 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
9676 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
9678 vty_out (vty
, " area %s virtual-link %s"
9679 " message-digest-key %d md5 %s%s",
9681 inet_ntoa (vl_data
->vl_peer
),
9682 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
9692 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
9696 /* redistribute print. */
9697 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9699 struct list
*red_list
;
9700 struct listnode
*node
;
9701 struct ospf_redist
*red
;
9703 red_list
= ospf
->redist
[type
];
9707 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
9709 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
9711 vty_out (vty
, " %d", red
->instance
);
9713 if (red
->dmetric
.value
>= 0)
9714 vty_out (vty
, " metric %d", red
->dmetric
.value
);
9716 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9717 vty_out (vty
, " metric-type 1");
9719 if (ROUTEMAP_NAME (red
))
9720 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
9722 vty_out (vty
, "%s", VTY_NEWLINE
);
9730 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
9732 if (ospf
->default_metric
!= -1)
9733 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
9739 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
9742 struct ospf_redist
*red
;
9746 /* distribute-list print. */
9747 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9748 if (DISTRIBUTE_NAME (ospf
, type
))
9749 vty_out (vty
, " distribute-list %s out %s%s",
9750 DISTRIBUTE_NAME (ospf
, type
),
9751 zebra_route_string(type
), VTY_NEWLINE
);
9753 /* default-information print. */
9754 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
9756 vty_out (vty
, " default-information originate");
9757 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9758 vty_out (vty
, " always");
9760 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9763 if (red
->dmetric
.value
>= 0)
9764 vty_out (vty
, " metric %d",
9765 red
->dmetric
.value
);
9766 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9767 vty_out (vty
, " metric-type 1");
9769 if (ROUTEMAP_NAME (red
))
9770 vty_out (vty
, " route-map %s",
9771 ROUTEMAP_NAME (red
));
9774 vty_out (vty
, "%s", VTY_NEWLINE
);
9783 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9785 struct route_node
*rn
;
9786 struct ospf_distance
*odistance
;
9788 if (ospf
->distance_all
)
9789 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9791 if (ospf
->distance_intra
9792 || ospf
->distance_inter
9793 || ospf
->distance_external
)
9795 vty_out (vty
, " distance ospf");
9797 if (ospf
->distance_intra
)
9798 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9799 if (ospf
->distance_inter
)
9800 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9801 if (ospf
->distance_external
)
9802 vty_out (vty
, " external %d", ospf
->distance_external
);
9804 vty_out (vty
, "%s", VTY_NEWLINE
);
9807 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9808 if ((odistance
= rn
->info
) != NULL
)
9810 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9811 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9812 odistance
->access_list
? odistance
->access_list
: "",
9818 /* OSPF configuration write function. */
9820 ospf_config_write (struct vty
*vty
)
9823 struct interface
*ifp
;
9824 struct ospf_interface
*oi
;
9825 struct listnode
*node
;
9828 ospf
= ospf_lookup ();
9829 if (ospf
!= NULL
&& ospf
->oi_running
)
9831 /* `router ospf' print. */
9833 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9835 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9839 if (!ospf
->networks
)
9842 /* Router ID print. */
9843 if (ospf
->router_id_static
.s_addr
!= 0)
9844 vty_out (vty
, " ospf router-id %s%s",
9845 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9847 /* ABR type print. */
9848 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9849 vty_out (vty
, " ospf abr-type %s%s",
9850 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9852 /* log-adjacency-changes flag print. */
9853 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9855 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9856 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9860 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9863 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9864 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9865 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9867 /* auto-cost reference-bandwidth configuration. */
9868 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9870 vty_out (vty
, "! Important: ensure reference bandwidth "
9871 "is consistent across all routers%s", VTY_NEWLINE
);
9872 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9873 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9876 /* SPF timers print. */
9877 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9878 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9879 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9880 vty_out (vty
, " timers throttle spf %d %d %d%s",
9881 ospf
->spf_delay
, ospf
->spf_holdtime
,
9882 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9884 /* LSA timers print. */
9885 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9886 vty_out (vty
, " timers throttle lsa all %d%s",
9887 ospf
->min_ls_interval
, VTY_NEWLINE
);
9888 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9889 vty_out (vty
, " timers lsa min-arrival %d%s",
9890 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9892 /* Write multiplier print. */
9893 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9894 vty_out (vty
, " ospf write-multiplier %d%s",
9895 ospf
->write_oi_count
, VTY_NEWLINE
);
9897 /* Max-metric router-lsa print */
9898 config_write_stub_router (vty
, ospf
);
9900 /* SPF refresh parameters print. */
9901 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9902 vty_out (vty
, " refresh timer %d%s",
9903 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9905 /* Redistribute information print. */
9906 config_write_ospf_redistribute (vty
, ospf
);
9908 /* passive-interface print. */
9909 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9910 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9912 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9913 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9914 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9915 ospf
->passive_interface_default
)
9917 vty_out (vty
, " %spassive-interface %s%s",
9918 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9919 ifp
->name
, VTY_NEWLINE
);
9921 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9923 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9925 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9928 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9931 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9934 vty_out (vty
, " %spassive-interface %s %s%s",
9935 oi
->params
->passive_interface
? "" : "no ",
9937 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9940 /* Network area print. */
9941 config_write_network_area (vty
, ospf
);
9943 /* Area config print. */
9944 config_write_ospf_area (vty
, ospf
);
9946 /* static neighbor print. */
9947 config_write_ospf_nbr_nbma (vty
, ospf
);
9949 /* Virtual-Link print. */
9950 config_write_virtual_link (vty
, ospf
);
9952 /* Default metric configuration. */
9953 config_write_ospf_default_metric (vty
, ospf
);
9955 /* Distribute-list and default-information print. */
9956 config_write_ospf_distribute (vty
, ospf
);
9958 /* Distance configuration. */
9959 config_write_ospf_distance (vty
, ospf
);
9961 ospf_opaque_config_write_router (vty
, ospf
);
9968 ospf_vty_show_init (void)
9970 /* "show ip ospf" commands. */
9971 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9973 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9975 /* "show ip ospf database" commands. */
9976 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9977 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
9978 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9980 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
9981 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9982 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9984 /* "show ip ospf interface" commands. */
9985 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9987 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9989 /* "show ip ospf neighbor" commands. */
9990 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9991 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9992 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9993 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9994 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9995 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9996 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9998 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
9999 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10000 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10001 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10002 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10003 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10004 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10006 /* "show ip ospf route" commands. */
10007 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
10008 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10010 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10011 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10015 /* ospfd's interface node. */
10016 static struct cmd_node interface_node
=
10023 /* Initialization of OSPF interface. */
10025 ospf_vty_if_init (void)
10027 /* Install interface node. */
10028 install_node (&interface_node
, config_write_interface
);
10030 install_element (CONFIG_NODE
, &interface_cmd
);
10031 install_element (CONFIG_NODE
, &no_interface_cmd
);
10032 install_default (INTERFACE_NODE
);
10034 /* "description" commands. */
10035 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
10036 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
10038 /* "ip ospf authentication" commands. */
10039 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10040 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10041 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
10042 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10043 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10044 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10045 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
10047 /* "ip ospf message-digest-key" commands. */
10048 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_addr_cmd
);
10049 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_addr_cmd
);
10050 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_addr_cmd
);
10051 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_addr_cmd
);
10053 /* "ip ospf cost" commands. */
10054 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_inet4_cmd
);
10055 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_cmd
);
10056 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_inet4_cmd
);
10057 install_element (INTERFACE_NODE
, &no_ospf_cost_inet4_cmd
);
10058 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_cmd
);
10060 /* "ip ospf mtu-ignore" commands. */
10061 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10062 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10064 /* "ip ospf dead-interval" commands. */
10065 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_addr_cmd
);
10066 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
10067 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_addr_cmd
);
10069 /* "ip ospf hello-interval" commands. */
10070 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_addr_cmd
);
10071 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_addr_cmd
);
10073 /* "ip ospf network" commands. */
10074 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
10075 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10076 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
10078 /* "ip ospf priority" commands. */
10079 install_element (INTERFACE_NODE
, &ip_ospf_priority_addr_cmd
);
10080 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_addr_cmd
);
10081 install_element (INTERFACE_NODE
, &no_ospf_priority_addr_cmd
);
10083 /* "ip ospf retransmit-interval" commands. */
10084 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10085 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
10086 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10088 /* "ip ospf transmit-delay" commands. */
10089 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10090 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10091 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_cmd
);
10092 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10094 /* "ip ospf area" commands. */
10095 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
10096 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10097 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_cmd
);
10099 /* These commands are compatibitliy for previous version. */
10100 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10101 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10102 install_element (INTERFACE_NODE
, &ospf_cost_u32_inet4_cmd
);
10103 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10104 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10105 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
10106 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
10107 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10108 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10112 ospf_vty_zebra_init (void)
10114 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
10115 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10116 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10117 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10119 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10120 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10122 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
10123 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10125 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
10126 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
10128 install_element (OSPF_NODE
, &ospf_distance_cmd
);
10129 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
10130 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10131 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
10133 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10134 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10135 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10136 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10140 static struct cmd_node ospf_node
=
10143 "%s(config-router)# ",
10148 ospf_interface_clear (struct interface
*ifp
)
10150 if (!if_is_operative (ifp
)) return;
10152 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
10153 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
10155 ospf_if_reset(ifp
);
10158 DEFUN (clear_ip_ospf_interface
,
10159 clear_ip_ospf_interface_cmd
,
10160 "clear ip ospf interface [IFNAME]",
10163 "OSPF information\n"
10164 "Interface information\n"
10165 "Interface name\n")
10167 int idx_ifname
= 4;
10168 struct interface
*ifp
;
10169 struct listnode
*node
;
10171 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
10173 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
10174 ospf_interface_clear(ifp
);
10176 else /* Interface name is specified. */
10178 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
10179 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
10181 ospf_interface_clear(ifp
);
10184 return CMD_SUCCESS
;
10188 ospf_vty_clear_init (void)
10190 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10194 /* Install OSPF related vty commands. */
10196 ospf_vty_init (void)
10198 /* Install ospf top node. */
10199 install_node (&ospf_node
, ospf_config_write
);
10201 /* "router ospf" commands. */
10202 install_element (CONFIG_NODE
, &router_ospf_cmd
);
10203 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
10206 install_default (OSPF_NODE
);
10208 /* "ospf router-id" commands. */
10209 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
10210 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
10211 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
10213 /* "passive-interface" commands. */
10214 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10215 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10217 /* "ospf abr-type" commands. */
10218 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
10219 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
10221 /* "ospf log-adjacency-changes" commands. */
10222 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10223 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10224 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10225 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10227 /* "ospf rfc1583-compatible" commands. */
10228 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10229 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10230 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10231 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10233 /* "network area" commands. */
10234 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
10235 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
10237 /* "area authentication" commands. */
10238 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
10239 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
10240 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10242 /* "area range" commands. */
10243 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
10244 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
10245 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10246 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
10247 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10248 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10250 /* "area virtual-link" commands. */
10251 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
10252 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
10253 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10254 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
10265 /* "area stub" commands. */
10266 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10267 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
10268 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10269 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
10271 /* "area nssa" commands. */
10272 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
10273 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
10274 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10275 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10276 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10278 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
10279 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10281 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
10282 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10284 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
10285 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10287 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
10288 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10290 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
10291 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10293 /* SPF timer commands */
10294 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10295 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10297 /* LSA timers commands */
10298 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10299 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10300 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
10301 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
10302 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
10303 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
10305 /* refresh timer commands */
10306 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
10307 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10309 /* max-metric commands */
10310 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10311 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10312 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10313 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10314 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10315 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10317 /* reference bandwidth commands */
10318 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10319 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10321 /* "neighbor" commands. */
10322 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
10323 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10324 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
10325 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
10327 /* write multiplier commands */
10328 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
10329 install_element (OSPF_NODE
, &write_multiplier_cmd
);
10330 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10331 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
10333 /* Init interface related vty commands. */
10334 ospf_vty_if_init ();
10336 /* Init zebra related vty commands. */
10337 ospf_vty_zebra_init ();