Merge branch 'vtysh-grammar' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into vtysh-grammar

This commit is contained in:
Quentin Young 2016-09-23 20:11:04 +00:00
commit 86959b0e07
54 changed files with 4290 additions and 1899 deletions

View File

@ -630,7 +630,8 @@ DEFUN (debug_bgp_neighbor_events_peer,
"BGP IPv6 neighbor to debug\n" "BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n") "BGP neighbor on interface to debug\n")
{ {
const char *host = argv[3]->arg; int idx_peer = 3;
const char *host = argv[idx_peer]->arg;
if (!bgp_debug_neighbor_events_peers) if (!bgp_debug_neighbor_events_peers)
bgp_debug_neighbor_events_peers = list_new (); bgp_debug_neighbor_events_peers = list_new ();
@ -684,8 +685,9 @@ DEFUN (no_debug_bgp_neighbor_events_peer,
"BGP IPv6 neighbor to debug\n" "BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n") "BGP neighbor on interface to debug\n")
{ {
int idx_peer = 4;
int found_peer = 0; int found_peer = 0;
const char *host = argv[4]->arg; const char *host = argv[idx_peer]->arg;
if (bgp_debug_neighbor_events_peers && !list_isempty(bgp_debug_neighbor_events_peers)) if (bgp_debug_neighbor_events_peers && !list_isempty(bgp_debug_neighbor_events_peers))
{ {
@ -774,7 +776,8 @@ DEFUN (debug_bgp_keepalive_peer,
"BGP IPv6 neighbor to debug\n" "BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n") "BGP neighbor on interface to debug\n")
{ {
const char *host = argv[3]->arg; int idx_peer = 3;
const char *host = argv[idx_peer]->arg;
if (!bgp_debug_keepalive_peers) if (!bgp_debug_keepalive_peers)
bgp_debug_keepalive_peers = list_new (); bgp_debug_keepalive_peers = list_new ();
@ -828,8 +831,9 @@ DEFUN (no_debug_bgp_keepalive_peer,
"BGP IPv6 neighbor to debug\n" "BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n") "BGP neighbor on interface to debug\n")
{ {
int idx_peer = 4;
int found_peer = 0; int found_peer = 0;
const char *host = argv[4]->arg; const char *host = argv[idx_peer]->arg;
if (bgp_debug_keepalive_peers && !list_isempty(bgp_debug_keepalive_peers)) if (bgp_debug_keepalive_peers && !list_isempty(bgp_debug_keepalive_peers))
{ {
@ -863,11 +867,12 @@ DEFUN (debug_bgp_bestpath_prefix,
"IPv6 prefix <network>/<length>\n") "IPv6 prefix <network>/<length>\n")
{ {
int idx_ipv4_ipv6_prefixlen = 3;
struct prefix *argv_p; struct prefix *argv_p;
int ret; int ret;
argv_p = prefix_new(); argv_p = prefix_new();
ret = str2prefix (argv[3]->arg, argv_p); ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret) if (!ret)
{ {
prefix_free(argv_p); prefix_free(argv_p);
@ -881,7 +886,7 @@ DEFUN (debug_bgp_bestpath_prefix,
if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, argv_p)) if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, argv_p))
{ {
vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[3]->arg, VTY_NEWLINE); vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -894,7 +899,7 @@ DEFUN (debug_bgp_bestpath_prefix,
else else
{ {
TERM_DEBUG_ON (bestpath, BESTPATH); TERM_DEBUG_ON (bestpath, BESTPATH);
vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[3]->arg, VTY_NEWLINE); vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
} }
return CMD_SUCCESS; return CMD_SUCCESS;
@ -911,12 +916,13 @@ DEFUN (no_debug_bgp_bestpath_prefix,
"IPv6 prefix <network>/<length>\n") "IPv6 prefix <network>/<length>\n")
{ {
int idx_ipv4_ipv6_prefixlen = 4;
struct prefix *argv_p; struct prefix *argv_p;
int found_prefix = 0; int found_prefix = 0;
int ret; int ret;
argv_p = prefix_new(); argv_p = prefix_new();
ret = str2prefix (argv[4]->arg, argv_p); ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret) if (!ret)
{ {
prefix_free(argv_p); prefix_free(argv_p);
@ -943,9 +949,9 @@ DEFUN (no_debug_bgp_bestpath_prefix,
} }
if (found_prefix) if (found_prefix)
vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
else else
vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1005,22 +1011,23 @@ DEFUN (debug_bgp_update_direct,
"Inbound updates\n" "Inbound updates\n"
"Outbound updates\n") "Outbound updates\n")
{ {
int idx_in_out = 3;
if (strncmp ("i", argv[3]->arg, 1) == 0) if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
bgp_debug_list_free(bgp_debug_update_in_peers); bgp_debug_list_free(bgp_debug_update_in_peers);
else else
bgp_debug_list_free(bgp_debug_update_out_peers); bgp_debug_list_free(bgp_debug_update_out_peers);
if (vty->node == CONFIG_NODE) if (vty->node == CONFIG_NODE)
{ {
if (strncmp ("i", argv[3]->arg, 1) == 0) if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
DEBUG_ON (update, UPDATE_IN); DEBUG_ON (update, UPDATE_IN);
else else
DEBUG_ON (update, UPDATE_OUT); DEBUG_ON (update, UPDATE_OUT);
} }
else else
{ {
if (strncmp ("i", argv[3]->arg, 1) == 0) if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
{ {
TERM_DEBUG_ON (update, UPDATE_IN); TERM_DEBUG_ON (update, UPDATE_IN);
vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE); vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
@ -1046,7 +1053,9 @@ DEFUN (debug_bgp_update_direct_peer,
"BGP IPv6 neighbor to debug\n" "BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n") "BGP neighbor on interface to debug\n")
{ {
const char *host = argv[4]->arg; int idx_in_out = 3;
int idx_peer = 4;
const char *host = argv[idx_peer]->arg;
int inbound; int inbound;
if (!bgp_debug_update_in_peers) if (!bgp_debug_update_in_peers)
@ -1055,7 +1064,7 @@ DEFUN (debug_bgp_update_direct_peer,
if (!bgp_debug_update_out_peers) if (!bgp_debug_update_out_peers)
bgp_debug_update_out_peers = list_new (); bgp_debug_update_out_peers = list_new ();
if (strncmp ("i", argv[3]->arg, 1) == 0) if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
inbound = 1; inbound = 1;
else else
inbound = 0; inbound = 0;
@ -1117,12 +1126,12 @@ DEFUN (debug_bgp_update_direct_peer,
if (inbound) if (inbound)
{ {
TERM_DEBUG_ON (update, UPDATE_IN); TERM_DEBUG_ON (update, UPDATE_IN);
vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
} }
else else
{ {
TERM_DEBUG_ON (update, UPDATE_OUT); TERM_DEBUG_ON (update, UPDATE_OUT);
vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
} }
} }
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1138,7 +1147,8 @@ DEFUN (no_debug_bgp_update_direct,
"Inbound updates\n" "Inbound updates\n"
"Outbound updates\n") "Outbound updates\n")
{ {
if (strncmp ("i", argv[4]->arg, 1) == 0) int idx_in_out = 4;
if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
{ {
bgp_debug_list_free(bgp_debug_update_in_peers); bgp_debug_list_free(bgp_debug_update_in_peers);
@ -1183,11 +1193,13 @@ DEFUN (no_debug_bgp_update_direct_peer,
"BGP IPv6 neighbor to debug\n" "BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n") "BGP neighbor on interface to debug\n")
{ {
int idx_in_out = 4;
int idx_peer = 5;
int inbound; int inbound;
int found_peer = 0; int found_peer = 0;
const char *host = argv[5]->arg; const char *host = argv[idx_peer]->arg;
if (strncmp ("i", argv[4]->arg, 1) == 0) if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
inbound = 1; inbound = 1;
else else
inbound = 0; inbound = 0;
@ -1271,11 +1283,12 @@ DEFUN (debug_bgp_update_prefix,
"IPv6 prefix <network>/<length>\n") "IPv6 prefix <network>/<length>\n")
{ {
int idx_ipv4_ipv6_prefixlen = 4;
struct prefix *argv_p; struct prefix *argv_p;
int ret; int ret;
argv_p = prefix_new(); argv_p = prefix_new();
ret = str2prefix (argv[4]->arg, argv_p); ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret) if (!ret)
{ {
prefix_free(argv_p); prefix_free(argv_p);
@ -1289,7 +1302,7 @@ DEFUN (debug_bgp_update_prefix,
if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p))
{ {
vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1302,7 +1315,7 @@ DEFUN (debug_bgp_update_prefix,
else else
{ {
TERM_DEBUG_ON (update, UPDATE_PREFIX); TERM_DEBUG_ON (update, UPDATE_PREFIX);
vty_out (vty, "BGP updates debugging is on for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP updates debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
} }
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1320,12 +1333,13 @@ DEFUN (no_debug_bgp_update_prefix,
"IPv6 prefix <network>/<length>\n") "IPv6 prefix <network>/<length>\n")
{ {
int idx_ipv4_ipv6_prefixlen = 5;
struct prefix *argv_p; struct prefix *argv_p;
int found_prefix = 0; int found_prefix = 0;
int ret; int ret;
argv_p = prefix_new(); argv_p = prefix_new();
ret = str2prefix (argv[5]->arg, argv_p); ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret) if (!ret)
{ {
prefix_free(argv_p); prefix_free(argv_p);
@ -1352,9 +1366,9 @@ DEFUN (no_debug_bgp_update_prefix,
} }
if (found_prefix) if (found_prefix)
vty_out (vty, "BGP updates debugging is off for %s%s", argv[5]->arg, VTY_NEWLINE); vty_out (vty, "BGP updates debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
else else
vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[5]->arg, VTY_NEWLINE); vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1418,11 +1432,12 @@ DEFUN (debug_bgp_zebra_prefix,
"IPv6 prefix <network>/<length>\n") "IPv6 prefix <network>/<length>\n")
{ {
int idx_ipv4_ipv6_prefixlen = 4;
struct prefix *argv_p; struct prefix *argv_p;
int ret; int ret;
argv_p = prefix_new(); argv_p = prefix_new();
ret = str2prefix (argv[4]->arg, argv_p); ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret) if (!ret)
{ {
prefix_free(argv_p); prefix_free(argv_p);
@ -1435,7 +1450,7 @@ DEFUN (debug_bgp_zebra_prefix,
if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p)) if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p))
{ {
vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1446,7 +1461,7 @@ DEFUN (debug_bgp_zebra_prefix,
else else
{ {
TERM_DEBUG_ON (zebra, ZEBRA); TERM_DEBUG_ON (zebra, ZEBRA);
vty_out (vty, "BGP zebra debugging is on for %s%s", argv[4]->arg, VTY_NEWLINE); vty_out (vty, "BGP zebra debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
} }
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1484,12 +1499,13 @@ DEFUN (no_debug_bgp_zebra_prefix,
"IPv6 prefix <network>/<length>\n") "IPv6 prefix <network>/<length>\n")
{ {
int idx_ipv4_ipv6_prefixlen = 5;
struct prefix *argv_p; struct prefix *argv_p;
int found_prefix = 0; int found_prefix = 0;
int ret; int ret;
argv_p = prefix_new(); argv_p = prefix_new();
ret = str2prefix (argv[5]->arg, argv_p); ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret) if (!ret)
{ {
prefix_free(argv_p); prefix_free(argv_p);
@ -1514,9 +1530,9 @@ DEFUN (no_debug_bgp_zebra_prefix,
} }
if (found_prefix) if (found_prefix)
vty_out (vty, "BGP zebra debugging is off for %s%s", argv[5]->arg, VTY_NEWLINE); vty_out (vty, "BGP zebra debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
else else
vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[5]->arg, VTY_NEWLINE); vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -736,13 +736,16 @@ DEFUN (dump_bgp_all,
"Output filename\n" "Output filename\n"
"Interval of output\n") "Interval of output\n")
{ {
int idx_dump_routes = 2;
int idx_path = 3;
int idx_interval = 4;
int bgp_dump_type = 0; int bgp_dump_type = 0;
const char *interval = NULL; const char *interval = NULL;
struct bgp_dump *bgp_dump_struct = NULL; struct bgp_dump *bgp_dump_struct = NULL;
const struct bgp_dump_type_map *map = NULL; const struct bgp_dump_type_map *map = NULL;
for (map = bgp_dump_type_map; map->str; map++) for (map = bgp_dump_type_map; map->str; map++)
if (strcmp(argv[2]->arg, map->str) == 0) if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0)
bgp_dump_type = map->type; bgp_dump_type = map->type;
switch (bgp_dump_type) switch (bgp_dump_type)
@ -763,10 +766,10 @@ DEFUN (dump_bgp_all,
/* When an interval is given */ /* When an interval is given */
if (argc == 3) if (argc == 3)
interval = argv[4]->arg; interval = argv[idx_interval]->arg;
return bgp_dump_set (vty, bgp_dump_struct, bgp_dump_type, return bgp_dump_set (vty, bgp_dump_struct, bgp_dump_type,
argv[3]->arg, interval); argv[idx_path]->arg, interval);
} }
DEFUN (no_dump_bgp_all, DEFUN (no_dump_bgp_all,
@ -781,12 +784,13 @@ DEFUN (no_dump_bgp_all,
"Stop dump process updates-et\n" "Stop dump process updates-et\n"
"Stop dump process route-mrt\n") "Stop dump process route-mrt\n")
{ {
int idx_dump_routes = 3;
int bgp_dump_type = 0; int bgp_dump_type = 0;
const struct bgp_dump_type_map *map = NULL; const struct bgp_dump_type_map *map = NULL;
struct bgp_dump *bgp_dump_struct = NULL; struct bgp_dump *bgp_dump_struct = NULL;
for (map = bgp_dump_type_map; map->str; map++) for (map = bgp_dump_type_map; map->str; map++)
if (strcmp(argv[3]->arg, map->str) == 0) if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0)
bgp_dump_type = map->type; bgp_dump_type = map->type;
switch (bgp_dump_type) switch (bgp_dump_type)

View File

@ -437,6 +437,8 @@ DEFUN (ip_as_path,
"Specify packets to forward\n" "Specify packets to forward\n"
"A regular-expression to match the BGP AS paths\n") "A regular-expression to match the BGP AS paths\n")
{ {
int idx_word = 3;
int idx_permit_deny = 4;
enum as_filter_type type; enum as_filter_type type;
struct as_filter *asfilter; struct as_filter *asfilter;
struct as_list *aslist; struct as_list *aslist;
@ -444,9 +446,9 @@ DEFUN (ip_as_path,
char *regstr; char *regstr;
/* Check the filter type. */ /* Check the filter type. */
if (strncmp (argv[4]->arg, "p", 1) == 0) if (strncmp (argv[idx_permit_deny]->arg, "p", 1) == 0)
type = AS_FILTER_PERMIT; type = AS_FILTER_PERMIT;
else if (strncmp (argv[4]->arg, "d", 1) == 0) else if (strncmp (argv[idx_permit_deny]->arg, "d", 1) == 0)
type = AS_FILTER_DENY; type = AS_FILTER_DENY;
else else
{ {
@ -461,7 +463,7 @@ DEFUN (ip_as_path,
if (!regex) if (!regex)
{ {
XFREE (MTYPE_TMP, regstr); XFREE (MTYPE_TMP, regstr);
vty_out (vty, "can't compile regexp %s%s", argv[3]->arg, vty_out (vty, "can't compile regexp %s%s", argv[idx_word]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -471,7 +473,7 @@ DEFUN (ip_as_path,
XFREE (MTYPE_TMP, regstr); XFREE (MTYPE_TMP, regstr);
/* Install new filter to the access_list. */ /* Install new filter to the access_list. */
aslist = as_list_get (argv[3]->arg); aslist = as_list_get (argv[idx_word]->arg);
/* Duplicate insertion check. */; /* Duplicate insertion check. */;
if (as_list_dup_check (aslist, asfilter)) if (as_list_dup_check (aslist, asfilter))
@ -494,6 +496,8 @@ DEFUN (no_ip_as_path,
"Specify packets to forward\n" "Specify packets to forward\n"
"A regular-expression to match the BGP AS paths\n") "A regular-expression to match the BGP AS paths\n")
{ {
int idx_word = 4;
int idx_permit_deny = 5;
enum as_filter_type type; enum as_filter_type type;
struct as_filter *asfilter; struct as_filter *asfilter;
struct as_list *aslist; struct as_list *aslist;
@ -501,18 +505,18 @@ DEFUN (no_ip_as_path,
regex_t *regex; regex_t *regex;
/* Lookup AS list from AS path list. */ /* Lookup AS list from AS path list. */
aslist = as_list_lookup (argv[4]->arg); aslist = as_list_lookup (argv[idx_word]->arg);
if (aslist == NULL) if (aslist == NULL)
{ {
vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[4]->arg, vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[idx_word]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
/* Check the filter type. */ /* Check the filter type. */
if (strncmp (argv[5]->arg, "p", 1) == 0) if (strncmp (argv[idx_permit_deny]->arg, "p", 1) == 0)
type = AS_FILTER_PERMIT; type = AS_FILTER_PERMIT;
else if (strncmp (argv[5]->arg, "d", 1) == 0) else if (strncmp (argv[idx_permit_deny]->arg, "d", 1) == 0)
type = AS_FILTER_DENY; type = AS_FILTER_DENY;
else else
{ {
@ -527,7 +531,7 @@ DEFUN (no_ip_as_path,
if (!regex) if (!regex)
{ {
XFREE (MTYPE_TMP, regstr); XFREE (MTYPE_TMP, regstr);
vty_out (vty, "can't compile regexp %s%s", argv[4]->arg, vty_out (vty, "can't compile regexp %s%s", argv[idx_word]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -558,12 +562,13 @@ DEFUN (no_ip_as_path_all,
"Specify an access list name\n" "Specify an access list name\n"
"Regular expression access list name\n") "Regular expression access list name\n")
{ {
int idx_word = 4;
struct as_list *aslist; struct as_list *aslist;
aslist = as_list_lookup (argv[4]->arg); aslist = as_list_lookup (argv[idx_word]->arg);
if (aslist == NULL) if (aslist == NULL)
{ {
vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[4]->arg, vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[idx_word]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -572,7 +577,7 @@ DEFUN (no_ip_as_path_all,
/* Run hook function. */ /* Run hook function. */
if (as_list_master.delete_hook) if (as_list_master.delete_hook)
(*as_list_master.delete_hook) (argv[4]->arg); (*as_list_master.delete_hook) (argv[idx_word]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -628,9 +633,10 @@ DEFUN (show_ip_as_path_access_list,
"List AS path access lists\n" "List AS path access lists\n"
"AS path access list name\n") "AS path access list name\n")
{ {
int idx_word = 3;
struct as_list *aslist; struct as_list *aslist;
aslist = as_list_lookup (argv[3]->arg); aslist = as_list_lookup (argv[idx_word]->arg);
if (aslist) if (aslist)
as_list_show (vty, aslist); as_list_show (vty, aslist);

View File

@ -360,7 +360,10 @@ DEFUN (vpnv4_network,
"BGP tag\n" "BGP tag\n"
"tag value\n") "tag value\n")
{ {
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[1]->arg, argv[3]->arg, argv[5]->arg, NULL); int idx_ipv4_prefixlen = 1;
int idx_ext_community = 3;
int idx_word = 5;
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL);
} }
DEFUN (vpnv4_network_route_map, DEFUN (vpnv4_network_route_map,
@ -375,7 +378,11 @@ DEFUN (vpnv4_network_route_map,
"route map\n" "route map\n"
"route map name\n") "route map name\n")
{ {
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[1]->arg, argv[3]->arg, argv[5]->arg, argv[7]->arg); int idx_ipv4_prefixlen = 1;
int idx_ext_community = 3;
int idx_word = 5;
int idx_word_2 = 7;
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg);
} }
/* For testing purpose, static route of MPLS-VPN. */ /* For testing purpose, static route of MPLS-VPN. */
@ -390,7 +397,10 @@ DEFUN (no_vpnv4_network,
"BGP tag\n" "BGP tag\n"
"tag value\n") "tag value\n")
{ {
return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[2]->arg, argv[4]->arg, argv[6]->arg); int idx_ipv4_prefixlen = 2;
int idx_ext_community = 4;
int idx_word = 6;
return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg);
} }
static int static int
@ -791,10 +801,11 @@ DEFUN (show_bgp_ipv4_vpn_rd,
"VPN Route Distinguisher\n" "VPN Route Distinguisher\n"
JSON_STR) JSON_STR)
{ {
int idx_ext_community = 5;
int ret; int ret;
struct prefix_rd prd; struct prefix_rd prd;
ret = str2prefix_rd (argv[5]->arg, &prd); ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret) if (! ret)
{ {
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -814,10 +825,11 @@ DEFUN (show_bgp_ipv6_vpn_rd,
"VPN Route Distinguisher\n" "VPN Route Distinguisher\n"
JSON_STR) JSON_STR)
{ {
int idx_ext_community = 5;
int ret; int ret;
struct prefix_rd prd; struct prefix_rd prd;
ret = str2prefix_rd (argv[5]->arg, &prd); ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (!ret) if (!ret)
{ {
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -849,10 +861,11 @@ DEFUN (show_ip_bgp_vpnv4_rd,
"Display information for a route distinguisher\n" "Display information for a route distinguisher\n"
"VPN Route Distinguisher\n") "VPN Route Distinguisher\n")
{ {
int idx_ext_community = 5;
int ret; int ret;
struct prefix_rd prd; struct prefix_rd prd;
ret = str2prefix_rd (argv[5]->arg, &prd); ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret) if (! ret)
{ {
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -885,10 +898,11 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags,
"VPN Route Distinguisher\n" "VPN Route Distinguisher\n"
"Display BGP tags for prefixes\n") "Display BGP tags for prefixes\n")
{ {
int idx_ext_community = 5;
int ret; int ret;
struct prefix_rd prd; struct prefix_rd prd;
ret = str2prefix_rd (argv[5]->arg, &prd); ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret) if (! ret)
{ {
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -910,12 +924,13 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
"Display routes learned from neighbor\n" "Display routes learned from neighbor\n"
"JavaScript Object Notation\n") "JavaScript Object Notation\n")
{ {
int idx_ipv4 = 6;
union sockunion su; union sockunion su;
struct peer *peer; struct peer *peer;
int ret; int ret;
u_char uj = use_json(argc, argv); u_char uj = use_json(argc, argv);
ret = str2sockunion (argv[6]->arg, &su); ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0) if (ret < 0)
{ {
if (uj) if (uj)
@ -927,7 +942,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
json_object_free(json_no); json_object_free(json_no);
} }
else else
vty_out (vty, "Malformed address: %s%s", argv[6]->arg, VTY_NEWLINE); vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -964,13 +979,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
"Display routes learned from neighbor\n" "Display routes learned from neighbor\n"
"JavaScript Object Notation\n") "JavaScript Object Notation\n")
{ {
int idx_ext_community = 5;
int idx_ipv4 = 7;
int ret; int ret;
union sockunion su; union sockunion su;
struct peer *peer; struct peer *peer;
struct prefix_rd prd; struct prefix_rd prd;
u_char uj = use_json(argc, argv); u_char uj = use_json(argc, argv);
ret = str2prefix_rd (argv[5]->arg, &prd); ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret) if (! ret)
{ {
if (uj) if (uj)
@ -986,7 +1003,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
return CMD_WARNING; return CMD_WARNING;
} }
ret = str2sockunion (argv[7]->arg, &su); ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0) if (ret < 0)
{ {
if (uj) if (uj)
@ -998,7 +1015,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
json_object_free(json_no); json_object_free(json_no);
} }
else else
vty_out (vty, "Malformed address: %s%s", argv[5]->arg, VTY_NEWLINE); vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1034,12 +1051,13 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
"Display the routes advertised to a BGP neighbor\n" "Display the routes advertised to a BGP neighbor\n"
"JavaScript Object Notation\n") "JavaScript Object Notation\n")
{ {
int idx_ipv4 = 6;
int ret; int ret;
struct peer *peer; struct peer *peer;
union sockunion su; union sockunion su;
u_char uj = use_json(argc, argv); u_char uj = use_json(argc, argv);
ret = str2sockunion (argv[6]->arg, &su); ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0) if (ret < 0)
{ {
if (uj) if (uj)
@ -1051,7 +1069,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
json_object_free(json_no); json_object_free(json_no);
} }
else else
vty_out (vty, "Malformed address: %s%s", argv[6]->arg, VTY_NEWLINE); vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
peer = peer_lookup (NULL, &su); peer = peer_lookup (NULL, &su);
@ -1087,13 +1105,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
"Display the routes advertised to a BGP neighbor\n" "Display the routes advertised to a BGP neighbor\n"
"JavaScript Object Notation\n") "JavaScript Object Notation\n")
{ {
int idx_ext_community = 5;
int idx_ipv4 = 7;
int ret; int ret;
struct peer *peer; struct peer *peer;
struct prefix_rd prd; struct prefix_rd prd;
union sockunion su; union sockunion su;
u_char uj = use_json(argc, argv); u_char uj = use_json(argc, argv);
ret = str2sockunion (argv[7]->arg, &su); ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0) if (ret < 0)
{ {
if (uj) if (uj)
@ -1105,7 +1125,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
json_object_free(json_no); json_object_free(json_no);
} }
else else
vty_out (vty, "Malformed address: %s%s", argv[5]->arg, VTY_NEWLINE); vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
peer = peer_lookup (NULL, &su); peer = peer_lookup (NULL, &su);
@ -1124,7 +1144,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
return CMD_WARNING; return CMD_WARNING;
} }
ret = str2prefix_rd (argv[5]->arg, &prd); ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret) if (! ret)
{ {
if (uj) if (uj)

View File

@ -520,7 +520,8 @@ DEFUN (show_ip_bgp_instance_nexthop,
BGP_INSTANCE_HELP_STR BGP_INSTANCE_HELP_STR
"BGP nexthop table\n") "BGP nexthop table\n")
{ {
return show_ip_bgp_nexthop_table (vty, argv[4]->arg, 0); int idx_word = 4;
return show_ip_bgp_nexthop_table (vty, argv[idx_word]->arg, 0);
} }
DEFUN (show_ip_bgp_instance_all_nexthop, DEFUN (show_ip_bgp_instance_all_nexthop,
@ -545,7 +546,8 @@ DEFUN (show_ip_bgp_instance_nexthop_detail,
BGP_INSTANCE_HELP_STR BGP_INSTANCE_HELP_STR
"BGP nexthop table\n") "BGP nexthop table\n")
{ {
return show_ip_bgp_nexthop_table (vty, argv[4]->arg, 1); int idx_word = 4;
return show_ip_bgp_nexthop_table (vty, argv[idx_word]->arg, 1);
} }
void void

File diff suppressed because it is too large Load Diff

View File

@ -3000,7 +3000,8 @@ DEFUN (match_peer,
"IP address of peer\n" "IP address of peer\n"
"IPv6 address of peer\n") "IPv6 address of peer\n")
{ {
return bgp_route_match_add (vty, vty->index, "peer", argv[2]->arg, int idx_ip = 2;
return bgp_route_match_add (vty, vty->index, "peer", argv[idx_ip]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -3054,7 +3055,8 @@ DEFUN (match_ip_address,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP Access-list name\n") "IP Access-list name\n")
{ {
return bgp_route_match_add (vty, vty->index, "ip address", argv[3]->arg, int idx_acl = 3;
return bgp_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg,
RMAP_EVENT_FILTER_ADDED); RMAP_EVENT_FILTER_ADDED);
} }
@ -3093,7 +3095,8 @@ DEFUN (match_ip_next_hop,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP Access-list name\n") "IP Access-list name\n")
{ {
return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg, int idx_acl = 3;
return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg,
RMAP_EVENT_FILTER_ADDED); RMAP_EVENT_FILTER_ADDED);
} }
@ -3131,7 +3134,8 @@ DEFUN (match_probability,
"Match portion of routes defined by percentage value\n" "Match portion of routes defined by percentage value\n"
"Percentage of routes\n") "Percentage of routes\n")
{ {
return bgp_route_match_add (vty, vty->index, "probability", argv[2]->arg, int idx_number = 2;
return bgp_route_match_add (vty, vty->index, "probability", argv[idx_number]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -3168,7 +3172,8 @@ DEFUN (match_ip_route_source,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP standard access-list name\n") "IP standard access-list name\n")
{ {
return bgp_route_match_add (vty, vty->index, "ip route-source", argv[3]->arg, int idx_acl = 3;
return bgp_route_match_add (vty, vty->index, "ip route-source", argv[idx_acl]->arg,
RMAP_EVENT_FILTER_ADDED); RMAP_EVENT_FILTER_ADDED);
} }
@ -3206,8 +3211,9 @@ DEFUN (match_ip_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return bgp_route_match_add (vty, vty->index, "ip address prefix-list", return bgp_route_match_add (vty, vty->index, "ip address prefix-list",
argv[4]->arg, RMAP_EVENT_PLIST_ADDED); argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
} }
/* /*
@ -3244,8 +3250,9 @@ DEFUN (match_ip_next_hop_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list", return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list",
argv[4]->arg, RMAP_EVENT_PLIST_ADDED); argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
} }
/* /*
@ -3282,8 +3289,9 @@ DEFUN (match_ip_route_source_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list", return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list",
argv[4]->arg, RMAP_EVENT_PLIST_ADDED); argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
} }
/* /*
@ -3318,7 +3326,8 @@ DEFUN (match_metric,
"Match metric of route\n" "Match metric of route\n"
"Metric value\n") "Metric value\n")
{ {
return bgp_route_match_add (vty, vty->index, "metric", argv[2]->arg, int idx_number = 2;
return bgp_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -3351,7 +3360,8 @@ DEFUN (match_local_pref,
"Match local-preference of route\n" "Match local-preference of route\n"
"Metric value\n") "Metric value\n")
{ {
return bgp_route_match_add (vty, vty->index, "local-preference", argv[2]->arg, int idx_number = 2;
return bgp_route_match_add (vty, vty->index, "local-preference", argv[idx_number]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -3386,7 +3396,8 @@ DEFUN (match_community,
"Community-list number (expanded)\n" "Community-list number (expanded)\n"
"Community-list name\n") "Community-list name\n")
{ {
return bgp_route_match_add (vty, vty->index, "community", argv[2]->arg, int idx_comm_list = 2;
return bgp_route_match_add (vty, vty->index, "community", argv[idx_comm_list]->arg,
RMAP_EVENT_CLIST_ADDED); RMAP_EVENT_CLIST_ADDED);
} }
@ -3400,13 +3411,14 @@ DEFUN (match_community_exact,
"Community-list name\n" "Community-list name\n"
"Do exact matching of communities\n") "Do exact matching of communities\n")
{ {
int idx_comm_list = 2;
int ret; int ret;
char *argstr; char *argstr;
argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
strlen (argv[2]->arg) + strlen ("exact-match") + 2); strlen (argv[idx_comm_list]->arg) + strlen ("exact-match") + 2);
sprintf (argstr, "%s exact-match", argv[2]->arg); sprintf (argstr, "%s exact-match", argv[idx_comm_list]->arg);
ret = bgp_route_match_add (vty, vty->index, "community", argstr, ret = bgp_route_match_add (vty, vty->index, "community", argstr,
RMAP_EVENT_CLIST_ADDED); RMAP_EVENT_CLIST_ADDED);
@ -3458,7 +3470,8 @@ DEFUN (match_ecommunity,
"Extended community-list number (expanded)\n" "Extended community-list number (expanded)\n"
"Extended community-list name\n") "Extended community-list name\n")
{ {
return bgp_route_match_add (vty, vty->index, "extcommunity", argv[2]->arg, int idx_comm_list = 2;
return bgp_route_match_add (vty, vty->index, "extcommunity", argv[idx_comm_list]->arg,
RMAP_EVENT_ECLIST_ADDED); RMAP_EVENT_ECLIST_ADDED);
} }
@ -3492,7 +3505,8 @@ DEFUN (match_aspath,
"Match BGP AS path list\n" "Match BGP AS path list\n"
"AS path access-list name\n") "AS path access-list name\n")
{ {
return bgp_route_match_add (vty, vty->index, "as-path", argv[2]->arg, int idx_word = 2;
return bgp_route_match_add (vty, vty->index, "as-path", argv[idx_word]->arg,
RMAP_EVENT_ASLIST_ADDED); RMAP_EVENT_ASLIST_ADDED);
} }
@ -3526,13 +3540,14 @@ DEFUN (match_origin,
"local IGP\n" "local IGP\n"
"unknown heritage\n") "unknown heritage\n")
{ {
if (strncmp (argv[2]->arg, "igp", 2) == 0) int idx_origin = 2;
if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0)
return bgp_route_match_add (vty, vty->index, "origin", "igp", return bgp_route_match_add (vty, vty->index, "origin", "igp",
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
if (strncmp (argv[2]->arg, "egp", 1) == 0) if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0)
return bgp_route_match_add (vty, vty->index, "origin", "egp", return bgp_route_match_add (vty, vty->index, "origin", "egp",
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
if (strncmp (argv[2]->arg, "incomplete", 2) == 0) if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0)
return bgp_route_match_add (vty, vty->index, "origin", "incomplete", return bgp_route_match_add (vty, vty->index, "origin", "incomplete",
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
@ -3569,7 +3584,8 @@ DEFUN (match_interface,
"Match first hop interface of route\n" "Match first hop interface of route\n"
"Interface name\n") "Interface name\n")
{ {
return bgp_route_match_add (vty, vty->index, "interface", argv[2]->arg, int idx_word = 2;
return bgp_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -3601,7 +3617,8 @@ DEFUN (match_tag,
"Match tag of route\n" "Match tag of route\n"
"Tag value\n") "Tag value\n")
{ {
return bgp_route_match_add (vty, vty->index, "tag", argv[2]->arg, int idx_number = 2;
return bgp_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -3635,10 +3652,11 @@ DEFUN (set_ip_nexthop,
"Next hop address\n" "Next hop address\n"
"IP address of next hop\n") "IP address of next hop\n")
{ {
int idx_ipv4 = 3;
union sockunion su; union sockunion su;
int ret; int ret;
ret = str2sockunion (argv[3]->arg, &su); ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE);
@ -3652,7 +3670,7 @@ DEFUN (set_ip_nexthop,
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[3]->arg); return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg);
} }
DEFUN (set_ip_nexthop_peer, DEFUN (set_ip_nexthop_peer,
@ -3728,7 +3746,8 @@ DEFUN (set_metric,
"Metric value for destination routing protocol\n" "Metric value for destination routing protocol\n"
"Metric value\n") "Metric value\n")
{ {
return bgp_route_set_add (vty, vty->index, "metric", argv[2]->arg); int idx_number = 2;
return bgp_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
} }
@ -3760,7 +3779,8 @@ DEFUN (set_local_pref,
"BGP local preference path attribute\n" "BGP local preference path attribute\n"
"Preference value\n") "Preference value\n")
{ {
return bgp_route_set_add (vty, vty->index, "local-preference", argv[2]->arg); int idx_number = 2;
return bgp_route_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg);
} }
/* /*
@ -3790,7 +3810,8 @@ DEFUN (set_weight,
"BGP weight for routing table\n" "BGP weight for routing table\n"
"Weight value\n") "Weight value\n")
{ {
return bgp_route_set_add (vty, vty->index, "weight", argv[2]->arg); int idx_number = 2;
return bgp_route_set_add (vty, vty->index, "weight", argv[idx_number]->arg);
} }
/* /*
@ -4055,11 +4076,12 @@ DEFUN (set_community_delete,
"Community-list name\n" "Community-list name\n"
"Delete matching communities\n") "Delete matching communities\n")
{ {
int idx_comm_list = 2;
char *str; char *str;
str = XCALLOC (MTYPE_TMP, strlen (argv[2]->arg) + strlen (" delete") + 1); str = XCALLOC (MTYPE_TMP, strlen (argv[idx_comm_list]->arg) + strlen (" delete") + 1);
strcpy (str, argv[2]->arg); strcpy (str, argv[idx_comm_list]->arg);
strcpy (str + strlen (argv[2]->arg), " delete"); strcpy (str + strlen (argv[idx_comm_list]->arg), " delete");
bgp_route_set_add (vty, vty->index, "comm-list", str); bgp_route_set_add (vty, vty->index, "comm-list", str);
@ -4178,11 +4200,12 @@ DEFUN (set_origin,
"local IGP\n" "local IGP\n"
"unknown heritage\n") "unknown heritage\n")
{ {
if (strncmp (argv[2]->arg, "igp", 2) == 0) int idx_origin = 2;
if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0)
return bgp_route_set_add (vty, vty->index, "origin", "igp"); return bgp_route_set_add (vty, vty->index, "origin", "igp");
if (strncmp (argv[2]->arg, "egp", 1) == 0) if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0)
return bgp_route_set_add (vty, vty->index, "origin", "egp"); return bgp_route_set_add (vty, vty->index, "origin", "egp");
if (strncmp (argv[2]->arg, "incomplete", 2) == 0) if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0)
return bgp_route_set_add (vty, vty->index, "origin", "incomplete"); return bgp_route_set_add (vty, vty->index, "origin", "incomplete");
return CMD_WARNING; return CMD_WARNING;
@ -4238,11 +4261,13 @@ DEFUN (set_aggregator_as,
"AS number\n" "AS number\n"
"IP address of aggregator\n") "IP address of aggregator\n")
{ {
int idx_number = 3;
int idx_ipv4 = 4;
int ret; int ret;
struct in_addr address; struct in_addr address;
char *argstr; char *argstr;
ret = inet_aton (argv[4]->arg, &address); ret = inet_aton (argv[idx_ipv4]->arg, &address);
if (ret == 0) if (ret == 0)
{ {
vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE); vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE);
@ -4250,9 +4275,9 @@ DEFUN (set_aggregator_as,
} }
argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
strlen (argv[3]->arg) + strlen (argv[4]->arg) + 2); strlen (argv[idx_number]->arg) + strlen (argv[idx_ipv4]->arg) + 2);
sprintf (argstr, "%s %s", argv[3]->arg, argv[4]->arg); sprintf (argstr, "%s %s", argv[idx_number]->arg, argv[idx_ipv4]->arg);
ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr); ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr);
@ -4314,7 +4339,8 @@ DEFUN (set_tag,
"Tag value for routing protocol\n" "Tag value for routing protocol\n"
"Tag value\n") "Tag value\n")
{ {
return bgp_route_set_add (vty, vty->index, "tag", argv[2]->arg); int idx_number = 2;
return bgp_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
} }
/* /*
@ -4347,7 +4373,8 @@ DEFUN (match_ipv6_address,
"Match IPv6 address of route\n" "Match IPv6 address of route\n"
"IPv6 access-list name\n") "IPv6 access-list name\n")
{ {
return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[3]->arg, int idx_word = 3;
return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[idx_word]->arg,
RMAP_EVENT_FILTER_ADDED); RMAP_EVENT_FILTER_ADDED);
} }
@ -4360,7 +4387,8 @@ DEFUN (no_match_ipv6_address,
"Match IPv6 address of route\n" "Match IPv6 address of route\n"
"IPv6 access-list name\n") "IPv6 access-list name\n")
{ {
return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[4]->arg, int idx_word = 4;
return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[idx_word]->arg,
RMAP_EVENT_FILTER_DELETED); RMAP_EVENT_FILTER_DELETED);
} }
@ -4372,7 +4400,8 @@ DEFUN (match_ipv6_next_hop,
"Match IPv6 next-hop address of route\n" "Match IPv6 next-hop address of route\n"
"IPv6 address of next hop\n") "IPv6 address of next hop\n")
{ {
return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[3]->arg, int idx_ipv6 = 3;
return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -4385,7 +4414,8 @@ DEFUN (no_match_ipv6_next_hop,
"Match IPv6 next-hop address of route\n" "Match IPv6 next-hop address of route\n"
"IPv6 address of next hop\n") "IPv6 address of next hop\n")
{ {
return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[4]->arg, int idx_ipv6 = 4;
return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg,
RMAP_EVENT_MATCH_DELETED); RMAP_EVENT_MATCH_DELETED);
} }
@ -4398,8 +4428,9 @@ DEFUN (match_ipv6_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list", return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list",
argv[4]->arg, RMAP_EVENT_PLIST_ADDED); argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
} }
DEFUN (no_match_ipv6_address_prefix_list, DEFUN (no_match_ipv6_address_prefix_list,
@ -4412,8 +4443,9 @@ DEFUN (no_match_ipv6_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 5;
return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list", return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list",
argv[5]->arg, RMAP_EVENT_PLIST_DELETED); argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
} }
DEFUN (set_ipv6_nexthop_peer, DEFUN (set_ipv6_nexthop_peer,
@ -4471,10 +4503,11 @@ DEFUN (set_ipv6_nexthop_global,
"IPv6 global address\n" "IPv6 global address\n"
"IPv6 address of next hop\n") "IPv6 address of next hop\n")
{ {
int idx_ipv6 = 4;
struct in6_addr addr; struct in6_addr addr;
int ret; int ret;
ret = inet_pton (AF_INET6, argv[4]->arg, &addr); ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr);
if (!ret) if (!ret)
{ {
vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE);
@ -4489,7 +4522,7 @@ DEFUN (set_ipv6_nexthop_global,
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[4]->arg); return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg);
} }
/* /*
@ -4525,10 +4558,11 @@ DEFUN (set_ipv6_nexthop_local,
"IPv6 local address\n" "IPv6 local address\n"
"IPv6 address of next hop\n") "IPv6 address of next hop\n")
{ {
int idx_ipv6 = 4;
struct in6_addr addr; struct in6_addr addr;
int ret; int ret;
ret = inet_pton (AF_INET6, argv[4]->arg, &addr); ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr);
if (!ret) if (!ret)
{ {
vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE);
@ -4540,7 +4574,7 @@ DEFUN (set_ipv6_nexthop_local,
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[4]->arg); return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg);
} }
/* /*
@ -4576,7 +4610,8 @@ DEFUN (set_vpnv4_nexthop,
"VPNv4 next-hop address\n" "VPNv4 next-hop address\n"
"IP address of next hop\n") "IP address of next hop\n")
{ {
return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[3]->arg); int idx_ipv4 = 3;
return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg);
} }
/* /*
@ -4608,7 +4643,8 @@ DEFUN (set_originator_id,
"BGP originator ID attribute\n" "BGP originator ID attribute\n"
"IP address of originator\n") "IP address of originator\n")
{ {
return bgp_route_set_add (vty, vty->index, "originator-id", argv[2]->arg); int idx_ipv4 = 2;
return bgp_route_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg);
} }
/* /*

File diff suppressed because it is too large Load Diff

View File

@ -551,6 +551,10 @@ DEFUN (isis_redistribute,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_afi = 1;
int idx_protocol = 2;
int idx_level = 3;
int idx_metric_rmap = 4;
struct isis_area *area = vty->index; struct isis_area *area = vty->index;
int family; int family;
int afi; int afi;
@ -562,7 +566,7 @@ DEFUN (isis_redistribute,
if (argc < 5) if (argc < 5)
return CMD_WARNING; return CMD_WARNING;
family = str2family(argv[1]->arg); family = str2family(argv[idx_afi]->arg);
if (family < 0) if (family < 0)
return CMD_WARNING; return CMD_WARNING;
@ -570,13 +574,13 @@ DEFUN (isis_redistribute,
if (!afi) if (!afi)
return CMD_WARNING; return CMD_WARNING;
type = proto_redistnum(afi, argv[2]->arg); type = proto_redistnum(afi, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_ISIS) if (type < 0 || type == ZEBRA_ROUTE_ISIS)
return CMD_WARNING; return CMD_WARNING;
if (!strcmp("level-1", argv[3]->arg)) if (!strcmp("level-1", argv[idx_level]->arg))
level = 1; level = 1;
else if (!strcmp("level-2", argv[3]->arg)) else if (!strcmp("level-2", argv[idx_level]->arg))
level = 2; level = 2;
else else
return CMD_WARNING; return CMD_WARNING;
@ -587,11 +591,11 @@ DEFUN (isis_redistribute,
return CMD_WARNING; return CMD_WARNING;
} }
if (argv[4]->arg) if (argv[idx_metric_rmap]->arg)
{ {
char *endp; char *endp;
metric = strtoul(argv[4]->arg, &endp, 10); metric = strtoul(argv[idx_metric_rmap]->arg, &endp, 10);
if (argv[4]->arg[0] == '\0' || *endp != '\0') if (argv[idx_metric_rmap]->arg[0] == '\0' || *endp != '\0')
return CMD_WARNING; return CMD_WARNING;
} }
else else
@ -616,6 +620,9 @@ DEFUN (no_isis_redistribute,
"Redistribute into level-1\n" "Redistribute into level-1\n"
"Redistribute into level-2\n") "Redistribute into level-2\n")
{ {
int idx_afi = 2;
int idx_protocol = 3;
int idx_level = 4;
struct isis_area *area = vty->index; struct isis_area *area = vty->index;
int type; int type;
int level; int level;
@ -625,7 +632,7 @@ DEFUN (no_isis_redistribute,
if (argc < 3) if (argc < 3)
return CMD_WARNING; return CMD_WARNING;
family = str2family(argv[2]->arg); family = str2family(argv[idx_afi]->arg);
if (family < 0) if (family < 0)
return CMD_WARNING; return CMD_WARNING;
@ -633,13 +640,13 @@ DEFUN (no_isis_redistribute,
if (!afi) if (!afi)
return CMD_WARNING; return CMD_WARNING;
type = proto_redistnum(afi, argv[3]->arg); type = proto_redistnum(afi, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_ISIS) if (type < 0 || type == ZEBRA_ROUTE_ISIS)
return CMD_WARNING; return CMD_WARNING;
if (!strcmp("level-1", argv[4]->arg)) if (!strcmp("level-1", argv[idx_level]->arg))
level = 1; level = 1;
else if (!strcmp("level-2", argv[4]->arg)) else if (!strcmp("level-2", argv[idx_level]->arg))
level = 2; level = 2;
else else
return CMD_WARNING; return CMD_WARNING;
@ -663,6 +670,9 @@ DEFUN (isis_default_originate,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_afi = 2;
int idx_level = 3;
int idx_metric_rmap = 4;
struct isis_area *area = vty->index; struct isis_area *area = vty->index;
int family; int family;
int originate_type; int originate_type;
@ -673,13 +683,13 @@ DEFUN (isis_default_originate,
if (argc < 5) if (argc < 5)
return CMD_WARNING; return CMD_WARNING;
family = str2family(argv[2]->arg); family = str2family(argv[idx_afi]->arg);
if (family < 0) if (family < 0)
return CMD_WARNING; return CMD_WARNING;
if (!strcmp("level-1", argv[3]->arg)) if (!strcmp("level-1", argv[idx_level]->arg))
level = 1; level = 1;
else if (!strcmp("level-2", argv[3]->arg)) else if (!strcmp("level-2", argv[idx_level]->arg))
level = 2; level = 2;
else else
return CMD_WARNING; return CMD_WARNING;
@ -690,7 +700,7 @@ DEFUN (isis_default_originate,
return CMD_WARNING; return CMD_WARNING;
} }
if (argv[4]->arg && *argv[4]->arg != '\0') if (argv[idx_metric_rmap]->arg && *argv[idx_metric_rmap]->arg != '\0')
originate_type = DEFAULT_ORIGINATE_ALWAYS; originate_type = DEFAULT_ORIGINATE_ALWAYS;
else else
originate_type = DEFAULT_ORIGINATE; originate_type = DEFAULT_ORIGINATE;
@ -730,6 +740,8 @@ DEFUN (no_isis_default_originate,
"Distribute default route into level-1\n" "Distribute default route into level-1\n"
"Distribute default route into level-2\n") "Distribute default route into level-2\n")
{ {
int idx_afi = 3;
int idx_level = 4;
struct isis_area *area = vty->index; struct isis_area *area = vty->index;
int family; int family;
@ -738,13 +750,13 @@ DEFUN (no_isis_default_originate,
if (argc < 2) if (argc < 2)
return CMD_WARNING; return CMD_WARNING;
family = str2family(argv[3]->arg); family = str2family(argv[idx_afi]->arg);
if (family < 0) if (family < 0)
return CMD_WARNING; return CMD_WARNING;
if (!strcmp("level-1", argv[4]->arg)) if (!strcmp("level-1", argv[idx_level]->arg))
level = 1; level = 1;
else if (!strcmp("level-2", argv[4]->arg)) else if (!strcmp("level-2", argv[idx_level]->arg))
level = 2; level = 2;
else else
return CMD_WARNING; return CMD_WARNING;

View File

@ -354,7 +354,8 @@ DEFUN (match_ip_address,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP Access-list name\n") "IP Access-list name\n")
{ {
return isis_route_match_add(vty, vty->index, "ip address", argv[3]->arg); int idx_acl = 3;
return isis_route_match_add(vty, vty->index, "ip address", argv[idx_acl]->arg);
} }
/* /*
@ -377,9 +378,10 @@ DEFUN (no_match_ip_address,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP Access-list name\n") "IP Access-list name\n")
{ {
int idx_acl = 4;
if (argc == 0) if (argc == 0)
return isis_route_match_delete(vty, vty->index, "ip address", NULL); return isis_route_match_delete(vty, vty->index, "ip address", NULL);
return isis_route_match_delete(vty, vty->index, "ip address", argv[4]->arg); return isis_route_match_delete(vty, vty->index, "ip address", argv[idx_acl]->arg);
} }
@ -394,7 +396,8 @@ DEFUN (match_ip_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
return isis_route_match_add(vty, vty->index, "ip address prefix-list", argv[4]->arg); int idx_word = 4;
return isis_route_match_add(vty, vty->index, "ip address prefix-list", argv[idx_word]->arg);
} }
/* /*
@ -433,7 +436,8 @@ DEFUN (match_ipv6_address,
"Match IPv6 address of route\n" "Match IPv6 address of route\n"
"IPv6 access-list name\n") "IPv6 access-list name\n")
{ {
return isis_route_match_add(vty, vty->index, "ipv6 address", argv[3]->arg); int idx_word = 3;
return isis_route_match_add(vty, vty->index, "ipv6 address", argv[idx_word]->arg);
} }
/* /*
@ -454,9 +458,10 @@ DEFUN (no_match_ipv6_address,
"Match IPv6 address of route\n" "Match IPv6 address of route\n"
"IPv6 access-list name\n") "IPv6 access-list name\n")
{ {
int idx_word = 4;
if (argc == 0) if (argc == 0)
return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL); return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL);
return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[4]->arg); return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[idx_word]->arg);
} }
@ -471,7 +476,8 @@ DEFUN (match_ipv6_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
return isis_route_match_add(vty, vty->index, "ipv6 address prefix-list", argv[4]->arg); int idx_word = 4;
return isis_route_match_add(vty, vty->index, "ipv6 address prefix-list", argv[idx_word]->arg);
} }
/* /*
@ -512,7 +518,8 @@ DEFUN (set_metric,
"Metric vale for destination routing protocol\n" "Metric vale for destination routing protocol\n"
"Metric value\n") "Metric value\n")
{ {
return isis_route_set_add(vty, vty->index, "metric", argv[2]->arg); int idx_number = 2;
return isis_route_set_add(vty, vty->index, "metric", argv[idx_number]->arg);
} }
/* /*
@ -534,9 +541,10 @@ DEFUN (no_set_metric,
"Metric value for destination routing protocol\n" "Metric value for destination routing protocol\n"
"Metric value\n") "Metric value\n")
{ {
int idx_number = 3;
if (argc == 0) if (argc == 0)
return isis_route_set_delete(vty, vty->index, "metric", NULL); return isis_route_set_delete(vty, vty->index, "metric", NULL);
return isis_route_set_delete(vty, vty->index, "metric", argv[3]->arg); return isis_route_set_delete(vty, vty->index, "metric", argv[idx_number]->arg);
} }
{ {

View File

@ -1163,11 +1163,12 @@ DEFUN (isis_mpls_te_router_addr,
"Stable IP address of the advertising router\n" "Stable IP address of the advertising router\n"
"MPLS-TE router address in IPv4 address format\n") "MPLS-TE router address in IPv4 address format\n")
{ {
int idx_ipv4 = 2;
struct in_addr value; struct in_addr value;
struct listnode *node; struct listnode *node;
struct isis_area *area; struct isis_area *area;
if (! inet_aton (argv[2]->arg, &value)) if (! inet_aton (argv[idx_ipv4]->arg, &value))
{ {
vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -1317,6 +1318,7 @@ DEFUN (show_isis_mpls_te_interface,
"Interface information\n" "Interface information\n"
"Interface name\n") "Interface name\n")
{ {
int idx_interface = 4;
struct interface *ifp; struct interface *ifp;
struct listnode *node; struct listnode *node;
@ -1329,7 +1331,7 @@ DEFUN (show_isis_mpls_te_interface,
/* Interface name is specified. */ /* Interface name is specified. */
else else
{ {
if ((ifp = if_lookup_by_name (argv[4]->arg)) == NULL) if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL)
vty_out (vty, "No such interface name%s", VTY_NEWLINE); vty_out (vty, "No such interface name%s", VTY_NEWLINE);
else else
show_mpls_te_sub (vty, ifp); show_mpls_te_sub (vty, ifp);

View File

@ -61,11 +61,13 @@ DEFUN (ip_router_isis,
"IS-IS Routing for IP\n" "IS-IS Routing for IP\n"
"Routing process tag\n") "Routing process tag\n")
{ {
int idx_afi = 0;
int idx_word = 3;
struct interface *ifp; struct interface *ifp;
struct isis_circuit *circuit; struct isis_circuit *circuit;
struct isis_area *area; struct isis_area *area;
const char *af = argv[0]->arg; const char *af = argv[idx_afi]->arg;
const char *area_tag = argv[3]->arg; const char *area_tag = argv[idx_word]->arg;
ifp = (struct interface *) vty->index; ifp = (struct interface *) vty->index;
assert (ifp); assert (ifp);
@ -115,11 +117,13 @@ DEFUN (no_ip_router_isis,
"IS-IS Routing for IP\n" "IS-IS Routing for IP\n"
"Routing process tag\n") "Routing process tag\n")
{ {
int idx_afi = 1;
int idx_word = 4;
struct interface *ifp; struct interface *ifp;
struct isis_area *area; struct isis_area *area;
struct isis_circuit *circuit; struct isis_circuit *circuit;
const char *af = argv[1]->arg; const char *af = argv[idx_afi]->arg;
const char *area_tag = argv[4]->arg; const char *area_tag = argv[idx_word]->arg;
ifp = (struct interface *) vty->index; ifp = (struct interface *) vty->index;
if (!ifp) if (!ifp)
@ -132,7 +136,7 @@ DEFUN (no_ip_router_isis,
if (!area) if (!area)
{ {
vty_out (vty, "Can't find ISIS instance %s%s", vty_out (vty, "Can't find ISIS instance %s%s",
argv[1]->arg, VTY_NEWLINE); argv[idx_afi]->arg, VTY_NEWLINE);
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
} }
@ -199,12 +203,13 @@ DEFUN (isis_circuit_type,
"Level-1-2 adjacencies are formed\n" "Level-1-2 adjacencies are formed\n"
"Level-2 only adjacencies are formed\n") "Level-2 only adjacencies are formed\n")
{ {
int idx_level = 2;
int is_type; int is_type;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
is_type = string2circuit_t (argv[2]->arg); is_type = string2circuit_t (argv[idx_level]->arg);
if (!is_type) if (!is_type)
{ {
vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE); vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
@ -305,15 +310,17 @@ DEFUN (isis_passwd,
"Cleartext password\n" "Cleartext password\n"
"Circuit password\n") "Circuit password\n")
{ {
int idx_encryption = 2;
int idx_word = 3;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
int rv; int rv;
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
if (argv[2]->arg[0] == 'm') if (argv[idx_encryption]->arg[0] == 'm')
rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[3]->arg); rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[idx_word]->arg);
else else
rv = isis_circuit_passwd_cleartext_set(circuit, argv[3]->arg); rv = isis_circuit_passwd_cleartext_set(circuit, argv[idx_word]->arg);
if (rv) if (rv)
{ {
vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
@ -358,12 +365,13 @@ DEFUN (isis_priority,
"Set priority for Designated Router election\n" "Set priority for Designated Router election\n"
"Priority value\n") "Priority value\n")
{ {
int idx_number = 2;
int prio; int prio;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
prio = atoi (argv[2]->arg); prio = atoi (argv[idx_number]->arg);
if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
{ {
vty_out (vty, "Invalid priority %d - should be <0-127>%s", vty_out (vty, "Invalid priority %d - should be <0-127>%s",
@ -412,12 +420,13 @@ DEFUN (isis_priority_l1,
"Priority value\n" "Priority value\n"
"Specify priority for level-1 routing\n") "Specify priority for level-1 routing\n")
{ {
int idx_number = 2;
int prio; int prio;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
prio = atoi (argv[2]->arg); prio = atoi (argv[idx_number]->arg);
if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
{ {
vty_out (vty, "Invalid priority %d - should be <0-127>%s", vty_out (vty, "Invalid priority %d - should be <0-127>%s",
@ -466,12 +475,13 @@ DEFUN (isis_priority_l2,
"Priority value\n" "Priority value\n"
"Specify priority for level-2 routing\n") "Specify priority for level-2 routing\n")
{ {
int idx_number = 2;
int prio; int prio;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
prio = atoi (argv[2]->arg); prio = atoi (argv[idx_number]->arg);
if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
{ {
vty_out (vty, "Invalid priority %d - should be <0-127>%s", vty_out (vty, "Invalid priority %d - should be <0-127>%s",
@ -520,12 +530,13 @@ DEFUN (isis_metric,
"Set default metric for circuit\n" "Set default metric for circuit\n"
"Default metric value\n") "Default metric value\n")
{ {
int idx_number = 2;
int met; int met;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
met = atoi (argv[2]->arg); met = atoi (argv[idx_number]->arg);
/* RFC3787 section 5.1 */ /* RFC3787 section 5.1 */
if (circuit->area && circuit->area->oldmetric == 1 && if (circuit->area && circuit->area->oldmetric == 1 &&
@ -586,12 +597,13 @@ DEFUN (isis_metric_l1,
"Default metric value\n" "Default metric value\n"
"Specify metric for level-1 routing\n") "Specify metric for level-1 routing\n")
{ {
int idx_number = 2;
int met; int met;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
met = atoi (argv[2]->arg); met = atoi (argv[idx_number]->arg);
/* RFC3787 section 5.1 */ /* RFC3787 section 5.1 */
if (circuit->area && circuit->area->oldmetric == 1 && if (circuit->area && circuit->area->oldmetric == 1 &&
@ -652,12 +664,13 @@ DEFUN (isis_metric_l2,
"Default metric value\n" "Default metric value\n"
"Specify metric for level-2 routing\n") "Specify metric for level-2 routing\n")
{ {
int idx_number = 2;
int met; int met;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
met = atoi (argv[2]->arg); met = atoi (argv[idx_number]->arg);
/* RFC3787 section 5.1 */ /* RFC3787 section 5.1 */
if (circuit->area && circuit->area->oldmetric == 1 && if (circuit->area && circuit->area->oldmetric == 1 &&
@ -719,12 +732,13 @@ DEFUN (isis_hello_interval,
"Hello interval value\n" "Hello interval value\n"
"Holdtime 1 seconds, interval depends on multiplier\n") "Holdtime 1 seconds, interval depends on multiplier\n")
{ {
int idx_number = 2;
int interval; int interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atoi (argv[2]->arg); interval = atoi (argv[idx_number]->arg);
if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
{ {
vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s", vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s",
@ -775,12 +789,13 @@ DEFUN (isis_hello_interval_l1,
"Holdtime 1 second, interval depends on multiplier\n" "Holdtime 1 second, interval depends on multiplier\n"
"Specify hello-interval for level-1 IIHs\n") "Specify hello-interval for level-1 IIHs\n")
{ {
int idx_number = 2;
long interval; long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atoi (argv[2]->arg); interval = atoi (argv[idx_number]->arg);
if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
{ {
vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
@ -831,12 +846,13 @@ DEFUN (isis_hello_interval_l2,
"Holdtime 1 second, interval depends on multiplier\n" "Holdtime 1 second, interval depends on multiplier\n"
"Specify hello-interval for level-2 IIHs\n") "Specify hello-interval for level-2 IIHs\n")
{ {
int idx_number = 2;
long interval; long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atoi (argv[2]->arg); interval = atoi (argv[idx_number]->arg);
if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
{ {
vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
@ -885,12 +901,13 @@ DEFUN (isis_hello_multiplier,
"Set multiplier for Hello holding time\n" "Set multiplier for Hello holding time\n"
"Hello multiplier value\n") "Hello multiplier value\n")
{ {
int idx_number = 2;
int mult; int mult;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
mult = atoi (argv[2]->arg); mult = atoi (argv[idx_number]->arg);
if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
{ {
vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
@ -939,12 +956,13 @@ DEFUN (isis_hello_multiplier_l1,
"Hello multiplier value\n" "Hello multiplier value\n"
"Specify hello multiplier for level-1 IIHs\n") "Specify hello multiplier for level-1 IIHs\n")
{ {
int idx_number = 2;
int mult; int mult;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
mult = atoi (argv[2]->arg); mult = atoi (argv[idx_number]->arg);
if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
{ {
vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
@ -993,12 +1011,13 @@ DEFUN (isis_hello_multiplier_l2,
"Hello multiplier value\n" "Hello multiplier value\n"
"Specify hello multiplier for level-2 IIHs\n") "Specify hello multiplier for level-2 IIHs\n")
{ {
int idx_number = 2;
int mult; int mult;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
mult = atoi (argv[2]->arg); mult = atoi (argv[idx_number]->arg);
if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
{ {
vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
@ -1081,12 +1100,13 @@ DEFUN (csnp_interval,
"Set CSNP interval in seconds\n" "Set CSNP interval in seconds\n"
"CSNP interval value\n") "CSNP interval value\n")
{ {
int idx_number = 2;
unsigned long interval; unsigned long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atol (argv[2]->arg); interval = atol (argv[idx_number]->arg);
if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
{ {
vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
@ -1135,12 +1155,13 @@ DEFUN (csnp_interval_l1,
"CSNP interval value\n" "CSNP interval value\n"
"Specify interval for level-1 CSNPs\n") "Specify interval for level-1 CSNPs\n")
{ {
int idx_number = 2;
unsigned long interval; unsigned long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atol (argv[2]->arg); interval = atol (argv[idx_number]->arg);
if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
{ {
vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
@ -1189,12 +1210,13 @@ DEFUN (csnp_interval_l2,
"CSNP interval value\n" "CSNP interval value\n"
"Specify interval for level-2 CSNPs\n") "Specify interval for level-2 CSNPs\n")
{ {
int idx_number = 2;
unsigned long interval; unsigned long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atol (argv[2]->arg); interval = atol (argv[idx_number]->arg);
if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
{ {
vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
@ -1242,12 +1264,13 @@ DEFUN (psnp_interval,
"Set PSNP interval in seconds\n" "Set PSNP interval in seconds\n"
"PSNP interval value\n") "PSNP interval value\n")
{ {
int idx_number = 2;
unsigned long interval; unsigned long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atol (argv[2]->arg); interval = atol (argv[idx_number]->arg);
if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
{ {
vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
@ -1296,12 +1319,13 @@ DEFUN (psnp_interval_l1,
"PSNP interval value\n" "PSNP interval value\n"
"Specify interval for level-1 PSNPs\n") "Specify interval for level-1 PSNPs\n")
{ {
int idx_number = 2;
unsigned long interval; unsigned long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atol (argv[2]->arg); interval = atol (argv[idx_number]->arg);
if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
{ {
vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
@ -1350,12 +1374,13 @@ DEFUN (psnp_interval_l2,
"PSNP interval value\n" "PSNP interval value\n"
"Specify interval for level-2 PSNPs\n") "Specify interval for level-2 PSNPs\n")
{ {
int idx_number = 2;
unsigned long interval; unsigned long interval;
struct isis_circuit *circuit = isis_circuit_lookup (vty); struct isis_circuit *circuit = isis_circuit_lookup (vty);
if (!circuit) if (!circuit)
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
interval = atol (argv[2]->arg); interval = atol (argv[idx_number]->arg);
if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
{ {
vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
@ -1442,12 +1467,13 @@ DEFUN (metric_style,
"Send and accept both styles of TLVs during transition\n" "Send and accept both styles of TLVs during transition\n"
"Use new style of TLVs to carry wider metric\n") "Use new style of TLVs to carry wider metric\n")
{ {
int idx_metric_style = 1;
struct isis_area *area = vty->index; struct isis_area *area = vty->index;
int ret; int ret;
assert(area); assert(area);
if (strncmp (argv[1]->arg, "w", 1) == 0) if (strncmp (argv[idx_metric_style]->arg, "w", 1) == 0)
{ {
isis_area_metricstyle_set(area, false, true); isis_area_metricstyle_set(area, false, true);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1457,9 +1483,9 @@ DEFUN (metric_style,
if (ret != CMD_SUCCESS) if (ret != CMD_SUCCESS)
return ret; return ret;
if (strncmp (argv[1]->arg, "t", 1) == 0) if (strncmp (argv[idx_metric_style]->arg, "t", 1) == 0)
isis_area_metricstyle_set(area, true, true); isis_area_metricstyle_set(area, true, true);
else if (strncmp (argv[1]->arg, "n", 1) == 0) else if (strncmp (argv[idx_metric_style]->arg, "n", 1) == 0)
isis_area_metricstyle_set(area, true, false); isis_area_metricstyle_set(area, true, false);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1597,9 +1623,10 @@ DEFUN (area_lsp_mtu,
"Configure the maximum size of generated LSPs\n" "Configure the maximum size of generated LSPs\n"
"Maximum size of generated LSPs\n") "Maximum size of generated LSPs\n")
{ {
int idx_number = 1;
unsigned int lsp_mtu; unsigned int lsp_mtu;
VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[1]->arg, 128, 4352); VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[idx_number]->arg, 128, 4352);
return area_lsp_mtu_set(vty, lsp_mtu); return area_lsp_mtu_set(vty, lsp_mtu);
} }
@ -1630,6 +1657,7 @@ DEFUN (is_type,
"Act as both a station router and an area router\n" "Act as both a station router and an area router\n"
"Act as an area router only\n") "Act as an area router only\n")
{ {
int idx_level = 1;
struct isis_area *area; struct isis_area *area;
int type; int type;
@ -1641,7 +1669,7 @@ DEFUN (is_type,
return CMD_ERR_NO_MATCH; return CMD_ERR_NO_MATCH;
} }
type = string2circuit_t (argv[1]->arg); type = string2circuit_t (argv[idx_level]->arg);
if (!type) if (!type)
{ {
vty_out (vty, "Unknown IS level %s", VTY_NEWLINE); vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
@ -1719,12 +1747,13 @@ DEFUN (lsp_gen_interval,
"Minimum interval between regenerating same LSP\n" "Minimum interval between regenerating same LSP\n"
"Minimum interval in seconds\n") "Minimum interval in seconds\n")
{ {
int idx_number = 1;
struct isis_area *area; struct isis_area *area;
uint16_t interval; uint16_t interval;
int level; int level;
area = vty->index; area = vty->index;
interval = atoi (argv[1]->arg); interval = atoi (argv[idx_number]->arg);
level = IS_LEVEL_1 | IS_LEVEL_2; level = IS_LEVEL_1 | IS_LEVEL_2;
return set_lsp_gen_interval (vty, area, interval, level); return set_lsp_gen_interval (vty, area, interval, level);
} }
@ -1761,12 +1790,13 @@ DEFUN (lsp_gen_interval_l1,
"Set interval for level 1 only\n" "Set interval for level 1 only\n"
"Minimum interval in seconds\n") "Minimum interval in seconds\n")
{ {
int idx_number = 2;
struct isis_area *area; struct isis_area *area;
uint16_t interval; uint16_t interval;
int level; int level;
area = vty->index; area = vty->index;
interval = atoi (argv[2]->arg); interval = atoi (argv[idx_number]->arg);
level = IS_LEVEL_1; level = IS_LEVEL_1;
return set_lsp_gen_interval (vty, area, interval, level); return set_lsp_gen_interval (vty, area, interval, level);
} }
@ -1805,12 +1835,13 @@ DEFUN (lsp_gen_interval_l2,
"Set interval for level 2 only\n" "Set interval for level 2 only\n"
"Minimum interval in seconds\n") "Minimum interval in seconds\n")
{ {
int idx_number = 2;
struct isis_area *area; struct isis_area *area;
uint16_t interval; uint16_t interval;
int level; int level;
area = vty->index; area = vty->index;
interval = atoi (argv[2]->arg); interval = atoi (argv[idx_number]->arg);
level = IS_LEVEL_2; level = IS_LEVEL_2;
return set_lsp_gen_interval (vty, area, interval, level); return set_lsp_gen_interval (vty, area, interval, level);
} }
@ -1848,11 +1879,12 @@ DEFUN (spf_interval,
"Minimum interval between SPF calculations\n" "Minimum interval between SPF calculations\n"
"Minimum interval between consecutive SPFs in seconds\n") "Minimum interval between consecutive SPFs in seconds\n")
{ {
int idx_number = 1;
struct isis_area *area; struct isis_area *area;
u_int16_t interval; u_int16_t interval;
area = vty->index; area = vty->index;
interval = atoi (argv[1]->arg); interval = atoi (argv[idx_number]->arg);
area->min_spf_interval[0] = interval; area->min_spf_interval[0] = interval;
area->min_spf_interval[1] = interval; area->min_spf_interval[1] = interval;
@ -1903,11 +1935,12 @@ DEFUN (spf_interval_l1,
"Set interval for level 1 only\n" "Set interval for level 1 only\n"
"Minimum interval between consecutive SPFs in seconds\n") "Minimum interval between consecutive SPFs in seconds\n")
{ {
int idx_number = 2;
struct isis_area *area; struct isis_area *area;
u_int16_t interval; u_int16_t interval;
area = vty->index; area = vty->index;
interval = atoi (argv[2]->arg); interval = atoi (argv[idx_number]->arg);
area->min_spf_interval[0] = interval; area->min_spf_interval[0] = interval;
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1937,11 +1970,12 @@ DEFUN (spf_interval_l2,
"Set interval for level 2 only\n" "Set interval for level 2 only\n"
"Minimum interval between consecutive SPFs in seconds\n") "Minimum interval between consecutive SPFs in seconds\n")
{ {
int idx_number = 2;
struct isis_area *area; struct isis_area *area;
u_int16_t interval; u_int16_t interval;
area = vty->index; area = vty->index;
interval = atoi (argv[2]->arg); interval = atoi (argv[idx_number]->arg);
area->min_spf_interval[1] = interval; area->min_spf_interval[1] = interval;
return CMD_SUCCESS; return CMD_SUCCESS;
@ -2022,7 +2056,8 @@ DEFUN (max_lsp_lifetime,
"Maximum LSP lifetime\n" "Maximum LSP lifetime\n"
"LSP lifetime in seconds\n") "LSP lifetime in seconds\n")
{ {
return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, atoi(argv[1]->arg)); int idx_number = 1;
return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, atoi(argv[idx_number]->arg));
} }
/* /*
@ -2050,7 +2085,8 @@ DEFUN (max_lsp_lifetime_l1,
"Maximum LSP lifetime for Level 1 only\n" "Maximum LSP lifetime for Level 1 only\n"
"LSP lifetime for Level 1 only in seconds\n") "LSP lifetime for Level 1 only in seconds\n")
{ {
return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, atoi(argv[2]->arg)); int idx_number = 2;
return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, atoi(argv[idx_number]->arg));
} }
/* /*
@ -2077,7 +2113,8 @@ DEFUN (max_lsp_lifetime_l2,
"Maximum LSP lifetime for Level 2 only\n" "Maximum LSP lifetime for Level 2 only\n"
"LSP lifetime for Level 2 only in seconds\n") "LSP lifetime for Level 2 only in seconds\n")
{ {
return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, atoi(argv[2]->arg)); int idx_number = 2;
return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, atoi(argv[idx_number]->arg));
} }
/* /*
@ -2148,7 +2185,8 @@ DEFUN (lsp_refresh_interval,
"LSP refresh interval\n" "LSP refresh interval\n"
"LSP refresh interval in seconds\n") "LSP refresh interval in seconds\n")
{ {
return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, atoi(argv[1]->arg)); int idx_number = 1;
return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, atoi(argv[idx_number]->arg));
} }
/* /*
@ -2176,7 +2214,8 @@ DEFUN (lsp_refresh_interval_l1,
"LSP refresh interval for Level 1 only\n" "LSP refresh interval for Level 1 only\n"
"LSP refresh interval for Level 1 only in seconds\n") "LSP refresh interval for Level 1 only in seconds\n")
{ {
return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, atoi(argv[2]->arg)); int idx_number = 2;
return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, atoi(argv[idx_number]->arg));
} }
/* /*
@ -2204,7 +2243,8 @@ DEFUN (lsp_refresh_interval_l2,
"LSP refresh interval for Level 2 only\n" "LSP refresh interval for Level 2 only\n"
"LSP refresh interval for Level 2 only in seconds\n") "LSP refresh interval for Level 2 only in seconds\n")
{ {
return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, atoi(argv[2]->arg)); int idx_number = 2;
return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, atoi(argv[idx_number]->arg));
} }
/* /*
@ -2271,8 +2311,10 @@ DEFUN (area_passwd_md5,
"Authentication type\n" "Authentication type\n"
"Level-wide password\n") "Level-wide password\n")
{ {
int idx_password = 0;
int idx_word = 2;
u_char snp_auth = 0; u_char snp_auth = 0;
int level = (argv[0]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; int level = (argv[idx_password]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1;
if (argc > 2) if (argc > 2)
{ {
@ -2282,7 +2324,7 @@ DEFUN (area_passwd_md5,
} }
return area_passwd_set(vty, level, isis_area_passwd_hmac_md5_set, return area_passwd_set(vty, level, isis_area_passwd_hmac_md5_set,
argv[2]->arg, snp_auth); argv[idx_word]->arg, snp_auth);
} }
@ -2307,8 +2349,10 @@ DEFUN (area_passwd_clear,
"Authentication type\n" "Authentication type\n"
"Area password\n") "Area password\n")
{ {
int idx_password = 0;
int idx_word = 2;
u_char snp_auth = 0; u_char snp_auth = 0;
int level = (argv[0]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; int level = (argv[idx_password]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1;
if (argc > 2) if (argc > 2)
{ {
@ -2318,7 +2362,7 @@ DEFUN (area_passwd_clear,
} }
return area_passwd_set(vty, level, isis_area_passwd_cleartext_set, return area_passwd_set(vty, level, isis_area_passwd_cleartext_set,
argv[2]->arg, snp_auth); argv[idx_word]->arg, snp_auth);
} }
@ -2329,7 +2373,8 @@ DEFUN (no_area_passwd,
"Configure the authentication password for an area\n" "Configure the authentication password for an area\n"
"Set the authentication password for a routing domain\n") "Set the authentication password for a routing domain\n")
{ {
int level = (argv[1]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; int idx_password = 1;
int level = (argv[idx_password]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1;
struct isis_area *area = vty->index; struct isis_area *area = vty->index;
if (!area) if (!area)

View File

@ -533,7 +533,8 @@ DEFUN (show_isis_interface_arg,
"ISIS interface\n" "ISIS interface\n"
"ISIS interface name\n") "ISIS interface name\n")
{ {
return show_isis_interface_common (vty, argv[3]->arg, ISIS_UI_LEVEL_DETAIL); int idx_word = 3;
return show_isis_interface_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
} }
/* /*
@ -707,7 +708,8 @@ DEFUN (show_isis_neighbor_arg,
"ISIS neighbor adjacencies\n" "ISIS neighbor adjacencies\n"
"System id\n") "System id\n")
{ {
return show_isis_neighbor_common (vty, argv[3]->arg, ISIS_UI_LEVEL_DETAIL); int idx_word = 3;
return show_isis_neighbor_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
} }
DEFUN (clear_isis_neighbor, DEFUN (clear_isis_neighbor,
@ -728,7 +730,8 @@ DEFUN (clear_isis_neighbor_arg,
"ISIS neighbor adjacencies\n" "ISIS neighbor adjacencies\n"
"System id\n") "System id\n")
{ {
return clear_isis_neighbor_common (vty, argv[3]->arg); int idx_word = 3;
return clear_isis_neighbor_common (vty, argv[idx_word]->arg);
} }
/* /*
@ -1530,7 +1533,8 @@ DEFUN (show_database_lsp_brief,
"IS-IS link state database\n" "IS-IS link state database\n"
"LSP ID\n") "LSP ID\n")
{ {
return show_isis_database (vty, argv[3]->arg, ISIS_UI_LEVEL_BRIEF); int idx_word = 3;
return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_BRIEF);
} }
DEFUN (show_database_lsp_detail, DEFUN (show_database_lsp_detail,
@ -1542,7 +1546,8 @@ DEFUN (show_database_lsp_detail,
"LSP ID\n" "LSP ID\n"
"Detailed information\n") "Detailed information\n")
{ {
return show_isis_database (vty, argv[3]->arg, ISIS_UI_LEVEL_DETAIL); int idx_word = 3;
return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
} }
DEFUN (show_database_detail, DEFUN (show_database_detail,
@ -1564,7 +1569,8 @@ DEFUN (show_database_detail_lsp,
"Detailed information\n" "Detailed information\n"
"LSP ID\n") "LSP ID\n")
{ {
return show_isis_database (vty, argv[4]->arg, ISIS_UI_LEVEL_DETAIL); int idx_word = 4;
return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
} }
/* /*
@ -1577,7 +1583,8 @@ DEFUN (router_isis,
"ISO IS-IS\n" "ISO IS-IS\n"
"ISO Routing area tag") "ISO Routing area tag")
{ {
return isis_area_get (vty, argv[2]->arg); int idx_word = 2;
return isis_area_get (vty, argv[idx_word]->arg);
} }
/* /*
@ -1588,7 +1595,8 @@ DEFUN (no_router_isis,
"no router isis WORD", "no router isis WORD",
"no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag") "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
{ {
return isis_area_destroy (vty, argv[3]->arg); int idx_word = 3;
return isis_area_destroy (vty, argv[idx_word]->arg);
} }
/* /*
@ -1600,7 +1608,8 @@ DEFUN (net,
"A Network Entity Title for this process (OSI only)\n" "A Network Entity Title for this process (OSI only)\n"
"XX.XXXX. ... .XXX.XX Network entity title (NET)\n") "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
{ {
return area_net_title (vty, argv[1]->arg); int idx_word = 1;
return area_net_title (vty, argv[idx_word]->arg);
} }
/* /*
@ -1613,7 +1622,8 @@ DEFUN (no_net,
"A Network Entity Title for this process (OSI only)\n" "A Network Entity Title for this process (OSI only)\n"
"XX.XXXX. ... .XXX.XX Network entity title (NET)\n") "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
{ {
return area_clear_net_title (vty, argv[2]->arg); int idx_word = 2;
return area_clear_net_title (vty, argv[idx_word]->arg);
} }
void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu) void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
@ -1966,14 +1976,15 @@ DEFUN (topology_baseis,
"A Network IS Base for this topology\n" "A Network IS Base for this topology\n"
"XXXX.XXXX.XXXX Network entity title (NET)\n") "XXXX.XXXX.XXXX Network entity title (NET)\n")
{ {
int idx_word = 2;
struct isis_area *area; struct isis_area *area;
u_char buff[ISIS_SYS_ID_LEN]; u_char buff[ISIS_SYS_ID_LEN];
area = vty->index; area = vty->index;
assert (area); assert (area);
if (sysid2buff (buff, argv[2]->arg)) if (sysid2buff (buff, argv[idx_word]->arg))
sysid2buff (area->topology_baseis, argv[2]->arg); sysid2buff (area->topology_baseis, argv[idx_word]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -2011,13 +2022,14 @@ DEFUN (topology_basedynh,
"Dynamic hostname base for this topology\n" "Dynamic hostname base for this topology\n"
"Dynamic hostname base\n") "Dynamic hostname base\n")
{ {
int idx_word = 2;
struct isis_area *area; struct isis_area *area;
area = vty->index; area = vty->index;
assert (area); assert (area);
/* I hope that it's enough. */ /* I hope that it's enough. */
area->topology_basedynh = strndup (argv[2]->arg, 16); area->topology_basedynh = strndup (argv[idx_word]->arg, 16);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -468,18 +468,20 @@ DEFUN (area_range,
"Specify IPv6 prefix\n" "Specify IPv6 prefix\n"
) )
{ {
int idx_ipv4 = 1;
int idx_ipv6_prefixlen = 3;
int ret; int ret;
struct ospf6_area *oa; struct ospf6_area *oa;
struct prefix prefix; struct prefix prefix;
struct ospf6_route *range; struct ospf6_route *range;
u_int32_t cost = OSPF_AREA_RANGE_COST_UNSPEC; u_int32_t cost = OSPF_AREA_RANGE_COST_UNSPEC;
OSPF6_CMD_AREA_GET (argv[1]->arg, oa); OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa);
ret = str2prefix (argv[3]->arg, &prefix); ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &prefix);
if (ret != 1 || prefix.family != AF_INET6) if (ret != 1 || prefix.family != AF_INET6)
{ {
vty_out (vty, "Malformed argument: %s%s", argv[3]->arg, VNL); vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv6_prefixlen]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -514,7 +516,7 @@ DEFUN (area_range,
range->path.u.cost_config = cost; range->path.u.cost_config = cost;
zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[3]->arg, range->flag); zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[idx_ipv6_prefixlen]->arg, range->flag);
if (range->rnode == NULL) if (range->rnode == NULL)
{ {
ospf6_route_add (range, oa->range_table); ospf6_route_add (range, oa->range_table);
@ -569,26 +571,27 @@ DEFUN (no_area_range,
"Configured address range\n" "Configured address range\n"
"Specify IPv6 prefix\n") "Specify IPv6 prefix\n")
{ {
int idx_ipv4 = 2;
int ret; int ret;
struct ospf6_area *oa; struct ospf6_area *oa;
struct prefix prefix; struct prefix prefix;
struct ospf6_route *range, *route; struct ospf6_route *range, *route;
OSPF6_CMD_AREA_GET (argv[2]->arg, oa); OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa);
argc--; argc--;
argv++; argv++;
ret = str2prefix (argv[2]->arg, &prefix); ret = str2prefix (argv[idx_ipv4]->arg, &prefix);
if (ret != 1 || prefix.family != AF_INET6) if (ret != 1 || prefix.family != AF_INET6)
{ {
vty_out (vty, "Malformed argument: %s%s", argv[2]->arg, VNL); vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
range = ospf6_route_lookup (&prefix, oa->range_table); range = ospf6_route_lookup (&prefix, oa->range_table);
if (range == NULL) if (range == NULL)
{ {
vty_out (vty, "Range %s does not exists.%s", argv[2]->arg, VNL); vty_out (vty, "Range %s does not exists.%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -677,21 +680,23 @@ DEFUN (area_filter_list,
"Filter networks sent to this area\n" "Filter networks sent to this area\n"
"Filter networks sent from this area\n") "Filter networks sent from this area\n")
{ {
int idx_ipv4 = 1;
int idx_word = 4;
struct ospf6_area *area; struct ospf6_area *area;
struct prefix_list *plist; struct prefix_list *plist;
OSPF6_CMD_AREA_GET (argv[1]->arg, area); OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area);
argc--; argc--;
argv++; argv++;
plist = prefix_list_lookup (AFI_IP6, argv[1]->arg); plist = prefix_list_lookup (AFI_IP6, argv[idx_ipv4]->arg);
if (strncmp (argv[4]->arg, "in", 2) == 0) if (strncmp (argv[idx_word]->arg, "in", 2) == 0)
{ {
PREFIX_LIST_IN (area) = plist; PREFIX_LIST_IN (area) = plist;
if (PREFIX_NAME_IN (area)) if (PREFIX_NAME_IN (area))
free (PREFIX_NAME_IN (area)); free (PREFIX_NAME_IN (area));
PREFIX_NAME_IN (area) = strdup (argv[1]->arg); PREFIX_NAME_IN (area) = strdup (argv[idx_ipv4]->arg);
ospf6_abr_reimport (area); ospf6_abr_reimport (area);
} }
else else
@ -700,7 +705,7 @@ DEFUN (area_filter_list,
if (PREFIX_NAME_OUT (area)) if (PREFIX_NAME_OUT (area))
free (PREFIX_NAME_OUT (area)); free (PREFIX_NAME_OUT (area));
PREFIX_NAME_OUT (area) = strdup (argv[1]->arg); PREFIX_NAME_OUT (area) = strdup (argv[idx_ipv4]->arg);
ospf6_abr_enable_area (area); ospf6_abr_enable_area (area);
} }
@ -719,16 +724,18 @@ DEFUN (no_area_filter_list,
"Filter networks sent to this area\n" "Filter networks sent to this area\n"
"Filter networks sent from this area\n") "Filter networks sent from this area\n")
{ {
int idx_ipv4 = 2;
int idx_word = 5;
struct ospf6_area *area; struct ospf6_area *area;
OSPF6_CMD_AREA_GET (argv[2]->arg, area); OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area);
argc--; argc--;
argv++; argv++;
if (strncmp (argv[5]->arg, "in", 2) == 0) if (strncmp (argv[idx_word]->arg, "in", 2) == 0)
{ {
if (PREFIX_NAME_IN (area)) if (PREFIX_NAME_IN (area))
if (strcmp (PREFIX_NAME_IN (area), argv[2]->arg) != 0) if (strcmp (PREFIX_NAME_IN (area), argv[idx_ipv4]->arg) != 0)
return CMD_SUCCESS; return CMD_SUCCESS;
PREFIX_LIST_IN (area) = NULL; PREFIX_LIST_IN (area) = NULL;
@ -741,7 +748,7 @@ DEFUN (no_area_filter_list,
else else
{ {
if (PREFIX_NAME_OUT (area)) if (PREFIX_NAME_OUT (area))
if (strcmp (PREFIX_NAME_OUT (area), argv[2]->arg) != 0) if (strcmp (PREFIX_NAME_OUT (area), argv[idx_ipv4]->arg) != 0)
return CMD_SUCCESS; return CMD_SUCCESS;
PREFIX_LIST_OUT (area) = NULL; PREFIX_LIST_OUT (area) = NULL;
@ -763,19 +770,21 @@ DEFUN (area_import_list,
"Set the filter for networks from other areas announced to the specified one\n" "Set the filter for networks from other areas announced to the specified one\n"
"Name of the acess-list\n") "Name of the acess-list\n")
{ {
int idx_ipv4 = 1;
int idx_name = 3;
struct ospf6_area *area; struct ospf6_area *area;
struct access_list *list; struct access_list *list;
OSPF6_CMD_AREA_GET(argv[1]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
list = access_list_lookup (AFI_IP6, argv[3]->arg); list = access_list_lookup (AFI_IP6, argv[idx_name]->arg);
IMPORT_LIST (area) = list; IMPORT_LIST (area) = list;
if (IMPORT_NAME (area)) if (IMPORT_NAME (area))
free (IMPORT_NAME (area)); free (IMPORT_NAME (area));
IMPORT_NAME (area) = strdup (argv[3]->arg); IMPORT_NAME (area) = strdup (argv[idx_name]->arg);
ospf6_abr_reimport (area); ospf6_abr_reimport (area);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -789,9 +798,10 @@ DEFUN (no_area_import_list,
"Unset the filter for networks announced to other areas\n" "Unset the filter for networks announced to other areas\n"
"NAme of the access-list\n") "NAme of the access-list\n")
{ {
int idx_ipv4 = 2;
struct ospf6_area *area; struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[2]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
IMPORT_LIST (area) = 0; IMPORT_LIST (area) = 0;
@ -812,19 +822,21 @@ DEFUN (area_export_list,
"Set the filter for networks announced to other areas\n" "Set the filter for networks announced to other areas\n"
"Name of the acess-list\n") "Name of the acess-list\n")
{ {
int idx_ipv4 = 1;
int idx_name = 3;
struct ospf6_area *area; struct ospf6_area *area;
struct access_list *list; struct access_list *list;
OSPF6_CMD_AREA_GET(argv[1]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
list = access_list_lookup (AFI_IP6, argv[3]->arg); list = access_list_lookup (AFI_IP6, argv[idx_name]->arg);
EXPORT_LIST (area) = list; EXPORT_LIST (area) = list;
if (EXPORT_NAME (area)) if (EXPORT_NAME (area))
free (EXPORT_NAME (area)); free (EXPORT_NAME (area));
EXPORT_NAME (area) = strdup (argv[3]->arg); EXPORT_NAME (area) = strdup (argv[idx_name]->arg);
ospf6_abr_enable_area (area); ospf6_abr_enable_area (area);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -838,9 +850,10 @@ DEFUN (no_area_export_list,
"Unset the filter for networks announced to other areas\n" "Unset the filter for networks announced to other areas\n"
"Name of the access-list\n") "Name of the access-list\n")
{ {
int idx_ipv4 = 2;
struct ospf6_area *area; struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[2]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
EXPORT_LIST (area) = 0; EXPORT_LIST (area) = 0;
@ -899,6 +912,7 @@ DEFUN (show_ipv6_ospf6_area_spf_tree,
"Shortest Path First caculation\n" "Shortest Path First caculation\n"
"Show SPF tree\n") "Show SPF tree\n")
{ {
int idx_ipv4 = 4;
u_int32_t area_id; u_int32_t area_id;
struct ospf6_area *oa; struct ospf6_area *oa;
struct ospf6_vertex *root; struct ospf6_vertex *root;
@ -909,15 +923,15 @@ DEFUN (show_ipv6_ospf6_area_spf_tree,
ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
if (inet_pton (AF_INET, argv[4]->arg, &area_id) != 1) if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
{ {
vty_out (vty, "Malformed Area-ID: %s%s", argv[4]->arg, VNL); vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
oa = ospf6_area_lookup (area_id, ospf6); oa = ospf6_area_lookup (area_id, ospf6);
if (oa == NULL) if (oa == NULL)
{ {
vty_out (vty, "No such Area: %s%s", argv[4]->arg, VNL); vty_out (vty, "No such Area: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -944,6 +958,8 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
"Show SPF tree\n" "Show SPF tree\n"
"Specify root's router-id to calculate another router's SPF tree\n") "Specify root's router-id to calculate another router's SPF tree\n")
{ {
int idx_ipv4 = 5;
int idx_ipv4_2 = 7;
u_int32_t area_id; u_int32_t area_id;
struct ospf6_area *oa; struct ospf6_area *oa;
struct ospf6_vertex *root; struct ospf6_vertex *root;
@ -955,18 +971,18 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
OSPF6_CMD_CHECK_RUNNING (); OSPF6_CMD_CHECK_RUNNING ();
inet_pton (AF_INET, argv[5]->arg, &router_id); inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id);
ospf6_linkstate_prefix (router_id, htonl (0), &prefix); ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
if (inet_pton (AF_INET, argv[7]->arg, &area_id) != 1) if (inet_pton (AF_INET, argv[idx_ipv4_2]->arg, &area_id) != 1)
{ {
vty_out (vty, "Malformed Area-ID: %s%s", argv[7]->arg, VNL); vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4_2]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
oa = ospf6_area_lookup (area_id, ospf6); oa = ospf6_area_lookup (area_id, ospf6);
if (oa == NULL) if (oa == NULL)
{ {
vty_out (vty, "No such Area: %s%s", argv[7]->arg, VNL); vty_out (vty, "No such Area: %s%s", argv[idx_ipv4_2]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1002,9 +1018,10 @@ DEFUN (ospf6_area_stub,
"OSPF6 area ID as a decimal value\n" "OSPF6 area ID as a decimal value\n"
"Configure OSPF6 area as stub\n") "Configure OSPF6 area as stub\n")
{ {
int idx_ipv4_number = 1;
struct ospf6_area *area; struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[1]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
if (!ospf6_area_stub_set (ospf6, area)) if (!ospf6_area_stub_set (ospf6, area))
{ {
@ -1027,9 +1044,10 @@ DEFUN (ospf6_area_stub_no_summary,
"Configure OSPF6 area as stub\n" "Configure OSPF6 area as stub\n"
"Do not inject inter-area routes into stub\n") "Do not inject inter-area routes into stub\n")
{ {
int idx_ipv4_number = 1;
struct ospf6_area *area; struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[1]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
if (!ospf6_area_stub_set (ospf6, area)) if (!ospf6_area_stub_set (ospf6, area))
{ {
@ -1052,9 +1070,10 @@ DEFUN (no_ospf6_area_stub,
"OSPF6 area ID as a decimal value\n" "OSPF6 area ID as a decimal value\n"
"Configure OSPF6 area as stub\n") "Configure OSPF6 area as stub\n")
{ {
int idx_ipv4_number = 2;
struct ospf6_area *area; struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[2]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
ospf6_area_stub_unset (ospf6, area); ospf6_area_stub_unset (ospf6, area);
ospf6_area_no_summary_unset (ospf6, area); ospf6_area_no_summary_unset (ospf6, area);
@ -1072,9 +1091,10 @@ DEFUN (no_ospf6_area_stub_no_summary,
"Configure OSPF6 area as stub\n" "Configure OSPF6 area as stub\n"
"Do not inject inter-area routes into area\n") "Do not inject inter-area routes into area\n")
{ {
int idx_ipv4_number = 2;
struct ospf6_area *area; struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[2]->arg, area); OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
ospf6_area_stub_unset (ospf6, area); ospf6_area_stub_unset (ospf6, area);
ospf6_area_no_summary_unset (ospf6, area); ospf6_area_no_summary_unset (ospf6, area);

View File

@ -667,14 +667,16 @@ DEFUN (ospf6_redistribute_routemap,
"Route map name\n" "Route map name\n"
) )
{ {
int idx_protocol = 1;
int idx_word = 3;
int type; int type;
type = proto_redistnum(AFI_IP6, argv[1]->arg); type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_OSPF6) if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
return CMD_WARNING; return CMD_WARNING;
ospf6_asbr_redistribute_unset (type); ospf6_asbr_redistribute_unset (type);
ospf6_asbr_routemap_set (type, argv[3]->arg); ospf6_asbr_routemap_set (type, argv[idx_word]->arg);
ospf6_asbr_redistribute_set (type); ospf6_asbr_redistribute_set (type);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1019,8 +1021,9 @@ DEFUN (ospf6_routemap_match_address_prefixlist,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IPv6 prefix-list name\n") "IPv6 prefix-list name\n")
{ {
int idx_word = 4;
int ret = route_map_add_match ((struct route_map_index *) vty->index, int ret = route_map_add_match ((struct route_map_index *) vty->index,
"ipv6 address prefix-list", argv[4]->arg); "ipv6 address prefix-list", argv[idx_word]->arg);
return route_map_command_status (vty, ret); return route_map_command_status (vty, ret);
} }
@ -1035,8 +1038,9 @@ DEFUN (ospf6_routemap_no_match_address_prefixlist,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IPv6 prefix-list name\n") "IPv6 prefix-list name\n")
{ {
int idx_word = 5;
int ret = route_map_delete_match ((struct route_map_index *) vty->index, int ret = route_map_delete_match ((struct route_map_index *) vty->index,
"ipv6 address prefix-list", argv[5]->arg); "ipv6 address prefix-list", argv[idx_word]->arg);
return route_map_command_status (vty, ret); return route_map_command_status (vty, ret);
} }
@ -1048,8 +1052,9 @@ DEFUN (ospf6_routemap_match_interface,
"Match first hop interface of route\n" "Match first hop interface of route\n"
"Interface name\n") "Interface name\n")
{ {
int idx_word = 2;
return route_map_add_match ((struct route_map_index *) vty->index, return route_map_add_match ((struct route_map_index *) vty->index,
"interface", argv[2]->arg); "interface", argv[idx_word]->arg);
} }
/* "no match interface WORD" */ /* "no match interface WORD" */
@ -1084,8 +1089,9 @@ DEFUN (ospf6_routemap_set_metric_type,
"OSPF6 external type 1 metric\n" "OSPF6 external type 1 metric\n"
"OSPF6 external type 2 metric\n") "OSPF6 external type 2 metric\n")
{ {
int idx_external = 2;
int ret = route_map_add_set ((struct route_map_index *) vty->index, int ret = route_map_add_set ((struct route_map_index *) vty->index,
"metric-type", argv[2]->arg); "metric-type", argv[idx_external]->arg);
return route_map_command_status (vty, ret); return route_map_command_status (vty, ret);
} }
@ -1099,8 +1105,9 @@ DEFUN (ospf6_routemap_no_set_metric_type,
"OSPF6 external type 1 metric\n" "OSPF6 external type 1 metric\n"
"OSPF6 external type 2 metric\n") "OSPF6 external type 2 metric\n")
{ {
int idx_external = 3;
int ret = route_map_delete_set ((struct route_map_index *) vty->index, int ret = route_map_delete_set ((struct route_map_index *) vty->index,
"metric-type", argv[3]->arg); "metric-type", argv[idx_external]->arg);
return route_map_command_status (vty, ret); return route_map_command_status (vty, ret);
} }
@ -1112,8 +1119,9 @@ DEFUN (set_metric,
"Metric value\n" "Metric value\n"
"Metric value\n") "Metric value\n")
{ {
int idx_number = 2;
int ret = route_map_add_set ((struct route_map_index *) vty->index, int ret = route_map_add_set ((struct route_map_index *) vty->index,
"metric", argv[2]->arg); "metric", argv[idx_number]->arg);
return route_map_command_status (vty, ret); return route_map_command_status (vty, ret);
} }
@ -1154,8 +1162,9 @@ DEFUN (ospf6_routemap_set_forwarding,
"Forwarding Address\n" "Forwarding Address\n"
"IPv6 Address\n") "IPv6 Address\n")
{ {
int idx_ipv6 = 2;
int ret = route_map_add_set ((struct route_map_index *) vty->index, int ret = route_map_add_set ((struct route_map_index *) vty->index,
"forwarding-address", argv[2]->arg); "forwarding-address", argv[idx_ipv6]->arg);
return route_map_command_status (vty, ret); return route_map_command_status (vty, ret);
} }
@ -1168,8 +1177,9 @@ DEFUN (ospf6_routemap_no_set_forwarding,
"Forwarding Address\n" "Forwarding Address\n"
"IPv6 Address\n") "IPv6 Address\n")
{ {
int idx_ipv6 = 3;
int ret = route_map_delete_set ((struct route_map_index *) vty->index, int ret = route_map_delete_set ((struct route_map_index *) vty->index,
"forwarding-address", argv[3]->arg); "forwarding-address", argv[idx_ipv6]->arg);
return route_map_command_status (vty, ret); return route_map_command_status (vty, ret);
} }

View File

@ -354,6 +354,9 @@ DEFUN (ipv6_ospf6_bfd_param,
"Required min receive interval\n" "Required min receive interval\n"
"Desired min transmit interval\n") "Desired min transmit interval\n")
{ {
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
u_int32_t rx_val; u_int32_t rx_val;
@ -369,7 +372,7 @@ DEFUN (ipv6_ospf6_bfd_param,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
if ((ret = bfd_validate_param (vty, argv[3]->arg, argv[4]->arg, argv[5]->arg, &dm_val, if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val,
&rx_val, &tx_val)) != CMD_SUCCESS) &rx_val, &tx_val)) != CMD_SUCCESS)
return ret; return ret;

View File

@ -1006,15 +1006,16 @@ DEFUN (show_ipv6_ospf6_interface,
IFNAME_STR IFNAME_STR
) )
{ {
int idx_ifname = 4;
struct interface *ifp; struct interface *ifp;
struct listnode *i; struct listnode *i;
if (argc) if (argc)
{ {
ifp = if_lookup_by_name (argv[4]->arg); ifp = if_lookup_by_name (argv[idx_ifname]->arg);
if (ifp == NULL) if (ifp == NULL)
{ {
vty_out (vty, "No such Interface: %s%s", argv[4]->arg, vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg,
VNL); VNL);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1068,20 +1069,21 @@ DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
"Display connected prefixes to advertise\n" "Display connected prefixes to advertise\n"
) )
{ {
int idx_ifname = 4;
struct interface *ifp; struct interface *ifp;
struct ospf6_interface *oi; struct ospf6_interface *oi;
ifp = if_lookup_by_name (argv[4]->arg); ifp = if_lookup_by_name (argv[idx_ifname]->arg);
if (ifp == NULL) if (ifp == NULL)
{ {
vty_out (vty, "No such Interface: %s%s", argv[4]->arg, VNL); vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL);
return CMD_WARNING; return CMD_WARNING;
} }
oi = ifp->info; oi = ifp->info;
if (oi == NULL) if (oi == NULL)
{ {
vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[4]->arg, VNL); vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[idx_ifname]->arg, VNL);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1158,6 +1160,7 @@ DEFUN (ipv6_ospf6_ifmtu,
"OSPFv3 Interface MTU\n" "OSPFv3 Interface MTU\n"
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
unsigned int ifmtu, iobuflen; unsigned int ifmtu, iobuflen;
@ -1172,7 +1175,7 @@ DEFUN (ipv6_ospf6_ifmtu,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
ifmtu = strtol (argv[3]->arg, NULL, 10); ifmtu = strtol (argv[idx_number]->arg, NULL, 10);
if (oi->ifmtu == ifmtu) if (oi->ifmtu == ifmtu)
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1266,6 +1269,7 @@ DEFUN (ipv6_ospf6_cost,
"Outgoing metric of this interface\n" "Outgoing metric of this interface\n"
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
unsigned long int lcost; unsigned long int lcost;
@ -1278,7 +1282,7 @@ DEFUN (ipv6_ospf6_cost,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
lcost = strtol (argv[3]->arg, NULL, 10); lcost = strtol (argv[idx_number]->arg, NULL, 10);
if (lcost > UINT32_MAX) if (lcost > UINT32_MAX)
{ {
@ -1331,13 +1335,14 @@ DEFUN (auto_cost_reference_bandwidth,
"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") "The reference bandwidth in terms of Mbits per second\n")
{ {
int idx_number = 2;
struct ospf6 *o = vty->index; struct ospf6 *o = vty->index;
struct ospf6_area *oa; struct ospf6_area *oa;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct listnode *i, *j; struct listnode *i, *j;
u_int32_t refbw; u_int32_t refbw;
refbw = strtol (argv[2]->arg, NULL, 10); refbw = strtol (argv[idx_number]->arg, NULL, 10);
if (refbw < 1 || refbw > 4294967) if (refbw < 1 || refbw > 4294967)
{ {
vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
@ -1398,6 +1403,7 @@ DEFUN (ipv6_ospf6_hellointerval,
SECONDS_STR SECONDS_STR
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1409,7 +1415,7 @@ DEFUN (ipv6_ospf6_hellointerval,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
oi->hello_interval = strtol (argv[3]->arg, NULL, 10); oi->hello_interval = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1423,6 +1429,7 @@ DEFUN (ipv6_ospf6_deadinterval,
SECONDS_STR SECONDS_STR
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1434,7 +1441,7 @@ DEFUN (ipv6_ospf6_deadinterval,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
oi->dead_interval = strtol (argv[3]->arg, NULL, 10); oi->dead_interval = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1448,6 +1455,7 @@ DEFUN (ipv6_ospf6_transmitdelay,
SECONDS_STR SECONDS_STR
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1459,7 +1467,7 @@ DEFUN (ipv6_ospf6_transmitdelay,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
oi->transdelay = strtol (argv[3]->arg, NULL, 10); oi->transdelay = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1473,6 +1481,7 @@ DEFUN (ipv6_ospf6_retransmitinterval,
SECONDS_STR SECONDS_STR
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1484,7 +1493,7 @@ DEFUN (ipv6_ospf6_retransmitinterval,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
oi->rxmt_interval = strtol (argv[3]->arg, NULL, 10); oi->rxmt_interval = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1498,6 +1507,7 @@ DEFUN (ipv6_ospf6_priority,
"Priority value\n" "Priority value\n"
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1509,7 +1519,7 @@ DEFUN (ipv6_ospf6_priority,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
oi->priority = strtol (argv[3]->arg, NULL, 10); oi->priority = strtol (argv[idx_number]->arg, NULL, 10);
if (oi->area && if (oi->area &&
(oi->state == OSPF6_INTERFACE_DROTHER || (oi->state == OSPF6_INTERFACE_DROTHER ||
@ -1529,6 +1539,7 @@ DEFUN (ipv6_ospf6_instance,
"Instance ID value\n" "Instance ID value\n"
) )
{ {
int idx_number = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1540,7 +1551,7 @@ DEFUN (ipv6_ospf6_instance,
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
assert (oi); assert (oi);
oi->instance_id = strtol (argv[3]->arg, NULL, 10); oi->instance_id = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1664,6 +1675,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list,
"Prefix list name\n" "Prefix list name\n"
) )
{ {
int idx_word = 4;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1677,7 +1689,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list,
if (oi->plist_name) if (oi->plist_name)
XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name); XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name);
oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[4]->arg); oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[idx_word]->arg);
ospf6_interface_connected_route_update (oi->interface); ospf6_interface_connected_route_update (oi->interface);
@ -1748,6 +1760,7 @@ DEFUN (ipv6_ospf6_network,
"Specify OSPF6 point-to-point network\n" "Specify OSPF6 point-to-point network\n"
) )
{ {
int idx_network = 3;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct interface *ifp; struct interface *ifp;
@ -1760,14 +1773,14 @@ DEFUN (ipv6_ospf6_network,
} }
assert (oi); assert (oi);
if (strncmp (argv[3]->arg, "b", 1) == 0) if (strncmp (argv[idx_network]->arg, "b", 1) == 0)
{ {
if (oi->type == OSPF_IFTYPE_BROADCAST) if (oi->type == OSPF_IFTYPE_BROADCAST)
return CMD_SUCCESS; return CMD_SUCCESS;
oi->type = OSPF_IFTYPE_BROADCAST; oi->type = OSPF_IFTYPE_BROADCAST;
} }
else if (strncmp (argv[3]->arg, "point-to-p", 10) == 0) else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0)
{ {
if (oi->type == OSPF_IFTYPE_POINTOPOINT) { if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1977,6 +1990,7 @@ DEFUN (clear_ipv6_ospf6_interface,
IFNAME_STR IFNAME_STR
) )
{ {
int idx_ifname = 4;
struct interface *ifp; struct interface *ifp;
struct listnode *node; struct listnode *node;
@ -1987,9 +2001,9 @@ DEFUN (clear_ipv6_ospf6_interface,
} }
else /* Interface name is specified. */ else /* Interface name is specified. */
{ {
if ((ifp = if_lookup_by_name (argv[4]->arg)) == NULL) if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg)) == NULL)
{ {
vty_out (vty, "No such Interface: %s%s", argv[4]->arg, VNL); vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL);
return CMD_WARNING; return CMD_WARNING;
} }
ospf6_interface_clear (vty, ifp); ospf6_interface_clear (vty, ifp);

View File

@ -1730,8 +1730,9 @@ DEFUN (debug_ospf6_brouter_router,
"Specify border-router's router-id\n" "Specify border-router's router-id\n"
) )
{ {
int idx_ipv4 = 4;
u_int32_t router_id; u_int32_t router_id;
inet_pton (AF_INET, argv[4]->arg, &router_id); inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id);
OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON (router_id); OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON (router_id);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1760,8 +1761,9 @@ DEFUN (debug_ospf6_brouter_area,
"Specify Area-ID\n" "Specify Area-ID\n"
) )
{ {
int idx_ipv4 = 4;
u_int32_t area_id; u_int32_t area_id;
inet_pton (AF_INET, argv[4]->arg, &area_id); inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id);
OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON (area_id); OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON (area_id);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -835,6 +835,7 @@ DEFUN (debug_ospf6_lsa_type,
"Specify LS type as Hexadecimal\n" "Specify LS type as Hexadecimal\n"
) )
{ {
int idx_lsa = 3;
unsigned int i; unsigned int i;
struct ospf6_lsa_handler *handler = NULL; struct ospf6_lsa_handler *handler = NULL;
@ -845,9 +846,9 @@ DEFUN (debug_ospf6_lsa_type,
handler = vector_slot (ospf6_lsa_handler_vector, i); handler = vector_slot (ospf6_lsa_handler_vector, i);
if (handler == NULL) if (handler == NULL)
continue; continue;
if (strncmp (argv[3]->arg, ospf6_lsa_handler_name(handler), strlen(argv[3]->arg)) == 0) if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0)
break; break;
if (! strcasecmp (argv[3]->arg, handler->name)) if (! strcasecmp (argv[idx_lsa]->arg, handler->name))
break; break;
handler = NULL; handler = NULL;
} }
@ -892,6 +893,7 @@ DEFUN (no_debug_ospf6_lsa_type,
"Specify LS type as Hexadecimal\n" "Specify LS type as Hexadecimal\n"
) )
{ {
int idx_lsa = 4;
u_int i; u_int i;
struct ospf6_lsa_handler *handler = NULL; struct ospf6_lsa_handler *handler = NULL;
@ -902,9 +904,9 @@ DEFUN (no_debug_ospf6_lsa_type,
handler = vector_slot (ospf6_lsa_handler_vector, i); handler = vector_slot (ospf6_lsa_handler_vector, i);
if (handler == NULL) if (handler == NULL)
continue; continue;
if (strncmp (argv[4]->arg, ospf6_lsa_handler_name(handler), strlen(argv[4]->arg)) == 0) if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0)
break; break;
if (! strcasecmp (argv[4]->arg, handler->name)) if (! strcasecmp (argv[idx_lsa]->arg, handler->name))
break; break;
} }

View File

@ -2371,6 +2371,7 @@ DEFUN (debug_ospf6_message,
"Debug All message\n" "Debug All message\n"
) )
{ {
int idx_packet = 3;
unsigned char level = 0; unsigned char level = 0;
int type = 0; int type = 0;
int i; int i;
@ -2378,19 +2379,19 @@ DEFUN (debug_ospf6_message,
assert (argc > 0); assert (argc > 0);
/* check type */ /* check type */
if (! strncmp (argv[3]->arg, "u", 1)) if (! strncmp (argv[idx_packet]->arg, "u", 1))
type = OSPF6_MESSAGE_TYPE_UNKNOWN; type = OSPF6_MESSAGE_TYPE_UNKNOWN;
else if (! strncmp (argv[3]->arg, "h", 1)) else if (! strncmp (argv[idx_packet]->arg, "h", 1))
type = OSPF6_MESSAGE_TYPE_HELLO; type = OSPF6_MESSAGE_TYPE_HELLO;
else if (! strncmp (argv[3]->arg, "d", 1)) else if (! strncmp (argv[idx_packet]->arg, "d", 1))
type = OSPF6_MESSAGE_TYPE_DBDESC; type = OSPF6_MESSAGE_TYPE_DBDESC;
else if (! strncmp (argv[3]->arg, "lsr", 3)) else if (! strncmp (argv[idx_packet]->arg, "lsr", 3))
type = OSPF6_MESSAGE_TYPE_LSREQ; type = OSPF6_MESSAGE_TYPE_LSREQ;
else if (! strncmp (argv[3]->arg, "lsu", 3)) else if (! strncmp (argv[idx_packet]->arg, "lsu", 3))
type = OSPF6_MESSAGE_TYPE_LSUPDATE; type = OSPF6_MESSAGE_TYPE_LSUPDATE;
else if (! strncmp (argv[3]->arg, "lsa", 3)) else if (! strncmp (argv[idx_packet]->arg, "lsa", 3))
type = OSPF6_MESSAGE_TYPE_LSACK; type = OSPF6_MESSAGE_TYPE_LSACK;
else if (! strncmp (argv[3]->arg, "a", 1)) else if (! strncmp (argv[idx_packet]->arg, "a", 1))
type = OSPF6_MESSAGE_TYPE_ALL; type = OSPF6_MESSAGE_TYPE_ALL;
if (argc == 1) if (argc == 1)
@ -2449,6 +2450,7 @@ DEFUN (no_debug_ospf6_message,
"Debug All message\n" "Debug All message\n"
) )
{ {
int idx_packet = 4;
unsigned char level = 0; unsigned char level = 0;
int type = 0; int type = 0;
int i; int i;
@ -2456,19 +2458,19 @@ DEFUN (no_debug_ospf6_message,
assert (argc > 0); assert (argc > 0);
/* check type */ /* check type */
if (! strncmp (argv[4]->arg, "u", 1)) if (! strncmp (argv[idx_packet]->arg, "u", 1))
type = OSPF6_MESSAGE_TYPE_UNKNOWN; type = OSPF6_MESSAGE_TYPE_UNKNOWN;
else if (! strncmp (argv[4]->arg, "h", 1)) else if (! strncmp (argv[idx_packet]->arg, "h", 1))
type = OSPF6_MESSAGE_TYPE_HELLO; type = OSPF6_MESSAGE_TYPE_HELLO;
else if (! strncmp (argv[4]->arg, "d", 1)) else if (! strncmp (argv[idx_packet]->arg, "d", 1))
type = OSPF6_MESSAGE_TYPE_DBDESC; type = OSPF6_MESSAGE_TYPE_DBDESC;
else if (! strncmp (argv[4]->arg, "lsr", 3)) else if (! strncmp (argv[idx_packet]->arg, "lsr", 3))
type = OSPF6_MESSAGE_TYPE_LSREQ; type = OSPF6_MESSAGE_TYPE_LSREQ;
else if (! strncmp (argv[4]->arg, "lsu", 3)) else if (! strncmp (argv[idx_packet]->arg, "lsu", 3))
type = OSPF6_MESSAGE_TYPE_LSUPDATE; type = OSPF6_MESSAGE_TYPE_LSUPDATE;
else if (! strncmp (argv[4]->arg, "lsa", 3)) else if (! strncmp (argv[idx_packet]->arg, "lsa", 3))
type = OSPF6_MESSAGE_TYPE_LSACK; type = OSPF6_MESSAGE_TYPE_LSACK;
else if (! strncmp (argv[4]->arg, "a", 1)) else if (! strncmp (argv[idx_packet]->arg, "a", 1))
type = OSPF6_MESSAGE_TYPE_ALL; type = OSPF6_MESSAGE_TYPE_ALL;
if (argc == 1) if (argc == 1)

View File

@ -893,6 +893,7 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
"Specify Router-ID as IPv4 address notation\n" "Specify Router-ID as IPv4 address notation\n"
) )
{ {
int idx_ipv4 = 4;
struct ospf6_neighbor *on; struct ospf6_neighbor *on;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct ospf6_area *oa; struct ospf6_area *oa;
@ -903,9 +904,9 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
OSPF6_CMD_CHECK_RUNNING (); OSPF6_CMD_CHECK_RUNNING ();
showfunc = ospf6_neighbor_show_detail; showfunc = ospf6_neighbor_show_detail;
if ((inet_pton (AF_INET, argv[4]->arg, &router_id)) != 1) if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1)
{ {
vty_out (vty, "Router-ID is not parsable: %s%s", argv[4]->arg, vty_out (vty, "Router-ID is not parsable: %s%s", argv[idx_ipv4]->arg,
VNL); VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -1573,15 +1573,16 @@ DEFUN (debug_ospf6_route,
"Debug route memory use\n" "Debug route memory use\n"
) )
{ {
int idx_type = 3;
unsigned char level = 0; unsigned char level = 0;
if (! strncmp (argv[3]->arg, "table", 5)) if (! strncmp (argv[idx_type]->arg, "table", 5))
level = OSPF6_DEBUG_ROUTE_TABLE; level = OSPF6_DEBUG_ROUTE_TABLE;
else if (! strncmp (argv[3]->arg, "intra", 5)) else if (! strncmp (argv[idx_type]->arg, "intra", 5))
level = OSPF6_DEBUG_ROUTE_INTRA; level = OSPF6_DEBUG_ROUTE_INTRA;
else if (! strncmp (argv[3]->arg, "inter", 5)) else if (! strncmp (argv[idx_type]->arg, "inter", 5))
level = OSPF6_DEBUG_ROUTE_INTER; level = OSPF6_DEBUG_ROUTE_INTER;
else if (! strncmp (argv[3]->arg, "memor", 5)) else if (! strncmp (argv[idx_type]->arg, "memor", 5))
level = OSPF6_DEBUG_ROUTE_MEMORY; level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_ON (level); OSPF6_DEBUG_ROUTE_ON (level);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1597,15 +1598,16 @@ DEFUN (no_debug_ospf6_route,
"Debug intra-area route calculation\n" "Debug intra-area route calculation\n"
"Debug route memory use\n") "Debug route memory use\n")
{ {
int idx_type = 4;
unsigned char level = 0; unsigned char level = 0;
if (! strncmp (argv[4]->arg, "table", 5)) if (! strncmp (argv[idx_type]->arg, "table", 5))
level = OSPF6_DEBUG_ROUTE_TABLE; level = OSPF6_DEBUG_ROUTE_TABLE;
else if (! strncmp (argv[4]->arg, "intra", 5)) else if (! strncmp (argv[idx_type]->arg, "intra", 5))
level = OSPF6_DEBUG_ROUTE_INTRA; level = OSPF6_DEBUG_ROUTE_INTRA;
else if (! strncmp (argv[4]->arg, "inter", 5)) else if (! strncmp (argv[idx_type]->arg, "inter", 5))
level = OSPF6_DEBUG_ROUTE_INTER; level = OSPF6_DEBUG_ROUTE_INTER;
else if (! strncmp (argv[4]->arg, "memor", 5)) else if (! strncmp (argv[idx_type]->arg, "memor", 5))
level = OSPF6_DEBUG_ROUTE_MEMORY; level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_OFF (level); OSPF6_DEBUG_ROUTE_OFF (level);
return CMD_SUCCESS; return CMD_SUCCESS;

View File

@ -885,6 +885,9 @@ DEFUN (ospf6_timers_throttle_spf,
"Initial hold time (msec) between consecutive SPF calculations\n" "Initial hold time (msec) between consecutive SPF calculations\n"
"Maximum hold time (msec)\n") "Maximum hold time (msec)\n")
{ {
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
unsigned int delay, hold, max; unsigned int delay, hold, max;
if (argc != 3) if (argc != 3)
@ -893,9 +896,9 @@ DEFUN (ospf6_timers_throttle_spf,
return CMD_WARNING; return CMD_WARNING;
} }
VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[3]->arg, 0, 600000); VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000);
VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[4]->arg, 0, 600000); VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000);
VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[5]->arg, 0, 600000); VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000);
return ospf6_timers_spf_set (vty, delay, hold, max); return ospf6_timers_spf_set (vty, delay, hold, max);
} }

View File

@ -324,16 +324,17 @@ DEFUN (ospf6_router_id,
"Configure OSPF Router-ID\n" "Configure OSPF Router-ID\n"
V4NOTATION_STR) V4NOTATION_STR)
{ {
int idx_ipv4 = 1;
int ret; int ret;
u_int32_t router_id; u_int32_t router_id;
struct ospf6 *o; struct ospf6 *o;
o = (struct ospf6 *) vty->index; o = (struct ospf6 *) vty->index;
ret = inet_pton (AF_INET, argv[1]->arg, &router_id); ret = inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id);
if (ret == 0) if (ret == 0)
{ {
vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[1]->arg, VNL); vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -404,6 +405,7 @@ DEFUN (ospf6_timers_lsa,
"Minimum delay in receiving new version of a LSA\n" "Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n") "Delay in milliseconds\n")
{ {
int idx_number = 3;
unsigned int minarrival; unsigned int minarrival;
struct ospf6 *ospf = vty->index; struct ospf6 *ospf = vty->index;
@ -416,7 +418,7 @@ DEFUN (ospf6_timers_lsa,
return CMD_WARNING; return CMD_WARNING;
} }
VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[3]->arg); VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg);
ospf->lsa_minarrival = minarrival; ospf->lsa_minarrival = minarrival;
@ -471,6 +473,8 @@ DEFUN (ospf6_interface_area,
"OSPF6 area ID in IPv4 address notation\n" "OSPF6 area ID in IPv4 address notation\n"
) )
{ {
int idx_ifname = 1;
int idx_ipv4 = 3;
struct ospf6 *o; struct ospf6 *o;
struct ospf6_area *oa; struct ospf6_area *oa;
struct ospf6_interface *oi; struct ospf6_interface *oi;
@ -480,7 +484,7 @@ DEFUN (ospf6_interface_area,
o = (struct ospf6 *) vty->index; o = (struct ospf6 *) vty->index;
/* find/create ospf6 interface */ /* find/create ospf6 interface */
ifp = if_get_by_name (argv[1]->arg); ifp = if_get_by_name (argv[idx_ifname]->arg);
oi = (struct ospf6_interface *) ifp->info; oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL) if (oi == NULL)
oi = ospf6_interface_create (ifp); oi = ospf6_interface_create (ifp);
@ -492,9 +496,9 @@ DEFUN (ospf6_interface_area,
} }
/* parse Area-ID */ /* parse Area-ID */
if (inet_pton (AF_INET, argv[3]->arg, &area_id) != 1) if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
{ {
vty_out (vty, "Invalid Area-ID: %s%s", argv[3]->arg, VNL); vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -533,15 +537,17 @@ DEFUN (no_ospf6_interface_area,
"OSPF6 area ID in IPv4 address notation\n" "OSPF6 area ID in IPv4 address notation\n"
) )
{ {
int idx_ifname = 2;
int idx_ipv4 = 4;
struct ospf6_interface *oi; struct ospf6_interface *oi;
struct ospf6_area *oa; struct ospf6_area *oa;
struct interface *ifp; struct interface *ifp;
u_int32_t area_id; u_int32_t area_id;
ifp = if_lookup_by_name (argv[2]->arg); ifp = if_lookup_by_name (argv[idx_ifname]->arg);
if (ifp == NULL) if (ifp == NULL)
{ {
vty_out (vty, "No such interface %s%s", argv[2]->arg, VNL); vty_out (vty, "No such interface %s%s", argv[idx_ifname]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -553,16 +559,16 @@ DEFUN (no_ospf6_interface_area,
} }
/* parse Area-ID */ /* parse Area-ID */
if (inet_pton (AF_INET, argv[4]->arg, &area_id) != 1) if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
{ {
vty_out (vty, "Invalid Area-ID: %s%s", argv[4]->arg, VNL); vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
/* Verify Area */ /* Verify Area */
if (oi->area == NULL) if (oi->area == NULL)
{ {
vty_out (vty, "No such Area-ID: %s%s", argv[4]->arg, VNL); vty_out (vty, "No such Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -726,13 +726,14 @@ DEFUN (debug_ospf6_zebra_sendrecv,
"Debug Receiving zebra\n" "Debug Receiving zebra\n"
) )
{ {
int idx_send_recv = 3;
unsigned char level = 0; unsigned char level = 0;
if (argc) if (argc)
{ {
if (! strncmp (argv[3]->arg, "s", 1)) if (! strncmp (argv[idx_send_recv]->arg, "s", 1))
level = OSPF6_DEBUG_ZEBRA_SEND; level = OSPF6_DEBUG_ZEBRA_SEND;
else if (! strncmp (argv[3]->arg, "r", 1)) else if (! strncmp (argv[idx_send_recv]->arg, "r", 1))
level = OSPF6_DEBUG_ZEBRA_RECV; level = OSPF6_DEBUG_ZEBRA_RECV;
} }
else else
@ -765,13 +766,14 @@ DEFUN (no_debug_ospf6_zebra_sendrecv,
"Debug Receiving zebra\n" "Debug Receiving zebra\n"
) )
{ {
int idx_send_recv = 4;
unsigned char level = 0; unsigned char level = 0;
if (argc) if (argc)
{ {
if (! strncmp (argv[4]->arg, "s", 1)) if (! strncmp (argv[idx_send_recv]->arg, "s", 1))
level = OSPF6_DEBUG_ZEBRA_SEND; level = OSPF6_DEBUG_ZEBRA_SEND;
else if (! strncmp (argv[4]->arg, "r", 1)) else if (! strncmp (argv[idx_send_recv]->arg, "r", 1))
level = OSPF6_DEBUG_ZEBRA_RECV; level = OSPF6_DEBUG_ZEBRA_RECV;
} }
else else

View File

@ -364,6 +364,7 @@ DEFUN (show_ipv6_ospf6_database_id,
"Specify Link state ID as IPv4 address notation\n" "Specify Link state ID as IPv4 address notation\n"
) )
{ {
int idx_ipv4 = 5;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -373,10 +374,10 @@ DEFUN (show_ipv6_ospf6_database_id,
OSPF6_CMD_CHECK_RUNNING (); OSPF6_CMD_CHECK_RUNNING ();
if ((inet_pton (AF_INET, argv[5]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &id)) != 1)
{ {
vty_out (vty, "Link State ID is not parsable: %s%s", vty_out (vty, "Link State ID is not parsable: %s%s",
argv[5]->arg, VNL); argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -461,6 +462,7 @@ DEFUN (show_ipv6_ospf6_database_router,
"Specify Advertising Router as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n"
) )
{ {
int idx_ipv4 = 6;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -470,10 +472,10 @@ DEFUN (show_ipv6_ospf6_database_router,
OSPF6_CMD_CHECK_RUNNING (); OSPF6_CMD_CHECK_RUNNING ();
if ((inet_pton (AF_INET, argv[6]->arg, &adv_router)) != 1) if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router)) != 1)
{ {
vty_out (vty, "Advertising Router is not parsable: %s%s", vty_out (vty, "Advertising Router is not parsable: %s%s",
argv[6]->arg, VNL); argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -596,6 +598,7 @@ DEFUN (show_ipv6_ospf6_database_type_id,
"Specify Link state ID as IPv4 address notation\n" "Specify Link state ID as IPv4 address notation\n"
) )
{ {
int idx_lsa = 4;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -610,10 +613,10 @@ DEFUN (show_ipv6_ospf6_database_type_id,
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1)
{ {
vty_out (vty, "Link state ID is not parsable: %s%s", vty_out (vty, "Link state ID is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -751,6 +754,7 @@ DEFUN (show_ipv6_ospf6_database_type_router,
"Specify Advertising Router as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n"
) )
{ {
int idx_lsa = 4;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -765,10 +769,10 @@ DEFUN (show_ipv6_ospf6_database_type_router,
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &adv_router)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &adv_router)) != 1)
{ {
vty_out (vty, "Advertising Router is not parsable: %s%s", vty_out (vty, "Advertising Router is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -844,6 +848,7 @@ DEFUN (show_ipv6_ospf6_database_id_router,
"Specify Advertising Router as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n"
) )
{ {
int idx_ipv4 = 5;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -854,20 +859,20 @@ DEFUN (show_ipv6_ospf6_database_id_router,
OSPF6_CMD_CHECK_RUNNING (); OSPF6_CMD_CHECK_RUNNING ();
if ((inet_pton (AF_INET, argv[5]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &id)) != 1)
{ {
vty_out (vty, "Link state ID is not parsable: %s%s", vty_out (vty, "Link state ID is not parsable: %s%s",
argv[5]->arg, VNL); argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[5]->arg, &adv_router)) != 1) if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router)) != 1)
{ {
vty_out (vty, "Advertising Router is not parsable: %s%s", vty_out (vty, "Advertising Router is not parsable: %s%s",
argv[5]->arg, VNL); argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -930,6 +935,7 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id,
"Specify Link state ID as IPv4 address notation\n" "Specify Link state ID as IPv4 address notation\n"
) )
{ {
int idx_ipv4 = 5;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -940,20 +946,20 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id,
OSPF6_CMD_CHECK_RUNNING (); OSPF6_CMD_CHECK_RUNNING ();
if ((inet_pton (AF_INET, argv[5]->arg, &adv_router)) != 1) if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router)) != 1)
{ {
vty_out (vty, "Advertising Router is not parsable: %s%s", vty_out (vty, "Advertising Router is not parsable: %s%s",
argv[5]->arg, VNL); argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[5]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &id)) != 1)
{ {
vty_out (vty, "Link state ID is not parsable: %s%s", vty_out (vty, "Link state ID is not parsable: %s%s",
argv[5]->arg, VNL); argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1031,6 +1037,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_router,
"Specify Advertising Router as IPv4 address notation\n" "Specify Advertising Router as IPv4 address notation\n"
) )
{ {
int idx_lsa = 4;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -1046,20 +1053,20 @@ DEFUN (show_ipv6_ospf6_database_type_id_router,
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1)
{ {
vty_out (vty, "Link state ID is not parsable: %s%s", vty_out (vty, "Link state ID is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &adv_router)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &adv_router)) != 1)
{ {
vty_out (vty, "Advertising Router is not parsable: %s%s", vty_out (vty, "Advertising Router is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1155,6 +1162,7 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
"Specify Link state ID as IPv4 address notation\n" "Specify Link state ID as IPv4 address notation\n"
) )
{ {
int idx_lsa = 4;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -1170,20 +1178,20 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &adv_router)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &adv_router)) != 1)
{ {
vty_out (vty, "Advertising Router is not parsable: %s%s", vty_out (vty, "Advertising Router is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1)
{ {
vty_out (vty, "Link state ID is not parsable: %s%s", vty_out (vty, "Link state ID is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1436,6 +1444,7 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id,
"Specify Link state ID as IPv4 address notation\n" "Specify Link state ID as IPv4 address notation\n"
) )
{ {
int idx_lsa = 4;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -1451,10 +1460,10 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id,
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1)
{ {
vty_out (vty, "Link State ID is not parsable: %s%s", vty_out (vty, "Link State ID is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1549,6 +1558,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated,
"Display Self-originated LSAs\n" "Display Self-originated LSAs\n"
) )
{ {
int idx_lsa = 4;
int level; int level;
struct listnode *i, *j; struct listnode *i, *j;
struct ospf6 *o = ospf6; struct ospf6 *o = ospf6;
@ -1564,10 +1574,10 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated,
argc--; argc--;
argv++; argv++;
if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1)
{ {
vty_out (vty, "Link State ID is not parsable: %s%s", vty_out (vty, "Link State ID is not parsable: %s%s",
argv[4]->arg, VNL); argv[idx_lsa]->arg, VNL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -387,6 +387,9 @@ DEFUN (ip_ospf_bfd_param,
"Required min receive interval\n" "Required min receive interval\n"
"Desired min transmit interval\n") "Desired min transmit interval\n")
{ {
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
u_int32_t rx_val; u_int32_t rx_val;
u_int32_t tx_val; u_int32_t tx_val;
@ -395,7 +398,7 @@ DEFUN (ip_ospf_bfd_param,
assert (ifp); assert (ifp);
if ((ret = bfd_validate_param (vty, argv[3]->arg, argv[4]->arg, argv[5]->arg, &dm_val, if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val,
&rx_val, &tx_val)) != CMD_SUCCESS) &rx_val, &tx_val)) != CMD_SUCCESS)
return ret; return ret;

View File

@ -910,9 +910,10 @@ DEFUN (debug_ospf_instance_packet,
"OSPF Link State Acknowledgment\n" "OSPF Link State Acknowledgment\n"
"OSPF all packets\n") "OSPF all packets\n")
{ {
int idx_number = 2;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1086,9 +1087,10 @@ DEFUN (no_debug_ospf_instance_packet,
"OSPF Link State Acknowledgment\n" "OSPF Link State Acknowledgment\n"
"OSPF all packets\n") "OSPF all packets\n")
{ {
int idx_number = 3;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1176,9 +1178,10 @@ DEFUN (debug_ospf_instance_ism,
"Instance ID\n" "Instance ID\n"
"OSPF Interface State Machine\n") "OSPF Interface State Machine\n")
{ {
int idx_number = 2;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1268,9 +1271,10 @@ DEFUN (no_debug_ospf_instance_ism,
"Instance ID\n" "Instance ID\n"
"OSPF Interface State Machine") "OSPF Interface State Machine")
{ {
int idx_number = 3;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1356,9 +1360,10 @@ DEFUN (debug_ospf_instance_nsm,
"Instance ID\n" "Instance ID\n"
"OSPF Neighbor State Machine\n") "OSPF Neighbor State Machine\n")
{ {
int idx_number = 2;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1448,9 +1453,10 @@ DEFUN (no_debug_ospf_instance_nsm,
"Instance ID\n" "Instance ID\n"
"OSPF Neighbor State Machine") "OSPF Neighbor State Machine")
{ {
int idx_number = 3;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1543,9 +1549,10 @@ DEFUN (debug_ospf_instance_lsa,
"Instance ID\n" "Instance ID\n"
"OSPF Link State Advertisement\n") "OSPF Link State Advertisement\n")
{ {
int idx_number = 2;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1641,9 +1648,10 @@ DEFUN (no_debug_ospf_instance_lsa,
"Instance ID\n" "Instance ID\n"
"OSPF Link State Advertisement\n") "OSPF Link State Advertisement\n")
{ {
int idx_number = 3;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1724,9 +1732,10 @@ DEFUN (debug_ospf_instance_zebra,
"Instance ID\n" "Instance ID\n"
"OSPF Zebra information\n") "OSPF Zebra information\n")
{ {
int idx_number = 2;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1811,9 +1820,10 @@ DEFUN (no_debug_ospf_instance_zebra,
"Instance ID\n" "Instance ID\n"
"OSPF Zebra information\n") "OSPF Zebra information\n")
{ {
int idx_number = 3;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1857,9 +1867,10 @@ DEFUN (debug_ospf_instance_event,
"Instance ID\n" "Instance ID\n"
"OSPF event information\n") "OSPF event information\n")
{ {
int idx_number = 2;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1878,9 +1889,10 @@ DEFUN (no_debug_ospf_instance_event,
"Instance ID\n" "Instance ID\n"
"OSPF event information\n") "OSPF event information\n")
{ {
int idx_number = 3;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1925,9 +1937,10 @@ DEFUN (debug_ospf_instance_nssa,
"Instance ID\n" "Instance ID\n"
"OSPF nssa information\n") "OSPF nssa information\n")
{ {
int idx_number = 2;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1946,9 +1959,10 @@ DEFUN (no_debug_ospf_instance_nssa,
"Instance ID\n" "Instance ID\n"
"OSPF nssa information\n") "OSPF nssa information\n")
{ {
int idx_number = 3;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if (!ospf_lookup_instance (instance)) if (!ospf_lookup_instance (instance))
return CMD_SUCCESS; return CMD_SUCCESS;
@ -2166,10 +2180,11 @@ DEFUN (show_debugging_ospf_instance,
OSPF_STR OSPF_STR
"Instance ID\n") "Instance ID\n")
{ {
int idx_number = 3;
struct ospf *ospf; struct ospf *ospf;
u_short instance = 0; u_short instance = 0;
VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
if ((ospf = ospf_lookup_instance (instance)) == NULL ) if ((ospf = ospf_lookup_instance (instance)) == NULL )
return CMD_SUCCESS; return CMD_SUCCESS;

View File

@ -1188,6 +1188,7 @@ DEFUN (router_info,
"Enable the Router Information functionality with Area flooding scope\n" "Enable the Router Information functionality with Area flooding scope\n"
"OSPF area ID in IP format") "OSPF area ID in IP format")
{ {
int idx_ipv4 = 2;
u_int8_t scope; u_int8_t scope;
@ -1197,7 +1198,7 @@ DEFUN (router_info,
/* Check and get Area value if present */ /* Check and get Area value if present */
if (argc == 1) if (argc == 1)
{ {
if (!inet_aton (argv[2]->arg, &OspfRI.area_id)) if (!inet_aton (argv[idx_ipv4]->arg, &OspfRI.area_id))
{ {
vty_out (vty, "Please specify Router Info Area by A.B.C.D%s", vty_out (vty, "Please specify Router Info Area by A.B.C.D%s",
VTY_NEWLINE); VTY_NEWLINE);
@ -1275,10 +1276,11 @@ DEFUN (pce_address,
"Stable IP address of the PCE\n" "Stable IP address of the PCE\n"
"PCE address in IPv4 address format\n") "PCE address in IPv4 address format\n")
{ {
int idx_ipv4 = 2;
struct in_addr value; struct in_addr value;
struct ospf_pce_info *pi = &OspfRI.pce_info; struct ospf_pce_info *pi = &OspfRI.pce_info;
if (!inet_aton (argv[2]->arg, &value)) if (!inet_aton (argv[idx_ipv4]->arg, &value))
{ {
vty_out (vty, "Please specify PCE Address by A.B.C.D%s", VTY_NEWLINE); vty_out (vty, "Please specify PCE Address by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -1322,10 +1324,11 @@ DEFUN (pce_path_scope,
"Path scope visibilities of the PCE for path computation\n" "Path scope visibilities of the PCE for path computation\n"
"32-bit Hexadecimal value\n") "32-bit Hexadecimal value\n")
{ {
int idx_bitpattern = 2;
uint32_t scope; uint32_t scope;
struct ospf_pce_info *pi = &OspfRI.pce_info; struct ospf_pce_info *pi = &OspfRI.pce_info;
if (sscanf (argv[2]->arg, "0x%x", &scope) != 1) if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &scope) != 1)
{ {
vty_out (vty, "pce_path_scope: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "pce_path_scope: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1369,13 +1372,14 @@ DEFUN (pce_domain,
"AS number where the PCE as visibilities for path computation\n" "AS number where the PCE as visibilities for path computation\n"
"AS number in decimal <0-65535>\n") "AS number in decimal <0-65535>\n")
{ {
int idx_number = 3;
uint32_t as; uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info; struct ospf_pce_info *pce = &OspfRI.pce_info;
struct listnode *node; struct listnode *node;
struct ri_pce_subtlv_domain *domain; struct ri_pce_subtlv_domain *domain;
if (sscanf (argv[3]->arg, "%d", &as) != 1) if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{ {
vty_out (vty, "pce_domain: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "pce_domain: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1408,11 +1412,12 @@ DEFUN (no_pce_domain,
"AS number where the PCE as visibilities for path computation\n" "AS number where the PCE as visibilities for path computation\n"
"AS number in decimal <0-65535>\n") "AS number in decimal <0-65535>\n")
{ {
int idx_number = 4;
uint32_t as; uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info; struct ospf_pce_info *pce = &OspfRI.pce_info;
if (sscanf (argv[4]->arg, "%d", &as) != 1) if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{ {
vty_out (vty, "no_pce_domain: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "no_pce_domain: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1437,13 +1442,14 @@ DEFUN (pce_neigbhor,
"AS number of PCE neighbors\n" "AS number of PCE neighbors\n"
"AS number in decimal <0-65535>\n") "AS number in decimal <0-65535>\n")
{ {
int idx_number = 3;
uint32_t as; uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info; struct ospf_pce_info *pce = &OspfRI.pce_info;
struct listnode *node; struct listnode *node;
struct ri_pce_subtlv_neighbor *neighbor; struct ri_pce_subtlv_neighbor *neighbor;
if (sscanf (argv[3]->arg, "%d", &as) != 1) if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{ {
vty_out (vty, "pce_neighbor: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "pce_neighbor: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1476,11 +1482,12 @@ DEFUN (no_pce_neighbor,
"AS number of PCE neighbor\n" "AS number of PCE neighbor\n"
"AS number in decimal <0-65535>\n") "AS number in decimal <0-65535>\n")
{ {
int idx_number = 4;
uint32_t as; uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info; struct ospf_pce_info *pce = &OspfRI.pce_info;
if (sscanf (argv[4]->arg, "%d", &as) != 1) if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{ {
vty_out (vty, "no_pce_neighbor: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "no_pce_neighbor: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1504,11 +1511,12 @@ DEFUN (pce_cap_flag,
"Capabilities of the PCE for path computation\n" "Capabilities of the PCE for path computation\n"
"32-bit Hexadecimal value\n") "32-bit Hexadecimal value\n")
{ {
int idx_bitpattern = 2;
uint32_t cap; uint32_t cap;
struct ospf_pce_info *pce = &OspfRI.pce_info; struct ospf_pce_info *pce = &OspfRI.pce_info;
if (sscanf (argv[2]->arg, "0x%x", &cap) != 1) if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &cap) != 1)
{ {
vty_out (vty, "pce_cap_flag: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "pce_cap_flag: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);

View File

@ -700,7 +700,8 @@ DEFUN (match_ip_nexthop,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP access-list name\n") "IP access-list name\n")
{ {
return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg); int idx_acl = 3;
return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg);
} }
/* /*
@ -736,8 +737,9 @@ DEFUN (match_ip_next_hop_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return ospf_route_match_add (vty, vty->index, "ip next-hop prefix-list", return ospf_route_match_add (vty, vty->index, "ip next-hop prefix-list",
argv[4]->arg); argv[idx_word]->arg);
} }
/* /*
@ -775,7 +777,8 @@ DEFUN (match_ip_address,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP access-list name\n") "IP access-list name\n")
{ {
return ospf_route_match_add (vty, vty->index, "ip address", argv[3]->arg); int idx_acl = 3;
return ospf_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg);
} }
/* /*
@ -811,8 +814,9 @@ DEFUN (match_ip_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return ospf_route_match_add (vty, vty->index, "ip address prefix-list", return ospf_route_match_add (vty, vty->index, "ip address prefix-list",
argv[4]->arg); argv[idx_word]->arg);
} }
/* /*
@ -847,7 +851,8 @@ DEFUN (match_interface,
"Match first hop interface of route\n" "Match first hop interface of route\n"
"Interface name\n") "Interface name\n")
{ {
return ospf_route_match_add (vty, vty->index, "interface", argv[2]->arg); int idx_word = 2;
return ospf_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg);
} }
/* /*
@ -877,7 +882,8 @@ DEFUN (match_tag,
"Match tag of route\n" "Match tag of route\n"
"Tag value\n") "Tag value\n")
{ {
return ospf_route_match_add (vty, vty->index, "tag", argv[2]->arg); int idx_number = 2;
return ospf_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg);
} }
/* /*
@ -907,7 +913,8 @@ DEFUN (set_metric,
"Metric value for destination routing protocol\n" "Metric value for destination routing protocol\n"
"Metric value\n") "Metric value\n")
{ {
return ospf_route_set_add (vty, vty->index, "metric", argv[2]->arg); int idx_number = 2;
return ospf_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
} }
/* /*
@ -938,12 +945,13 @@ DEFUN (set_metric_type,
"OSPF[6] external type 1 metric\n" "OSPF[6] external type 1 metric\n"
"OSPF[6] external type 2 metric\n") "OSPF[6] external type 2 metric\n")
{ {
if (strcmp (argv[2]->arg, "1") == 0) int idx_external = 2;
if (strcmp (argv[idx_external]->arg, "1") == 0)
return ospf_route_set_add (vty, vty->index, "metric-type", "type-1"); return ospf_route_set_add (vty, vty->index, "metric-type", "type-1");
if (strcmp (argv[2]->arg, "2") == 0) if (strcmp (argv[idx_external]->arg, "2") == 0)
return ospf_route_set_add (vty, vty->index, "metric-type", "type-2"); return ospf_route_set_add (vty, vty->index, "metric-type", "type-2");
return ospf_route_set_add (vty, vty->index, "metric-type", argv[2]->arg); return ospf_route_set_add (vty, vty->index, "metric-type", argv[idx_external]->arg);
} }
/* /*
@ -974,7 +982,8 @@ DEFUN (set_tag,
"Tag value for routing protocol\n" "Tag value for routing protocol\n"
"Tag value\n") "Tag value\n")
{ {
return ospf_route_set_add (vty, vty->index, "tag", argv[2]->arg); int idx_number = 2;
return ospf_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
} }
/* /*

View File

@ -2341,6 +2341,7 @@ DEFUN (ospf_mpls_te_router_addr,
"Stable IP address of the advertising router\n" "Stable IP address of the advertising router\n"
"MPLS-TE router address in IPv4 address format\n") "MPLS-TE router address in IPv4 address format\n")
{ {
int idx_ipv4 = 2;
struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr; struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr;
struct in_addr value; struct in_addr value;
struct ospf *ospf = vty->index; struct ospf *ospf = vty->index;
@ -2348,7 +2349,7 @@ DEFUN (ospf_mpls_te_router_addr,
if (!ospf) if (!ospf)
return CMD_SUCCESS; return CMD_SUCCESS;
if (! inet_aton (argv[2]->arg, &value)) if (! inet_aton (argv[idx_ipv4]->arg, &value))
{ {
vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -2482,7 +2483,8 @@ DEFUN (ospf_mpls_te_inter_as_area,
"OSPF area ID in IP format\n" "OSPF area ID in IP format\n"
"OSPF area ID as decimal value\n") "OSPF area ID as decimal value\n")
{ {
return set_inter_as_mode (vty, "area", argv[3]->arg); int idx_ipv4_number = 3;
return set_inter_as_mode (vty, "area", argv[idx_ipv4_number]->arg);
} }
DEFUN (no_ospf_mpls_te_inter_as, DEFUN (no_ospf_mpls_te_inter_as,
@ -2626,6 +2628,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
"Interface information\n" "Interface information\n"
"Interface name\n") "Interface name\n")
{ {
int idx_interface = 5;
struct interface *ifp; struct interface *ifp;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -2638,7 +2641,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
/* Interface name is specified. */ /* Interface name is specified. */
else else
{ {
if ((ifp = if_lookup_by_name (argv[5]->arg)) == NULL) if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL)
vty_out (vty, "No such interface name%s", VTY_NEWLINE); vty_out (vty, "No such interface name%s", VTY_NEWLINE);
else else
show_mpls_te_link_sub (vty, ifp); show_mpls_te_link_sub (vty, ifp);

File diff suppressed because it is too large Load Diff

View File

@ -1533,8 +1533,9 @@ DEFUN (pim_interface,
"Select an interface to configure\n" "Select an interface to configure\n"
"Interface's name\n") "Interface's name\n")
{ {
int idx_ifname = 1;
struct interface *ifp; struct interface *ifp;
const char *ifname = argv[1]->arg; const char *ifname = argv[idx_ifname]->arg;
size_t sl; size_t sl;
sl = strlen(ifname); sl = strlen(ifname);
@ -2368,13 +2369,14 @@ DEFUN (show_ip_rib,
RIB_STR RIB_STR
"Unicast address\n") "Unicast address\n")
{ {
int idx_ipv4 = 3;
struct in_addr addr; struct in_addr addr;
const char *addr_str; const char *addr_str;
struct pim_nexthop nexthop; struct pim_nexthop nexthop;
char nexthop_addr_str[100]; char nexthop_addr_str[100];
int result; int result;
addr_str = argv[3]->arg; addr_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, addr_str, &addr); result = inet_pton(AF_INET, addr_str, &addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad unicast address %s: errno=%d: %s%s", vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
@ -2466,16 +2468,17 @@ DEFUN (ip_pim_rp,
"Rendevous Point\n" "Rendevous Point\n"
"ip address of RP\n") "ip address of RP\n")
{ {
int idx_ipv4 = 3;
int result; int result;
result = inet_pton(AF_INET, argv[3]->arg, &qpim_rp.rpf_addr.s_addr); result = inet_pton(AF_INET, argv[idx_ipv4]->arg, &qpim_rp.rpf_addr.s_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "%% Bad RP address specified: %s", argv[3]->arg); vty_out(vty, "%% Bad RP address specified: %s", argv[idx_ipv4]->arg);
return CMD_WARNING; return CMD_WARNING;
} }
if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) { if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) {
vty_out(vty, "%% No Path to RP address specified: %s", argv[3]->arg); vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg);
return CMD_WARNING; return CMD_WARNING;
} }
@ -2484,7 +2487,7 @@ DEFUN (ip_pim_rp,
DEFUN (no_ip_pim_rp, DEFUN (no_ip_pim_rp,
no_ip_pim_rp_cmd, no_ip_pim_rp_cmd,
"no ip pim rp {A.B.C.D}", "no ip pim rp [A.B.C.D]",
NO_STR NO_STR
IP_STR IP_STR
"pim multicast routing\n" "pim multicast routing\n"
@ -2531,9 +2534,10 @@ DEFUN (ip_ssmpingd,
CONF_SSMPINGD_STR CONF_SSMPINGD_STR
"Source address\n") "Source address\n")
{ {
int idx_ipv4 = 2;
int result; int result;
struct in_addr source_addr; struct in_addr source_addr;
const char *source_str = (argc > 0) ? argv[2]->arg : "0.0.0.0"; const char *source_str = (argc > 0) ? argv[idx_ipv4]->arg : "0.0.0.0";
result = inet_pton(AF_INET, source_str, &source_addr); result = inet_pton(AF_INET, source_str, &source_addr);
if (result <= 0) { if (result <= 0) {
@ -2560,9 +2564,10 @@ DEFUN (no_ip_ssmpingd,
CONF_SSMPINGD_STR CONF_SSMPINGD_STR
"Source address\n") "Source address\n")
{ {
int idx_ipv4 = 3;
int result; int result;
struct in_addr source_addr; struct in_addr source_addr;
const char *source_str = (argc > 0) ? argv[3]->arg : "0.0.0.0"; const char *source_str = (argc > 0) ? argv[idx_ipv4]->arg : "0.0.0.0";
result = inet_pton(AF_INET, source_str, &source_addr); result = inet_pton(AF_INET, source_str, &source_addr);
if (result <= 0) { if (result <= 0) {
@ -2648,6 +2653,8 @@ DEFUN (interface_ip_igmp_join,
"Multicast group address\n" "Multicast group address\n"
"Source address\n") "Source address\n")
{ {
int idx_ipv4 = 3;
int idx_ipv4_2 = 4;
struct interface *ifp; struct interface *ifp;
const char *group_str; const char *group_str;
const char *source_str; const char *source_str;
@ -2658,7 +2665,7 @@ DEFUN (interface_ip_igmp_join,
ifp = vty->index; ifp = vty->index;
/* Group address */ /* Group address */
group_str = argv[3]->arg; group_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, group_str, &group_addr); result = inet_pton(AF_INET, group_str, &group_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -2667,7 +2674,7 @@ DEFUN (interface_ip_igmp_join,
} }
/* Source address */ /* Source address */
source_str = argv[4]->arg; source_str = argv[idx_ipv4_2]->arg;
result = inet_pton(AF_INET, source_str, &source_addr); result = inet_pton(AF_INET, source_str, &source_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad source address %s: errno=%d: %s%s", vty_out(vty, "Bad source address %s: errno=%d: %s%s",
@ -2695,6 +2702,8 @@ DEFUN (interface_no_ip_igmp_join,
"Multicast group address\n" "Multicast group address\n"
"Source address\n") "Source address\n")
{ {
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
struct interface *ifp; struct interface *ifp;
const char *group_str; const char *group_str;
const char *source_str; const char *source_str;
@ -2705,7 +2714,7 @@ DEFUN (interface_no_ip_igmp_join,
ifp = vty->index; ifp = vty->index;
/* Group address */ /* Group address */
group_str = argv[4]->arg; group_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, group_str, &group_addr); result = inet_pton(AF_INET, group_str, &group_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -2714,7 +2723,7 @@ DEFUN (interface_no_ip_igmp_join,
} }
/* Source address */ /* Source address */
source_str = argv[5]->arg; source_str = argv[idx_ipv4_2]->arg;
result = inet_pton(AF_INET, source_str, &source_addr); result = inet_pton(AF_INET, source_str, &source_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad source address %s: errno=%d: %s%s", vty_out(vty, "Bad source address %s: errno=%d: %s%s",
@ -2865,7 +2874,7 @@ static void change_query_max_response_time(struct pim_interface *pim_ifp,
DEFUN (interface_ip_igmp_query_interval, DEFUN (interface_ip_igmp_query_interval,
interface_ip_igmp_query_interval_cmd, interface_ip_igmp_query_interval_cmd,
PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>", PIM_CMD_IP_IGMP_QUERY_INTERVAL " (1-1800)",
IP_STR IP_STR
IFACE_IGMP_STR IFACE_IGMP_STR
IFACE_IGMP_QUERY_INTERVAL_STR IFACE_IGMP_QUERY_INTERVAL_STR
@ -2960,7 +2969,7 @@ DEFUN (interface_no_ip_igmp_query_interval,
DEFUN (interface_ip_igmp_query_max_response_time, DEFUN (interface_ip_igmp_query_max_response_time,
interface_ip_igmp_query_max_response_time_cmd, interface_ip_igmp_query_max_response_time_cmd,
PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>", PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " (1-25)",
IP_STR IP_STR
IFACE_IGMP_STR IFACE_IGMP_STR
IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
@ -3053,7 +3062,7 @@ DEFUN (interface_no_ip_igmp_query_max_response_time,
DEFUN (interface_ip_igmp_query_max_response_time_dsec, DEFUN (interface_ip_igmp_query_max_response_time_dsec,
interface_ip_igmp_query_max_response_time_dsec_cmd, interface_ip_igmp_query_max_response_time_dsec_cmd,
PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>", PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " (10-250)",
IP_STR IP_STR
IFACE_IGMP_STR IFACE_IGMP_STR
IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
@ -3146,12 +3155,13 @@ DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
DEFUN (interface_ip_pim_drprio, DEFUN (interface_ip_pim_drprio,
interface_ip_pim_drprio_cmd, interface_ip_pim_drprio_cmd,
"ip pim drpriority <1-4294967295>", "ip pim drpriority (1-4294967295)",
IP_STR IP_STR
PIM_STR PIM_STR
"Set the Designated Router Election Priority\n" "Set the Designated Router Election Priority\n"
"Value of the new DR Priority\n") "Value of the new DR Priority\n")
{ {
int idx_number = 3;
struct interface *ifp; struct interface *ifp;
struct pim_interface *pim_ifp; struct pim_interface *pim_ifp;
uint32_t old_dr_prio; uint32_t old_dr_prio;
@ -3166,7 +3176,7 @@ DEFUN (interface_ip_pim_drprio,
old_dr_prio = pim_ifp->pim_dr_priority; old_dr_prio = pim_ifp->pim_dr_priority;
pim_ifp->pim_dr_priority = strtol(argv[3]->arg, NULL, 10); pim_ifp->pim_dr_priority = strtol(argv[idx_number]->arg, NULL, 10);
if (old_dr_prio != pim_ifp->pim_dr_priority) { if (old_dr_prio != pim_ifp->pim_dr_priority) {
if (pim_if_dr_election(ifp)) if (pim_if_dr_election(ifp))
@ -3178,7 +3188,7 @@ DEFUN (interface_ip_pim_drprio,
DEFUN (interface_no_ip_pim_drprio, DEFUN (interface_no_ip_pim_drprio,
interface_no_ip_pim_drprio_cmd, interface_no_ip_pim_drprio_cmd,
"no ip pim drpriority {<1-4294967295>}", "no ip pim drpriority [(1-4294967295)]",
IP_STR IP_STR
PIM_STR PIM_STR
"Revert the Designated Router Priority to default\n" "Revert the Designated Router Priority to default\n"
@ -3345,6 +3355,8 @@ DEFUN (interface_ip_mroute,
"Outgoing interface name\n" "Outgoing interface name\n"
"Group address\n") "Group address\n")
{ {
int idx_interface = 2;
int idx_ipv4 = 3;
struct interface *iif; struct interface *iif;
struct interface *oif; struct interface *oif;
const char *oifname; const char *oifname;
@ -3355,7 +3367,7 @@ DEFUN (interface_ip_mroute,
iif = vty->index; iif = vty->index;
oifname = argv[2]->arg; oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname); oif = if_lookup_by_name(oifname);
if (!oif) { if (!oif) {
vty_out(vty, "No such interface name %s%s", vty_out(vty, "No such interface name %s%s",
@ -3363,7 +3375,7 @@ DEFUN (interface_ip_mroute,
return CMD_WARNING; return CMD_WARNING;
} }
grp_str = argv[3]->arg; grp_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, grp_str, &grp_addr); result = inet_pton(AF_INET, grp_str, &grp_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -3390,6 +3402,9 @@ DEFUN (interface_ip_mroute_source,
"Group address\n" "Group address\n"
"Source address\n") "Source address\n")
{ {
int idx_interface = 2;
int idx_ipv4 = 3;
int idx_ipv4_2 = 4;
struct interface *iif; struct interface *iif;
struct interface *oif; struct interface *oif;
const char *oifname; const char *oifname;
@ -3401,7 +3416,7 @@ DEFUN (interface_ip_mroute_source,
iif = vty->index; iif = vty->index;
oifname = argv[2]->arg; oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname); oif = if_lookup_by_name(oifname);
if (!oif) { if (!oif) {
vty_out(vty, "No such interface name %s%s", vty_out(vty, "No such interface name %s%s",
@ -3409,7 +3424,7 @@ DEFUN (interface_ip_mroute_source,
return CMD_WARNING; return CMD_WARNING;
} }
grp_str = argv[3]->arg; grp_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, grp_str, &grp_addr); result = inet_pton(AF_INET, grp_str, &grp_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -3417,7 +3432,7 @@ DEFUN (interface_ip_mroute_source,
return CMD_WARNING; return CMD_WARNING;
} }
src_str = argv[4]->arg; src_str = argv[idx_ipv4_2]->arg;
result = inet_pton(AF_INET, src_str, &src_addr); result = inet_pton(AF_INET, src_str, &src_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad source address %s: errno=%d: %s%s", vty_out(vty, "Bad source address %s: errno=%d: %s%s",
@ -3442,6 +3457,8 @@ DEFUN (interface_no_ip_mroute,
"Outgoing interface name\n" "Outgoing interface name\n"
"Group Address\n") "Group Address\n")
{ {
int idx_interface = 3;
int idx_ipv4 = 4;
struct interface *iif; struct interface *iif;
struct interface *oif; struct interface *oif;
const char *oifname; const char *oifname;
@ -3452,7 +3469,7 @@ DEFUN (interface_no_ip_mroute,
iif = vty->index; iif = vty->index;
oifname = argv[3]->arg; oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname); oif = if_lookup_by_name(oifname);
if (!oif) { if (!oif) {
vty_out(vty, "No such interface name %s%s", vty_out(vty, "No such interface name %s%s",
@ -3460,7 +3477,7 @@ DEFUN (interface_no_ip_mroute,
return CMD_WARNING; return CMD_WARNING;
} }
grp_str = argv[4]->arg; grp_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, grp_str, &grp_addr); result = inet_pton(AF_INET, grp_str, &grp_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -3488,6 +3505,9 @@ DEFUN (interface_no_ip_mroute_source,
"Group Address\n" "Group Address\n"
"Source Address\n") "Source Address\n")
{ {
int idx_interface = 3;
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
struct interface *iif; struct interface *iif;
struct interface *oif; struct interface *oif;
const char *oifname; const char *oifname;
@ -3499,7 +3519,7 @@ DEFUN (interface_no_ip_mroute_source,
iif = vty->index; iif = vty->index;
oifname = argv[3]->arg; oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname); oif = if_lookup_by_name(oifname);
if (!oif) { if (!oif) {
vty_out(vty, "No such interface name %s%s", vty_out(vty, "No such interface name %s%s",
@ -3507,7 +3527,7 @@ DEFUN (interface_no_ip_mroute_source,
return CMD_WARNING; return CMD_WARNING;
} }
grp_str = argv[4]->arg; grp_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, grp_str, &grp_addr); result = inet_pton(AF_INET, grp_str, &grp_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -3515,7 +3535,7 @@ DEFUN (interface_no_ip_mroute_source,
return CMD_WARNING; return CMD_WARNING;
} }
src_str = argv[5]->arg; src_str = argv[idx_ipv4_2]->arg;
result = inet_pton(AF_INET, src_str, &src_addr); result = inet_pton(AF_INET, src_str, &src_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad source address %s: errno=%d: %s%s", vty_out(vty, "Bad source address %s: errno=%d: %s%s",
@ -3543,12 +3563,13 @@ DEFUN (interface_no_ip_mroute_source,
*/ */
DEFUN (interface_ip_pim_hello, DEFUN (interface_ip_pim_hello,
interface_ip_pim_hello_cmd, interface_ip_pim_hello_cmd,
"ip pim hello <1-180>", "ip pim hello (1-180)",
IP_STR IP_STR
PIM_STR PIM_STR
IFACE_PIM_HELLO_STR IFACE_PIM_HELLO_STR
IFACE_PIM_HELLO_TIME_STR) IFACE_PIM_HELLO_TIME_STR)
{ {
int idx_number = 3;
struct interface *ifp; struct interface *ifp;
struct pim_interface *pim_ifp; struct pim_interface *pim_ifp;
@ -3560,7 +3581,7 @@ DEFUN (interface_ip_pim_hello,
return CMD_WARNING; return CMD_WARNING;
} }
pim_ifp->pim_hello_period = strtol(argv[3]->arg, NULL, 10); pim_ifp->pim_hello_period = strtol(argv[idx_number]->arg, NULL, 10);
if (argc == 2) if (argc == 2)
pim_ifp->pim_default_holdtime = strtol(argv[4]->arg, NULL, 10); pim_ifp->pim_default_holdtime = strtol(argv[4]->arg, NULL, 10);
@ -3572,7 +3593,7 @@ DEFUN (interface_ip_pim_hello,
DEFUN (interface_no_ip_pim_hello, DEFUN (interface_no_ip_pim_hello,
interface_no_ip_pim_hello_cmd, interface_no_ip_pim_hello_cmd,
"no ip pim hello {<1-180> <1-180>}", "no ip pim hello [(1-180) (1-180)]",
NO_STR NO_STR
IP_STR IP_STR
PIM_STR PIM_STR
@ -3867,19 +3888,20 @@ DEFUN (debug_pim_packets,
DEFUN (debug_pim_packets_filter, DEFUN (debug_pim_packets_filter,
debug_pim_packets_filter_cmd, debug_pim_packets_filter_cmd,
"debug pim packets (hello|joins)", "debug pim packets <hello|joins>",
DEBUG_STR DEBUG_STR
DEBUG_PIM_STR DEBUG_PIM_STR
DEBUG_PIM_PACKETS_STR DEBUG_PIM_PACKETS_STR
DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_HELLO_PACKETS_STR
DEBUG_PIM_J_P_PACKETS_STR) DEBUG_PIM_J_P_PACKETS_STR)
{ {
if (strncmp(argv[3]->arg,"h",1) == 0) int idx_hello_join = 3;
if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0)
{ {
PIM_DO_DEBUG_PIM_HELLO; PIM_DO_DEBUG_PIM_HELLO;
vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE); vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE);
} }
else if (strncmp(argv[3]->arg,"j",1) == 0) else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
{ {
PIM_DO_DEBUG_PIM_J_P; PIM_DO_DEBUG_PIM_J_P;
vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE); vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE);
@ -3912,7 +3934,7 @@ DEFUN (no_debug_pim_packets,
DEFUN (no_debug_pim_packets_filter, DEFUN (no_debug_pim_packets_filter,
no_debug_pim_packets_filter_cmd, no_debug_pim_packets_filter_cmd,
"no debug pim packets (hello|joins)", "no debug pim packets <hello|joins>",
NO_STR NO_STR
DEBUG_STR DEBUG_STR
DEBUG_PIM_STR DEBUG_PIM_STR
@ -3920,12 +3942,13 @@ DEFUN (no_debug_pim_packets_filter,
DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_HELLO_PACKETS_STR
DEBUG_PIM_J_P_PACKETS_STR) DEBUG_PIM_J_P_PACKETS_STR)
{ {
if (strncmp(argv[4]->arg,"h",1) == 0) int idx_hello_join = 4;
if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0)
{ {
PIM_DONT_DEBUG_PIM_HELLO; PIM_DONT_DEBUG_PIM_HELLO;
vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE); vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE);
} }
else if (strncmp(argv[4]->arg,"j",1) == 0) else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
{ {
PIM_DONT_DEBUG_PIM_J_P; PIM_DONT_DEBUG_PIM_J_P;
vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE); vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE);
@ -4137,7 +4160,7 @@ static struct igmp_sock *find_igmp_sock_by_fd(int fd)
DEFUN (test_igmp_receive_report, DEFUN (test_igmp_receive_report,
test_igmp_receive_report_cmd, test_igmp_receive_report_cmd,
"test igmp receive report <0-65535> A.B.C.D <1-6> .LINE", "test igmp receive report (0-65535) A.B.C.D (1-6) .LINE",
"Test\n" "Test\n"
"Test IGMP protocol\n" "Test IGMP protocol\n"
"Test IGMP message\n" "Test IGMP message\n"
@ -4147,6 +4170,9 @@ DEFUN (test_igmp_receive_report,
"Record type\n" "Record type\n"
"Sources\n") "Sources\n")
{ {
int idx_number = 4;
int idx_ipv4 = 5;
int idx_number_2 = 6;
char buf[1000]; char buf[1000];
char *igmp_msg; char *igmp_msg;
struct ip *ip_hdr; struct ip *ip_hdr;
@ -4168,7 +4194,7 @@ DEFUN (test_igmp_receive_report,
struct in_addr *src_addr; struct in_addr *src_addr;
int argi; int argi;
socket = argv[4]->arg; socket = argv[idx_number]->arg;
socket_fd = atoi(socket); socket_fd = atoi(socket);
igmp = find_igmp_sock_by_fd(socket_fd); igmp = find_igmp_sock_by_fd(socket_fd);
if (!igmp) { if (!igmp) {
@ -4177,7 +4203,7 @@ DEFUN (test_igmp_receive_report,
return CMD_WARNING; return CMD_WARNING;
} }
grp_str = argv[5]->arg; grp_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, grp_str, &grp_addr); result = inet_pton(AF_INET, grp_str, &grp_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -4185,7 +4211,7 @@ DEFUN (test_igmp_receive_report,
return CMD_WARNING; return CMD_WARNING;
} }
record_type_str = argv[6]->arg; record_type_str = argv[idx_number_2]->arg;
record_type = atoi(record_type_str); record_type = atoi(record_type_str);
/* /*
@ -4259,6 +4285,8 @@ DEFUN (test_pim_receive_dump,
"Neighbor address\n" "Neighbor address\n"
"Packet dump\n") "Packet dump\n")
{ {
int idx_interface = 4;
int idx_ipv4 = 5;
uint8_t buf[1000]; uint8_t buf[1000];
uint8_t *pim_msg; uint8_t *pim_msg;
struct ip *ip_hdr; struct ip *ip_hdr;
@ -4273,7 +4301,7 @@ DEFUN (test_pim_receive_dump,
int result; int result;
/* Find interface */ /* Find interface */
ifname = argv[4]->arg; ifname = argv[idx_interface]->arg;
ifp = if_lookup_by_name(ifname); ifp = if_lookup_by_name(ifname);
if (!ifp) { if (!ifp) {
vty_out(vty, "No such interface name %s%s", vty_out(vty, "No such interface name %s%s",
@ -4282,7 +4310,7 @@ DEFUN (test_pim_receive_dump,
} }
/* Neighbor address */ /* Neighbor address */
neigh_str = argv[5]->arg; neigh_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, neigh_str, &neigh_addr); result = inet_pton(AF_INET, neigh_str, &neigh_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
@ -4362,7 +4390,7 @@ DEFUN (test_pim_receive_dump,
DEFUN (test_pim_receive_hello, DEFUN (test_pim_receive_hello,
test_pim_receive_hello_cmd, test_pim_receive_hello_cmd,
"test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]", "test pim receive hello INTERFACE A.B.C.D (0-65535) (0-65535) (0-65535) (0-32767) (0-65535) (0-1) [LINE]",
"Test\n" "Test\n"
"Test PIM protocol\n" "Test PIM protocol\n"
"Test PIM message reception\n" "Test PIM message reception\n"
@ -4377,6 +4405,14 @@ DEFUN (test_pim_receive_hello,
"Neighbor LAN prune delay T-bit\n" "Neighbor LAN prune delay T-bit\n"
"Neighbor secondary addresses\n") "Neighbor secondary addresses\n")
{ {
int idx_interface = 4;
int idx_ipv4 = 5;
int idx_number = 6;
int idx_number_2 = 7;
int idx_number_3 = 8;
int idx_number_4 = 9;
int idx_number_5 = 10;
int idx_number_6 = 11;
uint8_t buf[1000]; uint8_t buf[1000];
uint8_t *pim_msg; uint8_t *pim_msg;
struct ip *ip_hdr; struct ip *ip_hdr;
@ -4398,7 +4434,7 @@ DEFUN (test_pim_receive_hello,
int result; int result;
/* Find interface */ /* Find interface */
ifname = argv[4]->arg; ifname = argv[idx_interface]->arg;
ifp = if_lookup_by_name(ifname); ifp = if_lookup_by_name(ifname);
if (!ifp) { if (!ifp) {
vty_out(vty, "No such interface name %s%s", vty_out(vty, "No such interface name %s%s",
@ -4407,7 +4443,7 @@ DEFUN (test_pim_receive_hello,
} }
/* Neighbor address */ /* Neighbor address */
neigh_str = argv[5]->arg; neigh_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, neigh_str, &neigh_addr); result = inet_pton(AF_INET, neigh_str, &neigh_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
@ -4415,12 +4451,12 @@ DEFUN (test_pim_receive_hello,
return CMD_WARNING; return CMD_WARNING;
} }
neigh_holdtime = atoi(argv[6]->arg); neigh_holdtime = atoi(argv[idx_number]->arg);
neigh_dr_priority = atoi(argv[7]->arg); neigh_dr_priority = atoi(argv[idx_number_2]->arg);
neigh_generation_id = atoi(argv[8]->arg); neigh_generation_id = atoi(argv[idx_number_3]->arg);
neigh_propagation_delay = atoi(argv[9]->arg); neigh_propagation_delay = atoi(argv[idx_number_4]->arg);
neigh_override_interval = atoi(argv[10]->arg); neigh_override_interval = atoi(argv[idx_number_5]->arg);
neigh_can_disable_join_suppression = atoi(argv[11]->arg); neigh_can_disable_join_suppression = atoi(argv[idx_number_6]->arg);
/* /*
Tweak IP header Tweak IP header
@ -4489,7 +4525,7 @@ DEFUN (test_pim_receive_hello,
DEFUN (test_pim_receive_assert, DEFUN (test_pim_receive_assert,
test_pim_receive_assert_cmd, test_pim_receive_assert_cmd,
"test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>", "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D (0-65535) (0-65535) (0-1)",
"Test\n" "Test\n"
"Test PIM protocol\n" "Test PIM protocol\n"
"Test PIM message reception\n" "Test PIM message reception\n"
@ -4502,6 +4538,13 @@ DEFUN (test_pim_receive_assert,
"Assert route metric\n" "Assert route metric\n"
"Assert RPT bit flag\n") "Assert RPT bit flag\n")
{ {
int idx_interface = 4;
int idx_ipv4 = 5;
int idx_ipv4_2 = 6;
int idx_ipv4_3 = 7;
int idx_number = 8;
int idx_number_2 = 9;
int idx_number_3 = 10;
uint8_t buf[1000]; uint8_t buf[1000];
uint8_t *buf_pastend = buf + sizeof(buf); uint8_t *buf_pastend = buf + sizeof(buf);
uint8_t *pim_msg; uint8_t *pim_msg;
@ -4524,7 +4567,7 @@ DEFUN (test_pim_receive_assert,
int result; int result;
/* Find interface */ /* Find interface */
ifname = argv[4]->arg; ifname = argv[idx_interface]->arg;
ifp = if_lookup_by_name(ifname); ifp = if_lookup_by_name(ifname);
if (!ifp) { if (!ifp) {
vty_out(vty, "No such interface name %s%s", vty_out(vty, "No such interface name %s%s",
@ -4533,7 +4576,7 @@ DEFUN (test_pim_receive_assert,
} }
/* Neighbor address */ /* Neighbor address */
neigh_str = argv[5]->arg; neigh_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, neigh_str, &neigh_addr); result = inet_pton(AF_INET, neigh_str, &neigh_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
@ -4542,7 +4585,7 @@ DEFUN (test_pim_receive_assert,
} }
/* Group address */ /* Group address */
group_str = argv[6]->arg; group_str = argv[idx_ipv4_2]->arg;
result = inet_pton(AF_INET, group_str, &group_addr); result = inet_pton(AF_INET, group_str, &group_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -4551,7 +4594,7 @@ DEFUN (test_pim_receive_assert,
} }
/* Source address */ /* Source address */
source_str = argv[7]->arg; source_str = argv[idx_ipv4_3]->arg;
result = inet_pton(AF_INET, source_str, &source_addr); result = inet_pton(AF_INET, source_str, &source_addr);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad source address %s: errno=%d: %s%s", vty_out(vty, "Bad source address %s: errno=%d: %s%s",
@ -4559,9 +4602,9 @@ DEFUN (test_pim_receive_assert,
return CMD_WARNING; return CMD_WARNING;
} }
assert_metric_preference = atoi(argv[8]->arg); assert_metric_preference = atoi(argv[idx_number]->arg);
assert_route_metric = atoi(argv[9]->arg); assert_route_metric = atoi(argv[idx_number_2]->arg);
assert_rpt_bit_flag = atoi(argv[10]->arg); assert_rpt_bit_flag = atoi(argv[idx_number_3]->arg);
remain = buf_pastend - buf; remain = buf_pastend - buf;
if (remain < (int) sizeof(struct ip)) { if (remain < (int) sizeof(struct ip)) {
@ -4797,7 +4840,7 @@ static int recv_joinprune(struct vty *vty,
DEFUN (test_pim_receive_join, DEFUN (test_pim_receive_join,
test_pim_receive_join_cmd, test_pim_receive_join_cmd,
"test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "test pim receive join INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
"Test\n" "Test\n"
"Test PIM protocol\n" "Test PIM protocol\n"
"Test PIM message reception\n" "Test PIM message reception\n"
@ -4814,7 +4857,7 @@ DEFUN (test_pim_receive_join,
DEFUN (test_pim_receive_prune, DEFUN (test_pim_receive_prune,
test_pim_receive_prune_cmd, test_pim_receive_prune_cmd,
"test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "test pim receive prune INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
"Test\n" "Test\n"
"Test PIM protocol\n" "Test PIM protocol\n"
"Test PIM message reception\n" "Test PIM message reception\n"
@ -4831,7 +4874,7 @@ DEFUN (test_pim_receive_prune,
DEFUN (test_pim_receive_upcall, DEFUN (test_pim_receive_upcall,
test_pim_receive_upcall_cmd, test_pim_receive_upcall_cmd,
"test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D", "test pim receive upcall <nocache|wrongvif|wholepkt> (0-65535) A.B.C.D A.B.C.D",
"Test\n" "Test\n"
"Test PIM protocol\n" "Test PIM protocol\n"
"Test PIM message reception\n" "Test PIM message reception\n"
@ -4843,13 +4886,17 @@ DEFUN (test_pim_receive_upcall,
"Multicast group address\n" "Multicast group address\n"
"Multicast source address\n") "Multicast source address\n")
{ {
int idx_type = 4;
int idx_number = 5;
int idx_ipv4 = 6;
int idx_ipv4_2 = 7;
struct igmpmsg msg; struct igmpmsg msg;
const char *upcall_type; const char *upcall_type;
const char *group_str; const char *group_str;
const char *source_str; const char *source_str;
int result; int result;
upcall_type = argv[4]->arg; upcall_type = argv[idx_type]->arg;
if (upcall_type[0] == 'n') if (upcall_type[0] == 'n')
msg.im_msgtype = IGMPMSG_NOCACHE; msg.im_msgtype = IGMPMSG_NOCACHE;
@ -4863,10 +4910,10 @@ DEFUN (test_pim_receive_upcall,
return CMD_WARNING; return CMD_WARNING;
} }
msg.im_vif = atoi(argv[5]->arg); msg.im_vif = atoi(argv[idx_number]->arg);
/* Group address */ /* Group address */
group_str = argv[6]->arg; group_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, group_str, &msg.im_dst); result = inet_pton(AF_INET, group_str, &msg.im_dst);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad group address %s: errno=%d: %s%s", vty_out(vty, "Bad group address %s: errno=%d: %s%s",
@ -4875,7 +4922,7 @@ DEFUN (test_pim_receive_upcall,
} }
/* Source address */ /* Source address */
source_str = argv[7]->arg; source_str = argv[idx_ipv4_2]->arg;
result = inet_pton(AF_INET, source_str, &msg.im_src); result = inet_pton(AF_INET, source_str, &msg.im_src);
if (result <= 0) { if (result <= 0) {
vty_out(vty, "Bad source address %s: errno=%d: %s%s", vty_out(vty, "Bad source address %s: errno=%d: %s%s",

View File

@ -97,10 +97,11 @@ DEFUN (debug_rip_packet_direct,
"RIP receive packet\n" "RIP receive packet\n"
"RIP send packet\n") "RIP send packet\n")
{ {
int idx_recv_send = 3;
rip_debug_packet |= RIP_DEBUG_PACKET; rip_debug_packet |= RIP_DEBUG_PACKET;
if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
rip_debug_packet |= RIP_DEBUG_SEND; rip_debug_packet |= RIP_DEBUG_SEND;
if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
rip_debug_packet |= RIP_DEBUG_RECV; rip_debug_packet |= RIP_DEBUG_RECV;
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -150,14 +151,15 @@ DEFUN (no_debug_rip_packet_direct,
"RIP option set for receive packet\n" "RIP option set for receive packet\n"
"RIP option set for send packet\n") "RIP option set for send packet\n")
{ {
if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0) int idx_recv_send = 4;
if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{ {
if (IS_RIP_DEBUG_RECV) if (IS_RIP_DEBUG_RECV)
rip_debug_packet &= ~RIP_DEBUG_SEND; rip_debug_packet &= ~RIP_DEBUG_SEND;
else else
rip_debug_packet = 0; rip_debug_packet = 0;
} }
else if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0) else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{ {
if (IS_RIP_DEBUG_SEND) if (IS_RIP_DEBUG_SEND)
rip_debug_packet &= ~RIP_DEBUG_RECV; rip_debug_packet &= ~RIP_DEBUG_RECV;

View File

@ -1225,19 +1225,20 @@ DEFUN (rip_network,
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Interface name\n") "Interface name\n")
{ {
int idx_ipv4_word = 1;
int ret; int ret;
struct prefix_ipv4 p; struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[1]->arg, &p); ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p);
if (ret) if (ret)
ret = rip_enable_network_add ((struct prefix *) &p); ret = rip_enable_network_add ((struct prefix *) &p);
else else
ret = rip_enable_if_add (argv[1]->arg); ret = rip_enable_if_add (argv[idx_ipv4_word]->arg);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "There is a same network configuration %s%s", argv[1]->arg, vty_out (vty, "There is a same network configuration %s%s", argv[idx_ipv4_word]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1254,19 +1255,20 @@ DEFUN (no_rip_network,
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Interface name\n") "Interface name\n")
{ {
int idx_ipv4_word = 2;
int ret; int ret;
struct prefix_ipv4 p; struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[2]->arg, &p); ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p);
if (ret) if (ret)
ret = rip_enable_network_delete ((struct prefix *) &p); ret = rip_enable_network_delete ((struct prefix *) &p);
else else
ret = rip_enable_if_delete (argv[2]->arg); ret = rip_enable_if_delete (argv[idx_ipv4_word]->arg);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "Can't find network configuration %s%s", argv[2]->arg, vty_out (vty, "Can't find network configuration %s%s", argv[idx_ipv4_word]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1281,10 +1283,11 @@ DEFUN (rip_neighbor,
"Specify a neighbor router\n" "Specify a neighbor router\n"
"Neighbor address\n") "Neighbor address\n")
{ {
int idx_ipv4 = 1;
int ret; int ret;
struct prefix_ipv4 p; struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[1]->arg, &p); ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p);
if (ret <= 0) if (ret <= 0)
{ {
@ -1305,10 +1308,11 @@ DEFUN (no_rip_neighbor,
"Specify a neighbor router\n" "Specify a neighbor router\n"
"Neighbor address\n") "Neighbor address\n")
{ {
int idx_ipv4 = 2;
int ret; int ret;
struct prefix_ipv4 p; struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[2]->arg, &p); ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p);
if (ret <= 0) if (ret <= 0)
{ {
@ -1331,6 +1335,7 @@ DEFUN (ip_rip_receive_version,
"RIP version 1\n" "RIP version 1\n"
"RIP version 2\n") "RIP version 2\n")
{ {
int idx_type = 4;
struct interface *ifp; struct interface *ifp;
struct rip_interface *ri; struct rip_interface *ri;
@ -1338,12 +1343,12 @@ DEFUN (ip_rip_receive_version,
ri = ifp->info; ri = ifp->info;
/* Version 1. */ /* Version 1. */
if (atoi (argv[4]->arg) == 1) if (atoi (argv[idx_type]->arg) == 1)
{ {
ri->ri_receive = RI_RIP_VERSION_1; ri->ri_receive = RI_RIP_VERSION_1;
return CMD_SUCCESS; return CMD_SUCCESS;
} }
if (atoi (argv[4]->arg) == 2) if (atoi (argv[idx_type]->arg) == 2)
{ {
ri->ri_receive = RI_RIP_VERSION_2; ri->ri_receive = RI_RIP_VERSION_2;
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1435,6 +1440,7 @@ DEFUN (ip_rip_send_version,
"RIP version 1\n" "RIP version 1\n"
"RIP version 2\n") "RIP version 2\n")
{ {
int idx_type = 4;
struct interface *ifp; struct interface *ifp;
struct rip_interface *ri; struct rip_interface *ri;
@ -1442,12 +1448,12 @@ DEFUN (ip_rip_send_version,
ri = ifp->info; ri = ifp->info;
/* Version 1. */ /* Version 1. */
if (atoi (argv[4]->arg) == 1) if (atoi (argv[idx_type]->arg) == 1)
{ {
ri->ri_send = RI_RIP_VERSION_1; ri->ri_send = RI_RIP_VERSION_1;
return CMD_SUCCESS; return CMD_SUCCESS;
} }
if (atoi (argv[4]->arg) == 2) if (atoi (argv[idx_type]->arg) == 2)
{ {
ri->ri_send = RI_RIP_VERSION_2; ri->ri_send = RI_RIP_VERSION_2;
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1553,6 +1559,7 @@ DEFUN (ip_rip_authentication_mode,
"Keyed message digest\n" "Keyed message digest\n"
"Clear text authentication\n") "Clear text authentication\n")
{ {
int idx_encryption = 4;
struct interface *ifp; struct interface *ifp;
struct rip_interface *ri; struct rip_interface *ri;
int auth_type; int auth_type;
@ -1566,9 +1573,9 @@ DEFUN (ip_rip_authentication_mode,
return CMD_WARNING; return CMD_WARNING;
} }
if (strncmp ("md5", argv[4]->arg, strlen (argv[4]->arg)) == 0) if (strncmp ("md5", argv[idx_encryption]->arg, strlen (argv[idx_encryption]->arg)) == 0)
auth_type = RIP_AUTH_MD5; auth_type = RIP_AUTH_MD5;
else if (strncmp ("text", argv[4]->arg, strlen (argv[4]->arg)) == 0) else if (strncmp ("text", argv[idx_encryption]->arg, strlen (argv[idx_encryption]->arg)) == 0)
auth_type = RIP_AUTH_SIMPLE_PASSWORD; auth_type = RIP_AUTH_SIMPLE_PASSWORD;
else else
{ {
@ -1657,13 +1664,14 @@ DEFUN (ip_rip_authentication_string,
"Authentication string\n" "Authentication string\n"
"Authentication string\n") "Authentication string\n")
{ {
int idx_line = 4;
struct interface *ifp; struct interface *ifp;
struct rip_interface *ri; struct rip_interface *ri;
ifp = (struct interface *)vty->index; ifp = (struct interface *)vty->index;
ri = ifp->info; ri = ifp->info;
if (strlen (argv[4]->arg) > 16) if (strlen (argv[idx_line]->arg) > 16)
{ {
vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s", vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s",
VTY_NEWLINE); VTY_NEWLINE);
@ -1679,7 +1687,7 @@ DEFUN (ip_rip_authentication_string,
if (ri->auth_str) if (ri->auth_str)
free (ri->auth_str); free (ri->auth_str);
ri->auth_str = strdup (argv[4]->arg); ri->auth_str = strdup (argv[idx_line]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1728,6 +1736,7 @@ DEFUN (ip_rip_authentication_key_chain,
"Authentication key-chain\n" "Authentication key-chain\n"
"name of key-chain\n") "name of key-chain\n")
{ {
int idx_line = 4;
struct interface *ifp; struct interface *ifp;
struct rip_interface *ri; struct rip_interface *ri;
@ -1744,7 +1753,7 @@ DEFUN (ip_rip_authentication_key_chain,
if (ri->key_chain) if (ri->key_chain)
free (ri->key_chain); free (ri->key_chain);
ri->key_chain = strdup (argv[4]->arg); ri->key_chain = strdup (argv[idx_line]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1878,7 +1887,8 @@ DEFUN (rip_passive_interface,
"Interface name\n" "Interface name\n"
"default for all interfaces\n") "default for all interfaces\n")
{ {
const char *ifname = argv[1]->arg; int idx_ifname = 1;
const char *ifname = argv[idx_ifname]->arg;
if (!strcmp(ifname,"default")) { if (!strcmp(ifname,"default")) {
passive_default = 1; passive_default = 1;
@ -1899,7 +1909,8 @@ DEFUN (no_rip_passive_interface,
"Interface name\n" "Interface name\n"
"default for all interfaces\n") "default for all interfaces\n")
{ {
const char *ifname = argv[2]->arg; int idx_ifname = 2;
const char *ifname = argv[idx_ifname]->arg;
if (!strcmp(ifname,"default")) { if (!strcmp(ifname,"default")) {
passive_default = 0; passive_default = 0;

View File

@ -289,7 +289,10 @@ DEFUN (rip_offset_list,
"For outgoing updates\n" "For outgoing updates\n"
"Metric value\n") "Metric value\n")
{ {
return rip_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, NULL); int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
} }
DEFUN (rip_offset_list_ifname, DEFUN (rip_offset_list_ifname,
@ -302,7 +305,11 @@ DEFUN (rip_offset_list_ifname,
"Metric value\n" "Metric value\n"
"Interface to match\n") "Interface to match\n")
{ {
return rip_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, argv[4]->arg); int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
int idx_ifname = 4;
return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
} }
DEFUN (no_rip_offset_list, DEFUN (no_rip_offset_list,
@ -315,7 +322,10 @@ DEFUN (no_rip_offset_list,
"For outgoing updates\n" "For outgoing updates\n"
"Metric value\n") "Metric value\n")
{ {
return rip_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL); int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
} }
DEFUN (no_rip_offset_list_ifname, DEFUN (no_rip_offset_list_ifname,
@ -329,7 +339,11 @@ DEFUN (no_rip_offset_list_ifname,
"Metric value\n" "Metric value\n"
"Interface to match\n") "Interface to match\n")
{ {
return rip_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg); int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
int idx_ifname = 5;
return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
} }
static int static int

View File

@ -742,7 +742,8 @@ DEFUN (match_metric,
"Match metric of route\n" "Match metric of route\n"
"Metric value\n") "Metric value\n")
{ {
return rip_route_match_add (vty, vty->index, "metric", argv[2]->arg); int idx_number = 2;
return rip_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg);
} }
/* /*
@ -772,7 +773,8 @@ DEFUN (match_interface,
"Match first hop interface of route\n" "Match first hop interface of route\n"
"Interface name\n") "Interface name\n")
{ {
return rip_route_match_add (vty, vty->index, "interface", argv[2]->arg); int idx_word = 2;
return rip_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg);
} }
/* /*
@ -805,7 +807,8 @@ DEFUN (match_ip_next_hop,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP Access-list name\n") "IP Access-list name\n")
{ {
return rip_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg); int idx_acl = 3;
return rip_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg);
} }
/* /*
@ -841,7 +844,8 @@ DEFUN (match_ip_next_hop_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[4]->arg); int idx_word = 4;
return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[idx_word]->arg);
} }
/* /*
@ -879,7 +883,8 @@ DEFUN (match_ip_address,
"IP Access-list name\n") "IP Access-list name\n")
{ {
return rip_route_match_add (vty, vty->index, "ip address", argv[3]->arg); int idx_acl = 3;
return rip_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg);
} }
/* /*
@ -915,7 +920,8 @@ DEFUN (match_ip_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[4]->arg); int idx_word = 4;
return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[idx_word]->arg);
} }
/* /*
@ -949,7 +955,8 @@ DEFUN (match_tag,
"Match tag of route\n" "Match tag of route\n"
"Metric value\n") "Metric value\n")
{ {
return rip_route_match_add (vty, vty->index, "tag", argv[2]->arg); int idx_number = 2;
return rip_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg);
} }
/* /*
@ -989,7 +996,8 @@ DEFUN (set_metric,
"Metric value for destination routing protocol\n" "Metric value for destination routing protocol\n"
"Metric value\n") "Metric value\n")
{ {
return rip_route_set_add (vty, vty->index, "metric", argv[2]->arg); int idx_number = 2;
return rip_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
} }
@ -1028,10 +1036,11 @@ DEFUN (set_ip_nexthop,
"Next hop address\n" "Next hop address\n"
"IP address of next hop\n") "IP address of next hop\n")
{ {
int idx_ipv4 = 3;
union sockunion su; union sockunion su;
int ret; int ret;
ret = str2sockunion (argv[3]->arg, &su); ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "%% Malformed next-hop address%s", VTY_NEWLINE); vty_out (vty, "%% Malformed next-hop address%s", VTY_NEWLINE);
@ -1045,7 +1054,7 @@ DEFUN (set_ip_nexthop,
return CMD_WARNING; return CMD_WARNING;
} }
return rip_route_set_add (vty, vty->index, "ip next-hop", argv[3]->arg); return rip_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg);
} }
/* /*
@ -1077,7 +1086,8 @@ DEFUN (set_tag,
"Tag value for routing protocol\n" "Tag value for routing protocol\n"
"Tag value\n") "Tag value\n")
{ {
return rip_route_set_add (vty, vty->index, "tag", argv[2]->arg); int idx_number = 2;
return rip_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
} }
/* /*

View File

@ -417,20 +417,22 @@ DEFUN (rip_redistribute_type_routemap,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_protocol = 1;
int idx_word = 3;
int i; int i;
for (i = 0; redist_type[i].str; i++) { for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[1]->arg, if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0) redist_type[i].str_min_len) == 0)
{ {
rip_routemap_set (redist_type[i].type, argv[3]->arg); rip_routemap_set (redist_type[i].type, argv[idx_word]->arg);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
redist_type[i].type, 0, VRF_DEFAULT); redist_type[i].type, 0, VRF_DEFAULT);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
} }
vty_out(vty, "Invalid type %s%s", argv[1]->arg, vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -445,21 +447,23 @@ DEFUN (no_rip_redistribute_type_routemap,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_protocol = 2;
int idx_word = 4;
int i; int i;
for (i = 0; redist_type[i].str; i++) for (i = 0; redist_type[i].str; i++)
{ {
if (strncmp(redist_type[i].str, argv[2]->arg, if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0) redist_type[i].str_min_len) == 0)
{ {
if (rip_routemap_unset (redist_type[i].type,argv[4]->arg)) if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg))
return CMD_WARNING; return CMD_WARNING;
rip_redistribute_unset (redist_type[i].type); rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
} }
vty_out(vty, "Invalid type %s%s", argv[2]->arg, vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -473,13 +477,15 @@ DEFUN (rip_redistribute_type_metric,
"Metric\n" "Metric\n"
"Metric value\n") "Metric value\n")
{ {
int idx_protocol = 1;
int idx_number = 3;
int i; int i;
int metric; int metric;
metric = atoi (argv[3]->arg); metric = atoi (argv[idx_number]->arg);
for (i = 0; redist_type[i].str; i++) { for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[1]->arg, if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0) redist_type[i].str_min_len) == 0)
{ {
rip_redistribute_metric_set (redist_type[i].type, metric); rip_redistribute_metric_set (redist_type[i].type, metric);
@ -489,7 +495,7 @@ DEFUN (rip_redistribute_type_metric,
} }
} }
vty_out(vty, "Invalid type %s%s", argv[1]->arg, vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -504,21 +510,23 @@ DEFUN (no_rip_redistribute_type_metric,
"Metric\n" "Metric\n"
"Metric value\n") "Metric value\n")
{ {
int idx_protocol = 2;
int idx_number = 4;
int i; int i;
for (i = 0; redist_type[i].str; i++) for (i = 0; redist_type[i].str; i++)
{ {
if (strncmp(redist_type[i].str, argv[2]->arg, if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0) redist_type[i].str_min_len) == 0)
{ {
if (rip_metric_unset (redist_type[i].type, atoi(argv[4]->arg))) if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
return CMD_WARNING; return CMD_WARNING;
rip_redistribute_unset (redist_type[i].type); rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
} }
vty_out(vty, "Invalid type %s%s", argv[2]->arg, vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -534,24 +542,27 @@ DEFUN (rip_redistribute_type_metric_routemap,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_protocol = 1;
int idx_number = 3;
int idx_word = 5;
int i; int i;
int metric; int metric;
metric = atoi (argv[3]->arg); metric = atoi (argv[idx_number]->arg);
for (i = 0; redist_type[i].str; i++) { for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[1]->arg, if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0) redist_type[i].str_min_len) == 0)
{ {
rip_redistribute_metric_set (redist_type[i].type, metric); rip_redistribute_metric_set (redist_type[i].type, metric);
rip_routemap_set (redist_type[i].type, argv[5]->arg); rip_routemap_set (redist_type[i].type, argv[idx_word]->arg);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
redist_type[i].type, 0, VRF_DEFAULT); redist_type[i].type, 0, VRF_DEFAULT);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
} }
vty_out(vty, "Invalid type %s%s", argv[1]->arg, vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -569,18 +580,21 @@ DEFUN (no_rip_redistribute_type_metric_routemap,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_protocol = 2;
int idx_number = 4;
int idx_word = 6;
int i; int i;
for (i = 0; redist_type[i].str; i++) for (i = 0; redist_type[i].str; i++)
{ {
if (strncmp(redist_type[i].str, argv[2]->arg, if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0) redist_type[i].str_min_len) == 0)
{ {
if (rip_metric_unset (redist_type[i].type, atoi(argv[4]->arg))) if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
return CMD_WARNING; return CMD_WARNING;
if (rip_routemap_unset (redist_type[i].type, argv[6]->arg)) if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg))
{ {
rip_redistribute_metric_set(redist_type[i].type, atoi(argv[4]->arg)); rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg));
return CMD_WARNING; return CMD_WARNING;
} }
rip_redistribute_unset (redist_type[i].type); rip_redistribute_unset (redist_type[i].type);
@ -588,7 +602,7 @@ DEFUN (no_rip_redistribute_type_metric_routemap,
} }
} }
vty_out(vty, "Invalid type %s%s", argv[2]->arg, vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;

View File

@ -2947,9 +2947,10 @@ DEFUN (rip_version,
"Set routing protocol version\n" "Set routing protocol version\n"
"version\n") "version\n")
{ {
int idx_number = 1;
int version; int version;
version = atoi (argv[1]->arg); version = atoi (argv[idx_number]->arg);
if (version != RIPv1 && version != RIPv2) if (version != RIPv1 && version != RIPv2)
{ {
vty_out (vty, "invalid rip version %d%s", version, vty_out (vty, "invalid rip version %d%s", version,
@ -2960,7 +2961,7 @@ DEFUN (rip_version,
rip->version_recv = version; rip->version_recv = version;
return CMD_SUCCESS; return CMD_SUCCESS;
} }
/* /*
* CHECK ME - The following ALIASes need to be implemented in this DEFUN * CHECK ME - The following ALIASes need to be implemented in this DEFUN
@ -2981,7 +2982,7 @@ DEFUN (no_rip_version,
rip->version_recv = RI_RIP_VERSION_1_AND_2; rip->version_recv = RI_RIP_VERSION_1_AND_2;
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (rip_route, DEFUN (rip_route,
@ -2990,11 +2991,12 @@ DEFUN (rip_route,
"RIP static route configuration\n" "RIP static route configuration\n"
"IP prefix <network>/<length>\n") "IP prefix <network>/<length>\n")
{ {
int idx_ipv4_prefixlen = 1;
int ret; int ret;
struct prefix_ipv4 p; struct prefix_ipv4 p;
struct route_node *node; struct route_node *node;
ret = str2prefix_ipv4 (argv[1]->arg, &p); ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "Malformed address%s", VTY_NEWLINE); vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -3026,11 +3028,12 @@ DEFUN (no_rip_route,
"RIP static route configuration\n" "RIP static route configuration\n"
"IP prefix <network>/<length>\n") "IP prefix <network>/<length>\n")
{ {
int idx_ipv4_prefixlen = 2;
int ret; int ret;
struct prefix_ipv4 p; struct prefix_ipv4 p;
struct route_node *node; struct route_node *node;
ret = str2prefix_ipv4 (argv[2]->arg, &p); ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "Malformed address%s", VTY_NEWLINE); vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -3042,7 +3045,7 @@ DEFUN (no_rip_route,
node = route_node_lookup (rip->route, (struct prefix *) &p); node = route_node_lookup (rip->route, (struct prefix *) &p);
if (! node) if (! node)
{ {
vty_out (vty, "Can't find route %s.%s", argv[2]->arg, vty_out (vty, "Can't find route %s.%s", argv[idx_ipv4_prefixlen]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -3079,9 +3082,10 @@ DEFUN (rip_default_metric,
"Set a metric of redistribute routes\n" "Set a metric of redistribute routes\n"
"Default metric\n") "Default metric\n")
{ {
int idx_number = 1;
if (rip) if (rip)
{ {
rip->default_metric = atoi (argv[1]->arg); rip->default_metric = atoi (argv[idx_number]->arg);
/* rip_update_default_metric (); */ /* rip_update_default_metric (); */
} }
return CMD_SUCCESS; return CMD_SUCCESS;
@ -3120,6 +3124,9 @@ DEFUN (rip_timers,
"Routing information timeout timer. Default is 180.\n" "Routing information timeout timer. Default is 180.\n"
"Garbage collection timer. Default is 120.\n") "Garbage collection timer. Default is 120.\n")
{ {
int idx_number = 2;
int idx_number_2 = 3;
int idx_number_3 = 4;
unsigned long update; unsigned long update;
unsigned long timeout; unsigned long timeout;
unsigned long garbage; unsigned long garbage;
@ -3127,21 +3134,21 @@ DEFUN (rip_timers,
unsigned long RIP_TIMER_MAX = 2147483647; unsigned long RIP_TIMER_MAX = 2147483647;
unsigned long RIP_TIMER_MIN = 5; unsigned long RIP_TIMER_MIN = 5;
update = strtoul (argv[2]->arg, &endptr, 10); update = strtoul (argv[idx_number]->arg, &endptr, 10);
if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN || *endptr != '\0') if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN || *endptr != '\0')
{ {
vty_out (vty, "update timer value error%s", VTY_NEWLINE); vty_out (vty, "update timer value error%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
timeout = strtoul (argv[3]->arg, &endptr, 10); timeout = strtoul (argv[idx_number_2]->arg, &endptr, 10);
if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN || *endptr != '\0') if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN || *endptr != '\0')
{ {
vty_out (vty, "timeout timer value error%s", VTY_NEWLINE); vty_out (vty, "timeout timer value error%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
garbage = strtoul (argv[4]->arg, &endptr, 10); garbage = strtoul (argv[idx_number_3]->arg, &endptr, 10);
if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN || *endptr != '\0') if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN || *endptr != '\0')
{ {
vty_out (vty, "garbage timer value error%s", VTY_NEWLINE); vty_out (vty, "garbage timer value error%s", VTY_NEWLINE);
@ -3392,7 +3399,8 @@ DEFUN (rip_distance,
"Administrative distance\n" "Administrative distance\n"
"Distance value\n") "Distance value\n")
{ {
rip->distance = atoi (argv[1]->arg); int idx_number = 1;
rip->distance = atoi (argv[idx_number]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -3414,7 +3422,9 @@ DEFUN (rip_distance_source,
"Distance value\n" "Distance value\n"
"IP source prefix\n") "IP source prefix\n")
{ {
rip_distance_set (vty, argv[1]->arg, argv[2]->arg, NULL); int idx_number = 1;
int idx_ipv4_prefixlen = 2;
rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -3426,7 +3436,9 @@ DEFUN (no_rip_distance_source,
"Distance value\n" "Distance value\n"
"IP source prefix\n") "IP source prefix\n")
{ {
rip_distance_unset (vty, argv[2]->arg, argv[3]->arg, NULL); int idx_number = 2;
int idx_ipv4_prefixlen = 3;
rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -3438,7 +3450,10 @@ DEFUN (rip_distance_source_access_list,
"IP source prefix\n" "IP source prefix\n"
"Access list name\n") "Access list name\n")
{ {
rip_distance_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg); int idx_number = 1;
int idx_ipv4_prefixlen = 2;
int idx_word = 3;
rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -3451,7 +3466,10 @@ DEFUN (no_rip_distance_source_access_list,
"IP source prefix\n" "IP source prefix\n"
"Access list name\n") "Access list name\n")
{ {
rip_distance_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg); int idx_number = 2;
int idx_ipv4_prefixlen = 3;
int idx_word = 4;
rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -98,10 +98,11 @@ DEFUN (debug_ripng_packet_direct,
"Debug option set for receive packet\n" "Debug option set for receive packet\n"
"Debug option set for send packet\n") "Debug option set for send packet\n")
{ {
int idx_recv_send = 3;
ripng_debug_packet |= RIPNG_DEBUG_PACKET; ripng_debug_packet |= RIPNG_DEBUG_PACKET;
if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
ripng_debug_packet |= RIPNG_DEBUG_SEND; ripng_debug_packet |= RIPNG_DEBUG_SEND;
if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
ripng_debug_packet |= RIPNG_DEBUG_RECV; ripng_debug_packet |= RIPNG_DEBUG_RECV;
return CMD_SUCCESS; return CMD_SUCCESS;
@ -152,14 +153,15 @@ DEFUN (no_debug_ripng_packet_direct,
"Debug option set for receive packet\n" "Debug option set for receive packet\n"
"Debug option set for send packet\n") "Debug option set for send packet\n")
{ {
if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0) int idx_recv_send = 4;
if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{ {
if (IS_RIPNG_DEBUG_RECV) if (IS_RIPNG_DEBUG_RECV)
ripng_debug_packet &= ~RIPNG_DEBUG_SEND; ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
else else
ripng_debug_packet = 0; ripng_debug_packet = 0;
} }
else if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0) else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{ {
if (IS_RIPNG_DEBUG_SEND) if (IS_RIPNG_DEBUG_SEND)
ripng_debug_packet &= ~RIPNG_DEBUG_RECV; ripng_debug_packet &= ~RIPNG_DEBUG_RECV;

View File

@ -953,20 +953,21 @@ DEFUN (ripng_network,
"RIPng enable on specified interface or network.\n" "RIPng enable on specified interface or network.\n"
"Interface or address") "Interface or address")
{ {
int idx_if_or_addr = 1;
int ret; int ret;
struct prefix p; struct prefix p;
ret = str2prefix (argv[1]->arg, &p); ret = str2prefix (argv[idx_if_or_addr]->arg, &p);
/* Given string is IPv6 network or interface name. */ /* Given string is IPv6 network or interface name. */
if (ret) if (ret)
ret = ripng_enable_network_add (&p); ret = ripng_enable_network_add (&p);
else else
ret = ripng_enable_if_add (argv[1]->arg); ret = ripng_enable_if_add (argv[idx_if_or_addr]->arg);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "There is same network configuration %s%s", argv[1]->arg, vty_out (vty, "There is same network configuration %s%s", argv[idx_if_or_addr]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -982,20 +983,21 @@ DEFUN (no_ripng_network,
"RIPng enable on specified interface or network.\n" "RIPng enable on specified interface or network.\n"
"Interface or address") "Interface or address")
{ {
int idx_if_or_addr = 2;
int ret; int ret;
struct prefix p; struct prefix p;
ret = str2prefix (argv[2]->arg, &p); ret = str2prefix (argv[idx_if_or_addr]->arg, &p);
/* Given string is interface name. */ /* Given string is interface name. */
if (ret) if (ret)
ret = ripng_enable_network_delete (&p); ret = ripng_enable_network_delete (&p);
else else
ret = ripng_enable_if_delete (argv[2]->arg); ret = ripng_enable_if_delete (argv[idx_if_or_addr]->arg);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "can't find network %s%s", argv[2]->arg, vty_out (vty, "can't find network %s%s", argv[idx_if_or_addr]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1073,7 +1075,8 @@ DEFUN (ripng_passive_interface,
"Suppress routing updates on an interface\n" "Suppress routing updates on an interface\n"
"Interface name\n") "Interface name\n")
{ {
return ripng_passive_interface_set (vty, argv[1]->arg); int idx_ifname = 1;
return ripng_passive_interface_set (vty, argv[idx_ifname]->arg);
} }
DEFUN (no_ripng_passive_interface, DEFUN (no_ripng_passive_interface,
@ -1083,7 +1086,8 @@ DEFUN (no_ripng_passive_interface,
"Suppress routing updates on an interface\n" "Suppress routing updates on an interface\n"
"Interface name\n") "Interface name\n")
{ {
return ripng_passive_interface_unset (vty, argv[2]->arg); int idx_ifname = 2;
return ripng_passive_interface_unset (vty, argv[idx_ifname]->arg);
} }
static struct ripng_interface * static struct ripng_interface *

View File

@ -297,7 +297,10 @@ DEFUN (ripng_offset_list,
"For outgoing updates\n" "For outgoing updates\n"
"Metric value\n") "Metric value\n")
{ {
return ripng_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, NULL); int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
} }
DEFUN (ripng_offset_list_ifname, DEFUN (ripng_offset_list_ifname,
@ -310,7 +313,11 @@ DEFUN (ripng_offset_list_ifname,
"Metric value\n" "Metric value\n"
"Interface to match\n") "Interface to match\n")
{ {
return ripng_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, argv[4]->arg); int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
int idx_ifname = 4;
return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
} }
DEFUN (no_ripng_offset_list, DEFUN (no_ripng_offset_list,
@ -323,7 +330,10 @@ DEFUN (no_ripng_offset_list,
"For outgoing updates\n" "For outgoing updates\n"
"Metric value\n") "Metric value\n")
{ {
return ripng_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL); int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
} }
DEFUN (no_ripng_offset_list_ifname, DEFUN (no_ripng_offset_list_ifname,
@ -337,7 +347,11 @@ DEFUN (no_ripng_offset_list_ifname,
"Metric value\n" "Metric value\n"
"Interface to match\n") "Interface to match\n")
{ {
return ripng_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg); int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
int idx_ifname = 5;
return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
} }
static int static int

View File

@ -507,7 +507,8 @@ DEFUN (match_metric,
"Match metric of route\n" "Match metric of route\n"
"Metric value\n") "Metric value\n")
{ {
return ripng_route_match_add (vty, vty->index, "metric", argv[2]->arg); int idx_number = 2;
return ripng_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg);
} }
/* /*
@ -537,7 +538,8 @@ DEFUN (match_interface,
"Match first hop interface of route\n" "Match first hop interface of route\n"
"Interface name\n") "Interface name\n")
{ {
return ripng_route_match_add (vty, vty->index, "interface", argv[2]->arg); int idx_word = 2;
return ripng_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg);
} }
/* /*
@ -567,7 +569,8 @@ DEFUN (match_tag,
"Match tag of route\n" "Match tag of route\n"
"Metric value\n") "Metric value\n")
{ {
return ripng_route_match_add (vty, vty->index, "tag", argv[2]->arg); int idx_number = 2;
return ripng_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg);
} }
/* /*
@ -599,7 +602,8 @@ DEFUN (set_metric,
"Metric value for destination routing protocol\n" "Metric value for destination routing protocol\n"
"Metric value\n") "Metric value\n")
{ {
return ripng_route_set_add (vty, vty->index, "metric", argv[2]->arg); int idx_number = 2;
return ripng_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
} }
/* /*
@ -631,10 +635,11 @@ DEFUN (set_ipv6_nexthop_local,
"IPv6 local address\n" "IPv6 local address\n"
"IPv6 address of next hop\n") "IPv6 address of next hop\n")
{ {
int idx_ipv6 = 4;
union sockunion su; union sockunion su;
int ret; int ret;
ret = str2sockunion (argv[4]->arg, &su); ret = str2sockunion (argv[idx_ipv6]->arg, &su);
if (ret < 0) if (ret < 0)
{ {
vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE); vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE);
@ -647,7 +652,7 @@ DEFUN (set_ipv6_nexthop_local,
return CMD_WARNING; return CMD_WARNING;
} }
return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[4]->arg); return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg);
} }
/* /*
@ -681,7 +686,8 @@ DEFUN (set_tag,
"Tag value for routing protocol\n" "Tag value for routing protocol\n"
"Tag value\n") "Tag value\n")
{ {
return ripng_route_set_add (vty, vty->index, "tag", argv[2]->arg); int idx_number = 2;
return ripng_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
} }
/* /*

View File

@ -400,15 +400,17 @@ DEFUN (ripng_redistribute_type_metric,
"Metric\n" "Metric\n"
"Metric value\n") "Metric value\n")
{ {
int idx_protocol = 1;
int idx_number = 3;
int type; int type;
int metric; int metric;
metric = atoi (argv[3]->arg); metric = atoi (argv[idx_number]->arg);
type = proto_redistnum(AFI_IP6, argv[1]->arg); type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
if (type < 0) if (type < 0)
{ {
vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE); vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -427,17 +429,19 @@ DEFUN (ripng_redistribute_type_routemap,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_protocol = 1;
int idx_word = 3;
int type; int type;
type = proto_redistnum(AFI_IP6, argv[1]->arg); type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
if (type < 0) if (type < 0)
{ {
vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE); vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
ripng_redistribute_routemap_set (type, argv[3]->arg); ripng_redistribute_routemap_set (type, argv[idx_word]->arg);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0,
VRF_DEFAULT); VRF_DEFAULT);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -454,20 +458,23 @@ DEFUN (ripng_redistribute_type_metric_routemap,
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int idx_protocol = 1;
int idx_number = 3;
int idx_word = 5;
int type; int type;
int metric; int metric;
type = proto_redistnum(AFI_IP6, argv[1]->arg); type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
metric = atoi (argv[3]->arg); metric = atoi (argv[idx_number]->arg);
if (type < 0) if (type < 0)
{ {
vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE); vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
ripng_redistribute_metric_set (type, metric); ripng_redistribute_metric_set (type, metric);
ripng_redistribute_routemap_set (type, argv[5]->arg); ripng_redistribute_routemap_set (type, argv[idx_word]->arg);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -2261,11 +2261,12 @@ DEFUN (ripng_route,
"Static route setup\n" "Static route setup\n"
"Set static RIPng route announcement\n") "Set static RIPng route announcement\n")
{ {
int idx_ipv6addr = 1;
int ret; int ret;
struct prefix_ipv6 p; struct prefix_ipv6 p;
struct route_node *rp; struct route_node *rp;
ret = str2prefix_ipv6 (argv[1]->arg, (struct prefix_ipv6 *)&p); ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p);
if (ret <= 0) if (ret <= 0)
{ {
vty_out (vty, "Malformed address%s", VTY_NEWLINE); vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -2294,11 +2295,12 @@ DEFUN (no_ripng_route,
"Static route setup\n" "Static route setup\n"
"Delete static RIPng route announcement\n") "Delete static RIPng route announcement\n")
{ {
int idx_ipv6addr = 2;
int ret; int ret;
struct prefix_ipv6 p; struct prefix_ipv6 p;
struct route_node *rp; struct route_node *rp;
ret = str2prefix_ipv6 (argv[2]->arg, (struct prefix_ipv6 *)&p); ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p);
if (ret <= 0) if (ret <= 0)
{ {
vty_out (vty, "Malformed address%s", VTY_NEWLINE); vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -2328,11 +2330,12 @@ DEFUN (ripng_aggregate_address,
"Set aggregate RIPng route announcement\n" "Set aggregate RIPng route announcement\n"
"Aggregate network\n") "Aggregate network\n")
{ {
int idx_ipv6_prefixlen = 1;
int ret; int ret;
struct prefix p; struct prefix p;
struct route_node *node; struct route_node *node;
ret = str2prefix_ipv6 (argv[1]->arg, (struct prefix_ipv6 *)&p); ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *)&p);
if (ret <= 0) if (ret <= 0)
{ {
vty_out (vty, "Malformed address%s", VTY_NEWLINE); vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -2361,11 +2364,12 @@ DEFUN (no_ripng_aggregate_address,
"Delete aggregate RIPng route announcement\n" "Delete aggregate RIPng route announcement\n"
"Aggregate network") "Aggregate network")
{ {
int idx_ipv6_prefixlen = 2;
int ret; int ret;
struct prefix p; struct prefix p;
struct route_node *rn; struct route_node *rn;
ret = str2prefix_ipv6 (argv[2]->arg, (struct prefix_ipv6 *) &p); ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *) &p);
if (ret <= 0) if (ret <= 0)
{ {
vty_out (vty, "Malformed address%s", VTY_NEWLINE); vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -2393,9 +2397,10 @@ DEFUN (ripng_default_metric,
"Set a metric of redistribute routes\n" "Set a metric of redistribute routes\n"
"Default metric\n") "Default metric\n")
{ {
int idx_number = 1;
if (ripng) if (ripng)
{ {
ripng->default_metric = atoi (argv[1]->arg); ripng->default_metric = atoi (argv[idx_number]->arg);
} }
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -2535,13 +2540,16 @@ DEFUN (ripng_timers,
"Routing information timeout timer. Default is 180.\n" "Routing information timeout timer. Default is 180.\n"
"Garbage collection timer. Default is 120.\n") "Garbage collection timer. Default is 120.\n")
{ {
int idx_number = 2;
int idx_number_2 = 3;
int idx_number_3 = 4;
unsigned long update; unsigned long update;
unsigned long timeout; unsigned long timeout;
unsigned long garbage; unsigned long garbage;
VTY_GET_INTEGER_RANGE("update timer", update, argv[2]->arg, 0, 65535); VTY_GET_INTEGER_RANGE("update timer", update, argv[idx_number]->arg, 0, 65535);
VTY_GET_INTEGER_RANGE("timeout timer", timeout, argv[3]->arg, 0, 65535); VTY_GET_INTEGER_RANGE("timeout timer", timeout, argv[idx_number_2]->arg, 0, 65535);
VTY_GET_INTEGER_RANGE("garbage timer", garbage, argv[4]->arg, 0, 65535); VTY_GET_INTEGER_RANGE("garbage timer", garbage, argv[idx_number_3]->arg, 0, 65535);
/* Set each timer value. */ /* Set each timer value. */
ripng->update_time = update; ripng->update_time = update;

View File

@ -4,6 +4,7 @@ import re
import sys import sys
import os import os
import subprocess import subprocess
from collections import OrderedDict
from copy import deepcopy from copy import deepcopy
from pprint import pformat, pprint from pprint import pformat, pprint
@ -156,7 +157,7 @@ def get_argv_translator(line_number, line):
return table return table
''' '''
def get_argv_variable_indexes(line_number, line): def get_command_string_variable_indexes(line_number, line):
indexes = {} indexes = {}
line = line.strip() line = line.strip()
@ -177,6 +178,359 @@ def get_argv_variable_indexes(line_number, line):
return (max_index, indexes) return (max_index, indexes)
def get_token_index_variable_name(line_number, token):
re_range = re.search('\(\d+-\d+\)', token)
if token.startswith('['):
assert token.endswith(']'), "Token %s should end with ]" % token
token = token[1:-1]
if token.startswith('<'):
assert token.endswith('>'), "Token %s should end with >" % token
token = token[1:-1]
if token == 'A.B.C.D':
return 'idx_ipv4'
elif token == 'A.B.C.D/M':
return 'idx_ipv4_prefixlen'
elif token == 'X:X::X:X':
return 'idx_ipv6'
elif token == 'X:X::X:X/M':
return 'idx_ipv6_prefixlen'
elif token == 'ASN:nn_or_IP-address:nn':
return 'idx_ext_community'
elif token == '.AA:NN':
return 'idx_community'
elif token == 'WORD':
return 'idx_word'
elif token == 'json':
return 'idx_json'
elif token == '.LINE':
return 'idx_regex'
elif token == 'A.B.C.D|INTERFACE':
return 'idx_ipv4_ifname'
elif token == 'A.B.C.D|INTERFACE|null0':
return 'idx_ipv4_ifname_null'
elif token == 'X:X::X:X|INTERFACE':
return 'idx_ipv6_ifname'
elif token == 'reject|blackhole':
return 'idx_reject_blackhole'
elif token == 'route-map NAME':
return 'idx_route_map'
elif token == 'recv|send|detail':
return 'idx_recv_send'
elif token == 'recv|send':
return 'idx_recv_send'
elif token == 'up|down':
return 'idx_up_down'
elif token == 'off-link':
return 'idx_off_link'
elif token == 'no-autoconfig':
return 'idx_no_autoconfig'
elif token == 'router-address':
return 'idx_router_address'
elif token == 'high|medium|low':
return 'idx_high_medium_low'
elif token == '(0-4294967295)|infinite':
return 'idx_number_infinite'
elif token == '(1-199)|(1300-2699)|WORD':
return 'idx_acl'
elif token == 'A.B.C.D|X:X::X:X':
return 'idx_ip'
elif token == 'in|out':
return 'idx_in_out'
elif token == 'deny|permit':
return 'idx_permit_deny'
elif token == 'view|vrf':
return 'idx_view_vrf'
elif token == 'unicast|multicast':
return 'idx_safi'
elif token == 'bestpath|multipath':
return 'idx_bestpath'
elif token == 'egp|igp|incomplete':
return 'idx_origin'
elif token == 'cisco|zebra' or token == 'cisco|ibm|shortcut|standard':
return 'idx_vendor'
elif token == 'as-set|no-as-set':
return 'idx_as_set'
elif token == 'confed|missing-as-worst':
return 'idx_med_knob'
elif token == 'both|send|receive' or token == 'send|recv':
return 'idx_send_recv'
elif token == 'both|extended|standard' or token == '1|2':
return 'idx_type'
elif token == 'A.B.C.D|WORD' or token == 'A.B.C.D/M|WORD':
return 'idx_ipv4_word'
elif token == 'advertise-queue|advertised-routes|packet-queue':
return 'idx_type'
elif token == 'ospf|table':
return 'idx_ospf_table'
elif token == 'as-path|next-hop|med' or token == 'next-hop|med' or token == 'as-path|med' or token == 'as-path|next-hop':
return 'idx_attribute'
elif token == '(1-4294967295)|external|internal' or token == '(1-4294967295)|internal|external':
return 'idx_remote_as'
elif token == '(1-500)|WORD' or token == '(1-99)|(100-500)|WORD':
return 'idx_comm_list'
elif token == 'ipv4|ipv6' or token == 'ip|ipv6':
return 'idx_afi'
elif token == 'md5|clear' or token == 'null|message-digest' or token == 'md5|text':
return 'idx_encryption'
elif token == 'IFNAME|default':
return 'idx_ifname'
elif token == 'type-1|type-2':
return 'idx_external'
elif token == 'table|intra-area|inter-area|memory':
return 'idx_type'
elif token == 'translate-candidate|translate-never|translate-always':
return 'idx_translate'
elif token == 'intra-area (1-255)|inter-area (1-255)|external (1-255)':
return 'idx_area_distance'
elif token == 'metric (0-16777214)|metric-type <1|2>|route-map WORD' or token == 'always|metric (0-16777214)|metric-type <1|2>|route-map WORD':
return 'idx_redist_param'
elif token == 'default|enable|disable' or token == 'enable|disable':
return 'idx_enable_disable'
elif token == 'unknown|hello|dbdesc|lsreq|lsupdate|lsack|all' or token == 'hello|dd|ls-request|ls-update|ls-ack|all':
return 'idx_packet'
elif token == 'router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown' or token == 'intra-area|inter-area|external-1|external-2' or token == 'router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix' or token == 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as':
return 'idx_lsa'
elif token == 'broadcast|point-to-point' or token == 'broadcast|non-broadcast|point-to-multipoint|point-to-point':
return 'idx_network'
elif token == 'A.B.C.D|(0-4294967295)':
return 'idx_ipv4_number'
elif token == 'narrow|transition|wide':
return 'idx_metric_style'
elif token == 'area-password|domain-password':
return 'idx_password'
elif token == 'param':
return 'idx_param'
elif token == 'advertised-routes|received-routes':
return 'idx_adv_rcvd_routes'
elif token == 'encap|multicast|unicast|vpn' or token == 'unicast|multicast|vpn|encap':
return 'idx_safi'
elif token == 'AA:NN|local-AS|no-advertise|no-export':
return 'idx_community'
elif token == 'all|all-et|updates|updates-et|routes-mrt':
return 'idx_dump_routes'
elif token == 'A.B.C.D|X:X::X:X|WORD':
return 'idx_peer'
elif token == 'A.B.C.D/M|X:X::X:X/M':
return 'idx_ipv4_ipv6_prefixlen'
elif token == 'level-1|level-2' or token == 'level-1|level-1-2|level-2-only':
return 'idx_level'
elif token == 'metric (0-16777215)|route-map WORD' or token == 'always|metric (0-16777215)|route-map WORD':
return 'idx_metric_rmap'
elif token == 'urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix':
return 'idx_rpf_lookup_mode'
elif token == 'hello|joins':
return 'idx_hello_join'
elif token == 'nocache|wrongvif|wholepkt':
return 'idx_type'
elif token in ('kernel|connected|static|rip|ospf|isis|pim|table',
'kernel|connected|static|ripng|ospf6|isis|table',
'kernel|connected|static|rip|isis|bgp|pim|table',
'kernel|connected|static|rip|ospf|isis|bgp|pim|table',
'kernel|connected|static|rip|ospf|isis|bgp|pim|table',
'kernel|connected|static|rip|ospf|isis|bgp|pim|table|any',
'kernel|connected|static|ripng|ospf6|isis|bgp|table|any',
'kernel|connected|static|ripng|ospf6|isis|bgp|table',
'kernel|connected|static|ospf6|isis|bgp|table',
'kernel|connected|static|ospf|isis|bgp|pim|table',
'kernel|connected|static|ripng|isis|bgp|table',
# '',
'bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static',
'kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table'):
return 'idx_protocol'
elif '|' in token:
raise Exception("%d: what variable name for %s" % (line_number, token))
elif re_range:
return 'idx_number'
elif token.upper() == token:
return 'idx_%s' % token.lower()
else:
raise Exception("%d: what variable name for %s" % (line_number, token))
def get_command_string_index_variable_table(line_number, line):
"""
Return a table that maps an index position to a variable name such as 'idx_ipv4'
"""
indexes = OrderedDict()
line = line.strip()
assert line.startswith('"'), "line does not start with \"\n%s" % (line)
assert line.endswith('",'), "line does not end with \",\n%s" % (line)
line = line[1:-2]
max_index = 0
for (token_index, token) in enumerate(line_to_tokens(line_number, line)):
if not token:
raise Exception("%d: empty token" % line_number)
if token_is_variable(line_number, token):
# print "%s is a token" % token
idx_variable_name = get_token_index_variable_name(line_number, token)
count = 0
for tmp in indexes.itervalues():
if tmp == idx_variable_name:
count += 1
elif re.search('^%s_\d+' % idx_variable_name, tmp):
count += 1
if count:
idx_variable_name = "%s_%d" % (idx_variable_name, count + 1)
indexes[token_index] = idx_variable_name
return indexes
def expand_command_string(line):
# in the middle
line = line.replace('" CMD_AS_RANGE "', '(1-4294967295)')
line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE "', '(1-5000)')
line = line.replace('" BGP_INSTANCE_CMD "', '<view|vrf> WORD')
line = line.replace('" BGP_INSTANCE_ALL_CMD "', '<view|vrf> all')
line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM) "', '(1-255)')
line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD "', '<kernel|connected|static|rip|ospf|isis|pim|table>')
line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD "', '<kernel|connected|static|ripng|ospf6|isis|table>')
line = line.replace('" OSPF_LSA_TYPES_CMD_STR "', 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as')
line = line.replace('" QUAGGA_REDIST_STR_OSPFD "', '<kernel|connected|static|rip|isis|bgp|pim|table>')
line = line.replace('" VRF_CMD_STR "', 'vrf NAME')
line = line.replace('" VRF_ALL_CMD_STR "', 'vrf all')
line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA "', '<kernel|connected|static|rip|ospf|isis|bgp|pim|table|any>')
line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA "', '<kernel|connected|static|ripng|ospf6|isis|bgp|table|any>')
line = line.replace('" QUAGGA_REDIST_STR_RIPNGD "', '<kernel|connected|static|ospf6|isis|bgp|table>')
line = line.replace('" QUAGGA_REDIST_STR_RIPD "', '<kernel|connected|static|ospf|isis|bgp|pim|table>')
line = line.replace('" QUAGGA_REDIST_STR_OSPF6D "', '<kernel|connected|static|ripng|isis|bgp|table>')
line = line.replace('" QUAGGA_REDIST_STR_ISISD "', '<kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table>')
line = line.replace('" LOG_FACILITIES "', '<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>')
# endswith
line = line.replace('" CMD_AS_RANGE,', ' (1-4294967295)",')
line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE,', ' (1-5000)",')
line = line.replace('" BGP_INSTANCE_CMD,', ' <view|vrf> WORD",')
line = line.replace('" BGP_INSTANCE_ALL_CMD,', ' <view|vrf> all",')
line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM),', '(1-255)",')
line = line.replace('" CMD_RANGE_STR(1, MAXTTL),', '(1-255)",')
line = line.replace('" BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,', '(2-255) (50-60000) (50-60000)",')
line = line.replace('" OSPF_LSA_TYPES_CMD_STR,',
' asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as",')
line = line.replace('" BGP_UPDATE_SOURCE_REQ_STR,', ' <A.B.C.D|X:X::X:X|WORD>",')
line = line.replace('" BGP_UPDATE_SOURCE_OPT_STR,', ' [A.B.C.D|X:X::X:X|WORD]",')
line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD,', ' <kernel|connected|static|rip|ospf|isis|pim|table>",')
line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD,', ' <kernel|connected|static|ripng|ospf6|isis|table>",')
line = line.replace('" QUAGGA_REDIST_STR_OSPFD,', ' <kernel|connected|static|rip|isis|bgp|pim|table>",')
line = line.replace('" VRF_CMD_STR,', ' vrf NAME",')
line = line.replace('" VRF_ALL_CMD_STR,', ' vrf all",')
line = line.replace('" QUAGGA_IP_REDIST_STR_ZEBRA,', ' <kernel|connected|static|rip|ospf|isis|bgp|pim|table>",')
line = line.replace('" QUAGGA_IP6_REDIST_STR_ZEBRA,', ' <kernel|connected|static|ripng|ospf6|isis|bgp|table>",')
line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA,', ' <kernel|connected|static|rip|ospf|isis|bgp|pim|table|any>",')
line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA,', ' <kernel|connected|static|ripng|ospf6|isis|bgp|table|any>",')
line = line.replace('" QUAGGA_REDIST_STR_RIPNGD,', ' <kernel|connected|static|ospf6|isis|bgp|table>",')
line = line.replace('" QUAGGA_REDIST_STR_RIPD,', ' <kernel|connected|static|ospf|isis|bgp|pim|table>",')
line = line.replace('" PIM_CMD_IP_MULTICAST_ROUTING,', ' ip multicast-routing",')
line = line.replace('" PIM_CMD_IP_IGMP_QUERY_INTERVAL,', ' ip igmp query-interval",')
line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,', ' ip igmp query-max-response-time-dsec",')
line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,', ' ip igmp query-max-response-time",')
line = line.replace('" QUAGGA_REDIST_STR_OSPF6D,', ' <kernel|connected|static|ripng|isis|bgp|table>",')
line = line.replace('" QUAGGA_REDIST_STR_ISISD,', ' <kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table>",')
line = line.replace('" LOG_FACILITIES,', ' <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",')
# startswith
line = line.replace('LISTEN_RANGE_CMD "', '"bgp listen range <A.B.C.D/M|X:X::X:X/M> ')
line = line.replace('NO_NEIGHBOR_CMD2 "', '"no neighbor <A.B.C.D|X:X::X:X|WORD> ')
line = line.replace('NEIGHBOR_CMD2 "', '"neighbor <A.B.C.D|X:X::X:X|WORD> ')
line = line.replace('NO_NEIGHBOR_CMD "', '"no neighbor <A.B.C.D|X:X::X:X> ')
line = line.replace('NEIGHBOR_CMD "', '"neighbor <A.B.C.D|X:X::X:X> ')
line = line.replace('PIM_CMD_NO "', '"no ')
line = line.replace('PIM_CMD_IP_IGMP_QUERY_INTERVAL "', '"ip igmp query-interval ')
line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "', '"ip igmp query-max-response-time ')
line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "', '"ip igmp query-max-response-time-dsec ')
# solo
line = line.replace('NO_NEIGHBOR_CMD2,', '"no neighbor <A.B.C.D|X:X::X:X|WORD>",')
line = line.replace('NEIGHBOR_CMD2,', '"neighbor <A.B.C.D|X:X::X:X|WORD>",')
line = line.replace('NO_NEIGHBOR_CMD,', '"no neighbor <A.B.C.D|X:X::X:X>",')
line = line.replace('NEIGHBOR_CMD,', '"neighbor <A.B.C.D|X:X::X:X>",')
line = line.replace('PIM_CMD_IP_MULTICAST_ROUTING,', '"ip multicast-routing",')
if line.rstrip().endswith('" ,'):
line = line.replace('" ,', '",')
return line
class DEFUN(object): class DEFUN(object):
def __init__(self, line_number, command_string_expanded, lines): def __init__(self, line_number, command_string_expanded, lines):
@ -216,14 +570,14 @@ DEFUN (no_bgp_maxmed_onstartup,
elif state == 'HELP': elif state == 'HELP':
if line.strip() == '{': if line.strip() == '{':
self.guts.append(line) # self.guts.append(line)
state = 'BODY' state = 'BODY'
else: else:
self.help_strings.append(line) self.help_strings.append(line)
elif state == 'BODY': elif state == 'BODY':
if line.rstrip() == '}': if line.rstrip() == '}':
self.guts.append(line) # self.guts.append(line)
state = None state = None
else: else:
self.guts.append(line) self.guts.append(line)
@ -239,7 +593,7 @@ DEFUN (no_bgp_maxmed_onstartup,
return self.name return self.name
def sanity_check(self): def sanity_check(self):
(max_index, variable_indexes) = get_argv_variable_indexes(self.line_number, self.command_string_expanded) (max_index, variable_indexes) = get_command_string_variable_indexes(self.line_number, self.command_string_expanded)
# sanity check that each argv index matches a variable in the command string # sanity check that each argv index matches a variable in the command string
for line in self.guts: for line in self.guts:
@ -256,7 +610,6 @@ DEFUN (no_bgp_maxmed_onstartup,
def get_new_command_string(self): def get_new_command_string(self):
line = self.command_string line = self.command_string
# dwalton
# Change <1-255> to (1-255) # Change <1-255> to (1-255)
# Change (foo|bar) to <foo|bar> # Change (foo|bar) to <foo|bar>
# Change {wazzup} to [wazzup]....there shouldn't be many of these # Change {wazzup} to [wazzup]....there shouldn't be many of these
@ -284,18 +637,68 @@ DEFUN (no_bgp_maxmed_onstartup,
line = re_space.group(1) + ' '.join(line.split()) + re_space.group(2) line = re_space.group(1) + ' '.join(line.split()) + re_space.group(2)
return line return line
def get_used_idx_variables(self, idx_table):
used = {}
# sanity check that each argv index matches a variable in the command string
for line in self.guts:
if 'argv[' in line and '->arg' in line:
tmp_line = deepcopy(line)
re_argv = re.search('^.*?argv\[(\w+)\]->arg(.*)$', tmp_line)
while re_argv:
index = re_argv.group(1)
if index.isdigit():
index = int(index)
if index in idx_table:
used[index] = idx_table[index]
else:
print "%d: could not find idx variable for %d" % (self.line_number, index)
else:
for (key, value) in idx_table.iteritems():
if value == index:
used[key] = value
break
tmp_line = re_argv.group(2)
re_argv = re.search('^.*?argv\[(\w+)\]->arg(.*)$', tmp_line)
return used
def dump(self): def dump(self):
new_command_string = self.get_new_command_string()
new_command_string_expanded = expand_command_string(new_command_string)
lines = [] lines = []
lines.append("DEFUN (%s,\n" % self.name) lines.append("DEFUN (%s,\n" % self.name)
lines.append(" %s,\n" % self.name_cmd) lines.append(" %s,\n" % self.name_cmd)
lines.append(self.get_new_command_string()) lines.append(new_command_string)
lines.extend(self.help_strings) lines.extend(self.help_strings)
lines.extend(self.guts) lines.append('{\n')
# only print the variables that will be used else we get a compile error
idx_table = get_command_string_index_variable_table(self.line_number, new_command_string_expanded)
idx_table_used = self.get_used_idx_variables(idx_table)
for index in sorted(idx_table_used.keys()):
idx_variable = idx_table_used[index]
lines.append(" int %s = %d;\n" % (idx_variable, index))
# sanity check that each argv index matches a variable in the command string
for line in self.guts:
if line.startswith(' int idx_'):
pass
elif 'argv[' in line and '->arg' in line:
for (index, idx_variable) in idx_table.iteritems():
line = line.replace("argv[%d]->arg" % index, "argv[%s]->arg" % idx_variable)
lines.append(line)
else:
lines.append(line)
lines.append('}\n')
return ''.join(lines) return ''.join(lines)
def update_argvs(filename): def update_argvs(filename):
lines = [] lines = []
@ -334,78 +737,7 @@ def update_argvs(filename):
state = 'DEFUN_BODY' state = 'DEFUN_BODY'
elif line_number == defun_line_number + 2: elif line_number == defun_line_number + 2:
line = expand_command_string(line)
# in the middle
line = line.replace('" CMD_AS_RANGE "', '<1-4294967295>')
line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE "', '<1-5000>')
line = line.replace('" BGP_INSTANCE_CMD "', '(view|vrf) WORD')
line = line.replace('" BGP_INSTANCE_ALL_CMD "', '(view|vrf) all')
line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM) "', '<1-255>')
line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD "', '(kernel|connected|static|rip|ospf|isis|pim|table)')
line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD "', '(kernel|connected|static|ripng|ospf6|isis|table)')
line = line.replace('" OSPF_LSA_TYPES_CMD_STR "', 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as')
line = line.replace('" QUAGGA_REDIST_STR_OSPFD "', '(kernel|connected|static|rip|isis|bgp|pim|table)')
line = line.replace('" VRF_CMD_STR "', 'vrf NAME')
line = line.replace('" VRF_ALL_CMD_STR "', 'vrf all')
line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA "', '(kernel|connected|static|rip|ospf|isis|bgp|pim|table|any)')
line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA "', '(kernel|connected|static|ripng|ospf6|isis|bgp|table|any)')
line = line.replace('" QUAGGA_REDIST_STR_RIPNGD "', '(kernel|connected|static|ospf6|isis|bgp|table)')
line = line.replace('" QUAGGA_REDIST_STR_RIPD "', '(kernel|connected|static|ospf|isis|bgp|pim|table)')
line = line.replace('" QUAGGA_REDIST_STR_OSPF6D "', '(kernel|connected|static|ripng|isis|bgp|table)')
line = line.replace('" QUAGGA_REDIST_STR_ISISD "', '(kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table)')
line = line.replace('" LOG_FACILITIES "', '(kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)')
# endswith
line = line.replace('" CMD_AS_RANGE,', ' <1-4294967295>",')
line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE,', ' <1-5000>",')
line = line.replace('" BGP_INSTANCE_CMD,', ' (view|vrf) WORD",')
line = line.replace('" BGP_INSTANCE_ALL_CMD,', ' (view|vrf) all",')
line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM),', '<1-255>",')
line = line.replace('" CMD_RANGE_STR(1, MAXTTL),', '<1-255>",')
line = line.replace('" BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,', '<2-255> <50-60000> <50-60000>",')
line = line.replace('" OSPF_LSA_TYPES_CMD_STR,',
' asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as",')
line = line.replace('" BGP_UPDATE_SOURCE_REQ_STR,', ' (A.B.C.D|X:X::X:X|WORD)",')
line = line.replace('" BGP_UPDATE_SOURCE_OPT_STR,', ' {A.B.C.D|X:X::X:X|WORD}",')
line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD,', ' (kernel|connected|static|rip|ospf|isis|pim|table)",')
line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD,', ' (kernel|connected|static|ripng|ospf6|isis|table)",')
line = line.replace('" QUAGGA_REDIST_STR_OSPFD,', ' (kernel|connected|static|rip|isis|bgp|pim|table)",')
line = line.replace('" VRF_CMD_STR,', ' vrf NAME",')
line = line.replace('" VRF_ALL_CMD_STR,', ' vrf all",')
line = line.replace('" QUAGGA_IP_REDIST_STR_ZEBRA,', ' (kernel|connected|static|rip|ospf|isis|bgp|pim|table)",')
line = line.replace('" QUAGGA_IP6_REDIST_STR_ZEBRA,', ' (kernel|connected|static|ripng|ospf6|isis|bgp|table)",')
line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA,', ' (kernel|connected|static|rip|ospf|isis|bgp|pim|table|any)",')
line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA,', ' (kernel|connected|static|ripng|ospf6|isis|bgp|table|any)",')
line = line.replace('" QUAGGA_REDIST_STR_RIPNGD,', ' (kernel|connected|static|ospf6|isis|bgp|table)",')
line = line.replace('" QUAGGA_REDIST_STR_RIPD,', ' (kernel|connected|static|ospf|isis|bgp|pim|table)",')
line = line.replace('" PIM_CMD_IP_MULTICAST_ROUTING,', ' ip multicast-routing",')
line = line.replace('" PIM_CMD_IP_IGMP_QUERY_INTERVAL,', ' ip igmp query-interval",')
line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,', ' ip igmp query-max-response-time-dsec",')
line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,', ' ip igmp query-max-response-time",')
line = line.replace('" QUAGGA_REDIST_STR_OSPF6D,', ' (kernel|connected|static|ripng|isis|bgp|table)",')
line = line.replace('" QUAGGA_REDIST_STR_ISISD,', ' (kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table)",')
line = line.replace('" LOG_FACILITIES,', ' (kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)",')
# startswith
line = line.replace('LISTEN_RANGE_CMD "', '"bgp listen range (A.B.C.D/M|X:X::X:X/M) ')
line = line.replace('NO_NEIGHBOR_CMD2 "', '"no neighbor (A.B.C.D|X:X::X:X|WORD) ')
line = line.replace('NEIGHBOR_CMD2 "', '"neighbor (A.B.C.D|X:X::X:X|WORD) ')
line = line.replace('NO_NEIGHBOR_CMD "', '"no neighbor (A.B.C.D|X:X::X:X) ')
line = line.replace('NEIGHBOR_CMD "', '"neighbor (A.B.C.D|X:X::X:X) ')
line = line.replace('PIM_CMD_NO "', '"no ')
line = line.replace('PIM_CMD_IP_IGMP_QUERY_INTERVAL "', '"ip igmp query-interval ')
line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "', '"ip igmp query-max-response-time ')
line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "', '"ip igmp query-max-response-time-dsec ')
# solo
line = line.replace('NO_NEIGHBOR_CMD2,', '"no neighbor (A.B.C.D|X:X::X:X|WORD)",')
line = line.replace('NEIGHBOR_CMD2,', '"neighbor (A.B.C.D|X:X::X:X|WORD)",')
line = line.replace('NO_NEIGHBOR_CMD,', '"no neighbor (A.B.C.D|X:X::X:X)",')
line = line.replace('NEIGHBOR_CMD,', '"neighbor (A.B.C.D|X:X::X:X)",')
line = line.replace('PIM_CMD_IP_MULTICAST_ROUTING,', '"ip multicast-routing",')
if line.rstrip().endswith('" ,'):
line = line.replace('" ,', '",')
command_string = line command_string = line
''' '''

View File

@ -130,12 +130,13 @@ DEFUN (debug_zebra_packet_direct,
"Debug option set for receive packet\n" "Debug option set for receive packet\n"
"Debug option set for send packet\n") "Debug option set for send packet\n")
{ {
int idx_recv_send = 3;
zebra_debug_packet = ZEBRA_DEBUG_PACKET; zebra_debug_packet = ZEBRA_DEBUG_PACKET;
if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
if (strncmp ("detail", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("detail", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -150,10 +151,11 @@ DEFUN (debug_zebra_packet_detail,
"Debug option set for send packet\n" "Debug option set for send packet\n"
"Debug option set detailed information\n") "Debug option set detailed information\n")
{ {
int idx_recv_send = 3;
zebra_debug_packet = ZEBRA_DEBUG_PACKET; zebra_debug_packet = ZEBRA_DEBUG_PACKET;
if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -180,9 +182,10 @@ DEFUN (debug_zebra_kernel_msgdump,
"Dump raw netlink messages received\n" "Dump raw netlink messages received\n"
"Dump raw netlink messages sent\n") "Dump raw netlink messages sent\n")
{ {
if (argv[4]->arg && strncmp(argv[4]->arg, "recv", strlen(argv[4]->arg)) == 0) int idx_recv_send = 4;
if (argv[idx_recv_send]->arg && strncmp(argv[idx_recv_send]->arg, "recv", strlen(argv[idx_recv_send]->arg)) == 0)
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
if (!argv[4]->arg || strncmp(argv[4]->arg, "send", strlen(argv[4]->arg)) == 0) if (!argv[idx_recv_send]->arg || strncmp(argv[idx_recv_send]->arg, "send", strlen(argv[idx_recv_send]->arg)) == 0)
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -267,9 +270,10 @@ DEFUN (no_debug_zebra_packet_direct,
"Debug option set for receive packet\n" "Debug option set for receive packet\n"
"Debug option set for send packet\n") "Debug option set for send packet\n")
{ {
if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0) int idx_recv_send = 4;
if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0) if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -296,9 +300,10 @@ DEFUN (no_debug_zebra_kernel_msgdump,
"Dump raw netlink messages received\n" "Dump raw netlink messages received\n"
"Dump raw netlink messages sent\n") "Dump raw netlink messages sent\n")
{ {
if (!argv[1] || (argv[5]->arg && strncmp(argv[5]->arg, "recv", strlen(argv[5]->arg)) == 0)) int idx_recv_send = 5;
if (!argv[1] || (argv[idx_recv_send]->arg && strncmp(argv[idx_recv_send]->arg, "recv", strlen(argv[idx_recv_send]->arg)) == 0))
UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
if (!argv[5]->arg || (argv[5]->arg && strncmp(argv[5]->arg, "send", strlen(argv[5]->arg)) == 0)) if (!argv[idx_recv_send]->arg || (argv[idx_recv_send]->arg && strncmp(argv[idx_recv_send]->arg, "send", strlen(argv[idx_recv_send]->arg)) == 0))
UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -1361,19 +1361,21 @@ DEFUN (show_interface_name_vrf,
"Interface name\n" "Interface name\n"
VRF_CMD_HELP_STR) VRF_CMD_HELP_STR)
{ {
int idx_ifname = 2;
int idx_name = 4;
struct interface *ifp; struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT; vrf_id_t vrf_id = VRF_DEFAULT;
interface_update_stats (); interface_update_stats ();
if (argc > 1) if (argc > 1)
VRF_GET_ID (vrf_id, argv[4]->arg); VRF_GET_ID (vrf_id, argv[idx_name]->arg);
/* Specified interface print. */ /* Specified interface print. */
ifp = if_lookup_by_name_vrf (argv[2]->arg, vrf_id); ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_id);
if (ifp == NULL) if (ifp == NULL)
{ {
vty_out (vty, "%% Can't find interface %s%s", argv[2]->arg, vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1399,6 +1401,7 @@ DEFUN (show_interface_name_vrf_all,
"Interface name\n" "Interface name\n"
VRF_ALL_CMD_HELP_STR) VRF_ALL_CMD_HELP_STR)
{ {
int idx_ifname = 2;
struct interface *ifp; struct interface *ifp;
vrf_iter_t iter; vrf_iter_t iter;
int found = 0; int found = 0;
@ -1409,7 +1412,7 @@ DEFUN (show_interface_name_vrf_all,
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
{ {
/* Specified interface print. */ /* Specified interface print. */
ifp = if_lookup_by_name_vrf (argv[2]->arg, vrf_iter2id (iter)); ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_iter2id (iter));
if (ifp) if (ifp)
{ {
if_dump_vty (vty, ifp); if_dump_vty (vty, ifp);
@ -1419,7 +1422,7 @@ DEFUN (show_interface_name_vrf_all,
if (!found) if (!found)
{ {
vty_out (vty, "%% Can't find interface %s%s", argv[2]->arg, VTY_NEWLINE); vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1678,11 +1681,12 @@ DEFUN (bandwidth_if,
"Set bandwidth informational parameter\n" "Set bandwidth informational parameter\n"
"Bandwidth in megabits\n") "Bandwidth in megabits\n")
{ {
int idx_number = 1;
struct interface *ifp; struct interface *ifp;
unsigned int bandwidth; unsigned int bandwidth;
ifp = (struct interface *) vty->index; ifp = (struct interface *) vty->index;
bandwidth = strtol(argv[1]->arg, NULL, 10); bandwidth = strtol(argv[idx_number]->arg, NULL, 10);
/* bandwidth range is <1-100000> */ /* bandwidth range is <1-100000> */
if (bandwidth < 1 || bandwidth > 100000) if (bandwidth < 1 || bandwidth > 100000)
@ -1844,11 +1848,12 @@ DEFUN (link_params_metric,
"Link metric for MPLS-TE purpose\n" "Link metric for MPLS-TE purpose\n"
"Metric value in decimal\n") "Metric value in decimal\n")
{ {
int idx_number = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
u_int32_t metric; u_int32_t metric;
VTY_GET_ULONG("metric", metric, argv[1]->arg); VTY_GET_ULONG("metric", metric, argv[idx_number]->arg);
/* Update TE metric if needed */ /* Update TE metric if needed */
link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE, metric); link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE, metric);
@ -1876,12 +1881,13 @@ DEFUN (link_params_maxbw,
"Maximum bandwidth that can be used\n" "Maximum bandwidth that can be used\n"
"Bytes/second (IEEE floating point format)\n") "Bytes/second (IEEE floating point format)\n")
{ {
int idx_bandwidth = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
float bw; float bw;
if (sscanf (argv[1]->arg, "%g", &bw) != 1) if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{ {
vty_out (vty, "link_params_maxbw: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_maxbw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1920,11 +1926,12 @@ DEFUN (link_params_max_rsv_bw,
"Maximum bandwidth that may be reserved\n" "Maximum bandwidth that may be reserved\n"
"Bytes/second (IEEE floating point format)\n") "Bytes/second (IEEE floating point format)\n")
{ {
int idx_bandwidth = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
float bw; float bw;
if (sscanf (argv[1]->arg, "%g", &bw) != 1) if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{ {
vty_out (vty, "link_params_max_rsv_bw: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_max_rsv_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1953,20 +1960,22 @@ DEFUN (link_params_unrsv_bw,
"Priority\n" "Priority\n"
"Bytes/second (IEEE floating point format)\n") "Bytes/second (IEEE floating point format)\n")
{ {
int idx_number = 1;
int idx_bandwidth = 2;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
int priority; int priority;
float bw; float bw;
/* We don't have to consider about range check here. */ /* We don't have to consider about range check here. */
if (sscanf (argv[1]->arg, "%d", &priority) != 1) if (sscanf (argv[idx_number]->arg, "%d", &priority) != 1)
{ {
vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
if (sscanf (argv[2]->arg, "%g", &bw) != 1) if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{ {
vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -1994,11 +2003,12 @@ DEFUN (link_params_admin_grp,
"Administrative group membership\n" "Administrative group membership\n"
"32-bit Hexadecimal value (e.g. 0xa1)\n") "32-bit Hexadecimal value (e.g. 0xa1)\n")
{ {
int idx_bitpattern = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
unsigned long value; unsigned long value;
if (sscanf (argv[1]->arg, "0x%lx", &value) != 1) if (sscanf (argv[idx_bitpattern]->arg, "0x%lx", &value) != 1)
{ {
vty_out (vty, "link_params_admin_grp: fscanf: %s%s", vty_out (vty, "link_params_admin_grp: fscanf: %s%s",
safe_strerror (errno), VTY_NEWLINE); safe_strerror (errno), VTY_NEWLINE);
@ -2034,19 +2044,21 @@ DEFUN (link_params_inter_as,
"Remote AS number\n" "Remote AS number\n"
"AS number in the range <1-4294967295>\n") "AS number in the range <1-4294967295>\n")
{ {
int idx_ipv4 = 1;
int idx_number = 3;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
struct in_addr addr; struct in_addr addr;
u_int32_t as; u_int32_t as;
if (!inet_aton (argv[1]->arg, &addr)) if (!inet_aton (argv[idx_ipv4]->arg, &addr))
{ {
vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
VTY_GET_ULONG("AS number", as, argv[3]->arg); VTY_GET_ULONG("AS number", as, argv[idx_number]->arg);
/* Update Remote IP and Remote AS fields if needed */ /* Update Remote IP and Remote AS fields if needed */
if (IS_PARAM_UNSET(iflp, LP_RMT_AS) if (IS_PARAM_UNSET(iflp, LP_RMT_AS)
@ -2105,6 +2117,7 @@ DEFUN (link_params_delay,
"Unidirectional Average Link Delay\n" "Unidirectional Average Link Delay\n"
"Average delay in micro-second as decimal (0...16777215)\n") "Average delay in micro-second as decimal (0...16777215)\n")
{ {
int idx_number = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
@ -2112,7 +2125,7 @@ DEFUN (link_params_delay,
u_int8_t update = 0; u_int8_t update = 0;
/* Get and Check new delay values */ /* Get and Check new delay values */
VTY_GET_ULONG("delay", delay, argv[1]->arg); VTY_GET_ULONG("delay", delay, argv[idx_number]->arg);
switch (argc) switch (argc)
{ {
case 1: case 1:
@ -2212,11 +2225,12 @@ DEFUN (link_params_delay_var,
"Unidirectional Link Delay Variation\n" "Unidirectional Link Delay Variation\n"
"delay variation in micro-second as decimal (0...16777215)\n") "delay variation in micro-second as decimal (0...16777215)\n")
{ {
int idx_number = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
u_int32_t value; u_int32_t value;
VTY_GET_ULONG("delay variation", value, argv[1]->arg); VTY_GET_ULONG("delay variation", value, argv[idx_number]->arg);
/* Update Delay Variation if needed */ /* Update Delay Variation if needed */
link_param_cmd_set_uint32 (ifp, &iflp->delay_var, LP_DELAY_VAR, value); link_param_cmd_set_uint32 (ifp, &iflp->delay_var, LP_DELAY_VAR, value);
@ -2244,11 +2258,12 @@ DEFUN (link_params_pkt_loss,
"Unidirectional Link Packet Loss\n" "Unidirectional Link Packet Loss\n"
"percentage of total traffic by 0.000003% step and less than 50.331642%\n") "percentage of total traffic by 0.000003% step and less than 50.331642%\n")
{ {
int idx_percentage = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
float fval; float fval;
if (sscanf (argv[1]->arg, "%g", &fval) != 1) if (sscanf (argv[idx_percentage]->arg, "%g", &fval) != 1)
{ {
vty_out (vty, "link_params_pkt_loss: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_pkt_loss: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -2284,11 +2299,12 @@ DEFUN (link_params_res_bw,
"Unidirectional Residual Bandwidth\n" "Unidirectional Residual Bandwidth\n"
"Bytes/second (IEEE floating point format)\n") "Bytes/second (IEEE floating point format)\n")
{ {
int idx_bandwidth = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
float bw; float bw;
if (sscanf (argv[1]->arg, "%g", &bw) != 1) if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{ {
vty_out (vty, "link_params_res_bw: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_res_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -2330,11 +2346,12 @@ DEFUN (link_params_ava_bw,
"Unidirectional Available Bandwidth\n" "Unidirectional Available Bandwidth\n"
"Bytes/second (IEEE floating point format)\n") "Bytes/second (IEEE floating point format)\n")
{ {
int idx_bandwidth = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
float bw; float bw;
if (sscanf (argv[1]->arg, "%g", &bw) != 1) if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{ {
vty_out (vty, "link_params_ava_bw: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_ava_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -2376,11 +2393,12 @@ DEFUN (link_params_use_bw,
"Unidirectional Utilised Bandwidth\n" "Unidirectional Utilised Bandwidth\n"
"Bytes/second (IEEE floating point format)\n") "Bytes/second (IEEE floating point format)\n")
{ {
int idx_bandwidth = 1;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct if_link_params *iflp = if_link_params_get (ifp); struct if_link_params *iflp = if_link_params_get (ifp);
float bw; float bw;
if (sscanf (argv[1]->arg, "%g", &bw) != 1) if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1)
{ {
vty_out (vty, "link_params_use_bw: fscanf: %s%s", safe_strerror (errno), vty_out (vty, "link_params_use_bw: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE); VTY_NEWLINE);
@ -2564,7 +2582,8 @@ DEFUN (ip_address,
"Set the IP address of an interface\n" "Set the IP address of an interface\n"
"IP address (e.g. 10.0.0.1/8)\n") "IP address (e.g. 10.0.0.1/8)\n")
{ {
return ip_address_install (vty, vty->index, argv[2]->arg, NULL, NULL); int idx_ipv4_prefixlen = 2;
return ip_address_install (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, NULL);
} }
DEFUN (no_ip_address, DEFUN (no_ip_address,
@ -2575,7 +2594,8 @@ DEFUN (no_ip_address,
"Set the IP address of an interface\n" "Set the IP address of an interface\n"
"IP Address (e.g. 10.0.0.1/8)") "IP Address (e.g. 10.0.0.1/8)")
{ {
return ip_address_uninstall (vty, vty->index, argv[3]->arg, NULL, NULL); int idx_ipv4_prefixlen = 3;
return ip_address_uninstall (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, NULL);
} }
@ -2589,7 +2609,9 @@ DEFUN (ip_address_label,
"Label of this address\n" "Label of this address\n"
"Label\n") "Label\n")
{ {
return ip_address_install (vty, vty->index, argv[2]->arg, NULL, argv[4]->arg); int idx_ipv4_prefixlen = 2;
int idx_line = 4;
return ip_address_install (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg);
} }
DEFUN (no_ip_address_label, DEFUN (no_ip_address_label,
@ -2602,7 +2624,9 @@ DEFUN (no_ip_address_label,
"Label of this address\n" "Label of this address\n"
"Label\n") "Label\n")
{ {
return ip_address_uninstall (vty, vty->index, argv[3]->arg, NULL, argv[5]->arg); int idx_ipv4_prefixlen = 3;
int idx_line = 5;
return ip_address_uninstall (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg);
} }
#endif /* HAVE_NETLINK */ #endif /* HAVE_NETLINK */
@ -2765,7 +2789,8 @@ DEFUN (ipv6_address,
"Set the IP address of an interface\n" "Set the IP address of an interface\n"
"IPv6 address (e.g. 3ffe:506::1/48)\n") "IPv6 address (e.g. 3ffe:506::1/48)\n")
{ {
return ipv6_address_install (vty, vty->index, argv[2]->arg, NULL, NULL, 0); int idx_ipv6_prefixlen = 2;
return ipv6_address_install (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0);
} }
DEFUN (no_ipv6_address, DEFUN (no_ipv6_address,
@ -2776,7 +2801,8 @@ DEFUN (no_ipv6_address,
"Set the IP address of an interface\n" "Set the IP address of an interface\n"
"IPv6 address (e.g. 3ffe:506::1/48)\n") "IPv6 address (e.g. 3ffe:506::1/48)\n")
{ {
return ipv6_address_uninstall (vty, vty->index, argv[3]->arg, NULL, NULL, 0); int idx_ipv6_prefixlen = 3;
return ipv6_address_uninstall (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0);
} }
#endif /* HAVE_IPV6 */ #endif /* HAVE_IPV6 */

View File

@ -469,6 +469,7 @@ DEFUN (ip_irdp_holdtime,
"Set holdtime value\n" "Set holdtime value\n"
"Holdtime value in seconds. Default is 1800 seconds\n") "Holdtime value in seconds. Default is 1800 seconds\n")
{ {
int idx_number = 3;
struct interface *ifp; struct interface *ifp;
struct zebra_if *zi; struct zebra_if *zi;
struct irdp_interface *irdp; struct irdp_interface *irdp;
@ -480,7 +481,7 @@ DEFUN (ip_irdp_holdtime,
zi=ifp->info; zi=ifp->info;
irdp=&zi->irdp; irdp=&zi->irdp;
irdp->Lifetime = atoi(argv[3]->arg); irdp->Lifetime = atoi(argv[idx_number]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -492,6 +493,7 @@ DEFUN (ip_irdp_minadvertinterval,
"Set minimum time between advertisement\n" "Set minimum time between advertisement\n"
"Minimum advertisement interval in seconds\n") "Minimum advertisement interval in seconds\n")
{ {
int idx_number = 3;
struct interface *ifp; struct interface *ifp;
struct zebra_if *zi; struct zebra_if *zi;
struct irdp_interface *irdp; struct irdp_interface *irdp;
@ -503,8 +505,8 @@ DEFUN (ip_irdp_minadvertinterval,
zi=ifp->info; zi=ifp->info;
irdp=&zi->irdp; irdp=&zi->irdp;
if( (unsigned) atoi(argv[3]->arg) <= irdp->MaxAdvertInterval) { if( (unsigned) atoi(argv[idx_number]->arg) <= irdp->MaxAdvertInterval) {
irdp->MinAdvertInterval = atoi(argv[3]->arg); irdp->MinAdvertInterval = atoi(argv[idx_number]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -525,6 +527,7 @@ DEFUN (ip_irdp_maxadvertinterval,
"Set maximum time between advertisement\n" "Set maximum time between advertisement\n"
"Maximum advertisement interval in seconds\n") "Maximum advertisement interval in seconds\n")
{ {
int idx_number = 3;
struct interface *ifp; struct interface *ifp;
struct zebra_if *zi; struct zebra_if *zi;
struct irdp_interface *irdp; struct irdp_interface *irdp;
@ -537,8 +540,8 @@ DEFUN (ip_irdp_maxadvertinterval,
irdp=&zi->irdp; irdp=&zi->irdp;
if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[3]->arg) ) { if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[idx_number]->arg) ) {
irdp->MaxAdvertInterval = atoi(argv[3]->arg); irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -564,6 +567,7 @@ DEFUN (ip_irdp_preference,
"Set default preference level for this interface\n" "Set default preference level for this interface\n"
"Preference level\n") "Preference level\n")
{ {
int idx_number = 3;
struct interface *ifp; struct interface *ifp;
struct zebra_if *zi; struct zebra_if *zi;
struct irdp_interface *irdp; struct irdp_interface *irdp;
@ -575,7 +579,7 @@ DEFUN (ip_irdp_preference,
zi=ifp->info; zi=ifp->info;
irdp=&zi->irdp; irdp=&zi->irdp;
irdp->Preference = atoi(argv[3]->arg); irdp->Preference = atoi(argv[idx_number]->arg);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -588,6 +592,8 @@ DEFUN (ip_irdp_address_preference,
"Set IRDP address for advertise\n" "Set IRDP address for advertise\n"
"Preference level\n") "Preference level\n")
{ {
int idx_ipv4 = 3;
int idx_number = 5;
struct listnode *node; struct listnode *node;
struct in_addr ip; struct in_addr ip;
int pref; int pref;
@ -605,10 +611,10 @@ DEFUN (ip_irdp_address_preference,
zi=ifp->info; zi=ifp->info;
irdp=&zi->irdp; irdp=&zi->irdp;
ret = inet_aton(argv[3]->arg, &ip); ret = inet_aton(argv[idx_ipv4]->arg, &ip);
if(!ret) return CMD_WARNING; if(!ret) return CMD_WARNING;
pref = atoi(argv[5]->arg); pref = atoi(argv[idx_number]->arg);
for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv)) for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
if(adv->ip.s_addr == ip.s_addr) if(adv->ip.s_addr == ip.s_addr)
@ -633,6 +639,7 @@ DEFUN (no_ip_irdp_address_preference,
"Select IRDP address\n" "Select IRDP address\n"
"Old preference level\n") "Old preference level\n")
{ {
int idx_ipv4 = 4;
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct in_addr ip; struct in_addr ip;
int ret; int ret;
@ -649,7 +656,7 @@ DEFUN (no_ip_irdp_address_preference,
zi=ifp->info; zi=ifp->info;
irdp=&zi->irdp; irdp=&zi->irdp;
ret = inet_aton(argv[4]->arg, &ip); ret = inet_aton(argv[idx_ipv4]->arg, &ip);
if (!ret) if (!ret)
return CMD_WARNING; return CMD_WARNING;

View File

@ -228,10 +228,11 @@ DEFUN (router_id,
"Manually set the router-id\n" "Manually set the router-id\n"
"IP address to use for router-id\n") "IP address to use for router-id\n")
{ {
int idx_ipv4 = 1;
struct prefix rid; struct prefix rid;
vrf_id_t vrf_id = VRF_DEFAULT; vrf_id_t vrf_id = VRF_DEFAULT;
rid.u.prefix4.s_addr = inet_addr (argv[1]->arg); rid.u.prefix4.s_addr = inet_addr (argv[idx_ipv4]->arg);
if (!rid.u.prefix4.s_addr) if (!rid.u.prefix4.s_addr)
return CMD_WARNING; return CMD_WARNING;

View File

@ -923,6 +923,7 @@ DEFUN (ipv6_nd_ra_interval_msec,
"Router Advertisement interval\n" "Router Advertisement interval\n"
"Router Advertisement interval in milliseconds\n") "Router Advertisement interval in milliseconds\n")
{ {
int idx_number = 4;
unsigned interval; unsigned interval;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct zebra_if *zif = ifp->info; struct zebra_if *zif = ifp->info;
@ -930,7 +931,7 @@ DEFUN (ipv6_nd_ra_interval_msec,
struct zebra_ns *zns; struct zebra_ns *zns;
zns = zvrf->zns; zns = zvrf->zns;
VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[4]->arg, 70, 1800000); VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[idx_number]->arg, 70, 1800000);
if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime * 1000)) if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime * 1000))
{ {
vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE);
@ -958,6 +959,7 @@ DEFUN (ipv6_nd_ra_interval,
"Router Advertisement interval\n" "Router Advertisement interval\n"
"Router Advertisement interval in seconds\n") "Router Advertisement interval in seconds\n")
{ {
int idx_number = 3;
unsigned interval; unsigned interval;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct zebra_if *zif = ifp->info; struct zebra_if *zif = ifp->info;
@ -965,7 +967,7 @@ DEFUN (ipv6_nd_ra_interval,
struct zebra_ns *zns; struct zebra_ns *zns;
zns = zvrf->zns; zns = zvrf->zns;
VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[3]->arg, 1, 1800); VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[idx_number]->arg, 1, 1800);
if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime)) if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime))
{ {
vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE);
@ -1039,6 +1041,7 @@ DEFUN (ipv6_nd_ra_lifetime,
"Router lifetime\n" "Router lifetime\n"
"Router lifetime in seconds (0 stands for a non-default gw)\n") "Router lifetime in seconds (0 stands for a non-default gw)\n")
{ {
int idx_number = 3;
int lifetime; int lifetime;
struct interface *ifp; struct interface *ifp;
struct zebra_if *zif; struct zebra_if *zif;
@ -1046,7 +1049,7 @@ DEFUN (ipv6_nd_ra_lifetime,
ifp = (struct interface *) vty->index; ifp = (struct interface *) vty->index;
zif = ifp->info; zif = ifp->info;
VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[3]->arg, 0, 9000); VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[idx_number]->arg, 0, 9000);
/* The value to be placed in the Router Lifetime field /* The value to be placed in the Router Lifetime field
* of Router Advertisements sent from the interface, * of Router Advertisements sent from the interface,
@ -1101,9 +1104,10 @@ DEFUN (ipv6_nd_reachable_time,
"Reachable time\n" "Reachable time\n"
"Reachable time in milliseconds\n") "Reachable time in milliseconds\n")
{ {
int idx_number = 3;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct zebra_if *zif = ifp->info; struct zebra_if *zif = ifp->info;
VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[3]->arg, 1, RTADV_MAX_REACHABLE_TIME); VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[idx_number]->arg, 1, RTADV_MAX_REACHABLE_TIME);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1145,9 +1149,10 @@ DEFUN (ipv6_nd_homeagent_preference,
"Home Agent preference\n" "Home Agent preference\n"
"preference value (default is 0, least preferred)\n") "preference value (default is 0, least preferred)\n")
{ {
int idx_number = 3;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct zebra_if *zif = ifp->info; struct zebra_if *zif = ifp->info;
VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[3]->arg, 0, 65535); VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[idx_number]->arg, 0, 65535);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1189,9 +1194,10 @@ DEFUN (ipv6_nd_homeagent_lifetime,
"Home Agent lifetime\n" "Home Agent lifetime\n"
"Home Agent lifetime in seconds (0 to track ra-lifetime)\n") "Home Agent lifetime in seconds (0 to track ra-lifetime)\n")
{ {
int idx_number = 3;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct zebra_if *zif = ifp->info; struct zebra_if *zif = ifp->info;
VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[3]->arg, 0, RTADV_MAX_HALIFETIME); VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[idx_number]->arg, 0, RTADV_MAX_HALIFETIME);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -1508,7 +1514,7 @@ DEFUN (no_ipv6_nd_other_config_flag,
*/ */
DEFUN (ipv6_nd_prefix, DEFUN (ipv6_nd_prefix,
ipv6_nd_prefix_cmd, ipv6_nd_prefix_cmd,
"ipv6 nd prefix X:X::X:X/M <(0-4294967295)|infinite> <(0-4294967295)|infinite> <off-link|> <no-autoconfig|> <router-address|>", "ipv6 nd prefix X:X::X:X/M <(0-4294967295)|infinite> <(0-4294967295)|infinite> <off-link> <no-autoconfig> <router-address>",
"Interface IPv6 config commands\n" "Interface IPv6 config commands\n"
"Neighbor discovery\n" "Neighbor discovery\n"
"Prefix information\n" "Prefix information\n"
@ -1521,6 +1527,9 @@ DEFUN (ipv6_nd_prefix,
"Do not use prefix for autoconfiguration\n" "Do not use prefix for autoconfiguration\n"
"Set Router Address flag\n") "Set Router Address flag\n")
{ {
int idx_ipv6_prefixlen = 3;
int idx_number_infinite = 4;
int idx_number_infinite_2 = 5;
int i; int i;
int ret; int ret;
int cursor = 1; int cursor = 1;
@ -1531,7 +1540,7 @@ DEFUN (ipv6_nd_prefix,
ifp = (struct interface *) vty->index; ifp = (struct interface *) vty->index;
zebra_if = ifp->info; zebra_if = ifp->info;
ret = str2prefix_ipv6 (argv[3]->arg, &rp.prefix); ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, &rp.prefix);
if (!ret) if (!ret)
{ {
vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
@ -1546,19 +1555,19 @@ DEFUN (ipv6_nd_prefix,
if (argc > 1) if (argc > 1)
{ {
if ((isdigit((unsigned char)argv[4]->arg[0])) if ((isdigit((unsigned char)argv[idx_number_infinite]->arg[0]))
|| strncmp (argv[4]->arg, "i", 1) == 0) || strncmp (argv[idx_number_infinite]->arg, "i", 1) == 0)
{ {
if ( strncmp (argv[4]->arg, "i", 1) == 0) if ( strncmp (argv[idx_number_infinite]->arg, "i", 1) == 0)
rp.AdvValidLifetime = UINT32_MAX; rp.AdvValidLifetime = UINT32_MAX;
else else
rp.AdvValidLifetime = (u_int32_t) strtoll (argv[4]->arg, rp.AdvValidLifetime = (u_int32_t) strtoll (argv[idx_number_infinite]->arg,
(char **)NULL, 10); (char **)NULL, 10);
if ( strncmp (argv[5]->arg, "i", 1) == 0) if ( strncmp (argv[idx_number_infinite_2]->arg, "i", 1) == 0)
rp.AdvPreferredLifetime = UINT32_MAX; rp.AdvPreferredLifetime = UINT32_MAX;
else else
rp.AdvPreferredLifetime = (u_int32_t) strtoll (argv[5]->arg, rp.AdvPreferredLifetime = (u_int32_t) strtoll (argv[idx_number_infinite_2]->arg,
(char **)NULL, 10); (char **)NULL, 10);
if (rp.AdvPreferredLifetime > rp.AdvValidLifetime) if (rp.AdvPreferredLifetime > rp.AdvValidLifetime)
@ -1790,6 +1799,7 @@ DEFUN (ipv6_nd_router_preference,
"Low default router preference\n" "Low default router preference\n"
"Medium default router preference (default)\n") "Medium default router preference (default)\n")
{ {
int idx_high_medium_low = 3;
struct interface *ifp; struct interface *ifp;
struct zebra_if *zif; struct zebra_if *zif;
int i = 0; int i = 0;
@ -1799,7 +1809,7 @@ DEFUN (ipv6_nd_router_preference,
while (0 != rtadv_pref_strs[i]) while (0 != rtadv_pref_strs[i])
{ {
if (strncmp (argv[3]->arg, rtadv_pref_strs[i], 1) == 0) if (strncmp (argv[idx_high_medium_low]->arg, rtadv_pref_strs[i], 1) == 0)
{ {
zif->rtadv.DefaultPreference = i; zif->rtadv.DefaultPreference = i;
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1850,9 +1860,10 @@ DEFUN (ipv6_nd_mtu,
"Advertised MTU\n" "Advertised MTU\n"
"MTU in bytes\n") "MTU in bytes\n")
{ {
int idx_number = 3;
struct interface *ifp = (struct interface *) vty->index; struct interface *ifp = (struct interface *) vty->index;
struct zebra_if *zif = ifp->info; struct zebra_if *zif = ifp->info;
VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[3]->arg, 1, 65535); VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[idx_number]->arg, 1, 65535);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -124,6 +124,7 @@ DEFUN (test_interface_state,
"up\n" "up\n"
"down\n") "down\n")
{ {
int idx_up_down = 1;
struct interface *ifp; struct interface *ifp;
if (argc < 1) if (argc < 1)
return CMD_WARNING; return CMD_WARNING;
@ -136,7 +137,7 @@ DEFUN (test_interface_state,
ifp->flags = IFF_BROADCAST|IFF_MULTICAST; ifp->flags = IFF_BROADCAST|IFF_MULTICAST;
} }
switch (argv[1]->arg[0]) switch (argv[idx_up_down]->arg[0])
{ {
case 'u': case 'u':
SET_FLAG (ifp->flags, IFF_UP); SET_FLAG (ifp->flags, IFF_UP);

View File

@ -301,7 +301,8 @@ DEFUN (match_interface,
"match first hop interface of route\n" "match first hop interface of route\n"
"Interface name\n") "Interface name\n")
{ {
return zebra_route_match_add (vty, vty->index, "interface", argv[2]->arg, int idx_word = 2;
return zebra_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -335,7 +336,8 @@ DEFUN (match_tag,
"Match tag of route\n" "Match tag of route\n"
"Tag value\n") "Tag value\n")
{ {
return zebra_route_match_add (vty, vty->index, "tag", argv[2]->arg, int idx_number = 2;
return zebra_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg,
RMAP_EVENT_MATCH_ADDED); RMAP_EVENT_MATCH_ADDED);
} }
@ -373,7 +375,8 @@ DEFUN (match_ip_next_hop,
"IP access-list number (expanded range)\n" "IP access-list number (expanded range)\n"
"IP Access-list name\n") "IP Access-list name\n")
{ {
return zebra_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg, RMAP_EVENT_FILTER_ADDED); int idx_acl = 3;
return zebra_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED);
} }
/* /*
@ -414,8 +417,9 @@ DEFUN (match_ip_next_hop_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return zebra_route_match_add (vty, vty->index, "ip next-hop prefix-list", return zebra_route_match_add (vty, vty->index, "ip next-hop prefix-list",
argv[4]->arg, RMAP_EVENT_PLIST_ADDED); argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
} }
/* /*
@ -460,7 +464,8 @@ DEFUN (match_ip_address,
"IP Access-list name\n") "IP Access-list name\n")
{ {
return zebra_route_match_add (vty, vty->index, "ip address", argv[3]->arg, int idx_acl = 3;
return zebra_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg,
RMAP_EVENT_FILTER_ADDED); RMAP_EVENT_FILTER_ADDED);
} }
@ -502,8 +507,9 @@ DEFUN (match_ip_address_prefix_list,
"Match entries of prefix-lists\n" "Match entries of prefix-lists\n"
"IP prefix-list name\n") "IP prefix-list name\n")
{ {
int idx_word = 4;
return zebra_route_match_add (vty, vty->index, "ip address prefix-list", return zebra_route_match_add (vty, vty->index, "ip address prefix-list",
argv[4]->arg, RMAP_EVENT_PLIST_ADDED); argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
} }
/* /*
@ -627,17 +633,18 @@ DEFUN (match_source_protocol,
MATCH_STR MATCH_STR
"Match protocol via which the route was learnt\n") "Match protocol via which the route was learnt\n")
{ {
int idx_protocol = 2;
int i; int i;
i = proto_name2num(argv[2]->arg); i = proto_name2num(argv[idx_protocol]->arg);
if (i < 0) if (i < 0)
{ {
vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "",
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
return zebra_route_match_add (vty, vty->index, "source-protocol", return zebra_route_match_add (vty, vty->index, "source-protocol",
argv[2]->arg, RMAP_EVENT_MATCH_ADDED); argv[idx_protocol]->arg, RMAP_EVENT_MATCH_ADDED);
} }
DEFUN (no_match_source_protocol, DEFUN (no_match_source_protocol,
@ -647,20 +654,21 @@ DEFUN (no_match_source_protocol,
MATCH_STR MATCH_STR
"No match protocol via which the route was learnt\n") "No match protocol via which the route was learnt\n")
{ {
int idx_protocol = 3;
int i; int i;
if (argc >= 1) if (argc >= 1)
{ {
i = proto_name2num(argv[3]->arg); i = proto_name2num(argv[idx_protocol]->arg);
if (i < 0) if (i < 0)
{ {
vty_out (vty, "invalid protocol name \"%s\"%s", argv[3]->arg ? argv[3]->arg : "", vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "",
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
} }
return zebra_route_match_delete (vty, vty->index, return zebra_route_match_delete (vty, vty->index,
"source-protocol", argv[3]->arg ? argv[3]->arg : NULL, "source-protocol", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : NULL,
RMAP_EVENT_MATCH_DELETED); RMAP_EVENT_MATCH_DELETED);
} }
@ -673,15 +681,16 @@ DEFUN (set_src,
"src address for route\n" "src address for route\n"
"src address\n") "src address\n")
{ {
int idx_ip = 2;
union g_addr src; union g_addr src;
struct interface *pif = NULL; struct interface *pif = NULL;
int family; int family;
struct prefix p; struct prefix p;
vrf_iter_t iter; vrf_iter_t iter;
if (inet_pton(AF_INET, argv[2]->arg, &src.ipv4) != 1) if (inet_pton(AF_INET, argv[idx_ip]->arg, &src.ipv4) != 1)
{ {
if (inet_pton(AF_INET6, argv[2]->arg, &src.ipv6) != 1) if (inet_pton(AF_INET6, argv[idx_ip]->arg, &src.ipv6) != 1)
{ {
vty_out (vty, "%% not a valid IPv4/v6 address%s", VTY_NEWLINE); vty_out (vty, "%% not a valid IPv4/v6 address%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
@ -722,7 +731,7 @@ DEFUN (set_src,
vty_out (vty, "%% not a local address%s", VTY_NEWLINE); vty_out (vty, "%% not a local address%s", VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
return zebra_route_set_add (vty, vty->index, "src", argv[2]->arg); return zebra_route_set_add (vty, vty->index, "src", argv[idx_ip]->arg);
} }
DEFUN (no_set_src, DEFUN (no_set_src,
@ -732,10 +741,11 @@ DEFUN (no_set_src,
SET_STR SET_STR
"Source address for route\n") "Source address for route\n")
{ {
int idx_ip = 3;
if (argc == 0) if (argc == 0)
return zebra_route_set_delete (vty, vty->index, "src", NULL); return zebra_route_set_delete (vty, vty->index, "src", NULL);
return zebra_route_set_delete (vty, vty->index, "src", argv[3]->arg); return zebra_route_set_delete (vty, vty->index, "src", argv[idx_ip]->arg);
} }
DEFUN (zebra_route_map_timer, DEFUN (zebra_route_map_timer,
@ -744,9 +754,10 @@ DEFUN (zebra_route_map_timer,
"Time to wait before route-map updates are processed\n" "Time to wait before route-map updates are processed\n"
"0 means event-driven updates are disabled\n") "0 means event-driven updates are disabled\n")
{ {
int idx_number = 3;
u_int32_t rmap_delay_timer; u_int32_t rmap_delay_timer;
VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[3]->arg, 0, 600); VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600);
zebra_route_map_set_delay_timer(rmap_delay_timer); zebra_route_map_set_delay_timer(rmap_delay_timer);
return (CMD_SUCCESS); return (CMD_SUCCESS);
@ -782,15 +793,16 @@ DEFUN (ip_protocol,
QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
"Route map name\n") "Route map name\n")
{ {
int idx_protocol = 2;
int i; int i;
if (strcasecmp(argv[2]->arg, "any") == 0) if (strcasecmp(argv[idx_protocol]->arg, "any") == 0)
i = ZEBRA_ROUTE_MAX; i = ZEBRA_ROUTE_MAX;
else else
i = proto_name2num(argv[2]->arg); i = proto_name2num(argv[idx_protocol]->arg);
if (i < 0) if (i < 0)
{ {
vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "",
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -805,7 +817,7 @@ DEFUN (ip_protocol,
if (IS_ZEBRA_DEBUG_RIB_DETAILED) if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug ("%u: IPv4 Routemap config for protocol %s, scheduling RIB processing", zlog_debug ("%u: IPv4 Routemap config for protocol %s, scheduling RIB processing",
VRF_DEFAULT, argv[2]->arg); VRF_DEFAULT, argv[idx_protocol]->arg);
rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -897,15 +909,16 @@ DEFUN (ipv6_protocol,
QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
"Route map name\n") "Route map name\n")
{ {
int idx_protocol = 2;
int i; int i;
if (strcasecmp(argv[2]->arg, "any") == 0) if (strcasecmp(argv[idx_protocol]->arg, "any") == 0)
i = ZEBRA_ROUTE_MAX; i = ZEBRA_ROUTE_MAX;
else else
i = proto_name2num(argv[2]->arg); i = proto_name2num(argv[idx_protocol]->arg);
if (i < 0) if (i < 0)
{ {
vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "",
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -920,7 +933,7 @@ DEFUN (ipv6_protocol,
if (IS_ZEBRA_DEBUG_RIB_DETAILED) if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug ("%u: IPv6 Routemap config for protocol %s, scheduling RIB processing", zlog_debug ("%u: IPv6 Routemap config for protocol %s, scheduling RIB processing",
VRF_DEFAULT, argv[2]->arg); VRF_DEFAULT, argv[idx_protocol]->arg);
rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -1013,15 +1026,16 @@ DEFUN (ip_protocol_nht_rmap,
QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
"Route map name\n") "Route map name\n")
{ {
int idx_protocol = 2;
int i; int i;
if (strcasecmp(argv[2]->arg, "any") == 0) if (strcasecmp(argv[idx_protocol]->arg, "any") == 0)
i = ZEBRA_ROUTE_MAX; i = ZEBRA_ROUTE_MAX;
else else
i = proto_name2num(argv[2]->arg); i = proto_name2num(argv[idx_protocol]->arg);
if (i < 0) if (i < 0)
{ {
vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "",
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }
@ -1119,15 +1133,16 @@ DEFUN (ipv6_protocol_nht_rmap,
QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
"Route map name\n") "Route map name\n")
{ {
int idx_protocol = 2;
int i; int i;
if (strcasecmp(argv[2]->arg, "any") == 0) if (strcasecmp(argv[idx_protocol]->arg, "any") == 0)
i = ZEBRA_ROUTE_MAX; i = ZEBRA_ROUTE_MAX;
else else
i = proto_name2num(argv[2]->arg); i = proto_name2num(argv[idx_protocol]->arg);
if (i < 0) if (i < 0)
{ {
vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "",
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }

File diff suppressed because it is too large Load Diff