ospfd: add 'int idx_foo' argv index variables

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
This commit is contained in:
Daniel Walton 2016-09-23 20:01:26 +00:00
parent 51c2641415
commit 8d769265c4
7 changed files with 390 additions and 199 deletions

View File

@ -387,6 +387,9 @@ DEFUN (ip_ospf_bfd_param,
"Required min receive 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;
u_int32_t rx_val;
u_int32_t tx_val;
@ -395,7 +398,7 @@ DEFUN (ip_ospf_bfd_param,
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)
return ret;

View File

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

View File

@ -1188,6 +1188,7 @@ DEFUN (router_info,
"Enable the Router Information functionality with Area flooding scope\n"
"OSPF area ID in IP format")
{
int idx_ipv4 = 2;
u_int8_t scope;
@ -1197,7 +1198,7 @@ DEFUN (router_info,
/* Check and get Area value if present */
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_NEWLINE);
@ -1275,10 +1276,11 @@ DEFUN (pce_address,
"Stable IP address of the PCE\n"
"PCE address in IPv4 address format\n")
{
int idx_ipv4 = 2;
struct in_addr value;
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);
return CMD_WARNING;
@ -1322,10 +1324,11 @@ DEFUN (pce_path_scope,
"Path scope visibilities of the PCE for path computation\n"
"32-bit Hexadecimal value\n")
{
int idx_bitpattern = 2;
uint32_t scope;
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_NEWLINE);
@ -1369,13 +1372,14 @@ DEFUN (pce_domain,
"AS number where the PCE as visibilities for path computation\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 3;
uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info;
struct listnode *node;
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_NEWLINE);
@ -1408,11 +1412,12 @@ DEFUN (no_pce_domain,
"AS number where the PCE as visibilities for path computation\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 4;
uint32_t as;
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_NEWLINE);
@ -1437,13 +1442,14 @@ DEFUN (pce_neigbhor,
"AS number of PCE neighbors\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 3;
uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info;
struct listnode *node;
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_NEWLINE);
@ -1476,11 +1482,12 @@ DEFUN (no_pce_neighbor,
"AS number of PCE neighbor\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 4;
uint32_t as;
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_NEWLINE);
@ -1504,11 +1511,12 @@ DEFUN (pce_cap_flag,
"Capabilities of the PCE for path computation\n"
"32-bit Hexadecimal value\n")
{
int idx_bitpattern = 2;
uint32_t cap;
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_NEWLINE);

View File

@ -700,7 +700,8 @@ DEFUN (match_ip_nexthop,
"IP access-list number (expanded range)\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"
"IP prefix-list name\n")
{
int idx_word = 4;
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 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"
"IP prefix-list name\n")
{
int idx_word = 4;
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"
"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"
"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\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 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");
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", 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\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"
"MPLS-TE router address in IPv4 address format\n")
{
int idx_ipv4 = 2;
struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr;
struct in_addr value;
struct ospf *ospf = vty->index;
@ -2348,7 +2349,7 @@ DEFUN (ospf_mpls_te_router_addr,
if (!ospf)
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);
return CMD_WARNING;
@ -2482,7 +2483,8 @@ DEFUN (ospf_mpls_te_inter_as_area,
"OSPF area ID in IP format\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,
@ -2626,6 +2628,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
"Interface information\n"
"Interface name\n")
{
int idx_interface = 5;
struct interface *ifp;
struct listnode *node, *nnode;
@ -2638,7 +2641,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
/* Interface name is specified. */
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);
else
show_mpls_te_link_sub (vty, ifp);

File diff suppressed because it is too large Load Diff

View File

@ -280,7 +280,7 @@ def get_token_index_variable_name(line_number, token):
elif token == 'egp|igp|incomplete':
return 'idx_origin'
elif token == 'cisco|zebra':
elif token == 'cisco|zebra' or token == 'cisco|ibm|shortcut|standard':
return 'idx_vendor'
elif token == 'as-set|no-as-set':
@ -316,7 +316,7 @@ def get_token_index_variable_name(line_number, token):
elif token == 'ipv4|ipv6' or token == 'ip|ipv6':
return 'idx_afi'
elif token == 'md5|clear':
elif token == 'md5|clear' or token == 'null|message-digest':
return 'idx_encryption'
elif token == 'type-1|type-2':
@ -325,13 +325,25 @@ def get_token_index_variable_name(line_number, token):
elif token == 'table|intra-area|inter-area|memory':
return 'idx_type'
elif token == 'unknown|hello|dbdesc|lsreq|lsupdate|lsack|all':
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':
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':
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)':