ospf_vty.c
上传用户:xiaozhuqw
上传日期:2009-11-15
资源大小:1338k
文件大小:217k
- /* OSPF VTY interface.
- * Copyright (C) 2000 Toshiaki Takada
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Zebra; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
- #include <zebra.h>
- #include "memory.h"
- #include "thread.h"
- #include "prefix.h"
- #include "table.h"
- #include "vty.h"
- #include "command.h"
- #include "plist.h"
- #include "log.h"
- #include "zclient.h"
- #include "ospfd/ospfd.h"
- #include "ospfd/ospf_asbr.h"
- #include "ospfd/ospf_lsa.h"
- #include "ospfd/ospf_lsdb.h"
- #include "ospfd/ospf_ism.h"
- #include "ospfd/ospf_interface.h"
- #include "ospfd/ospf_nsm.h"
- #include "ospfd/ospf_neighbor.h"
- #include "ospfd/ospf_flood.h"
- #include "ospfd/ospf_abr.h"
- #include "ospfd/ospf_spf.h"
- #include "ospfd/ospf_route.h"
- #include "ospfd/ospf_zebra.h"
- /*#include "ospfd/ospf_routemap.h" */
- #include "ospfd/ospf_vty.h"
- #include "ospfd/ospf_dump.h"
- static char *ospf_network_type_str[] =
- {
- "Null",
- "POINTOPOINT",
- "BROADCAST",
- "NBMA",
- "POINTOMULTIPOINT",
- "VIRTUALLINK",
- "LOOPBACK"
- };
- /* Utility functions. */
- int
- ospf_str2area_id (char *str, struct in_addr *area_id, int *format)
- {
- char *endptr = NULL;
- unsigned long ret;
- /* match "A.B.C.D". */
- if (strchr (str, '.') != NULL)
- {
- ret = inet_aton (str, area_id);
- if (!ret)
- return -1;
- *format = OSPF_AREA_ID_FORMAT_ADDRESS;
- }
- /* match "<0-4294967295>". */
- else
- {
- ret = strtoul (str, &endptr, 10);
- if (*endptr != ' ' || (ret == ULONG_MAX && errno == ERANGE))
- return -1;
- area_id->s_addr = htonl (ret);
- *format = OSPF_AREA_ID_FORMAT_DECIMAL;
- }
- return 0;
- }
- int
- str2distribute_source (char *str, int *source)
- {
- /* Sanity check. */
- if (str == NULL)
- return 0;
- if (strncmp (str, "k", 1) == 0)
- *source = ZEBRA_ROUTE_KERNEL;
- else if (strncmp (str, "c", 1) == 0)
- *source = ZEBRA_ROUTE_CONNECT;
- else if (strncmp (str, "s", 1) == 0)
- *source = ZEBRA_ROUTE_STATIC;
- else if (strncmp (str, "r", 1) == 0)
- *source = ZEBRA_ROUTE_RIP;
- else if (strncmp (str, "b", 1) == 0)
- *source = ZEBRA_ROUTE_BGP;
- else
- return 0;
- return 1;
- }
- int
- str2metric (char *str, int *metric)
- {
- /* Sanity check. */
- if (str == NULL)
- return 0;
- *metric = strtol (str, NULL, 10);
- if (*metric < 0 && *metric > 16777214)
- {
- /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
- return 0;
- }
- return 1;
- }
- int
- str2metric_type (char *str, int *metric_type)
- {
- /* Sanity check. */
- if (str == NULL)
- return 0;
- if (strncmp (str, "1", 1) == 0)
- *metric_type = EXTERNAL_METRIC_TYPE_1;
- else if (strncmp (str, "2", 1) == 0)
- *metric_type = EXTERNAL_METRIC_TYPE_2;
- else
- return 0;
- return 1;
- }
- int
- ospf_oi_count (struct interface *ifp)
- {
- struct route_node *rn;
- int i = 0;
- for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
- if (rn->info)
- i++;
- return i;
- }
- DEFUN (router_ospf,
- router_ospf_cmd,
- "router ospf",
- "Enable a routing processn"
- "Start OSPF configurationn")
- {
- vty->node = OSPF_NODE;
- vty->index = ospf_get ();
-
- return CMD_SUCCESS;
- }
- DEFUN (no_router_ospf,
- no_router_ospf_cmd,
- "no router ospf",
- NO_STR
- "Enable a routing processn"
- "Start OSPF configurationn")
- {
- struct ospf *ospf;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf_finish (ospf);
- return CMD_SUCCESS;
- }
- DEFUN (ospf_router_id,
- ospf_router_id_cmd,
- "ospf router-id A.B.C.D",
- "OSPF specific commandsn"
- "router-id for the OSPF processn"
- "OSPF router-id in IP address formatn")
- {
- struct ospf *ospf = vty->index;
- struct in_addr router_id;
- int ret;
- ret = inet_aton (argv[0], &router_id);
- if (!ret)
- {
- vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf->router_id_static = router_id;
- if (ospf->t_router_id_update == NULL)
- OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
- OSPF_ROUTER_ID_UPDATE_DELAY);
- return CMD_SUCCESS;
- }
- ALIAS (ospf_router_id,
- router_ospf_id_cmd,
- "router-id A.B.C.D",
- "router-id for the OSPF processn"
- "OSPF router-id in IP address formatn");
- DEFUN (no_ospf_router_id,
- no_ospf_router_id_cmd,
- "no ospf router-id",
- NO_STR
- "OSPF specific commandsn"
- "router-id for the OSPF processn")
- {
- struct ospf *ospf = vty->index;
- ospf->router_id_static.s_addr = 0;
- ospf_router_id_update (ospf);
- return CMD_SUCCESS;
- }
- ALIAS (no_ospf_router_id,
- no_router_ospf_id_cmd,
- "no router-id",
- NO_STR
- "router-id for the OSPF processn");
- DEFUN (ospf_passive_interface,
- ospf_passive_interface_addr_cmd,
- "passive-interface IFNAME A.B.C.D",
- "Suppress routing updates on an interfacen"
- "Interface's namen")
- {
- struct interface *ifp;
- struct in_addr addr;
- int ret;
- struct ospf_if_params *params;
- ifp = if_lookup_by_name (argv[0]);
-
- if (ifp == NULL)
- {
- vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- params = IF_DEF_PARAMS (ifp);
- if (argc == 2)
- {
- ret = inet_aton(argv[1], &addr);
- if (!ret)
- {
- vty_out (vty, "Please specify interface address by A.B.C.D%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- params = ospf_get_if_params (ifp, addr);
- ospf_if_update_params (ifp, addr);
- }
- SET_IF_PARAM (params, passive_interface);
- params->passive_interface = OSPF_IF_PASSIVE;
-
- return CMD_SUCCESS;
- }
- ALIAS (ospf_passive_interface,
- ospf_passive_interface_cmd,
- "passive-interface IFNAME",
- "Suppress routing updates on an interfacen"
- "Interface's namen");
- DEFUN (no_ospf_passive_interface,
- no_ospf_passive_interface_addr_cmd,
- "no passive-interface IFNAME A.B.C.D",
- NO_STR
- "Allow routing updates on an interfacen"
- "Interface's namen")
- {
- struct interface *ifp;
- struct in_addr addr;
- struct ospf_if_params *params;
- int ret;
-
- ifp = if_lookup_by_name (argv[0]);
-
- if (ifp == NULL)
- {
- vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- params = IF_DEF_PARAMS (ifp);
- if (argc == 2)
- {
- ret = inet_aton(argv[1], &addr);
- if (!ret)
- {
- vty_out (vty, "Please specify interface address by A.B.C.D%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- params = ospf_lookup_if_params (ifp, addr);
- if (params == NULL)
- return CMD_SUCCESS;
- }
- UNSET_IF_PARAM (params, passive_interface);
- params->passive_interface = OSPF_IF_ACTIVE;
-
- if (params != IF_DEF_PARAMS (ifp))
- {
- ospf_free_if_params (ifp, addr);
- ospf_if_update_params (ifp, addr);
- }
-
- return CMD_SUCCESS;
- }
- ALIAS (no_ospf_passive_interface,
- no_ospf_passive_interface_cmd,
- "no passive-interface IFNAME",
- NO_STR
- "Allow routing updates on an interfacen"
- "Interface's namen");
- DEFUN (ospf_network_area,
- ospf_network_area_cmd,
- "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
- "Enable routing on an IP networkn"
- "OSPF network prefixn"
- "Set the OSPF area IDn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen")
- {
- struct ospf *ospf= vty->index;
- struct prefix_ipv4 p;
- struct in_addr area_id;
- int ret, format;
- /* Get network prefix and Area ID. */
- VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
- ret = ospf_network_set (ospf, &p, area_id);
- if (ret == 0)
- {
- vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_network_area,
- no_ospf_network_area_cmd,
- "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
- NO_STR
- "Enable routing on an IP networkn"
- "OSPF network prefixn"
- "Set the OSPF area IDn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen")
- {
- struct ospf *ospf = (struct ospf *) vty->index;
- struct prefix_ipv4 p;
- struct in_addr area_id;
- int ret, format;
- /* Get network prefix and Area ID. */
- VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
- ret = ospf_network_unset (ospf, &p, area_id);
- if (ret == 0)
- {
- vty_out (vty, "Can't find specified network area configuration.%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_range,
- ospf_area_range_cmd,
- "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn")
- {
- struct ospf *ospf = vty->index;
- struct prefix_ipv4 p;
- struct in_addr area_id;
- int format;
- u_int32_t cost;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
- ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
- if (argc > 2)
- {
- VTY_GET_UINT32 ("range cost", cost, argv[2]);
- ospf_area_range_cost_set (ospf, area_id, &p, cost);
- }
- return CMD_SUCCESS;
- }
- ALIAS (ospf_area_range,
- ospf_area_range_advertise_cmd,
- "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "OSPF area range for route advertise (default)n"
- "Area range prefixn"
- "Advertise this range (default)n");
- ALIAS (ospf_area_range,
- ospf_area_range_cost_cmd,
- "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "User specified metric for this rangen"
- "Advertised metric for this rangen");
- ALIAS (ospf_area_range,
- ospf_area_range_advertise_cost_cmd,
- "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "Advertise this range (default)n"
- "User specified metric for this rangen"
- "Advertised metric for this rangen");
- DEFUN (ospf_area_range_not_advertise,
- ospf_area_range_not_advertise_cmd,
- "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "DoNotAdvertise this rangen")
- {
- struct ospf *ospf = vty->index;
- struct prefix_ipv4 p;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
- ospf_area_range_set (ospf, area_id, &p, 0);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_range,
- no_ospf_area_range_cmd,
- "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn")
- {
- struct ospf *ospf = vty->index;
- struct prefix_ipv4 p;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
- ospf_area_range_unset (ospf, area_id, &p);
- return CMD_SUCCESS;
- }
- ALIAS (no_ospf_area_range,
- no_ospf_area_range_advertise_cmd,
- "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "Advertise this range (default)n"
- "DoNotAdvertise this rangen");
- ALIAS (no_ospf_area_range,
- no_ospf_area_range_cost_cmd,
- "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "User specified metric for this rangen"
- "Advertised metric for this rangen");
- ALIAS (no_ospf_area_range,
- no_ospf_area_range_advertise_cost_cmd,
- "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "Advertise this range (default)n"
- "User specified metric for this rangen"
- "Advertised metric for this rangen");
- DEFUN (ospf_area_range_substitute,
- ospf_area_range_substitute_cmd,
- "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "Announce area range as another prefixn"
- "Network prefix to be announced instead of rangen")
- {
- struct ospf *ospf = vty->index;
- struct prefix_ipv4 p, s;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
- VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
- ospf_area_range_substitute_set (ospf, area_id, &p, &s);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_range_substitute,
- no_ospf_area_range_substitute_cmd,
- "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Summarize routes matching address/mask (border routers only)n"
- "Area range prefixn"
- "Announce area range as another prefixn"
- "Network prefix to be announced instead of rangen")
- {
- struct ospf *ospf = vty->index;
- struct prefix_ipv4 p, s;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
- VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
- ospf_area_range_substitute_unset (ospf, area_id, &p);
- return CMD_SUCCESS;
- }
- /* Command Handler Logic in VLink stuff is delicate!!
- ALTER AT YOUR OWN RISK!!!!
- Various dummy values are used to represent 'NoChange' state for
- VLink configuration NOT being changed by a VLink command, and
- special syntax is used within the command strings so that the
- typed in command verbs can be seen in the configuration command
- bacckend handler. This is to drastically reduce the verbeage
- required to coe up with a reasonably compatible Cisco VLink command
- - Matthew Grant <grantma@anathoth.gen.nz>
- Wed, 21 Feb 2001 15:13:52 +1300
- */
- /* Configuration data for virtual links
- */
- struct ospf_vl_config_data {
- struct vty *vty; /* vty stuff */
- struct in_addr area_id; /* area ID from command line */
- int format; /* command line area ID format */
- struct in_addr vl_peer; /* command line vl_peer */
- int auth_type; /* Authehntication type, if given */
- char *auth_key; /* simple password if present */
- int crypto_key_id; /* Cryptographic key ID */
- char *md5_key; /* MD5 authentication key */
- int hello_interval; /* Obvious what these are... */
- int retransmit_interval;
- int transmit_delay;
- int dead_interval;
- };
- void
- ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
- struct vty *vty)
- {
- memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
- vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
- vl_config->vty = vty;
- }
- struct ospf_vl_data *
- ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
- {
- struct ospf_area *area;
- struct ospf_vl_data *vl_data;
- struct vty *vty;
- struct in_addr area_id;
- vty = vl_config->vty;
- area_id = vl_config->area_id;
- if (area_id.s_addr == OSPF_AREA_BACKBONE)
- {
- vty_out (vty,
- "Configuring VLs over the backbone is not allowed%s",
- VTY_NEWLINE);
- return NULL;
- }
- area = ospf_area_get (ospf, area_id, vl_config->format);
- if (area->external_routing != OSPF_AREA_DEFAULT)
- {
- if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
- vty_out (vty, "Area %s is %s%s",
- inet_ntoa (area_id),
- #ifdef HAVE_NSSA
- area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
- #else
- "stub",
- #endif /* HAVE_NSSA */
- VTY_NEWLINE);
- else
- vty_out (vty, "Area %ld is %s%s",
- (u_long)ntohl (area_id.s_addr),
- #ifdef HAVE_NSSA
- area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
- #else
- "stub",
- #endif /* HAVE_NSSA */
- VTY_NEWLINE);
- return NULL;
- }
-
- if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
- {
- vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
- if (vl_data->vl_oi == NULL)
- {
- vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
- ospf_vl_add (ospf, vl_data);
- ospf_spf_calculate_schedule (ospf);
- }
- }
- return vl_data;
- }
- int
- ospf_vl_set_security (struct ospf_vl_data *vl_data,
- struct ospf_vl_config_data *vl_config)
- {
- struct crypt_key *ck;
- struct vty *vty;
- struct interface *ifp = vl_data->vl_oi->ifp;
- vty = vl_config->vty;
- if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
- {
- SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
- IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
- }
- if (vl_config->auth_key)
- {
- memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
- strncpy (IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
- OSPF_AUTH_SIMPLE_SIZE);
- }
- else if (vl_config->md5_key)
- {
- if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
- != NULL)
- {
- vty_out (vty, "OSPF: Key %d already exists%s",
- vl_config->crypto_key_id, VTY_NEWLINE);
- return CMD_WARNING;
- }
- ck = ospf_crypt_key_new ();
- ck->key_id = vl_config->crypto_key_id;
- memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
- strncpy (ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
-
- ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
- }
- else if (vl_config->crypto_key_id != 0)
- {
- /* Delete a key */
- if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
- vl_config->crypto_key_id) == NULL)
- {
- vty_out (vty, "OSPF: Key %d does not exist%s",
- vl_config->crypto_key_id, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
- }
-
- return CMD_SUCCESS;
- }
- int
- ospf_vl_set_timers (struct ospf_vl_data *vl_data,
- struct ospf_vl_config_data *vl_config)
- {
- struct interface *ifp = ifp = vl_data->vl_oi->ifp;
- /* Virtual Link data initialised to defaults, so only set
- if a value given */
- if (vl_config->hello_interval)
- {
- SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
- IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
- }
- if (vl_config->dead_interval)
- {
- SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
- IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
- }
- if (vl_config->retransmit_interval)
- {
- SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
- IF_DEF_PARAMS (ifp)->retransmit_interval
- = vl_config->retransmit_interval;
- }
-
- if (vl_config->transmit_delay)
- {
- SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
- IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
- }
-
- return CMD_SUCCESS;
- }
- /* The business end of all of the above */
- int
- ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
- {
- struct ospf_vl_data *vl_data;
- int ret;
- vl_data = ospf_find_vl_data (ospf, vl_config);
- if (!vl_data)
- return CMD_WARNING;
-
- /* Process this one first as it can have a fatal result, which can
- only logically occur if the virtual link exists already
- Thus a command error does not result in a change to the
- running configuration such as unexpectedly altered timer
- values etc.*/
- ret = ospf_vl_set_security (vl_data, vl_config);
- if (ret != CMD_SUCCESS)
- return ret;
- /* Set any time based parameters, these area already range checked */
- ret = ospf_vl_set_timers (vl_data, vl_config);
- if (ret != CMD_SUCCESS)
- return ret;
- return CMD_SUCCESS;
- }
- /* This stuff exists to make specifying all the alias commands A LOT simpler
- */
- #define VLINK_HELPSTR_IPADDR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure a virtual linkn"
- "Router ID of the remote ABRn"
- #define VLINK_HELPSTR_AUTHTYPE_SIMPLE
- "Enable authentication on this virtual linkn"
- "dummy string n"
- #define VLINK_HELPSTR_AUTHTYPE_ALL
- VLINK_HELPSTR_AUTHTYPE_SIMPLE
- "Use null authenticationn"
- "Use message-digest authenticationn"
- #define VLINK_HELPSTR_TIME_PARAM_NOSECS
- "Time between HELLO packetsn"
- "Time between retransmitting lost link state advertisementsn"
- "Link state transmit delayn"
- "Interval after which a neighbor is declared deadn"
- #define VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM_NOSECS
- "Secondsn"
- #define VLINK_HELPSTR_AUTH_SIMPLE
- "Authentication password (key)n"
- "The OSPF password (key)"
- #define VLINK_HELPSTR_AUTH_MD5
- "Message digest authentication password (key)n"
- "dummy string n"
- "Key IDn"
- "Use MD5 algorithmn"
- "The OSPF password (key)"
- DEFUN (ospf_area_vlink,
- ospf_area_vlink_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
- VLINK_HELPSTR_IPADDR)
- {
- struct ospf *ospf = vty->index;
- struct ospf_vl_config_data vl_config;
- char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
- char md5_key[OSPF_AUTH_MD5_SIZE+1];
- int i;
- int ret;
-
- ospf_vl_config_data_init(&vl_config, vty);
- /* Read off first 2 parameters and check them */
- ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
- if (ret < 0)
- {
- vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- ret = inet_aton (argv[1], &vl_config.vl_peer);
- if (! ret)
- {
- vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (argc <=2)
- {
- /* Thats all folks! - BUGS B. strikes again!!!*/
- return ospf_vl_set (ospf, &vl_config);
- }
- /* Deal with other parameters */
- for (i=2; i < argc; i++)
- {
- /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
- switch (argv[i][0])
- {
- case 'a':
- if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
- {
- /* authentication-key - this option can occur anywhere on
- command line. At start of command line
- must check for authentication option. */
- memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
- strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
- vl_config.auth_key = auth_key;
- i++;
- }
- else if (strncmp (argv[i], "authentication", 14) == 0)
- {
- /* authentication - this option can only occur at start
- of command line */
- vl_config.auth_type = OSPF_AUTH_SIMPLE;
- if ((i+1) < argc)
- {
- if (strncmp (argv[i+1], "n", 1) == 0)
- {
- /* "authentication null" */
- vl_config.auth_type = OSPF_AUTH_NULL;
- i++;
- }
- else if (strncmp (argv[i+1], "m", 1) == 0
- && strcmp (argv[i+1], "message-digest-") != 0)
- {
- /* "authentication message-digest" */
- vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
- i++;
- }
- }
- }
- break;
- case 'm':
- /* message-digest-key */
- i++;
- vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
- if (vl_config.crypto_key_id < 0)
- return CMD_WARNING;
- i++;
- memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
- strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
- vl_config.md5_key = md5_key;
- break;
- case 'h':
- /* Hello interval */
- i++;
- vl_config.hello_interval = strtol (argv[i], NULL, 10);
- if (vl_config.hello_interval < 0)
- return CMD_WARNING;
- break;
- case 'r':
- /* Retransmit Interval */
- i++;
- vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
- if (vl_config.retransmit_interval < 0)
- return CMD_WARNING;
- break;
- case 't':
- /* Transmit Delay */
- i++;
- vl_config.transmit_delay = strtol (argv[i], NULL, 10);
- if (vl_config.transmit_delay < 0)
- return CMD_WARNING;
- break;
- case 'd':
- /* Dead Interval */
- i++;
- vl_config.dead_interval = strtol (argv[i], NULL, 10);
- if (vl_config.dead_interval < 0)
- return CMD_WARNING;
- break;
- }
- }
- /* Action configuration */
- return ospf_vl_set (ospf, &vl_config);
- }
- DEFUN (no_ospf_area_vlink,
- no_ospf_area_vlink_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
- NO_STR
- VLINK_HELPSTR_IPADDR)
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct ospf_vl_config_data vl_config;
- struct ospf_vl_data *vl_data = NULL;
- char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
- int i;
- int ret, format;
- ospf_vl_config_data_init(&vl_config, vty);
- ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
- if (ret < 0)
- {
- vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
- if (!area)
- {
- vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- ret = inet_aton (argv[1], &vl_config.vl_peer);
- if (! ret)
- {
- vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (argc <=2)
- {
- /* Basic VLink no command */
- /* Thats all folks! - BUGS B. strikes again!!!*/
- if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
- ospf_vl_delete (ospf, vl_data);
- ospf_area_check_free (ospf, vl_config.area_id);
-
- return CMD_SUCCESS;
- }
- /* If we are down here, we are reseting parameters */
- /* Deal with other parameters */
- for (i=2; i < argc; i++)
- {
- /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
- switch (argv[i][0])
- {
- case 'a':
- if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
- {
- /* authentication-key - this option can occur anywhere on
- command line. At start of command line
- must check for authentication option. */
- memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
- vl_config.auth_key = auth_key;
- }
- else if (strncmp (argv[i], "authentication", 14) == 0)
- {
- /* authentication - this option can only occur at start
- of command line */
- vl_config.auth_type = OSPF_AUTH_NOTSET;
- }
- break;
- case 'm':
- /* message-digest-key */
- /* Delete one key */
- i++;
- vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
- if (vl_config.crypto_key_id < 0)
- return CMD_WARNING;
- vl_config.md5_key = NULL;
- break;
- case 'h':
- /* Hello interval */
- vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
- break;
- case 'r':
- /* Retransmit Interval */
- vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
- break;
- case 't':
- /* Transmit Delay */
- vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
- break;
- case 'd':
- /* Dead Interval */
- i++;
- vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
- break;
- }
- }
- /* Action configuration */
- return ospf_vl_set (ospf, &vl_config);
- }
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_param1_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_param1_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_param2_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_param2_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_param3_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_param3_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_param4_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_param4_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
- "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM
- VLINK_HELPSTR_TIME_PARAM);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_authtype_args_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|) (message-digest|null)",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_ALL);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_authtype_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|)",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_SIMPLE);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_authtype_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_SIMPLE);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_md5_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(message-digest-key|) <1-255> md5 KEY",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTH_MD5);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_md5_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(message-digest-key|) <1-255>",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTH_MD5);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_authkey_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication-key|) AUTH_KEY",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTH_SIMPLE);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_authkey_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication-key|)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTH_SIMPLE);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_authtype_args_authkey_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|) (message-digest|null) "
- "(authentication-key|) AUTH_KEY",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_ALL
- VLINK_HELPSTR_AUTH_SIMPLE);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_authtype_authkey_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|) "
- "(authentication-key|) AUTH_KEY",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_SIMPLE
- VLINK_HELPSTR_AUTH_SIMPLE);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_authtype_authkey_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|) "
- "(authentication-key|)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_SIMPLE
- VLINK_HELPSTR_AUTH_SIMPLE);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_authtype_args_md5_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|) (message-digest|null) "
- "(message-digest-key|) <1-255> md5 KEY",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_ALL
- VLINK_HELPSTR_AUTH_MD5);
- ALIAS (ospf_area_vlink,
- ospf_area_vlink_authtype_md5_cmd,
- "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|) "
- "(message-digest-key|) <1-255> md5 KEY",
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_SIMPLE
- VLINK_HELPSTR_AUTH_MD5);
- ALIAS (no_ospf_area_vlink,
- no_ospf_area_vlink_authtype_md5_cmd,
- "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
- "(authentication|) "
- "(message-digest-key|)",
- NO_STR
- VLINK_HELPSTR_IPADDR
- VLINK_HELPSTR_AUTHTYPE_SIMPLE
- VLINK_HELPSTR_AUTH_MD5);
- DEFUN (ospf_area_shortcut,
- ospf_area_shortcut_cmd,
- "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure the area's shortcutting moden"
- "Set default shortcutting behaviorn"
- "Enable shortcutting through the arean"
- "Disable shortcutting through the arean")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int mode;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
- area = ospf_area_get (ospf, area_id, format);
- if (strncmp (argv[1], "de", 2) == 0)
- mode = OSPF_SHORTCUT_DEFAULT;
- else if (strncmp (argv[1], "di", 2) == 0)
- mode = OSPF_SHORTCUT_DISABLE;
- else if (strncmp (argv[1], "e", 1) == 0)
- mode = OSPF_SHORTCUT_ENABLE;
- else
- return CMD_WARNING;
- ospf_area_shortcut_set (ospf, area, mode);
- if (ospf->abr_type != OSPF_ABR_SHORTCUT)
- vty_out (vty, "Shortcut area setting will take effect "
- "only when the router is configured as Shortcut ABR%s",
- VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_shortcut,
- no_ospf_area_shortcut_cmd,
- "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Deconfigure the area's shortcutting moden"
- "Deconfigure enabled shortcutting through the arean"
- "Deconfigure disabled shortcutting through the arean")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (ospf, area_id);
- if (!area)
- return CMD_SUCCESS;
- ospf_area_shortcut_unset (ospf, area);
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_stub,
- ospf_area_stub_cmd,
- "area (A.B.C.D|<0-4294967295>) stub",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as stubn")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int ret, format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
- ret = ospf_area_stub_set (ospf, area_id);
- if (ret == 0)
- {
- vty_out (vty, "First deconfigure all virtual link through this area%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf_area_no_summary_unset (ospf, area_id);
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_stub_no_summary,
- ospf_area_stub_no_summary_cmd,
- "area (A.B.C.D|<0-4294967295>) stub no-summary",
- "OSPF stub parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as stubn"
- "Do not inject inter-area routes into stubn")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int ret, format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
- ret = ospf_area_stub_set (ospf, area_id);
- if (ret == 0)
- {
- vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf_area_no_summary_set (ospf, area_id);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_stub,
- no_ospf_area_stub_cmd,
- "no area (A.B.C.D|<0-4294967295>) stub",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as stubn")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
- ospf_area_stub_unset (ospf, area_id);
- ospf_area_no_summary_unset (ospf, area_id);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_stub_no_summary,
- no_ospf_area_stub_no_summary_cmd,
- "no area (A.B.C.D|<0-4294967295>) stub no-summary",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as stubn"
- "Do not inject inter-area routes into arean")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
- ospf_area_no_summary_unset (ospf, area_id);
- return CMD_SUCCESS;
- }
- #ifdef HAVE_NSSA
- DEFUN (ospf_area_nssa,
- ospf_area_nssa_cmd,
- "area (A.B.C.D|<0-4294967295>) nssa",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as nssan")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int ret, format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
- ret = ospf_area_nssa_set (ospf, area_id);
- if (ret == 0)
- {
- vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (argc > 1)
- {
- if (strncmp (argv[1], "translate-c", 11) == 0)
- ospf_area_nssa_translator_role_set (ospf, area_id,
- OSPF_NSSA_ROLE_CANDIDATE);
- else if (strncmp (argv[1], "translate-n", 11) == 0)
- ospf_area_nssa_translator_role_set (ospf, area_id,
- OSPF_NSSA_ROLE_NEVER);
- else if (strncmp (argv[1], "translate-a", 11) == 0)
- ospf_area_nssa_translator_role_set (ospf, area_id,
- OSPF_NSSA_ROLE_ALWAYS);
- }
- if (argc > 2)
- ospf_area_no_summary_set (ospf, area_id);
- return CMD_SUCCESS;
- }
- ALIAS (ospf_area_nssa,
- ospf_area_nssa_translate_no_summary_cmd,
- "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) (no-summary|)",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as nssan"
- "Configure NSSA-ABR for translate election (default)n"
- "Configure NSSA-ABR to never translaten"
- "Configure NSSA-ABR to always translaten"
- "Do not inject inter-area routes into nssan"
- "dummyn");
- ALIAS (ospf_area_nssa,
- ospf_area_nssa_translate_cmd,
- "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as nssan"
- "Configure NSSA-ABR for translate election (default)n"
- "Configure NSSA-ABR to never translaten"
- "Configure NSSA-ABR to always translaten");
- DEFUN (ospf_area_nssa_no_summary,
- ospf_area_nssa_no_summary_cmd,
- "area (A.B.C.D|<0-4294967295>) nssa no-summary",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as nssan"
- "Do not inject inter-area routes into nssan")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int ret, format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
- ret = ospf_area_nssa_set (ospf, area_id);
- if (ret == 0)
- {
- vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf_area_no_summary_set (ospf, area_id);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_nssa,
- no_ospf_area_nssa_cmd,
- "no area (A.B.C.D|<0-4294967295>) nssa",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as nssan")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
- ospf_area_nssa_unset (ospf, area_id);
- ospf_area_no_summary_unset (ospf, area_id);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_nssa_no_summary,
- no_ospf_area_nssa_no_summary_cmd,
- "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Configure OSPF area as nssan"
- "Do not inject inter-area routes into nssan")
- {
- struct ospf *ospf = vty->index;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
- ospf_area_no_summary_unset (ospf, area_id);
- return CMD_SUCCESS;
- }
- #endif /* HAVE_NSSA */
- DEFUN (ospf_area_default_cost,
- ospf_area_default_cost_cmd,
- "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Set the summary-default cost of a NSSA or stub arean"
- "Stub's advertised default summary costn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- u_int32_t cost;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
- VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
- area = ospf_area_get (ospf, area_id, format);
- if (area->external_routing == OSPF_AREA_DEFAULT)
- {
- vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- area->default_cost = cost;
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_default_cost,
- no_ospf_area_default_cost_cmd,
- "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Set the summary-default cost of a NSSA or stub arean"
- "Stub's advertised default summary costn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- u_int32_t cost;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
- VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
- area = ospf_area_lookup_by_area_id (ospf, area_id);
- if (area == NULL)
- return CMD_SUCCESS;
- if (area->external_routing == OSPF_AREA_DEFAULT)
- {
- vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- area->default_cost = 1;
- ospf_area_check_free (ospf, area_id);
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_export_list,
- ospf_area_export_list_cmd,
- "area (A.B.C.D|<0-4294967295>) export-list NAME",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Set the filter for networks announced to other areasn"
- "Name of the access-listn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]);
- area = ospf_area_get (ospf, area_id, format);
- ospf_area_export_list_set (ospf, area, argv[1]);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_export_list,
- no_ospf_area_export_list_cmd,
- "no area (A.B.C.D|<0-4294967295>) export-list NAME",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Unset the filter for networks announced to other areasn"
- "Name of the access-listn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (ospf, area_id);
- if (area == NULL)
- return CMD_SUCCESS;
- ospf_area_export_list_unset (ospf, area);
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_import_list,
- ospf_area_import_list_cmd,
- "area (A.B.C.D|<0-4294967295>) import-list NAME",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Set the filter for networks from other areas announced to the specified onen"
- "Name of the access-listn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]);
- area = ospf_area_get (ospf, area_id, format);
- ospf_area_import_list_set (ospf, area, argv[1]);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_import_list,
- no_ospf_area_import_list_cmd,
- "no area (A.B.C.D|<0-4294967295>) import-list NAME",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Unset the filter for networks announced to other areasn"
- "Name of the access-listn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (ospf, area_id);
- if (area == NULL)
- return CMD_SUCCESS;
- ospf_area_import_list_unset (ospf, area);
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_filter_list,
- ospf_area_filter_list_cmd,
- "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Filter networks between OSPF areasn"
- "Filter prefixes between OSPF areasn"
- "Name of an IP prefix-listn"
- "Filter networks sent to this arean"
- "Filter networks sent from this arean")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- struct prefix_list *plist;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_get (ospf, area_id, format);
- plist = prefix_list_lookup (AFI_IP, argv[1]);
- if (strncmp (argv[2], "in", 2) == 0)
- {
- PREFIX_LIST_IN (area) = plist;
- if (PREFIX_NAME_IN (area))
- free (PREFIX_NAME_IN (area));
- PREFIX_NAME_IN (area) = strdup (argv[1]);
- ospf_schedule_abr_task (ospf);
- }
- else
- {
- PREFIX_LIST_OUT (area) = plist;
- if (PREFIX_NAME_OUT (area))
- free (PREFIX_NAME_OUT (area));
- PREFIX_NAME_OUT (area) = strdup (argv[1]);
- ospf_schedule_abr_task (ospf);
- }
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_filter_list,
- no_ospf_area_filter_list_cmd,
- "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Filter networks between OSPF areasn"
- "Filter prefixes between OSPF areasn"
- "Name of an IP prefix-listn"
- "Filter networks sent to this arean"
- "Filter networks sent from this arean")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- struct prefix_list *plist;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (ospf, area_id);
- plist = prefix_list_lookup (AFI_IP, argv[1]);
- if (strncmp (argv[2], "in", 2) == 0)
- {
- if (PREFIX_NAME_IN (area))
- if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
- return CMD_SUCCESS;
- PREFIX_LIST_IN (area) = NULL;
- if (PREFIX_NAME_IN (area))
- free (PREFIX_NAME_IN (area));
- PREFIX_NAME_IN (area) = NULL;
- ospf_schedule_abr_task (ospf);
- }
- else
- {
- if (PREFIX_NAME_OUT (area))
- if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
- return CMD_SUCCESS;
- PREFIX_LIST_OUT (area) = NULL;
- if (PREFIX_NAME_OUT (area))
- free (PREFIX_NAME_OUT (area));
- PREFIX_NAME_OUT (area) = NULL;
- ospf_schedule_abr_task (ospf);
- }
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_authentication_message_digest,
- ospf_area_authentication_message_digest_cmd,
- "area (A.B.C.D|<0-4294967295>) authentication message-digest",
- "OSPF area parametersn"
- "Enable authenticationn"
- "Use message-digest authenticationn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_get (ospf, area_id, format);
- area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
- return CMD_SUCCESS;
- }
- DEFUN (ospf_area_authentication,
- ospf_area_authentication_cmd,
- "area (A.B.C.D|<0-4294967295>) authentication",
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Enable authenticationn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_get (ospf, area_id, format);
- area->auth_type = OSPF_AUTH_SIMPLE;
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_area_authentication,
- no_ospf_area_authentication_cmd,
- "no area (A.B.C.D|<0-4294967295>) authentication",
- NO_STR
- "OSPF area parametersn"
- "OSPF area ID in IP address formatn"
- "OSPF area ID as a decimal valuen"
- "Enable authenticationn")
- {
- struct ospf *ospf = vty->index;
- struct ospf_area *area;
- struct in_addr area_id;
- int format;
- VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
- area = ospf_area_lookup_by_area_id (ospf, area_id);
- if (area == NULL)
- return CMD_SUCCESS;
- area->auth_type = OSPF_AUTH_NULL;
- ospf_area_check_free (ospf, area_id);
-
- return CMD_SUCCESS;
- }
- DEFUN (ospf_abr_type,
- ospf_abr_type_cmd,
- "ospf abr-type (cisco|ibm|shortcut|standard)",
- "OSPF specific commandsn"
- "Set OSPF ABR typen"
- "Alternative ABR, cisco implementationn"
- "Alternative ABR, IBM implementationn"
- "Shortcut ABRn"
- "Standard behavior (RFC2328)n")
- {
- struct ospf *ospf = vty->index;
- u_char abr_type = OSPF_ABR_UNKNOWN;
- if (strncmp (argv[0], "c", 1) == 0)
- abr_type = OSPF_ABR_CISCO;
- else if (strncmp (argv[0], "i", 1) == 0)
- abr_type = OSPF_ABR_IBM;
- else if (strncmp (argv[0], "sh", 2) == 0)
- abr_type = OSPF_ABR_SHORTCUT;
- else if (strncmp (argv[0], "st", 2) == 0)
- abr_type = OSPF_ABR_STAND;
- else
- return CMD_WARNING;
- /* If ABR type value is changed, schedule ABR task. */
- if (ospf->abr_type != abr_type)
- {
- ospf->abr_type = abr_type;
- ospf_schedule_abr_task (ospf);
- }
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_abr_type,
- no_ospf_abr_type_cmd,
- "no ospf abr-type (cisco|ibm|shortcut)",
- NO_STR
- "OSPF specific commandsn"
- "Set OSPF ABR typen"
- "Alternative ABR, cisco implementationn"
- "Alternative ABR, IBM implementationn"
- "Shortcut ABRn")
- {
- struct ospf *ospf = vty->index;
- u_char abr_type = OSPF_ABR_UNKNOWN;
- if (strncmp (argv[0], "c", 1) == 0)
- abr_type = OSPF_ABR_CISCO;
- else if (strncmp (argv[0], "i", 1) == 0)
- abr_type = OSPF_ABR_IBM;
- else if (strncmp (argv[0], "s", 1) == 0)
- abr_type = OSPF_ABR_SHORTCUT;
- else
- return CMD_WARNING;
- /* If ABR type value is changed, schedule ABR task. */
- if (ospf->abr_type == abr_type)
- {
- ospf->abr_type = OSPF_ABR_STAND;
- ospf_schedule_abr_task (ospf);
- }
- return CMD_SUCCESS;
- }
- DEFUN (ospf_compatible_rfc1583,
- ospf_compatible_rfc1583_cmd,
- "compatible rfc1583",
- "OSPF compatibility listn"
- "compatible with RFC 1583n")
- {
- struct ospf *ospf = vty->index;
- if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
- {
- SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
- ospf_spf_calculate_schedule (ospf);
- }
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_compatible_rfc1583,
- no_ospf_compatible_rfc1583_cmd,
- "no compatible rfc1583",
- NO_STR
- "OSPF compatibility listn"
- "compatible with RFC 1583n")
- {
- struct ospf *ospf = vty->index;
- if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
- {
- UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
- ospf_spf_calculate_schedule (ospf);
- }
- return CMD_SUCCESS;
- }
- ALIAS (ospf_compatible_rfc1583,
- ospf_rfc1583_flag_cmd,
- "ospf rfc1583compatibility",
- "OSPF specific commandsn"
- "Enable the RFC1583Compatibility flagn");
- ALIAS (no_ospf_compatible_rfc1583,
- no_ospf_rfc1583_flag_cmd,
- "no ospf rfc1583compatibility",
- NO_STR
- "OSPF specific commandsn"
- "Disable the RFC1583Compatibility flagn");
- DEFUN (ospf_timers_spf,
- ospf_timers_spf_cmd,
- "timers spf <0-4294967295> <0-4294967295>",
- "Adjust routing timersn"
- "OSPF SPF timersn"
- "Delay between receiving a change to SPF calculationn"
- "Hold time between consecutive SPF calculationsn")
- {
- struct ospf *ospf = vty->index;
- u_int32_t delay, hold;
- VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
- VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
- ospf_timers_spf_set (ospf, delay, hold);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_timers_spf,
- no_ospf_timers_spf_cmd,
- "no timers spf",
- NO_STR
- "Adjust routing timersn"
- "OSPF SPF timersn")
- {
- struct ospf *ospf = vty->index;
- ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
- ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
- return CMD_SUCCESS;
- }
- DEFUN (ospf_neighbor,
- ospf_neighbor_cmd,
- "neighbor A.B.C.D",
- NEIGHBOR_STR
- "Neighbor IP addressn")
- {
- struct ospf *ospf = vty->index;
- struct in_addr nbr_addr;
- int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
- int interval = OSPF_POLL_INTERVAL_DEFAULT;
- VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
- if (argc > 1)
- VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
- if (argc > 2)
- VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
- ospf_nbr_nbma_set (ospf, nbr_addr);
- if (argc > 1)
- ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
- if (argc > 2)
- ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
- return CMD_SUCCESS;
- }
- ALIAS (ospf_neighbor,
- ospf_neighbor_priority_poll_interval_cmd,
- "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
- NEIGHBOR_STR
- "Neighbor IP addressn"
- "Neighbor Priorityn"
- "Priorityn"
- "Dead Neighbor Polling intervaln"
- "Secondsn");
- ALIAS (ospf_neighbor,
- ospf_neighbor_priority_cmd,
- "neighbor A.B.C.D priority <0-255>",
- NEIGHBOR_STR
- "Neighbor IP addressn"
- "Neighbor Priorityn"
- "Secondsn");
- DEFUN (ospf_neighbor_poll_interval,
- ospf_neighbor_poll_interval_cmd,
- "neighbor A.B.C.D poll-interval <1-65535>",
- NEIGHBOR_STR
- "Neighbor IP addressn"
- "Dead Neighbor Polling intervaln"
- "Secondsn")
- {
- struct ospf *ospf = vty->index;
- struct in_addr nbr_addr;
- int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
- int interval = OSPF_POLL_INTERVAL_DEFAULT;
- VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
- if (argc > 1)
- VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
- if (argc > 2)
- VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
- ospf_nbr_nbma_set (ospf, nbr_addr);
- if (argc > 1)
- ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
- if (argc > 2)
- ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
- return CMD_SUCCESS;
- }
- ALIAS (ospf_neighbor_poll_interval,
- ospf_neighbor_poll_interval_priority_cmd,
- "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
- NEIGHBOR_STR
- "Neighbor addressn"
- "OSPF dead-router polling intervaln"
- "Secondsn"
- "OSPF priority of non-broadcast neighborn"
- "Priorityn");
- DEFUN (no_ospf_neighbor,
- no_ospf_neighbor_cmd,
- "no neighbor A.B.C.D",
- NO_STR
- NEIGHBOR_STR
- "Neighbor IP addressn")
- {
- struct ospf *ospf = vty->index;
- struct in_addr nbr_addr;
- int ret;
- VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
- ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
- return CMD_SUCCESS;
- }
- ALIAS (no_ospf_neighbor,
- no_ospf_neighbor_priority_cmd,
- "no neighbor A.B.C.D priority <0-255>",
- NO_STR
- NEIGHBOR_STR
- "Neighbor IP addressn"
- "Neighbor Priorityn"
- "Priorityn");
- ALIAS (no_ospf_neighbor,
- no_ospf_neighbor_poll_interval_cmd,
- "no neighbor A.B.C.D poll-interval <1-65535>",
- NO_STR
- NEIGHBOR_STR
- "Neighbor IP addressn"
- "Dead Neighbor Polling intervaln"
- "Secondsn");
- ALIAS (no_ospf_neighbor,
- no_ospf_neighbor_priority_pollinterval_cmd,
- "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
- NO_STR
- NEIGHBOR_STR
- "Neighbor IP addressn"
- "Neighbor Priorityn"
- "Priorityn"
- "Dead Neighbor Polling intervaln"
- "Secondsn");
- DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
- "refresh timer <10-1800>",
- "Adjust refresh parametersn"
- "Set refresh timern"
- "Timer value in secondsn")
- {
- struct ospf *ospf = vty->index;
- int interval;
-
- VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
- interval = (interval / 10) * 10;
- ospf_timers_refresh_set (ospf, interval);
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
- "no refresh timer <10-1800>",
- "Adjust refresh parametersn"
- "Unset refresh timern"
- "Timer value in secondsn")
- {
- struct ospf *ospf = vty->index;
- int interval;
- if (argc == 1)
- {
- VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
-
- if (ospf->lsa_refresh_interval != interval ||
- interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
- return CMD_SUCCESS;
- }
- ospf_timers_refresh_unset (ospf);
- return CMD_SUCCESS;
- }
- ALIAS (no_ospf_refresh_timer,
- no_ospf_refresh_timer_cmd,
- "no refresh timer",
- "Adjust refresh parametersn"
- "Unset refresh timern");
- DEFUN (ospf_auto_cost_reference_bandwidth,
- ospf_auto_cost_reference_bandwidth_cmd,
- "auto-cost reference-bandwidth <1-4294967>",
- "Calculate OSPF interface cost according to bandwidthn"
- "Use reference bandwidth method to assign OSPF costn"
- "The reference bandwidth in terms of Mbits per secondn")
- {
- struct ospf *ospf = vty->index;
- u_int32_t refbw;
- listnode node;
- refbw = strtol (argv[0], NULL, 10);
- if (refbw < 1 || refbw > 4294967)
- {
- vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- /* If reference bandwidth is changed. */
- if ((refbw * 1000) == ospf->ref_bandwidth)
- return CMD_SUCCESS;
-
- ospf->ref_bandwidth = refbw * 1000;
- vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
- vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
-
- for (node = listhead (om->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
-
- return CMD_SUCCESS;
- }
- DEFUN (no_ospf_auto_cost_reference_bandwidth,
- no_ospf_auto_cost_reference_bandwidth_cmd,
- "no auto-cost reference-bandwidth",
- NO_STR
- "Calculate OSPF interface cost according to bandwidthn"
- "Use reference bandwidth method to assign OSPF costn")
- {
- struct ospf *ospf = vty->index;
- listnode node;
- if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
- return CMD_SUCCESS;
-
- ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
- vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
- vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
- for (node = listhead (om->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
-
- return CMD_SUCCESS;
- }
- char *ospf_abr_type_descr_str[] =
- {
- "Unknown",
- "Standard (RFC2328)",
- "Alternative IBM",
- "Alternative Cisco",
- "Alternative Shortcut"
- };
- char *ospf_shortcut_mode_descr_str[] =
- {
- "Default",
- "Enabled",
- "Disabled"
- };
- void
- show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
- {
- /* Show Area ID. */
- vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
- /* Show Area type/mode. */
- if (OSPF_IS_AREA_BACKBONE (area))
- vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
- else
- {
- if (area->external_routing == OSPF_AREA_STUB)
- vty_out (vty, " (Stub%s%s)",
- area->no_summary ? ", no summary" : "",
- area->shortcut_configured ? "; " : "");
- #ifdef HAVE_NSSA
- else
- if (area->external_routing == OSPF_AREA_NSSA)
- vty_out (vty, " (NSSA%s%s)",
- area->no_summary ? ", no summary" : "",
- area->shortcut_configured ? "; " : "");
- #endif /* HAVE_NSSA */
- vty_out (vty, "%s", VTY_NEWLINE);
- vty_out (vty, " Shortcutting mode: %s",
- ospf_shortcut_mode_descr_str[area->shortcut_configured]);
- vty_out (vty, ", S-bit consensus: %s%s",
- area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
- }
- /* Show number of interfaces. */
- vty_out (vty, " Number of interfaces in this area: Total: %d, "
- "Active: %d%s", listcount (area->oiflist),
- area->act_ints, VTY_NEWLINE);
- #ifdef HAVE_NSSA
- if (area->external_routing == OSPF_AREA_NSSA)
- {
- vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
- if (! IS_OSPF_ABR (area->ospf))
- vty_out (vty, " It is not ABR, therefore not Translator. %s",
- VTY_NEWLINE);
- else
- {
- if (area->NSSATranslator)
- vty_out (vty, " We are an ABR and the NSSA Elected Translator. %s", VTY_NEWLINE);
- else
- vty_out (vty, " We are an ABR, but not the NSSA Elected Translator. %s", VTY_NEWLINE);
- }
- }
- #endif /* HAVE_NSSA */
- /* Show number of fully adjacent neighbors. */
- vty_out (vty, " Number of fully adjacent neighbors in this area:"
- " %d%s", area->full_nbrs, VTY_NEWLINE);
- /* Show authentication type. */
- vty_out (vty, " Area has ");
- if (area->auth_type == OSPF_AUTH_NULL)
- vty_out (vty, "no authentication%s", VTY_NEWLINE);
- else if (area->auth_type == OSPF_AUTH_SIMPLE)
- vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
- else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
- vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
- if (!OSPF_IS_AREA_BACKBONE (area))
- vty_out (vty, " Number of full virtual adjacencies going through"
- " this area: %d%s", area->full_vls, VTY_NEWLINE);
- /* Show SPF calculation times. */
- vty_out (vty, " SPF algorithm executed %d times%s",
- area->spf_calculation, VTY_NEWLINE);
- /* Show number of LSA. */
- vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- DEFUN (show_ip_ospf,
- show_ip_ospf_cmd,
- "show ip ospf",
- SHOW_STR
- IP_STR
- "OSPF informationn")
- {
- listnode node;
- struct ospf_area * area;
- struct ospf *ospf;
- /* Check OSPF is enable. */
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- /* Show Router ID. */
- vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
- inet_ntoa (ospf->router_id),
- VTY_NEWLINE);
- /* Show capability. */
- vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
- vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
- vty_out (vty, " RFC1583Compatibility flag is %s%s",
- CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
- "enabled" : "disabled", VTY_NEWLINE);
- #ifdef HAVE_OPAQUE_LSA
- vty_out (vty, " OpaqueCapability flag is %s%s%s",
- CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
- "enabled" : "disabled",
- IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
- " (origination blocked)" : "",
- VTY_NEWLINE);
- #endif /* HAVE_OPAQUE_LSA */
- /* Show SPF timers. */
- vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
- ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
- /* Show refresh parameters. */
- vty_out (vty, " Refresh timer %d secs%s",
- ospf->lsa_refresh_interval, VTY_NEWLINE);
-
- /* Show ABR/ASBR flags. */
- if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
- vty_out (vty, " This router is an ABR, ABR type is: %s%s",
- ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
- if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
- vty_out (vty, " This router is an ASBR "
- "(injecting external routing information)%s", VTY_NEWLINE);
- /* Show Number of AS-external-LSAs. */
- vty_out (vty, " Number of external LSA %ld%s",
- ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE);
- /* Show number of areas attached. */
- vty_out (vty, " Number of areas attached to this router: %d%s%s",
- listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
- /* Show each area status. */
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- show_ip_ospf_area (vty, area);
- return CMD_SUCCESS;
- }
- void
- show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
- struct interface *ifp)
- {
- struct ospf_neighbor *nbr;
- int oi_count;
- struct route_node *rn;
- char buf[9];
- oi_count = ospf_oi_count (ifp);
-
- /* Is interface up? */
- if (if_is_up (ifp))
- vty_out (vty, "%s is up, line protocol is up%s", ifp->name, VTY_NEWLINE);
- else
- {
- vty_out (vty, "%s is down, line protocol is down%s", ifp->name,
- VTY_NEWLINE);
-
- if (oi_count == 0)
- vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
- else
- vty_out (vty, " OSPF is enabled, but not running on this interface%s",
- VTY_NEWLINE);
- return;
- }
- /* Is interface OSPF enabled? */
- if (oi_count == 0)
- {
- vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
- return;
- }
-
- for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
- {
- struct ospf_interface *oi = rn->info;
-
- if (oi == NULL)
- continue;
-
- /* Show OSPF interface information. */
- vty_out (vty, " Internet Address %s/%d,",
- inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
- vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
- VTY_NEWLINE);
- vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
- inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
- oi->output_cost, VTY_NEWLINE);
- vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
- OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
- PRIORITY (oi), VTY_NEWLINE);
- /* Show DR information. */
- if (DR (oi).s_addr == 0)
- vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
- else
- {
- nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
- if (nbr == NULL)
- vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
- else
- {
- vty_out (vty, " Designated Router (ID) %s,",
- inet_ntoa (nbr->router_id));
- vty_out (vty, " Interface Address %s%s",
- inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
- }
- }
- /* Show BDR information. */
- if (BDR (oi).s_addr == 0)
- vty_out (vty, " No backup designated router on this network%s",
- VTY_NEWLINE);
- else
- {
- nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
- if (nbr == NULL)
- vty_out (vty, " No backup designated router on this network%s",
- VTY_NEWLINE);
- else
- {
- vty_out (vty, " Backup Designated Router (ID) %s,",
- inet_ntoa (nbr->router_id));
- vty_out (vty, " Interface Address %s%s",
- inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
- }
- }
- vty_out (vty, " Timer intervals configured,");
- vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
- OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
- OSPF_IF_PARAM (oi, v_wait),
- OSPF_IF_PARAM (oi, retransmit_interval),
- VTY_NEWLINE);
-
- if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
- vty_out (vty, " Hello due in %s%s",
- ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
- else /* OSPF_IF_PASSIVE is set */
- vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
-
- vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
- ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
- VTY_NEWLINE);
- }
- }
- DEFUN (show_ip_ospf_interface,
- show_ip_ospf_interface_cmd,
- "show ip ospf interface [INTERFACE]",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Interface informationn"
- "Interface namen")
- {
- struct interface *ifp;
- struct ospf *ospf;
- listnode node;
- ospf = ospf_lookup ();
- /* Show All Interfaces. */
- if (argc == 0)
- for (node = listhead (iflist); node; nextnode (node))
- show_ip_ospf_interface_sub (vty, ospf, node->data);
- /* Interface name is specified. */
- else
- {
- if ((ifp = if_lookup_by_name (argv[0])) == NULL)
- vty_out (vty, "No such interface name%s", VTY_NEWLINE);
- else
- show_ip_ospf_interface_sub (vty, ospf, ifp);
- }
- return CMD_SUCCESS;
- }
- void
- show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
- {
- struct route_node *rn;
- struct ospf_neighbor *nbr;
- char msgbuf[16];
- char timebuf[9];
- for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
- if ((nbr = rn->info))
- /* Do not show myself. */
- if (nbr != oi->nbr_self)
- /* Down state is not shown. */
- if (nbr->state != NSM_Down)
- {
- ospf_nbr_state_message (nbr, msgbuf, 16);
- if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
- vty_out (vty, "%-15s %3d %-15s %8s ",
- "-", nbr->priority,
- msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
- else
- vty_out (vty, "%-15s %3d %-15s %8s ",
- inet_ntoa (nbr->router_id), nbr->priority,
- msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
- vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
- vty_out (vty, "%-15s %5ld %5ld %5d%s",
- IF_NAME (oi), ospf_ls_retransmit_count (nbr),
- ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
- VTY_NEWLINE);
- }
- }
- DEFUN (show_ip_ospf_neighbor,
- show_ip_ospf_neighbor_cmd,
- "show ip ospf neighbor",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Neighbor listn")
- {
- struct ospf *ospf;
- listnode node;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- /* Show All neighbors. */
- vty_out (vty, "%sNeighbor ID Pri State Dead "
- "Time Address Interface RXmtL "
- "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- show_ip_ospf_neighbor_sub (vty, getdata (node));
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_ospf_neighbor_all,
- show_ip_ospf_neighbor_all_cmd,
- "show ip ospf neighbor all",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Neighbor listn"
- "include down status neighborn")
- {
- struct ospf *ospf = vty->index;
- listnode node;
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- /* Show All neighbors. */
- vty_out (vty, "%sNeighbor ID Pri State Dead "
- "Time Address Interface RXmtL "
- "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
- listnode nbr_node;
- show_ip_ospf_neighbor_sub (vty, oi);
- /* print Down neighbor status */
- for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
- {
- struct ospf_nbr_nbma *nbr_nbma;
- nbr_nbma = getdata (nbr_node);
- if (nbr_nbma->nbr == NULL
- || nbr_nbma->nbr->state == NSM_Down)
- {
- vty_out (vty, "%-15s %3d %-15s %8s ",
- "-", nbr_nbma->priority, "Down", "-");
- vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
- inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
- 0, 0, 0, VTY_NEWLINE);
- }
- }
- }
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_ospf_neighbor_int,
- show_ip_ospf_neighbor_int_cmd,
- "show ip ospf neighbor A.B.C.D",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Neighbor listn"
- "Interface namen")
- {
- struct ospf *ospf;
- struct ospf_interface *oi;
- struct in_addr addr;
- int ret;
-
- ret = inet_aton (argv[0], &addr);
- if (!ret)
- {
- vty_out (vty, "Please specify interface address by A.B.C.D%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
- vty_out (vty, "No such interface address%s", VTY_NEWLINE);
- else
- {
- vty_out (vty, "%sNeighbor ID Pri State Dead "
- "Time Address Interface RXmtL "
- "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- show_ip_ospf_neighbor_sub (vty, oi);
- }
- return CMD_SUCCESS;
- }
- void
- show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
- struct ospf_nbr_nbma *nbr_nbma)
- {
- char timebuf[9];
- /* Show neighbor ID. */
- vty_out (vty, " Neighbor %s,", "-");
- /* Show interface address. */
- vty_out (vty, " interface address %s%s",
- inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
- /* Show Area ID. */
- vty_out (vty, " In the area %s via interface %s%s",
- ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
- /* Show neighbor priority and state. */
- vty_out (vty, " Neighbor priority is %d, State is %s,",
- nbr_nbma->priority, "Down");
- /* Show state changes. */
- vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
- /* Show PollInterval */
- vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
- /* Show poll-interval timer. */
- vty_out (vty, " Poll timer due in %s%s",
- ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
- /* Show poll-interval timer thread. */
- vty_out (vty, " Thread Poll Timer %s%s",
- nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
- }
- void
- show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
- struct ospf_neighbor *nbr)
- {
- char timebuf[9];
- /* Show neighbor ID. */
- if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
- vty_out (vty, " Neighbor %s,", "-");
- else
- vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
- /* Show interface address. */
- vty_out (vty, " interface address %s%s",
- inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
- /* Show Area ID. */
- vty_out (vty, " In the area %s via interface %s%s",
- ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
- /* Show neighbor priority and state. */
- vty_out (vty, " Neighbor priority is %d, State is %s,",
- nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
- /* Show state changes. */
- vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
- /* Show Designated Rotuer ID. */
- vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
- /* Show Backup Designated Rotuer ID. */
- vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
- /* Show options. */
- vty_out (vty, " Options %d %s%s", nbr->options,
- ospf_options_dump (nbr->options), VTY_NEWLINE);
- /* Show Router Dead interval timer. */
- vty_out (vty, " Dead timer due in %s%s",
- ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
- /* Show Database Summary list. */
- vty_out (vty, " Database Summary List %d%s",
- ospf_db_summary_count (nbr), VTY_NEWLINE);
- /* Show Link State Request list. */
- vty_out (vty, " Link State Request List %ld%s",
- ospf_ls_request_count (nbr), VTY_NEWLINE);
- /* Show Link State Retransmission list. */
- vty_out (vty, " Link State Retransmission List %ld%s",
- ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
- /* Show inactivity timer thread. */
- vty_out (vty, " Thread Inactivity Timer %s%s",
- nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
- /* Show Database Description retransmission thread. */
- vty_out (vty, " Thread Database Description Retransmision %s%s",
- nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
- /* Show Link State Request Retransmission thread. */
- vty_out (vty, " Thread Link State Request Retransmission %s%s",
- nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
- /* Show Link State Update Retransmission thread. */
- vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
- nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
- }
- DEFUN (show_ip_ospf_neighbor_id,
- show_ip_ospf_neighbor_id_cmd,
- "show ip ospf neighbor A.B.C.D",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Neighbor listn"
- "Neighbor IDn")
- {
- struct ospf *ospf;
- listnode node;
- struct ospf_neighbor *nbr;
- struct in_addr router_id;
- int ret;
- ret = inet_aton (argv[0], &router_id);
- if (!ret)
- {
- vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
- if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
- {
- show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
- return CMD_SUCCESS;
- }
- }
- /* Nothing to show. */
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_ospf_neighbor_detail,
- show_ip_ospf_neighbor_detail_cmd,
- "show ip ospf neighbor detail",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Neighbor listn"
- "detail of all neighborsn")
- {
- struct ospf *ospf;
- listnode node;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
- struct route_node *rn;
- struct ospf_neighbor *nbr;
- for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
- if ((nbr = rn->info))
- if (nbr != oi->nbr_self)
- if (nbr->state != NSM_Down)
- show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
- }
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_ospf_neighbor_detail_all,
- show_ip_ospf_neighbor_detail_all_cmd,
- "show ip ospf neighbor detail all",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Neighbor listn"
- "detail of all neighborsn"
- "include down status neighborn")
- {
- struct ospf *ospf;
- listnode node;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
- struct route_node *rn;
- struct ospf_neighbor *nbr;
- for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
- if ((nbr = rn->info))
- if (nbr != oi->nbr_self)
- if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
- show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
- if (oi->type == OSPF_IFTYPE_NBMA)
- {
- listnode nd;
- for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
- {
- struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
- if (nbr_nbma->nbr == NULL
- || nbr_nbma->nbr->state == NSM_Down)
- show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
- }
- }
- }
- return CMD_SUCCESS;
- }
- DEFUN (show_ip_ospf_neighbor_int_detail,
- show_ip_ospf_neighbor_int_detail_cmd,
- "show ip ospf neighbor A.B.C.D detail",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Neighbor listn"
- "Interface addressn"
- "detail of all neighbors")
- {
- struct ospf *ospf;
- struct ospf_interface *oi;
- struct in_addr addr;
- int ret;
-
- ret = inet_aton (argv[0], &addr);
- if (!ret)
- {
- vty_out (vty, "Please specify interface address by A.B.C.D%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
- if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
- vty_out (vty, "No such interface address%s", VTY_NEWLINE);
- else
- {
- struct route_node *rn;
- struct ospf_neighbor *nbr;
- for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
- if ((nbr = rn->info))
- if (nbr != oi->nbr_self)
- if (nbr->state != NSM_Down)
- show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
- }
- return CMD_SUCCESS;
- }
- /* Show functions */
- int
- show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
- {
- struct router_lsa *rl;
- struct summary_lsa *sl;
- struct as_external_lsa *asel;
- struct prefix_ipv4 p;
- if (lsa != NULL)
- /* If self option is set, check LSA self flag. */
- if (self == 0 || IS_LSA_SELF (lsa))
- {
- /* LSA common part show. */
- vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
- vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
- inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
- (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
- /* LSA specific part show. */
- switch (lsa->data->type)
- {
- case OSPF_ROUTER_LSA:
- rl = (struct router_lsa *) lsa->data;
- vty_out (vty, " %-d", ntohs (rl->links));
- break;
- case OSPF_SUMMARY_LSA:
- sl = (struct summary_lsa *) lsa->data;
- p.family = AF_INET;
- p.prefix = sl->header.id;
- p.prefixlen = ip_masklen (sl->mask);
- apply_mask_ipv4 (&p);
- vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
- break;
- case OSPF_AS_EXTERNAL_LSA:
- #ifdef HAVE_NSSA
- case OSPF_AS_NSSA_LSA:
- #endif /* HAVE_NSSA */
- asel = (struct as_external_lsa *) lsa->data;
- p.family = AF_INET;
- p.prefix = asel->header.id;
- p.prefixlen = ip_masklen (asel->mask);
- apply_mask_ipv4 (&p);
- vty_out (vty, " %s %s/%d [0x%lx]",
- IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
- inet_ntoa (p.prefix), p.prefixlen,
- (u_long)ntohl (asel->e[0].route_tag));
- break;
- case OSPF_NETWORK_LSA:
- case OSPF_ASBR_SUMMARY_LSA:
- #ifdef HAVE_OPAQUE_LSA
- case OSPF_OPAQUE_LINK_LSA:
- case OSPF_OPAQUE_AREA_LSA:
- case OSPF_OPAQUE_AS_LSA:
- #endif /* HAVE_OPAQUE_LSA */
- default:
- break;
- }
- vty_out (vty, VTY_NEWLINE);
- }
- return 0;
- }
- char *show_database_desc[] =
- {
- "unknown",
- "Router Link States",
- "Net Link States",
- "Summary Link States",
- "ASBR-Summary Link States",
- "AS External Link States",
- #if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA)
- "Group Membership LSA",
- "NSSA-external Link States",
- #endif /* HAVE_NSSA */
- #ifdef HAVE_OPAQUE_LSA
- "Type-8 LSA",
- "Link-Local Opaque-LSA",
- "Area-Local Opaque-LSA",
- "AS-external Opaque-LSA",
- #endif /* HAVE_OPAQUE_LSA */
- };
- #define SHOW_OSPF_COMMON_HEADER
- "Link ID ADV Router Age Seq# CkSum"
- char *show_database_header[] =
- {
- "",
- "Link ID ADV Router Age Seq# CkSum Link count",
- "Link ID ADV Router Age Seq# CkSum",
- "Link ID ADV Router Age Seq# CkSum Route",
- "Link ID ADV Router Age Seq# CkSum",
- "Link ID ADV Router Age Seq# CkSum Route",
- #ifdef HAVE_NSSA
- " --- header for Group Member ----",
- "Link ID ADV Router Age Seq# CkSum Route",
- #endif /* HAVE_NSSA */
- #ifdef HAVE_OPAQUE_LSA
- #ifndef HAVE_NSSA
- " --- type-6 ---",
- " --- type-7 ---",
- #endif /* HAVE_NSSA */
- " --- type-8 ---",
- "Opaque-Type/Id ADV Router Age Seq# CkSum",
- "Opaque-Type/Id ADV Router Age Seq# CkSum",
- "Opaque-Type/Id ADV Router Age Seq# CkSum",
- #endif /* HAVE_OPAQUE_LSA */
- };
- void
- show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
- {
- struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
- vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
- vty_out (vty, " Options: %d%s", lsa->data->options, VTY_NEWLINE);
- if (lsa->data->type == OSPF_ROUTER_LSA)
- {
- vty_out (vty, " Flags: 0x%x" , rlsa->flags);
- if (rlsa->flags)
- vty_out (vty, " :%s%s%s%s",
- IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
- IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
- IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
- IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- vty_out (vty, " LS Type: %s%s",
- LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
- vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
- LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
- vty_out (vty, " Advertising Router: %s%s",
- inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
- vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
- VTY_NEWLINE);
- vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
- VTY_NEWLINE);
- vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
- }
- char *link_type_desc[] =
- {
- "(null)",
- "another Router (point-to-point)",
- "a Transit Network",
- "Stub Network",
- "a Virtual Link",
- };
- char *link_id_desc[] =
- {
- "(null)",
- "Neighboring Router ID",
- "Designated Router address",
- "Net",
- "Neighboring Router ID",
- };
- char *link_data_desc[] =
- {
- "(null)",
- "Router Interface address",
- "Router Interface address",
- "Network Mask",
- "Router Interface address",
- };
- /* Show router-LSA each Link information. */
- void
- show_ip_ospf_database_router_links (struct vty *vty,
- struct router_lsa *rl)
- {
- int len, i, type;
- len = ntohs (rl->header.length) - 4;
- for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
- {
- type = rl->link[i].type;
- vty_out (vty, " Link connected to: %s%s",
- link_type_desc[type], VTY_NEWLINE);
- vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
- inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
- vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
- inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
- vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
- vty_out (vty, " TOS 0 Metric: %d%s",
- ntohs (rl->link[i].metric), VTY_NEWLINE);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- }
- /* Show router-LSA detail information. */
- int
- show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
- {
- if (lsa != NULL)
- {
- struct router_lsa *rl = (struct router_lsa *) lsa->data;
- show_ip_ospf_database_header (vty, lsa);
-
- vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
- VTY_NEWLINE, VTY_NEWLINE);
- show_ip_ospf_database_router_links (vty, rl);
- }
- return 0;
- }
- /* Show network-LSA detail information. */
- int
- show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
- {
- int length, i;
- if (lsa != NULL)
- {
- struct network_lsa *nl = (struct network_lsa *) lsa->data;
- show_ip_ospf_database_header (vty, lsa);
- vty_out (vty, " Network Mask: /%d%s",
- ip_masklen (nl->mask), VTY_NEWLINE);
- length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
- for (i = 0; length > 0; i++, length -= 4)
- vty_out (vty, " Attached Router: %s%s",
- inet_ntoa (nl->routers[i]), VTY_NEWLINE);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- return 0;
- }
- /* Show summary-LSA detail information. */
- int
- show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
- {
- if (lsa != NULL)
- {
- struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
- show_ip_ospf_database_header (vty, lsa);
- vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
- VTY_NEWLINE);
- vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
- VTY_NEWLINE);
- }
- return 0;
- }
- /* Show summary-ASBR-LSA detail information. */
- int
- show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
- {
- if (lsa != NULL)
- {
- struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
- show_ip_ospf_database_header (vty, lsa);
- vty_out (vty, " Network Mask: /%d%s",
- ip_masklen (sl->mask), VTY_NEWLINE);
- vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
- VTY_NEWLINE);
- }
- return 0;
- }
- /* Show AS-external-LSA detail information. */
- int
- show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
- {
- if (lsa != NULL)
- {
- struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
- show_ip_ospf_database_header (vty, lsa);
- vty_out (vty, " Network Mask: /%d%s",
- ip_masklen (al->mask), VTY_NEWLINE);
- vty_out (vty, " Metric Type: %s%s",
- IS_EXTERNAL_METRIC (al->e[0].tos) ?
- "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
- vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
- vty_out (vty, " Metric: %d%s",
- GET_METRIC (al->e[0].metric), VTY_NEWLINE);
- vty_out (vty, " Forward Address: %s%s",
- inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
- vty_out (vty, " External Route Tag: %lu%s%s",
- (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
- }
- return 0;
- }
- #ifdef HAVE_NSSA
- int
- show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
- {
- struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
- /* show_ip_ospf_database_header (vty, lsa); */
- zlog_info( " Network Mask: /%d%s",
- ip_masklen (al->mask), "n");
- zlog_info( " Metric Type: %s%s",
- IS_EXTERNAL_METRIC (al->e[0].tos) ?
- "2 (Larger than any link state path)" : "1", "n");
- zlog_info( " TOS: 0%s", "n");
- zlog_info( " Metric: %d%s",
- GET_METRIC (al->e[0].metric), "n");
- zlog_info( " Forward Address: %s%s",
- inet_ntoa (al->e[0].fwd_addr), "n");
- zlog_info( " External Route Tag: %u%s%s",
- ntohl (al->e[0].route_tag), "n", "n");
- return 0;
- }
- /* Show AS-NSSA-LSA detail information. */
- int
- show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
- {
- if (lsa != NULL)
- {
- struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
- show_ip_ospf_database_header (vty, lsa);
- vty_out (vty, " Network Mask: /%d%s",
- ip_masklen (al->mask), VTY_NEWLINE);
- vty_out (vty, " Metric Type: %s%s",
- IS_EXTERNAL_METRIC (al->e[0].tos) ?
- "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
- vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
- vty_out (vty, " Metric: %d%s",
- GET_METRIC (al->e[0].metric), VTY_NEWLINE);
- vty_out (vty, " NSSA: Forward Address: %s%s",
- inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
- vty_out (vty, " External Route Tag: %u%s%s",
- ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
- }
- return 0;
- }
- #endif /* HAVE_NSSA */
- int
- show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
- {
- return 0;
- }
- #ifdef HAVE_OPAQUE_LSA
- int
- show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
- {
- if (lsa != NULL)
- {
- show_ip_ospf_database_header (vty, lsa);
- show_opaque_info_detail (vty, lsa);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- return 0;
- }
- #endif /* HAVE_OPAQUE_LSA */
- int (*show_function[])(struct vty *, struct ospf_lsa *) =
- {
- NULL,
- show_router_lsa_detail,
- show_network_lsa_detail,
- show_summary_lsa_detail,
- show_summary_asbr_lsa_detail,
- show_as_external_lsa_detail,
- #ifdef HAVE_NSSA
- show_func_dummy,
- show_as_nssa_lsa_detail, /* almost same as external */
- #endif /* HAVE_NSSA */
- #ifdef HAVE_OPAQUE_LSA
- #ifndef HAVE_NSSA
- show_func_dummy,
- show_func_dummy,
- #endif /* HAVE_NSSA */
- NULL, /* type-8 */
- show_opaque_lsa_detail,
- show_opaque_lsa_detail,
- show_opaque_lsa_detail,
- #endif /* HAVE_OPAQUE_LSA */
- };
- void
- show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
- struct in_addr *adv_router)
- {
- memset (lp, 0, sizeof (struct prefix_ls));
- lp->family = 0;
- if (id == NULL)
- lp->prefixlen = 0;
- else if (adv_router == NULL)
- {
- lp->prefixlen = 32;
- lp->id = *id;
- }
- else
- {
- lp->prefixlen = 64;
- lp->id = *id;
- lp->adv_router = *adv_router;
- }
- }
- void
- show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
- struct in_addr *id, struct in_addr *adv_router)
- {
- struct prefix_ls lp;
- struct route_node *rn, *start;
- struct ospf_lsa *lsa;
- show_lsa_prefix_set (vty, &lp, id, adv_router);
- start = route_node_get (rt, (struct prefix *) &lp);
- if (start)
- {
- route_lock_node (start);
- for (rn = start; rn; rn = route_next_until (rn, start))
- if ((lsa = rn->info))
- {
- #ifdef HAVE_NSSA
- /* Stay away from any Local Translated Type-7 LSAs */
- if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
- continue;
- #endif /* HAVE_NSSA */
- if (show_function[lsa->data->type] != NULL)
- show_function[lsa->data->type] (vty, lsa);
- }
- route_unlock_node (start);
- }
- }
- /* Show detail LSA information
- -- if id is NULL then show all LSAs. */
- void
- show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
- struct in_addr *id, struct in_addr *adv_router)
- {
- listnode node;
- switch (type)
- {
- case OSPF_AS_EXTERNAL_LSA:
- #ifdef HAVE_OPAQUE_LSA
- case OSPF_OPAQUE_AS_LSA:
- #endif /* HAVE_OPAQUE_LSA */
- vty_out (vty, " %s %s%s",
- show_database_desc[type],
- VTY_NEWLINE, VTY_NEWLINE);
- show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
- break;
- default:
- for (node = listhead (ospf->areas); node; nextnode (node))
- {
- struct ospf_area *area = node->data;
- vty_out (vty, "%s %s (Area %s)%s%s",
- VTY_NEWLINE, show_database_desc[type],
- ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
- show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
- }
- break;
- }
- }
- void
- show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
- struct in_addr *adv_router)
- {
- struct route_node *rn;
- struct ospf_lsa *lsa;
- for (rn = route_top (rt); rn; rn = route_next (rn))
- if ((lsa = rn->info))
- if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
- {
- #ifdef HAVE_NSSA
- if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
- continue;
- #endif /* HAVE_NSSA */
- if (show_function[lsa->data->type] != NULL)
- show_function[lsa->data->type] (vty, lsa);
- }
- }
- /* Show detail LSA information. */
- void
- show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
- struct in_addr *adv_router)
- {
- listnode node;
- switch (type)
- {
- case OSPF_AS_EXTERNAL_LSA:
- #ifdef HAVE_OPAQUE_LSA
- case OSPF_OPAQUE_AS_LSA:
- #endif /* HAVE_OPAQUE_LSA */
- vty_out (vty, " %s %s%s",
- show_database_desc[type],
- VTY_NEWLINE, VTY_NEWLINE);
- show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
- adv_router);
- break;
- default:
- for (node = listhead (ospf->areas); node; nextnode (node))
- {
- struct ospf_area *area = node->data;
- vty_out (vty, "%s %s (Area %s)%s%s",
- VTY_NEWLINE, show_database_desc[type],
- ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
- show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
- adv_router);
- }
- break;
- }
- }
- void
- show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
- {
- struct ospf_lsa *lsa;
- struct route_node *rn;
- listnode node;
- int type;
- for (node = listhead (ospf->areas); node; nextnode (node))
- {
- struct ospf_area *area = node->data;
- for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
- {
- switch (type)
- {
- case OSPF_AS_EXTERNAL_LSA:
- #ifdef HAVE_OPAQUE_LSA
- case OSPF_OPAQUE_AS_LSA:
- #endif /* HAVE_OPAQUE_LSA */
- continue;
- default:
- break;
- }
- if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
- (!self && ospf_lsdb_count (area->lsdb, type) > 0))
- {
- vty_out (vty, " %s (Area %s)%s%s",
- show_database_desc[type],
- ospf_area_desc_string (area),
- VTY_NEWLINE, VTY_NEWLINE);
- vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
- LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
- show_lsa_summary (vty, lsa, self);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- }
- }
- for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
- {
- switch (type)
- {
- case OSPF_AS_EXTERNAL_LSA:
- #ifdef HAVE_OPAQUE_LSA
- case OSPF_OPAQUE_AS_LSA:
- #endif /* HAVE_OPAQUE_LSA */
- break;;
- default:
- continue;
- }
- if (ospf_lsdb_count_self (ospf->lsdb, type) ||
- (!self && ospf_lsdb_count (ospf->lsdb, type)))
- {
- vty_out (vty, " %s%s%s",
- show_database_desc[type],
- VTY_NEWLINE, VTY_NEWLINE);
- vty_out (vty, "%s%s", show_database_header[type],
- VTY_NEWLINE);
- LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
- show_lsa_summary (vty, lsa, self);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- }
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- void
- show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
- {
- listnode node;
- struct ospf_lsa *lsa;
- vty_out (vty, "%s MaxAge Link States:%s%s",
- VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
- if ((lsa = node->data) != NULL)
- {
- vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
- vty_out (vty, "Link State ID: %s%s",
- inet_ntoa (lsa->data->id), VTY_NEWLINE);
- vty_out (vty, "Advertising Router: %s%s",
- inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
- vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
- }
- #ifdef HAVE_NSSA
- #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link staten"
- #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
- #else /* HAVE_NSSA */
- #define OSPF_LSA_TYPE_NSSA_DESC ""
- #define OSPF_LSA_TYPE_NSSA_CMD_STR ""
- #endif /* HAVE_NSSA */
- #ifdef HAVE_OPAQUE_LSA
- #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSAn"
- #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSAn"
- #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSAn"
- #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
- #else /* HAVE_OPAQUE_LSA */
- #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
- #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
- #define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
- #define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
- #endif /* HAVE_OPAQUE_LSA */
- #define OSPF_LSA_TYPES_CMD_STR
- "asbr-summary|external|network|router|summary"
- OSPF_LSA_TYPE_NSSA_CMD_STR
- OSPF_LSA_TYPE_OPAQUE_CMD_STR
- #define OSPF_LSA_TYPES_DESC
- "ASBR summary link statesn"
- "External link statesn"
- "Network link statesn"
- "Router link statesn"
- "Network summary link statesn"
- OSPF_LSA_TYPE_NSSA_DESC
- OSPF_LSA_TYPE_OPAQUE_LINK_DESC
- OSPF_LSA_TYPE_OPAQUE_AREA_DESC
- OSPF_LSA_TYPE_OPAQUE_AS_DESC
- DEFUN (show_ip_ospf_database,
- show_ip_ospf_database_cmd,
- "show ip ospf database",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Database summaryn")
- {
- struct ospf *ospf;
- int type, ret;
- struct in_addr id, adv_router;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- return CMD_SUCCESS;
- vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
- inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
- /* Show all LSA. */
- if (argc == 0)
- {
- show_ip_ospf_database_summary (vty, ospf, 0);
- return CMD_SUCCESS;
- }
- /* Set database type to show. */
- if (strncmp (argv[0], "r", 1) == 0)
- type = OSPF_ROUTER_LSA;
- else if (strncmp (argv[0], "ne", 2) == 0)
- type = OSPF_NETWORK_LSA;
- #ifdef HAVE_NSSA
- else if (strncmp (argv[0], "ns", 2) == 0)
- type = OSPF_AS_NSSA_LSA;
- #endif /* HAVE_NSSA */
- else if (strncmp (argv[0], "su", 2) == 0)
- type = OSPF_SUMMARY_LSA;
- else if (strncmp (argv[0], "a", 1) == 0)
- type = OSPF_ASBR_SUMMARY_LSA;
- else if (strncmp (argv[0], "e", 1) == 0)
- type = OSPF_AS_EXTERNAL_LSA;
- else if (strncmp (argv[0], "se", 2) == 0)
- {
- show_ip_ospf_database_summary (vty, ospf, 1);
- return CMD_SUCCESS;
- }
- else if (strncmp (argv[0], "m", 1) == 0)
- {
- show_ip_ospf_database_maxage (vty, ospf);
- return CMD_SUCCESS;
- }
- #ifdef HAVE_OPAQUE_LSA
- else if (strncmp (argv[0], "opaque-l", 8) == 0)
- type = OSPF_OPAQUE_LINK_LSA;
- else if (strncmp (argv[0], "opaque-ar", 9) == 0)
- type = OSPF_OPAQUE_AREA_LSA;
- else if (strncmp (argv[0], "opaque-as", 9) == 0)
- type = OSPF_OPAQUE_AS_LSA;
- #endif /* HAVE_OPAQUE_LSA */
- else
- return CMD_WARNING;
- /* `show ip ospf database LSA'. */
- if (argc == 1)
- show_lsa_detail (vty, ospf, type, NULL, NULL);
- else if (argc >= 2)
- {
- ret = inet_aton (argv[1], &id);
- if (!ret)
- return CMD_WARNING;
-
- /* `show ip ospf database LSA ID'. */
- if (argc == 2)
- show_lsa_detail (vty, ospf, type, &id, NULL);
- /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
- else if (argc == 3)
- {
- if (strncmp (argv[2], "s", 1) == 0)
- adv_router = ospf->router_id;
- else
- {
- ret = inet_aton (argv[2], &adv_router);
- if (!ret)
- return CMD_WARNING;
- }
- show_lsa_detail (vty, ospf, type, &id, &adv_router);
- }
- }
- return CMD_SUCCESS;
- }
- ALIAS (show_ip_ospf_database,
- show_ip_ospf_database_type_cmd,
- "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Database summaryn"
- OSPF_LSA_TYPES_DESC
- "LSAs in MaxAge listn"
- "Self-originated link statesn");
- ALIAS (show_ip_ospf_database,
- show_ip_ospf_database_type_id_cmd,
- "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
- SHOW_STR
- IP_STR
- "OSPF informationn"
- "Database summaryn"
- OSPF_LSA_TYPES_DESC
- "Link State ID (as an IP address)n");
- ALIAS (show_ip_ospf_database,
- show_ip_ospf_database_type_id_adv_router_cmd,
- "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",