--- embedaddon/quagga/ospfd/ospf_vty.c 2013/07/21 23:54:40 1.1.1.3 +++ embedaddon/quagga/ospfd/ospf_vty.c 2016/11/02 10:09:12 1.1.1.4 @@ -49,7 +49,7 @@ #include "ospfd/ospf_vty.h" #include "ospfd/ospf_dump.h" - + static const char *ospf_network_type_str[] = { "Null", @@ -61,7 +61,7 @@ static const char *ospf_network_type_str[] = "LOOPBACK" }; - + /* Utility functions. */ static int ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) @@ -94,7 +94,7 @@ ospf_str2area_id (const char *str, struct in_addr *are return 0; } - + static int str2metric (const char *str, int *metric) { @@ -142,7 +142,7 @@ ospf_oi_count (struct interface *ifp) return i; } - + DEFUN (router_ospf, router_ospf_cmd, "router ospf", @@ -254,9 +254,9 @@ ospf_passive_interface_default (struct ospf *ospf, u_c } static void -ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, - struct in_addr addr, - struct ospf_if_params *params, u_char value) +ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, + struct ospf_if_params *params, u_char value, + struct in_addr addr) { u_char dflt; @@ -276,7 +276,14 @@ ospf_passive_interface_update (struct ospf *ospf, stru ospf_free_if_params (ifp, addr); ospf_if_update_params (ifp, addr); } - else +} + +static void +ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, + struct ospf_if_params *params, u_char value) +{ + params->passive_interface = value; + if (params == IF_DEF_PARAMS (ifp)) { if (value != ospf->passive_interface_default) SET_IF_PARAM (params, passive_interface); @@ -285,6 +292,41 @@ ospf_passive_interface_update (struct ospf *ospf, stru } } +/* get the appropriate ospf parameters structure, checking if + * there's a valid interface address at the argi'th argv index + */ +enum { + VTY_SET = 0, + VTY_UNSET, +}; +#define OSPF_VTY_GET_IF_PARAMS(ifp,params,argi,addr,set) \ + (params) = IF_DEF_PARAMS ((ifp)); \ + \ + if (argc == (argi) + 1) \ + { \ + int ret = inet_aton(argv[(argi)], &(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)); \ + \ + if (set) \ + ospf_if_update_params ((ifp), (addr)); \ + else if ((params) == NULL) \ + return CMD_SUCCESS; \ + } + +#define OSPF_VTY_PARAM_UNSET(params,var,ifp,addr) \ + UNSET_IF_PARAM ((params), var); \ + if ((params) != IF_DEF_PARAMS ((ifp))) \ + { \ + ospf_free_if_params ((ifp), (addr)); \ + ospf_if_update_params ((ifp), (addr)); \ + } + DEFUN (ospf_passive_interface, ospf_passive_interface_addr_cmd, "passive-interface IFNAME A.B.C.D", @@ -320,8 +362,11 @@ DEFUN (ospf_passive_interface, params = ospf_get_if_params (ifp, addr); ospf_if_update_params (ifp, addr); + ospf_passive_interface_update_addr (ospf, ifp, params, + OSPF_IF_PASSIVE, addr); } - ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); + + ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); /* XXX We should call ospf_if_set_multicast on exactly those * interfaces for which the passive property changed. It is too much @@ -397,9 +442,11 @@ DEFUN (no_ospf_passive_interface, params = ospf_lookup_if_params (ifp, addr); if (params == NULL) return CMD_SUCCESS; + ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, + addr); } - ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); - + ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); + /* XXX We should call ospf_if_set_multicast on exactly those * interfaces for which the passive property changed. It is too much * work to determine this set, so we do this for every interface. @@ -441,7 +488,7 @@ DEFUN (ospf_network_area, "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { - struct ospf *ospf= vty->index; + struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; int ret, format; @@ -490,7 +537,7 @@ DEFUN (no_ospf_network_area, return CMD_SUCCESS; } - + DEFUN (ospf_area_range, ospf_area_range_cmd, "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", @@ -634,7 +681,7 @@ ALIAS (no_ospf_area_range, "Advertise this range (default)\n" "User specified metric for this range\n" "Advertised metric for this range\n") - + 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", @@ -686,7 +733,7 @@ DEFUN (no_ospf_area_range_substitute, return CMD_SUCCESS; } - + /* Command Handler Logic in VLink stuff is delicate!! ALTER AT YOUR OWN RISK!!!! @@ -771,7 +818,7 @@ ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_c { vl_data->vl_oi = ospf_vl_new (ospf, vl_data); ospf_vl_add (ospf, vl_data); - ospf_spf_calculate_schedule (ospf); + ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); } } return vl_data; @@ -1382,7 +1429,7 @@ ALIAS (no_ospf_area_vlink, 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)", @@ -1450,7 +1497,7 @@ DEFUN (no_ospf_area_shortcut, return CMD_SUCCESS; } - + DEFUN (ospf_area_stub, ospf_area_stub_cmd, "area (A.B.C.D|<0-4294967295>) stub", @@ -1971,11 +2018,13 @@ DEFUN (no_ospf_area_filter_list, 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 parameters\n" + "OSPF area ID in IP address format\n" + "OSPF area ID as a decimal value\n" "Enable authentication\n" "Use message-digest authentication\n") { @@ -2040,7 +2089,7 @@ DEFUN (no_ospf_area_authentication, return CMD_SUCCESS; } - + DEFUN (ospf_abr_type, ospf_abr_type_cmd, "ospf abr-type (cisco|ibm|shortcut|standard)", @@ -2170,7 +2219,7 @@ DEFUN (ospf_compatible_rfc1583, if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) { SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); - ospf_spf_calculate_schedule (ospf); + ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); } return CMD_SUCCESS; } @@ -2187,7 +2236,7 @@ DEFUN (no_ospf_compatible_rfc1583, if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) { UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); - ospf_spf_calculate_schedule (ospf); + ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); } return CMD_SUCCESS; } @@ -2204,7 +2253,7 @@ ALIAS (no_ospf_compatible_rfc1583, NO_STR "OSPF specific commands\n" "Disable the RFC1583Compatibility flag\n") - + static int ospf_timers_spf_set (struct vty *vty, unsigned int delay, unsigned int hold, @@ -2219,6 +2268,83 @@ ospf_timers_spf_set (struct vty *vty, unsigned int del return CMD_SUCCESS; } +DEFUN (ospf_timers_min_ls_interval, + ospf_timers_min_ls_interval_cmd, + "timers throttle lsa all <0-5000>", + "Adjust routing timers\n" + "Throttling adaptive timer\n" + "LSA delay between transmissions\n" + NO_STR + "Delay (msec) between sending LSAs\n") +{ + struct ospf *ospf = vty->index; + unsigned int interval; + + if (argc != 1) + { + vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); + return CMD_WARNING; + } + + VTY_GET_INTEGER ("LSA interval", interval, argv[0]); + + ospf->min_ls_interval = interval; + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_timers_min_ls_interval, + no_ospf_timers_min_ls_interval_cmd, + "no timers throttle lsa all", + NO_STR + "Adjust routing timers\n" + "Throttling adaptive timer\n" + "LSA delay between transmissions\n") +{ + struct ospf *ospf = vty->index; + ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; + + return CMD_SUCCESS; +} + +DEFUN (ospf_timers_min_ls_arrival, + ospf_timers_min_ls_arrival_cmd, + "timers lsa arrival <0-1000>", + "Adjust routing timers\n" + "Throttling link state advertisement delays\n" + "OSPF minimum arrival interval delay\n" + "Delay (msec) between accepted LSAs\n") +{ + struct ospf *ospf = vty->index; + unsigned int arrival; + + if (argc != 1) + { + vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); + return CMD_WARNING; + } + + VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000); + + ospf->min_ls_arrival = arrival; + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_timers_min_ls_arrival, + no_ospf_timers_min_ls_arrival_cmd, + "no timers lsa arrival", + NO_STR + "Adjust routing timers\n" + "Throttling link state advertisement delays\n" + "OSPF minimum arrival interval delay\n") +{ + struct ospf *ospf = vty->index; + ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; + + return CMD_SUCCESS; +} + DEFUN (ospf_timers_throttle_spf, ospf_timers_throttle_spf_cmd, "timers throttle spf <0-600000> <0-600000> <0-600000>", @@ -2295,7 +2421,7 @@ ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, NO_STR "Adjust routing timers\n" "OSPF SPF timers\n") - + DEFUN (ospf_neighbor, ospf_neighbor_cmd, "neighbor A.B.C.D", @@ -2428,7 +2554,7 @@ ALIAS (no_ospf_neighbor, "Dead Neighbor Polling interval\n" "Seconds\n") - + DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, "refresh timer <10-1800>", "Adjust refresh parameters\n" @@ -2546,7 +2672,7 @@ const char *ospf_shortcut_mode_descr_str[] = }; - + static void show_ip_ospf_area (struct vty *vty, struct ospf_area *area) { @@ -2660,14 +2786,12 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area * vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); -#ifdef HAVE_OPAQUE_LSA vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); -#endif /* HAVE_OPAQUE_LSA */ vty_out (vty, "%s", VTY_NEWLINE); } @@ -2708,14 +2832,10 @@ DEFUN (show_ip_ospf, 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", + vty_out (vty, " OpaqueCapability flag is %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 stub-router configuration */ if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED @@ -2747,6 +2867,9 @@ DEFUN (show_ip_ospf, vty_out (vty, "last executed %s ago%s", ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), VTY_NEWLINE); + vty_out (vty, " Last SPF duration %s%s", + ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), + VTY_NEWLINE); } else vty_out (vty, "has not been run%s", VTY_NEWLINE); @@ -2772,11 +2895,9 @@ DEFUN (show_ip_ospf, vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); -#ifdef HAVE_OPAQUE_LSA vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); -#endif /* HAVE_OPAQUE_LSA */ /* Show number of areas attached. */ vty_out (vty, " Number of areas attached to this router: %d%s", listcount (ospf->areas), VTY_NEWLINE); @@ -2798,7 +2919,7 @@ DEFUN (show_ip_ospf, return CMD_SUCCESS; } - + static void show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp) @@ -3427,7 +3548,7 @@ DEFUN (show_ip_ospf_neighbor_int_detail, return CMD_SUCCESS; } - + /* Show functions */ static int show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) @@ -3479,11 +3600,9 @@ show_lsa_summary (struct vty *vty, struct ospf_lsa *ls 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; } @@ -3503,12 +3622,10 @@ static const char *show_database_desc[] = "AS External Link States", "Group Membership LSA", "NSSA-external Link States", -#ifdef HAVE_OPAQUE_LSA "Type-8 LSA", "Link-Local Opaque-LSA", "Area-Local Opaque-LSA", "AS-external Opaque-LSA", -#endif /* HAVE_OPAQUE_LSA */ }; static const char *show_database_header[] = @@ -3521,12 +3638,10 @@ static const char *show_database_header[] = "Link ID ADV Router Age Seq# CkSum Route", " --- header for Group Member ----", "Link ID ADV Router Age Seq# CkSum Route", -#ifdef HAVE_OPAQUE_LSA " --- 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 */ }; static void @@ -3602,7 +3717,8 @@ static void show_ip_ospf_database_router_links (struct vty *vty, struct router_lsa *rl) { - int len, i, type; + int len, type; + unsigned int i; len = ntohs (rl->header.length) - 4; for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) @@ -3797,7 +3913,6 @@ show_func_dummy (struct vty *vty, struct ospf_lsa *lsa return 0; } -#ifdef HAVE_OPAQUE_LSA static int show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) { @@ -3810,7 +3925,6 @@ show_opaque_lsa_detail (struct vty *vty, struct ospf_l } return 0; } -#endif /* HAVE_OPAQUE_LSA */ int (*show_function[])(struct vty *, struct ospf_lsa *) = { @@ -3822,12 +3936,10 @@ int (*show_function[])(struct vty *, struct ospf_lsa * show_as_external_lsa_detail, show_func_dummy, show_as_nssa_lsa_detail, /* almost same as external */ -#ifdef HAVE_OPAQUE_LSA NULL, /* type-8 */ show_opaque_lsa_detail, show_opaque_lsa_detail, show_opaque_lsa_detail, -#endif /* HAVE_OPAQUE_LSA */ }; static void @@ -3886,9 +3998,7 @@ show_lsa_detail (struct vty *vty, struct ospf *ospf, i 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); @@ -3935,9 +4045,7 @@ show_lsa_detail_adv_router (struct vty *vty, struct os 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); @@ -3973,9 +4081,7 @@ show_ip_ospf_database_summary (struct vty *vty, struct switch (type) { case OSPF_AS_EXTERNAL_LSA: -#ifdef HAVE_OPAQUE_LSA case OSPF_OPAQUE_AS_LSA: -#endif /* HAVE_OPAQUE_LSA */ continue; default: break; @@ -4002,9 +4108,7 @@ show_ip_ospf_database_summary (struct vty *vty, struct switch (type) { case OSPF_AS_EXTERNAL_LSA: -#ifdef HAVE_OPAQUE_LSA case OSPF_OPAQUE_AS_LSA: -#endif /* HAVE_OPAQUE_LSA */ break; default: continue; @@ -4032,7 +4136,6 @@ static void show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) { struct route_node *rn; - struct ospf_lsa *lsa; vty_out (vty, "%s MaxAge Link States:%s%s", VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); @@ -4057,17 +4160,10 @@ show_ip_ospf_database_maxage (struct vty *vty, struct #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" -#ifdef HAVE_OPAQUE_LSA #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" #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" \ @@ -4137,14 +4233,12 @@ DEFUN (show_ip_ospf_database, 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; @@ -4264,14 +4358,12 @@ DEFUN (show_ip_ospf_database_type_adv_router, type = OSPF_ASBR_SUMMARY_LSA; else if (strncmp (argv[0], "e", 1) == 0) type = OSPF_AS_EXTERNAL_LSA; -#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; @@ -4300,7 +4392,7 @@ ALIAS (show_ip_ospf_database_type_adv_router, OSPF_LSA_TYPES_DESC "Self-originated link states\n") - + DEFUN (ip_ospf_authentication_args, ip_ospf_authentication_args_addr_cmd, "ip ospf authentication (null|message-digest) A.B.C.D", @@ -5307,7 +5399,13 @@ DEFUN (ip_ospf_network, struct interface *ifp = vty->index; int old_type = IF_DEF_PARAMS (ifp)->type; struct route_node *rn; - + + if (old_type == OSPF_IFTYPE_LOOPBACK) + { + vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); + return CMD_WARNING; + } + if (strncmp (argv[0], "b", 1) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; else if (strncmp (argv[0], "n", 1) == 0) @@ -5785,80 +5883,81 @@ ALIAS (no_ip_ospf_transmit_delay, "OSPF interface commands\n" "Link state transmit delay\n") - -DEFUN (ospf_redistribute_source_metric_type, - ospf_redistribute_source_metric_type_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD - " metric <0-16777214> metric-type (1|2) route-map WORD", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "Metric for redistributed routes\n" - "OSPF default metric\n" - "OSPF exterior metric type for redistributed routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "Route map reference\n" - "Pointer to route-map entries\n") +DEFUN (ip_ospf_area, + ip_ospf_area_cmd, + "ip ospf area (A.B.C.D|<0-4294967295>) [A.B.C.D]", + "IP Information\n" + "OSPF interface commands\n" + "Enable OSPF on this interface\n" + "OSPF area ID in IP address format\n" + "OSPF area ID as a decimal value\n" + "Address of interface\n") { - struct ospf *ospf = vty->index; - int source; - int type = -1; - int metric = -1; + struct interface *ifp = vty->index; + struct in_addr area_id; + struct in_addr addr; + int format; + struct ospf_if_params *params; - /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[0]); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) - return CMD_WARNING; + VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); - /* Get metric value. */ - if (argc >= 2) - if (!str2metric (argv[1], &metric)) + OSPF_VTY_GET_IF_PARAMS(ifp, params, 1, addr, VTY_SET); + + if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) + { + vty_out (vty, "There is already an interface area statement.%s", + VTY_NEWLINE); return CMD_WARNING; - - /* Get metric type. */ - if (argc >= 3) - if (!str2metric_type (argv[2], &type)) + } + if (memcmp (ifp->name, "VLINK", 5) == 0) + { + vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); return CMD_WARNING; + } + + SET_IF_PARAM (params, if_area); + params->if_area = area_id; + ospf_interface_area_set (ifp); - if (argc == 4) - ospf_routemap_set (ospf, source, argv[3]); - else - ospf_routemap_unset (ospf, source); + return CMD_SUCCESS; +} + +DEFUN (no_ip_ospf_area, + no_ip_ospf_area_cmd, + "no ip ospf area [A.B.C.D]", + NO_STR + "IP Information\n" + "OSPF interface commands\n" + "Disable OSPF on this interface\n" + "Address of interface\n") +{ + struct interface *ifp = vty->index; + struct ospf_if_params *params; + struct in_addr addr; + + OSPF_VTY_GET_IF_PARAMS(ifp, params, 0, addr, VTY_UNSET); - return ospf_redistribute_set (ospf, source, type, metric); + if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) + return CMD_SUCCESS; + + OSPF_VTY_PARAM_UNSET(params, if_area, ifp, addr); + + ospf_interface_area_unset (ifp); + + return CMD_SUCCESS; } -ALIAS (ospf_redistribute_source_metric_type, - ospf_redistribute_source_metric_type_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD - " metric <0-16777214> metric-type (1|2)", +DEFUN (ospf_redistribute_source, + ospf_redistribute_source_cmd, + "redistribute " QUAGGA_REDIST_STR_OSPFD + " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", REDIST_STR QUAGGA_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" "OSPF default metric\n" "OSPF exterior metric type for redistributed routes\n" "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n") - -ALIAS (ospf_redistribute_source_metric_type, - ospf_redistribute_source_metric_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "Metric for redistributed routes\n" - "OSPF default metric\n") - -DEFUN (ospf_redistribute_source_type_metric, - ospf_redistribute_source_type_metric_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD - " metric-type (1|2) metric <0-16777214> route-map WORD", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "OSPF exterior metric type for redistributed routes\n" - "Set OSPF External Type 1 metrics\n" "Set OSPF External Type 2 metrics\n" - "Metric for redistributed routes\n" - "OSPF default metric\n" "Route map reference\n" "Pointer to route-map entries\n") { @@ -5867,22 +5966,25 @@ DEFUN (ospf_redistribute_source_type_metric, int type = -1; int metric = -1; + if (argc < 4) + return CMD_WARNING; /* should not happen */ + /* Get distribute source. */ source = proto_redistnum(AFI_IP, argv[0]); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; /* Get metric value. */ - if (argc >= 2) - if (!str2metric_type (argv[1], &type)) + if (argv[1] != NULL) + if (!str2metric (argv[1], &metric)) return CMD_WARNING; /* Get metric type. */ - if (argc >= 3) - if (!str2metric (argv[2], &metric)) + if (argv[2] != NULL) + if (!str2metric_type (argv[2], &type)) return CMD_WARNING; - if (argc == 4) + if (argv[3] != NULL) ospf_routemap_set (ospf, source, argv[3]); else ospf_routemap_unset (ospf, source); @@ -5890,124 +5992,6 @@ DEFUN (ospf_redistribute_source_type_metric, return ospf_redistribute_set (ospf, source, type, metric); } -ALIAS (ospf_redistribute_source_type_metric, - ospf_redistribute_source_type_metric_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD - " metric-type (1|2) metric <0-16777214>", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "OSPF exterior metric type for redistributed routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "Metric for redistributed routes\n" - "OSPF default metric\n") - -ALIAS (ospf_redistribute_source_type_metric, - ospf_redistribute_source_type_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "OSPF exterior metric type for redistributed routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n") - -ALIAS (ospf_redistribute_source_type_metric, - ospf_redistribute_source_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD, - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD) - -DEFUN (ospf_redistribute_source_metric_routemap, - ospf_redistribute_source_metric_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD - " metric <0-16777214> route-map WORD", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "Metric for redistributed routes\n" - "OSPF default metric\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int source; - int metric = -1; - - /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[0]); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) - return CMD_WARNING; - - /* Get metric value. */ - if (argc >= 2) - if (!str2metric (argv[1], &metric)) - return CMD_WARNING; - - if (argc == 3) - ospf_routemap_set (ospf, source, argv[2]); - else - ospf_routemap_unset (ospf, source); - - return ospf_redistribute_set (ospf, source, -1, metric); -} - -DEFUN (ospf_redistribute_source_type_routemap, - ospf_redistribute_source_type_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD - " metric-type (1|2) route-map WORD", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "OSPF exterior metric type for redistributed routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int source; - int type = -1; - - /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[0]); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) - return CMD_WARNING; - - /* Get metric value. */ - if (argc >= 2) - if (!str2metric_type (argv[1], &type)) - return CMD_WARNING; - - if (argc == 3) - ospf_routemap_set (ospf, source, argv[2]); - else - ospf_routemap_unset (ospf, source); - - return ospf_redistribute_set (ospf, source, type, -1); -} - -DEFUN (ospf_redistribute_source_routemap, - ospf_redistribute_source_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD", - REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int source; - - /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[0]); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) - return CMD_WARNING; - - if (argc == 2) - ospf_routemap_set (ospf, source, argv[1]); - else - ospf_routemap_unset (ospf, source); - - return ospf_redistribute_set (ospf, source, -1, -1); -} - DEFUN (no_ospf_redistribute_source, no_ospf_redistribute_source_cmd, "no redistribute " QUAGGA_REDIST_STR_OSPFD, @@ -6065,203 +6049,12 @@ DEFUN (no_ospf_distribute_list_out, } /* Default information originate. */ -DEFUN (ospf_default_information_originate_metric_type_routemap, - ospf_default_information_originate_metric_type_routemap_cmd, - "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "OSPF default metric\n" - "OSPF metric\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int type = -1; - int metric = -1; - - /* Get metric value. */ - if (argc >= 1) - if (!str2metric (argv[0], &metric)) - return CMD_WARNING; - - /* Get metric type. */ - if (argc >= 2) - if (!str2metric_type (argv[1], &type)) - return CMD_WARNING; - - if (argc == 3) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, - type, metric); -} - -ALIAS (ospf_default_information_originate_metric_type_routemap, - ospf_default_information_originate_metric_type_cmd, - "default-information originate metric <0-16777214> metric-type (1|2)", - "Control distribution of default information\n" - "Distribute a default route\n" - "OSPF default metric\n" - "OSPF metric\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n") - -ALIAS (ospf_default_information_originate_metric_type_routemap, - ospf_default_information_originate_metric_cmd, - "default-information originate metric <0-16777214>", - "Control distribution of default information\n" - "Distribute a default route\n" - "OSPF default metric\n" - "OSPF metric\n") - -ALIAS (ospf_default_information_originate_metric_type_routemap, +DEFUN (ospf_default_information_originate, ospf_default_information_originate_cmd, - "default-information originate", + "default-information originate " + "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", "Control distribution of default information\n" - "Distribute a default route\n") - -/* Default information originate. */ -DEFUN (ospf_default_information_originate_metric_routemap, - ospf_default_information_originate_metric_routemap_cmd, - "default-information originate metric <0-16777214> route-map WORD", - "Control distribution of default information\n" "Distribute a default route\n" - "OSPF default metric\n" - "OSPF metric\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int metric = -1; - - /* Get metric value. */ - if (argc >= 1) - if (!str2metric (argv[0], &metric)) - return CMD_WARNING; - - if (argc == 2) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, - -1, metric); -} - -/* Default information originate. */ -DEFUN (ospf_default_information_originate_routemap, - ospf_default_information_originate_routemap_cmd, - "default-information originate route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - - if (argc == 1) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); -} - -DEFUN (ospf_default_information_originate_type_metric_routemap, - ospf_default_information_originate_type_metric_routemap_cmd, - "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "OSPF default metric\n" - "OSPF metric\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int type = -1; - int metric = -1; - - /* Get metric type. */ - if (argc >= 1) - if (!str2metric_type (argv[0], &type)) - return CMD_WARNING; - - /* Get metric value. */ - if (argc >= 2) - if (!str2metric (argv[1], &metric)) - return CMD_WARNING; - - if (argc == 3) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, - type, metric); -} - -ALIAS (ospf_default_information_originate_type_metric_routemap, - ospf_default_information_originate_type_metric_cmd, - "default-information originate metric-type (1|2) metric <0-16777214>", - "Control distribution of default information\n" - "Distribute a default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "OSPF default metric\n" - "OSPF metric\n") - -ALIAS (ospf_default_information_originate_type_metric_routemap, - ospf_default_information_originate_type_cmd, - "default-information originate metric-type (1|2)", - "Control distribution of default information\n" - "Distribute a default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n") - -DEFUN (ospf_default_information_originate_type_routemap, - ospf_default_information_originate_type_routemap_cmd, - "default-information originate metric-type (1|2) route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int type = -1; - - /* Get metric type. */ - if (argc >= 1) - if (!str2metric_type (argv[0], &type)) - return CMD_WARNING; - - if (argc == 2) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, - type, -1); -} - -DEFUN (ospf_default_information_originate_always_metric_type_routemap, - ospf_default_information_originate_always_metric_type_routemap_cmd, - "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" "Always advertise default route\n" "OSPF default metric\n" "OSPF metric\n" @@ -6272,192 +6065,36 @@ DEFUN (ospf_default_information_originate_always_metri "Pointer to route-map entries\n") { struct ospf *ospf = vty->index; + int default_originate = DEFAULT_ORIGINATE_ZEBRA; int type = -1; int metric = -1; - /* Get metric value. */ - if (argc >= 1) - if (!str2metric (argv[0], &metric)) - return CMD_WARNING; + if (argc < 4) + return CMD_WARNING; /* this should not happen */ - /* Get metric type. */ - if (argc >= 2) - if (!str2metric_type (argv[1], &type)) - return CMD_WARNING; + /* Check whether "always" was specified */ + if (argv[0] != NULL) + default_originate = DEFAULT_ORIGINATE_ALWAYS; - if (argc == 3) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, - type, metric); -} - -ALIAS (ospf_default_information_originate_always_metric_type_routemap, - ospf_default_information_originate_always_metric_type_cmd, - "default-information originate always metric <0-16777214> metric-type (1|2)", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "OSPF default metric\n" - "OSPF metric\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n") - -ALIAS (ospf_default_information_originate_always_metric_type_routemap, - ospf_default_information_originate_always_metric_cmd, - "default-information originate always metric <0-16777214>", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "OSPF default metric\n" - "OSPF metric\n" - "OSPF metric type for default routes\n") - -ALIAS (ospf_default_information_originate_always_metric_type_routemap, - ospf_default_information_originate_always_cmd, - "default-information originate always", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n") - -DEFUN (ospf_default_information_originate_always_metric_routemap, - ospf_default_information_originate_always_metric_routemap_cmd, - "default-information originate always metric <0-16777214> route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "OSPF default metric\n" - "OSPF metric\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int metric = -1; - /* Get metric value. */ - if (argc >= 1) - if (!str2metric (argv[0], &metric)) + if (argv[1] != NULL) + if (!str2metric (argv[1], &metric)) return CMD_WARNING; - if (argc == 2) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, - -1, metric); -} - -DEFUN (ospf_default_information_originate_always_routemap, - ospf_default_information_originate_always_routemap_cmd, - "default-information originate always route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - - if (argc == 1) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); -} - -DEFUN (ospf_default_information_originate_always_type_metric_routemap, - ospf_default_information_originate_always_type_metric_routemap_cmd, - "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "OSPF default metric\n" - "OSPF metric\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int type = -1; - int metric = -1; - /* Get metric type. */ - if (argc >= 1) - if (!str2metric_type (argv[0], &type)) + if (argv[2] != NULL) + if (!str2metric_type (argv[2], &type)) return CMD_WARNING; - /* Get metric value. */ - if (argc >= 2) - if (!str2metric (argv[1], &metric)) - return CMD_WARNING; - - if (argc == 3) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); + if (argv[3] != NULL) + ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]); else ospf_routemap_unset (ospf, DEFAULT_ROUTE); - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, + return ospf_redistribute_default_set (ospf, default_originate, type, metric); } -ALIAS (ospf_default_information_originate_always_type_metric_routemap, - ospf_default_information_originate_always_type_metric_cmd, - "default-information originate always metric-type (1|2) metric <0-16777214>", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "OSPF default metric\n" - "OSPF metric\n") - -ALIAS (ospf_default_information_originate_always_type_metric_routemap, - ospf_default_information_originate_always_type_cmd, - "default-information originate always metric-type (1|2)", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n") - -DEFUN (ospf_default_information_originate_always_type_routemap, - ospf_default_information_originate_always_type_routemap_cmd, - "default-information originate always metric-type (1|2) route-map WORD", - "Control distribution of default information\n" - "Distribute a default route\n" - "Always advertise default route\n" - "OSPF metric type for default routes\n" - "Set OSPF External Type 1 metrics\n" - "Set OSPF External Type 2 metrics\n" - "Route map reference\n" - "Pointer to route-map entries\n") -{ - struct ospf *ospf = vty->index; - int type = -1; - - /* Get metric type. */ - if (argc >= 1) - if (!str2metric_type (argv[0], &type)) - return CMD_WARNING; - - if (argc == 2) - ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); - else - ospf_routemap_unset (ospf, DEFAULT_ROUTE); - - return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, - type, -1); -} - DEFUN (no_ospf_default_information_originate, no_ospf_default_information_originate_cmd, "no default-information originate", @@ -6550,300 +6187,77 @@ DEFUN (no_ospf_distance, DEFUN (no_ospf_distance_ospf, no_ospf_distance_ospf_cmd, - "no distance ospf", + "no distance ospf {intra-area|inter-area|external}", NO_STR "Define an administrative distance\n" "OSPF Administrative distance\n" - "OSPF Distance\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_intra = 0; - ospf->distance_inter = 0; - ospf->distance_external = 0; - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_intra, - ospf_distance_ospf_intra_cmd, - "distance ospf intra-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" + "OSPF Distance\n" "Intra-area routes\n" - "Distance for intra-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_intra = atoi (argv[0]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_intra_inter, - ospf_distance_ospf_intra_inter_cmd, - "distance ospf intra-area <1-255> inter-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Intra-area routes\n" - "Distance for intra-area routes\n" "Inter-area routes\n" - "Distance for inter-area routes\n") + "External routes\n") { struct ospf *ospf = vty->index; - ospf->distance_intra = atoi (argv[0]); - ospf->distance_inter = atoi (argv[1]); + if (argc < 3) + return CMD_WARNING; - return CMD_SUCCESS; -} + if (argv[0] != NULL) + ospf->distance_intra = 0; -DEFUN (ospf_distance_ospf_intra_external, - ospf_distance_ospf_intra_external_cmd, - "distance ospf intra-area <1-255> external <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Intra-area routes\n" - "Distance for intra-area routes\n" - "External routes\n" - "Distance for external routes\n") -{ - struct ospf *ospf = vty->index; + if (argv[1] != NULL) + ospf->distance_inter = 0; - ospf->distance_intra = atoi (argv[0]); - ospf->distance_external = atoi (argv[1]); + if (argv[2] != NULL) + ospf->distance_external = 0; - return CMD_SUCCESS; -} + if (argv[0] || argv[1] || argv[2]) + return CMD_SUCCESS; -DEFUN (ospf_distance_ospf_intra_inter_external, - ospf_distance_ospf_intra_inter_external_cmd, - "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Intra-area routes\n" - "Distance for intra-area routes\n" - "Inter-area routes\n" - "Distance for inter-area routes\n" - "External routes\n" - "Distance for external routes\n") -{ - struct ospf *ospf = vty->index; + /* If no arguments are given, clear all distance information */ + ospf->distance_intra = 0; + ospf->distance_inter = 0; + ospf->distance_external = 0; - ospf->distance_intra = atoi (argv[0]); - ospf->distance_inter = atoi (argv[1]); - ospf->distance_external = atoi (argv[2]); - return CMD_SUCCESS; } -DEFUN (ospf_distance_ospf_intra_external_inter, - ospf_distance_ospf_intra_external_inter_cmd, - "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", +DEFUN (ospf_distance_ospf, + ospf_distance_ospf_cmd, + "distance ospf " + "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", "Define an administrative distance\n" "OSPF Administrative distance\n" "Intra-area routes\n" "Distance for intra-area routes\n" - "External routes\n" - "Distance for external routes\n" "Inter-area routes\n" - "Distance for inter-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_intra = atoi (argv[0]); - ospf->distance_external = atoi (argv[1]); - ospf->distance_inter = atoi (argv[2]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_inter, - ospf_distance_ospf_inter_cmd, - "distance ospf inter-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Inter-area routes\n" - "Distance for inter-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_inter = atoi (argv[0]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_inter_intra, - ospf_distance_ospf_inter_intra_cmd, - "distance ospf inter-area <1-255> intra-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Inter-area routes\n" "Distance for inter-area routes\n" - "Intra-area routes\n" - "Distance for intra-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_inter = atoi (argv[0]); - ospf->distance_intra = atoi (argv[1]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_inter_external, - ospf_distance_ospf_inter_external_cmd, - "distance ospf inter-area <1-255> external <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Inter-area routes\n" - "Distance for inter-area routes\n" "External routes\n" "Distance for external routes\n") { struct ospf *ospf = vty->index; - ospf->distance_inter = atoi (argv[0]); - ospf->distance_external = atoi (argv[1]); + if (argc < 3) /* should not happen */ + return CMD_WARNING; - return CMD_SUCCESS; -} + if (!argv[0] && !argv[1] && !argv[2]) + { + vty_out(vty, "%% Command incomplete. (Arguments required)%s", + VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (ospf_distance_ospf_inter_intra_external, - ospf_distance_ospf_inter_intra_external_cmd, - "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Inter-area routes\n" - "Distance for inter-area routes\n" - "Intra-area routes\n" - "Distance for intra-area routes\n" - "External routes\n" - "Distance for external routes\n") -{ - struct ospf *ospf = vty->index; + if (argv[0] != NULL) + ospf->distance_intra = atoi(argv[0]); - ospf->distance_inter = atoi (argv[0]); - ospf->distance_intra = atoi (argv[1]); - ospf->distance_external = atoi (argv[2]); + if (argv[1] != NULL) + ospf->distance_inter = atoi(argv[1]); - return CMD_SUCCESS; -} + if (argv[2] != NULL) + ospf->distance_external = atoi(argv[2]); -DEFUN (ospf_distance_ospf_inter_external_intra, - ospf_distance_ospf_inter_external_intra_cmd, - "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "Inter-area routes\n" - "Distance for inter-area routes\n" - "External routes\n" - "Distance for external routes\n" - "Intra-area routes\n" - "Distance for intra-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_inter = atoi (argv[0]); - ospf->distance_external = atoi (argv[1]); - ospf->distance_intra = atoi (argv[2]); - return CMD_SUCCESS; } -DEFUN (ospf_distance_ospf_external, - ospf_distance_ospf_external_cmd, - "distance ospf external <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "External routes\n" - "Distance for external routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_external = atoi (argv[0]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_external_intra, - ospf_distance_ospf_external_intra_cmd, - "distance ospf external <1-255> intra-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "External routes\n" - "Distance for external routes\n" - "Intra-area routes\n" - "Distance for intra-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_external = atoi (argv[0]); - ospf->distance_intra = atoi (argv[1]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_external_inter, - ospf_distance_ospf_external_inter_cmd, - "distance ospf external <1-255> inter-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "External routes\n" - "Distance for external routes\n" - "Inter-area routes\n" - "Distance for inter-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_external = atoi (argv[0]); - ospf->distance_inter = atoi (argv[1]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_external_intra_inter, - ospf_distance_ospf_external_intra_inter_cmd, - "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "External routes\n" - "Distance for external routes\n" - "Intra-area routes\n" - "Distance for intra-area routes\n" - "Inter-area routes\n" - "Distance for inter-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_external = atoi (argv[0]); - ospf->distance_intra = atoi (argv[1]); - ospf->distance_inter = atoi (argv[2]); - - return CMD_SUCCESS; -} - -DEFUN (ospf_distance_ospf_external_inter_intra, - ospf_distance_ospf_external_inter_intra_cmd, - "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", - "Define an administrative distance\n" - "OSPF Administrative distance\n" - "External routes\n" - "Distance for external routes\n" - "Inter-area routes\n" - "Distance for inter-area routes\n" - "Intra-area routes\n" - "Distance for intra-area routes\n") -{ - struct ospf *ospf = vty->index; - - ospf->distance_external = atoi (argv[0]); - ospf->distance_inter = atoi (argv[1]); - ospf->distance_intra = atoi (argv[2]); - - return CMD_SUCCESS; -} - DEFUN (ospf_distance_source, ospf_distance_source_cmd, "distance <1-255> A.B.C.D/M", @@ -7002,7 +6416,7 @@ ALIAS (no_ip_ospf_mtu_ignore, "IP Information\n" "OSPF interface commands\n" "Disable mtu mismatch detection\n") - + DEFUN (ospf_max_metric_router_lsa_admin, ospf_max_metric_router_lsa_admin_cmd, "max-metric router-lsa administrative", @@ -7171,7 +6585,7 @@ config_write_stub_router (struct vty *vty, struct ospf } return; } - + static void show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) { @@ -7390,7 +6804,7 @@ DEFUN (show_ip_ospf_route, return CMD_SUCCESS; } - + const char *ospf_abr_type_str[] = { "unknown", @@ -7419,7 +6833,7 @@ area_id2str (char *buf, int length, struct ospf_area * sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); } - + const char *ospf_int_type_str[] = { "unknown", /* should never be used. */ @@ -7597,6 +7011,15 @@ config_write_interface (struct vty *vty) vty_out (vty, "%s", VTY_NEWLINE); } + /* Area print. */ + if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) + { + vty_out (vty, " ip ospf area %s", inet_ntoa (params->if_area)); + if (params != IF_DEF_PARAMS (ifp)) + vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); + vty_out (vty, "%s", VTY_NEWLINE); + } + /* MTU ignore print. */ if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) @@ -7626,9 +7049,7 @@ config_write_interface (struct vty *vty) } } while (rn); -#ifdef HAVE_OPAQUE_LSA ospf_opaque_config_write_if (vty, ifp); -#endif /* HAVE_OPAQUE_LSA */ } return write; @@ -7853,7 +7274,7 @@ config_write_virtual_link (struct vty *vty, struct osp return 0; } - + static int config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) { @@ -7861,7 +7282,8 @@ config_write_ospf_redistribute (struct vty *vty, struc /* redistribute print. */ for (type = 0; type < ZEBRA_ROUTE_MAX; type++) - if (type != zclient->redist_default && zclient->redist[type]) + if (type != zclient->redist_default && + vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT)) { vty_out (vty, " redistribute %s", zebra_route_string(type)); if (ospf->dmetric[type].value >= 0) @@ -8016,6 +7438,14 @@ ospf_config_write (struct vty *vty) ospf->ref_bandwidth / 1000, VTY_NEWLINE); } + /* LSA timers */ + if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) + vty_out (vty, " timers throttle lsa all %d%s", + ospf->min_ls_interval, VTY_NEWLINE); + if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) + vty_out (vty, " timers lsa arrival %d%s", + ospf->min_ls_arrival, VTY_NEWLINE); + /* SPF timers print. */ if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || @@ -8088,9 +7518,7 @@ ospf_config_write (struct vty *vty) /* Distance configuration. */ config_write_ospf_distance (vty, ospf); -#ifdef HAVE_OPAQUE_LSA ospf_opaque_config_write_router (vty, ospf); -#endif /* HAVE_OPAQUE_LSA */ } return write; @@ -8146,7 +7574,7 @@ ospf_vty_show_init (void) install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); } - + /* ospfd's interface node. */ static struct cmd_node interface_node = { @@ -8238,6 +7666,10 @@ ospf_vty_if_init (void) install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); + /* "ip ospf area" commands. */ + install_element (INTERFACE_NODE, &ip_ospf_area_cmd); + install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); + /* These commands are compatibitliy for previous version. */ install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); @@ -8266,63 +7698,13 @@ ospf_vty_if_init (void) static void ospf_vty_zebra_init (void) { - install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); - install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); - install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); - install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); install_element (OSPF_NODE, &ospf_redistribute_source_cmd); - install_element (OSPF_NODE, - &ospf_redistribute_source_metric_type_routemap_cmd); - install_element (OSPF_NODE, - &ospf_redistribute_source_type_metric_routemap_cmd); - install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); - install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); - install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); - install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_metric_type_cmd); - install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_type_metric_cmd); - install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); install_element (OSPF_NODE, &ospf_default_information_originate_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_metric_type_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_metric_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_type_metric_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_type_cmd); - - install_element (OSPF_NODE, - &ospf_default_information_originate_metric_type_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_metric_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_type_metric_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_type_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_metric_type_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_metric_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_type_metric_routemap_cmd); - install_element (OSPF_NODE, - &ospf_default_information_originate_always_type_routemap_cmd); - install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); install_element (OSPF_NODE, &ospf_default_metric_cmd); @@ -8332,21 +7714,7 @@ ospf_vty_zebra_init (void) install_element (OSPF_NODE, &ospf_distance_cmd); install_element (OSPF_NODE, &no_ospf_distance_cmd); install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); - install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); + install_element (OSPF_NODE, &ospf_distance_ospf_cmd); #if 0 install_element (OSPF_NODE, &ospf_distance_source_cmd); install_element (OSPF_NODE, &no_ospf_distance_source_cmd); @@ -8362,7 +7730,7 @@ static struct cmd_node ospf_node = 1 }; - + /* Install OSPF related vty commands. */ void ospf_vty_init (void) @@ -8491,6 +7859,12 @@ ospf_vty_init (void) install_element (OSPF_NODE, &ospf_area_import_list_cmd); install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); + /* LSA timer commands */ + install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); + install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); + install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); + install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); + /* SPF timer commands */ install_element (OSPF_NODE, &ospf_timers_spf_cmd); install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);