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
38 #include "ospfd/ospfd.h"
39 #include "ospfd/ospf_asbr.h"
40 #include "ospfd/ospf_lsa.h"
41 #include "ospfd/ospf_lsdb.h"
42 #include "ospfd/ospf_ism.h"
43 #include "ospfd/ospf_interface.h"
44 #include "ospfd/ospf_nsm.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_flood.h"
47 #include "ospfd/ospf_abr.h"
48 #include "ospfd/ospf_spf.h"
49 #include "ospfd/ospf_route.h"
50 #include "ospfd/ospf_zebra.h"
51 /*#include "ospfd/ospf_routemap.h" */
52 #include "ospfd/ospf_vty.h"
53 #include "ospfd/ospf_dump.h"
54 #include "ospfd/ospf_bfd.h"
56 static const char *ospf_network_type_str
[] =
67 /* Utility functions. */
69 ospf_str2area_id (const char *str
, struct in_addr
*area_id
, int *format
)
74 /* match "A.B.C.D". */
75 if (strchr (str
, '.') != NULL
)
77 ret
= inet_aton (str
, area_id
);
80 *format
= OSPF_AREA_ID_FORMAT_ADDRESS
;
82 /* match "<0-4294967295>". */
88 ret
= strtoul (str
, &endptr
, 10);
89 if (*endptr
!= '\0' || errno
|| ret
> UINT32_MAX
)
92 area_id
->s_addr
= htonl (ret
);
93 *format
= OSPF_AREA_ID_FORMAT_DECIMAL
;
101 str2metric (const char *str
, int *metric
)
107 *metric
= strtol (str
, NULL
, 10);
108 if (*metric
< 0 && *metric
> 16777214)
110 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
118 str2metric_type (const char *str
, int *metric_type
)
124 if (strncmp (str
, "1", 1) == 0)
125 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
126 else if (strncmp (str
, "2", 1) == 0)
127 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
135 ospf_oi_count (struct interface
*ifp
)
137 struct route_node
*rn
;
140 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
151 "Enable a routing process\n"
152 "Start OSPF configuration\n")
155 u_short instance
= 0;
157 ospf
= ospf_lookup();
160 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
164 vty
->node
= OSPF_NODE
;
167 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
169 /* The following logic to set the vty->index is in place to be able
170 to ignore the commands which dont belong to this instance. */
171 if (ospf
->instance
!= instance
)
175 if (IS_DEBUG_OSPF_EVENT
)
176 zlog_debug ("Config command 'router ospf %d' received", instance
);
177 ospf
->oi_running
= 1;
179 ospf_router_id_update (ospf
);
186 router_ospf_instance_cmd
,
187 "router ospf <1-65535>",
188 "Enable a routing process\n"
189 "Start OSPF configuration\n"
192 DEFUN (no_router_ospf
,
196 "Enable a routing process\n"
197 "Start OSPF configuration\n")
200 u_short instance
= 0;
203 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
205 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
213 ALIAS (no_router_ospf
,
214 no_router_ospf_instance_cmd
,
215 "no router ospf <1-65535>",
217 "Enable a routing process\n"
218 "Start OSPF configuration\n"
221 DEFUN (ospf_router_id
,
223 "ospf router-id A.B.C.D",
224 "OSPF specific commands\n"
225 "router-id for the OSPF process\n"
226 "OSPF router-id in IP address format\n")
228 struct ospf
*ospf
= vty
->index
;
229 struct listnode
*node
;
230 struct ospf_area
*area
;
231 struct in_addr router_id
;
237 ret
= inet_aton (argv
[0], &router_id
);
240 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
244 ospf
->router_id_static
= router_id
;
246 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
249 vty_out (vty
, "For this router-id change to take effect,"
250 " save config and restart ospfd%s", VTY_NEWLINE
);
254 ospf_router_id_update (ospf
);
259 ALIAS_HIDDEN (ospf_router_id
,
260 ospf_router_id_old_cmd
,
262 "router-id for the OSPF process\n"
263 "OSPF router-id in IP address format\n")
265 DEFUN (no_ospf_router_id
,
266 no_ospf_router_id_cmd
,
269 "OSPF specific commands\n"
270 "router-id for the OSPF process\n")
272 struct ospf
*ospf
= vty
->index
;
273 struct listnode
*node
;
274 struct ospf_area
*area
;
279 ospf
->router_id_static
.s_addr
= 0;
281 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
284 vty_out (vty
, "For this router-id change to take effect,"
285 " save config and restart ospfd%s", VTY_NEWLINE
);
289 ospf_router_id_update (ospf
);
294 ALIAS (no_ospf_router_id
,
295 no_ospf_router_id_val_cmd
,
296 "no ospf router-id A.B.C.D",
298 "OSPF specific commands\n"
299 "router-id for the OSPF process\n"
300 "OSPF router-id in IP address format\n")
303 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
306 struct interface
*ifp
;
307 struct ospf_interface
*oi
;
309 ospf
->passive_interface_default
= newval
;
311 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
314 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
315 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
317 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
319 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
320 UNSET_IF_PARAM (oi
->params
, passive_interface
);
321 /* update multicast memberships */
322 ospf_if_set_multicast(oi
);
327 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
328 struct ospf_if_params
*params
, u_char value
,
333 params
->passive_interface
= value
;
334 if (params
!= IF_DEF_PARAMS (ifp
))
336 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
337 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
339 dflt
= ospf
->passive_interface_default
;
342 SET_IF_PARAM (params
, passive_interface
);
344 UNSET_IF_PARAM (params
, passive_interface
);
346 ospf_free_if_params (ifp
, addr
);
347 ospf_if_update_params (ifp
, addr
);
352 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
353 struct ospf_if_params
*params
, u_char value
)
355 params
->passive_interface
= value
;
356 if (params
== IF_DEF_PARAMS (ifp
))
358 if (value
!= ospf
->passive_interface_default
)
359 SET_IF_PARAM (params
, passive_interface
);
361 UNSET_IF_PARAM (params
, passive_interface
);
365 DEFUN (ospf_passive_interface
,
366 ospf_passive_interface_addr_cmd
,
367 "passive-interface IFNAME A.B.C.D",
368 "Suppress routing updates on an interface\n"
369 "Interface's name\n")
371 struct interface
*ifp
;
372 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
374 struct ospf_if_params
*params
;
375 struct route_node
*rn
;
376 struct ospf
*ospf
= vty
->index
;
383 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
387 ifp
= if_get_by_name (argv
[0]);
389 params
= IF_DEF_PARAMS (ifp
);
393 ret
= inet_aton(argv
[1], &addr
);
396 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
401 params
= ospf_get_if_params (ifp
, addr
);
402 ospf_if_update_params (ifp
, addr
);
403 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
404 OSPF_IF_PASSIVE
, addr
);
407 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
409 /* XXX We should call ospf_if_set_multicast on exactly those
410 * interfaces for which the passive property changed. It is too much
411 * work to determine this set, so we do this for every interface.
412 * This is safe and reasonable because ospf_if_set_multicast uses a
413 * record of joined groups to avoid systems calls if the desired
414 * memberships match the current memership.
417 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
419 struct ospf_interface
*oi
= rn
->info
;
421 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
422 ospf_if_set_multicast(oi
);
425 * XXX It is not clear what state transitions the interface needs to
426 * undergo when going from active to passive. Fixing this will
427 * require precise identification of interfaces having such a
434 ALIAS (ospf_passive_interface
,
435 ospf_passive_interface_cmd
,
436 "passive-interface IFNAME",
437 "Suppress routing updates on an interface\n"
438 "Interface's name\n")
440 ALIAS (ospf_passive_interface
,
441 ospf_passive_interface_default_cmd
,
442 "passive-interface default",
443 "Suppress routing updates on an interface\n"
444 "Suppress routing updates on interfaces by default\n")
446 DEFUN (no_ospf_passive_interface
,
447 no_ospf_passive_interface_addr_cmd
,
448 "no passive-interface IFNAME A.B.C.D",
450 "Allow routing updates on an interface\n"
451 "Interface's name\n")
453 struct interface
*ifp
;
454 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
455 struct ospf_if_params
*params
;
457 struct route_node
*rn
;
458 struct ospf
*ospf
= vty
->index
;
465 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
469 ifp
= if_get_by_name (argv
[0]);
471 params
= IF_DEF_PARAMS (ifp
);
475 ret
= inet_aton(argv
[1], &addr
);
478 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
483 params
= ospf_lookup_if_params (ifp
, addr
);
486 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
489 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
491 /* XXX We should call ospf_if_set_multicast on exactly those
492 * interfaces for which the passive property changed. It is too much
493 * work to determine this set, so we do this for every interface.
494 * This is safe and reasonable because ospf_if_set_multicast uses a
495 * record of joined groups to avoid systems calls if the desired
496 * memberships match the current memership.
498 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
500 struct ospf_interface
*oi
= rn
->info
;
502 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
503 ospf_if_set_multicast(oi
);
509 ALIAS (no_ospf_passive_interface
,
510 no_ospf_passive_interface_cmd
,
511 "no passive-interface IFNAME",
513 "Allow routing updates on an interface\n"
514 "Interface's name\n")
516 ALIAS (no_ospf_passive_interface
,
517 no_ospf_passive_interface_default_cmd
,
518 "no passive-interface default",
520 "Allow routing updates on an interface\n"
521 "Allow routing updates on interfaces by default\n")
523 DEFUN (ospf_network_area
,
524 ospf_network_area_cmd
,
525 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
526 "Enable routing on an IP network\n"
527 "OSPF network prefix\n"
528 "Set the OSPF area ID\n"
529 "OSPF area ID in IP address format\n"
530 "OSPF area ID as a decimal value\n")
532 struct ospf
*ospf
= vty
->index
;
533 struct prefix_ipv4 p
;
534 struct in_addr area_id
;
542 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
547 if (ospf
->if_ospf_cli_count
> 0)
549 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
554 /* Get network prefix and Area ID. */
555 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[0]);
556 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[1]);
558 ret
= ospf_network_set (ospf
, &p
, area_id
);
561 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
568 DEFUN (no_ospf_network_area
,
569 no_ospf_network_area_cmd
,
570 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
572 "Enable routing on an IP network\n"
573 "OSPF network prefix\n"
574 "Set the OSPF area ID\n"
575 "OSPF area ID in IP address format\n"
576 "OSPF area ID as a decimal value\n")
578 struct ospf
*ospf
= (struct ospf
*) vty
->index
;
579 struct prefix_ipv4 p
;
580 struct in_addr area_id
;
588 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
593 /* Get network prefix and Area ID. */
594 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[0]);
595 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[1]);
597 ret
= ospf_network_unset (ospf
, &p
, area_id
);
600 vty_out (vty
, "Can't find specified network area configuration.%s",
609 DEFUN (ospf_area_range
,
611 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
612 "OSPF area parameters\n"
613 "OSPF area ID in IP address format\n"
614 "OSPF area ID as a decimal value\n"
615 "Summarize routes matching address/mask (border routers only)\n"
616 "Area range prefix\n")
618 struct ospf
*ospf
= vty
->index
;
619 struct prefix_ipv4 p
;
620 struct in_addr area_id
;
627 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
628 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
630 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
633 VTY_GET_INTEGER ("range cost", cost
, argv
[2]);
634 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
640 ALIAS (ospf_area_range
,
641 ospf_area_range_advertise_cmd
,
642 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
643 "OSPF area parameters\n"
644 "OSPF area ID in IP address format\n"
645 "OSPF area ID as a decimal value\n"
646 "OSPF area range for route advertise (default)\n"
647 "Area range prefix\n"
648 "Advertise this range (default)\n")
650 ALIAS (ospf_area_range
,
651 ospf_area_range_cost_cmd
,
652 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
653 "OSPF area parameters\n"
654 "OSPF area ID in IP address format\n"
655 "OSPF area ID as a decimal value\n"
656 "Summarize routes matching address/mask (border routers only)\n"
657 "Area range prefix\n"
658 "User specified metric for this range\n"
659 "Advertised metric for this range\n")
661 ALIAS (ospf_area_range
,
662 ospf_area_range_advertise_cost_cmd
,
663 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
664 "OSPF area parameters\n"
665 "OSPF area ID in IP address format\n"
666 "OSPF area ID as a decimal value\n"
667 "Summarize routes matching address/mask (border routers only)\n"
668 "Area range prefix\n"
669 "Advertise this range (default)\n"
670 "User specified metric for this range\n"
671 "Advertised metric for this range\n")
673 DEFUN (ospf_area_range_not_advertise
,
674 ospf_area_range_not_advertise_cmd
,
675 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
676 "OSPF area parameters\n"
677 "OSPF area ID in IP address format\n"
678 "OSPF area ID as a decimal value\n"
679 "Summarize routes matching address/mask (border routers only)\n"
680 "Area range prefix\n"
681 "DoNotAdvertise this range\n")
683 struct ospf
*ospf
= vty
->index
;
684 struct prefix_ipv4 p
;
685 struct in_addr area_id
;
691 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
692 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
694 ospf_area_range_set (ospf
, area_id
, &p
, 0);
699 DEFUN (no_ospf_area_range
,
700 no_ospf_area_range_cmd
,
701 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
703 "OSPF area parameters\n"
704 "OSPF area ID in IP address format\n"
705 "OSPF area ID as a decimal value\n"
706 "Summarize routes matching address/mask (border routers only)\n"
707 "Area range prefix\n")
709 struct ospf
*ospf
= vty
->index
;
710 struct prefix_ipv4 p
;
711 struct in_addr area_id
;
717 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
718 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
720 ospf_area_range_unset (ospf
, area_id
, &p
);
725 ALIAS (no_ospf_area_range
,
726 no_ospf_area_range_advertise_cmd
,
727 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
729 "OSPF area parameters\n"
730 "OSPF area ID in IP address format\n"
731 "OSPF area ID as a decimal value\n"
732 "Summarize routes matching address/mask (border routers only)\n"
733 "Area range prefix\n"
734 "Advertise this range (default)\n"
735 "DoNotAdvertise this range\n")
737 ALIAS (no_ospf_area_range
,
738 no_ospf_area_range_cost_cmd
,
739 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
741 "OSPF area parameters\n"
742 "OSPF area ID in IP address format\n"
743 "OSPF area ID as a decimal value\n"
744 "Summarize routes matching address/mask (border routers only)\n"
745 "Area range prefix\n"
746 "User specified metric for this range\n"
747 "Advertised metric for this range\n")
749 ALIAS (no_ospf_area_range
,
750 no_ospf_area_range_advertise_cost_cmd
,
751 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
753 "OSPF area parameters\n"
754 "OSPF area ID in IP address format\n"
755 "OSPF area ID as a decimal value\n"
756 "Summarize routes matching address/mask (border routers only)\n"
757 "Area range prefix\n"
758 "Advertise this range (default)\n"
759 "User specified metric for this range\n"
760 "Advertised metric for this range\n")
762 DEFUN (ospf_area_range_substitute
,
763 ospf_area_range_substitute_cmd
,
764 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
765 "OSPF area parameters\n"
766 "OSPF area ID in IP address format\n"
767 "OSPF area ID as a decimal value\n"
768 "Summarize routes matching address/mask (border routers only)\n"
769 "Area range prefix\n"
770 "Announce area range as another prefix\n"
771 "Network prefix to be announced instead of range\n")
773 struct ospf
*ospf
= vty
->index
;
774 struct prefix_ipv4 p
, s
;
775 struct in_addr area_id
;
781 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
782 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
783 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[2]);
785 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
790 DEFUN (no_ospf_area_range_substitute
,
791 no_ospf_area_range_substitute_cmd
,
792 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
794 "OSPF area parameters\n"
795 "OSPF area ID in IP address format\n"
796 "OSPF area ID as a decimal value\n"
797 "Summarize routes matching address/mask (border routers only)\n"
798 "Area range prefix\n"
799 "Announce area range as another prefix\n"
800 "Network prefix to be announced instead of range\n")
802 struct ospf
*ospf
= vty
->index
;
803 struct prefix_ipv4 p
, s
;
804 struct in_addr area_id
;
810 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
811 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
812 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[2]);
814 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
820 /* Command Handler Logic in VLink stuff is delicate!!
822 ALTER AT YOUR OWN RISK!!!!
824 Various dummy values are used to represent 'NoChange' state for
825 VLink configuration NOT being changed by a VLink command, and
826 special syntax is used within the command strings so that the
827 typed in command verbs can be seen in the configuration command
828 bacckend handler. This is to drastically reduce the verbeage
829 required to coe up with a reasonably compatible Cisco VLink command
831 - Matthew Grant <grantma@anathoth.gen.nz>
832 Wed, 21 Feb 2001 15:13:52 +1300
836 /* Configuration data for virtual links
838 struct ospf_vl_config_data
{
839 struct vty
*vty
; /* vty stuff */
840 struct in_addr area_id
; /* area ID from command line */
841 int format
; /* command line area ID format */
842 struct in_addr vl_peer
; /* command line vl_peer */
843 int auth_type
; /* Authehntication type, if given */
844 char *auth_key
; /* simple password if present */
845 int crypto_key_id
; /* Cryptographic key ID */
846 char *md5_key
; /* MD5 authentication key */
847 int hello_interval
; /* Obvious what these are... */
848 int retransmit_interval
;
854 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
857 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
858 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
859 vl_config
->vty
= vty
;
862 static struct ospf_vl_data
*
863 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
865 struct ospf_area
*area
;
866 struct ospf_vl_data
*vl_data
;
868 struct in_addr area_id
;
870 vty
= vl_config
->vty
;
871 area_id
= vl_config
->area_id
;
873 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
876 "Configuring VLs over the backbone is not allowed%s",
880 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
882 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
884 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
885 vty_out (vty
, "Area %s is %s%s",
887 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
890 vty_out (vty
, "Area %ld is %s%s",
891 (u_long
)ntohl (area_id
.s_addr
),
892 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
897 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
899 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
900 if (vl_data
->vl_oi
== NULL
)
902 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
903 ospf_vl_add (ospf
, vl_data
);
904 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
912 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
913 struct ospf_vl_config_data
*vl_config
)
915 struct crypt_key
*ck
;
917 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
919 vty
= vl_config
->vty
;
921 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
923 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
924 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
927 if (vl_config
->auth_key
)
929 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
930 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
931 OSPF_AUTH_SIMPLE_SIZE
);
933 else if (vl_config
->md5_key
)
935 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
938 vty_out (vty
, "OSPF: Key %d already exists%s",
939 vl_config
->crypto_key_id
, VTY_NEWLINE
);
942 ck
= ospf_crypt_key_new ();
943 ck
->key_id
= vl_config
->crypto_key_id
;
944 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
945 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
947 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
949 else if (vl_config
->crypto_key_id
!= 0)
953 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
954 vl_config
->crypto_key_id
) == NULL
)
956 vty_out (vty
, "OSPF: Key %d does not exist%s",
957 vl_config
->crypto_key_id
, VTY_NEWLINE
);
961 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
969 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
970 struct ospf_vl_config_data
*vl_config
)
972 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
973 /* Virtual Link data initialised to defaults, so only set
975 if (vl_config
->hello_interval
)
977 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
978 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
981 if (vl_config
->dead_interval
)
983 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
984 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
987 if (vl_config
->retransmit_interval
)
989 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
990 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
993 if (vl_config
->transmit_delay
)
995 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
996 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
1004 /* The business end of all of the above */
1006 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
1008 struct ospf_vl_data
*vl_data
;
1011 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
1015 /* Process this one first as it can have a fatal result, which can
1016 only logically occur if the virtual link exists already
1017 Thus a command error does not result in a change to the
1018 running configuration such as unexpectedly altered timer
1020 ret
= ospf_vl_set_security (vl_data
, vl_config
);
1021 if (ret
!= CMD_SUCCESS
)
1024 /* Set any time based parameters, these area already range checked */
1026 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
1027 if (ret
!= CMD_SUCCESS
)
1034 /* This stuff exists to make specifying all the alias commands A LOT simpler
1036 #define VLINK_HELPSTR_IPADDR \
1037 "OSPF area parameters\n" \
1038 "OSPF area ID in IP address format\n" \
1039 "OSPF area ID as a decimal value\n" \
1040 "Configure a virtual link\n" \
1041 "Router ID of the remote ABR\n"
1043 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1044 "Enable authentication on this virtual link\n" \
1047 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1048 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1049 "Use null authentication\n" \
1050 "Use message-digest authentication\n"
1052 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
1053 "Time between HELLO packets\n" \
1054 "Time between retransmitting lost link state advertisements\n" \
1055 "Link state transmit delay\n" \
1056 "Interval after which a neighbor is declared dead\n"
1058 #define VLINK_HELPSTR_TIME_PARAM \
1059 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1062 #define VLINK_HELPSTR_AUTH_SIMPLE \
1063 "Authentication password (key)\n" \
1064 "The OSPF password (key)"
1066 #define VLINK_HELPSTR_AUTH_MD5 \
1067 "Message digest authentication password (key)\n" \
1070 "Use MD5 algorithm\n" \
1071 "The OSPF password (key)"
1073 DEFUN (ospf_area_vlink
,
1074 ospf_area_vlink_cmd
,
1075 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1076 VLINK_HELPSTR_IPADDR
)
1078 struct ospf
*ospf
= vty
->index
;
1079 struct ospf_vl_config_data vl_config
;
1080 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1081 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1088 ospf_vl_config_data_init(&vl_config
, vty
);
1090 /* Read off first 2 parameters and check them */
1091 ret
= ospf_str2area_id (argv
[0], &vl_config
.area_id
, &vl_config
.format
);
1094 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1098 ret
= inet_aton (argv
[1], &vl_config
.vl_peer
);
1101 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1108 /* Thats all folks! - BUGS B. strikes again!!!*/
1110 return ospf_vl_set (ospf
, &vl_config
);
1113 /* Deal with other parameters */
1114 for (i
=2; i
< argc
; i
++)
1117 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1123 if (i
> 2 || strncmp (argv
[i
], "authentication-", 15) == 0)
1125 /* authentication-key - this option can occur anywhere on
1126 command line. At start of command line
1127 must check for authentication option. */
1128 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1129 strncpy (auth_key
, argv
[i
+1], OSPF_AUTH_SIMPLE_SIZE
);
1130 vl_config
.auth_key
= auth_key
;
1133 else if (strncmp (argv
[i
], "authentication", 14) == 0)
1135 /* authentication - this option can only occur at start
1137 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1140 if (strncmp (argv
[i
+1], "n", 1) == 0)
1142 /* "authentication null" */
1143 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1146 else if (strncmp (argv
[i
+1], "m", 1) == 0
1147 && strcmp (argv
[i
+1], "message-digest-") != 0)
1149 /* "authentication message-digest" */
1150 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1158 /* message-digest-key */
1160 vl_config
.crypto_key_id
= strtol (argv
[i
], NULL
, 10);
1161 if (vl_config
.crypto_key_id
< 0)
1164 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1165 strncpy (md5_key
, argv
[i
], OSPF_AUTH_MD5_SIZE
);
1166 vl_config
.md5_key
= md5_key
;
1170 /* Hello interval */
1172 vl_config
.hello_interval
= strtol (argv
[i
], NULL
, 10);
1173 if (vl_config
.hello_interval
< 0)
1178 /* Retransmit Interval */
1180 vl_config
.retransmit_interval
= strtol (argv
[i
], NULL
, 10);
1181 if (vl_config
.retransmit_interval
< 0)
1186 /* Transmit Delay */
1188 vl_config
.transmit_delay
= strtol (argv
[i
], NULL
, 10);
1189 if (vl_config
.transmit_delay
< 0)
1196 vl_config
.dead_interval
= strtol (argv
[i
], NULL
, 10);
1197 if (vl_config
.dead_interval
< 0)
1204 /* Action configuration */
1206 return ospf_vl_set (ospf
, &vl_config
);
1210 DEFUN (no_ospf_area_vlink
,
1211 no_ospf_area_vlink_cmd
,
1212 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1214 VLINK_HELPSTR_IPADDR
)
1216 struct ospf
*ospf
= vty
->index
;
1217 struct ospf_area
*area
;
1218 struct ospf_vl_config_data vl_config
;
1219 struct ospf_vl_data
*vl_data
= NULL
;
1220 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1227 ospf_vl_config_data_init(&vl_config
, vty
);
1229 ret
= ospf_str2area_id (argv
[0], &vl_config
.area_id
, &format
);
1232 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1236 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1239 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1243 ret
= inet_aton (argv
[1], &vl_config
.vl_peer
);
1246 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1253 /* Basic VLink no command */
1254 /* Thats all folks! - BUGS B. strikes again!!!*/
1255 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1256 ospf_vl_delete (ospf
, vl_data
);
1258 ospf_area_check_free (ospf
, vl_config
.area_id
);
1263 /* If we are down here, we are reseting parameters */
1265 /* Deal with other parameters */
1266 for (i
=2; i
< argc
; i
++)
1268 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1274 if (i
> 2 || strncmp (argv
[i
], "authentication-", 15) == 0)
1276 /* authentication-key - this option can occur anywhere on
1277 command line. At start of command line
1278 must check for authentication option. */
1279 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1280 vl_config
.auth_key
= auth_key
;
1282 else if (strncmp (argv
[i
], "authentication", 14) == 0)
1284 /* authentication - this option can only occur at start
1286 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1291 /* message-digest-key */
1292 /* Delete one key */
1296 vl_config
.crypto_key_id
= strtol (argv
[i
], NULL
, 10);
1297 if (vl_config
.crypto_key_id
< 0)
1299 vl_config
.md5_key
= NULL
;
1306 /* Hello interval */
1307 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1311 /* Retransmit Interval */
1312 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1316 /* Transmit Delay */
1317 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1323 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1329 /* Action configuration */
1331 return ospf_vl_set (ospf
, &vl_config
);
1334 ALIAS (ospf_area_vlink
,
1335 ospf_area_vlink_param1_cmd
,
1336 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1337 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1338 VLINK_HELPSTR_IPADDR
1339 VLINK_HELPSTR_TIME_PARAM
)
1341 ALIAS (no_ospf_area_vlink
,
1342 no_ospf_area_vlink_param1_cmd
,
1343 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1344 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1346 VLINK_HELPSTR_IPADDR
1347 VLINK_HELPSTR_TIME_PARAM
)
1349 ALIAS (ospf_area_vlink
,
1350 ospf_area_vlink_param2_cmd
,
1351 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1352 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1353 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1354 VLINK_HELPSTR_IPADDR
1355 VLINK_HELPSTR_TIME_PARAM
1356 VLINK_HELPSTR_TIME_PARAM
)
1358 ALIAS (no_ospf_area_vlink
,
1359 no_ospf_area_vlink_param2_cmd
,
1360 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1361 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1362 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1364 VLINK_HELPSTR_IPADDR
1365 VLINK_HELPSTR_TIME_PARAM
1366 VLINK_HELPSTR_TIME_PARAM
)
1368 ALIAS (ospf_area_vlink
,
1369 ospf_area_vlink_param3_cmd
,
1370 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1371 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1372 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1373 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1374 VLINK_HELPSTR_IPADDR
1375 VLINK_HELPSTR_TIME_PARAM
1376 VLINK_HELPSTR_TIME_PARAM
1377 VLINK_HELPSTR_TIME_PARAM
)
1379 ALIAS (no_ospf_area_vlink
,
1380 no_ospf_area_vlink_param3_cmd
,
1381 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1382 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1383 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1384 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1386 VLINK_HELPSTR_IPADDR
1387 VLINK_HELPSTR_TIME_PARAM
1388 VLINK_HELPSTR_TIME_PARAM
1389 VLINK_HELPSTR_TIME_PARAM
)
1391 ALIAS (ospf_area_vlink
,
1392 ospf_area_vlink_param4_cmd
,
1393 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1394 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1395 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1396 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1397 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1398 VLINK_HELPSTR_IPADDR
1399 VLINK_HELPSTR_TIME_PARAM
1400 VLINK_HELPSTR_TIME_PARAM
1401 VLINK_HELPSTR_TIME_PARAM
1402 VLINK_HELPSTR_TIME_PARAM
)
1404 ALIAS (no_ospf_area_vlink
,
1405 no_ospf_area_vlink_param4_cmd
,
1406 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1407 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1408 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1409 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1410 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1412 VLINK_HELPSTR_IPADDR
1413 VLINK_HELPSTR_TIME_PARAM
1414 VLINK_HELPSTR_TIME_PARAM
1415 VLINK_HELPSTR_TIME_PARAM
1416 VLINK_HELPSTR_TIME_PARAM
)
1418 ALIAS (ospf_area_vlink
,
1419 ospf_area_vlink_authtype_args_cmd
,
1420 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1421 "(authentication|) (message-digest|null)",
1422 VLINK_HELPSTR_IPADDR
1423 VLINK_HELPSTR_AUTHTYPE_ALL
)
1425 ALIAS (no_ospf_area_vlink
,
1426 no_ospf_area_vlink_authtype_args_cmd
,
1427 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1428 "(authentication|) (message-digest|null)",
1430 VLINK_HELPSTR_IPADDR
1431 VLINK_HELPSTR_AUTHTYPE_ALL
)
1433 ALIAS (ospf_area_vlink
,
1434 ospf_area_vlink_authtype_cmd
,
1435 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1436 "(authentication|)",
1437 VLINK_HELPSTR_IPADDR
1438 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1440 ALIAS (no_ospf_area_vlink
,
1441 no_ospf_area_vlink_authtype_cmd
,
1442 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1443 "(authentication|)",
1445 VLINK_HELPSTR_IPADDR
1446 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1448 ALIAS (ospf_area_vlink
,
1449 ospf_area_vlink_md5_cmd
,
1450 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1451 "(message-digest-key|) <1-255> md5 KEY",
1452 VLINK_HELPSTR_IPADDR
1453 VLINK_HELPSTR_AUTH_MD5
)
1455 ALIAS (no_ospf_area_vlink
,
1456 no_ospf_area_vlink_md5_cmd
,
1457 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1458 "(message-digest-key|) <1-255> md5 KEY",
1460 VLINK_HELPSTR_IPADDR
1461 VLINK_HELPSTR_AUTH_MD5
)
1463 ALIAS (ospf_area_vlink
,
1464 ospf_area_vlink_authkey_cmd
,
1465 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1466 "(authentication-key|) AUTH_KEY",
1467 VLINK_HELPSTR_IPADDR
1468 VLINK_HELPSTR_AUTH_SIMPLE
)
1470 ALIAS (no_ospf_area_vlink
,
1471 no_ospf_area_vlink_authkey_cmd
,
1472 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1473 "(authentication-key|) AUTH_KEY",
1475 VLINK_HELPSTR_IPADDR
1476 VLINK_HELPSTR_AUTH_SIMPLE
)
1478 ALIAS (ospf_area_vlink
,
1479 ospf_area_vlink_authtype_args_authkey_cmd
,
1480 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1481 "(authentication|) (message-digest|null) "
1482 "(authentication-key|) AUTH_KEY",
1483 VLINK_HELPSTR_IPADDR
1484 VLINK_HELPSTR_AUTHTYPE_ALL
1485 VLINK_HELPSTR_AUTH_SIMPLE
)
1487 ALIAS (no_ospf_area_vlink
,
1488 no_ospf_area_vlink_authtype_args_authkey_cmd
,
1489 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1490 "(authentication|) (message-digest|null) "
1491 "(authentication-key|) AUTH_KEY",
1493 VLINK_HELPSTR_IPADDR
1494 VLINK_HELPSTR_AUTHTYPE_ALL
1495 VLINK_HELPSTR_AUTH_SIMPLE
)
1497 ALIAS (ospf_area_vlink
,
1498 ospf_area_vlink_authtype_authkey_cmd
,
1499 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1500 "(authentication|) "
1501 "(authentication-key|) AUTH_KEY",
1502 VLINK_HELPSTR_IPADDR
1503 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1504 VLINK_HELPSTR_AUTH_SIMPLE
)
1506 ALIAS (no_ospf_area_vlink
,
1507 no_ospf_area_vlink_authtype_authkey_cmd
,
1508 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1509 "(authentication|) "
1510 "(authentication-key|) AUTH_KEY",
1512 VLINK_HELPSTR_IPADDR
1513 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1514 VLINK_HELPSTR_AUTH_SIMPLE
)
1516 ALIAS (ospf_area_vlink
,
1517 ospf_area_vlink_authtype_args_md5_cmd
,
1518 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1519 "(authentication|) (message-digest|null) "
1520 "(message-digest-key|) <1-255> md5 KEY",
1521 VLINK_HELPSTR_IPADDR
1522 VLINK_HELPSTR_AUTHTYPE_ALL
1523 VLINK_HELPSTR_AUTH_MD5
)
1525 ALIAS (no_ospf_area_vlink
,
1526 no_ospf_area_vlink_authtype_args_md5_cmd
,
1527 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1528 "(authentication|) (message-digest|null) "
1529 "(message-digest-key|) <1-255> md5 KEY",
1531 VLINK_HELPSTR_IPADDR
1532 VLINK_HELPSTR_AUTHTYPE_ALL
1533 VLINK_HELPSTR_AUTH_MD5
)
1535 ALIAS (ospf_area_vlink
,
1536 ospf_area_vlink_authtype_md5_cmd
,
1537 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1538 "(authentication|) "
1539 "(message-digest-key|) <1-255> md5 KEY",
1540 VLINK_HELPSTR_IPADDR
1541 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1542 VLINK_HELPSTR_AUTH_MD5
)
1544 ALIAS (no_ospf_area_vlink
,
1545 no_ospf_area_vlink_authtype_md5_cmd
,
1546 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1547 "(authentication|) "
1548 "(message-digest-key|) <1-255> md5 KEY",
1550 VLINK_HELPSTR_IPADDR
1551 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1552 VLINK_HELPSTR_AUTH_MD5
)
1555 DEFUN (ospf_area_shortcut
,
1556 ospf_area_shortcut_cmd
,
1557 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1558 "OSPF area parameters\n"
1559 "OSPF area ID in IP address format\n"
1560 "OSPF area ID as a decimal value\n"
1561 "Configure the area's shortcutting mode\n"
1562 "Set default shortcutting behavior\n"
1563 "Enable shortcutting through the area\n"
1564 "Disable shortcutting through the area\n")
1566 struct ospf
*ospf
= vty
->index
;
1567 struct ospf_area
*area
;
1568 struct in_addr area_id
;
1575 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1577 area
= ospf_area_get (ospf
, area_id
, format
);
1579 if (strncmp (argv
[1], "de", 2) == 0)
1580 mode
= OSPF_SHORTCUT_DEFAULT
;
1581 else if (strncmp (argv
[1], "di", 2) == 0)
1582 mode
= OSPF_SHORTCUT_DISABLE
;
1583 else if (strncmp (argv
[1], "e", 1) == 0)
1584 mode
= OSPF_SHORTCUT_ENABLE
;
1588 ospf_area_shortcut_set (ospf
, area
, mode
);
1590 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1591 vty_out (vty
, "Shortcut area setting will take effect "
1592 "only when the router is configured as Shortcut ABR%s",
1598 DEFUN (no_ospf_area_shortcut
,
1599 no_ospf_area_shortcut_cmd
,
1600 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1602 "OSPF area parameters\n"
1603 "OSPF area ID in IP address format\n"
1604 "OSPF area ID as a decimal value\n"
1605 "Deconfigure the area's shortcutting mode\n"
1606 "Deconfigure enabled shortcutting through the area\n"
1607 "Deconfigure disabled shortcutting through the area\n")
1609 struct ospf
*ospf
= vty
->index
;
1610 struct ospf_area
*area
;
1611 struct in_addr area_id
;
1617 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1619 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1623 ospf_area_shortcut_unset (ospf
, area
);
1629 DEFUN (ospf_area_stub
,
1631 "area (A.B.C.D|<0-4294967295>) stub",
1632 "OSPF area parameters\n"
1633 "OSPF area ID in IP address format\n"
1634 "OSPF area ID as a decimal value\n"
1635 "Configure OSPF area as stub\n")
1637 struct ospf
*ospf
= vty
->index
;
1638 struct in_addr area_id
;
1644 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1646 ret
= ospf_area_stub_set (ospf
, area_id
);
1649 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1654 ospf_area_no_summary_unset (ospf
, area_id
);
1659 DEFUN (ospf_area_stub_no_summary
,
1660 ospf_area_stub_no_summary_cmd
,
1661 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1662 "OSPF stub parameters\n"
1663 "OSPF area ID in IP address format\n"
1664 "OSPF area ID as a decimal value\n"
1665 "Configure OSPF area as stub\n"
1666 "Do not inject inter-area routes into stub\n")
1668 struct ospf
*ospf
= vty
->index
;
1669 struct in_addr area_id
;
1675 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1677 ret
= ospf_area_stub_set (ospf
, area_id
);
1680 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1685 ospf_area_no_summary_set (ospf
, area_id
);
1690 DEFUN (no_ospf_area_stub
,
1691 no_ospf_area_stub_cmd
,
1692 "no area (A.B.C.D|<0-4294967295>) stub",
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Configure OSPF area as stub\n")
1699 struct ospf
*ospf
= vty
->index
;
1700 struct in_addr area_id
;
1706 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1708 ospf_area_stub_unset (ospf
, area_id
);
1709 ospf_area_no_summary_unset (ospf
, area_id
);
1714 DEFUN (no_ospf_area_stub_no_summary
,
1715 no_ospf_area_stub_no_summary_cmd
,
1716 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
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 stub\n"
1722 "Do not inject inter-area routes into area\n")
1724 struct ospf
*ospf
= vty
->index
;
1725 struct in_addr area_id
;
1731 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1732 ospf_area_no_summary_unset (ospf
, area_id
);
1738 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, const char *argv
[],
1741 struct ospf
*ospf
= vty
->index
;
1742 struct in_addr area_id
;
1748 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1750 ret
= ospf_area_nssa_set (ospf
, area_id
);
1753 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1760 if (strncmp (argv
[1], "translate-c", 11) == 0)
1761 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1762 OSPF_NSSA_ROLE_CANDIDATE
);
1763 else if (strncmp (argv
[1], "translate-n", 11) == 0)
1764 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1765 OSPF_NSSA_ROLE_NEVER
);
1766 else if (strncmp (argv
[1], "translate-a", 11) == 0)
1767 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1768 OSPF_NSSA_ROLE_ALWAYS
);
1772 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1773 OSPF_NSSA_ROLE_CANDIDATE
);
1777 ospf_area_no_summary_set (ospf
, area_id
);
1779 ospf_area_no_summary_unset (ospf
, area_id
);
1781 ospf_schedule_abr_task (ospf
);
1786 DEFUN (ospf_area_nssa_translate_no_summary
,
1787 ospf_area_nssa_translate_no_summary_cmd
,
1788 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
1789 "OSPF area parameters\n"
1790 "OSPF area ID in IP address format\n"
1791 "OSPF area ID as a decimal value\n"
1792 "Configure OSPF area as nssa\n"
1793 "Configure NSSA-ABR for translate election (default)\n"
1794 "Configure NSSA-ABR to never translate\n"
1795 "Configure NSSA-ABR to always translate\n"
1796 "Do not inject inter-area routes into nssa\n")
1798 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1801 DEFUN (ospf_area_nssa_translate
,
1802 ospf_area_nssa_translate_cmd
,
1803 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1804 "OSPF area parameters\n"
1805 "OSPF area ID in IP address format\n"
1806 "OSPF area ID as a decimal value\n"
1807 "Configure OSPF area as nssa\n"
1808 "Configure NSSA-ABR for translate election (default)\n"
1809 "Configure NSSA-ABR to never translate\n"
1810 "Configure NSSA-ABR to always translate\n")
1812 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1815 DEFUN (ospf_area_nssa
,
1817 "area (A.B.C.D|<0-4294967295>) nssa",
1818 "OSPF area parameters\n"
1819 "OSPF area ID in IP address format\n"
1820 "OSPF area ID as a decimal value\n"
1821 "Configure OSPF area as nssa\n")
1823 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1826 DEFUN (ospf_area_nssa_no_summary
,
1827 ospf_area_nssa_no_summary_cmd
,
1828 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1829 "OSPF area parameters\n"
1830 "OSPF area ID in IP address format\n"
1831 "OSPF area ID as a decimal value\n"
1832 "Configure OSPF area as nssa\n"
1833 "Do not inject inter-area routes into nssa\n")
1835 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1838 DEFUN (no_ospf_area_nssa
,
1839 no_ospf_area_nssa_cmd
,
1840 "no area (A.B.C.D|<0-4294967295>) nssa",
1842 "OSPF area parameters\n"
1843 "OSPF area ID in IP address format\n"
1844 "OSPF area ID as a decimal value\n"
1845 "Configure OSPF area as nssa\n")
1847 struct ospf
*ospf
= vty
->index
;
1848 struct in_addr area_id
;
1854 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1856 ospf_area_nssa_unset (ospf
, area_id
);
1857 ospf_area_no_summary_unset (ospf
, area_id
);
1859 ospf_schedule_abr_task (ospf
);
1864 ALIAS (no_ospf_area_nssa
,
1865 no_ospf_area_nssa_no_summary_cmd
,
1866 "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}",
1868 "OSPF area parameters\n"
1869 "OSPF area ID in IP address format\n"
1870 "OSPF area ID as a decimal value\n"
1871 "Configure OSPF area as nssa\n"
1872 "Configure NSSA-ABR for translate election (default)\n"
1873 "Configure NSSA-ABR to never translate\n"
1874 "Configure NSSA-ABR to always translate\n"
1875 "Do not inject inter-area routes into nssa\n")
1877 DEFUN (ospf_area_default_cost
,
1878 ospf_area_default_cost_cmd
,
1879 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1880 "OSPF area parameters\n"
1881 "OSPF area ID in IP address format\n"
1882 "OSPF area ID as a decimal value\n"
1883 "Set the summary-default cost of a NSSA or stub area\n"
1884 "Stub's advertised default summary cost\n")
1886 struct ospf
*ospf
= vty
->index
;
1887 struct ospf_area
*area
;
1888 struct in_addr area_id
;
1891 struct prefix_ipv4 p
;
1896 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1897 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[1], 0, 16777215);
1899 area
= ospf_area_get (ospf
, area_id
, format
);
1901 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1903 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1907 area
->default_cost
= cost
;
1910 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1912 if (IS_DEBUG_OSPF_EVENT
)
1913 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1914 "announcing 0.0.0.0/0 to area %s",
1915 inet_ntoa (area
->area_id
));
1916 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1921 DEFUN (no_ospf_area_default_cost
,
1922 no_ospf_area_default_cost_cmd
,
1923 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1925 "OSPF area parameters\n"
1926 "OSPF area ID in IP address format\n"
1927 "OSPF area ID as a decimal value\n"
1928 "Set the summary-default cost of a NSSA or stub area\n"
1929 "Stub's advertised default summary cost\n")
1931 struct ospf
*ospf
= vty
->index
;
1932 struct ospf_area
*area
;
1933 struct in_addr area_id
;
1935 struct prefix_ipv4 p
;
1940 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1941 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[1], 0, OSPF_LS_INFINITY
);
1943 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1947 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1949 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1953 area
->default_cost
= 1;
1956 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1958 if (IS_DEBUG_OSPF_EVENT
)
1959 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1960 "announcing 0.0.0.0/0 to area %s",
1961 inet_ntoa (area
->area_id
));
1962 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1965 ospf_area_check_free (ospf
, area_id
);
1970 DEFUN (ospf_area_export_list
,
1971 ospf_area_export_list_cmd
,
1972 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1973 "OSPF area parameters\n"
1974 "OSPF area ID in IP address format\n"
1975 "OSPF area ID as a decimal value\n"
1976 "Set the filter for networks announced to other areas\n"
1977 "Name of the access-list\n")
1979 struct ospf
*ospf
= vty
->index
;
1980 struct ospf_area
*area
;
1981 struct in_addr area_id
;
1987 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
1989 area
= ospf_area_get (ospf
, area_id
, format
);
1990 ospf_area_export_list_set (ospf
, area
, argv
[1]);
1995 DEFUN (no_ospf_area_export_list
,
1996 no_ospf_area_export_list_cmd
,
1997 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1999 "OSPF area parameters\n"
2000 "OSPF area ID in IP address format\n"
2001 "OSPF area ID as a decimal value\n"
2002 "Unset the filter for networks announced to other areas\n"
2003 "Name of the access-list\n")
2005 struct ospf
*ospf
= vty
->index
;
2006 struct ospf_area
*area
;
2007 struct in_addr area_id
;
2013 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2015 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2019 ospf_area_export_list_unset (ospf
, area
);
2025 DEFUN (ospf_area_import_list
,
2026 ospf_area_import_list_cmd
,
2027 "area (A.B.C.D|<0-4294967295>) import-list NAME",
2028 "OSPF area parameters\n"
2029 "OSPF area ID in IP address format\n"
2030 "OSPF area ID as a decimal value\n"
2031 "Set the filter for networks from other areas announced to the specified one\n"
2032 "Name of the access-list\n")
2034 struct ospf
*ospf
= vty
->index
;
2035 struct ospf_area
*area
;
2036 struct in_addr area_id
;
2042 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2044 area
= ospf_area_get (ospf
, area_id
, format
);
2045 ospf_area_import_list_set (ospf
, area
, argv
[1]);
2050 DEFUN (no_ospf_area_import_list
,
2051 no_ospf_area_import_list_cmd
,
2052 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
2054 "OSPF area parameters\n"
2055 "OSPF area ID in IP address format\n"
2056 "OSPF area ID as a decimal value\n"
2057 "Unset the filter for networks announced to other areas\n"
2058 "Name of the access-list\n")
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
[0]);
2070 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2074 ospf_area_import_list_unset (ospf
, area
);
2079 DEFUN (ospf_area_filter_list
,
2080 ospf_area_filter_list_cmd
,
2081 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2082 "OSPF area parameters\n"
2083 "OSPF area ID in IP address format\n"
2084 "OSPF area ID as a decimal value\n"
2085 "Filter networks between OSPF areas\n"
2086 "Filter prefixes between OSPF areas\n"
2087 "Name of an IP prefix-list\n"
2088 "Filter networks sent to this area\n"
2089 "Filter networks sent from this area\n")
2091 struct ospf
*ospf
= vty
->index
;
2092 struct ospf_area
*area
;
2093 struct in_addr area_id
;
2094 struct prefix_list
*plist
;
2100 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2102 area
= ospf_area_get (ospf
, area_id
, format
);
2103 plist
= prefix_list_lookup (AFI_IP
, argv
[1]);
2104 if (strncmp (argv
[2], "in", 2) == 0)
2106 PREFIX_LIST_IN (area
) = plist
;
2107 if (PREFIX_NAME_IN (area
))
2108 free (PREFIX_NAME_IN (area
));
2110 PREFIX_NAME_IN (area
) = strdup (argv
[1]);
2111 ospf_schedule_abr_task (ospf
);
2115 PREFIX_LIST_OUT (area
) = plist
;
2116 if (PREFIX_NAME_OUT (area
))
2117 free (PREFIX_NAME_OUT (area
));
2119 PREFIX_NAME_OUT (area
) = strdup (argv
[1]);
2120 ospf_schedule_abr_task (ospf
);
2126 DEFUN (no_ospf_area_filter_list
,
2127 no_ospf_area_filter_list_cmd
,
2128 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2130 "OSPF area parameters\n"
2131 "OSPF area ID in IP address format\n"
2132 "OSPF area ID as a decimal value\n"
2133 "Filter networks between OSPF areas\n"
2134 "Filter prefixes between OSPF areas\n"
2135 "Name of an IP prefix-list\n"
2136 "Filter networks sent to this area\n"
2137 "Filter networks sent from this area\n")
2139 struct ospf
*ospf
= vty
->index
;
2140 struct ospf_area
*area
;
2141 struct in_addr area_id
;
2147 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2149 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
2152 if (strncmp (argv
[2], "in", 2) == 0)
2154 if (PREFIX_NAME_IN (area
))
2155 if (strcmp (PREFIX_NAME_IN (area
), argv
[1]) != 0)
2158 PREFIX_LIST_IN (area
) = NULL
;
2159 if (PREFIX_NAME_IN (area
))
2160 free (PREFIX_NAME_IN (area
));
2162 PREFIX_NAME_IN (area
) = NULL
;
2164 ospf_schedule_abr_task (ospf
);
2168 if (PREFIX_NAME_OUT (area
))
2169 if (strcmp (PREFIX_NAME_OUT (area
), argv
[1]) != 0)
2172 PREFIX_LIST_OUT (area
) = NULL
;
2173 if (PREFIX_NAME_OUT (area
))
2174 free (PREFIX_NAME_OUT (area
));
2176 PREFIX_NAME_OUT (area
) = NULL
;
2178 ospf_schedule_abr_task (ospf
);
2185 DEFUN (ospf_area_authentication_message_digest
,
2186 ospf_area_authentication_message_digest_cmd
,
2187 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2188 "OSPF area parameters\n"
2189 "OSPF area ID in IP address format\n"
2190 "OSPF area ID as a decimal value\n"
2191 "Enable authentication\n"
2192 "Use message-digest authentication\n")
2194 struct ospf
*ospf
= vty
->index
;
2195 struct ospf_area
*area
;
2196 struct in_addr area_id
;
2202 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2204 area
= ospf_area_get (ospf
, area_id
, format
);
2205 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
2210 DEFUN (ospf_area_authentication
,
2211 ospf_area_authentication_cmd
,
2212 "area (A.B.C.D|<0-4294967295>) authentication",
2213 "OSPF area parameters\n"
2214 "OSPF area ID in IP address format\n"
2215 "OSPF area ID as a decimal value\n"
2216 "Enable authentication\n")
2218 struct ospf
*ospf
= vty
->index
;
2219 struct ospf_area
*area
;
2220 struct in_addr area_id
;
2226 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2228 area
= ospf_area_get (ospf
, area_id
, format
);
2229 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2234 DEFUN (no_ospf_area_authentication
,
2235 no_ospf_area_authentication_cmd
,
2236 "no area (A.B.C.D|<0-4294967295>) authentication",
2238 "OSPF area parameters\n"
2239 "OSPF area ID in IP address format\n"
2240 "OSPF area ID as a decimal value\n"
2241 "Enable authentication\n")
2243 struct ospf
*ospf
= vty
->index
;
2244 struct ospf_area
*area
;
2245 struct in_addr area_id
;
2251 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2253 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2257 area
->auth_type
= OSPF_AUTH_NULL
;
2259 ospf_area_check_free (ospf
, area_id
);
2265 DEFUN (ospf_abr_type
,
2267 "ospf abr-type (cisco|ibm|shortcut|standard)",
2268 "OSPF specific commands\n"
2269 "Set OSPF ABR type\n"
2270 "Alternative ABR, cisco implementation\n"
2271 "Alternative ABR, IBM implementation\n"
2273 "Standard behavior (RFC2328)\n")
2275 struct ospf
*ospf
= vty
->index
;
2276 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2281 if (strncmp (argv
[0], "c", 1) == 0)
2282 abr_type
= OSPF_ABR_CISCO
;
2283 else if (strncmp (argv
[0], "i", 1) == 0)
2284 abr_type
= OSPF_ABR_IBM
;
2285 else if (strncmp (argv
[0], "sh", 2) == 0)
2286 abr_type
= OSPF_ABR_SHORTCUT
;
2287 else if (strncmp (argv
[0], "st", 2) == 0)
2288 abr_type
= OSPF_ABR_STAND
;
2292 /* If ABR type value is changed, schedule ABR task. */
2293 if (ospf
->abr_type
!= abr_type
)
2295 ospf
->abr_type
= abr_type
;
2296 ospf_schedule_abr_task (ospf
);
2302 DEFUN (no_ospf_abr_type
,
2303 no_ospf_abr_type_cmd
,
2304 "no ospf abr-type (cisco|ibm|shortcut|standard)",
2306 "OSPF specific commands\n"
2307 "Set OSPF ABR type\n"
2308 "Alternative ABR, cisco implementation\n"
2309 "Alternative ABR, IBM implementation\n"
2312 struct ospf
*ospf
= vty
->index
;
2313 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2318 if (strncmp (argv
[0], "c", 1) == 0)
2319 abr_type
= OSPF_ABR_CISCO
;
2320 else if (strncmp (argv
[0], "i", 1) == 0)
2321 abr_type
= OSPF_ABR_IBM
;
2322 else if (strncmp (argv
[0], "sh", 2) == 0)
2323 abr_type
= OSPF_ABR_SHORTCUT
;
2324 else if (strncmp (argv
[0], "st", 2) == 0)
2325 abr_type
= OSPF_ABR_STAND
;
2329 /* If ABR type value is changed, schedule ABR task. */
2330 if (ospf
->abr_type
== abr_type
)
2332 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2333 ospf_schedule_abr_task (ospf
);
2339 DEFUN (ospf_log_adjacency_changes
,
2340 ospf_log_adjacency_changes_cmd
,
2341 "log-adjacency-changes",
2342 "Log changes in adjacency state\n")
2344 struct ospf
*ospf
= vty
->index
;
2349 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2350 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2354 DEFUN (ospf_log_adjacency_changes_detail
,
2355 ospf_log_adjacency_changes_detail_cmd
,
2356 "log-adjacency-changes detail",
2357 "Log changes in adjacency state\n"
2358 "Log all state changes\n")
2360 struct ospf
*ospf
= vty
->index
;
2365 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2366 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2370 DEFUN (no_ospf_log_adjacency_changes
,
2371 no_ospf_log_adjacency_changes_cmd
,
2372 "no log-adjacency-changes",
2374 "Log changes in adjacency state\n")
2376 struct ospf
*ospf
= vty
->index
;
2381 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2382 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2386 DEFUN (no_ospf_log_adjacency_changes_detail
,
2387 no_ospf_log_adjacency_changes_detail_cmd
,
2388 "no log-adjacency-changes detail",
2390 "Log changes in adjacency state\n"
2391 "Log all state changes\n")
2393 struct ospf
*ospf
= vty
->index
;
2398 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2399 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2403 DEFUN (ospf_compatible_rfc1583
,
2404 ospf_compatible_rfc1583_cmd
,
2405 "compatible rfc1583",
2406 "OSPF compatibility list\n"
2407 "compatible with RFC 1583\n")
2409 struct ospf
*ospf
= vty
->index
;
2414 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2416 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2417 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2422 DEFUN (no_ospf_compatible_rfc1583
,
2423 no_ospf_compatible_rfc1583_cmd
,
2424 "no compatible rfc1583",
2426 "OSPF compatibility list\n"
2427 "compatible with RFC 1583\n")
2429 struct ospf
*ospf
= vty
->index
;
2434 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2436 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2437 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2442 ALIAS (ospf_compatible_rfc1583
,
2443 ospf_rfc1583_flag_cmd
,
2444 "ospf rfc1583compatibility",
2445 "OSPF specific commands\n"
2446 "Enable the RFC1583Compatibility flag\n")
2448 ALIAS (no_ospf_compatible_rfc1583
,
2449 no_ospf_rfc1583_flag_cmd
,
2450 "no ospf rfc1583compatibility",
2452 "OSPF specific commands\n"
2453 "Disable the RFC1583Compatibility flag\n")
2456 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2460 struct ospf
*ospf
= vty
->index
;
2465 ospf
->spf_delay
= delay
;
2466 ospf
->spf_holdtime
= hold
;
2467 ospf
->spf_max_holdtime
= max
;
2472 DEFUN (ospf_timers_min_ls_interval
,
2473 ospf_timers_min_ls_interval_cmd
,
2474 "timers throttle lsa all <0-5000>",
2475 "Adjust routing timers\n"
2476 "Throttling adaptive timer\n"
2477 "LSA delay between transmissions\n"
2479 "Delay (msec) between sending LSAs\n")
2481 struct ospf
*ospf
= vty
->index
;
2482 unsigned int interval
;
2489 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2493 VTY_GET_INTEGER ("LSA interval", interval
, argv
[0]);
2495 ospf
->min_ls_interval
= interval
;
2500 DEFUN (no_ospf_timers_min_ls_interval
,
2501 no_ospf_timers_min_ls_interval_cmd
,
2502 "no timers throttle lsa all",
2504 "Adjust routing timers\n"
2505 "Throttling adaptive timer\n"
2506 "LSA delay between transmissions\n"
2509 struct ospf
*ospf
= vty
->index
;
2510 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2515 ALIAS (no_ospf_timers_min_ls_interval
,
2516 no_ospf_timers_min_ls_interval_val_cmd
,
2517 "no timers throttle lsa all <0-5000>",
2519 "Adjust routing timers\n"
2520 "Throttling adaptive timer\n"
2521 "LSA delay between transmissions\n"
2523 "Delay (msec) between sending LSAs\n")
2525 DEFUN (ospf_timers_min_ls_arrival
,
2526 ospf_timers_min_ls_arrival_cmd
,
2527 "timers lsa arrival <0-1000>",
2528 "Adjust routing timers\n"
2529 "Throttling link state advertisement delays\n"
2530 "OSPF minimum arrival interval delay\n"
2531 "Delay (msec) between accepted LSAs\n")
2533 struct ospf
*ospf
= vty
->index
;
2534 unsigned int arrival
;
2541 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2545 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[0], 0, 1000);
2547 ospf
->min_ls_arrival
= arrival
;
2552 DEFUN (no_ospf_timers_min_ls_arrival
,
2553 no_ospf_timers_min_ls_arrival_cmd
,
2554 "no timers lsa arrival",
2556 "Adjust routing timers\n"
2557 "Throttling link state advertisement delays\n"
2558 "OSPF minimum arrival interval delay\n")
2560 struct ospf
*ospf
= vty
->index
;
2565 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2570 ALIAS (no_ospf_timers_min_ls_arrival
,
2571 no_ospf_timers_min_ls_arrival_val_cmd
,
2572 "no timers lsa arrival <0-1000>",
2574 "Adjust routing timers\n"
2575 "Throttling link state advertisement delays\n"
2576 "OSPF minimum arrival interval delay\n"
2577 "Delay (msec) between accepted LSAs\n")
2579 DEFUN (ospf_timers_throttle_spf
,
2580 ospf_timers_throttle_spf_cmd
,
2581 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2582 "Adjust routing timers\n"
2583 "Throttling adaptive timer\n"
2585 "Delay (msec) from first change received till SPF calculation\n"
2586 "Initial hold time (msec) between consecutive SPF calculations\n"
2587 "Maximum hold time (msec)\n")
2589 unsigned int delay
, hold
, max
;
2593 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2597 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[0], 0, 600000);
2598 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[1], 0, 600000);
2599 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[2], 0, 600000);
2601 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2604 DEFUN (no_ospf_timers_throttle_spf
,
2605 no_ospf_timers_throttle_spf_cmd
,
2606 "no timers throttle spf",
2608 "Adjust routing timers\n"
2609 "Throttling adaptive timer\n"
2610 "OSPF SPF timers\n")
2612 return ospf_timers_spf_set (vty
,
2613 OSPF_SPF_DELAY_DEFAULT
,
2614 OSPF_SPF_HOLDTIME_DEFAULT
,
2615 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2618 ALIAS (no_ospf_timers_throttle_spf
,
2619 no_ospf_timers_throttle_spf_val_cmd
,
2620 "no timers throttle spf <0-600000> <0-600000> <0-600000>",
2622 "Adjust routing timers\n"
2623 "Throttling adaptive timer\n"
2625 "Delay (msec) from first change received till SPF calculation\n"
2626 "Initial hold time (msec) between consecutive SPF calculations\n"
2627 "Maximum hold time (msec)\n")
2629 DEFUN (ospf_timers_lsa
,
2630 ospf_timers_lsa_cmd
,
2631 "timers lsa min-arrival <0-600000>",
2632 "Adjust routing timers\n"
2634 "Minimum delay in receiving new version of a LSA\n"
2635 "Delay in milliseconds\n")
2637 unsigned int minarrival
;
2638 struct ospf
*ospf
= vty
->index
;
2645 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2649 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2651 ospf
->min_ls_arrival
= minarrival
;
2656 DEFUN (no_ospf_timers_lsa
,
2657 no_ospf_timers_lsa_cmd
,
2658 "no timers lsa min-arrival",
2660 "Adjust routing timers\n"
2662 "Minimum delay in receiving new version of a LSA\n")
2664 unsigned int minarrival
;
2665 struct ospf
*ospf
= vty
->index
;
2672 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2674 if (ospf
->min_ls_arrival
!= minarrival
||
2675 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2679 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2684 ALIAS (no_ospf_timers_lsa
,
2685 no_ospf_timers_lsa_val_cmd
,
2686 "no timers lsa min-arrival <0-600000>",
2688 "Adjust routing timers\n"
2690 "Minimum delay in receiving new version of a LSA\n"
2691 "Delay in milliseconds\n")
2694 DEFUN (ospf_neighbor
,
2698 "Neighbor IP address\n")
2700 struct ospf
*ospf
= vty
->index
;
2701 struct in_addr nbr_addr
;
2702 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2703 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2708 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2711 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[1], 0, 255);
2714 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[2], 1, 65535);
2716 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2718 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2720 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2725 ALIAS (ospf_neighbor
,
2726 ospf_neighbor_priority_poll_interval_cmd
,
2727 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2729 "Neighbor IP address\n"
2730 "Neighbor Priority\n"
2732 "Dead Neighbor Polling interval\n"
2735 ALIAS (ospf_neighbor
,
2736 ospf_neighbor_priority_cmd
,
2737 "neighbor A.B.C.D priority <0-255>",
2739 "Neighbor IP address\n"
2740 "Neighbor Priority\n"
2743 DEFUN (ospf_neighbor_poll_interval
,
2744 ospf_neighbor_poll_interval_cmd
,
2745 "neighbor A.B.C.D poll-interval <1-65535>",
2747 "Neighbor IP address\n"
2748 "Dead Neighbor Polling interval\n"
2751 struct ospf
*ospf
= vty
->index
;
2752 struct in_addr nbr_addr
;
2753 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2754 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2759 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2762 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[1], 1, 65535);
2765 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[2], 0, 255);
2767 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2769 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2771 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2776 ALIAS (ospf_neighbor_poll_interval
,
2777 ospf_neighbor_poll_interval_priority_cmd
,
2778 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2780 "Neighbor address\n"
2781 "OSPF dead-router polling interval\n"
2783 "OSPF priority of non-broadcast neighbor\n"
2786 DEFUN (no_ospf_neighbor
,
2787 no_ospf_neighbor_cmd
,
2788 "no neighbor A.B.C.D",
2791 "Neighbor IP address\n")
2793 struct ospf
*ospf
= vty
->index
;
2794 struct in_addr nbr_addr
;
2799 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2801 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2806 ALIAS (no_ospf_neighbor
,
2807 no_ospf_neighbor_priority_cmd
,
2808 "no neighbor A.B.C.D priority <0-255>",
2811 "Neighbor IP address\n"
2812 "Neighbor Priority\n"
2815 ALIAS (no_ospf_neighbor
,
2816 no_ospf_neighbor_poll_interval_cmd
,
2817 "no neighbor A.B.C.D poll-interval <1-65535>",
2820 "Neighbor IP address\n"
2821 "Dead Neighbor Polling interval\n"
2824 ALIAS (no_ospf_neighbor
,
2825 no_ospf_neighbor_poll_interval_priority_cmd
,
2826 "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2829 "Neighbor IP address\n"
2830 "Dead Neighbor Polling interval\n"
2832 "OSPF priority of non-broadcast neighbor\n"
2835 ALIAS (no_ospf_neighbor
,
2836 no_ospf_neighbor_priority_pollinterval_cmd
,
2837 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2840 "Neighbor IP address\n"
2841 "Neighbor Priority\n"
2843 "Dead Neighbor Polling interval\n"
2846 DEFUN (ospf_refresh_timer
, ospf_refresh_timer_cmd
,
2847 "refresh timer <10-1800>",
2848 "Adjust refresh parameters\n"
2849 "Set refresh timer\n"
2850 "Timer value in seconds\n")
2852 struct ospf
*ospf
= vty
->index
;
2853 unsigned int interval
;
2858 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2859 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2861 ospf_timers_refresh_set (ospf
, interval
);
2866 DEFUN (no_ospf_refresh_timer
, no_ospf_refresh_timer_val_cmd
,
2867 "no refresh timer <10-1800>",
2868 "Adjust refresh parameters\n"
2869 "Unset refresh timer\n"
2870 "Timer value in seconds\n")
2872 struct ospf
*ospf
= vty
->index
;
2873 unsigned int interval
;
2880 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2882 if (ospf
->lsa_refresh_interval
!= interval
||
2883 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2887 ospf_timers_refresh_unset (ospf
);
2892 ALIAS (no_ospf_refresh_timer
,
2893 no_ospf_refresh_timer_cmd
,
2895 "Adjust refresh parameters\n"
2896 "Unset refresh timer\n")
2898 DEFUN (ospf_auto_cost_reference_bandwidth
,
2899 ospf_auto_cost_reference_bandwidth_cmd
,
2900 "auto-cost reference-bandwidth <1-4294967>",
2901 "Calculate OSPF interface cost according to bandwidth\n"
2902 "Use reference bandwidth method to assign OSPF cost\n"
2903 "The reference bandwidth in terms of Mbits per second\n")
2905 struct ospf
*ospf
= vty
->index
;
2907 struct listnode
*node
;
2908 struct interface
*ifp
;
2913 refbw
= strtol (argv
[0], NULL
, 10);
2914 if (refbw
< 1 || refbw
> 4294967)
2916 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2920 /* If reference bandwidth is changed. */
2921 if ((refbw
) == ospf
->ref_bandwidth
)
2924 ospf
->ref_bandwidth
= refbw
;
2925 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2926 ospf_if_recalculate_output_cost (ifp
);
2931 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2932 no_ospf_auto_cost_reference_bandwidth_cmd
,
2933 "no auto-cost reference-bandwidth",
2935 "Calculate OSPF interface cost according to bandwidth\n"
2936 "Use reference bandwidth method to assign OSPF cost\n")
2938 struct ospf
*ospf
= vty
->index
;
2939 struct listnode
*node
, *nnode
;
2940 struct interface
*ifp
;
2945 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2948 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2949 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2950 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2952 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2953 ospf_if_recalculate_output_cost (ifp
);
2958 ALIAS (no_ospf_auto_cost_reference_bandwidth
,
2959 no_ospf_auto_cost_reference_bandwidth_val_cmd
,
2960 "no auto-cost reference-bandwidth <1-4294967>",
2962 "Calculate OSPF interface cost according to bandwidth\n"
2963 "Use reference bandwidth method to assign OSPF cost\n"
2964 "The reference bandwidth in terms of Mbits per second\n")
2966 DEFUN (ospf_write_multiplier
,
2967 ospf_write_multiplier_cmd
,
2968 "ospf write-multiplier <1-100>",
2969 "OSPF specific commands\n"
2970 "Write multiplier\n"
2971 "Maximum number of interface serviced per write\n")
2973 struct ospf
*ospf
= vty
->index
;
2974 u_int32_t write_oi_count
;
2979 write_oi_count
= strtol (argv
[0], NULL
, 10);
2980 if (write_oi_count
< 1 || write_oi_count
> 100)
2982 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2986 ospf
->write_oi_count
= write_oi_count
;
2990 ALIAS (ospf_write_multiplier
,
2991 write_multiplier_cmd
,
2992 "write-multiplier <1-100>",
2993 "Write multiplier\n"
2994 "Maximum number of interface serviced per write\n")
2996 DEFUN (no_ospf_write_multiplier
,
2997 no_ospf_write_multiplier_cmd
,
2998 "no ospf write-multiplier <1-100>",
3000 "OSPF specific commands\n"
3001 "Write multiplier\n"
3002 "Maximum number of interface serviced per write\n")
3004 struct ospf
*ospf
= vty
->index
;
3009 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
3013 ALIAS (no_ospf_write_multiplier
,
3014 no_write_multiplier_cmd
,
3015 "no write-multiplier",
3017 "Write multiplier\n")
3019 ALIAS (no_ospf_write_multiplier
,
3020 no_write_multiplier_val_cmd
,
3021 "no write-multiplier <1-100>",
3023 "Write multiplier\n"
3024 "Maximum number of interface serviced per write\n")
3026 const char *ospf_abr_type_descr_str
[] =
3029 "Standard (RFC2328)",
3031 "Alternative Cisco",
3032 "Alternative Shortcut"
3035 const char *ospf_shortcut_mode_descr_str
[] =
3043 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
3045 json_object
*json_area
= NULL
;
3048 json_area
= json_object_new_object();
3052 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
3054 /* Show Area type/mode. */
3055 if (OSPF_IS_AREA_BACKBONE (area
))
3058 json_object_boolean_true_add(json_area
, "backbone");
3060 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
3066 if (area
->external_routing
== OSPF_AREA_STUB
)
3068 if (area
->no_summary
)
3069 json_object_boolean_true_add(json_area
, "stubNoSummary");
3070 if (area
->shortcut_configured
)
3071 json_object_boolean_true_add(json_area
, "stubShortcut");
3073 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3075 if (area
->no_summary
)
3076 json_object_boolean_true_add(json_area
, "nssaNoSummary");
3077 if (area
->shortcut_configured
)
3078 json_object_boolean_true_add(json_area
, "nssaShortcut");
3081 json_object_string_add(json_area
,"shortcuttingMode",
3082 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3083 if (area
->shortcut_capability
)
3084 json_object_boolean_true_add(json_area
,"sBitConcensus");
3088 if (area
->external_routing
== OSPF_AREA_STUB
)
3089 vty_out (vty
, " (Stub%s%s)",
3090 area
->no_summary
? ", no summary" : "",
3091 area
->shortcut_configured
? "; " : "");
3092 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3093 vty_out (vty
, " (NSSA%s%s)",
3094 area
->no_summary
? ", no summary" : "",
3095 area
->shortcut_configured
? "; " : "");
3097 vty_out (vty
, "%s", VTY_NEWLINE
);
3098 vty_out (vty
, " Shortcutting mode: %s",
3099 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3100 vty_out (vty
, ", S-bit consensus: %s%s",
3101 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
3105 /* Show number of interfaces */
3108 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
3109 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
3112 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
3113 "Active: %d%s", listcount (area
->oiflist
),
3114 area
->act_ints
, VTY_NEWLINE
);
3116 if (area
->external_routing
== OSPF_AREA_NSSA
)
3120 json_object_boolean_true_add(json_area
, "nssa");
3121 if (! IS_OSPF_ABR (area
->ospf
))
3122 json_object_boolean_false_add(json_area
, "abr");
3123 else if (area
->NSSATranslatorState
)
3125 json_object_boolean_true_add(json_area
, "abr");
3126 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3127 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
3128 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3129 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
3133 json_object_boolean_true_add(json_area
, "abr");
3134 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3135 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
3137 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
3142 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
3143 if (! IS_OSPF_ABR (area
->ospf
))
3144 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
3146 else if (area
->NSSATranslatorState
)
3148 vty_out (vty
, " We are an ABR and ");
3149 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3150 vty_out (vty
, "the NSSA Elected Translator. %s",
3152 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3153 vty_out (vty
, "always an NSSA Translator. %s",
3158 vty_out (vty
, " We are an ABR, but ");
3159 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3160 vty_out (vty
, "not the NSSA Elected Translator. %s",
3163 vty_out (vty
, "never an NSSA Translator. %s",
3169 /* Stub-router state for this area */
3170 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
3172 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3176 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
3177 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3178 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
3179 if (area
->t_stub_router
)
3181 struct timeval result
;
3182 unsigned long time_store
= 0;
3183 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
3184 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3185 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
3190 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
3192 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3193 vty_out (vty
, " Administratively activated (indefinitely)%s",
3195 if (area
->t_stub_router
)
3196 vty_out (vty
, " Active from startup, %s remaining%s",
3197 ospf_timer_dump (area
->t_stub_router
, timebuf
,
3198 sizeof(timebuf
)), VTY_NEWLINE
);
3204 /* Show number of fully adjacent neighbors. */
3205 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
3207 /* Show authentication type. */
3208 if (area
->auth_type
== OSPF_AUTH_NULL
)
3209 json_object_string_add(json_area
, "authentication", "authenticationNone");
3210 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3211 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
3212 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3213 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
3215 if (!OSPF_IS_AREA_BACKBONE (area
))
3216 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
3218 /* Show SPF calculation times. */
3219 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
3220 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
3221 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
3222 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
3223 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
3224 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
3225 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
3226 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
3227 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3228 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3229 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3230 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3234 /* Show number of fully adjacent neighbors. */
3235 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
3236 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
3238 /* Show authentication type. */
3239 vty_out (vty
, " Area has ");
3240 if (area
->auth_type
== OSPF_AUTH_NULL
)
3241 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
3242 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3243 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
3244 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3245 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
3247 if (!OSPF_IS_AREA_BACKBONE (area
))
3248 vty_out (vty
, " Number of full virtual adjacencies going through"
3249 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
3251 /* Show SPF calculation times. */
3252 vty_out (vty
, " SPF algorithm executed %d times%s",
3253 area
->spf_calculation
, VTY_NEWLINE
);
3255 /* Show number of LSA. */
3256 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
3257 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3258 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
3259 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
3260 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3261 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
3262 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
3263 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3264 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
3265 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
3266 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3267 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3268 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
3269 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3270 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
3271 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
3276 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3277 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3278 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3279 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3283 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3284 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3285 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
3286 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3287 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3288 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
3292 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
3294 vty_out (vty
, "%s", VTY_NEWLINE
);
3298 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3300 struct listnode
*node
, *nnode
;
3301 struct ospf_area
* area
;
3302 struct timeval result
;
3303 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3304 json_object
*json
= NULL
;
3305 json_object
*json_areas
= NULL
;
3309 json
= json_object_new_object();
3310 json_areas
= json_object_new_object();
3317 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3321 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3322 VTY_NEWLINE
, VTY_NEWLINE
);
3326 /* Show Router ID. */
3329 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3333 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3334 inet_ntoa (ospf
->router_id
),
3338 /* Graceful shutdown */
3339 if (ospf
->t_deferred_shutdown
)
3343 unsigned long time_store
= 0;
3344 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3345 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3346 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3350 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3351 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3352 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3356 /* Show capability. */
3359 json_object_boolean_true_add(json
, "tosRoutesOnly");
3360 json_object_boolean_true_add(json
, "rfc2328Conform");
3361 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3363 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3368 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3369 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3370 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3371 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3372 "enabled" : "disabled", VTY_NEWLINE
);
3377 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3379 json_object_boolean_true_add(json
, "opaqueCapable");
3384 vty_out (vty
, " OpaqueCapability flag is %s%s",
3385 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3389 /* Show stub-router configuration */
3390 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3391 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3395 json_object_boolean_true_add(json
, "stubAdvertisement");
3396 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3397 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3398 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3399 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3403 vty_out (vty
, " Stub router advertisement is configured%s",
3405 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3406 vty_out (vty
, " Enabled for %us after start-up%s",
3407 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3408 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3409 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3410 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3414 /* Show SPF timers. */
3417 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3418 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3419 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3420 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3424 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3425 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3426 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3427 " Hold time multiplier is currently %d%s",
3428 ospf
->spf_delay
, VTY_NEWLINE
,
3429 ospf
->spf_holdtime
, VTY_NEWLINE
,
3430 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3431 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3436 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3438 unsigned long time_store
= 0;
3440 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3441 result
= tv_sub (result
, recent_relative_time());
3442 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3443 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3445 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3446 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3449 json_object_boolean_true_add(json
, "spfHasNotRun");
3453 vty_out (vty
, " SPF algorithm ");
3454 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3456 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3457 vty_out (vty
, "last executed %s ago%s",
3458 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3460 vty_out (vty
, " Last SPF duration %s%s",
3461 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3465 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3470 struct timeval temp_time
;
3471 unsigned long time_store
= 0;
3473 if (ospf
->t_spf_calc
)
3475 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3476 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3477 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3480 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3481 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3482 /* Show write multiplier values */
3483 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3484 /* Show refresh parameters. */
3485 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3489 vty_out (vty
, " SPF timer %s%s%s",
3490 (ospf
->t_spf_calc
? "due in " : "is "),
3491 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3494 vty_out (vty
, " LSA minimum interval %d msecs%s",
3495 ospf
->min_ls_interval
, VTY_NEWLINE
);
3496 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3497 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3499 /* Show write multiplier values */
3500 vty_out (vty
, " Write Multiplier set to %d %s",
3501 ospf
->write_oi_count
, VTY_NEWLINE
);
3503 /* Show refresh parameters. */
3504 vty_out (vty
, " Refresh timer %d secs%s",
3505 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3508 /* Show ABR/ASBR flags. */
3509 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3512 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3514 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3515 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3517 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3520 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3522 vty_out (vty
, " This router is an ASBR "
3523 "(injecting external routing information)%s", VTY_NEWLINE
);
3526 /* Show Number of AS-external-LSAs. */
3529 json_object_int_add(json
, "lsaExternalCounter",
3530 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3531 json_object_int_add(json
, "lsaExternalChecksum",
3532 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3536 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3537 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3538 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3543 json_object_int_add(json
, "lsaAsopaqueCounter",
3544 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3545 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3546 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3550 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3551 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3552 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3555 /* Show number of areas attached. */
3557 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3559 vty_out (vty
, " Number of areas attached to this router: %d%s",
3560 listcount (ospf
->areas
), VTY_NEWLINE
);
3562 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3564 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3567 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3569 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3574 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3576 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3579 /* Show each area status. */
3580 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3581 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3585 json_object_object_add(json
, "areas", json_areas
);
3586 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3587 json_object_free(json
);
3590 vty_out (vty
, "%s",VTY_NEWLINE
);
3595 DEFUN (show_ip_ospf
,
3597 "show ip ospf {json}",
3600 "OSPF information\n"
3601 "JavaScript Object Notation\n")
3604 u_char uj
= use_json(argc
, argv
);
3606 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3609 return (show_ip_ospf_common(vty
, ospf
, uj
));
3612 DEFUN (show_ip_ospf_instance
,
3613 show_ip_ospf_instance_cmd
,
3614 "show ip ospf <1-65535> {json}",
3617 "OSPF information\n"
3619 "JavaScript Object Notation\n")
3622 u_short instance
= 0;
3623 u_char uj
= use_json(argc
, argv
);
3625 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
3626 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3629 return (show_ip_ospf_common(vty
, ospf
, uj
));
3633 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3634 json_object
*json_interface_sub
, u_char use_json
)
3637 struct ospf_neighbor
*nbr
;
3638 struct route_node
*rn
;
3640 /* Is interface up? */
3643 is_up
= if_is_operative(ifp
);
3645 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3647 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3649 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3650 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3651 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3652 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3656 vty_out (vty
, "%s is %s%s", ifp
->name
,
3657 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3658 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3659 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3663 /* Is interface OSPF enabled? */
3666 if (ospf_oi_count(ifp
) == 0)
3668 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3673 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3677 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3681 if (ospf_oi_count(ifp
) == 0)
3683 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3688 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3694 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3696 struct ospf_interface
*oi
= rn
->info
;
3701 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3704 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3706 vty_out (vty
, " This interface is UNNUMBERED,");
3710 /* Show OSPF interface information. */
3713 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3714 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3717 vty_out (vty
, " Internet Address %s/%d,",
3718 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3720 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3722 struct in_addr
*dest
;
3725 if (CONNECTED_PEER(oi
->connected
)
3726 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3731 /* For Vlinks, showing the peer address is probably more
3732 * * * * * informative than the local interface that is being used
3734 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3735 dest
= &oi
->vl_data
->peer_addr
;
3737 dest
= &oi
->connected
->destination
->u
.prefix4
;
3741 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3742 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3743 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3745 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3748 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3753 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3754 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3755 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3756 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3757 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3758 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3759 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3760 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3761 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3765 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3768 vty_out (vty
, " MTU mismatch detection:%s%s",
3769 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3771 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3772 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3773 oi
->output_cost
, VTY_NEWLINE
);
3775 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3776 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3777 PRIORITY (oi
), VTY_NEWLINE
);
3780 /* Show DR information. */
3781 if (DR (oi
).s_addr
== 0)
3784 vty_out (vty
, " No backup designated router on this network%s",
3789 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3793 vty_out (vty
, " No backup designated router on this network%s",
3800 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3801 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3805 vty_out (vty
, " Backup Designated Router (ID) %s,",
3806 inet_ntoa (nbr
->router_id
));
3807 vty_out (vty
, " Interface Address %s%s",
3808 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3813 /* Next network-LSA sequence number we'll use, if we're elected DR */
3814 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3817 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3819 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3820 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3825 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3826 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3828 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3829 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3830 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3831 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3836 vty_out (vty
, " Multicast group memberships:");
3837 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3838 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3840 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3841 vty_out (vty
, " OSPFAllRouters");
3842 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3843 vty_out (vty
, " OSPFDesignatedRouters");
3846 vty_out (vty
, " <None>");
3847 vty_out (vty
, "%s", VTY_NEWLINE
);
3852 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3853 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3855 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3856 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3857 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3858 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3862 vty_out (vty
, " Timer intervals configured,");
3863 vty_out (vty
, " Hello ");
3864 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3865 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3867 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3868 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3869 OSPF_IF_PARAM (oi
, v_wait
),
3870 OSPF_IF_PARAM (oi
, v_wait
),
3871 OSPF_IF_PARAM (oi
, retransmit_interval
),
3875 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3877 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3880 struct timeval result
;
3881 unsigned long time_store
= 0;
3883 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3889 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3890 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3893 vty_out (vty
, " Hello due in %s%s",
3894 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3897 else /* passive-interface is set */
3900 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3902 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3907 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3908 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3911 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3912 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3914 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3919 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3920 const char **argv
, int iface_argv
, u_char use_json
)
3922 struct interface
*ifp
;
3923 struct listnode
*node
;
3924 json_object
*json
= NULL
;
3925 json_object
*json_interface_sub
= NULL
;
3929 json
= json_object_new_object();
3930 json_interface_sub
= json_object_new_object();
3936 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3938 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3939 VTY_NEWLINE
, VTY_NEWLINE
);
3942 if (argc
== (iface_argv
+ 1))
3944 /* Show All Interfaces.*/
3945 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3947 if (ospf_oi_count(ifp
))
3949 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3951 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3955 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
], "json") == 0)
3959 json
= json_object_new_object();
3960 json_interface_sub
= json_object_new_object ();
3963 /* Show All Interfaces. */
3964 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3966 if (ospf_oi_count(ifp
))
3968 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3970 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3976 /* Interface name is specified. */
3977 if ((ifp
= if_lookup_by_name (argv
[iface_argv
])) == NULL
)
3980 json_object_boolean_true_add(json
, "noSuchIface");
3982 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3986 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3988 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3994 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3995 json_object_free(json
);
3998 vty_out (vty
, "%s", VTY_NEWLINE
);
4003 DEFUN (show_ip_ospf_interface
,
4004 show_ip_ospf_interface_cmd
,
4005 "show ip ospf interface [INTERFACE] {json}",
4008 "OSPF information\n"
4009 "Interface information\n"
4011 "JavaScript Object Notation\n")
4014 u_char uj
= use_json(argc
, argv
);
4016 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4019 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
4022 DEFUN (show_ip_ospf_instance_interface
,
4023 show_ip_ospf_instance_interface_cmd
,
4024 "show ip ospf <1-65535> interface [INTERFACE] {json}",
4027 "OSPF information\n"
4029 "Interface information\n"
4031 "JavaScript Object Notation\n")
4034 u_short instance
= 0;
4035 u_char uj
= use_json(argc
, argv
);
4037 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4038 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4041 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
4045 show_ip_ospf_neighbour_header (struct vty
*vty
)
4047 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
4049 "Neighbor ID", "Pri", "State", "Dead Time",
4050 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
4055 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
4057 struct route_node
*rn
;
4058 struct ospf_neighbor
*nbr
;
4060 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4061 json_object
*json_neighbor
= NULL
;
4063 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4065 if ((nbr
= rn
->info
))
4067 /* Do not show myself. */
4068 if (nbr
!= oi
->nbr_self
)
4070 /* Down state is not shown. */
4071 if (nbr
->state
!= NSM_Down
)
4075 json_neighbor
= json_object_new_object();
4076 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4078 struct timeval result
;
4079 unsigned long time_store
= 0;
4081 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
4082 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
4084 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
4085 json_object_string_add (json_neighbor
, "state", msgbuf
);
4086 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
4087 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
4088 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
4089 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
4090 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
4091 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
4092 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4093 json_object_object_add(json
, "neighbor", json_neighbor
);
4095 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
4099 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4101 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4102 vty_out (vty
, "%-15s %3d %-15s ",
4106 vty_out (vty
, "%-15s %3d %-15s ",
4107 inet_ntoa (nbr
->router_id
), nbr
->priority
,
4110 vty_out (vty
, "%9s ",
4111 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
4113 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
4114 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
4115 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
4116 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
4126 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4128 struct ospf_interface
*oi
;
4129 struct listnode
*node
;
4130 json_object
*json
= NULL
;
4133 json
= json_object_new_object();
4135 show_ip_ospf_neighbour_header (vty
);
4140 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4142 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4143 VTY_NEWLINE
, VTY_NEWLINE
);
4146 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4147 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4151 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4152 json_object_free(json
);
4155 vty_out (vty
, "%s", VTY_NEWLINE
);
4160 DEFUN (show_ip_ospf_neighbor
,
4161 show_ip_ospf_neighbor_cmd
,
4162 "show ip ospf neighbor {json}",
4165 "OSPF information\n"
4167 "JavaScript Object Notation\n")
4170 u_char uj
= use_json(argc
, argv
);
4172 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4175 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4179 DEFUN (show_ip_ospf_instance_neighbor
,
4180 show_ip_ospf_instance_neighbor_cmd
,
4181 "show ip ospf <1-65535> neighbor {json}",
4184 "OSPF information\n"
4187 "JavaScript Object Notation\n")
4190 u_short instance
= 0;
4191 u_char uj
= use_json(argc
, argv
);
4193 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4194 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4197 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4201 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4203 struct listnode
*node
;
4204 struct ospf_interface
*oi
;
4205 json_object
*json
= NULL
;
4206 json_object
*json_neighbor_sub
= NULL
;
4210 json
= json_object_new_object();
4211 json_neighbor_sub
= json_object_new_object();
4214 show_ip_ospf_neighbour_header (vty
);
4219 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4221 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4222 VTY_NEWLINE
, VTY_NEWLINE
);
4225 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4227 struct listnode
*nbr_node
;
4228 struct ospf_nbr_nbma
*nbr_nbma
;
4230 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4232 /* print Down neighbor status */
4233 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4235 if (nbr_nbma
->nbr
== NULL
4236 || nbr_nbma
->nbr
->state
== NSM_Down
)
4240 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4241 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4242 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4243 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4244 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4245 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4246 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4250 vty_out (vty
, "%-15s %3d %-15s %9s ",
4251 "-", nbr_nbma
->priority
, "Down", "-");
4252 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4253 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4254 0, 0, 0, VTY_NEWLINE
);
4262 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4263 json_object_free(json
);
4266 vty_out (vty
, "%s", VTY_NEWLINE
);
4271 DEFUN (show_ip_ospf_neighbor_all
,
4272 show_ip_ospf_neighbor_all_cmd
,
4273 "show ip ospf neighbor all {json}",
4276 "OSPF information\n"
4278 "include down status neighbor\n"
4279 "JavaScript Object Notation\n")
4282 u_char uj
= use_json(argc
, argv
);
4284 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4287 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4290 DEFUN (show_ip_ospf_instance_neighbor_all
,
4291 show_ip_ospf_instance_neighbor_all_cmd
,
4292 "show ip ospf <1-65535> neighbor all {json}",
4295 "OSPF information\n"
4298 "include down status neighbor\n"
4299 "JavaScript Object Notation\n")
4302 u_short instance
= 0;
4303 u_char uj
= use_json(argc
, argv
);
4305 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4306 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4309 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4313 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4314 const char **argv
, u_char use_json
)
4316 struct interface
*ifp
;
4317 struct route_node
*rn
;
4318 json_object
*json
= NULL
;
4321 json
= json_object_new_object();
4323 show_ip_ospf_neighbour_header (vty
);
4328 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4330 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4331 VTY_NEWLINE
, VTY_NEWLINE
);
4334 ifp
= if_lookup_by_name (argv
[arg_base
]);
4338 json_object_boolean_true_add(json
, "noSuchIface");
4340 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4344 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4346 struct ospf_interface
*oi
= rn
->info
;
4351 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4356 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4357 json_object_free(json
);
4360 vty_out (vty
, "%s", VTY_NEWLINE
);
4365 DEFUN (show_ip_ospf_neighbor_int
,
4366 show_ip_ospf_neighbor_int_cmd
,
4367 "show ip ospf neighbor IFNAME {json}",
4370 "OSPF information\n"
4373 "JavaScript Object Notation\n")
4376 u_char uj
= use_json(argc
, argv
);
4378 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4381 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4384 DEFUN (show_ip_ospf_instance_neighbor_int
,
4385 show_ip_ospf_instance_neighbor_int_cmd
,
4386 "show ip ospf <1-65535> neighbor IFNAME {json}",
4389 "OSPF information\n"
4393 "JavaScript Object Notation\n")
4396 u_short instance
= 0;
4397 u_char uj
= use_json(argc
, argv
);
4399 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4400 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4403 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4407 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4408 u_char use_json
, json_object
*json
)
4410 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4411 json_object
*json_sub
= NULL
;
4414 json_sub
= json_object_new_object();
4415 else /* Show neighbor ID. */
4416 vty_out (vty
, " Neighbor %s,", "-");
4418 /* Show interface address. */
4420 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4422 vty_out (vty
, " interface address %s%s",
4423 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4428 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4429 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4432 vty_out (vty
, " In the area %s via interface %s%s",
4433 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4435 /* Show neighbor priority and state. */
4438 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4439 json_object_string_add(json_sub
, "nbrState", "down");
4442 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4443 nbr_nbma
->priority
, "Down");
4445 /* Show state changes. */
4447 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4449 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4451 /* Show PollInterval */
4453 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4455 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4457 /* Show poll-interval timer. */
4460 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4461 unsigned long time_store
= 0;
4462 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4463 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4466 vty_out (vty
, " Poll timer due in %s%s",
4467 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4470 /* Show poll-interval timer thread. */
4473 if (nbr_nbma
->t_poll
!= NULL
)
4474 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4477 vty_out (vty
, " Thread Poll Timer %s%s",
4478 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4481 json_object_object_add(json
, "noNbrId", json_sub
);
4485 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4486 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4488 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4489 json_object
*json_sub
= NULL
;
4492 json_sub
= json_object_new_object();
4495 /* Show neighbor ID. */
4496 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4497 vty_out (vty
, " Neighbor %s,", "-");
4499 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4502 /* Show interface address. */
4504 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4506 vty_out (vty
, " interface address %s%s",
4507 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4512 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4513 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4516 vty_out (vty
, " In the area %s via interface %s%s",
4517 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4519 /* Show neighbor priority and state. */
4522 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4523 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4526 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4527 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4529 /* Show state changes. */
4531 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4533 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4535 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4537 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4540 unsigned long time_store
= 0;
4541 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4542 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4546 vty_out (vty
, " Most recent state change statistics:%s",
4548 vty_out (vty
, " Progressive change %s ago%s",
4549 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4554 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4556 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4559 unsigned long time_store
= 0;
4560 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4561 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4562 if (nbr
->last_regress_str
)
4563 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4567 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4568 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4569 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4574 /* Show Designated Rotuer ID. */
4576 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4578 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4580 /* Show Backup Designated Rotuer ID. */
4582 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4584 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4589 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4590 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4593 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4594 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4596 /* Show Router Dead interval timer. */
4599 if (nbr
->t_inactivity
)
4601 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4602 unsigned long time_store
= 0;
4603 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4604 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4607 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4610 vty_out (vty
, " Dead timer due in %s%s",
4611 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4614 /* Show Database Summary list. */
4616 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4618 vty_out (vty
, " Database Summary List %d%s",
4619 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4621 /* Show Link State Request list. */
4623 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4625 vty_out (vty
, " Link State Request List %ld%s",
4626 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4628 /* Show Link State Retransmission list. */
4630 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4632 vty_out (vty
, " Link State Retransmission List %ld%s",
4633 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4635 /* Show inactivity timer thread. */
4638 if (nbr
->t_inactivity
!= NULL
)
4639 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4642 vty_out (vty
, " Thread Inactivity Timer %s%s",
4643 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4645 /* Show Database Description retransmission thread. */
4648 if (nbr
->t_db_desc
!= NULL
)
4649 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4652 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4653 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4655 /* Show Link State Request Retransmission thread. */
4658 if (nbr
->t_ls_req
!= NULL
)
4659 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4662 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4663 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4665 /* Show Link State Update Retransmission thread. */
4668 if (nbr
->t_ls_upd
!= NULL
)
4669 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4672 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4673 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4677 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4678 json_object_object_add(json
, "noNbrId", json_sub
);
4680 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4683 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4687 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4688 int arg_base
, const char **argv
, u_char use_json
)
4690 struct listnode
*node
;
4691 struct ospf_neighbor
*nbr
;
4692 struct ospf_interface
*oi
;
4693 struct in_addr router_id
;
4695 json_object
*json
= NULL
;
4698 json
= json_object_new_object();
4703 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4705 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4706 VTY_NEWLINE
, VTY_NEWLINE
);
4709 ret
= inet_aton (argv
[arg_base
], &router_id
);
4713 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4717 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4719 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4721 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4727 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4728 json_object_free(json
);
4731 vty_out (vty
, "%s", VTY_NEWLINE
);
4736 DEFUN (show_ip_ospf_neighbor_id
,
4737 show_ip_ospf_neighbor_id_cmd
,
4738 "show ip ospf neighbor A.B.C.D {json}",
4741 "OSPF information\n"
4744 "JavaScript Object Notation\n")
4747 u_char uj
= use_json(argc
, argv
);
4749 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4752 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4755 DEFUN (show_ip_ospf_instance_neighbor_id
,
4756 show_ip_ospf_instance_neighbor_id_cmd
,
4757 "show ip ospf <1-65535> neighbor A.B.C.D {json}",
4760 "OSPF information\n"
4764 "JavaScript Object Notation\n")
4767 u_short instance
= 0;
4768 u_char uj
= use_json(argc
, argv
);
4770 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4771 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4774 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4778 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4780 struct ospf_interface
*oi
;
4781 struct listnode
*node
;
4782 json_object
*json
= NULL
;
4785 json
= json_object_new_object();
4790 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4792 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4793 VTY_NEWLINE
, VTY_NEWLINE
);
4796 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4798 struct route_node
*rn
;
4799 struct ospf_neighbor
*nbr
;
4801 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4803 if ((nbr
= rn
->info
))
4805 if (nbr
!= oi
->nbr_self
)
4807 if (nbr
->state
!= NSM_Down
)
4809 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4818 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4819 json_object_free(json
);
4822 vty_out (vty
, "%s", VTY_NEWLINE
);
4827 DEFUN (show_ip_ospf_neighbor_detail
,
4828 show_ip_ospf_neighbor_detail_cmd
,
4829 "show ip ospf neighbor detail {json}",
4832 "OSPF information\n"
4834 "detail of all neighbors\n"
4835 "JavaScript Object Notation\n")
4838 u_char uj
= use_json(argc
, argv
);
4840 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4843 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4846 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4847 show_ip_ospf_instance_neighbor_detail_cmd
,
4848 "show ip ospf <1-65535> neighbor detail {json}",
4851 "OSPF information\n"
4854 "detail of all neighbors\n"
4855 "JavaScript Object Notation\n")
4858 u_short instance
= 0;
4859 u_char uj
= use_json(argc
, argv
);
4861 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4862 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4865 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4869 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4871 struct listnode
*node
;
4872 struct ospf_interface
*oi
;
4873 json_object
*json
= NULL
;
4876 json
= json_object_new_object();
4881 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4883 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4884 VTY_NEWLINE
, VTY_NEWLINE
);
4887 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4889 struct route_node
*rn
;
4890 struct ospf_neighbor
*nbr
;
4891 struct ospf_nbr_nbma
*nbr_nbma
;
4893 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4894 if ((nbr
= rn
->info
))
4895 if (nbr
!= oi
->nbr_self
)
4896 if (nbr
->state
!= NSM_Down
)
4897 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4899 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4901 struct listnode
*nd
;
4903 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4905 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4906 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4913 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4914 json_object_free(json
);
4918 vty_out (vty
, "%s", VTY_NEWLINE
);
4924 DEFUN (show_ip_ospf_neighbor_detail_all
,
4925 show_ip_ospf_neighbor_detail_all_cmd
,
4926 "show ip ospf neighbor detail all {json}",
4929 "OSPF information\n"
4931 "detail of all neighbors\n"
4932 "include down status neighbor\n"
4933 "JavaScript Object Notation\n")
4936 u_char uj
= use_json(argc
, argv
);
4938 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4941 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4944 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4945 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4946 "show ip ospf <1-65535> neighbor detail all {json}",
4949 "OSPF information\n"
4952 "detail of all neighbors\n"
4953 "include down status neighbor\n"
4954 "JavaScript Object Notation\n")
4957 u_short instance
= 0;
4958 u_char uj
= use_json(argc
, argv
);
4960 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4961 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4964 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4968 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4969 int arg_base
, const char **argv
, u_char use_json
)
4971 struct ospf_interface
*oi
;
4972 struct interface
*ifp
;
4973 struct route_node
*rn
, *nrn
;
4974 struct ospf_neighbor
*nbr
;
4975 json_object
*json
= NULL
;
4978 json
= json_object_new_object();
4983 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4985 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4986 VTY_NEWLINE
, VTY_NEWLINE
);
4989 ifp
= if_lookup_by_name (argv
[arg_base
]);
4993 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4997 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4999 if ((oi
= rn
->info
))
5001 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
5003 if ((nbr
= nrn
->info
))
5005 if (nbr
!= oi
->nbr_self
)
5007 if (nbr
->state
!= NSM_Down
)
5008 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
5017 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
5018 json_object_free(json
);
5021 vty_out (vty
, "%s", VTY_NEWLINE
);
5026 DEFUN (show_ip_ospf_neighbor_int_detail
,
5027 show_ip_ospf_neighbor_int_detail_cmd
,
5028 "show ip ospf neighbor IFNAME detail {json}",
5031 "OSPF information\n"
5034 "detail of all neighbors\n"
5035 "JavaScript Object Notation\n")
5038 u_char uj
= use_json(argc
, argv
);
5040 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5043 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
5046 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5047 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5048 "show ip ospf <1-65535> neighbor IFNAME detail {json}",
5051 "OSPF information\n"
5055 "detail of all neighbors\n"
5056 "JavaScript Object Notation\n")
5059 u_short instance
= 0;
5060 u_char uj
= use_json(argc
, argv
);
5062 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5063 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
5066 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
5069 /* Show functions */
5071 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
5073 struct router_lsa
*rl
;
5074 struct summary_lsa
*sl
;
5075 struct as_external_lsa
*asel
;
5076 struct prefix_ipv4 p
;
5079 /* If self option is set, check LSA self flag. */
5080 if (self
== 0 || IS_LSA_SELF (lsa
))
5082 /* LSA common part show. */
5083 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
5084 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
5085 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
5086 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
5087 /* LSA specific part show. */
5088 switch (lsa
->data
->type
)
5090 case OSPF_ROUTER_LSA
:
5091 rl
= (struct router_lsa
*) lsa
->data
;
5092 vty_out (vty
, " %-d", ntohs (rl
->links
));
5094 case OSPF_SUMMARY_LSA
:
5095 sl
= (struct summary_lsa
*) lsa
->data
;
5098 p
.prefix
= sl
->header
.id
;
5099 p
.prefixlen
= ip_masklen (sl
->mask
);
5100 apply_mask_ipv4 (&p
);
5102 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
5104 case OSPF_AS_EXTERNAL_LSA
:
5105 case OSPF_AS_NSSA_LSA
:
5106 asel
= (struct as_external_lsa
*) lsa
->data
;
5109 p
.prefix
= asel
->header
.id
;
5110 p
.prefixlen
= ip_masklen (asel
->mask
);
5111 apply_mask_ipv4 (&p
);
5113 vty_out (vty
, " %s %s/%d [0x%lx]",
5114 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
5115 inet_ntoa (p
.prefix
), p
.prefixlen
,
5116 (u_long
)ntohl (asel
->e
[0].route_tag
));
5118 case OSPF_NETWORK_LSA
:
5119 case OSPF_ASBR_SUMMARY_LSA
:
5120 case OSPF_OPAQUE_LINK_LSA
:
5121 case OSPF_OPAQUE_AREA_LSA
:
5122 case OSPF_OPAQUE_AS_LSA
:
5126 vty_out (vty
, VTY_NEWLINE
);
5132 static const char *show_database_desc
[] =
5135 "Router Link States",
5137 "Summary Link States",
5138 "ASBR-Summary Link States",
5139 "AS External Link States",
5140 "Group Membership LSA",
5141 "NSSA-external Link States",
5143 "Link-Local Opaque-LSA",
5144 "Area-Local Opaque-LSA",
5145 "AS-external Opaque-LSA",
5148 static const char *show_database_header
[] =
5151 "Link ID ADV Router Age Seq# CkSum Link count",
5152 "Link ID ADV Router Age Seq# CkSum",
5153 "Link ID ADV Router Age Seq# CkSum Route",
5154 "Link ID ADV Router Age Seq# CkSum",
5155 "Link ID ADV Router Age Seq# CkSum Route",
5156 " --- header for Group Member ----",
5157 "Link ID ADV Router Age Seq# CkSum Route",
5159 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5160 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5161 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5165 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
5167 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
5169 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
5170 vty_out (vty
, " Options: 0x%-2x : %s%s",
5172 ospf_options_dump(lsa
->data
->options
),
5174 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
5176 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
5179 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
5181 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
5184 vty_out (vty
, " :%s%s%s%s",
5185 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
5186 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
5187 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
5188 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
5190 vty_out (vty
, "%s", VTY_NEWLINE
);
5192 vty_out (vty
, " LS Type: %s%s",
5193 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5194 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
5195 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5196 vty_out (vty
, " Advertising Router: %s%s",
5197 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5198 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5200 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5202 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5205 const char *link_type_desc
[] =
5208 "another Router (point-to-point)",
5209 "a Transit Network",
5214 const char *link_id_desc
[] =
5217 "Neighboring Router ID",
5218 "Designated Router address",
5220 "Neighboring Router ID",
5223 const char *link_data_desc
[] =
5226 "Router Interface address",
5227 "Router Interface address",
5229 "Router Interface address",
5232 /* Show router-LSA each Link information. */
5234 show_ip_ospf_database_router_links (struct vty
*vty
,
5235 struct router_lsa
*rl
)
5240 len
= ntohs (rl
->header
.length
) - 4;
5241 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5243 type
= rl
->link
[i
].type
;
5245 vty_out (vty
, " Link connected to: %s%s",
5246 link_type_desc
[type
], VTY_NEWLINE
);
5247 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5248 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5249 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5250 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5251 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5252 vty_out (vty
, " TOS 0 Metric: %d%s",
5253 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5254 vty_out (vty
, "%s", VTY_NEWLINE
);
5258 /* Show router-LSA detail information. */
5260 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5264 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5266 show_ip_ospf_database_header (vty
, lsa
);
5268 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5269 VTY_NEWLINE
, VTY_NEWLINE
);
5271 show_ip_ospf_database_router_links (vty
, rl
);
5272 vty_out (vty
, "%s", VTY_NEWLINE
);
5278 /* Show network-LSA detail information. */
5280 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5286 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5288 show_ip_ospf_database_header (vty
, lsa
);
5290 vty_out (vty
, " Network Mask: /%d%s",
5291 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5293 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5295 for (i
= 0; length
> 0; i
++, length
-= 4)
5296 vty_out (vty
, " Attached Router: %s%s",
5297 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5299 vty_out (vty
, "%s", VTY_NEWLINE
);
5305 /* Show summary-LSA detail information. */
5307 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5311 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5313 show_ip_ospf_database_header (vty
, lsa
);
5315 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5317 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5319 vty_out (vty
, "%s", VTY_NEWLINE
);
5325 /* Show summary-ASBR-LSA detail information. */
5327 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5331 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5333 show_ip_ospf_database_header (vty
, lsa
);
5335 vty_out (vty
, " Network Mask: /%d%s",
5336 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5337 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5339 vty_out (vty
, "%s", VTY_NEWLINE
);
5345 /* Show AS-external-LSA detail information. */
5347 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5351 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5353 show_ip_ospf_database_header (vty
, lsa
);
5355 vty_out (vty
, " Network Mask: /%d%s",
5356 ip_masklen (al
->mask
), VTY_NEWLINE
);
5357 vty_out (vty
, " Metric Type: %s%s",
5358 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5359 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5360 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5361 vty_out (vty
, " Metric: %d%s",
5362 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5363 vty_out (vty
, " Forward Address: %s%s",
5364 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5366 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5367 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5375 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5377 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5379 /* show_ip_ospf_database_header (vty, lsa); */
5381 zlog_debug( " Network Mask: /%d%s",
5382 ip_masklen (al
->mask
), "\n");
5383 zlog_debug( " Metric Type: %s%s",
5384 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5385 "2 (Larger than any link state path)" : "1", "\n");
5386 zlog_debug( " TOS: 0%s", "\n");
5387 zlog_debug( " Metric: %d%s",
5388 GET_METRIC (al
->e
[0].metric
), "\n");
5389 zlog_debug( " Forward Address: %s%s",
5390 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5392 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5393 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5399 /* Show AS-NSSA-LSA detail information. */
5401 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5405 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5407 show_ip_ospf_database_header (vty
, lsa
);
5409 vty_out (vty
, " Network Mask: /%d%s",
5410 ip_masklen (al
->mask
), VTY_NEWLINE
);
5411 vty_out (vty
, " Metric Type: %s%s",
5412 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5413 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5414 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5415 vty_out (vty
, " Metric: %d%s",
5416 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5417 vty_out (vty
, " NSSA: Forward Address: %s%s",
5418 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5420 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5421 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5428 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5434 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5438 show_ip_ospf_database_header (vty
, lsa
);
5439 show_opaque_info_detail (vty
, lsa
);
5441 vty_out (vty
, "%s", VTY_NEWLINE
);
5446 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5449 show_router_lsa_detail
,
5450 show_network_lsa_detail
,
5451 show_summary_lsa_detail
,
5452 show_summary_asbr_lsa_detail
,
5453 show_as_external_lsa_detail
,
5455 show_as_nssa_lsa_detail
, /* almost same as external */
5457 show_opaque_lsa_detail
,
5458 show_opaque_lsa_detail
,
5459 show_opaque_lsa_detail
,
5463 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5464 struct in_addr
*adv_router
)
5466 memset (lp
, 0, sizeof (struct prefix_ls
));
5470 else if (adv_router
== NULL
)
5479 lp
->adv_router
= *adv_router
;
5484 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5485 struct in_addr
*id
, struct in_addr
*adv_router
)
5487 struct prefix_ls lp
;
5488 struct route_node
*rn
, *start
;
5489 struct ospf_lsa
*lsa
;
5491 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5492 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5495 route_lock_node (start
);
5496 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5497 if ((lsa
= rn
->info
))
5499 if (show_function
[lsa
->data
->type
] != NULL
)
5500 show_function
[lsa
->data
->type
] (vty
, lsa
);
5502 route_unlock_node (start
);
5506 /* Show detail LSA information
5507 -- if id is NULL then show all LSAs. */
5509 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5510 struct in_addr
*id
, struct in_addr
*adv_router
)
5512 struct listnode
*node
;
5513 struct ospf_area
*area
;
5517 case OSPF_AS_EXTERNAL_LSA
:
5518 case OSPF_OPAQUE_AS_LSA
:
5519 vty_out (vty
, " %s %s%s",
5520 show_database_desc
[type
],
5521 VTY_NEWLINE
, VTY_NEWLINE
);
5522 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5525 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5527 vty_out (vty
, "%s %s (Area %s)%s%s",
5528 VTY_NEWLINE
, show_database_desc
[type
],
5529 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5530 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5537 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5538 struct in_addr
*adv_router
)
5540 struct route_node
*rn
;
5541 struct ospf_lsa
*lsa
;
5543 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5544 if ((lsa
= rn
->info
))
5545 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5547 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5549 if (show_function
[lsa
->data
->type
] != NULL
)
5550 show_function
[lsa
->data
->type
] (vty
, lsa
);
5554 /* Show detail LSA information. */
5556 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5557 struct in_addr
*adv_router
)
5559 struct listnode
*node
;
5560 struct ospf_area
*area
;
5564 case OSPF_AS_EXTERNAL_LSA
:
5565 case OSPF_OPAQUE_AS_LSA
:
5566 vty_out (vty
, " %s %s%s",
5567 show_database_desc
[type
],
5568 VTY_NEWLINE
, VTY_NEWLINE
);
5569 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5573 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5575 vty_out (vty
, "%s %s (Area %s)%s%s",
5576 VTY_NEWLINE
, show_database_desc
[type
],
5577 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5578 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5586 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5588 struct ospf_lsa
*lsa
;
5589 struct route_node
*rn
;
5590 struct ospf_area
*area
;
5591 struct listnode
*node
;
5594 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5596 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5600 case OSPF_AS_EXTERNAL_LSA
:
5601 case OSPF_OPAQUE_AS_LSA
:
5606 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5607 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5609 vty_out (vty
, " %s (Area %s)%s%s",
5610 show_database_desc
[type
],
5611 ospf_area_desc_string (area
),
5612 VTY_NEWLINE
, VTY_NEWLINE
);
5613 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5615 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5616 show_lsa_summary (vty
, lsa
, self
);
5618 vty_out (vty
, "%s", VTY_NEWLINE
);
5623 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5627 case OSPF_AS_EXTERNAL_LSA
:
5628 case OSPF_OPAQUE_AS_LSA
:
5633 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5634 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5636 vty_out (vty
, " %s%s%s",
5637 show_database_desc
[type
],
5638 VTY_NEWLINE
, VTY_NEWLINE
);
5639 vty_out (vty
, "%s%s", show_database_header
[type
],
5642 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5643 show_lsa_summary (vty
, lsa
, self
);
5645 vty_out (vty
, "%s", VTY_NEWLINE
);
5649 vty_out (vty
, "%s", VTY_NEWLINE
);
5653 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5655 struct route_node
*rn
;
5657 vty_out (vty
, "%s MaxAge Link States:%s%s",
5658 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5660 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5662 struct ospf_lsa
*lsa
;
5664 if ((lsa
= rn
->info
) != NULL
)
5666 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5667 vty_out (vty
, "Link State ID: %s%s",
5668 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5669 vty_out (vty
, "Advertising Router: %s%s",
5670 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5671 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5672 vty_out (vty
, "%s", VTY_NEWLINE
);
5677 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5678 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5680 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5681 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5682 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5683 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5685 #define OSPF_LSA_TYPES_CMD_STR \
5686 "asbr-summary|external|network|router|summary" \
5687 OSPF_LSA_TYPE_NSSA_CMD_STR \
5688 OSPF_LSA_TYPE_OPAQUE_CMD_STR
5690 #define OSPF_LSA_TYPES_DESC \
5691 "ASBR summary link states\n" \
5692 "External link states\n" \
5693 "Network link states\n" \
5694 "Router link states\n" \
5695 "Network summary link states\n" \
5696 OSPF_LSA_TYPE_NSSA_DESC \
5697 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5698 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5699 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5702 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5703 int arg_base
, int argc
, const char **argv
)
5706 struct in_addr id
, adv_router
;
5709 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5712 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5713 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5716 if (argc
== arg_base
+ 0)
5718 show_ip_ospf_database_summary (vty
, ospf
, 0);
5722 /* Set database type to show. */
5723 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5724 type
= OSPF_ROUTER_LSA
;
5725 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5726 type
= OSPF_NETWORK_LSA
;
5727 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5728 type
= OSPF_AS_NSSA_LSA
;
5729 else if (strncmp (argv
[arg_base
+ 0], "su", 2) == 0)
5730 type
= OSPF_SUMMARY_LSA
;
5731 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5732 type
= OSPF_ASBR_SUMMARY_LSA
;
5733 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5734 type
= OSPF_AS_EXTERNAL_LSA
;
5735 else if (strncmp (argv
[arg_base
+ 0], "se", 2) == 0)
5737 show_ip_ospf_database_summary (vty
, ospf
, 1);
5740 else if (strncmp (argv
[arg_base
+ 0], "m", 1) == 0)
5742 show_ip_ospf_database_maxage (vty
, ospf
);
5745 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5746 type
= OSPF_OPAQUE_LINK_LSA
;
5747 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5748 type
= OSPF_OPAQUE_AREA_LSA
;
5749 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5750 type
= OSPF_OPAQUE_AS_LSA
;
5754 /* `show ip ospf database LSA'. */
5755 if (argc
== arg_base
+ 1)
5756 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5757 else if (argc
>= arg_base
+ 2)
5759 ret
= inet_aton (argv
[arg_base
+ 1], &id
);
5763 /* `show ip ospf database LSA ID'. */
5764 if (argc
== arg_base
+ 2)
5765 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5766 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5767 else if (argc
== arg_base
+ 3)
5769 if (strncmp (argv
[arg_base
+ 2], "s", 1) == 0)
5770 adv_router
= ospf
->router_id
;
5773 ret
= inet_aton (argv
[arg_base
+ 2], &adv_router
);
5777 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5784 DEFUN (show_ip_ospf_database
,
5785 show_ip_ospf_database_cmd
,
5786 "show ip ospf database",
5789 "OSPF information\n"
5790 "Database summary\n")
5794 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5797 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5800 ALIAS (show_ip_ospf_database
,
5801 show_ip_ospf_database_type_cmd
,
5802 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5805 "OSPF information\n"
5806 "Database summary\n"
5808 "LSAs in MaxAge list\n"
5809 "Self-originated link states\n")
5811 ALIAS (show_ip_ospf_database
,
5812 show_ip_ospf_database_type_id_cmd
,
5813 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5816 "OSPF information\n"
5817 "Database summary\n"
5819 "Link State ID (as an IP address)\n")
5821 ALIAS (show_ip_ospf_database
,
5822 show_ip_ospf_database_type_id_adv_router_cmd
,
5823 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5826 "OSPF information\n"
5827 "Database summary\n"
5829 "Link State ID (as an IP address)\n"
5830 "Advertising Router link states\n"
5831 "Advertising Router (as an IP address)\n")
5833 ALIAS (show_ip_ospf_database
,
5834 show_ip_ospf_database_type_id_self_cmd
,
5835 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5838 "OSPF information\n"
5839 "Database summary\n"
5841 "Link State ID (as an IP address)\n"
5842 "Self-originated link states\n"
5845 DEFUN (show_ip_ospf_instance_database
,
5846 show_ip_ospf_instance_database_cmd
,
5847 "show ip ospf <1-65535> database",
5850 "OSPF information\n"
5852 "Database summary\n")
5855 u_short instance
= 0;
5857 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5859 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5862 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5865 ALIAS (show_ip_ospf_instance_database
,
5866 show_ip_ospf_instance_database_type_cmd
,
5867 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5870 "OSPF information\n"
5872 "Database summary\n"
5874 "LSAs in MaxAge list\n"
5875 "Self-originated link states\n")
5877 ALIAS (show_ip_ospf_instance_database
,
5878 show_ip_ospf_instance_database_type_id_cmd
,
5879 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5882 "OSPF information\n"
5884 "Database summary\n"
5886 "Link State ID (as an IP address)\n")
5888 ALIAS (show_ip_ospf_instance_database
,
5889 show_ip_ospf_instance_database_type_id_adv_router_cmd
,
5890 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5893 "OSPF information\n"
5895 "Database summary\n"
5897 "Link State ID (as an IP address)\n"
5898 "Advertising Router link states\n"
5899 "Advertising Router (as an IP address)\n")
5901 ALIAS (show_ip_ospf_instance_database
,
5902 show_ip_ospf_instance_database_type_id_self_cmd
,
5903 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5906 "OSPF information\n"
5908 "Database summary\n"
5910 "Link State ID (as an IP address)\n"
5911 "Self-originated link states\n"
5916 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5917 int arg_base
, int argc
, const char **argv
)
5920 struct in_addr adv_router
;
5923 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5926 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5927 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5929 if (argc
!= arg_base
+ 2)
5932 /* Set database type to show. */
5933 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5934 type
= OSPF_ROUTER_LSA
;
5935 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5936 type
= OSPF_NETWORK_LSA
;
5937 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5938 type
= OSPF_AS_NSSA_LSA
;
5939 else if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
5940 type
= OSPF_SUMMARY_LSA
;
5941 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5942 type
= OSPF_ASBR_SUMMARY_LSA
;
5943 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5944 type
= OSPF_AS_EXTERNAL_LSA
;
5945 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5946 type
= OSPF_OPAQUE_LINK_LSA
;
5947 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5948 type
= OSPF_OPAQUE_AREA_LSA
;
5949 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5950 type
= OSPF_OPAQUE_AS_LSA
;
5954 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5955 if (strncmp (argv
[arg_base
+ 1], "s", 1) == 0)
5956 adv_router
= ospf
->router_id
;
5959 ret
= inet_aton (argv
[arg_base
+ 1], &adv_router
);
5964 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5969 DEFUN (show_ip_ospf_database_type_adv_router
,
5970 show_ip_ospf_database_type_adv_router_cmd
,
5971 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
5974 "OSPF information\n"
5975 "Database summary\n"
5977 "Advertising Router link states\n"
5978 "Advertising Router (as an IP address)\n")
5982 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5985 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5988 ALIAS (show_ip_ospf_database_type_adv_router
,
5989 show_ip_ospf_database_type_self_cmd
,
5990 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
5993 "OSPF information\n"
5994 "Database summary\n"
5996 "Self-originated link states\n")
5998 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5999 show_ip_ospf_instance_database_type_adv_router_cmd
,
6000 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
6003 "OSPF information\n"
6005 "Database summary\n"
6007 "Advertising Router link states\n"
6008 "Advertising Router (as an IP address)\n")
6011 u_short instance
= 0;
6013 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
6015 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
6018 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
6021 ALIAS (show_ip_ospf_instance_database_type_adv_router
,
6022 show_ip_ospf_instance_database_type_self_cmd
,
6023 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
6026 "OSPF information\n"
6028 "Database summary\n"
6030 "Self-originated link states\n")
6032 DEFUN (ip_ospf_authentication_args
,
6033 ip_ospf_authentication_args_addr_cmd
,
6034 "ip ospf authentication (null|message-digest) A.B.C.D",
6036 "OSPF interface commands\n"
6037 "Enable authentication on this interface\n"
6038 "Use null authentication\n"
6039 "Use message-digest authentication\n"
6040 "Address of interface")
6042 struct interface
*ifp
;
6043 struct in_addr addr
;
6045 struct ospf_if_params
*params
;
6048 params
= IF_DEF_PARAMS (ifp
);
6052 ret
= inet_aton(argv
[1], &addr
);
6055 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6060 params
= ospf_get_if_params (ifp
, addr
);
6061 ospf_if_update_params (ifp
, addr
);
6064 /* Handle null authentication */
6065 if ( argv
[0][0] == 'n' )
6067 SET_IF_PARAM (params
, auth_type
);
6068 params
->auth_type
= OSPF_AUTH_NULL
;
6072 /* Handle message-digest authentication */
6073 if ( argv
[0][0] == 'm' )
6075 SET_IF_PARAM (params
, auth_type
);
6076 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6080 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
6084 ALIAS (ip_ospf_authentication_args
,
6085 ip_ospf_authentication_args_cmd
,
6086 "ip ospf authentication (null|message-digest)",
6088 "OSPF interface commands\n"
6089 "Enable authentication on this interface\n"
6090 "Use null authentication\n"
6091 "Use message-digest authentication\n")
6093 DEFUN (ip_ospf_authentication
,
6094 ip_ospf_authentication_addr_cmd
,
6095 "ip ospf authentication A.B.C.D",
6097 "OSPF interface commands\n"
6098 "Enable authentication on this interface\n"
6099 "Address of interface")
6101 struct interface
*ifp
;
6102 struct in_addr addr
;
6104 struct ospf_if_params
*params
;
6107 params
= IF_DEF_PARAMS (ifp
);
6111 ret
= inet_aton(argv
[0], &addr
);
6114 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6119 params
= ospf_get_if_params (ifp
, addr
);
6120 ospf_if_update_params (ifp
, addr
);
6123 SET_IF_PARAM (params
, auth_type
);
6124 params
->auth_type
= OSPF_AUTH_SIMPLE
;
6129 ALIAS (ip_ospf_authentication
,
6130 ip_ospf_authentication_cmd
,
6131 "ip ospf authentication",
6133 "OSPF interface commands\n"
6134 "Enable authentication on this interface\n")
6136 DEFUN (no_ip_ospf_authentication_args
,
6137 no_ip_ospf_authentication_args_addr_cmd
,
6138 "no ip ospf authentication (null|message-digest) A.B.C.D",
6141 "OSPF interface commands\n"
6142 "Enable authentication on this interface\n"
6143 "Use null authentication\n"
6144 "Use message-digest authentication\n"
6145 "Address of interface")
6147 struct interface
*ifp
;
6148 struct in_addr addr
;
6150 struct ospf_if_params
*params
;
6151 struct route_node
*rn
;
6155 params
= IF_DEF_PARAMS (ifp
);
6159 ret
= inet_aton(argv
[1], &addr
);
6162 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6167 params
= ospf_lookup_if_params (ifp
, addr
);
6170 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6173 params
->auth_type
= OSPF_AUTH_NOTSET
;
6174 UNSET_IF_PARAM (params
, auth_type
);
6175 if (params
!= IF_DEF_PARAMS (ifp
))
6177 ospf_free_if_params (ifp
, addr
);
6178 ospf_if_update_params (ifp
, addr
);
6183 if ( argv
[0][0] == 'n' )
6185 auth_type
= OSPF_AUTH_NULL
;
6187 else if ( argv
[0][0] == 'm' )
6189 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6193 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
6197 * Here we have a case where the user has entered
6198 * 'no ip ospf authentication (null | message_digest )'
6199 * we need to find if we have any ip addresses underneath it that
6200 * correspond to the associated type.
6202 if (params
->auth_type
== auth_type
)
6204 params
->auth_type
= OSPF_AUTH_NOTSET
;
6205 UNSET_IF_PARAM (params
, auth_type
);
6208 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6210 if ((params
= rn
->info
))
6212 if (params
->auth_type
== auth_type
)
6214 params
->auth_type
= OSPF_AUTH_NOTSET
;
6215 UNSET_IF_PARAM (params
, auth_type
);
6216 if (params
!= IF_DEF_PARAMS (ifp
))
6218 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6219 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6229 ALIAS (no_ip_ospf_authentication_args
,
6230 no_ip_ospf_authentication_args_cmd
,
6231 "no ip ospf authentication (null|message-digest)",
6234 "OSPF interface commands\n"
6235 "Enable authentication on this interface\n"
6236 "Use null authentication\n"
6237 "Use message-digest authentication\n")
6239 DEFUN (no_ip_ospf_authentication
,
6240 no_ip_ospf_authentication_addr_cmd
,
6241 "no ip ospf authentication A.B.C.D",
6244 "OSPF interface commands\n"
6245 "Enable authentication on this interface\n"
6246 "Address of interface")
6248 struct interface
*ifp
;
6249 struct in_addr addr
;
6251 struct ospf_if_params
*params
;
6252 struct route_node
*rn
;
6255 params
= IF_DEF_PARAMS (ifp
);
6259 ret
= inet_aton(argv
[0], &addr
);
6262 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6267 params
= ospf_lookup_if_params (ifp
, addr
);
6270 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6274 params
->auth_type
= OSPF_AUTH_NOTSET
;
6275 UNSET_IF_PARAM (params
, auth_type
);
6276 if (params
!= IF_DEF_PARAMS (ifp
))
6278 ospf_free_if_params (ifp
, addr
);
6279 ospf_if_update_params (ifp
, addr
);
6285 * When a user enters 'no ip ospf authentication'
6286 * We should remove all authentication types from
6289 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6290 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6291 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6293 params
->auth_type
= OSPF_AUTH_NOTSET
;
6294 UNSET_IF_PARAM (params
, auth_type
);
6297 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6299 if ((params
= rn
->info
))
6302 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6303 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6304 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6306 params
->auth_type
= OSPF_AUTH_NOTSET
;
6307 UNSET_IF_PARAM (params
, auth_type
);
6308 if (params
!= IF_DEF_PARAMS (ifp
))
6310 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6311 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6321 ALIAS (no_ip_ospf_authentication
,
6322 no_ip_ospf_authentication_cmd
,
6323 "no ip ospf authentication",
6326 "OSPF interface commands\n"
6327 "Enable authentication on this interface\n")
6329 DEFUN (ip_ospf_authentication_key
,
6330 ip_ospf_authentication_key_addr_cmd
,
6331 "ip ospf authentication-key AUTH_KEY A.B.C.D",
6333 "OSPF interface commands\n"
6334 "Authentication password (key)\n"
6335 "The OSPF password (key)\n"
6336 "Address of interface")
6338 struct interface
*ifp
;
6339 struct in_addr addr
;
6341 struct ospf_if_params
*params
;
6344 params
= IF_DEF_PARAMS (ifp
);
6348 ret
= inet_aton(argv
[1], &addr
);
6351 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6356 params
= ospf_get_if_params (ifp
, addr
);
6357 ospf_if_update_params (ifp
, addr
);
6360 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6361 strncpy ((char *) params
->auth_simple
, argv
[0], OSPF_AUTH_SIMPLE_SIZE
);
6362 SET_IF_PARAM (params
, auth_simple
);
6367 ALIAS (ip_ospf_authentication_key
,
6368 ip_ospf_authentication_key_cmd
,
6369 "ip ospf authentication-key AUTH_KEY",
6371 "OSPF interface commands\n"
6372 "Authentication password (key)\n"
6373 "The OSPF password (key)")
6375 ALIAS_HIDDEN (ip_ospf_authentication_key
,
6376 ospf_authentication_key_cmd
,
6377 "ospf authentication-key AUTH_KEY",
6378 "OSPF interface commands\n"
6379 "Authentication password (key)\n"
6380 "The OSPF password (key)")
6382 DEFUN (no_ip_ospf_authentication_key
,
6383 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6384 "no ip ospf authentication-key AUTH_KEY A.B.C.D",
6387 "OSPF interface commands\n"
6388 "Authentication password (key)\n"
6389 "The OSPF password (key)")
6391 struct interface
*ifp
;
6392 struct in_addr addr
;
6393 struct ospf_if_params
*params
;
6397 params
= IF_DEF_PARAMS (ifp
);
6401 ret
= inet_aton(argv
[1], &addr
);
6404 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6409 params
= ospf_lookup_if_params (ifp
, addr
);
6414 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6415 UNSET_IF_PARAM (params
, auth_simple
);
6417 if (params
!= IF_DEF_PARAMS (ifp
))
6419 ospf_free_if_params (ifp
, addr
);
6420 ospf_if_update_params (ifp
, addr
);
6426 ALIAS (no_ip_ospf_authentication_key
,
6427 no_ip_ospf_authentication_key_authkey_cmd
,
6428 "no ip ospf authentication-key AUTH_KEY",
6431 "OSPF interface commands\n"
6432 "Authentication password (key)\n")
6434 ALIAS (no_ip_ospf_authentication_key
,
6435 no_ip_ospf_authentication_key_cmd
,
6436 "no ip ospf authentication-key",
6439 "OSPF interface commands\n"
6440 "Authentication password (key)\n")
6442 ALIAS (no_ip_ospf_authentication_key
,
6443 no_ospf_authentication_key_cmd
,
6444 "no ospf authentication-key",
6446 "OSPF interface commands\n"
6447 "Authentication password (key)\n")
6449 ALIAS (no_ip_ospf_authentication_key
,
6450 no_ospf_authentication_key_authkey_cmd
,
6451 "no ospf authentication-key AUTH_KEY",
6453 "OSPF interface commands\n"
6454 "Authentication password (key)\n"
6455 "The OSPF password (key)\n")
6457 ALIAS (no_ip_ospf_authentication_key
,
6458 no_ospf_authentication_key_authkey_ip_cmd
,
6459 "no ospf authentication-key AUTH_KEY A.B.C.D",
6461 "OSPF interface commands\n"
6462 "Authentication password (key)\n"
6463 "The OSPF password (key)\n"
6464 "Address of interface")
6466 DEFUN (ip_ospf_message_digest_key
,
6467 ip_ospf_message_digest_key_addr_cmd
,
6468 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6470 "OSPF interface commands\n"
6471 "Message digest authentication password (key)\n"
6473 "Use MD5 algorithm\n"
6474 "The OSPF password (key)"
6475 "Address of interface")
6477 struct interface
*ifp
;
6478 struct crypt_key
*ck
;
6480 struct in_addr addr
;
6482 struct ospf_if_params
*params
;
6485 params
= IF_DEF_PARAMS (ifp
);
6489 ret
= inet_aton(argv
[2], &addr
);
6492 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6497 params
= ospf_get_if_params (ifp
, addr
);
6498 ospf_if_update_params (ifp
, addr
);
6501 key_id
= strtol (argv
[0], NULL
, 10);
6502 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6504 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6508 ck
= ospf_crypt_key_new ();
6509 ck
->key_id
= (u_char
) key_id
;
6510 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6511 strncpy ((char *) ck
->auth_key
, argv
[1], OSPF_AUTH_MD5_SIZE
);
6513 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6514 SET_IF_PARAM (params
, auth_crypt
);
6519 ALIAS (ip_ospf_message_digest_key
,
6520 ip_ospf_message_digest_key_cmd
,
6521 "ip ospf message-digest-key <1-255> md5 KEY",
6523 "OSPF interface commands\n"
6524 "Message digest authentication password (key)\n"
6526 "Use MD5 algorithm\n"
6527 "The OSPF password (key)")
6529 ALIAS_HIDDEN (ip_ospf_message_digest_key
,
6530 ospf_message_digest_key_cmd
,
6531 "ospf message-digest-key <1-255> md5 KEY",
6532 "OSPF interface commands\n"
6533 "Message digest authentication password (key)\n"
6535 "Use MD5 algorithm\n"
6536 "The OSPF password (key)")
6538 DEFUN (no_ip_ospf_message_digest_key_md5
,
6539 no_ip_ospf_message_digest_key_md5_addr_cmd
,
6540 "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6543 "OSPF interface commands\n"
6544 "Message digest authentication password (key)\n"
6546 "Use MD5 algorithm\n"
6547 "The OSPF password (key)"
6548 "Address of interface")
6550 struct interface
*ifp
;
6551 struct crypt_key
*ck
;
6553 struct in_addr addr
;
6555 struct ospf_if_params
*params
;
6558 params
= IF_DEF_PARAMS (ifp
);
6562 ret
= inet_aton(argv
[2], &addr
);
6565 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6570 params
= ospf_lookup_if_params (ifp
, addr
);
6575 key_id
= strtol (argv
[0], NULL
, 10);
6576 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6579 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6583 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6585 if (params
!= IF_DEF_PARAMS (ifp
))
6587 ospf_free_if_params (ifp
, addr
);
6588 ospf_if_update_params (ifp
, addr
);
6594 ALIAS (no_ip_ospf_message_digest_key_md5
,
6595 no_ip_ospf_message_digest_key_md5_cmd
,
6596 "no ip ospf message-digest-key <1-255> md5 KEY",
6599 "OSPF interface commands\n"
6600 "Message digest authentication password (key)\n"
6602 "Use MD5 algorithm\n"
6603 "The OSPF password (key)")
6605 DEFUN (no_ip_ospf_message_digest_key
,
6606 no_ip_ospf_message_digest_key_addr_cmd
,
6607 "no ip ospf message-digest-key <1-255> A.B.C.D",
6610 "OSPF interface commands\n"
6611 "Message digest authentication password (key)\n"
6613 "Address of interface")
6615 struct interface
*ifp
;
6616 struct crypt_key
*ck
;
6618 struct in_addr addr
;
6620 struct ospf_if_params
*params
;
6623 params
= IF_DEF_PARAMS (ifp
);
6627 ret
= inet_aton(argv
[1], &addr
);
6630 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6635 params
= ospf_lookup_if_params (ifp
, addr
);
6640 key_id
= strtol (argv
[0], NULL
, 10);
6641 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6644 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6648 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6650 if (params
!= IF_DEF_PARAMS (ifp
))
6652 ospf_free_if_params (ifp
, addr
);
6653 ospf_if_update_params (ifp
, addr
);
6659 ALIAS (no_ip_ospf_message_digest_key
,
6660 no_ip_ospf_message_digest_key_cmd
,
6661 "no ip ospf message-digest-key <1-255>",
6664 "OSPF interface commands\n"
6665 "Message digest authentication password (key)\n"
6668 ALIAS (no_ip_ospf_message_digest_key
,
6669 no_ospf_message_digest_key_cmd
,
6670 "no ospf message-digest-key <1-255>",
6672 "OSPF interface commands\n"
6673 "Message digest authentication password (key)\n"
6676 DEFUN (ip_ospf_cost
,
6677 ip_ospf_cost_u32_inet4_cmd
,
6678 "ip ospf cost <1-65535> A.B.C.D",
6680 "OSPF interface commands\n"
6683 "Address of interface")
6685 struct interface
*ifp
= vty
->index
;
6687 struct in_addr addr
;
6689 struct ospf_if_params
*params
;
6691 params
= IF_DEF_PARAMS (ifp
);
6693 cost
= strtol (argv
[0], NULL
, 10);
6695 /* cost range is <1-65535>. */
6696 if (cost
< 1 || cost
> 65535)
6698 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6704 ret
= inet_aton(argv
[1], &addr
);
6707 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6712 params
= ospf_get_if_params (ifp
, addr
);
6713 ospf_if_update_params (ifp
, addr
);
6716 SET_IF_PARAM (params
, output_cost_cmd
);
6717 params
->output_cost_cmd
= cost
;
6719 ospf_if_recalculate_output_cost (ifp
);
6724 ALIAS (ip_ospf_cost
,
6725 ip_ospf_cost_u32_cmd
,
6726 "ip ospf cost <1-65535>",
6728 "OSPF interface commands\n"
6732 ALIAS_HIDDEN (ip_ospf_cost
,
6734 "ospf cost <1-65535>",
6735 "OSPF interface commands\n"
6739 ALIAS_HIDDEN (ip_ospf_cost
,
6740 ospf_cost_u32_inet4_cmd
,
6741 "ospf cost <1-65535> A.B.C.D",
6742 "OSPF interface commands\n"
6745 "Address of interface")
6747 DEFUN (no_ip_ospf_cost
,
6748 no_ip_ospf_cost_inet4_cmd
,
6749 "no ip ospf cost A.B.C.D",
6752 "OSPF interface commands\n"
6754 "Address of interface")
6756 struct interface
*ifp
= vty
->index
;
6757 struct in_addr addr
;
6759 struct ospf_if_params
*params
;
6762 params
= IF_DEF_PARAMS (ifp
);
6766 ret
= inet_aton(argv
[0], &addr
);
6769 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6774 params
= ospf_lookup_if_params (ifp
, addr
);
6779 UNSET_IF_PARAM (params
, output_cost_cmd
);
6781 if (params
!= IF_DEF_PARAMS (ifp
))
6783 ospf_free_if_params (ifp
, addr
);
6784 ospf_if_update_params (ifp
, addr
);
6787 ospf_if_recalculate_output_cost (ifp
);
6792 ALIAS (no_ip_ospf_cost
,
6793 no_ip_ospf_cost_cmd
,
6797 "OSPF interface commands\n"
6800 ALIAS (no_ip_ospf_cost
,
6804 "OSPF interface commands\n"
6807 ALIAS (no_ip_ospf_cost
,
6808 no_ospf_cost_inet4_cmd
,
6809 "no ospf cost A.B.C.D",
6811 "OSPF interface commands\n"
6813 "Address of interface")
6815 DEFUN (no_ip_ospf_cost2
,
6816 no_ip_ospf_cost_u32_cmd
,
6817 "no ip ospf cost <1-65535>",
6820 "OSPF interface commands\n"
6824 struct interface
*ifp
= vty
->index
;
6825 struct in_addr addr
;
6828 struct ospf_if_params
*params
;
6831 params
= IF_DEF_PARAMS (ifp
);
6833 /* According to the semantics we are mimicking "no ip ospf cost N" is
6834 * always treated as "no ip ospf cost" regardless of the actual value
6835 * of N already configured for the interface. Thus the first argument
6836 * is always checked to be a number, but is ignored after that.
6838 cost
= strtol (argv
[0], NULL
, 10);
6839 if (cost
< 1 || cost
> 65535)
6841 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6847 ret
= inet_aton(argv
[1], &addr
);
6850 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6855 params
= ospf_lookup_if_params (ifp
, addr
);
6860 UNSET_IF_PARAM (params
, output_cost_cmd
);
6862 if (params
!= IF_DEF_PARAMS (ifp
))
6864 ospf_free_if_params (ifp
, addr
);
6865 ospf_if_update_params (ifp
, addr
);
6868 ospf_if_recalculate_output_cost (ifp
);
6873 ALIAS (no_ip_ospf_cost2
,
6874 no_ospf_cost_u32_cmd
,
6875 "no ospf cost <1-65535>",
6877 "OSPF interface commands\n"
6881 ALIAS (no_ip_ospf_cost2
,
6882 no_ip_ospf_cost_u32_inet4_cmd
,
6883 "no ip ospf cost <1-65535> A.B.C.D",
6886 "OSPF interface commands\n"
6889 "Address of interface")
6891 ALIAS (no_ip_ospf_cost2
,
6892 no_ospf_cost_u32_inet4_cmd
,
6893 "no ospf cost <1-65535> A.B.C.D",
6895 "OSPF interface commands\n"
6898 "Address of interface")
6901 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6903 struct route_node
*rn
;
6904 struct ospf_neighbor
*nbr
;
6906 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6907 if ((nbr
= rn
->info
))
6909 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6910 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6911 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6912 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6917 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6918 const char *nbr_str
,
6919 const char *fast_hello_str
)
6921 struct interface
*ifp
= vty
->index
;
6924 struct in_addr addr
;
6926 struct ospf_if_params
*params
;
6927 struct ospf_interface
*oi
;
6928 struct route_node
*rn
;
6930 params
= IF_DEF_PARAMS (ifp
);
6934 ret
= inet_aton(nbr_str
, &addr
);
6937 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6942 params
= ospf_get_if_params (ifp
, addr
);
6943 ospf_if_update_params (ifp
, addr
);
6948 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6951 /* reset fast_hello too, just to be sure */
6952 UNSET_IF_PARAM (params
, fast_hello
);
6953 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6955 else if (fast_hello_str
)
6957 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6959 /* 1s dead-interval with sub-second hellos desired */
6960 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6961 SET_IF_PARAM (params
, fast_hello
);
6962 params
->fast_hello
= hellomult
;
6966 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6971 SET_IF_PARAM (params
, v_wait
);
6972 params
->v_wait
= seconds
;
6974 /* Update timer values in neighbor structure. */
6978 if ((ospf
= ospf_lookup()))
6980 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6982 ospf_nbr_timer_update (oi
);
6987 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6988 if ((oi
= rn
->info
))
6989 ospf_nbr_timer_update (oi
);
6996 DEFUN (ip_ospf_dead_interval
,
6997 ip_ospf_dead_interval_addr_cmd
,
6998 "ip ospf dead-interval <1-65535> A.B.C.D",
7000 "OSPF interface commands\n"
7001 "Interval after which a neighbor is declared dead\n"
7003 "Address of interface\n")
7006 return ospf_vty_dead_interval_set (vty
, argv
[0], argv
[1], NULL
);
7008 return ospf_vty_dead_interval_set (vty
, argv
[0], NULL
, NULL
);
7011 ALIAS (ip_ospf_dead_interval
,
7012 ip_ospf_dead_interval_cmd
,
7013 "ip ospf dead-interval <1-65535>",
7015 "OSPF interface commands\n"
7016 "Interval after which a neighbor is declared dead\n"
7019 ALIAS_HIDDEN (ip_ospf_dead_interval
,
7020 ospf_dead_interval_cmd
,
7021 "ospf dead-interval <1-65535>",
7022 "OSPF interface commands\n"
7023 "Interval after which a neighbor is declared dead\n"
7026 DEFUN (ip_ospf_dead_interval_minimal
,
7027 ip_ospf_dead_interval_minimal_addr_cmd
,
7028 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7030 "OSPF interface commands\n"
7031 "Interval after which a neighbor is declared dead\n"
7032 "Minimal 1s dead-interval with fast sub-second hellos\n"
7033 "Hello multiplier factor\n"
7034 "Number of Hellos to send each second\n"
7035 "Address of interface\n")
7038 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[1], argv
[0]);
7040 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[0]);
7043 ALIAS (ip_ospf_dead_interval_minimal
,
7044 ip_ospf_dead_interval_minimal_cmd
,
7045 "ip ospf dead-interval minimal hello-multiplier <1-10>",
7047 "OSPF interface commands\n"
7048 "Interval after which a neighbor is declared dead\n"
7049 "Minimal 1s dead-interval with fast sub-second hellos\n"
7050 "Hello multiplier factor\n"
7051 "Number of Hellos to send each second\n")
7053 DEFUN (no_ip_ospf_dead_interval
,
7054 no_ip_ospf_dead_interval_addr_cmd
,
7055 "no ip ospf dead-interval <1-65535> A.B.C.D",
7058 "OSPF interface commands\n"
7059 "Interval after which a neighbor is declared dead\n"
7061 "Address of interface")
7063 struct interface
*ifp
= vty
->index
;
7064 struct in_addr addr
;
7066 struct ospf_if_params
*params
;
7067 struct ospf_interface
*oi
;
7068 struct route_node
*rn
;
7071 params
= IF_DEF_PARAMS (ifp
);
7075 ret
= inet_aton(argv
[1], &addr
);
7078 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7083 params
= ospf_lookup_if_params (ifp
, addr
);
7088 UNSET_IF_PARAM (params
, v_wait
);
7089 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7091 UNSET_IF_PARAM (params
, fast_hello
);
7092 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7094 if (params
!= IF_DEF_PARAMS (ifp
))
7096 ospf_free_if_params (ifp
, addr
);
7097 ospf_if_update_params (ifp
, addr
);
7100 /* Update timer values in neighbor structure. */
7105 if ((ospf
= ospf_lookup()))
7107 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
7109 ospf_nbr_timer_update (oi
);
7114 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7115 if ((oi
= rn
->info
))
7116 ospf_nbr_timer_update (oi
);
7122 ALIAS (no_ip_ospf_dead_interval
,
7123 no_ip_ospf_dead_interval_seconds_cmd
,
7124 "no ip ospf dead-interval <1-65535>",
7127 "OSPF interface commands\n"
7128 "Interval after which a neighbor is declared dead\n"
7131 ALIAS (no_ip_ospf_dead_interval
,
7132 no_ip_ospf_dead_interval_cmd
,
7133 "no ip ospf dead-interval",
7136 "OSPF interface commands\n"
7137 "Interval after which a neighbor is declared dead\n")
7139 ALIAS (no_ip_ospf_dead_interval
,
7140 no_ospf_dead_interval_cmd
,
7141 "no ospf dead-interval",
7143 "OSPF interface commands\n"
7144 "Interval after which a neighbor is declared dead\n")
7146 ALIAS (no_ip_ospf_dead_interval
,
7147 no_ip_ospf_dead_interval_minimal_addr_cmd
,
7148 "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7151 "OSPF interface commands\n"
7152 "Interval after which a neighbor is declared dead\n"
7153 "Minimal 1s dead-interval with fast sub-second hellos\n"
7154 "Hello multiplier factor\n"
7155 "Number of Hellos to send each second\n"
7156 "Address of interface\n")
7158 ALIAS (no_ip_ospf_dead_interval
,
7159 no_ip_ospf_dead_interval_minimal_cmd
,
7160 "no ip ospf dead-interval minimal hello-multiplier <1-10>",
7163 "OSPF interface commands\n"
7164 "Interval after which a neighbor is declared dead\n"
7165 "Minimal 1s dead-interval with fast sub-second hellos\n"
7166 "Hello multiplier factor\n"
7167 "Number of Hellos to send each second\n")
7169 DEFUN (ip_ospf_hello_interval
,
7170 ip_ospf_hello_interval_addr_cmd
,
7171 "ip ospf hello-interval <1-65535> A.B.C.D",
7173 "OSPF interface commands\n"
7174 "Time between HELLO packets\n"
7176 "Address of interface")
7178 struct interface
*ifp
= vty
->index
;
7180 struct in_addr addr
;
7182 struct ospf_if_params
*params
;
7184 params
= IF_DEF_PARAMS (ifp
);
7186 seconds
= strtol (argv
[0], NULL
, 10);
7188 /* HelloInterval range is <1-65535>. */
7189 if (seconds
< 1 || seconds
> 65535)
7191 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7197 ret
= inet_aton(argv
[1], &addr
);
7200 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7205 params
= ospf_get_if_params (ifp
, addr
);
7206 ospf_if_update_params (ifp
, addr
);
7209 SET_IF_PARAM (params
, v_hello
);
7210 params
->v_hello
= seconds
;
7215 ALIAS (ip_ospf_hello_interval
,
7216 ip_ospf_hello_interval_cmd
,
7217 "ip ospf hello-interval <1-65535>",
7219 "OSPF interface commands\n"
7220 "Time between HELLO packets\n"
7223 ALIAS_HIDDEN (ip_ospf_hello_interval
,
7224 ospf_hello_interval_cmd
,
7225 "ospf hello-interval <1-65535>",
7226 "OSPF interface commands\n"
7227 "Time between HELLO packets\n"
7230 DEFUN (no_ip_ospf_hello_interval
,
7231 no_ip_ospf_hello_interval_addr_cmd
,
7232 "no ip ospf hello-interval <1-65535> A.B.C.D",
7235 "OSPF interface commands\n"
7236 "Time between HELLO packets\n"
7238 "Address of interface")
7240 struct interface
*ifp
= vty
->index
;
7241 struct in_addr addr
;
7243 struct ospf_if_params
*params
;
7246 params
= IF_DEF_PARAMS (ifp
);
7250 ret
= inet_aton(argv
[1], &addr
);
7253 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7258 params
= ospf_lookup_if_params (ifp
, addr
);
7263 UNSET_IF_PARAM (params
, v_hello
);
7264 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7266 if (params
!= IF_DEF_PARAMS (ifp
))
7268 ospf_free_if_params (ifp
, addr
);
7269 ospf_if_update_params (ifp
, addr
);
7275 ALIAS (no_ip_ospf_hello_interval
,
7276 no_ip_ospf_hello_interval_seconds_cmd
,
7277 "no ip ospf hello-interval <1-65535>",
7280 "OSPF interface commands\n"
7281 "Time between HELLO packets\n"
7284 ALIAS (no_ip_ospf_hello_interval
,
7285 no_ip_ospf_hello_interval_cmd
,
7286 "no ip ospf hello-interval",
7289 "OSPF interface commands\n"
7290 "Time between HELLO packets\n")
7292 ALIAS (no_ip_ospf_hello_interval
,
7293 no_ospf_hello_interval_cmd
,
7294 "no ospf hello-interval <1-65535>",
7296 "OSPF interface commands\n"
7297 "Time between HELLO packets\n"
7300 DEFUN (ip_ospf_network
,
7301 ip_ospf_network_cmd
,
7302 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7304 "OSPF interface commands\n"
7306 "Specify OSPF broadcast multi-access network\n"
7307 "Specify OSPF NBMA network\n"
7308 "Specify OSPF point-to-multipoint network\n"
7309 "Specify OSPF point-to-point network\n")
7311 struct interface
*ifp
= vty
->index
;
7312 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7313 struct route_node
*rn
;
7315 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7317 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7321 if (strncmp (argv
[0], "b", 1) == 0)
7322 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7323 else if (strncmp (argv
[0], "n", 1) == 0)
7324 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7325 else if (strncmp (argv
[0], "point-to-m", 10) == 0)
7326 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7327 else if (strncmp (argv
[0], "point-to-p", 10) == 0)
7328 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7330 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7333 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7335 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7337 struct ospf_interface
*oi
= rn
->info
;
7342 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7344 if (oi
->state
> ISM_Down
)
7346 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7347 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7354 ALIAS_HIDDEN (ip_ospf_network
,
7356 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7357 "OSPF interface commands\n"
7359 "Specify OSPF broadcast multi-access network\n"
7360 "Specify OSPF NBMA network\n"
7361 "Specify OSPF point-to-multipoint network\n"
7362 "Specify OSPF point-to-point network\n")
7364 DEFUN (no_ip_ospf_network
,
7365 no_ip_ospf_network_cmd
,
7366 "no ip ospf network",
7369 "OSPF interface commands\n"
7372 struct interface
*ifp
= vty
->index
;
7373 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7374 struct route_node
*rn
;
7376 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7378 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7381 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7383 struct ospf_interface
*oi
= rn
->info
;
7388 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7390 if (oi
->state
> ISM_Down
)
7392 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7393 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7400 ALIAS (no_ip_ospf_network
,
7401 no_ip_ospf_network_val_cmd
,
7402 "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7405 "OSPF interface commands\n"
7407 "Specify OSPF broadcast multi-access network\n"
7408 "Specify OSPF NBMA network\n"
7409 "Specify OSPF point-to-multipoint network\n"
7410 "Specify OSPF point-to-point network\n")
7412 ALIAS (no_ip_ospf_network
,
7413 no_ospf_network_cmd
,
7416 "OSPF interface commands\n"
7419 ALIAS (no_ip_ospf_network
,
7420 no_ospf_network_val_cmd
,
7421 "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7423 "OSPF interface commands\n"
7425 "Specify OSPF broadcast multi-access network\n"
7426 "Specify OSPF NBMA network\n"
7427 "Specify OSPF point-to-multipoint network\n"
7428 "Specify OSPF point-to-point network\n")
7430 DEFUN (ip_ospf_priority
,
7431 ip_ospf_priority_addr_cmd
,
7432 "ip ospf priority <0-255> A.B.C.D",
7434 "OSPF interface commands\n"
7437 "Address of interface")
7439 struct interface
*ifp
= vty
->index
;
7441 struct route_node
*rn
;
7442 struct in_addr addr
;
7444 struct ospf_if_params
*params
;
7446 params
= IF_DEF_PARAMS (ifp
);
7448 priority
= strtol (argv
[0], NULL
, 10);
7450 /* Router Priority range is <0-255>. */
7451 if (priority
< 0 || priority
> 255)
7453 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7459 ret
= inet_aton(argv
[1], &addr
);
7462 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7467 params
= ospf_get_if_params (ifp
, addr
);
7468 ospf_if_update_params (ifp
, addr
);
7471 SET_IF_PARAM (params
, priority
);
7472 params
->priority
= priority
;
7474 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7476 struct ospf_interface
*oi
= rn
->info
;
7482 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7484 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7485 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7492 ALIAS (ip_ospf_priority
,
7493 ip_ospf_priority_cmd
,
7494 "ip ospf priority <0-255>",
7496 "OSPF interface commands\n"
7500 ALIAS_HIDDEN (ip_ospf_priority
,
7502 "ospf priority <0-255>",
7503 "OSPF interface commands\n"
7507 DEFUN (no_ip_ospf_priority
,
7508 no_ip_ospf_priority_addr_cmd
,
7509 "no ip ospf priority <0-255> A.B.C.D",
7512 "OSPF interface commands\n"
7515 "Address of interface")
7517 struct interface
*ifp
= vty
->index
;
7518 struct route_node
*rn
;
7519 struct in_addr addr
;
7521 struct ospf_if_params
*params
;
7524 params
= IF_DEF_PARAMS (ifp
);
7528 ret
= inet_aton(argv
[1], &addr
);
7531 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7536 params
= ospf_lookup_if_params (ifp
, addr
);
7541 UNSET_IF_PARAM (params
, priority
);
7542 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7544 if (params
!= IF_DEF_PARAMS (ifp
))
7546 ospf_free_if_params (ifp
, addr
);
7547 ospf_if_update_params (ifp
, addr
);
7550 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7552 struct ospf_interface
*oi
= rn
->info
;
7558 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7560 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7561 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7568 ALIAS (no_ip_ospf_priority
,
7569 no_ip_ospf_priority_no_param_cmd
,
7570 "no ip ospf priority",
7573 "OSPF interface commands\n"
7574 "Router priority\n");
7576 ALIAS (no_ip_ospf_priority
,
7577 no_ip_ospf_priority_cmd
,
7578 "no ip ospf priority <0-255>",
7581 "OSPF interface commands\n"
7585 ALIAS (no_ip_ospf_priority
,
7586 no_ospf_priority_cmd
,
7587 "no ospf priority <0-255>",
7589 "OSPF interface commands\n"
7594 DEFUN (ip_ospf_retransmit_interval
,
7595 ip_ospf_retransmit_interval_addr_cmd
,
7596 "ip ospf retransmit-interval <3-65535> A.B.C.D",
7598 "OSPF interface commands\n"
7599 "Time between retransmitting lost link state advertisements\n"
7601 "Address of interface")
7603 struct interface
*ifp
= vty
->index
;
7605 struct in_addr addr
;
7607 struct ospf_if_params
*params
;
7609 params
= IF_DEF_PARAMS (ifp
);
7610 seconds
= strtol (argv
[0], NULL
, 10);
7612 /* Retransmit Interval range is <3-65535>. */
7613 if (seconds
< 3 || seconds
> 65535)
7615 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7622 ret
= inet_aton(argv
[1], &addr
);
7625 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7630 params
= ospf_get_if_params (ifp
, addr
);
7631 ospf_if_update_params (ifp
, addr
);
7634 SET_IF_PARAM (params
, retransmit_interval
);
7635 params
->retransmit_interval
= seconds
;
7640 ALIAS (ip_ospf_retransmit_interval
,
7641 ip_ospf_retransmit_interval_cmd
,
7642 "ip ospf retransmit-interval <3-65535>",
7644 "OSPF interface commands\n"
7645 "Time between retransmitting lost link state advertisements\n"
7648 ALIAS_HIDDEN (ip_ospf_retransmit_interval
,
7649 ospf_retransmit_interval_cmd
,
7650 "ospf retransmit-interval <3-65535>",
7651 "OSPF interface commands\n"
7652 "Time between retransmitting lost link state advertisements\n"
7655 DEFUN (no_ip_ospf_retransmit_interval
,
7656 no_ip_ospf_retransmit_interval_addr_cmd
,
7657 "no ip ospf retransmit-interval A.B.C.D",
7660 "OSPF interface commands\n"
7661 "Time between retransmitting lost link state advertisements\n"
7662 "Address of interface")
7664 struct interface
*ifp
= vty
->index
;
7665 struct in_addr addr
;
7667 struct ospf_if_params
*params
;
7671 params
= IF_DEF_PARAMS (ifp
);
7680 ret
= inet_aton(argv
[addr_index
], &addr
);
7683 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7688 params
= ospf_lookup_if_params (ifp
, addr
);
7693 UNSET_IF_PARAM (params
, retransmit_interval
);
7694 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7696 if (params
!= IF_DEF_PARAMS (ifp
))
7698 ospf_free_if_params (ifp
, addr
);
7699 ospf_if_update_params (ifp
, addr
);
7705 ALIAS (no_ip_ospf_retransmit_interval
,
7706 no_ip_ospf_retransmit_interval_sec_addr_cmd
,
7707 "no ip ospf retransmit-interval <3-65535> A.B.C.D",
7710 "OSPF interface commands\n"
7711 "Time between retransmitting lost link state advertisements\n"
7713 "Address of interface")
7715 ALIAS (no_ip_ospf_retransmit_interval
,
7716 no_ip_ospf_retransmit_interval_cmd
,
7717 "no ip ospf retransmit-interval",
7720 "OSPF interface commands\n"
7721 "Time between retransmitting lost link state advertisements\n")
7723 ALIAS (no_ip_ospf_retransmit_interval
,
7724 no_ospf_retransmit_interval_cmd
,
7725 "no ospf retransmit-interval",
7727 "OSPF interface commands\n"
7728 "Time between retransmitting lost link state advertisements\n")
7730 DEFUN (no_ip_ospf_retransmit_interval_sec
,
7731 no_ip_ospf_retransmit_interval_sec_cmd
,
7732 "no ip ospf retransmit-interval <3-65535>",
7735 "OSPF interface commands\n"
7736 "Time between retransmitting lost link state advertisements\n"
7739 struct interface
*ifp
= vty
->index
;
7740 struct ospf_if_params
*params
;
7743 params
= IF_DEF_PARAMS (ifp
);
7745 UNSET_IF_PARAM (params
, retransmit_interval
);
7746 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7752 DEFUN (ip_ospf_transmit_delay
,
7753 ip_ospf_transmit_delay_addr_cmd
,
7754 "ip ospf transmit-delay <1-65535> A.B.C.D",
7756 "OSPF interface commands\n"
7757 "Link state transmit delay\n"
7759 "Address of interface")
7761 struct interface
*ifp
= vty
->index
;
7763 struct in_addr addr
;
7765 struct ospf_if_params
*params
;
7767 params
= IF_DEF_PARAMS (ifp
);
7768 seconds
= strtol (argv
[0], NULL
, 10);
7770 /* Transmit Delay range is <1-65535>. */
7771 if (seconds
< 1 || seconds
> 65535)
7773 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7779 ret
= inet_aton(argv
[1], &addr
);
7782 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7787 params
= ospf_get_if_params (ifp
, addr
);
7788 ospf_if_update_params (ifp
, addr
);
7791 SET_IF_PARAM (params
, transmit_delay
);
7792 params
->transmit_delay
= seconds
;
7797 ALIAS (ip_ospf_transmit_delay
,
7798 ip_ospf_transmit_delay_cmd
,
7799 "ip ospf transmit-delay <1-65535>",
7801 "OSPF interface commands\n"
7802 "Link state transmit delay\n"
7805 ALIAS_HIDDEN (ip_ospf_transmit_delay
,
7806 ospf_transmit_delay_cmd
,
7807 "ospf transmit-delay <1-65535>",
7808 "OSPF interface commands\n"
7809 "Link state transmit delay\n"
7812 DEFUN (no_ip_ospf_transmit_delay
,
7813 no_ip_ospf_transmit_delay_addr_cmd
,
7814 "no ip ospf transmit-delay A.B.C.D",
7817 "OSPF interface commands\n"
7818 "Link state transmit delay\n"
7819 "Address of interface")
7821 struct interface
*ifp
= vty
->index
;
7822 struct in_addr addr
;
7824 struct ospf_if_params
*params
;
7828 params
= IF_DEF_PARAMS (ifp
);
7837 ret
= inet_aton(argv
[addr_index
], &addr
);
7840 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7845 params
= ospf_lookup_if_params (ifp
, addr
);
7850 UNSET_IF_PARAM (params
, transmit_delay
);
7851 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7853 if (params
!= IF_DEF_PARAMS (ifp
))
7855 ospf_free_if_params (ifp
, addr
);
7856 ospf_if_update_params (ifp
, addr
);
7862 ALIAS (no_ip_ospf_transmit_delay
,
7863 no_ip_ospf_transmit_delay_sec_addr_cmd
,
7864 "no ip ospf transmit-delay <1-65535> A.B.C.D",
7867 "OSPF interface commands\n"
7868 "Link state transmit delay\n"
7870 "Address of interface")
7872 ALIAS (no_ip_ospf_transmit_delay
,
7873 no_ip_ospf_transmit_delay_cmd
,
7874 "no ip ospf transmit-delay",
7877 "OSPF interface commands\n"
7878 "Link state transmit delay\n")
7880 ALIAS (no_ip_ospf_transmit_delay
,
7881 no_ospf_transmit_delay_cmd
,
7882 "no ospf transmit-delay",
7884 "OSPF interface commands\n"
7885 "Link state transmit delay\n")
7887 DEFUN (no_ip_ospf_transmit_delay_sec
,
7888 no_ip_ospf_transmit_delay_sec_cmd
,
7889 "no ip ospf transmit-delay <1-65535>",
7892 "OSPF interface commands\n"
7893 "Link state transmit delay\n"
7895 "Address of interface")
7897 struct interface
*ifp
= vty
->index
;
7898 struct ospf_if_params
*params
;
7901 params
= IF_DEF_PARAMS (ifp
);
7903 UNSET_IF_PARAM (params
, transmit_delay
);
7904 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7909 DEFUN (ip_ospf_area
,
7911 "ip ospf area (A.B.C.D|<0-4294967295>)",
7913 "OSPF interface commands\n"
7914 "Enable OSPF on this interface\n"
7915 "OSPF area ID in IP address format\n"
7916 "OSPF area ID as a decimal value\n")
7918 struct interface
*ifp
= vty
->index
;
7920 struct in_addr area_id
;
7922 struct ospf_if_params
*params
;
7923 struct route_node
*rn
;
7924 u_short instance
= 0;
7927 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
7929 ospf
= ospf_lookup_instance (instance
);
7932 params
= IF_DEF_PARAMS (ifp
);
7933 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7935 ospf_interface_unset (ifp
);
7936 ospf
= ospf_lookup();
7937 ospf
->if_ospf_cli_count
--;
7942 ret
= ospf_str2area_id (argv
[instance
? 1 : 0], &area_id
, &format
);
7945 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7949 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7951 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7955 params
= IF_DEF_PARAMS (ifp
);
7956 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7959 "Must remove previous area config before changing ospf area %s",
7964 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7966 if (rn
->info
!= NULL
)
7968 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7973 /* enable ospf on this interface with area_id */
7974 ospf_interface_set (ifp
, area_id
);
7975 ospf
->if_ospf_cli_count
++;
7980 ALIAS (ip_ospf_area
,
7981 ip_ospf_instance_area_cmd
,
7982 "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
7984 "OSPF interface commands\n"
7986 "Enable OSPF on this interface\n"
7987 "OSPF area ID in IP address format\n"
7988 "OSPF area ID as a decimal value\n")
7990 DEFUN (no_ip_ospf_area
,
7991 no_ip_ospf_area_cmd
,
7995 "OSPF interface commands\n"
7996 "Disable OSPF on this interface\n")
7998 struct interface
*ifp
= vty
->index
;
8000 struct ospf_if_params
*params
;
8001 u_short instance
= 0;
8003 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8006 params
= IF_DEF_PARAMS (ifp
);
8007 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8009 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8013 ospf_interface_unset (ifp
);
8014 ospf
->if_ospf_cli_count
--;
8018 ALIAS (no_ip_ospf_area
,
8019 no_ip_ospf_area_val_cmd
,
8020 "no ip ospf area (A.B.C.D|<0-4294967295>)",
8023 "OSPF interface commands\n"
8024 "Disable OSPF on this interface\n"
8025 "OSPF area ID in IP address format\n"
8026 "OSPF area ID as a decimal value\n")
8028 DEFUN (no_ip_ospf_instance_area
,
8029 no_ip_ospf_instance_area_cmd
,
8030 "no ip ospf <1-65535> area",
8033 "OSPF interface commands\n"
8035 "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
[0]);
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 ALIAS (no_ip_ospf_instance_area
,
8060 no_ip_ospf_instance_area_val_cmd
,
8061 "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
8064 "OSPF interface commands\n"
8066 "Disable OSPF on this interface\n"
8067 "OSPF area ID in IP address format\n"
8068 "OSPF area ID as a decimal value\n")
8070 DEFUN (ospf_redistribute_source
,
8071 ospf_redistribute_source_cmd
,
8072 "redistribute " FRR_REDIST_STR_OSPFD
8073 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8075 FRR_REDIST_HELP_STR_OSPFD
8076 "Metric for redistributed routes\n"
8077 "OSPF default metric\n"
8078 "OSPF exterior metric type for redistributed routes\n"
8079 "Set OSPF External Type 1 metrics\n"
8080 "Set OSPF External Type 2 metrics\n"
8081 "Route map reference\n"
8082 "Pointer to route-map entries\n")
8084 struct ospf
*ospf
= vty
->index
;
8088 struct ospf_redist
*red
;
8094 return CMD_WARNING
; /* should not happen */
8099 /* Get distribute source. */
8100 source
= proto_redistnum(AFI_IP
, argv
[0]);
8101 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8104 /* Get metric value. */
8105 if (argv
[1] != NULL
)
8106 if (!str2metric (argv
[1], &metric
))
8109 /* Get metric type. */
8110 if (argv
[2] != NULL
)
8111 if (!str2metric_type (argv
[2], &type
))
8114 red
= ospf_redist_add(ospf
, source
, 0);
8116 if (argv
[3] != NULL
)
8117 ospf_routemap_set (red
, argv
[3]);
8119 ospf_routemap_unset (red
);
8121 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
8124 DEFUN (no_ospf_redistribute_source
,
8125 no_ospf_redistribute_source_cmd
,
8126 "no redistribute " FRR_REDIST_STR_OSPFD
8127 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8130 FRR_REDIST_HELP_STR_OSPFD
8131 "Metric for redistributed routes\n"
8132 "OSPF default metric\n"
8133 "OSPF exterior metric type for redistributed routes\n"
8134 "Set OSPF External Type 1 metrics\n"
8135 "Set OSPF External Type 2 metrics\n"
8136 "Route map reference\n"
8137 "Pointer to route-map entries\n")
8139 struct ospf
*ospf
= vty
->index
;
8141 struct ospf_redist
*red
;
8145 source
= proto_redistnum(AFI_IP
, argv
[0]);
8146 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8149 red
= ospf_redist_lookup(ospf
, source
, 0);
8153 ospf_routemap_unset (red
);
8154 return ospf_redistribute_unset (ospf
, source
, 0);
8157 DEFUN (ospf_redistribute_instance_source
,
8158 ospf_redistribute_instance_source_cmd
,
8159 "redistribute (ospf|table) <1-65535>"
8160 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8162 "Open Shortest Path First\n"
8163 "Non-main Kernel Routing Table\n"
8164 "Instance ID/Table ID\n"
8165 "Metric for redistributed routes\n"
8166 "OSPF default metric\n"
8167 "OSPF exterior metric type for redistributed routes\n"
8168 "Set OSPF External Type 1 metrics\n"
8169 "Set OSPF External Type 2 metrics\n"
8170 "Route map reference\n"
8171 "Pointer to route-map entries\n")
8173 struct ospf
*ospf
= vty
->index
;
8178 struct ospf_redist
*red
;
8183 if (strncmp(argv
[0], "o", 1) == 0)
8184 source
= ZEBRA_ROUTE_OSPF
;
8186 source
= ZEBRA_ROUTE_TABLE
;
8188 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8193 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8195 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8200 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8202 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8207 /* Get metric value. */
8208 if (argv
[2] != NULL
)
8209 if (!str2metric (argv
[2], &metric
))
8212 /* Get metric type. */
8213 if (argv
[3] != NULL
)
8214 if (!str2metric_type (argv
[3], &type
))
8217 red
= ospf_redist_add(ospf
, source
, instance
);
8218 if (argv
[4] != NULL
)
8219 ospf_routemap_set (red
, argv
[4]);
8221 ospf_routemap_unset (red
);
8223 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
8226 DEFUN (no_ospf_redistribute_instance_source
,
8227 no_ospf_redistribute_instance_source_cmd
,
8228 "no redistribute (ospf|table) <1-65535>"
8229 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8232 "Open Shortest Path First\n"
8233 "Non-main Kernel Routing Table\n"
8234 "Instance ID/Table Id\n"
8235 "Metric for redistributed routes\n"
8236 "OSPF default metric\n"
8237 "OSPF exterior metric type for redistributed routes\n"
8238 "Set OSPF External Type 1 metrics\n"
8239 "Set OSPF External Type 2 metrics\n"
8240 "Route map reference\n"
8241 "Pointer to route-map entries\n")
8243 struct ospf
*ospf
= vty
->index
;
8245 struct ospf_redist
*red
;
8251 if (strncmp(argv
[0], "o", 1) == 0)
8252 source
= ZEBRA_ROUTE_OSPF
;
8254 source
= ZEBRA_ROUTE_TABLE
;
8256 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8258 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8260 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8265 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8267 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8272 red
= ospf_redist_lookup(ospf
, source
, instance
);
8276 ospf_routemap_unset (red
);
8277 return ospf_redistribute_unset (ospf
, source
, instance
);
8280 DEFUN (ospf_distribute_list_out
,
8281 ospf_distribute_list_out_cmd
,
8282 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8283 "Filter networks in routing updates\n"
8284 "Access-list name\n"
8286 FRR_REDIST_HELP_STR_OSPFD
)
8288 struct ospf
*ospf
= vty
->index
;
8294 /* Get distribute source. */
8295 source
= proto_redistnum(AFI_IP
, argv
[1]);
8296 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8299 return ospf_distribute_list_out_set (ospf
, source
, argv
[0]);
8302 DEFUN (no_ospf_distribute_list_out
,
8303 no_ospf_distribute_list_out_cmd
,
8304 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8306 "Filter networks in routing updates\n"
8307 "Access-list name\n"
8309 FRR_REDIST_HELP_STR_OSPFD
)
8311 struct ospf
*ospf
= vty
->index
;
8317 source
= proto_redistnum(AFI_IP
, argv
[1]);
8318 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8321 return ospf_distribute_list_out_unset (ospf
, source
, argv
[0]);
8324 /* Default information originate. */
8325 DEFUN (ospf_default_information_originate
,
8326 ospf_default_information_originate_cmd
,
8327 "default-information originate "
8328 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8329 "Control distribution of default information\n"
8330 "Distribute a default route\n"
8331 "Always advertise default route\n"
8332 "OSPF default metric\n"
8334 "OSPF metric type for default routes\n"
8335 "Set OSPF External Type 1 metrics\n"
8336 "Set OSPF External Type 2 metrics\n"
8337 "Route map reference\n"
8338 "Pointer to route-map entries\n")
8340 struct ospf
*ospf
= vty
->index
;
8341 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8344 struct ospf_redist
*red
;
8350 return CMD_WARNING
; /* this should not happen */
8352 /* Check whether "always" was specified */
8353 if (argv
[0] != NULL
)
8354 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8356 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8358 /* Get metric value. */
8359 if (argv
[1] != NULL
)
8360 if (!str2metric (argv
[1], &metric
))
8363 /* Get metric type. */
8364 if (argv
[2] != NULL
)
8365 if (!str2metric_type (argv
[2], &type
))
8368 if (argv
[3] != NULL
)
8369 ospf_routemap_set (red
, argv
[3]);
8371 ospf_routemap_unset (red
);
8373 return ospf_redistribute_default_set (ospf
, default_originate
,
8377 DEFUN (no_ospf_default_information_originate
,
8378 no_ospf_default_information_originate_cmd
,
8379 "no default-information originate"
8380 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8382 "Control distribution of default information\n"
8383 "Distribute a default route\n"
8384 "Always advertise default route\n"
8385 "OSPF default metric\n"
8387 "OSPF metric type for default routes\n"
8388 "Set OSPF External Type 1 metrics\n"
8389 "Set OSPF External Type 2 metrics\n"
8390 "Route map reference\n"
8391 "Pointer to route-map entries\n")
8393 struct ospf
*ospf
= vty
->index
;
8394 struct prefix_ipv4 p
;
8395 struct ospf_external
*ext
;
8396 struct ospf_redist
*red
;
8402 p
.prefix
.s_addr
= 0;
8405 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
8407 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
8408 EXTERNAL_INFO (ext
)) {
8409 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
8410 ospf_external_del (DEFAULT_ROUTE
, 0);
8413 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8417 ospf_routemap_unset (red
);
8418 return ospf_redistribute_default_unset (ospf
);
8421 DEFUN (ospf_default_metric
,
8422 ospf_default_metric_cmd
,
8423 "default-metric <0-16777214>",
8424 "Set metric of redistributed routes\n"
8427 struct ospf
*ospf
= vty
->index
;
8433 if (!str2metric (argv
[0], &metric
))
8436 ospf
->default_metric
= metric
;
8441 DEFUN (no_ospf_default_metric
,
8442 no_ospf_default_metric_cmd
,
8443 "no default-metric",
8445 "Set metric of redistributed routes\n")
8447 struct ospf
*ospf
= vty
->index
;
8452 ospf
->default_metric
= -1;
8457 ALIAS (no_ospf_default_metric
,
8458 no_ospf_default_metric_val_cmd
,
8459 "no default-metric <0-16777214>",
8461 "Set metric of redistributed routes\n"
8464 DEFUN (ospf_distance
,
8467 "Define an administrative distance\n"
8468 "OSPF Administrative distance\n")
8470 struct ospf
*ospf
= vty
->index
;
8475 ospf
->distance_all
= atoi (argv
[0]);
8480 DEFUN (no_ospf_distance
,
8481 no_ospf_distance_cmd
,
8482 "no distance <1-255>",
8484 "Define an administrative distance\n"
8485 "OSPF Administrative distance\n")
8487 struct ospf
*ospf
= vty
->index
;
8492 ospf
->distance_all
= 0;
8497 DEFUN (no_ospf_distance_ospf
,
8498 no_ospf_distance_ospf_cmd
,
8499 "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8501 "Define an administrative distance\n"
8502 "OSPF Administrative distance\n"
8503 "Intra-area routes\n"
8504 "Distance for intra-area routes\n"
8505 "Inter-area routes\n"
8506 "Distance for inter-area routes\n"
8508 "Distance for external routes\n")
8510 struct ospf
*ospf
= vty
->index
;
8521 if (argv
[0] != NULL
)
8522 ospf
->distance_intra
= 0;
8524 if (argv
[1] != NULL
)
8525 ospf
->distance_inter
= 0;
8527 if (argv
[2] != NULL
)
8528 ospf
->distance_external
= 0;
8530 if (argv
[0] || argv
[1] || argv
[2])
8533 /* If no arguments are given, clear all distance information */
8534 ospf
->distance_intra
= 0;
8535 ospf
->distance_inter
= 0;
8536 ospf
->distance_external
= 0;
8541 DEFUN (ospf_distance_ospf
,
8542 ospf_distance_ospf_cmd
,
8544 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8545 "Define an administrative distance\n"
8546 "OSPF Administrative distance\n"
8547 "Intra-area routes\n"
8548 "Distance for intra-area routes\n"
8549 "Inter-area routes\n"
8550 "Distance for inter-area routes\n"
8552 "Distance for external routes\n")
8554 struct ospf
*ospf
= vty
->index
;
8559 if (argc
< 3) /* should not happen */
8562 if (!argv
[0] && !argv
[1] && !argv
[2])
8564 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
8569 if (argv
[0] != NULL
)
8570 ospf
->distance_intra
= atoi(argv
[0]);
8572 if (argv
[1] != NULL
)
8573 ospf
->distance_inter
= atoi(argv
[1]);
8575 if (argv
[2] != NULL
)
8576 ospf
->distance_external
= atoi(argv
[2]);
8581 DEFUN (ospf_distance_source
,
8582 ospf_distance_source_cmd
,
8583 "distance <1-255> A.B.C.D/M",
8584 "Administrative distance\n"
8586 "IP source prefix\n")
8588 struct ospf
*ospf
= vty
->index
;
8593 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], NULL
);
8598 DEFUN (no_ospf_distance_source
,
8599 no_ospf_distance_source_cmd
,
8600 "no distance <1-255> A.B.C.D/M",
8602 "Administrative distance\n"
8604 "IP source prefix\n")
8606 struct ospf
*ospf
= vty
->index
;
8611 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], NULL
);
8616 DEFUN (ospf_distance_source_access_list
,
8617 ospf_distance_source_access_list_cmd
,
8618 "distance <1-255> A.B.C.D/M WORD",
8619 "Administrative distance\n"
8621 "IP source prefix\n"
8622 "Access list name\n")
8624 struct ospf
*ospf
= vty
->index
;
8629 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
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")
8643 struct ospf
*ospf
= vty
->index
;
8648 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
8653 DEFUN (ip_ospf_mtu_ignore
,
8654 ip_ospf_mtu_ignore_addr_cmd
,
8655 "ip ospf mtu-ignore A.B.C.D",
8657 "OSPF interface commands\n"
8658 "Disable mtu mismatch detection\n"
8659 "Address of interface")
8661 struct interface
*ifp
= vty
->index
;
8662 struct in_addr addr
;
8665 struct ospf_if_params
*params
;
8666 params
= IF_DEF_PARAMS (ifp
);
8670 ret
= inet_aton(argv
[0], &addr
);
8673 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8677 params
= ospf_get_if_params (ifp
, addr
);
8678 ospf_if_update_params (ifp
, addr
);
8680 params
->mtu_ignore
= 1;
8681 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8682 SET_IF_PARAM (params
, mtu_ignore
);
8685 UNSET_IF_PARAM (params
, mtu_ignore
);
8686 if (params
!= IF_DEF_PARAMS (ifp
))
8688 ospf_free_if_params (ifp
, addr
);
8689 ospf_if_update_params (ifp
, addr
);
8695 ALIAS (ip_ospf_mtu_ignore
,
8696 ip_ospf_mtu_ignore_cmd
,
8697 "ip ospf mtu-ignore",
8699 "OSPF interface commands\n"
8700 "Disable mtu mismatch detection\n")
8703 DEFUN (no_ip_ospf_mtu_ignore
,
8704 no_ip_ospf_mtu_ignore_addr_cmd
,
8705 "no ip ospf mtu-ignore A.B.C.D",
8707 "OSPF interface commands\n"
8708 "Disable mtu mismatch detection\n"
8709 "Address of interface")
8711 struct interface
*ifp
= vty
->index
;
8712 struct in_addr addr
;
8715 struct ospf_if_params
*params
;
8716 params
= IF_DEF_PARAMS (ifp
);
8720 ret
= inet_aton(argv
[0], &addr
);
8723 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8727 params
= ospf_get_if_params (ifp
, addr
);
8728 ospf_if_update_params (ifp
, addr
);
8730 params
->mtu_ignore
= 0;
8731 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8732 SET_IF_PARAM (params
, mtu_ignore
);
8735 UNSET_IF_PARAM (params
, mtu_ignore
);
8736 if (params
!= IF_DEF_PARAMS (ifp
))
8738 ospf_free_if_params (ifp
, addr
);
8739 ospf_if_update_params (ifp
, addr
);
8745 ALIAS (no_ip_ospf_mtu_ignore
,
8746 no_ip_ospf_mtu_ignore_cmd
,
8747 "no ip ospf mtu-ignore",
8749 "OSPF interface commands\n"
8750 "Disable mtu mismatch detection\n")
8752 DEFUN (ospf_max_metric_router_lsa_admin
,
8753 ospf_max_metric_router_lsa_admin_cmd
,
8754 "max-metric router-lsa administrative",
8755 "OSPF maximum / infinite-distance metric\n"
8756 "Advertise own Router-LSA with infinite distance (stub router)\n"
8757 "Administratively applied, for an indefinite period\n")
8759 struct listnode
*ln
;
8760 struct ospf_area
*area
;
8761 struct ospf
*ospf
= vty
->index
;
8766 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8768 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8770 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
8771 ospf_router_lsa_update_area (area
);
8774 /* Allows for areas configured later to get the property */
8775 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8780 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8781 no_ospf_max_metric_router_lsa_admin_cmd
,
8782 "no max-metric router-lsa administrative",
8784 "OSPF maximum / infinite-distance metric\n"
8785 "Advertise own Router-LSA with infinite distance (stub router)\n"
8786 "Administratively applied, for an indefinite period\n")
8788 struct listnode
*ln
;
8789 struct ospf_area
*area
;
8790 struct ospf
*ospf
= vty
->index
;
8795 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8797 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8799 /* Don't trample on the start-up stub timer */
8800 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8801 && !area
->t_stub_router
)
8803 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8804 ospf_router_lsa_update_area (area
);
8807 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8811 DEFUN (ospf_max_metric_router_lsa_startup
,
8812 ospf_max_metric_router_lsa_startup_cmd
,
8813 "max-metric router-lsa on-startup <5-86400>",
8814 "OSPF maximum / infinite-distance metric\n"
8815 "Advertise own Router-LSA with infinite distance (stub router)\n"
8816 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8817 "Time (seconds) to advertise self as stub-router\n")
8819 unsigned int seconds
;
8820 struct ospf
*ospf
= vty
->index
;
8827 vty_out (vty
, "%% Must supply stub-router period");
8831 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[0]);
8833 ospf
->stub_router_startup_time
= seconds
;
8838 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8839 no_ospf_max_metric_router_lsa_startup_cmd
,
8840 "no max-metric router-lsa on-startup <5-86400>",
8842 "OSPF maximum / infinite-distance metric\n"
8843 "Advertise own Router-LSA with infinite distance (stub router)\n"
8844 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8845 "Time (seconds) to advertise self as stub-router\n")
8847 struct listnode
*ln
;
8848 struct ospf_area
*area
;
8849 struct ospf
*ospf
= vty
->index
;
8854 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8856 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8858 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8859 OSPF_TIMER_OFF (area
->t_stub_router
);
8861 /* Don't trample on admin stub routed */
8862 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8864 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8865 ospf_router_lsa_update_area (area
);
8871 ALIAS (no_ospf_max_metric_router_lsa_startup
,
8872 no_ospf_max_metric_router_lsa_startup_no_param_cmd
,
8873 "no max-metric router-lsa on-startup",
8875 "OSPF maximum / infinite-distance metric\n"
8876 "Advertise own Router-LSA with infinite distance (stub router)\n"
8877 "Automatically advertise stub Router-LSA on startup of OSPF\n");
8879 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8880 ospf_max_metric_router_lsa_shutdown_cmd
,
8881 "max-metric router-lsa on-shutdown <5-100>",
8882 "OSPF maximum / infinite-distance metric\n"
8883 "Advertise own Router-LSA with infinite distance (stub router)\n"
8884 "Advertise stub-router prior to full shutdown of OSPF\n"
8885 "Time (seconds) to wait till full shutdown\n")
8887 unsigned int seconds
;
8888 struct ospf
*ospf
= vty
->index
;
8895 vty_out (vty
, "%% Must supply stub-router shutdown period");
8899 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[0]);
8901 ospf
->stub_router_shutdown_time
= seconds
;
8906 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8907 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8908 "no max-metric router-lsa on-shutdown <5-100>",
8910 "OSPF maximum / infinite-distance metric\n"
8911 "Advertise own Router-LSA with infinite distance (stub router)\n"
8912 "Advertise stub-router prior to full shutdown of OSPF\n"
8913 "Time (seconds) to wait till full shutdown\n")
8915 struct ospf
*ospf
= vty
->index
;
8920 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8925 ALIAS (no_ospf_max_metric_router_lsa_shutdown
,
8926 no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
,
8927 "no max-metric router-lsa on-shutdown",
8929 "OSPF maximum / infinite-distance metric\n"
8930 "Advertise own Router-LSA with infinite distance (stub router)\n"
8931 "Advertise stub-router prior to full shutdown of OSPF\n");
8934 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8936 struct listnode
*ln
;
8937 struct ospf_area
*area
;
8939 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8940 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8941 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8942 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8943 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8944 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8945 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8947 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8949 vty_out (vty
, " max-metric router-lsa administrative%s",
8958 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8960 struct route_node
*rn
;
8961 struct ospf_route
*or;
8962 struct listnode
*pnode
, *pnnode
;
8963 struct ospf_path
*path
;
8965 vty_out (vty
, "============ OSPF network routing table ============%s",
8968 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8969 if ((or = rn
->info
) != NULL
)
8972 snprintf (buf1
, 19, "%s/%d",
8973 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8975 switch (or->path_type
)
8977 case OSPF_PATH_INTER_AREA
:
8978 if (or->type
== OSPF_DESTINATION_NETWORK
)
8979 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8980 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8981 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8982 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8984 case OSPF_PATH_INTRA_AREA
:
8985 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8986 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8992 if (or->type
== OSPF_DESTINATION_NETWORK
)
8993 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8995 if (if_lookup_by_index(path
->ifindex
))
8997 if (path
->nexthop
.s_addr
== 0)
8998 vty_out (vty
, "%24s directly attached to %s%s",
8999 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9001 vty_out (vty
, "%24s via %s, %s%s", "",
9002 inet_ntoa (path
->nexthop
),
9003 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9007 vty_out (vty
, "%s", VTY_NEWLINE
);
9011 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
9013 struct route_node
*rn
;
9014 struct ospf_route
*or;
9015 struct listnode
*pnode
;
9016 struct listnode
*node
;
9017 struct ospf_path
*path
;
9019 vty_out (vty
, "============ OSPF router routing table =============%s",
9021 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
9026 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
9028 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
9031 vty_out (vty
, "%24s", "");
9034 vty_out (vty
, "%s [%d] area: %s",
9035 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
9036 or->cost
, inet_ntoa (or->u
.std
.area_id
));
9038 vty_out (vty
, "%s%s%s",
9039 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
9040 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
9043 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
9045 if (if_lookup_by_index(path
->ifindex
))
9047 if (path
->nexthop
.s_addr
== 0)
9048 vty_out (vty
, "%24s directly attached to %s%s",
9049 "", ifindex2ifname (path
->ifindex
),
9052 vty_out (vty
, "%24s via %s, %s%s", "",
9053 inet_ntoa (path
->nexthop
),
9054 ifindex2ifname (path
->ifindex
),
9060 vty_out (vty
, "%s", VTY_NEWLINE
);
9064 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
9066 struct route_node
*rn
;
9067 struct ospf_route
*er
;
9068 struct listnode
*pnode
, *pnnode
;
9069 struct ospf_path
*path
;
9071 vty_out (vty
, "============ OSPF external routing table ===========%s",
9073 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
9074 if ((er
= rn
->info
) != NULL
)
9077 snprintf (buf1
, 19, "%s/%d",
9078 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
9080 switch (er
->path_type
)
9082 case OSPF_PATH_TYPE1_EXTERNAL
:
9083 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
9084 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9086 case OSPF_PATH_TYPE2_EXTERNAL
:
9087 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
9088 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9092 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
9094 if (if_lookup_by_index(path
->ifindex
))
9096 if (path
->nexthop
.s_addr
== 0)
9097 vty_out (vty
, "%24s directly attached to %s%s",
9098 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9100 vty_out (vty
, "%24s via %s, %s%s", "",
9101 inet_ntoa (path
->nexthop
),
9102 ifindex2ifname (path
->ifindex
),
9107 vty_out (vty
, "%s", VTY_NEWLINE
);
9111 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
9114 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9115 VTY_NEWLINE
, VTY_NEWLINE
);
9117 if (ospf
->new_table
== NULL
)
9119 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9123 /* Show Network routes.
9124 show_ip_ospf_route_network (vty, ospf->new_table); */
9126 /* Show Router routes. */
9127 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9129 vty_out (vty
, "%s", VTY_NEWLINE
);
9134 DEFUN (show_ip_ospf_border_routers
,
9135 show_ip_ospf_border_routers_cmd
,
9136 "show ip ospf border-routers",
9139 "OSPF information\n"
9140 "Show all the ABR's and ASBR's\n")
9144 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9147 return show_ip_ospf_border_routers_common(vty
, ospf
);
9150 DEFUN (show_ip_ospf_instance_border_routers
,
9151 show_ip_ospf_instance_border_routers_cmd
,
9152 "show ip ospf <1-65535> border-routers",
9155 "OSPF information\n"
9157 "Show all the ABR's and ASBR's\n")
9160 u_short instance
= 0;
9162 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9163 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9166 return show_ip_ospf_border_routers_common(vty
, ospf
);
9170 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
9173 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9174 VTY_NEWLINE
, VTY_NEWLINE
);
9176 if (ospf
->new_table
== NULL
)
9178 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9182 /* Show Network routes. */
9183 show_ip_ospf_route_network (vty
, ospf
->new_table
);
9185 /* Show Router routes. */
9186 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9188 /* Show AS External routes. */
9189 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
9191 vty_out (vty
, "%s", VTY_NEWLINE
);
9196 DEFUN (show_ip_ospf_route
,
9197 show_ip_ospf_route_cmd
,
9198 "show ip ospf route",
9201 "OSPF information\n"
9202 "OSPF routing table\n")
9206 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9209 return show_ip_ospf_route_common(vty
, ospf
);
9212 DEFUN (show_ip_ospf_instance_route
,
9213 show_ip_ospf_instance_route_cmd
,
9214 "show ip ospf <1-65535> route",
9217 "OSPF information\n"
9219 "OSPF routing table\n")
9222 u_short instance
= 0;
9224 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9225 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9228 return show_ip_ospf_route_common(vty
, ospf
);
9231 const char *ospf_abr_type_str
[] =
9240 const char *ospf_shortcut_mode_str
[] =
9249 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
9251 memset (buf
, 0, length
);
9253 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9254 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
9256 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
9260 const char *ospf_int_type_str
[] =
9262 "unknown", /* should never be used. */
9266 "point-to-multipoint",
9267 "virtual-link", /* should never be used. */
9271 /* Configuration write function for ospfd. */
9273 config_write_interface (struct vty
*vty
)
9275 struct listnode
*n1
, *n2
;
9276 struct interface
*ifp
;
9277 struct crypt_key
*ck
;
9279 struct route_node
*rn
= NULL
;
9280 struct ospf_if_params
*params
;
9281 struct ospf
*ospf
= ospf_lookup();
9283 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
9285 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
9288 if (ifp
->ifindex
== IFINDEX_DELETED
)
9291 vty_out (vty
, "!%s", VTY_NEWLINE
);
9292 vty_out (vty
, "interface %s%s", ifp
->name
,
9295 vty_out (vty
, " description %s%s", ifp
->desc
,
9300 params
= IF_DEF_PARAMS (ifp
);
9303 /* Interface Network print. */
9304 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
9305 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
9307 if (params
->type
!= ospf_default_iftype(ifp
))
9309 vty_out (vty
, " ip ospf network %s",
9310 ospf_int_type_str
[params
->type
]);
9311 if (params
!= IF_DEF_PARAMS (ifp
))
9312 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9313 vty_out (vty
, "%s", VTY_NEWLINE
);
9317 /* OSPF interface authentication print */
9318 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
9319 params
->auth_type
!= OSPF_AUTH_NOTSET
)
9321 const char *auth_str
;
9323 /* Translation tables are not that much help here due to syntax
9324 of the simple option */
9325 switch (params
->auth_type
)
9328 case OSPF_AUTH_NULL
:
9332 case OSPF_AUTH_SIMPLE
:
9336 case OSPF_AUTH_CRYPTOGRAPHIC
:
9337 auth_str
= " message-digest";
9345 vty_out (vty
, " ip ospf authentication%s", auth_str
);
9346 if (params
!= IF_DEF_PARAMS (ifp
))
9347 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9348 vty_out (vty
, "%s", VTY_NEWLINE
);
9351 /* Simple Authentication Password print. */
9352 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
9353 params
->auth_simple
[0] != '\0')
9355 vty_out (vty
, " ip ospf authentication-key %s",
9356 params
->auth_simple
);
9357 if (params
!= IF_DEF_PARAMS (ifp
))
9358 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9359 vty_out (vty
, "%s", VTY_NEWLINE
);
9362 /* Cryptographic Authentication Key print. */
9363 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
9365 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
9366 ck
->key_id
, ck
->auth_key
);
9367 if (params
!= IF_DEF_PARAMS (ifp
))
9368 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9369 vty_out (vty
, "%s", VTY_NEWLINE
);
9372 /* Interface Output Cost print. */
9373 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
9375 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
9376 if (params
!= IF_DEF_PARAMS (ifp
))
9377 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9378 vty_out (vty
, "%s", VTY_NEWLINE
);
9381 /* Hello Interval print. */
9382 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
9383 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
9385 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
9386 if (params
!= IF_DEF_PARAMS (ifp
))
9387 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9388 vty_out (vty
, "%s", VTY_NEWLINE
);
9392 /* Router Dead Interval print. */
9393 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
9394 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
9396 vty_out (vty
, " ip ospf dead-interval ");
9399 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
9400 vty_out (vty
, "minimal hello-multiplier %d",
9401 params
->fast_hello
);
9403 vty_out (vty
, "%u", params
->v_wait
);
9405 if (params
!= IF_DEF_PARAMS (ifp
))
9406 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9407 vty_out (vty
, "%s", VTY_NEWLINE
);
9410 /* Router Priority print. */
9411 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
9412 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
9414 vty_out (vty
, " ip ospf priority %u", params
->priority
);
9415 if (params
!= IF_DEF_PARAMS (ifp
))
9416 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9417 vty_out (vty
, "%s", VTY_NEWLINE
);
9420 /* Retransmit Interval print. */
9421 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
9422 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
9424 vty_out (vty
, " ip ospf retransmit-interval %u",
9425 params
->retransmit_interval
);
9426 if (params
!= IF_DEF_PARAMS (ifp
))
9427 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9428 vty_out (vty
, "%s", VTY_NEWLINE
);
9431 /* Transmit Delay print. */
9432 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
9433 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
9435 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
9436 if (params
!= IF_DEF_PARAMS (ifp
))
9437 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9438 vty_out (vty
, "%s", VTY_NEWLINE
);
9442 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
9445 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
9446 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9448 vty_out (vty
, " ip ospf area %s%s",
9449 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9454 ospf_bfd_write_config(vty
, params
);
9456 /* MTU ignore print. */
9457 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
9458 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9460 if (params
->mtu_ignore
== 0)
9461 vty_out (vty
, " no ip ospf mtu-ignore");
9463 vty_out (vty
, " ip ospf mtu-ignore");
9464 if (params
!= IF_DEF_PARAMS (ifp
))
9465 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9466 vty_out (vty
, "%s", VTY_NEWLINE
);
9473 rn
= route_top (IF_OIFS_PARAMS (ifp
));
9475 rn
= route_next (rn
);
9485 ospf_opaque_config_write_if (vty
, ifp
);
9492 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
9494 struct route_node
*rn
;
9495 u_char buf
[INET_ADDRSTRLEN
];
9497 /* `network area' print. */
9498 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
9501 struct ospf_network
*n
= rn
->info
;
9503 memset (buf
, 0, INET_ADDRSTRLEN
);
9505 /* Create Area ID string by specified Area ID format. */
9506 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9507 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
9509 sprintf ((char *) buf
, "%lu",
9510 (unsigned long int) ntohl (n
->area_id
.s_addr
));
9512 /* Network print. */
9513 vty_out (vty
, " network %s/%d area %s%s",
9514 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9522 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
9524 struct listnode
*node
;
9525 struct ospf_area
*area
;
9526 u_char buf
[INET_ADDRSTRLEN
];
9528 /* Area configuration print. */
9529 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
9531 struct route_node
*rn1
;
9533 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
9535 if (area
->auth_type
!= OSPF_AUTH_NULL
)
9537 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9538 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
9540 vty_out (vty
, " area %s authentication message-digest%s",
9544 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9545 vty_out (vty
, " area %s shortcut %s%s", buf
,
9546 ospf_shortcut_mode_str
[area
->shortcut_configured
],
9549 if ((area
->external_routing
== OSPF_AREA_STUB
)
9550 || (area
->external_routing
== OSPF_AREA_NSSA
)
9553 if (area
->external_routing
== OSPF_AREA_STUB
)
9554 vty_out (vty
, " area %s stub", buf
);
9555 else if (area
->external_routing
== OSPF_AREA_NSSA
)
9557 vty_out (vty
, " area %s nssa", buf
);
9558 switch (area
->NSSATranslatorRole
)
9560 case OSPF_NSSA_ROLE_NEVER
:
9561 vty_out (vty
, " translate-never");
9563 case OSPF_NSSA_ROLE_ALWAYS
:
9564 vty_out (vty
, " translate-always");
9566 case OSPF_NSSA_ROLE_CANDIDATE
:
9568 vty_out (vty
, " translate-candidate");
9572 if (area
->no_summary
)
9573 vty_out (vty
, " no-summary");
9575 vty_out (vty
, "%s", VTY_NEWLINE
);
9577 if (area
->default_cost
!= 1)
9578 vty_out (vty
, " area %s default-cost %d%s", buf
,
9579 area
->default_cost
, VTY_NEWLINE
);
9582 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
9585 struct ospf_area_range
*range
= rn1
->info
;
9587 vty_out (vty
, " area %s range %s/%d", buf
,
9588 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
9590 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
9591 vty_out (vty
, " cost %d", range
->cost_config
);
9593 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
9594 vty_out (vty
, " not-advertise");
9596 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
9597 vty_out (vty
, " substitute %s/%d",
9598 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
9600 vty_out (vty
, "%s", VTY_NEWLINE
);
9603 if (EXPORT_NAME (area
))
9604 vty_out (vty
, " area %s export-list %s%s", buf
,
9605 EXPORT_NAME (area
), VTY_NEWLINE
);
9607 if (IMPORT_NAME (area
))
9608 vty_out (vty
, " area %s import-list %s%s", buf
,
9609 IMPORT_NAME (area
), VTY_NEWLINE
);
9611 if (PREFIX_NAME_IN (area
))
9612 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
9613 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
9615 if (PREFIX_NAME_OUT (area
))
9616 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
9617 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
9624 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
9626 struct ospf_nbr_nbma
*nbr_nbma
;
9627 struct route_node
*rn
;
9629 /* Static Neighbor configuration print. */
9630 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
9631 if ((nbr_nbma
= rn
->info
))
9633 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
9635 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9636 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
9638 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9639 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
9641 vty_out (vty
, "%s", VTY_NEWLINE
);
9648 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
9650 struct listnode
*node
;
9651 struct ospf_vl_data
*vl_data
;
9652 u_char buf
[INET_ADDRSTRLEN
];
9654 /* Virtual-Link print */
9655 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
9657 struct listnode
*n2
;
9658 struct crypt_key
*ck
;
9659 struct ospf_interface
*oi
;
9661 if (vl_data
!= NULL
)
9663 memset (buf
, 0, INET_ADDRSTRLEN
);
9665 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9666 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
9668 sprintf ((char *) buf
, "%lu",
9669 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
9670 oi
= vl_data
->vl_oi
;
9673 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
9674 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
9675 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
9676 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
9677 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9679 inet_ntoa (vl_data
->vl_peer
),
9680 OSPF_IF_PARAM (oi
, v_hello
),
9681 OSPF_IF_PARAM (oi
, retransmit_interval
),
9682 OSPF_IF_PARAM (oi
, transmit_delay
),
9683 OSPF_IF_PARAM (oi
, v_wait
),
9686 vty_out (vty
, " area %s virtual-link %s%s", buf
,
9687 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
9689 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
9690 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
9692 inet_ntoa (vl_data
->vl_peer
),
9693 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
9696 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
9698 vty_out (vty
, " area %s virtual-link %s"
9699 " message-digest-key %d md5 %s%s",
9701 inet_ntoa (vl_data
->vl_peer
),
9702 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
9712 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
9716 /* redistribute print. */
9717 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9719 struct list
*red_list
;
9720 struct listnode
*node
;
9721 struct ospf_redist
*red
;
9723 red_list
= ospf
->redist
[type
];
9727 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
9729 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
9731 vty_out (vty
, " %d", red
->instance
);
9733 if (red
->dmetric
.value
>= 0)
9734 vty_out (vty
, " metric %d", red
->dmetric
.value
);
9736 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9737 vty_out (vty
, " metric-type 1");
9739 if (ROUTEMAP_NAME (red
))
9740 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
9742 vty_out (vty
, "%s", VTY_NEWLINE
);
9750 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
9752 if (ospf
->default_metric
!= -1)
9753 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
9759 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
9762 struct ospf_redist
*red
;
9766 /* distribute-list print. */
9767 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9768 if (DISTRIBUTE_NAME (ospf
, type
))
9769 vty_out (vty
, " distribute-list %s out %s%s",
9770 DISTRIBUTE_NAME (ospf
, type
),
9771 zebra_route_string(type
), VTY_NEWLINE
);
9773 /* default-information print. */
9774 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
9776 vty_out (vty
, " default-information originate");
9777 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9778 vty_out (vty
, " always");
9780 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9783 if (red
->dmetric
.value
>= 0)
9784 vty_out (vty
, " metric %d",
9785 red
->dmetric
.value
);
9786 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9787 vty_out (vty
, " metric-type 1");
9789 if (ROUTEMAP_NAME (red
))
9790 vty_out (vty
, " route-map %s",
9791 ROUTEMAP_NAME (red
));
9794 vty_out (vty
, "%s", VTY_NEWLINE
);
9803 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9805 struct route_node
*rn
;
9806 struct ospf_distance
*odistance
;
9808 if (ospf
->distance_all
)
9809 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9811 if (ospf
->distance_intra
9812 || ospf
->distance_inter
9813 || ospf
->distance_external
)
9815 vty_out (vty
, " distance ospf");
9817 if (ospf
->distance_intra
)
9818 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9819 if (ospf
->distance_inter
)
9820 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9821 if (ospf
->distance_external
)
9822 vty_out (vty
, " external %d", ospf
->distance_external
);
9824 vty_out (vty
, "%s", VTY_NEWLINE
);
9827 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9828 if ((odistance
= rn
->info
) != NULL
)
9830 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9831 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9832 odistance
->access_list
? odistance
->access_list
: "",
9838 /* OSPF configuration write function. */
9840 ospf_config_write (struct vty
*vty
)
9843 struct interface
*ifp
;
9844 struct ospf_interface
*oi
;
9845 struct listnode
*node
;
9848 ospf
= ospf_lookup ();
9849 if (ospf
!= NULL
&& ospf
->oi_running
)
9851 /* `router ospf' print. */
9853 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9855 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9859 if (!ospf
->networks
)
9862 /* Router ID print. */
9863 if (ospf
->router_id_static
.s_addr
!= 0)
9864 vty_out (vty
, " ospf router-id %s%s",
9865 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9867 /* ABR type print. */
9868 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9869 vty_out (vty
, " ospf abr-type %s%s",
9870 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9872 /* log-adjacency-changes flag print. */
9873 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9875 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9876 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9877 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
9878 vty_out(vty
, " log-adjacency-changes%s", VTY_NEWLINE
);
9880 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
9882 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9885 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9886 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9887 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9889 /* auto-cost reference-bandwidth configuration. */
9890 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9892 vty_out (vty
, "! Important: ensure reference bandwidth "
9893 "is consistent across all routers%s", VTY_NEWLINE
);
9894 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9895 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9898 /* SPF timers print. */
9899 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9900 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9901 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9902 vty_out (vty
, " timers throttle spf %d %d %d%s",
9903 ospf
->spf_delay
, ospf
->spf_holdtime
,
9904 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9906 /* LSA timers print. */
9907 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9908 vty_out (vty
, " timers throttle lsa all %d%s",
9909 ospf
->min_ls_interval
, VTY_NEWLINE
);
9910 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9911 vty_out (vty
, " timers lsa min-arrival %d%s",
9912 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9914 /* Write multiplier print. */
9915 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9916 vty_out (vty
, " ospf write-multiplier %d%s",
9917 ospf
->write_oi_count
, VTY_NEWLINE
);
9919 /* Max-metric router-lsa print */
9920 config_write_stub_router (vty
, ospf
);
9922 /* SPF refresh parameters print. */
9923 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9924 vty_out (vty
, " refresh timer %d%s",
9925 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9927 /* Redistribute information print. */
9928 config_write_ospf_redistribute (vty
, ospf
);
9930 /* passive-interface print. */
9931 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9932 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9934 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9935 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9936 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9937 ospf
->passive_interface_default
)
9939 vty_out (vty
, " %spassive-interface %s%s",
9940 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9941 ifp
->name
, VTY_NEWLINE
);
9943 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9945 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9947 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9950 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9953 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9956 vty_out (vty
, " %spassive-interface %s %s%s",
9957 oi
->params
->passive_interface
? "" : "no ",
9959 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9962 /* Network area print. */
9963 config_write_network_area (vty
, ospf
);
9965 /* Area config print. */
9966 config_write_ospf_area (vty
, ospf
);
9968 /* static neighbor print. */
9969 config_write_ospf_nbr_nbma (vty
, ospf
);
9971 /* Virtual-Link print. */
9972 config_write_virtual_link (vty
, ospf
);
9974 /* Default metric configuration. */
9975 config_write_ospf_default_metric (vty
, ospf
);
9977 /* Distribute-list and default-information print. */
9978 config_write_ospf_distribute (vty
, ospf
);
9980 /* Distance configuration. */
9981 config_write_ospf_distance (vty
, ospf
);
9983 ospf_opaque_config_write_router (vty
, ospf
);
9990 ospf_vty_show_init (void)
9992 /* "show ip ospf" commands. */
9993 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9995 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9997 /* "show ip ospf database" commands. */
9998 install_element (VIEW_NODE
, &show_ip_ospf_database_type_cmd
);
9999 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_cmd
);
10000 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_adv_router_cmd
);
10001 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
10002 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_self_cmd
);
10003 install_element (VIEW_NODE
, &show_ip_ospf_database_type_self_cmd
);
10004 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
10006 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_cmd
);
10007 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_cmd
);
10008 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_adv_router_cmd
);
10009 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
10010 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_self_cmd
);
10011 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_self_cmd
);
10012 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
10014 /* "show ip ospf interface" commands. */
10015 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
10017 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
10019 /* "show ip ospf neighbor" commands. */
10020 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
10021 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
10022 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
10023 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
10024 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
10025 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
10026 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
10028 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10029 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10030 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10031 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10032 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10033 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10034 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10036 /* "show ip ospf route" commands. */
10037 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
10038 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10040 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10041 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10045 /* ospfd's interface node. */
10046 static struct cmd_node interface_node
=
10053 /* Initialization of OSPF interface. */
10055 ospf_vty_if_init (void)
10057 /* Install interface node. */
10058 install_node (&interface_node
, config_write_interface
);
10060 install_element (CONFIG_NODE
, &interface_cmd
);
10061 install_element (CONFIG_NODE
, &no_interface_cmd
);
10062 install_default (INTERFACE_NODE
);
10064 /* "description" commands. */
10065 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
10066 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
10068 /* "ip ospf authentication" commands. */
10069 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10070 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_cmd
);
10071 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10072 install_element (INTERFACE_NODE
, &ip_ospf_authentication_cmd
);
10073 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
10074 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_cmd
);
10075 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10076 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_cmd
);
10077 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10078 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_cmd
);
10079 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10080 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_cmd
);
10081 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_cmd
);
10083 /* "ip ospf message-digest-key" commands. */
10084 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_addr_cmd
);
10085 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
10086 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_addr_cmd
);
10087 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
10088 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_addr_cmd
);
10089 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_cmd
);
10091 /* "ip ospf cost" commands. */
10092 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_inet4_cmd
);
10093 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_cmd
);
10094 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_cmd
);
10095 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_inet4_cmd
);
10096 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_inet4_cmd
);
10097 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
10099 /* "ip ospf mtu-ignore" commands. */
10100 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10101 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_cmd
);
10102 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10103 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_cmd
);
10105 /* "ip ospf dead-interval" commands. */
10106 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_addr_cmd
);
10107 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
10108 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
10109 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_cmd
);
10110 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_addr_cmd
);
10111 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
10112 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_seconds_cmd
);
10114 /* "ip ospf hello-interval" commands. */
10115 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_addr_cmd
);
10116 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
10117 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_addr_cmd
);
10118 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
10119 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_seconds_cmd
);
10121 /* "ip ospf network" commands. */
10122 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
10123 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10124 install_element (INTERFACE_NODE
, &no_ip_ospf_network_val_cmd
);
10126 /* "ip ospf priority" commands. */
10127 install_element (INTERFACE_NODE
, &ip_ospf_priority_addr_cmd
);
10128 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
10129 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
10130 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_no_param_cmd
);
10131 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_addr_cmd
);
10133 /* "ip ospf retransmit-interval" commands. */
10134 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10135 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_cmd
);
10136 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
10137 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_cmd
);
10138 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_addr_cmd
);
10139 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_cmd
);
10141 /* "ip ospf transmit-delay" commands. */
10142 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10143 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_cmd
);
10144 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10145 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_cmd
);
10146 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_addr_cmd
);
10147 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_cmd
);
10149 /* "ip ospf area" commands. */
10150 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
10151 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10152 install_element (INTERFACE_NODE
, &no_ip_ospf_area_val_cmd
);
10153 install_element (INTERFACE_NODE
, &ip_ospf_instance_area_cmd
);
10154 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_cmd
);
10155 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_val_cmd
);
10157 /* These commands are compatibitliy for previous version. */
10158 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10159 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_cmd
);
10160 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_cmd
);
10161 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_ip_cmd
);
10162 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10163 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
10164 install_element (INTERFACE_NODE
, &ospf_cost_u32_cmd
);
10165 install_element (INTERFACE_NODE
, &ospf_cost_u32_inet4_cmd
);
10166 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
10167 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_cmd
);
10168 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_inet4_cmd
);
10169 install_element (INTERFACE_NODE
, &no_ospf_cost_inet4_cmd
);
10170 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10171 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
10172 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_addr_cmd
);
10173 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_cmd
);
10174 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10175 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
10176 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
10177 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
10178 install_element (INTERFACE_NODE
, &no_ospf_network_val_cmd
);
10179 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
10180 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
10181 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10182 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10183 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10184 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10188 ospf_vty_zebra_init (void)
10190 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
10191 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10192 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10193 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10195 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10196 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10198 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
10199 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10201 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
10202 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
10203 install_element (OSPF_NODE
, &no_ospf_default_metric_val_cmd
);
10205 install_element (OSPF_NODE
, &ospf_distance_cmd
);
10206 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
10207 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10208 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
10210 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10211 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10212 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10213 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10217 static struct cmd_node ospf_node
=
10220 "%s(config-router)# ",
10225 ospf_interface_clear (struct interface
*ifp
)
10227 if (!if_is_operative (ifp
)) return;
10229 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
10230 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
10232 ospf_if_reset(ifp
);
10235 DEFUN (clear_ip_ospf_interface
,
10236 clear_ip_ospf_interface_cmd
,
10237 "clear ip ospf interface [IFNAME]",
10240 "OSPF information\n"
10241 "Interface information\n"
10242 "Interface name\n")
10244 struct interface
*ifp
;
10245 struct listnode
*node
;
10247 if (argc
== 0) /* Clear all the ospfv2 interfaces. */
10249 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
10250 ospf_interface_clear(ifp
);
10252 else /* Interface name is specified. */
10254 if ((ifp
= if_lookup_by_name (argv
[0])) == NULL
)
10255 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
10257 ospf_interface_clear(ifp
);
10260 return CMD_SUCCESS
;
10264 ospf_vty_clear_init (void)
10266 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10270 /* Install OSPF related vty commands. */
10272 ospf_vty_init (void)
10274 /* Install ospf top node. */
10275 install_node (&ospf_node
, ospf_config_write
);
10277 /* "router ospf" commands. */
10278 install_element (CONFIG_NODE
, &router_ospf_cmd
);
10279 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
10281 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
10282 install_element (CONFIG_NODE
, &no_router_ospf_instance_cmd
);
10284 install_default (OSPF_NODE
);
10286 /* "ospf router-id" commands. */
10287 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
10288 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
10289 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
10290 install_element (OSPF_NODE
, &no_ospf_router_id_val_cmd
);
10292 /* "passive-interface" commands. */
10293 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10294 install_element (OSPF_NODE
, &ospf_passive_interface_cmd
);
10295 install_element (OSPF_NODE
, &ospf_passive_interface_default_cmd
);
10296 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10297 install_element (OSPF_NODE
, &no_ospf_passive_interface_cmd
);
10298 install_element (OSPF_NODE
, &no_ospf_passive_interface_default_cmd
);
10300 /* "ospf abr-type" commands. */
10301 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
10302 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
10304 /* "ospf log-adjacency-changes" commands. */
10305 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10306 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10307 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10308 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10310 /* "ospf rfc1583-compatible" commands. */
10311 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10312 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10313 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10314 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10316 /* "network area" commands. */
10317 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
10318 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
10320 /* "area authentication" commands. */
10321 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
10322 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
10323 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10325 /* "area range" commands. */
10326 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
10327 install_element (OSPF_NODE
, &ospf_area_range_advertise_cmd
);
10328 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
10329 install_element (OSPF_NODE
, &ospf_area_range_advertise_cost_cmd
);
10330 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10331 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
10332 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cmd
);
10333 install_element (OSPF_NODE
, &no_ospf_area_range_cost_cmd
);
10334 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cost_cmd
);
10335 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10336 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10338 /* "area virtual-link" commands. */
10339 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
10340 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10342 install_element (OSPF_NODE
, &ospf_area_vlink_param1_cmd
);
10343 install_element (OSPF_NODE
, &no_ospf_area_vlink_param1_cmd
);
10345 install_element (OSPF_NODE
, &ospf_area_vlink_param2_cmd
);
10346 install_element (OSPF_NODE
, &no_ospf_area_vlink_param2_cmd
);
10348 install_element (OSPF_NODE
, &ospf_area_vlink_param3_cmd
);
10349 install_element (OSPF_NODE
, &no_ospf_area_vlink_param3_cmd
);
10351 install_element (OSPF_NODE
, &ospf_area_vlink_param4_cmd
);
10352 install_element (OSPF_NODE
, &no_ospf_area_vlink_param4_cmd
);
10354 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_cmd
);
10355 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_cmd
);
10356 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_cmd
);
10357 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_cmd
);
10359 install_element (OSPF_NODE
, &ospf_area_vlink_md5_cmd
);
10360 install_element (OSPF_NODE
, &no_ospf_area_vlink_md5_cmd
);
10362 install_element (OSPF_NODE
, &ospf_area_vlink_authkey_cmd
);
10363 install_element (OSPF_NODE
, &no_ospf_area_vlink_authkey_cmd
);
10365 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_authkey_cmd
);
10366 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_authkey_cmd
);
10367 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_authkey_cmd
);
10368 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_authkey_cmd
);
10370 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_md5_cmd
);
10371 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_md5_cmd
);
10372 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_md5_cmd
);
10373 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_md5_cmd
);
10375 /* "area stub" commands. */
10376 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10377 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
10378 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10379 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
10381 /* "area nssa" commands. */
10382 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
10383 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
10384 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10385 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10386 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10387 install_element (OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
10389 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
10390 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10392 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
10393 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10395 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
10396 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10398 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
10399 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10401 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
10402 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10404 /* SPF timer commands */
10405 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10406 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10407 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_val_cmd
);
10409 /* LSA timers commands */
10410 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10411 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10412 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_val_cmd
);
10413 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
10414 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
10415 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_val_cmd
);
10416 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
10417 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
10418 install_element (OSPF_NODE
, &no_ospf_timers_lsa_val_cmd
);
10420 /* refresh timer commands */
10421 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
10422 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10423 install_element (OSPF_NODE
, &no_ospf_refresh_timer_cmd
);
10425 /* max-metric commands */
10426 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10427 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10428 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10429 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10430 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_no_param_cmd
);
10431 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10432 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10433 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
);
10435 /* reference bandwidth commands */
10436 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10437 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10438 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_val_cmd
);
10440 /* "neighbor" commands. */
10441 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
10442 install_element (OSPF_NODE
, &ospf_neighbor_priority_poll_interval_cmd
);
10443 install_element (OSPF_NODE
, &ospf_neighbor_priority_cmd
);
10444 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10445 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_priority_cmd
);
10446 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
10447 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_cmd
);
10448 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_cmd
);
10449 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_priority_cmd
);
10450 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_pollinterval_cmd
);
10452 /* write multiplier commands */
10453 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
10454 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10455 install_element (OSPF_NODE
, &write_multiplier_cmd
);
10456 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
10457 install_element (OSPF_NODE
, &no_write_multiplier_val_cmd
);
10459 /* Init interface related vty commands. */
10460 ospf_vty_if_init ();
10462 /* Init zebra related vty commands. */
10463 ospf_vty_zebra_init ();