From: root Date: Fri, 30 Sep 2016 15:16:19 +0000 (-0400) Subject: ospfd: resolve argc CHECK MEs in ospf_vty.c X-Git-Tag: frr-3.0-branchpoint~129^2~118 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=7a7be51923d07bbacda978fd35b805b22d65fd31;p=matthieu%2Ffrr.git ospfd: resolve argc CHECK MEs in ospf_vty.c Signed-off-by: Don Slice --- diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 09947f49e5..5753671f16 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -143,20 +143,12 @@ ospf_oi_count (struct interface *ifp) return i; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "router ospf <1-65535>", - * "Enable a routing process\n" - * "Start OSPF configuration\n" - * "Instance ID\n" - * - */ DEFUN (router_ospf, router_ospf_cmd, - "router ospf", + "router ospf [(1-65535)]", "Enable a routing process\n" - "Start OSPF configuration\n") + "Start OSPF configuration\n" + "Instance ID\n") { struct ospf *ospf; u_short instance = 0; @@ -170,8 +162,8 @@ DEFUN (router_ospf, vty->node = OSPF_NODE; - if (argc) - VTY_GET_INTEGER ("Instance", instance, argv[0]); + if (argc > 2) + VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); /* The following logic to set the vty->index is in place to be able to ignore the commands which dont belong to this instance. */ @@ -189,27 +181,18 @@ DEFUN (router_ospf, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no router ospf <1-65535>", - * NO_STR - * "Enable a routing process\n" - * "Start OSPF configuration\n" - * "Instance ID\n" - * - */ DEFUN (no_router_ospf, no_router_ospf_cmd, - "no router ospf", + "no router ospf [(1-65535)]", NO_STR "Enable a routing process\n" - "Start OSPF configuration\n") + "Start OSPF configuration\n" + "Instance ID\n") { struct ospf *ospf; u_short instance = 0; - if (argc) + if (argc > 3) VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL) @@ -260,27 +243,51 @@ DEFUN (ospf_router_id, return CMD_SUCCESS; } -ALIAS_HIDDEN (ospf_router_id, +DEFUN_HIDDEN (ospf_router_id_old, ospf_router_id_old_cmd, "router-id A.B.C.D", "router-id for the OSPF process\n" "OSPF router-id in IP address format\n") +{ + int idx_ipv4 = 1; + struct ospf *ospf = vty->index; + struct listnode *node; + struct ospf_area *area; + struct in_addr router_id; + int ret; + + if (!ospf) + return CMD_SUCCESS; + + ret = inet_aton (argv[idx_ipv4]->arg, &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; + + for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) + if (area->full_nbrs) + { + vty_out (vty, "For this router-id change to take effect," + " save config and restart ospfd%s", VTY_NEWLINE); + return CMD_SUCCESS; + } + + ospf_router_id_update (ospf); + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf router-id A.B.C.D", - * NO_STR - * "OSPF specific commands\n" - * "router-id for the OSPF process\n" - * "OSPF router-id in IP address format\n" - * - */ DEFUN (no_ospf_router_id, no_ospf_router_id_cmd, - "no ospf router-id", + "no ospf router-id [A.B.C.D]", NO_STR "OSPF specific commands\n" - "router-id for the OSPF process\n") + "router-id for the OSPF process\n" + "OSPF router-id in IP address format\n") { struct ospf *ospf = vty->index; struct listnode *node; @@ -368,22 +375,12 @@ ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, } } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "passive-interface IFNAME", - * "Suppress routing updates on an interface\n" - * "Interface's name\n" - * - * "passive-interface default", - * "Suppress routing updates on an interface\n" - * "Suppress routing updates on interfaces by default\n" - * - */ DEFUN (ospf_passive_interface, ospf_passive_interface_addr_cmd, - "passive-interface IFNAME A.B.C.D", + "passive-interface ", "Suppress routing updates on an interface\n" - "Interface's name\n") + "Interface's name\n" + "Suppress routing updates on interfaces by default\n") { int idx_ipv4 = 2; struct interface *ifp; @@ -396,19 +393,19 @@ DEFUN (ospf_passive_interface, if (!ospf) return CMD_SUCCESS; - if (argc == 0) + if (strcmp (argv[1]->text, "default") == 0) { ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); return CMD_SUCCESS; } - ifp = if_get_by_name (argv[idx_ipv4]->arg); + ifp = if_get_by_name (argv[1]->arg); params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 3) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -449,27 +446,13 @@ DEFUN (ospf_passive_interface, return CMD_SUCCESS; } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no passive-interface default", - * NO_STR - * "Allow routing updates on an interface\n" - * "Allow routing updates on interfaces by default\n" - * - * "no passive-interface IFNAME", - * NO_STR - * "Allow routing updates on an interface\n" - * "Interface's name\n" - * - */ DEFUN (no_ospf_passive_interface, no_ospf_passive_interface_addr_cmd, - "no passive-interface IFNAME A.B.C.D", + "no passive-interface ", NO_STR "Allow routing updates on an interface\n" - "Interface's name\n") + "Interface's name\n" + "Allow routing updates on interfaces by default\n") { int idx_ipv4 = 3; struct interface *ifp; @@ -482,19 +465,19 @@ DEFUN (no_ospf_passive_interface, if (!ospf) return CMD_SUCCESS; - if (argc == 0) + if (strcmp (argv[2]->text, "default") == 0) { ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); return CMD_SUCCESS; } - ifp = if_get_by_name (argv[idx_ipv4]->arg); + ifp = if_get_by_name (argv[2]->arg); params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 4) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -619,48 +602,21 @@ DEFUN (no_ospf_network_area, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", - * "OSPF area parameters\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * "OSPF area range for route advertise (default)\n" - * "Area range prefix\n" - * "Advertise this range (default)\n" - * - * "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", - * "OSPF area parameters\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * "Summarize routes matching address/mask (border routers only)\n" - * "Area range prefix\n" - * "User specified metric for this range\n" - * "Advertised metric for this range\n" - * - * "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", - * "OSPF area parameters\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * "Summarize routes matching address/mask (border routers only)\n" - * "Area range prefix\n" - * "Advertise this range (default)\n" - * "User specified metric for this range\n" - * "Advertised metric for this range\n" - * - */ DEFUN (ospf_area_range, ospf_area_range_cmd, - "area range A.B.C.D/M", + "area range A.B.C.D/M [advertise [cost (0-16777215)]]", "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n") + "Area range prefix\n" + "Advertise this range (default)\n" + "User specified metric for this range\n" + "Advertised metric for this range\n") { int idx_ipv4_number = 1; int idx_ipv4_prefixlen = 3; + int idx_cost = 6; struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -674,17 +630,48 @@ DEFUN (ospf_area_range, VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); - if (argc > 2) + if (argc > 5) { - VTY_GET_INTEGER ("range cost", cost, argv[2]); + VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); ospf_area_range_cost_set (ospf, area_id, &p, cost); } return CMD_SUCCESS; } +DEFUN (ospf_area_range_cost, + ospf_area_range_cost_cmd, + "area range A.B.C.D/M cost (0-16777215)", + "OSPF area parameters\n" + "OSPF area ID in IP address format\n" + "OSPF area ID as a decimal value\n" + "Summarize routes matching address/mask (border routers only)\n" + "Area range prefix\n" + "User specified metric for this range\n" + "Advertised metric for this range\n") +{ + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; + int idx_cost = 5; + struct ospf *ospf = vty->index; + struct prefix_ipv4 p; + struct in_addr area_id; + int format; + u_int32_t cost; + + if (!ospf) + return CMD_SUCCESS; + + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); + + ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); + VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); + ospf_area_range_cost_set (ospf, area_id, &p, cost); + return CMD_SUCCESS; +} DEFUN (ospf_area_range_not_advertise, ospf_area_range_not_advertise_cmd, @@ -714,49 +701,17 @@ DEFUN (ospf_area_range_not_advertise, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", - * NO_STR - * "OSPF area parameters\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * "Summarize routes matching address/mask (border routers only)\n" - * "Area range prefix\n" - * "Advertise this range (default)\n" - * "DoNotAdvertise this range\n" - * - * "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", - * NO_STR - * "OSPF area parameters\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * "Summarize routes matching address/mask (border routers only)\n" - * "Area range prefix\n" - * "Advertise this range (default)\n" - * "User specified metric for this range\n" - * "Advertised metric for this range\n" - * - * "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", - * NO_STR - * "OSPF area parameters\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * "Summarize routes matching address/mask (border routers only)\n" - * "Area range prefix\n" - * "User specified metric for this range\n" - * "Advertised metric for this range\n" - * - */ DEFUN (no_ospf_area_range, no_ospf_area_range_cmd, - "no area range A.B.C.D/M", + "no area range A.B.C.D/M []", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" "Summarize routes matching address/mask (border routers only)\n" - "Area range prefix\n") + "Area range prefix\n" + "Advertise this range (default)\n" + "DoNotAdvertise this range\n") { int idx_ipv4_number = 2; int idx_ipv4_prefixlen = 4; @@ -776,9 +731,6 @@ DEFUN (no_ospf_area_range, return CMD_SUCCESS; } - - - DEFUN (ospf_area_range_substitute, ospf_area_range_substitute_cmd, "area range A.B.C.D/M substitute A.B.C.D/M", @@ -858,7 +810,6 @@ DEFUN (no_ospf_area_range_substitute, Wed, 21 Feb 2001 15:13:52 +1300 */ - /* Configuration data for virtual links */ struct ospf_vl_config_data { @@ -1026,7 +977,6 @@ ospf_vl_set_timers (struct ospf_vl_data *vl_data, } - /* The business end of all of the above */ static int ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) @@ -1096,93 +1046,19 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) "Use MD5 algorithm\n" \ "The OSPF password (key)" -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "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 - * - * "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 - * - * "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 - * - * "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 - * - * "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 - * - * "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 - * - * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|) (message-digest|null)", - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_ALL - * - * "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 - * - * "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 - * - * "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 - * - * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|)", - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_SIMPLE - * - * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication-key|) AUTH_KEY", - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTH_SIMPLE - * - */ DEFUN (ospf_area_vlink, ospf_area_vlink_cmd, - "area virtual-link A.B.C.D", - VLINK_HELPSTR_IPADDR) + "area virtual-link A.B.C.D " + "[authentication] [] " + "[arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */ - switch (argv[i][0]) + switch (argv[i]->arg[0]) { case 'a': - if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) + if (i >5 || strncmp (argv[i]->arg, "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); + strncpy (auth_key, argv[i+1]->text, OSPF_AUTH_SIMPLE_SIZE); vl_config.auth_key = auth_key; i++; } - else if (strncmp (argv[i], "authentication", 14) == 0) + else if (strncmp (argv[i]->arg, "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) + if (strncmp (argv[i+1]->arg, "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) + else if (strncmp (argv[i+1]->arg, "m", 1) == 0 + && strcmp (argv[i+1]->arg, "message-digest-") != 0) { /* "authentication message-digest" */ vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; @@ -1268,19 +1144,86 @@ DEFUN (ospf_area_vlink, case 'm': /* message-digest-key */ i++; - vl_config.crypto_key_id = strtol (argv[i], NULL, 10); + vl_config.crypto_key_id = strtol (argv[i]->arg, 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); + strncpy (md5_key, argv[i]->arg, OSPF_AUTH_MD5_SIZE); vl_config.md5_key = md5_key; break; + } + } + + + /* Action configuration */ + + return ospf_vl_set (ospf, &vl_config); + +} + +DEFUN (ospf_area_vlink_intervals, + ospf_area_vlink_intervals_cmd, + "area virtual-link A.B.C.D " + "[ (1-65535)] " + "[ (1-65535)] " + "[ (1-65535)] " + "[ (1-65535)] ", + VLINK_HELPSTR_IPADDR + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM) +{ + int idx_ipv4_number = 1; + int idx_ipv4 = 3; + struct ospf *ospf = vty->index; + struct ospf_vl_config_data vl_config; + int i; + int ret; + + if (!ospf) + return CMD_SUCCESS; + + ospf_vl_config_data_init(&vl_config, vty); + + /* Read off first 2 parameters and check them */ + ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &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[idx_ipv4]->arg, &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 <=4) + { + /* Thats all folks! - BUGS B. strikes again!!!*/ + + return ospf_vl_set (ospf, &vl_config); + } + + /* Deal with other parameters */ + for (i=5; i < argc; i++) + { + + /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->arg, VTY_NEWLINE); */ + + switch (argv[i]->arg[0]) + { + case 'h': /* Hello interval */ i++; - vl_config.hello_interval = strtol (argv[i], NULL, 10); + vl_config.hello_interval = strtol (argv[i]->arg, NULL, 10); if (vl_config.hello_interval < 0) return CMD_WARNING; break; @@ -1288,7 +1231,7 @@ DEFUN (ospf_area_vlink, case 'r': /* Retransmit Interval */ i++; - vl_config.retransmit_interval = strtol (argv[i], NULL, 10); + vl_config.retransmit_interval = strtol (argv[i]->arg, NULL, 10); if (vl_config.retransmit_interval < 0) return CMD_WARNING; break; @@ -1296,7 +1239,7 @@ DEFUN (ospf_area_vlink, case 't': /* Transmit Delay */ i++; - vl_config.transmit_delay = strtol (argv[i], NULL, 10); + vl_config.transmit_delay = strtol (argv[i]->arg, NULL, 10); if (vl_config.transmit_delay < 0) return CMD_WARNING; break; @@ -1304,7 +1247,7 @@ DEFUN (ospf_area_vlink, case 'd': /* Dead Interval */ i++; - vl_config.dead_interval = strtol (argv[i], NULL, 10); + vl_config.dead_interval = strtol (argv[i]->arg, NULL, 10); if (vl_config.dead_interval < 0) return CMD_WARNING; break; @@ -1318,106 +1261,20 @@ DEFUN (ospf_area_vlink, } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no 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>", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_TIME_PARAM - * VLINK_HELPSTR_TIME_PARAM - * VLINK_HELPSTR_TIME_PARAM - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|) " - * "(message-digest-key|) <1-255> md5 KEY", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_SIMPLE - * VLINK_HELPSTR_AUTH_MD5 - * - * "no 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>", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_TIME_PARAM - * VLINK_HELPSTR_TIME_PARAM - * - * "no 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>", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_TIME_PARAM - * VLINK_HELPSTR_TIME_PARAM - * VLINK_HELPSTR_TIME_PARAM - * VLINK_HELPSTR_TIME_PARAM - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_TIME_PARAM - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(message-digest-key|) <1-255> md5 KEY", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTH_MD5 - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|)", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_SIMPLE - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|) (message-digest|null) " - * "(message-digest-key|) <1-255> md5 KEY", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_ALL - * VLINK_HELPSTR_AUTH_MD5 - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|) " - * "(authentication-key|) AUTH_KEY", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_SIMPLE - * VLINK_HELPSTR_AUTH_SIMPLE - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication-key|) AUTH_KEY", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTH_SIMPLE - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|) (message-digest|null)", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_ALL - * - * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " - * "(authentication|) (message-digest|null) " - * "(authentication-key|) AUTH_KEY", - * NO_STR - * VLINK_HELPSTR_IPADDR - * VLINK_HELPSTR_AUTHTYPE_ALL - * VLINK_HELPSTR_AUTH_SIMPLE - * - */ DEFUN (no_ospf_area_vlink, no_ospf_area_vlink_cmd, - "no area virtual-link A.B.C.D", + "area virtual-link A.B.C.D " + "[authentication] [] " + "[arg[0]) { case 'a': - if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) + if (i > 2 || strncmp (argv[i]->text, "authentication-", 15) == 0) { /* authentication-key - this option can occur anywhere on command line. At start of command line @@ -1487,7 +1344,7 @@ DEFUN (no_ospf_area_vlink, memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); vl_config.auth_key = auth_key; } - else if (strncmp (argv[i], "authentication", 14) == 0) + else if (strncmp (argv[i]->text, "authentication", 14) == 0) { /* authentication - this option can only occur at start of command line */ @@ -1499,12 +1356,92 @@ DEFUN (no_ospf_area_vlink, /* message-digest-key */ /* Delete one key */ i++; - vl_config.crypto_key_id = strtol (argv[i], NULL, 10); + vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); if (vl_config.crypto_key_id < 0) return CMD_WARNING; vl_config.md5_key = NULL; break; + } + } + + + /* Action configuration */ + + return ospf_vl_set (ospf, &vl_config); +} + +DEFUN (no_ospf_area_vlink_intervals, + no_ospf_area_vlink_intervals_cmd, + "area virtual-link A.B.C.D " + "[ (1-65535)] " + "[ (1-65535)] " + "[ (1-65535)] " + "[ (1-65535)] ", + VLINK_HELPSTR_IPADDR + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM + VLINK_HELPSTR_TIME_PARAM) +{ + int idx_ipv4_number = 2; + int idx_ipv4 = 4; + struct ospf *ospf = vty->index; + struct ospf_area *area; + struct ospf_vl_config_data vl_config; + struct ospf_vl_data *vl_data = NULL; + int i; + int ret, format; + + if (!ospf) + return CMD_SUCCESS; + + ospf_vl_config_data_init(&vl_config, vty); + + ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &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[idx_ipv4]->arg, &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 <=5) + { + /* Basic VLink no command */ + /* Thats all folks! - BUGS B. strikes again!!!*/ + if ((vl_data = ospf_vl_lookup (ospf, 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=6; i < argc; i++) + { + /* vty_out (vty, "argv[%d] - %s%s", i, argv[i]->arg, VTY_NEWLINE); */ + + switch (argv[i]->arg[0]) + { + case 'h': /* Hello interval */ vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; @@ -1534,31 +1471,6 @@ DEFUN (no_ospf_area_vlink, return ospf_vl_set (ospf, &vl_config); } - - - - - - - - - - - - - - - - - - - - - - - - - DEFUN (ospf_area_shortcut, ospf_area_shortcut_cmd, "area shortcut ", @@ -1749,7 +1661,7 @@ DEFUN (no_ospf_area_stub_no_summary, } static int -ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], +ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv, int nosum) { struct ospf *ospf = vty->index; @@ -1759,7 +1671,7 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); + VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg); ret = ospf_area_nssa_set (ospf, area_id); if (ret == 0) @@ -1771,13 +1683,13 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], if (argc > 1) { - if (strncmp (argv[1], "translate-c", 11) == 0) + if (strncmp (argv[3]->text, "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) + else if (strncmp (argv[3]->text, "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) + else if (strncmp (argv[3]->text, "translate-a", 11) == 0) ospf_area_nssa_translator_role_set (ospf, area_id, OSPF_NSSA_ROLE_ALWAYS); } @@ -1849,29 +1761,19 @@ DEFUN (ospf_area_nssa_no_summary, return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}", - * NO_STR - * "OSPF area parameters\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * "Configure OSPF area as nssa\n" - * "Configure NSSA-ABR for translate election (default)\n" - * "Configure NSSA-ABR to never translate\n" - * "Configure NSSA-ABR to always translate\n" - * "Do not inject inter-area routes into nssa\n" - * - */ DEFUN (no_ospf_area_nssa, no_ospf_area_nssa_cmd, - "no area nssa", + "no area nssa [ [no-summary]]", NO_STR "OSPF area parameters\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n" - "Configure OSPF area as nssa\n") -{ + "Configure OSPF area as nssa\n" + "Configure NSSA-ABR for translate election (default)\n" + "Configure NSSA-ABR to never translate\n" + "Configure NSSA-ABR to always translate\n" + "Do not inject inter-area routes into nssa\n") + { int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct in_addr area_id; @@ -2009,7 +1911,7 @@ DEFUN (ospf_area_export_list, VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - ospf_area_export_list_set (ospf, area, argv[1]); + ospf_area_export_list_set (ospf, area, argv[3]->arg); return CMD_SUCCESS; } @@ -2066,7 +1968,7 @@ DEFUN (ospf_area_import_list, VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - ospf_area_import_list_set (ospf, area, argv[1]); + ospf_area_import_list_set (ospf, area, argv[3]->arg); return CMD_SUCCESS; } @@ -2436,13 +2338,6 @@ DEFUN (no_ospf_log_adjacency_changes_detail, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ospf rfc1583compatibility", - * "OSPF specific commands\n" - * "Enable the RFC1583Compatibility flag\n" - * - */ DEFUN (ospf_compatible_rfc1583, ospf_compatible_rfc1583_cmd, "compatible rfc1583", @@ -2462,14 +2357,6 @@ DEFUN (ospf_compatible_rfc1583, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf rfc1583compatibility", - * NO_STR - * "OSPF specific commands\n" - * "Disable the RFC1583Compatibility flag\n" - * - */ DEFUN (no_ospf_compatible_rfc1583, no_ospf_compatible_rfc1583_cmd, "no compatible rfc1583", @@ -2490,7 +2377,18 @@ DEFUN (no_ospf_compatible_rfc1583, return CMD_SUCCESS; } +ALIAS (ospf_compatible_rfc1583, + ospf_rfc1583_flag_cmd, + "ospf rfc1583compatibility", + "OSPF specific commands\n" + "Enable the RFC1583Compatibility flag\n") +ALIAS (no_ospf_compatible_rfc1583, + no_ospf_rfc1583_flag_cmd, + "no ospf rfc1583compatibility", + NO_STR + "OSPF specific commands\n" + "Disable the RFC1583Compatibility flag\n") static int ospf_timers_spf_set (struct vty *vty, unsigned int delay, @@ -2538,25 +2436,15 @@ DEFUN (ospf_timers_min_ls_interval, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no timers throttle lsa all <0-5000>", - * NO_STR - * "Adjust routing timers\n" - * "Throttling adaptive timer\n" - * "LSA delay between transmissions\n" - * "All LSA types\n" - * "Delay (msec) between sending LSAs\n" - * - */ DEFUN (no_ospf_timers_min_ls_interval, no_ospf_timers_min_ls_interval_cmd, - "no timers throttle lsa all", + "no timers throttle lsa all [(0-5000)]", NO_STR "Adjust routing timers\n" "Throttling adaptive timer\n" "LSA delay between transmissions\n" - "All LSA types\n") + "All LSA types\n" + "Delay (msec) between sending LSAs\n") { struct ospf *ospf = vty->index; ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; @@ -2593,23 +2481,14 @@ DEFUN (ospf_timers_min_ls_arrival, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no timers lsa arrival <0-1000>", - * NO_STR - * "Adjust routing timers\n" - * "Throttling link state advertisement delays\n" - * "OSPF minimum arrival interval delay\n" - * "Delay (msec) between accepted LSAs\n" - * - */ DEFUN (no_ospf_timers_min_ls_arrival, no_ospf_timers_min_ls_arrival_cmd, - "no timers lsa arrival", + "no timers lsa arrival [(0-1000)]", NO_STR "Adjust routing timers\n" "Throttling link state advertisement delays\n" - "OSPF minimum arrival interval delay\n") + "OSPF minimum arrival interval delay\n" + "Delay (msec) between accepted LSAs\n") { struct ospf *ospf = vty->index; @@ -2650,26 +2529,17 @@ DEFUN (ospf_timers_throttle_spf, return ospf_timers_spf_set (vty, delay, hold, max); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no timers throttle spf <0-600000> <0-600000> <0-600000>", - * NO_STR - * "Adjust routing timers\n" - * "Throttling adaptive timer\n" - * "OSPF SPF timers\n" - * "Delay (msec) from first change received till SPF calculation\n" - * "Initial hold time (msec) between consecutive SPF calculations\n" - * "Maximum hold time (msec)\n" - * - */ DEFUN (no_ospf_timers_throttle_spf, no_ospf_timers_throttle_spf_cmd, - "no timers throttle spf", + "no timers throttle spf [(0-600000)(0-600000)(0-600000)]", NO_STR "Adjust routing timers\n" "Throttling adaptive timer\n" - "OSPF SPF timers\n") -{ + "OSPF SPF timers\n" + "Delay (msec) from first change received till SPF calculation\n" + "Initial hold time (msec) between consecutive SPF calculations\n" + "Maximum hold time (msec)\n") + { return ospf_timers_spf_set (vty, OSPF_SPF_DELAY_DEFAULT, OSPF_SPF_HOLDTIME_DEFAULT, @@ -2705,23 +2575,14 @@ DEFUN (ospf_timers_lsa, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no timers lsa min-arrival <0-600000>", - * NO_STR - * "Adjust routing timers\n" - * "OSPF LSA timers\n" - * "Minimum delay in receiving new version of a LSA\n" - * "Delay in milliseconds\n" - * - */ DEFUN (no_ospf_timers_lsa, no_ospf_timers_lsa_cmd, - "no timers lsa min-arrival", + "no timers lsa min-arrival [(0-600000)]", NO_STR "Adjust routing timers\n" "OSPF LSA timers\n" - "Minimum delay in receiving new version of a LSA\n") + "Minimum delay in receiving new version of a LSA\n" + "Delay in milliseconds\n") { unsigned int minarrival; struct ospf *ospf = vty->index; @@ -2729,9 +2590,9 @@ DEFUN (no_ospf_timers_lsa, if (!ospf) return CMD_SUCCESS; - if (argc) + if (argc > 4) { - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); + VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[4]->arg); if (ospf->min_ls_arrival != minarrival || minarrival == OSPF_MIN_LS_ARRIVAL) @@ -2743,32 +2604,19 @@ DEFUN (no_ospf_timers_lsa, return CMD_SUCCESS; } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", - * NEIGHBOR_STR - * "Neighbor IP address\n" - * "Neighbor Priority\n" - * "Priority\n" - * "Dead Neighbor Polling interval\n" - * "Seconds\n" - * - * "neighbor A.B.C.D priority <0-255>", - * NEIGHBOR_STR - * "Neighbor IP address\n" - * "Neighbor Priority\n" - * "Seconds\n" - * - */ DEFUN (ospf_neighbor, ospf_neighbor_cmd, - "neighbor A.B.C.D", + "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]", NEIGHBOR_STR - "Neighbor IP address\n") + "Neighbor IP address\n" + "Neighbor Priority\n" + "Priority\n" + "Dead Neighbor Polling interval\n" + "Seconds\n") { int idx_ipv4 = 1; + int idx_pri = 3; + int idx_poll = 5; struct ospf *ospf = vty->index; struct in_addr nbr_addr; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; @@ -2779,44 +2627,36 @@ DEFUN (ospf_neighbor, VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); - 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); + VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 0, 255); + + if (argc > 4) + VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 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_priority_set (ospf, nbr_addr, priority); + + if (argc > 4) ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); return CMD_SUCCESS; } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", - * NEIGHBOR_STR - * "Neighbor address\n" - * "OSPF dead-router polling interval\n" - * "Seconds\n" - * "OSPF priority of non-broadcast neighbor\n" - * "Priority\n" - * - */ DEFUN (ospf_neighbor_poll_interval, ospf_neighbor_poll_interval_cmd, - "neighbor A.B.C.D poll-interval (1-65535)", + "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", NEIGHBOR_STR "Neighbor IP address\n" "Dead Neighbor Polling interval\n" - "Seconds\n") -{ + "Seconds\n" + "OSPF priority of non-broadcast neighbor\n" + "Priority\n") + { int idx_ipv4 = 1; - int idx_number = 3; + int idx_poll = 3; + int idx_pri = 5; struct ospf *ospf = vty->index; struct in_addr nbr_addr; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; @@ -2827,63 +2667,30 @@ DEFUN (ospf_neighbor_poll_interval, VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); - if (argc > 1) - VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_number]->arg, 1, 65535); + VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); - if (argc > 2) - VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); + if (argc > 4) + VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 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_poll_interval_set (ospf, nbr_addr, interval); + + if (argc > 4) ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", - * NO_STR - * NEIGHBOR_STR - * "Neighbor IP address\n" - * "Neighbor Priority\n" - * "Priority\n" - * "Dead Neighbor Polling interval\n" - * "Seconds\n" - * - * "no neighbor A.B.C.D priority <0-255>", - * NO_STR - * NEIGHBOR_STR - * "Neighbor IP address\n" - * "Neighbor Priority\n" - * "Priority\n" - * - * "no neighbor A.B.C.D poll-interval <1-65535>", - * NO_STR - * NEIGHBOR_STR - * "Neighbor IP address\n" - * "Dead Neighbor Polling interval\n" - * "Seconds\n" - * - * "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", - * NO_STR - * NEIGHBOR_STR - * "Neighbor IP address\n" - * "Dead Neighbor Polling interval\n" - * "Seconds\n" - * "OSPF priority of non-broadcast neighbor\n" - * "Priority\n" - * - */ DEFUN (no_ospf_neighbor, no_ospf_neighbor_cmd, - "no neighbor A.B.C.D", + "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]", NO_STR NEIGHBOR_STR - "Neighbor IP address\n") + "Neighbor IP address\n" + "Neighbor Priority\n" + "Priority\n" + "Dead Neighbor Polling interval\n" + "Seconds\n") { int idx_ipv4 = 2; struct ospf *ospf = vty->index; @@ -2899,9 +2706,30 @@ DEFUN (no_ospf_neighbor, return CMD_SUCCESS; } +DEFUN (no_ospf_neighbor_poll, + no_ospf_neighbor_poll_cmd, + "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", + NO_STR + NEIGHBOR_STR + "Neighbor IP address\n" + "Dead Neighbor Polling interval\n" + "Seconds\n" + "Neighbor Priority\n" + "Priority\n") +{ + int idx_ipv4 = 2; + struct ospf *ospf = vty->index; + struct in_addr nbr_addr; + + if (!ospf) + return CMD_SUCCESS; + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); + (void)ospf_nbr_nbma_unset (ospf, nbr_addr); + return CMD_SUCCESS; +} DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, @@ -2925,16 +2753,9 @@ DEFUN (ospf_refresh_timer, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no refresh timer", - * "Adjust refresh parameters\n" - * "Unset refresh timer\n" - * - */ DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, - "no refresh timer (10-1800)", + "no refresh timer [(10-1800)]", "Adjust refresh parameters\n" "Unset refresh timer\n" "Timer value in seconds\n") @@ -2995,21 +2816,13 @@ DEFUN (ospf_auto_cost_reference_bandwidth, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no auto-cost reference-bandwidth <1-4294967>", - * NO_STR - * "Calculate OSPF interface cost according to bandwidth\n" - * "Use reference bandwidth method to assign OSPF cost\n" - * "The reference bandwidth in terms of Mbits per second\n" - * - */ DEFUN (no_ospf_auto_cost_reference_bandwidth, no_ospf_auto_cost_reference_bandwidth_cmd, - "no auto-cost reference-bandwidth", + "no auto-cost reference-bandwidth [(1-4294967)]", NO_STR "Calculate OSPF interface cost according to bandwidth\n" - "Use reference bandwidth method to assign OSPF cost\n") + "Use reference bandwidth method to assign OSPF cost\n" + "The reference bandwidth in terms of Mbits per second\n") { struct ospf *ospf = vty->index; struct listnode *node, *nnode; @@ -3031,14 +2844,6 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "write-multiplier <1-100>", - * "Write multiplier\n" - * "Maximum number of interface serviced per write\n" - * - */ DEFUN (ospf_write_multiplier, ospf_write_multiplier_cmd, "ospf write-multiplier (1-100)", @@ -3046,13 +2851,18 @@ DEFUN (ospf_write_multiplier, "Write multiplier\n" "Maximum number of interface serviced per write\n") { - int idx_number = 2; + int idx_number; struct ospf *ospf = vty->index; u_int32_t write_oi_count; if (!ospf) return CMD_SUCCESS; + if (argc == 3) + idx_number = 2; + else + idx_number = 1; + write_oi_count = strtol (argv[idx_number]->arg, NULL, 10); if (write_oi_count < 1 || write_oi_count > 100) { @@ -3064,19 +2874,12 @@ DEFUN (ospf_write_multiplier, return CMD_SUCCESS; } +ALIAS (ospf_write_multiplier, + write_multiplier_cmd, + "write-multiplier (1-100)", + "Write multiplier\n" + "Maximum number of interface serviced per write\n") -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no write-multiplier", - * NO_STR - * "Write multiplier\n" - * - * "no write-multiplier <1-100>", - * NO_STR - * "Write multiplier\n" - * "Maximum number of interface serviced per write\n" - * - */ DEFUN (no_ospf_write_multiplier, no_ospf_write_multiplier_cmd, "no ospf write-multiplier (1-100)", @@ -3094,7 +2897,12 @@ DEFUN (no_ospf_write_multiplier, return CMD_SUCCESS; } - +ALIAS (no_ospf_write_multiplier, + no_write_multiplier_cmd, + "no write-multiplier (1-100)", + NO_STR + "Write multiplier\n" + "Maximum number of interface serviced per write\n") const char *ospf_abr_type_descr_str[] = { @@ -3989,7 +3797,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface static int show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, - const char **argv, int iface_argv, u_char use_json) + struct cmd_token **argv, int iface_argv, u_char use_json) { struct interface *ifp; struct listnode *node; @@ -4024,7 +3832,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, } } } - else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0) + else if (argv[iface_argv] && strcmp(argv[iface_argv]->arg, "json") == 0) { if (!use_json) { @@ -4046,7 +3854,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, else { /* Interface name is specified. */ - if ((ifp = if_lookup_by_name (argv[iface_argv])) == NULL) + if ((ifp = if_lookup_by_name (argv[iface_argv]->arg)) == NULL) { if (use_json) json_object_boolean_true_add(json, "noSuchIface"); @@ -4386,7 +4194,7 @@ DEFUN (show_ip_ospf_instance_neighbor_all, static int show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, - const char **argv, u_char use_json) + struct cmd_token **argv, u_char use_json) { struct interface *ifp; struct route_node *rn; @@ -4406,7 +4214,7 @@ show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_ba VTY_NEWLINE, VTY_NEWLINE); } - ifp = if_lookup_by_name (argv[arg_base]); + ifp = if_lookup_by_name (argv[arg_base]->arg); if (!ifp) { if (use_json) @@ -4756,7 +4564,7 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, static int show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, - int arg_base, const char **argv, u_char use_json) + int arg_base, struct cmd_token **argv, u_char use_json) { struct listnode *node; struct ospf_neighbor *nbr; @@ -4777,7 +4585,7 @@ show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, VTY_NEWLINE, VTY_NEWLINE); } - ret = inet_aton (argv[arg_base], &router_id); + ret = inet_aton (argv[arg_base]->arg, &router_id); if (!ret) { if (!use_json) @@ -5040,7 +4848,7 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all, static int show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, - int arg_base, const char **argv, u_char use_json) + int arg_base, struct cmd_token **argv, u_char use_json) { struct ospf_interface *oi; struct interface *ifp; @@ -5060,7 +4868,7 @@ show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, VTY_NEWLINE, VTY_NEWLINE); } - ifp = if_lookup_by_name (argv[arg_base]); + ifp = if_lookup_by_name (argv[arg_base]->arg); if (!ifp) { if (!use_json) @@ -5444,7 +5252,6 @@ show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) return 0; } - #if 0 static int show_as_external_lsa_stdvty (struct ospf_lsa *lsa) @@ -5470,7 +5277,6 @@ show_as_external_lsa_stdvty (struct ospf_lsa *lsa) return 0; } #endif - /* Show AS-NSSA-LSA detail information. */ static int show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) @@ -5770,8 +5576,9 @@ show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) static int show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, - int arg_base, int argc, const char **argv) + int arg_base, int argc, struct cmd_token **argv) { + int idx_type = 4; int type, ret; struct in_addr id, adv_router; @@ -5783,64 +5590,64 @@ show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); /* Show all LSA. */ - if (argc == arg_base + 0) + if (argc == arg_base + 4) { show_ip_ospf_database_summary (vty, ospf, 0); return CMD_SUCCESS; } /* Set database type to show. */ - if (strncmp (argv[arg_base + 0], "r", 1) == 0) + if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) type = OSPF_ROUTER_LSA; - else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) type = OSPF_NETWORK_LSA; - else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) type = OSPF_AS_NSSA_LSA; - else if (strncmp (argv[arg_base + 0], "su", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "su", 2) == 0) type = OSPF_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "a", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) type = OSPF_ASBR_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) type = OSPF_AS_EXTERNAL_LSA; - else if (strncmp (argv[arg_base + 0], "se", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "se", 2) == 0) { show_ip_ospf_database_summary (vty, ospf, 1); return CMD_SUCCESS; } - else if (strncmp (argv[arg_base + 0], "m", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "m", 1) == 0) { show_ip_ospf_database_maxage (vty, ospf); return CMD_SUCCESS; } - else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) type = OSPF_OPAQUE_LINK_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) type = OSPF_OPAQUE_AREA_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) type = OSPF_OPAQUE_AS_LSA; else return CMD_WARNING; /* `show ip ospf database LSA'. */ - if (argc == arg_base + 1) + if (argc == arg_base + 5) show_lsa_detail (vty, ospf, type, NULL, NULL); - else if (argc >= arg_base + 2) + else if (argc >= arg_base + 6) { - ret = inet_aton (argv[arg_base + 1], &id); + ret = inet_aton (argv[arg_base + 5]->arg, &id); if (!ret) return CMD_WARNING; /* `show ip ospf database LSA ID'. */ - if (argc == arg_base + 2) + if (argc == arg_base + 6) show_lsa_detail (vty, ospf, type, &id, NULL); /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ - else if (argc == arg_base + 3) + else if (argc == arg_base + 7) { - if (strncmp (argv[arg_base + 2], "s", 1) == 0) + if (strncmp (argv[arg_base + 6]->text, "s", 1) == 0) adv_router = ospf->router_id; else { - ret = inet_aton (argv[arg_base + 2], &adv_router); + ret = inet_aton (argv[arg_base + 7]->arg, &adv_router); if (!ret) return CMD_WARNING; } @@ -5851,53 +5658,18 @@ show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) A.B.C.D", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Link State ID (as an IP address)\n" - * - * "show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) A.B.C.D (self-originate|)", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Link State ID (as an IP address)\n" - * "Self-originated link states\n" - * "\n" - * - * "show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) A.B.C.D adv-router A.B.C.D", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Link State ID (as an IP address)\n" - * "Advertising Router link states\n" - * "Advertising Router (as an IP address)\n" - * - * "show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as|max-age|self-originate)", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "LSAs in MaxAge list\n" - * "Self-originated link states\n" - * - */ DEFUN (show_ip_ospf_database, show_ip_ospf_database_cmd, - "show ip ospf database", + "show ip ospf database [ [A.B.C.D []]]", SHOW_STR IP_STR "OSPF information\n" - "Database summary\n") + "Database summary\n" + OSPF_LSA_TYPES_DESC + "Link State ID (as an IP address)\n" + "Self-originated link states\n" + "Advertising Router link states\n" + "Advertising Router (as an IP address)\n") { struct ospf *ospf; @@ -5907,62 +5679,37 @@ DEFUN (show_ip_ospf_database, return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); } +DEFUN (show_ip_ospf_database_max, + show_ip_ospf_database_max_cmd, + "show ip ospf database ", + SHOW_STR + IP_STR + "OSPF information\n" + "Database summary\n" + "LSAs in MaxAge list\n" + "Self-originated link states\n") +{ + struct ospf *ospf; + if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) + return CMD_SUCCESS; + return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); +} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) A.B.C.D adv-router A.B.C.D", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Instance ID\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Link State ID (as an IP address)\n" - * "Advertising Router link states\n" - * "Advertising Router (as an IP address)\n" - * - * "show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) A.B.C.D", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Instance ID\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Link State ID (as an IP address)\n" - * - * "show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) A.B.C.D (self-originate|)", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Instance ID\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Link State ID (as an IP address)\n" - * "Self-originated link states\n" - * "\n" - * - * "show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as|max-age|self-originate)", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Instance ID\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "LSAs in MaxAge list\n" - * "Self-originated link states\n" - * - */ DEFUN (show_ip_ospf_instance_database, show_ip_ospf_instance_database_cmd, - "show ip ospf (1-65535) database", + "show ip ospf (1-65535) database [ [A.B.C.D []]]", SHOW_STR IP_STR "OSPF information\n" "Instance ID\n" - "Database summary\n") + "Database summary\n" + OSPF_LSA_TYPES_DESC + "Link State ID (as an IP address)\n" + "Self-originated link states\n" + "Advertising Router link states\n" + "Advertising Router (as an IP address)\n") { int idx_number = 3; struct ospf *ospf; @@ -5976,15 +5723,35 @@ DEFUN (show_ip_ospf_instance_database, return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); } +DEFUN (show_ip_ospf_instance_database_max, + show_ip_ospf_instance_database_max_cmd, + "show ip ospf (1-65535) database ", + SHOW_STR + IP_STR + "OSPF information\n" + "Instance ID\n" + "Database summary\n" + "LSAs in MaxAge list\n" + "Self-originated link states\n") +{ + int idx_number = 3; + struct ospf *ospf; + u_short instance = 0; + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); + if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) + return CMD_SUCCESS; + return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); +} static int show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, - int arg_base, int argc, const char **argv) + int arg_base, int argc, struct cmd_token **argv) { + int idx_type = 4; int type, ret; struct in_addr adv_router; @@ -5995,37 +5762,37 @@ show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); - if (argc != arg_base + 2) + if (argc != arg_base + 7) return CMD_WARNING; /* Set database type to show. */ - if (strncmp (argv[arg_base + 0], "r", 1) == 0) + if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) type = OSPF_ROUTER_LSA; - else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) type = OSPF_NETWORK_LSA; - else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) type = OSPF_AS_NSSA_LSA; - else if (strncmp (argv[arg_base + 0], "s", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "s", 1) == 0) type = OSPF_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "a", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) type = OSPF_ASBR_SUMMARY_LSA; - else if (strncmp (argv[arg_base + 0], "e", 1) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) type = OSPF_AS_EXTERNAL_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) type = OSPF_OPAQUE_LINK_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) type = OSPF_OPAQUE_AREA_LSA; - else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) + else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) type = OSPF_OPAQUE_AS_LSA; else return CMD_WARNING; /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ - if (strncmp (argv[arg_base + 1], "s", 1) == 0) + if (strncmp (argv[arg_base + 5]->text, "s", 1) == 0) adv_router = ospf->router_id; else { - ret = inet_aton (argv[arg_base + 1], &adv_router); + ret = inet_aton (argv[arg_base + 6]->arg, &adv_router); if (!ret) return CMD_WARNING; } @@ -6035,20 +5802,9 @@ show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip ospf database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) (self-originate|)", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Self-originated link states\n" - * - */ DEFUN (show_ip_ospf_database_type_adv_router, show_ip_ospf_database_type_adv_router_cmd, - "show ip ospf database adv-router A.B.C.D", + "show ip ospf database ", SHOW_STR IP_STR "OSPF information\n" @@ -6065,22 +5821,9 @@ DEFUN (show_ip_ospf_database_type_adv_router, return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip ospf <1-65535> database (asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as) (self-originate|)", - * SHOW_STR - * IP_STR - * "OSPF information\n" - * "Instance ID\n" - * "Database summary\n" - * OSPF_LSA_TYPES_DESC - * "Self-originated link states\n" - * - */ DEFUN (show_ip_ospf_instance_database_type_adv_router, show_ip_ospf_instance_database_type_adv_router_cmd, - "show ip ospf (1-65535) database adv-router A.B.C.D", + "show ip ospf (1-65535) database ", SHOW_STR IP_STR "OSPF information\n" @@ -6102,26 +5845,15 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf authentication (null|message-digest)", - * "IP Information\n" - * "OSPF interface commands\n" - * "Enable authentication on this interface\n" - * "Use null authentication\n" - * "Use message-digest authentication\n" - * - */ DEFUN (ip_ospf_authentication_args, ip_ospf_authentication_args_addr_cmd, - "ip ospf authentication A.B.C.D", + "ip ospf authentication [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Enable authentication on this interface\n" "Use null authentication\n" "Use message-digest authentication\n" - "Address of interface") + "Address of interface\n") { int idx_encryption = 3; int idx_ipv4 = 4; @@ -6133,7 +5865,7 @@ DEFUN (ip_ospf_authentication_args, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -6167,18 +5899,9 @@ DEFUN (ip_ospf_authentication_args, return CMD_WARNING; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf authentication", - * "IP Information\n" - * "OSPF interface commands\n" - * "Enable authentication on this interface\n" - * - */ DEFUN (ip_ospf_authentication, ip_ospf_authentication_addr_cmd, - "ip ospf authentication A.B.C.D", + "ip ospf authentication [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Enable authentication on this interface\n" @@ -6193,7 +5916,7 @@ DEFUN (ip_ospf_authentication, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 4) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -6213,21 +5936,9 @@ DEFUN (ip_ospf_authentication, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf authentication (null|message-digest)", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Enable authentication on this interface\n" - * "Use null authentication\n" - * "Use message-digest authentication\n" - * - */ DEFUN (no_ip_ospf_authentication_args, no_ip_ospf_authentication_args_addr_cmd, - "no ip ospf authentication A.B.C.D", + "no ip ospf authentication [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6248,7 +5959,7 @@ DEFUN (no_ip_ospf_authentication_args, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 6) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -6320,19 +6031,9 @@ DEFUN (no_ip_ospf_authentication_args, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf authentication", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Enable authentication on this interface\n" - * - */ DEFUN (no_ip_ospf_authentication, no_ip_ospf_authentication_addr_cmd, - "no ip ospf authentication A.B.C.D", + "no ip ospf authentication [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6349,7 +6050,7 @@ DEFUN (no_ip_ospf_authentication, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -6413,19 +6114,9 @@ DEFUN (no_ip_ospf_authentication, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf authentication-key AUTH_KEY", - * "IP Information\n" - * "OSPF interface commands\n" - * "Authentication password (key)\n" - * "The OSPF password (key)" - * - */ DEFUN (ip_ospf_authentication_key, ip_ospf_authentication_key_addr_cmd, - "ip ospf authentication-key AUTH_KEY A.B.C.D", + "ip ospf authentication-key AUTH_KEY [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Authentication password (key)\n" @@ -6441,9 +6132,9 @@ DEFUN (ip_ospf_authentication_key, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6456,58 +6147,36 @@ DEFUN (ip_ospf_authentication_key, } memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); - strncpy ((char *) params->auth_simple, argv[idx_ipv4]->arg, OSPF_AUTH_SIMPLE_SIZE); + strncpy ((char *) params->auth_simple, argv[3]->arg, OSPF_AUTH_SIMPLE_SIZE); SET_IF_PARAM (params, auth_simple); return CMD_SUCCESS; } -ALIAS_HIDDEN (ip_ospf_authentication_key, +DEFUN_HIDDEN (ospf_authentication_key, ospf_authentication_key_cmd, "ospf authentication-key AUTH_KEY", "OSPF interface commands\n" "Authentication password (key)\n" "The OSPF password (key)") +{ + struct interface *ifp; + struct ospf_if_params *params; -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf authentication-key AUTH_KEY A.B.C.D", - * NO_STR - * "OSPF interface commands\n" - * "Authentication password (key)\n" - * "The OSPF password (key)\n" - * "Address of interface" - * - * "no ospf authentication-key AUTH_KEY", - * NO_STR - * "OSPF interface commands\n" - * "Authentication password (key)\n" - * "The OSPF password (key)\n" - * - * "no ip ospf authentication-key", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Authentication password (key)\n" - * - * "no ip ospf authentication-key AUTH_KEY", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Authentication password (key)\n" - * - * "no ospf authentication-key", - * NO_STR - * "OSPF interface commands\n" - * "Authentication password (key)\n" - * - */ -DEFUN (no_ip_ospf_authentication_key, - no_ip_ospf_authentication_key_authkey_addr_cmd, - "no ip ospf authentication-key AUTH_KEY A.B.C.D", + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); + strncpy ((char *) params->auth_simple, argv[2]->arg, OSPF_AUTH_SIMPLE_SIZE); + SET_IF_PARAM (params, auth_simple); + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_authentication_key, + no_ospf_authentication_key_authkey_addr_cmd, + "no ospf authentication-key [AUTH_KEY [A.B.C.D]]", NO_STR - "IP Information\n" "OSPF interface commands\n" "Authentication password (key)\n" "The OSPF password (key)") @@ -6520,9 +6189,9 @@ DEFUN (no_ip_ospf_authentication_key, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6547,25 +6216,53 @@ DEFUN (no_ip_ospf_authentication_key, return CMD_SUCCESS; } +DEFUN (no_ip_ospf_authentication_key, + no_ip_ospf_authentication_key_authkey_addr_cmd, + "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]", + NO_STR + "IP Information\n" + "OSPF interface commands\n" + "Authentication password (key)\n" + "The OSPF password (key)") +{ + struct interface *ifp; + struct in_addr addr; + struct ospf_if_params *params; + int ret; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + if (argc == 6) + { + ret = inet_aton(argv[5]->arg, &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; + } + memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); + UNSET_IF_PARAM (params, auth_simple); + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf message-digest-key <1-255> md5 KEY", - * "IP Information\n" - * "OSPF interface commands\n" - * "Message digest authentication password (key)\n" - * "Key ID\n" - * "Use MD5 algorithm\n" - * "The OSPF password (key)" - * - */ DEFUN (ip_ospf_message_digest_key, ip_ospf_message_digest_key_addr_cmd, - "ip ospf message-digest-key (1-255) md5 KEY A.B.C.D", + "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Message digest authentication password (key)\n" @@ -6586,9 +6283,9 @@ DEFUN (ip_ospf_message_digest_key, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 3) + if (argc == 7) { - ret = inet_aton(argv[2], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6619,7 +6316,7 @@ DEFUN (ip_ospf_message_digest_key, } -ALIAS_HIDDEN (ip_ospf_message_digest_key, +DEFUN_HIDDEN (ospf_message_digest_key, ospf_message_digest_key_cmd, "ospf message-digest-key <1-255> md5 KEY", "OSPF interface commands\n" @@ -6627,22 +6324,36 @@ ALIAS_HIDDEN (ip_ospf_message_digest_key, "Key ID\n" "Use MD5 algorithm\n" "The OSPF password (key)") +{ + int idx_number = 2; + struct interface *ifp; + struct crypt_key *ck; + u_char key_id; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + key_id = strtol (argv[idx_number]->arg, NULL, 10); + if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) + { + vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); + return CMD_WARNING; + } + + ck = ospf_crypt_key_new (); + ck->key_id = (u_char) key_id; + memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); + strncpy ((char *) ck->auth_key, argv[idx_number]->arg, OSPF_AUTH_MD5_SIZE); + + ospf_crypt_key_add (params->auth_crypt, ck); + SET_IF_PARAM (params, auth_crypt); + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf message-digest-key <1-255> md5 KEY", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Message digest authentication password (key)\n" - * "Key ID\n" - * "Use MD5 algorithm\n" - * "The OSPF password (key)" - * - */ DEFUN (no_ip_ospf_message_digest_key_md5, no_ip_ospf_message_digest_key_md5_addr_cmd, - "no ip ospf message-digest-key (1-255) md5 KEY A.B.C.D", + "no ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6663,9 +6374,9 @@ DEFUN (no_ip_ospf_message_digest_key_md5, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 3) + if (argc == 8) { - ret = inet_aton(argv[2], &addr); + ret = inet_aton(argv[7]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6697,26 +6408,64 @@ DEFUN (no_ip_ospf_message_digest_key_md5, return CMD_SUCCESS; } +DEFUN (no_ospf_message_digest_key, + no_ospf_message_digest_key_addr_cmd, + "no ospf message-digest-key (1-255) [A.B.C.D]", + NO_STR + "OSPF interface commands\n" + "Message digest authentication password (key)\n" + "Key ID\n" + "Address of interface") +{ + int idx_number = 3; + int idx_ipv4 = 4; + struct interface *ifp; + struct crypt_key *ck; + int key_id; + struct in_addr addr; + int ret; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &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; + } + + key_id = strtol (argv[idx_number]->arg, NULL, 10); + ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); + if (ck == NULL) + { + vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); + return CMD_WARNING; + } + + ospf_crypt_key_delete (params->auth_crypt, key_id); + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf message-digest-key <1-255>", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Message digest authentication password (key)\n" - * "Key ID\n" - * - * "no ospf message-digest-key <1-255>", - * NO_STR - * "OSPF interface commands\n" - * "Message digest authentication password (key)\n" - * "Key ID\n" - * - */ DEFUN (no_ip_ospf_message_digest_key, no_ip_ospf_message_digest_key_addr_cmd, - "no ip ospf message-digest-key (1-255) A.B.C.D", + "no ip ospf message-digest-key (1-255) [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6732,11 +6481,11 @@ DEFUN (no_ip_ospf_message_digest_key, struct in_addr addr; int ret; struct ospf_if_params *params; - + ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 6) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -6766,24 +6515,13 @@ DEFUN (no_ip_ospf_message_digest_key, ospf_free_if_params (ifp, addr); ospf_if_update_params (ifp, addr); } - + return CMD_SUCCESS; } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf cost <1-65535>", - * "IP Information\n" - * "OSPF interface commands\n" - * "Interface cost\n" - * "Cost" - * - */ DEFUN (ip_ospf_cost, ip_ospf_cost_u32_inet4_cmd, - "ip ospf cost (1-65535) A.B.C.D", + "ip ospf cost (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Interface cost\n" @@ -6797,7 +6535,7 @@ DEFUN (ip_ospf_cost, struct in_addr addr; int ret; struct ospf_if_params *params; - + params = IF_DEF_PARAMS (ifp); cost = strtol (argv[idx_number]->arg, NULL, 10); @@ -6809,7 +6547,7 @@ DEFUN (ip_ospf_cost, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -6831,45 +6569,103 @@ DEFUN (ip_ospf_cost, return CMD_SUCCESS; } - -ALIAS_HIDDEN (ip_ospf_cost, - ospf_cost_u32_cmd, - "ospf cost <1-65535>", - "OSPF interface commands\n" - "Interface cost\n" - "Cost") - -ALIAS_HIDDEN (ip_ospf_cost, +DEFUN_HIDDEN (ospf_cost, ospf_cost_u32_inet4_cmd, "ospf cost <1-65535> A.B.C.D", "OSPF interface commands\n" "Interface cost\n" "Cost\n" "Address of interface") +{ + int idx_number = 2; + int idx_ipv4 = 3; + struct interface *ifp = vty->index; + u_int32_t cost; + struct in_addr addr; + int ret; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + + cost = strtol (argv[idx_number]->arg, NULL, 10); + + /* cost range is <1-65535>. */ + if (cost < 1 || cost > 65535) + { + vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &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, output_cost_cmd); + params->output_cost_cmd = cost; + + ospf_if_recalculate_output_cost (ifp); + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_cost, + no_ospf_cost_inet4_cmd, + "no ospf cost [A.B.C.D]", + NO_STR + "OSPF interface commands\n" + "Interface cost\n" + "Address of interface") +{ + int idx_ipv4 = 3; + struct interface *ifp = vty->index; + struct in_addr addr; + int ret; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + if (argc == 4) + { + ret = inet_aton(argv[idx_ipv4]->arg, &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, output_cost_cmd); + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + ospf_if_recalculate_output_cost (ifp); + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf cost A.B.C.D", - * NO_STR - * "OSPF interface commands\n" - * "Interface cost\n" - * "Address of interface" - * - * "no ospf cost", - * NO_STR - * "OSPF interface commands\n" - * "Interface cost\n" - * - * "no ip ospf cost", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Interface cost\n" - * - */ DEFUN (no_ip_ospf_cost, no_ip_ospf_cost_inet4_cmd, - "no ip ospf cost A.B.C.D", + "no ip ospf cost [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -6881,11 +6677,11 @@ DEFUN (no_ip_ospf_cost, struct in_addr addr; int ret; struct ospf_if_params *params; - + ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -6913,43 +6709,78 @@ DEFUN (no_ip_ospf_cost, return CMD_SUCCESS; } +DEFUN (no_ospf_cost2, + no_ospf_cost_u32_cmd, + "no ospf cost [(1-65535) [A.B.C.D]]", + NO_STR + "OSPF interface commands\n" + "Interface cost\n" + "Cost\n" + "Address of interface\n") +{ + int idx_number = 3; + int idx_ipv4 = 4; + struct interface *ifp = vty->index; + struct in_addr addr; + u_int32_t cost; + int ret; + struct ospf_if_params *params; + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + /* According to the semantics we are mimicking "no ip ospf cost N" is + * always treated as "no ip ospf cost" regardless of the actual value + * of N already configured for the interface. Thus the first argument + * is always checked to be a number, but is ignored after that. + */ + cost = strtol (argv[idx_number]->arg, NULL, 10); + if (cost < 1 || cost > 65535) + { + vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &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, output_cost_cmd); + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + + ospf_if_recalculate_output_cost (ifp); + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf cost <1-65535>", - * NO_STR - * "OSPF interface commands\n" - * "Interface cost\n" - * "Cost" - * - * "no ospf cost <1-65535> A.B.C.D", - * NO_STR - * "OSPF interface commands\n" - * "Interface cost\n" - * "Cost\n" - * "Address of interface" - * - * "no ip ospf cost <1-65535> A.B.C.D", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Interface cost\n" - * "Cost\n" - * "Address of interface" - * - */ DEFUN (no_ip_ospf_cost2, no_ip_ospf_cost_u32_cmd, - "no ip ospf cost (1-65535)", + "no ip ospf cost (1-65535) [A.B.C.D]", NO_STR "IP Information\n" "OSPF interface commands\n" "Interface cost\n" - "Cost") + "Cost\n" + "Address of interface\n") { int idx_number = 4; + int idx_ipv4 = 5; struct interface *ifp = vty->index; struct in_addr addr; u_int32_t cost; @@ -6971,9 +6802,9 @@ DEFUN (no_ip_ospf_cost2, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7097,19 +6928,9 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf dead-interval <1-65535>", - * "IP Information\n" - * "OSPF interface commands\n" - * "Interval after which a neighbor is declared dead\n" - * "Seconds\n" - * - */ DEFUN (ip_ospf_dead_interval, ip_ospf_dead_interval_addr_cmd, - "ip ospf dead-interval (1-65535) A.B.C.D", + "ip ospf dead-interval (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Interval after which a neighbor is declared dead\n" @@ -7118,34 +6939,28 @@ DEFUN (ip_ospf_dead_interval, { int idx_number = 3; int idx_ipv4 = 4; - if (argc == 2) + if (argc == 5) return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, argv[idx_ipv4]->arg, NULL); else return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, NULL, NULL); } -ALIAS_HIDDEN (ip_ospf_dead_interval, +DEFUN_HIDDEN (ospf_dead_interval, ospf_dead_interval_cmd, "ospf dead-interval <1-65535>", "OSPF interface commands\n" "Interval after which a neighbor is declared dead\n" "Seconds\n") +{ + int idx_number = 2; + + return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, NULL, NULL); +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf dead-interval minimal hello-multiplier <1-10>", - * "IP Information\n" - * "OSPF interface commands\n" - * "Interval after which a neighbor is declared dead\n" - * "Minimal 1s dead-interval with fast sub-second hellos\n" - * "Hello multiplier factor\n" - * "Number of Hellos to send each second\n" - * - */ DEFUN (ip_ospf_dead_interval_minimal, ip_ospf_dead_interval_minimal_addr_cmd, - "ip ospf dead-interval minimal hello-multiplier (1-10) A.B.C.D", + "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Interval after which a neighbor is declared dead\n" @@ -7156,56 +6971,37 @@ DEFUN (ip_ospf_dead_interval_minimal, { int idx_number = 5; int idx_ipv4 = 6; - if (argc == 2) + if (argc == 7) return ospf_vty_dead_interval_set (vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg); else return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[idx_number]->arg); } +DEFUN (no_ospf_dead_interval, + no_ospf_dead_interval_cmd, + "no ospf dead-interval", + NO_STR + "OSPF interface commands\n" + "Interval after which a neighbor is declared dead\n") +{ + struct interface *ifp = vty->index; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + UNSET_IF_PARAM (params, v_wait); + params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; + + UNSET_IF_PARAM (params, fast_hello); + params->fast_hello = OSPF_FAST_HELLO_DEFAULT; + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf dead-interval", - * NO_STR - * "OSPF interface commands\n" - * "Interval after which a neighbor is declared dead\n" - * - * "no ip ospf dead-interval minimal hello-multiplier <1-10>", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Interval after which a neighbor is declared dead\n" - * "Minimal 1s dead-interval with fast sub-second hellos\n" - * "Hello multiplier factor\n" - * "Number of Hellos to send each second\n" - * - * "no ip ospf dead-interval <1-65535>", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Interval after which a neighbor is declared dead\n" - * "Seconds\n" - * - * "no ip ospf dead-interval", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Interval after which a neighbor is declared dead\n" - * - * "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Interval after which a neighbor is declared dead\n" - * "Minimal 1s dead-interval with fast sub-second hellos\n" - * "Hello multiplier factor\n" - * "Number of Hellos to send each second\n" - * "Address of interface\n" - * - */ DEFUN (no_ip_ospf_dead_interval, no_ip_ospf_dead_interval_addr_cmd, - "no ip ospf dead-interval (1-65535) A.B.C.D", + "no ip ospf dead-interval [[(1-65535)|] [A.B.C.D]]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7213,7 +7009,7 @@ DEFUN (no_ip_ospf_dead_interval, "Seconds\n" "Address of interface") { - int idx_ipv4 = 5; + int idx_ipv4 = argc - 1; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -7224,7 +7020,7 @@ DEFUN (no_ip_ospf_dead_interval, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argv[idx_ipv4]->type == IPV4_TKN) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -7273,23 +7069,9 @@ DEFUN (no_ip_ospf_dead_interval, return CMD_SUCCESS; } - - - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf hello-interval <1-65535>", - * "IP Information\n" - * "OSPF interface commands\n" - * "Time between HELLO packets\n" - * "Seconds\n" - * - */ DEFUN (ip_ospf_hello_interval, ip_ospf_hello_interval_addr_cmd, - "ip ospf hello-interval (1-65535) A.B.C.D", + "ip ospf hello-interval (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Time between HELLO packets\n" @@ -7315,7 +7097,7 @@ DEFUN (ip_ospf_hello_interval, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -7336,38 +7118,38 @@ DEFUN (ip_ospf_hello_interval, } -ALIAS_HIDDEN (ip_ospf_hello_interval, +DEFUN_HIDDEN (ospf_hello_interval, ospf_hello_interval_cmd, "ospf hello-interval <1-65535>", "OSPF interface commands\n" "Time between HELLO packets\n" "Seconds\n") +{ + int idx_number = 2; + struct interface *ifp = vty->index; + u_int32_t seconds; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + + seconds = strtol (argv[idx_number]->arg, NULL, 10); + + /* HelloInterval range is <1-65535>. */ + if (seconds < 1 || seconds > 65535) + { + vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, v_hello); + params->v_hello = seconds; + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf hello-interval <1-65535>", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Time between HELLO packets\n" - * "Seconds\n" - * - * "no ip ospf hello-interval", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Time between HELLO packets\n" - * - * "no ospf hello-interval <1-65535>", - * NO_STR - * "OSPF interface commands\n" - * "Time between HELLO packets\n" - * "Seconds\n" - * - */ DEFUN (no_ip_ospf_hello_interval, no_ip_ospf_hello_interval_addr_cmd, - "no ip ospf hello-interval (1-65535) A.B.C.D", + "no [ip] ospf hello-interval [(1-65535) [A.B.C.D]]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7384,7 +7166,10 @@ DEFUN (no_ip_ospf_hello_interval, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (strcmp (argv[1]->arg, "ip") == 0) + idx_ipv4 = 4; + + if (argc == idx_ipv4+1) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -7461,129 +7246,276 @@ DEFUN (ip_ospf_network, if (oi->state > ISM_Down) { - OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); - OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); + } + } + + return CMD_SUCCESS; +} + +DEFUN_HIDDEN (ospf_network, + ospf_network_cmd, + "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", + "OSPF interface commands\n" + "Network type\n" + "Specify OSPF broadcast multi-access network\n" + "Specify OSPF NBMA network\n" + "Specify OSPF point-to-multipoint network\n" + "Specify OSPF point-to-point network\n") +{ + int idx_network = 2; + 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[idx_network]->arg, "b", 1) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; + else if (strncmp (argv[idx_network]->arg, "n", 1) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; + else if (strncmp (argv[idx_network]->arg, "point-to-m", 10) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; + else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0) + IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; + + if (IF_DEF_PARAMS (ifp)->type == old_type) + return CMD_SUCCESS; + + SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + oi->type = IF_DEF_PARAMS (ifp)->type; + + if (oi->state > ISM_Down) + { + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); + } + } + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_network, + no_ospf_network_cmd, + "no ospf network []", + NO_STR + "OSPF interface commands\n" + "Network type\n" + "Specify OSPF broadcast multi-access network\n" + "Specify OSPF NBMA network\n" + "Specify OSPF point-to-multipoint network\n" + "Specify OSPF point-to-point network\n") + { + struct interface *ifp = vty->index; + int old_type = IF_DEF_PARAMS (ifp)->type; + struct route_node *rn; + + IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); + + if (IF_DEF_PARAMS (ifp)->type == old_type) + return CMD_SUCCESS; + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + oi->type = IF_DEF_PARAMS (ifp)->type; + + if (oi->state > ISM_Down) + { + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); + } + } + + return CMD_SUCCESS; +} + +DEFUN (no_ip_ospf_network, + no_ip_ospf_network_cmd, + "no ip ospf network []", + NO_STR + "IP Information\n" + "OSPF interface commands\n" + "Network type\n" + "Specify OSPF broadcast multi-access network\n" + "Specify OSPF NBMA network\n" + "Specify OSPF point-to-multipoint network\n" + "Specify OSPF point-to-point network\n") + { + struct interface *ifp = vty->index; + int old_type = IF_DEF_PARAMS (ifp)->type; + struct route_node *rn; + + IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); + + if (IF_DEF_PARAMS (ifp)->type == old_type) + return CMD_SUCCESS; + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + oi->type = IF_DEF_PARAMS (ifp)->type; + + if (oi->state > ISM_Down) + { + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); + OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); + } + } + + return CMD_SUCCESS; +} + +DEFUN (ip_ospf_priority, + ip_ospf_priority_addr_cmd, + "ip ospf priority (0-255) [A.B.C.D]", + "IP Information\n" + "OSPF interface commands\n" + "Router priority\n" + "Priority\n" + "Address of interface") +{ + int idx_number = 3; + int idx_ipv4 = 4; + struct interface *ifp = vty->index; + long priority; + struct route_node *rn; + struct in_addr addr; + int ret; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + + priority = strtol (argv[idx_number]->arg, NULL, 10); + + /* Router Priority range is <0-255>. */ + if (priority < 0 || priority > 255) + { + vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (argc == 5) + { + ret = inet_aton(argv[idx_ipv4]->arg, &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, priority); + params->priority = priority; + + for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) + { + struct ospf_interface *oi = rn->info; + + if (!oi) + continue; + + if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) + { + PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); } } return CMD_SUCCESS; } -ALIAS_HIDDEN (ip_ospf_network, - ospf_network_cmd, - "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", - "OSPF interface commands\n" - "Network type\n" - "Specify OSPF broadcast multi-access network\n" - "Specify OSPF NBMA network\n" - "Specify OSPF point-to-multipoint network\n" - "Specify OSPF point-to-point network\n") -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", - * NO_STR - * "OSPF interface commands\n" - * "Network type\n" - * "Specify OSPF broadcast multi-access network\n" - * "Specify OSPF NBMA network\n" - * "Specify OSPF point-to-multipoint network\n" - * "Specify OSPF point-to-point network\n" - * - * "no ospf network", - * NO_STR - * "OSPF interface commands\n" - * "Network type\n" - * - * "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Network type\n" - * "Specify OSPF broadcast multi-access network\n" - * "Specify OSPF NBMA network\n" - * "Specify OSPF point-to-multipoint network\n" - * "Specify OSPF point-to-point network\n" - * - */ -DEFUN (no_ip_ospf_network, - no_ip_ospf_network_cmd, - "no ip ospf network", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Network type\n") +DEFUN_HIDDEN (ospf_priority, + ospf_priority_cmd, + "ospf priority <0-255>", + "OSPF interface commands\n" + "Router priority\n" + "Priority\n") { + int idx_number = 2; struct interface *ifp = vty->index; - int old_type = IF_DEF_PARAMS (ifp)->type; + long priority; struct route_node *rn; + struct ospf_if_params *params; - IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); + params = IF_DEF_PARAMS (ifp); - if (IF_DEF_PARAMS (ifp)->type == old_type) - return CMD_SUCCESS; + priority = strtol (argv[idx_number]->arg, NULL, 10); + + /* Router Priority range is <0-255>. */ + if (priority < 0 || priority > 255) + { + vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, priority); + params->priority = priority; for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) { struct ospf_interface *oi = rn->info; if (!oi) - continue; - - oi->type = IF_DEF_PARAMS (ifp)->type; - - if (oi->state > ISM_Down) - { - OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); - OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); - } + continue; + + + if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) + { + PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + } } return CMD_SUCCESS; } - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf priority <0-255>", - * "IP Information\n" - * "OSPF interface commands\n" - * "Router priority\n" - * "Priority\n" - * - */ -DEFUN (ip_ospf_priority, - ip_ospf_priority_addr_cmd, - "ip ospf priority (0-255) A.B.C.D", - "IP Information\n" +DEFUN (no_ospf_priority, + no_ospf_priority_addr_cmd, + "no ospf priority [(0-255) [A.B.C.D]]", + NO_STR "OSPF interface commands\n" "Router priority\n" "Priority\n" "Address of interface") { - int idx_number = 3; int idx_ipv4 = 4; struct interface *ifp = vty->index; - long priority; struct route_node *rn; struct in_addr addr; int ret; struct ospf_if_params *params; - - params = IF_DEF_PARAMS (ifp); - - priority = strtol (argv[idx_number]->arg, NULL, 10); - /* Router Priority range is <0-255>. */ - if (priority < 0 || priority > 255) - { - vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); - return CMD_WARNING; - } + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -7593,13 +7525,20 @@ DEFUN (ip_ospf_priority, return CMD_WARNING; } - params = ospf_get_if_params (ifp, addr); + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; + } + + UNSET_IF_PARAM (params, priority); + params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; + + if (params != IF_DEF_PARAMS (ifp)) + { + ospf_free_if_params (ifp, addr); ospf_if_update_params (ifp, addr); } - SET_IF_PARAM (params, priority); - params->priority = priority; - for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) { struct ospf_interface *oi = rn->info; @@ -7618,39 +7557,9 @@ DEFUN (ip_ospf_priority, return CMD_SUCCESS; } - -ALIAS_HIDDEN (ip_ospf_priority, - ospf_priority_cmd, - "ospf priority <0-255>", - "OSPF interface commands\n" - "Router priority\n" - "Priority\n") - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf priority", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Router priority\n" - * - * "no ip ospf priority <0-255>", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Router priority\n" - * "Priority\n" - * - * "no ospf priority <0-255>", - * NO_STR - * "OSPF interface commands\n" - * "Router priority\n" - * "Priority\n" - * - */ DEFUN (no_ip_ospf_priority, no_ip_ospf_priority_addr_cmd, - "no ip ospf priority (0-255) A.B.C.D", + "no ip ospf priority [(0-255) [A.B.C.D]]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7668,7 +7577,7 @@ DEFUN (no_ip_ospf_priority, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 6) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -7711,21 +7620,9 @@ DEFUN (no_ip_ospf_priority, } - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf retransmit-interval <3-65535>", - * "IP Information\n" - * "OSPF interface commands\n" - * "Time between retransmitting lost link state advertisements\n" - * "Seconds\n" - * - */ DEFUN (ip_ospf_retransmit_interval, ip_ospf_retransmit_interval_addr_cmd, - "ip ospf retransmit-interval (3-65535) A.B.C.D", + "ip ospf retransmit-interval (3-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Time between retransmitting lost link state advertisements\n" @@ -7751,7 +7648,7 @@ DEFUN (ip_ospf_retransmit_interval, } - if (argc == 2) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -7771,39 +7668,55 @@ DEFUN (ip_ospf_retransmit_interval, return CMD_SUCCESS; } - -ALIAS_HIDDEN (ip_ospf_retransmit_interval, +DEFUN_HIDDEN (ospf_retransmit_interval, ospf_retransmit_interval_cmd, "ospf retransmit-interval <3-65535>", "OSPF interface commands\n" "Time between retransmitting lost link state advertisements\n" "Seconds\n") +{ + int idx_number = 2; + struct interface *ifp = vty->index; + u_int32_t seconds; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + seconds = strtol (argv[idx_number]->arg, NULL, 10); + + /* Retransmit Interval range is <3-65535>. */ + if (seconds < 3 || seconds > 65535) + { + vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, retransmit_interval); + params->retransmit_interval = seconds; + + return CMD_SUCCESS; +} + +DEFUN (no_ospf_retransmit_interval, + no_ospf_retransmit_interval_cmd, + "no ospf retransmit-interval", + NO_STR + "OSPF interface commands\n" + "Time between retransmitting lost link state advertisements\n") +{ + struct interface *ifp = vty->index; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + UNSET_IF_PARAM (params, retransmit_interval); + params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf retransmit-interval <3-65535> A.B.C.D", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Time between retransmitting lost link state advertisements\n" - * "Seconds\n" - * "Address of interface" - * - * "no ip ospf retransmit-interval", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Time between retransmitting lost link state advertisements\n" - * - * "no ospf retransmit-interval", - * NO_STR - * "OSPF interface commands\n" - * "Time between retransmitting lost link state advertisements\n" - * - */ DEFUN (no_ip_ospf_retransmit_interval, no_ip_ospf_retransmit_interval_addr_cmd, - "no ip ospf retransmit-interval A.B.C.D", + "no ip ospf retransmit-interval [<(3-65535 [A.B.C.D]|A.B.C.D>]", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7819,14 +7732,14 @@ DEFUN (no_ip_ospf_retransmit_interval, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc >= 1) + if (argc >= 5) { - if (argc == 1) - addr_index = 0; + if (argc == 5) + addr_index = 4; else - addr_index = 1; + addr_index = 5; - ret = inet_aton(argv[addr_index], &addr); + ret = inet_aton(argv[addr_index]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7852,42 +7765,9 @@ DEFUN (no_ip_ospf_retransmit_interval, } - - -DEFUN (no_ip_ospf_retransmit_interval_sec, - no_ip_ospf_retransmit_interval_sec_cmd, - "no ip ospf retransmit-interval (3-65535)", - NO_STR - "IP Information\n" - "OSPF interface commands\n" - "Time between retransmitting lost link state advertisements\n" - "Seconds\n") -{ - struct interface *ifp = vty->index; - struct ospf_if_params *params; - - ifp = vty->index; - params = IF_DEF_PARAMS (ifp); - - UNSET_IF_PARAM (params, retransmit_interval); - params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; - - return CMD_SUCCESS; -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf transmit-delay <1-65535>", - * "IP Information\n" - * "OSPF interface commands\n" - * "Link state transmit delay\n" - * "Seconds\n" - * - */ DEFUN (ip_ospf_transmit_delay, ip_ospf_transmit_delay_addr_cmd, - "ip ospf transmit-delay (1-65535) A.B.C.D", + "ip ospf transmit-delay (1-65535) [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Link state transmit delay\n" @@ -7912,7 +7792,7 @@ DEFUN (ip_ospf_transmit_delay, return CMD_WARNING; } - if (argc == 2) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -7933,38 +7813,37 @@ DEFUN (ip_ospf_transmit_delay, } -ALIAS_HIDDEN (ip_ospf_transmit_delay, +DEFUN_HIDDEN (ospf_transmit_delay, ospf_transmit_delay_cmd, "ospf transmit-delay <1-65535>", "OSPF interface commands\n" "Link state transmit delay\n" "Seconds\n") +{ + int idx_number = 2; + struct interface *ifp = vty->index; + u_int32_t seconds; + struct ospf_if_params *params; + + params = IF_DEF_PARAMS (ifp); + seconds = strtol (argv[idx_number]->arg, NULL, 10); + + /* Transmit Delay range is <1-65535>. */ + if (seconds < 1 || seconds > 65535) + { + vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + SET_IF_PARAM (params, transmit_delay); + params->transmit_delay = seconds; + + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ospf transmit-delay", - * NO_STR - * "OSPF interface commands\n" - * "Link state transmit delay\n" - * - * "no ip ospf transmit-delay", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Link state transmit delay\n" - * - * "no ip ospf transmit-delay <1-65535> A.B.C.D", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Link state transmit delay\n" - * "Seconds\n" - * "Address of interface" - * - */ DEFUN (no_ip_ospf_transmit_delay, no_ip_ospf_transmit_delay_addr_cmd, - "no ip ospf transmit-delay A.B.C.D", + "no ip ospf transmit-delay []", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -7980,14 +7859,14 @@ DEFUN (no_ip_ospf_transmit_delay, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc >= 1) + if (argc >= 5) { - if (argc == 1) - addr_index = 0; + if (argc == 5) + addr_index = 4; else - addr_index = 1; + addr_index = 5; - ret = inet_aton(argv[addr_index], &addr); + ret = inet_aton(argv[addr_index]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -8013,7 +7892,24 @@ DEFUN (no_ip_ospf_transmit_delay, } +DEFUN (no_ospf_transmit_delay, + no_ospf_transmit_delay_cmd, + "no ospf transmit-delay", + NO_STR + "OSPF interface commands\n" + "Link state transmit delay\n") +{ + struct interface *ifp = vty->index; + struct ospf_if_params *params; + + ifp = vty->index; + params = IF_DEF_PARAMS (ifp); + + UNSET_IF_PARAM (params, transmit_delay); + params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; + return CMD_SUCCESS; +} DEFUN (no_ip_ospf_transmit_delay_sec, no_ip_ospf_transmit_delay_sec_cmd, @@ -8037,27 +7933,17 @@ DEFUN (no_ip_ospf_transmit_delay_sec, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", - * "IP Information\n" - * "OSPF interface commands\n" - * "Instance ID\n" - * "Enable OSPF on this interface\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * - */ DEFUN (ip_ospf_area, ip_ospf_area_cmd, - "ip ospf area ", + "ip ospf [(1-65535)]area ", "IP Information\n" "OSPF interface commands\n" + "Instance ID\n" "Enable OSPF on this interface\n" "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { - int idx_ipv4_number = 3; + int idx_ipv4_number = 2; struct interface *ifp = vty->index; int format, ret; struct in_addr area_id; @@ -8066,7 +7952,7 @@ DEFUN (ip_ospf_area, struct route_node *rn; u_short instance = 0; - if (argc == 2) + if (argc == 5) VTY_GET_INTEGER ("Instance", instance, argv[idx_ipv4_number]->arg); ospf = ospf_lookup_instance (instance); @@ -8082,7 +7968,7 @@ DEFUN (ip_ospf_area, return CMD_SUCCESS; } - ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format); + ret = ospf_str2area_id (argv[instance ? 4 : 3]->arg, &area_id, &format); if (ret < 0) { vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", @@ -8120,25 +8006,15 @@ DEFUN (ip_ospf_area, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf area (A.B.C.D|<0-4294967295>)", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Disable OSPF on this interface\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * - */ DEFUN (no_ip_ospf_area, no_ip_ospf_area_cmd, - "no ip ospf area", + "no ip ospf area []", NO_STR "IP Information\n" "OSPF interface commands\n" - "Disable OSPF on this interface\n") + "Disable OSPF on this interface\n" + "OSPF area ID in IP address format\n" + "OSPF area ID as a decimal value\n") { struct interface *ifp = vty->index; struct ospf *ospf; @@ -8160,22 +8036,9 @@ DEFUN (no_ip_ospf_area, return CMD_SUCCESS; } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", - * NO_STR - * "IP Information\n" - * "OSPF interface commands\n" - * "Instance ID\n" - * "Disable OSPF on this interface\n" - * "OSPF area ID in IP address format\n" - * "OSPF area ID as a decimal value\n" - * - */ DEFUN (no_ip_ospf_instance_area, no_ip_ospf_instance_area_cmd, - "no ip ospf (1-65535) area", + "no ip ospf (1-65535) area []", NO_STR "IP Information\n" "OSPF interface commands\n" @@ -8205,7 +8068,6 @@ DEFUN (no_ip_ospf_instance_area, return CMD_SUCCESS; } - DEFUN (ospf_redistribute_source, ospf_redistribute_source_cmd, "redistribute [metric (0-16777214)|metric-type <1|2>|route-map WORD]", @@ -8242,19 +8104,19 @@ DEFUN (ospf_redistribute_source, return CMD_WARNING; /* Get metric value. */ - if (argv[idx_redist_param]->arg != NULL) - if (!str2metric (argv[idx_redist_param]->arg, &metric)) + if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) + if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ - if (argv[2] != NULL) - if (!str2metric_type (argv[2], &type)) + if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) + if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) return CMD_WARNING; red = ospf_redist_add(ospf, source, 0); - if (argv[3] != NULL) - ospf_routemap_set (red, argv[3]); + if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) + ospf_routemap_set (red, argv[idx_redist_param+1]->arg); else ospf_routemap_unset (red); @@ -8347,18 +8209,19 @@ DEFUN (ospf_redistribute_instance_source, } /* Get metric value. */ - if (argv[idx_redist_param]->arg != NULL) - if (!str2metric (argv[idx_redist_param]->arg, &metric)) + if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) + if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ - if (argv[3] != NULL) - if (!str2metric_type (argv[3], &type)) + if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) + if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) return CMD_WARNING; red = ospf_redist_add(ospf, source, instance); - if (argv[4] != NULL) - ospf_routemap_set (red, argv[4]); + + if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) + ospf_routemap_set (red, argv[idx_redist_param+1]->arg); else ospf_routemap_unset (red); @@ -8501,17 +8364,17 @@ DEFUN (ospf_default_information_originate, red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); /* Get metric value. */ - if (argv[1] != NULL) - if (!str2metric (argv[1], &metric)) + if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) + if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ - if (argv[2] != NULL) - if (!str2metric_type (argv[2], &type)) + if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) + if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) return CMD_WARNING; - if (argv[3] != NULL) - ospf_routemap_set (red, argv[3]); + if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) + ospf_routemap_set (red, argv[idx_redist_param+1]->arg); else ospf_routemap_unset (red); @@ -8583,19 +8446,12 @@ DEFUN (ospf_default_metric, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no default-metric <0-16777214>", - * NO_STR - * "Set metric of redistributed routes\n" - * "Default metric\n" - * - */ DEFUN (no_ospf_default_metric, no_ospf_default_metric_cmd, - "no default-metric", + "no default-metric [(0-16777214)]", NO_STR - "Set metric of redistributed routes\n") + "Set metric of redistributed routes\n" + "Default metric\n") { struct ospf *ospf = vty->index; @@ -8715,14 +8571,14 @@ DEFUN (ospf_distance_ospf, return CMD_WARNING; } - if (argv[idx_area_distance]->arg != NULL) - ospf->distance_intra = atoi(argv[idx_area_distance]->arg); + if (strcmp (argv[idx_area_distance]->text, "intra") == 0) + ospf->distance_intra = atoi(argv[idx_area_distance+1]->arg); - if (argv[1] != NULL) - ospf->distance_inter = atoi(argv[1]); + if (strcmp (argv[idx_area_distance]->text, "inter") == 0) + ospf->distance_inter = atoi(argv[idx_area_distance+1]->arg); - if (argv[2] != NULL) - ospf->distance_external = atoi(argv[2]); + if (strcmp (argv[idx_area_distance]->text, "external") == 0) + ospf->distance_external = atoi(argv[idx_area_distance+1]->arg); return CMD_SUCCESS; } @@ -8809,17 +8665,9 @@ DEFUN (no_ospf_distance_source_access_list, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ip ospf mtu-ignore", - * "IP Information\n" - * "OSPF interface commands\n" - * "Disable mtu mismatch detection\n" - * - */ DEFUN (ip_ospf_mtu_ignore, ip_ospf_mtu_ignore_addr_cmd, - "ip ospf mtu-ignore A.B.C.D", + "ip ospf mtu-ignore [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Disable mtu mismatch detection\n" @@ -8833,7 +8681,7 @@ DEFUN (ip_ospf_mtu_ignore, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 4) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -8860,19 +8708,9 @@ DEFUN (ip_ospf_mtu_ignore, return CMD_SUCCESS; } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ip ospf mtu-ignore", - * "IP Information\n" - * "OSPF interface commands\n" - * "Disable mtu mismatch detection\n" - * - */ DEFUN (no_ip_ospf_mtu_ignore, no_ip_ospf_mtu_ignore_addr_cmd, - "no ip ospf mtu-ignore A.B.C.D", + "no ip ospf mtu-ignore [A.B.C.D]", "IP Information\n" "OSPF interface commands\n" "Disable mtu mismatch detection\n" @@ -8886,7 +8724,7 @@ DEFUN (no_ip_ospf_mtu_ignore, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - if (argc == 1) + if (argc == 5) { ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) @@ -9001,18 +8839,9 @@ DEFUN (ospf_max_metric_router_lsa_startup, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no max-metric router-lsa on-startup", - * NO_STR - * "OSPF maximum / infinite-distance metric\n" - * "Advertise own Router-LSA with infinite distance (stub router)\n" - * "Automatically advertise stub Router-LSA on startup of OSPF\n" - * - */ DEFUN (no_ospf_max_metric_router_lsa_startup, no_ospf_max_metric_router_lsa_startup_cmd, - "no max-metric router-lsa on-startup (5-86400)", + "no max-metric router-lsa on-startup [(5-86400)]", NO_STR "OSPF maximum / infinite-distance metric\n" "Advertise own Router-LSA with infinite distance (stub router)\n" @@ -9072,21 +8901,9 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no max-metric router-lsa on-shutdown", - * NO_STR - * "OSPF maximum / infinite-distance metric\n" - * "Advertise own Router-LSA with infinite distance (stub router)\n" - * "Advertise stub-router prior to full shutdown of OSPF\n"); - * - * static void - * config_write_stub_router (struct vty *vty, struct ospf *ospf - * - */ DEFUN (no_ospf_max_metric_router_lsa_shutdown, no_ospf_max_metric_router_lsa_shutdown_cmd, - "no max-metric router-lsa on-shutdown (5-100)", + "no max-metric router-lsa on-shutdown [(5-100)]", NO_STR "OSPF maximum / infinite-distance metric\n" "Advertise own Router-LSA with infinite distance (stub router)\n" @@ -10172,13 +9989,17 @@ ospf_vty_show_init (void) /* "show ip ospf database" commands. */ install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); install_element (VIEW_NODE, &show_ip_ospf_database_cmd); + install_element (VIEW_NODE, &show_ip_ospf_database_max_cmd); install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); + install_element (ENABLE_NODE, &show_ip_ospf_database_max_cmd); install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); + install_element (VIEW_NODE, &show_ip_ospf_instance_database_max_cmd); install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); install_element (ENABLE_NODE, &show_ip_ospf_instance_database_cmd); + install_element (ENABLE_NODE, &show_ip_ospf_instance_database_max_cmd); /* "show ip ospf interface" commands. */ install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); @@ -10261,16 +10082,20 @@ ospf_vty_if_init (void) install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); + install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_addr_cmd); /* "ip ospf message-digest-key" commands. */ install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_addr_cmd); + install_element (INTERFACE_NODE, &no_ospf_message_digest_key_addr_cmd); /* "ip ospf cost" commands. */ install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); + install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); + install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); /* "ip ospf mtu-ignore" commands. */ install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); @@ -10288,20 +10113,23 @@ ospf_vty_if_init (void) /* "ip ospf network" commands. */ install_element (INTERFACE_NODE, &ip_ospf_network_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); + install_element (INTERFACE_NODE, &no_ospf_network_cmd); /* "ip ospf priority" commands. */ install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); + install_element (INTERFACE_NODE, &no_ospf_priority_addr_cmd); /* "ip ospf retransmit-interval" commands. */ install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); - install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_cmd); + install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); /* "ip ospf transmit-delay" commands. */ install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_cmd); + install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); /* "ip ospf area" commands. */ install_element (INTERFACE_NODE, &ip_ospf_area_cmd); @@ -10311,7 +10139,6 @@ ospf_vty_if_init (void) /* These commands are compatibitliy for previous version. */ install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); - install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); @@ -10381,14 +10208,14 @@ DEFUN (clear_ip_ospf_interface, struct interface *ifp; struct listnode *node; - if (argc == 0) /* Clear all the ospfv2 interfaces. */ + if (argc == 4) /* Clear all the ospfv2 interfaces. */ { for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) ospf_interface_clear(ifp); } else /* Interface name is specified. */ { - if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg)) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_ifname]->text)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else ospf_interface_clear(ifp); @@ -10440,6 +10267,8 @@ ospf_vty_init (void) /* "ospf rfc1583-compatible" commands. */ install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); + install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); + install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); /* "network area" commands. */ install_element (OSPF_NODE, &ospf_network_area_cmd); @@ -10452,6 +10281,7 @@ ospf_vty_init (void) /* "area range" commands. */ install_element (OSPF_NODE, &ospf_area_range_cmd); + install_element (OSPF_NODE, &ospf_area_range_cost_cmd); install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); install_element (OSPF_NODE, &no_ospf_area_range_cmd); install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); @@ -10459,7 +10289,9 @@ ospf_vty_init (void) /* "area virtual-link" commands. */ install_element (OSPF_NODE, &ospf_area_vlink_cmd); + install_element (OSPF_NODE, &ospf_area_vlink_intervals_cmd); install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); + install_element (OSPF_NODE, &no_ospf_area_vlink_intervals_cmd); @@ -10530,10 +10362,13 @@ ospf_vty_init (void) install_element (OSPF_NODE, &ospf_neighbor_cmd); install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); install_element (OSPF_NODE, &no_ospf_neighbor_cmd); + install_element (OSPF_NODE, &no_ospf_neighbor_poll_cmd); /* write multiplier commands */ install_element (OSPF_NODE, &ospf_write_multiplier_cmd); + install_element (OSPF_NODE, &write_multiplier_cmd); install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); + install_element (OSPF_NODE, &no_write_multiplier_cmd); /* Init interface related vty commands. */ ospf_vty_if_init ();