summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-09-22 21:40:28 +0000
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-09-22 21:40:28 +0000
commitfcbee690565e9bb8a5722d86bf665fde827a5b0d (patch)
tree9b392a710d695dd5b388ce54ace6ceb9dfe24c5d
parent1bf1b05af96ba0e54462e329ea5aa3195605f68a (diff)
lib: argv update for if.c
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
-rw-r--r--lib/if.c89
1 files changed, 40 insertions, 49 deletions
diff --git a/lib/if.c b/lib/if.c
index bd6079c0fd..646f33354e 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -673,19 +673,19 @@ if_dump_all (void)
DEFUN (interface_desc,
interface_desc_cmd,
- "description .LINE",
+ "description LINE...",
"Interface specific description\n"
"Characters describing this interface\n")
{
struct interface *ifp;
- if (argc == 0)
+ if (argc == 1)
return CMD_SUCCESS;
ifp = vty->index;
if (ifp->desc)
XFREE (MTYPE_TMP, ifp->desc);
- ifp->desc = argv_concat(argv, argc, 0);
+ ifp->desc = argv_concat(argv, argc, 1);
return CMD_SUCCESS;
}
@@ -750,36 +750,40 @@ if_sunwzebra_get (const char *name, size_t nlen, vrf_id_t vrf_id)
DEFUN (interface,
interface_cmd,
- "interface IFNAME",
+ "interface IFNAME ["VRF_CMD_STR"]",
"Select an interface to configure\n"
- "Interface's name\n")
+ "Interface's name\n"
+ VRF_CMD_HELP_STR)
{
+ const char *ifname = argv[1]->arg;
+ const char *vrfname = (argc > 2) ? argv[3]->arg : NULL;
+
struct interface *ifp;
size_t sl;
vrf_id_t vrf_id = VRF_DEFAULT;
- if ((sl = strlen(argv[0])) > INTERFACE_NAMSIZ)
+ if ((sl = strlen(ifname)) > INTERFACE_NAMSIZ)
{
vty_out (vty, "%% Interface name %s is invalid: length exceeds "
"%d characters%s",
- argv[0], INTERFACE_NAMSIZ, VTY_NEWLINE);
+ ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
return CMD_WARNING;
}
/*Pending: need proper vrf name based lookup/(possible creation of VRF)
Imagine forward reference of a vrf by name in this interface config */
- if (argc > 1)
- VRF_GET_ID (vrf_id, argv[1]);
+ if (vrfname)
+ VRF_GET_ID (vrf_id, vrfname);
#ifdef SUNOS_5
- ifp = if_sunwzebra_get (argv[0], sl, vrf_id);
+ ifp = if_sunwzebra_get (ifname, sl, vrf_id);
#else
- ifp = if_get_by_name_len_vrf (argv[0], sl, vrf_id, 1);
+ ifp = if_get_by_name_len_vrf (ifname, sl, vrf_id, 1);
#endif /* SUNOS_5 */
if (!ifp)
{
- vty_out (vty, "%% interface %s not in %s%s", argv[0], argv[1], VTY_NEWLINE);
+ vty_out (vty, "%% interface %s not in %s%s", ifname, vrfname, VTY_NEWLINE);
return CMD_WARNING;
}
vty->index = ifp;
@@ -788,32 +792,29 @@ DEFUN (interface,
return CMD_SUCCESS;
}
-ALIAS (interface,
- interface_vrf_cmd,
- "interface IFNAME " VRF_CMD_STR,
- "Select an interface to configure\n"
- "Interface's name\n"
- VRF_CMD_HELP_STR)
-
DEFUN_NOSH (no_interface,
no_interface_cmd,
- "no interface IFNAME",
+ "no interface IFNAME [VRF_CMD_STR]",
NO_STR
"Delete a pseudo interface's configuration\n"
- "Interface's name\n")
+ "Interface's name\n"
+ VRF_CMD_HELP_STR)
{
+ const char *ifname = argv[2]->arg;
+ const char *vrfname = (argc > 3) ? argv[3]->arg : NULL;
+
// deleting interface
struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT;
- if (argc > 1)
- VRF_GET_ID (vrf_id, argv[1]);
+ if (argc > 3)
+ VRF_GET_ID (vrf_id, vrfname);
- ifp = if_lookup_by_name_vrf (argv[0], vrf_id);
+ ifp = if_lookup_by_name_vrf (ifname, vrf_id);
if (ifp == NULL)
{
- vty_out (vty, "%% Interface %s does not exist%s", argv[0], VTY_NEWLINE);
+ vty_out (vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -829,32 +830,26 @@ DEFUN_NOSH (no_interface,
return CMD_SUCCESS;
}
-ALIAS (no_interface,
- no_interface_vrf_cmd,
- "no interface IFNAME " VRF_CMD_STR,
- NO_STR
- "Delete a pseudo interface's configuration\n"
- "Interface's name\n"
- VRF_CMD_HELP_STR)
-
DEFUN (vrf,
vrf_cmd,
"vrf NAME",
"Select a VRF to configure\n"
"VRF's name\n")
{
+ const char *vrfname = argv[1]->arg;
+
struct vrf *vrfp;
size_t sl;
- if ((sl = strlen(argv[0])) > VRF_NAMSIZ)
+ if ((sl = strlen(vrfname)) > VRF_NAMSIZ)
{
vty_out (vty, "%% VRF name %s is invalid: length exceeds "
"%d characters%s",
- argv[0], VRF_NAMSIZ, VTY_NEWLINE);
+ vrfname, VRF_NAMSIZ, VTY_NEWLINE);
return CMD_WARNING;
}
- vrfp = vrf_get (VRF_UNKNOWN, argv[0]);
+ vrfp = vrf_get (VRF_UNKNOWN, vrfname);
vty->index = vrfp;
vty->node = VRF_NODE;
@@ -869,13 +864,15 @@ DEFUN_NOSH (no_vrf,
"Delete a pseudo VRF's configuration\n"
"VRF's name\n")
{
+ const char *vrfname = argv[2]->arg;
+
struct vrf *vrfp;
- vrfp = vrf_list_lookup_by_name (argv[0]);
+ vrfp = vrf_list_lookup_by_name (vrfname);;
if (vrfp == NULL)
{
- vty_out (vty, "%% VRF %s does not exist%s", argv[0], VTY_NEWLINE);
+ vty_out (vty, "%% VRF %s does not exist%s", vrfname, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -895,9 +892,10 @@ DEFUN_NOSH (no_vrf,
/* For debug purpose. */
DEFUN (show_address,
show_address_cmd,
- "show address",
+ "show address [VRF_CMD_STR]",
SHOW_STR
- "address\n")
+ "address\n"
+ VRF_CMD_HELP_STR)
{
struct listnode *node;
struct listnode *node2;
@@ -906,8 +904,8 @@ DEFUN (show_address,
struct prefix *p;
vrf_id_t vrf_id = VRF_DEFAULT;
- if (argc > 0)
- VRF_GET_ID (vrf_id, argv[0]);
+ if (argc > 2)
+ VRF_GET_ID (vrf_id, argv[2]->arg);
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp))
{
@@ -923,13 +921,6 @@ DEFUN (show_address,
return CMD_SUCCESS;
}
-ALIAS (show_address,
- show_address_vrf_cmd,
- "show address " VRF_CMD_STR,
- SHOW_STR
- "address\n"
- VRF_CMD_HELP_STR)
-
DEFUN (show_address_vrf_all,
show_address_vrf_all_cmd,
"show address " VRF_ALL_CMD_STR,