|
|
ee47b4 |
From e3f6d0eab95ef6b7336aaea2f44ecb79ead4216d Mon Sep 17 00:00:00 2001
|
|
|
ee47b4 |
From: padkrish <padkrish@cisco.com>
|
|
|
ee47b4 |
Date: Wed, 21 Jan 2015 03:37:09 +0000
|
|
|
ee47b4 |
Subject: [PATCH] VDP: Changes to make the interface to VDP22 (in lldpad) as
|
|
|
ee47b4 |
TLV
|
|
|
ee47b4 |
|
|
|
ee47b4 |
Changes to make the interface to VDP22 (in lldpad) as len, key, len,
|
|
|
ee47b4 |
value, which is in sync with other modules of lldpad.
|
|
|
ee47b4 |
|
|
|
ee47b4 |
Currently, the VSI parameters of VDP22 to LLDPAD are comma separated.
|
|
|
ee47b4 |
This patch has changes to have VSI Parameters being given to VDP22 as
|
|
|
ee47b4 |
Keyword_len followed by Keyword followed by value_len followed by
|
|
|
ee47b4 |
value. vdptool is also modified to reflect the same. This is
|
|
|
ee47b4 |
synchronous with other interface of lldpad like lldptool.
|
|
|
ee47b4 |
|
|
|
ee47b4 |
As an example, if vdptool is invoked as:
|
|
|
ee47b4 |
|
|
|
ee47b4 |
"vdptool -i eth2 -T -S -V assoc -c mode=assoc -c mgrid2=0 \
|
|
|
ee47b4 |
-c typeid=0 -c typeidver=0 -c uuid=00000000-3333-2222-888a-aabbccddee72 \
|
|
|
ee47b4 |
-c hints=none -c filter=0-00:00:00:11:22:72-90001",
|
|
|
ee47b4 |
|
|
|
ee47b4 |
the input to lldpad will be:
|
|
|
ee47b4 |
|
|
|
ee47b4 |
"M000080c4C3020000011c04eth2020000000304mode0005assoc06mgrid20001006typeid0001009typeidver0001004uuid002400000000-3333-2222-888a-aabbccddee7205hints0004none06filter00190-00:00:00:11:22:72-90001"
|
|
|
ee47b4 |
|
|
|
ee47b4 |
Another option is also added to vdptool to wait and print the response
|
|
|
ee47b4 |
from the bridge.
|
|
|
ee47b4 |
|
|
|
ee47b4 |
Signed-off-by: padkrish <padkrish@cisco.com>
|
|
|
ee47b4 |
---
|
|
|
ee47b4 |
include/qbg_vdp22.h | 5 ++
|
|
|
ee47b4 |
include/qbg_vdp22_clif.h | 7 +++
|
|
|
ee47b4 |
include/qbg_vdp22def.h | 24 ++++++++
|
|
|
ee47b4 |
qbg/vdp22_cmds.c | 125 +++++++-------------------------------
|
|
|
ee47b4 |
qbg/vdp_ascii.c | 152 +++++++++++++++++++++++++++++++----------------
|
|
|
ee47b4 |
vdptool.c | 53 +++++++++++------
|
|
|
ee47b4 |
6 files changed, 193 insertions(+), 173 deletions(-)
|
|
|
ee47b4 |
|
|
|
ee47b4 |
diff --git a/include/qbg_vdp22.h b/include/qbg_vdp22.h
|
|
|
ee47b4 |
index b345602..45f44d5 100644
|
|
|
ee47b4 |
--- a/include/qbg_vdp22.h
|
|
|
ee47b4 |
+++ b/include/qbg_vdp22.h
|
|
|
ee47b4 |
@@ -163,6 +163,11 @@ struct vdp22_user_data { /* Head for all VDP data */
|
|
|
ee47b4 |
LIST_HEAD(vdp22_head, vdp22) head;
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+struct vsi_keyword_handler {
|
|
|
ee47b4 |
+ char *keyword;
|
|
|
ee47b4 |
+ enum vsi_mand_arg val;
|
|
|
ee47b4 |
+};
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
struct lldp_module *vdp22_register(void);
|
|
|
ee47b4 |
void vdp22_unregister(struct lldp_module *);
|
|
|
ee47b4 |
void vdp22_start(const char *, int);
|
|
|
ee47b4 |
diff --git a/include/qbg_vdp22_clif.h b/include/qbg_vdp22_clif.h
|
|
|
ee47b4 |
index 008022a..8346b98 100644
|
|
|
ee47b4 |
--- a/include/qbg_vdp22_clif.h
|
|
|
ee47b4 |
+++ b/include/qbg_vdp22_clif.h
|
|
|
ee47b4 |
@@ -29,6 +29,10 @@
|
|
|
ee47b4 |
|
|
|
ee47b4 |
#ifndef QBG_VDP22_CLIF_H
|
|
|
ee47b4 |
#define QBG_VDP22_CLIF_H
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+#define OP_FID_POS 8 /* Second Byte */
|
|
|
ee47b4 |
+#define OP_OUI_POS 16 /* Third Byte */
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
typedef enum {
|
|
|
ee47b4 |
cmd_getstats,
|
|
|
ee47b4 |
cmd_gettlv,
|
|
|
ee47b4 |
@@ -51,6 +55,9 @@ typedef enum {
|
|
|
ee47b4 |
op_config = 0x10,
|
|
|
ee47b4 |
op_delete = 0x20,
|
|
|
ee47b4 |
op_key = 0x40
|
|
|
ee47b4 |
+ /* Second Byte is used for signifying the number of Filter fields and
|
|
|
ee47b4 |
+ * the third byte is used for signifying the number of OUI fields.
|
|
|
ee47b4 |
+ */
|
|
|
ee47b4 |
} vdp22_op;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
struct lldp_module *vdp22_cli_register(void);
|
|
|
ee47b4 |
diff --git a/include/qbg_vdp22def.h b/include/qbg_vdp22def.h
|
|
|
ee47b4 |
index 52f4502..21ba15d 100644
|
|
|
ee47b4 |
--- a/include/qbg_vdp22def.h
|
|
|
ee47b4 |
+++ b/include/qbg_vdp22def.h
|
|
|
ee47b4 |
@@ -72,4 +72,28 @@ enum vdp22_migration_hints {
|
|
|
ee47b4 |
VDP22_MIGFROM = 32 /* S-bit migrate from hint */
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+enum vsi_mand_arg {
|
|
|
ee47b4 |
+ VSI_MODE_ARG = 0,
|
|
|
ee47b4 |
+ VSI_MGRID2_ARG,
|
|
|
ee47b4 |
+ VSI_TYPEID_ARG,
|
|
|
ee47b4 |
+ VSI_TYPEIDVER_ARG,
|
|
|
ee47b4 |
+/* VSI_VSIIDFRMT_ARG, TODO */
|
|
|
ee47b4 |
+ VSI_VSIID_ARG,
|
|
|
ee47b4 |
+ VSI_FILTER_ARG,
|
|
|
ee47b4 |
+ VSI_MAND_NUM_ARG,
|
|
|
ee47b4 |
+ VSI_HINTS_ARG,
|
|
|
ee47b4 |
+ VSI_INVALID_ARG
|
|
|
ee47b4 |
+};
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+#define VSI22_ARG_MODE_STR "mode"
|
|
|
ee47b4 |
+#define VSI22_ARG_MGRID_STR "mgrid2"
|
|
|
ee47b4 |
+#define VSI22_ARG_TYPEID_STR "typeid"
|
|
|
ee47b4 |
+#define VSI22_ARG_TYPEIDVER_STR "typeidver"
|
|
|
ee47b4 |
+#define VSI22_ARG_VSIIDFRMT_STR "vsiidfrmt"
|
|
|
ee47b4 |
+/*#define VSI22_ARG_VSIID_STR "vsiid" TODO*/
|
|
|
ee47b4 |
+#define VSI22_ARG_VSIID_STR "uuid"
|
|
|
ee47b4 |
+#define VSI22_ARG_HINTS_STR "hints"
|
|
|
ee47b4 |
+#define VSI22_ARG_FILTER_STR "filter"
|
|
|
ee47b4 |
+#define VSI22_ARG_OUI_STR "oui"
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
#endif
|
|
|
ee47b4 |
diff --git a/qbg/vdp22_cmds.c b/qbg/vdp22_cmds.c
|
|
|
ee47b4 |
index f055441..dde4669 100644
|
|
|
ee47b4 |
--- a/qbg/vdp22_cmds.c
|
|
|
ee47b4 |
+++ b/qbg/vdp22_cmds.c
|
|
|
ee47b4 |
@@ -104,37 +104,6 @@ static int handle_get_arg(struct cmd *cmd, char *arg, char *argvalue,
|
|
|
ee47b4 |
return status;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-static int handle_get(struct cmd *cmd, UNUSED char *arg, char *argvalue,
|
|
|
ee47b4 |
- char *obuf, int obuf_len)
|
|
|
ee47b4 |
-{
|
|
|
ee47b4 |
- struct arg_handlers *ah;
|
|
|
ee47b4 |
- int rval;
|
|
|
ee47b4 |
- char *nbuf;
|
|
|
ee47b4 |
- int nbuf_len;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- memset(obuf, 0, obuf_len);
|
|
|
ee47b4 |
- nbuf = obuf + 12;
|
|
|
ee47b4 |
- nbuf_len = obuf_len - 12;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- ah = get_my_arghndl(cmd->module_id);
|
|
|
ee47b4 |
- if (!ah)
|
|
|
ee47b4 |
- return cmd_not_applicable;
|
|
|
ee47b4 |
- for (; ah->arg; ++ah) {
|
|
|
ee47b4 |
- if (strcmp(ah->arg, ARG_VDP22_VSI))
|
|
|
ee47b4 |
- continue;
|
|
|
ee47b4 |
- if (ah->handle_get && (ah->arg_class == TLV_ARG)) {
|
|
|
ee47b4 |
- rval = ah->handle_get(cmd, ah->arg, argvalue,
|
|
|
ee47b4 |
- nbuf, nbuf_len);
|
|
|
ee47b4 |
- if (rval != cmd_success && rval != cmd_not_applicable)
|
|
|
ee47b4 |
- return rval;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- nbuf_len -= strlen(nbuf);
|
|
|
ee47b4 |
- nbuf = nbuf + strlen(nbuf);
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
- return cmd_success;
|
|
|
ee47b4 |
-}
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
static int handle_test_arg(struct cmd *cmd, char *arg, char *argvalue,
|
|
|
ee47b4 |
char *obuf, int obuf_len)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
@@ -223,17 +192,13 @@ static int handle_set_arg(struct cmd *cmd, char *arg, char *argvalue,
|
|
|
ee47b4 |
*/
|
|
|
ee47b4 |
int vdp22_clif_cmd(UNUSED void *data, UNUSED struct sockaddr_un *from,
|
|
|
ee47b4 |
UNUSED socklen_t fromlen,
|
|
|
ee47b4 |
- char *ibuf, int ilen, char *rbuf, int rlen)
|
|
|
ee47b4 |
+ char *ibuf, UNUSED int ilen, char *rbuf, int rlen)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
struct cmd cmd;
|
|
|
ee47b4 |
u8 len, version;
|
|
|
ee47b4 |
int ioff, roff;
|
|
|
ee47b4 |
int rstatus = cmd_invalid;
|
|
|
ee47b4 |
- char **args;
|
|
|
ee47b4 |
- char **argvals;
|
|
|
ee47b4 |
bool test_failed = false;
|
|
|
ee47b4 |
- int numargs = 0;
|
|
|
ee47b4 |
- int i, offset;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
memset(&cmd, 0, sizeof(cmd));
|
|
|
ee47b4 |
cmd.module_id = LLDP_MOD_VDP22;
|
|
|
ee47b4 |
@@ -275,32 +240,6 @@ int vdp22_clif_cmd(UNUSED void *data, UNUSED struct sockaddr_un *from,
|
|
|
ee47b4 |
if (!(cmd.ops & op_config))
|
|
|
ee47b4 |
return cmd_invalid;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
- /* Count args and argvalues */
|
|
|
ee47b4 |
- offset = ioff;
|
|
|
ee47b4 |
- for (numargs = 0; (ilen - offset) > 2; numargs++) {
|
|
|
ee47b4 |
- offset += 2;
|
|
|
ee47b4 |
- if (ilen - offset > 0) {
|
|
|
ee47b4 |
- offset++;
|
|
|
ee47b4 |
- if (ilen - offset > 4)
|
|
|
ee47b4 |
- offset += 4;
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- args = calloc(numargs, sizeof(char *));
|
|
|
ee47b4 |
- if (!args)
|
|
|
ee47b4 |
- return cmd_failed;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- argvals = calloc(numargs, sizeof(char *));
|
|
|
ee47b4 |
- if (!argvals) {
|
|
|
ee47b4 |
- free(args);
|
|
|
ee47b4 |
- return cmd_failed;
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- if ((cmd.ops & op_arg) && (cmd.ops & op_argval))
|
|
|
ee47b4 |
- numargs = get_arg_val_list(ibuf, ilen, &ioff, args, argvals);
|
|
|
ee47b4 |
- else if (cmd.ops & op_arg)
|
|
|
ee47b4 |
- numargs = get_arg_list(ibuf, ilen, &ioff, args);
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
snprintf(rbuf, rlen, "%c%1x%02x%08x%02x%s",
|
|
|
ee47b4 |
CMD_REQUEST, CLIF_MSG_VERSION,
|
|
|
ee47b4 |
cmd.cmd, cmd.ops,
|
|
|
ee47b4 |
@@ -309,42 +248,29 @@ int vdp22_clif_cmd(UNUSED void *data, UNUSED struct sockaddr_un *from,
|
|
|
ee47b4 |
|
|
|
ee47b4 |
/* Confirm port is a valid LLDP port */
|
|
|
ee47b4 |
if (!get_ifidx(cmd.ifname) || !is_valid_lldp_device(cmd.ifname)) {
|
|
|
ee47b4 |
- free(argvals);
|
|
|
ee47b4 |
- free(args);
|
|
|
ee47b4 |
return cmd_device_not_found;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
snprintf(rbuf + roff, rlen - roff, "%08x", cmd.tlvid);
|
|
|
ee47b4 |
roff += 8;
|
|
|
ee47b4 |
if (cmd.cmd == cmd_gettlv) {
|
|
|
ee47b4 |
- if (!numargs)
|
|
|
ee47b4 |
- rstatus = handle_get(&cmd, NULL, NULL,
|
|
|
ee47b4 |
- rbuf + strlen(rbuf),
|
|
|
ee47b4 |
- rlen - strlen(rbuf));
|
|
|
ee47b4 |
- else
|
|
|
ee47b4 |
- for (i = 0; i < numargs; i++)
|
|
|
ee47b4 |
- rstatus = handle_get_arg(&cmd, args[i], NULL,
|
|
|
ee47b4 |
- rbuf + strlen(rbuf),
|
|
|
ee47b4 |
- rlen - strlen(rbuf));
|
|
|
ee47b4 |
+ rstatus = handle_get_arg(&cmd, ARG_VDP22_VSI,
|
|
|
ee47b4 |
+ NULL,
|
|
|
ee47b4 |
+ rbuf + strlen(rbuf),
|
|
|
ee47b4 |
+ rlen - strlen(rbuf));
|
|
|
ee47b4 |
} else {
|
|
|
ee47b4 |
- for (i = 0; i < numargs; i++) {
|
|
|
ee47b4 |
- rstatus = handle_test_arg(&cmd, args[i], argvals[i],
|
|
|
ee47b4 |
- rbuf + strlen(rbuf),
|
|
|
ee47b4 |
- rlen - strlen(rbuf));
|
|
|
ee47b4 |
- if (rstatus != cmd_not_applicable &&
|
|
|
ee47b4 |
- rstatus != cmd_success)
|
|
|
ee47b4 |
- test_failed = true;
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
+ rstatus = handle_test_arg(&cmd, ARG_VDP22_VSI,
|
|
|
ee47b4 |
+ ibuf + ioff,
|
|
|
ee47b4 |
+ rbuf + strlen(rbuf),
|
|
|
ee47b4 |
+ rlen - strlen(rbuf));
|
|
|
ee47b4 |
+ if (rstatus != cmd_not_applicable && rstatus != cmd_success)
|
|
|
ee47b4 |
+ test_failed = true;
|
|
|
ee47b4 |
if (!test_failed)
|
|
|
ee47b4 |
- for (i = 0; i < numargs; i++)
|
|
|
ee47b4 |
- rstatus = handle_set_arg(&cmd, args[i],
|
|
|
ee47b4 |
- argvals[i],
|
|
|
ee47b4 |
- rbuf + strlen(rbuf),
|
|
|
ee47b4 |
- rlen - strlen(rbuf));
|
|
|
ee47b4 |
+ rstatus = handle_set_arg(&cmd,
|
|
|
ee47b4 |
+ ARG_VDP22_VSI, ibuf + ioff,
|
|
|
ee47b4 |
+ rbuf + strlen(rbuf),
|
|
|
ee47b4 |
+ rlen - strlen(rbuf));
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- free(argvals);
|
|
|
ee47b4 |
- free(args);
|
|
|
ee47b4 |
return rstatus;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
@@ -436,27 +362,16 @@ out:
|
|
|
ee47b4 |
return good_cmd;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-/*
|
|
|
ee47b4 |
- * Count the number of fid data fields in the argument value.
|
|
|
ee47b4 |
- */
|
|
|
ee47b4 |
-#define VDP22_FID_IDX 6 /* Min index of fid data */
|
|
|
ee47b4 |
-static int count_fid(char *argvalue)
|
|
|
ee47b4 |
-{
|
|
|
ee47b4 |
- char *p = argvalue;
|
|
|
ee47b4 |
- int i;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- for (i = 0; (p = strchr(p, ',')); ++i, ++p)
|
|
|
ee47b4 |
- ;
|
|
|
ee47b4 |
- return i + 1 - VDP22_FID_IDX;
|
|
|
ee47b4 |
-}
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
static int set_arg_vsi2(struct cmd *cmd, char *argvalue, bool test)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
- int no = count_fid(argvalue);
|
|
|
ee47b4 |
+ int no = (cmd->ops >> OP_FID_POS) & 0xff;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
if (no <= 0)
|
|
|
ee47b4 |
return -EINVAL;
|
|
|
ee47b4 |
- return set_arg_vsi3(cmd, argvalue, test, no);
|
|
|
ee47b4 |
+ if ((cmd->ops & op_arg) && (cmd->ops & op_argval))
|
|
|
ee47b4 |
+ return set_arg_vsi3(cmd, argvalue, test, no);
|
|
|
ee47b4 |
+ else /* Not supported for now */
|
|
|
ee47b4 |
+ return cmd_failed;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
static int set_arg_vsi(struct cmd *cmd, UNUSED char *arg, char *argvalue,
|
|
|
ee47b4 |
diff --git a/qbg/vdp_ascii.c b/qbg/vdp_ascii.c
|
|
|
ee47b4 |
index 0ace562..09e53c6 100644
|
|
|
ee47b4 |
--- a/qbg/vdp_ascii.c
|
|
|
ee47b4 |
+++ b/qbg/vdp_ascii.c
|
|
|
ee47b4 |
@@ -43,6 +43,17 @@
|
|
|
ee47b4 |
#include "qbg_vdp22.h"
|
|
|
ee47b4 |
#include "qbg_vdpnl.h"
|
|
|
ee47b4 |
#include "qbg_utils.h"
|
|
|
ee47b4 |
+#include "lldp_util.h"
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+struct vsi_keyword_handler vsi_key_handle[] = {
|
|
|
ee47b4 |
+ {VSI22_ARG_MODE_STR, VSI_MODE_ARG},
|
|
|
ee47b4 |
+ {VSI22_ARG_MGRID_STR, VSI_MGRID2_ARG},
|
|
|
ee47b4 |
+ {VSI22_ARG_TYPEID_STR, VSI_TYPEID_ARG},
|
|
|
ee47b4 |
+ {VSI22_ARG_TYPEIDVER_STR, VSI_TYPEIDVER_ARG},
|
|
|
ee47b4 |
+/* {VSI22_ARG_VSIIDFRMT_STR, VSI_VSIIDFRMT_ARG}, TODO*/
|
|
|
ee47b4 |
+ {VSI22_ARG_VSIID_STR, VSI_VSIID_ARG},
|
|
|
ee47b4 |
+ {VSI22_ARG_HINTS_STR, VSI_HINTS_ARG},
|
|
|
ee47b4 |
+ {VSI22_ARG_FILTER_STR, VSI_FILTER_ARG} };
|
|
|
ee47b4 |
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
* Check if it is a UUID and consists of hexadecimal digits and dashes only.
|
|
|
ee47b4 |
@@ -253,6 +264,18 @@ static bool getmode(struct vdpnl_vsi *p, char *s)
|
|
|
ee47b4 |
return true;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+enum vsi_mand_arg get_keywork_val(char *keyword)
|
|
|
ee47b4 |
+{
|
|
|
ee47b4 |
+ int count, key_str_size;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ key_str_size = sizeof(vsi_key_handle) / sizeof(vsi_key_handle[0]);
|
|
|
ee47b4 |
+ for (count = 0; count < key_str_size; count++) {
|
|
|
ee47b4 |
+ if (!strcmp(keyword, vsi_key_handle[count].keyword))
|
|
|
ee47b4 |
+ return vsi_key_handle[count].val;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ return VSI_INVALID_ARG;
|
|
|
ee47b4 |
+}
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
* Parse the mode parameter to create/change an VSI assoication.
|
|
|
ee47b4 |
* The format is a comma separated list of tokens:
|
|
|
ee47b4 |
@@ -276,66 +299,95 @@ static bool getmode(struct vdpnl_vsi *p, char *s)
|
|
|
ee47b4 |
* mac := xx:xx:xx:xx:xx:xx
|
|
|
ee47b4 |
*/
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-static int str2vdpnl(char *argvalue, struct vdpnl_vsi *vsi)
|
|
|
ee47b4 |
+static int str2vdpnl(char *orig_argvalue, struct vdpnl_vsi *vsi)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
+ char **args;
|
|
|
ee47b4 |
+ char **argvals;
|
|
|
ee47b4 |
+ char *argvalue;
|
|
|
ee47b4 |
int rc = -ENOMEM;
|
|
|
ee47b4 |
unsigned int no;
|
|
|
ee47b4 |
- unsigned short idx;
|
|
|
ee47b4 |
- char *cmdstring, *token;
|
|
|
ee47b4 |
+ unsigned short idx = 0;
|
|
|
ee47b4 |
+ int i, ioff = 0, offset;
|
|
|
ee47b4 |
+ int ilen = strlen(orig_argvalue);
|
|
|
ee47b4 |
+ int numargs;
|
|
|
ee47b4 |
+ enum vsi_mand_arg vsi_key;
|
|
|
ee47b4 |
+ u16 vsi_mand_mask = (1 << VSI_MAND_NUM_ARG) - 1;
|
|
|
ee47b4 |
+ u16 num_arg_keys = 0;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
- cmdstring = strdup(argvalue);
|
|
|
ee47b4 |
- if (!cmdstring)
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
- rc = -EINVAL;
|
|
|
ee47b4 |
- /* 1st field is VSI command */
|
|
|
ee47b4 |
- token = strtok(cmdstring, ",");
|
|
|
ee47b4 |
- if (!token || !getmode(vsi, token))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ argvalue = strdup(orig_argvalue);
|
|
|
ee47b4 |
+ if (!argvalue)
|
|
|
ee47b4 |
+ goto out;
|
|
|
ee47b4 |
+ /* Count args and argvalues */
|
|
|
ee47b4 |
+ offset = ioff;
|
|
|
ee47b4 |
+ for (numargs = 0; (ilen - offset) > 2; numargs++) {
|
|
|
ee47b4 |
+ offset += 2;
|
|
|
ee47b4 |
+ if (ilen - offset > 0) {
|
|
|
ee47b4 |
+ offset++;
|
|
|
ee47b4 |
+ if (ilen - offset > 4)
|
|
|
ee47b4 |
+ offset += 4;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ args = calloc(numargs, sizeof(char *));
|
|
|
ee47b4 |
+ if (!args)
|
|
|
ee47b4 |
+ goto out_argvalue;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
- /* 2nd field is VSI Manager Identifer (16 bytes maximum) */
|
|
|
ee47b4 |
- token = strtok(NULL, ",");
|
|
|
ee47b4 |
- if (!token || !getmgr2id(vsi, token))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- /* 3rd field is type identifier */
|
|
|
ee47b4 |
- token = strtok(NULL, ",");
|
|
|
ee47b4 |
- if (!token || !getnumber(token, 0, 0xffffff, &no))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
- vsi->vsi_typeid = no;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- /* 4th field is type version identifier */
|
|
|
ee47b4 |
- token = strtok(NULL, ",");
|
|
|
ee47b4 |
- if (!token || !getnumber(token, 0, 0xff, &no))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
- vsi->vsi_typeversion = no;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- /* 5th field is filter VSI UUID */
|
|
|
ee47b4 |
- token = strtok(NULL, ",");
|
|
|
ee47b4 |
- if (!token || vdp_str2uuid(vsi->vsi_uuid, token, sizeof(vsi->vsi_uuid)))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
- vsi->vsi_idfmt = VDP22_ID_UUID;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- /* 6th field is migration hints */
|
|
|
ee47b4 |
- token = strtok(NULL, ",");
|
|
|
ee47b4 |
- if (!token || !gethints(vsi, token))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
- /*
|
|
|
ee47b4 |
- * 7th and remaining fields are filter information format data.
|
|
|
ee47b4 |
- * All fields must have the same format. The first fid field determines
|
|
|
ee47b4 |
- * the format.
|
|
|
ee47b4 |
- */
|
|
|
ee47b4 |
- for (idx = 0, token = strtok(NULL, ","); token != NULL;
|
|
|
ee47b4 |
- ++idx, token = strtok(NULL, ",")) {
|
|
|
ee47b4 |
- if (idx < vsi->macsz && !getfid(vsi, token, idx))
|
|
|
ee47b4 |
+ argvals = calloc(numargs, sizeof(char *));
|
|
|
ee47b4 |
+ if (!argvals)
|
|
|
ee47b4 |
+ goto out_args;
|
|
|
ee47b4 |
+ numargs = get_arg_val_list(argvalue, ilen, &ioff, args, argvals);
|
|
|
ee47b4 |
+ for (i = 0; i < numargs; i++) {
|
|
|
ee47b4 |
+ vsi_key = get_keywork_val(args[i]);
|
|
|
ee47b4 |
+ switch (vsi_key) {
|
|
|
ee47b4 |
+ case VSI_MODE_ARG:
|
|
|
ee47b4 |
+ if (!argvals[i] || !getmode(vsi, argvals[i]))
|
|
|
ee47b4 |
+ goto out_free;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VSI_MGRID2_ARG:
|
|
|
ee47b4 |
+ if (!argvals[i] || !getmgr2id(vsi, argvals[i]))
|
|
|
ee47b4 |
+ goto out_free;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VSI_TYPEID_ARG:
|
|
|
ee47b4 |
+ if (!argvals[i] ||
|
|
|
ee47b4 |
+ !getnumber(argvals[i], 0, 0xffffff, &no))
|
|
|
ee47b4 |
+ goto out_free;
|
|
|
ee47b4 |
+ vsi->vsi_typeid = no;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VSI_TYPEIDVER_ARG:
|
|
|
ee47b4 |
+ if (!argvals[i] || !getnumber(argvals[i], 0, 0xff, &no))
|
|
|
ee47b4 |
+ goto out_free;
|
|
|
ee47b4 |
+ vsi->vsi_typeversion = no;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VSI_VSIID_ARG:
|
|
|
ee47b4 |
+ if (!argvals[i] ||
|
|
|
ee47b4 |
+ vdp_str2uuid(vsi->vsi_uuid, argvals[i],
|
|
|
ee47b4 |
+ sizeof(vsi->vsi_uuid)))
|
|
|
ee47b4 |
+ goto out_free;
|
|
|
ee47b4 |
+ vsi->vsi_idfmt = VDP22_ID_UUID;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VSI_FILTER_ARG:
|
|
|
ee47b4 |
+ if (idx < vsi->macsz && !getfid(vsi, argvals[i], idx))
|
|
|
ee47b4 |
+ goto out_free;
|
|
|
ee47b4 |
+ idx++;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VSI_HINTS_ARG:
|
|
|
ee47b4 |
+ if (!argvals[i] || !gethints(vsi, argvals[i]))
|
|
|
ee47b4 |
+ goto out_free;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ default:
|
|
|
ee47b4 |
goto out_free;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ num_arg_keys |= (1 << vsi_key);
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
/* Return error if no filter information provided */
|
|
|
ee47b4 |
- if (idx)
|
|
|
ee47b4 |
+ if ((num_arg_keys & vsi_mand_mask) == vsi_mand_mask)
|
|
|
ee47b4 |
rc = 0;
|
|
|
ee47b4 |
out_free:
|
|
|
ee47b4 |
- free(cmdstring);
|
|
|
ee47b4 |
+ free(argvals);
|
|
|
ee47b4 |
+out_args:
|
|
|
ee47b4 |
+ free(args);
|
|
|
ee47b4 |
+out_argvalue:
|
|
|
ee47b4 |
+ free(argvalue);
|
|
|
ee47b4 |
+out:
|
|
|
ee47b4 |
return rc;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
diff --git a/vdptool.c b/vdptool.c
|
|
|
ee47b4 |
index e7d384a..f506020 100644
|
|
|
ee47b4 |
--- a/vdptool.c
|
|
|
ee47b4 |
+++ b/vdptool.c
|
|
|
ee47b4 |
@@ -125,31 +125,28 @@ static int render_cmd(struct cmd *cmd, int argc, char **args, char **argvals)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
int len;
|
|
|
ee47b4 |
int i;
|
|
|
ee47b4 |
+ int fid = 0, oui = 0;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
len = sizeof(cmd->obuf);
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+ if (cmd->cmd == cmd_settlv) {
|
|
|
ee47b4 |
+ for (i = 0; i < argc; i++) {
|
|
|
ee47b4 |
+ if (args[i]) {
|
|
|
ee47b4 |
+ if (!strncasecmp(args[i], "filter",
|
|
|
ee47b4 |
+ strlen("filter")))
|
|
|
ee47b4 |
+ fid++;
|
|
|
ee47b4 |
+ else if (!strncasecmp(args[i], "oui",
|
|
|
ee47b4 |
+ strlen("oui")))
|
|
|
ee47b4 |
+ oui++;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ cmd->ops |= (fid << OP_FID_POS) | (oui << OP_OUI_POS);
|
|
|
ee47b4 |
/* all command messages begin this way */
|
|
|
ee47b4 |
snprintf(cmd->obuf, len, "%c%08x%c%1x%02x%08x%02x%s%02x%08x",
|
|
|
ee47b4 |
MOD_CMD, cmd->module_id, CMD_REQUEST, CLIF_MSG_VERSION,
|
|
|
ee47b4 |
cmd->cmd, cmd->ops, (unsigned int) strlen(cmd->ifname),
|
|
|
ee47b4 |
cmd->ifname, cmd->type, cmd->tlvid);
|
|
|
ee47b4 |
-#if PADDU
|
|
|
ee47b4 |
- if (cmd->cmd == cmd_settlv) {
|
|
|
ee47b4 |
- size_t len2 = 0;
|
|
|
ee47b4 |
- /*
|
|
|
ee47b4 |
- * Get total length and append it plus any args and argvals
|
|
|
ee47b4 |
- * to the command message
|
|
|
ee47b4 |
- */
|
|
|
ee47b4 |
- for (i = 0; i < argc; i++) {
|
|
|
ee47b4 |
- if (args[i])
|
|
|
ee47b4 |
- len2 += 2 + strlen(args[i]);
|
|
|
ee47b4 |
- if (argvals[i])
|
|
|
ee47b4 |
- len2 += 4 + strlen(argvals[i]);
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
- snprintf(cmd->obuf + strlen(cmd->obuf), len - strlen(cmd->obuf),
|
|
|
ee47b4 |
- "%04zx", len2);
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
-#endif
|
|
|
ee47b4 |
/* Add any args and argvals to the command message */
|
|
|
ee47b4 |
for (i = 0; i < argc; i++) {
|
|
|
ee47b4 |
if (args[i])
|
|
|
ee47b4 |
@@ -710,6 +707,9 @@ static int _clif_command(struct clif *clif, char *cmd, int print)
|
|
|
ee47b4 |
char buf[MAX_CLIF_MSGBUF];
|
|
|
ee47b4 |
size_t len;
|
|
|
ee47b4 |
int ret;
|
|
|
ee47b4 |
+ int rc;
|
|
|
ee47b4 |
+ char reply[100];
|
|
|
ee47b4 |
+ size_t reply_len2 = sizeof(reply);
|
|
|
ee47b4 |
|
|
|
ee47b4 |
print_raw_message(cmd, print);
|
|
|
ee47b4 |
|
|
|
ee47b4 |
@@ -730,6 +730,13 @@ static int _clif_command(struct clif *clif, char *cmd, int print)
|
|
|
ee47b4 |
buf[len] = '\0';
|
|
|
ee47b4 |
ret = parse_print_message(buf, print);
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
+ if (cli_attached) {
|
|
|
ee47b4 |
+ rc = clif_vsievt(clif, reply, &reply_len2, 5);
|
|
|
ee47b4 |
+ printf("\nReturn from vsievt %d ret %d Reply %s\n", rc, ret,
|
|
|
ee47b4 |
+ reply);
|
|
|
ee47b4 |
+ if (!rc)
|
|
|
ee47b4 |
+ printf("\nMsg is %s\n", reply);
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
|
|
|
ee47b4 |
return ret;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
@@ -854,6 +861,7 @@ static int request(struct clif *clif, int argc, char *argv[])
|
|
|
ee47b4 |
int numargs = 0;
|
|
|
ee47b4 |
char **argptr = &argv[0];
|
|
|
ee47b4 |
char *end;
|
|
|
ee47b4 |
+ char attach_str[9] = "";
|
|
|
ee47b4 |
int c;
|
|
|
ee47b4 |
int option_index;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
@@ -865,7 +873,7 @@ static int request(struct clif *clif, int argc, char *argv[])
|
|
|
ee47b4 |
|
|
|
ee47b4 |
opterr = 0;
|
|
|
ee47b4 |
for (;;) {
|
|
|
ee47b4 |
- c = getopt_long(argc, argv, "i:tThcnvrRpqV:",
|
|
|
ee47b4 |
+ c = getopt_long(argc, argv, "i:tTWhcnvrRpqV:",
|
|
|
ee47b4 |
lldptool_opts, &option_index);
|
|
|
ee47b4 |
if (c < 0)
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
@@ -936,6 +944,15 @@ static int request(struct clif *clif, int argc, char *argv[])
|
|
|
ee47b4 |
case 'v':
|
|
|
ee47b4 |
command.cmd = cmd_version;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
+ case 'W':
|
|
|
ee47b4 |
+ snprintf(attach_str, sizeof(attach_str), "%x",
|
|
|
ee47b4 |
+ LLDP_MOD_VDP22);
|
|
|
ee47b4 |
+ if (clif_attach(clif, attach_str) != 0) {
|
|
|
ee47b4 |
+ printf("Warning: Failed to attach to lldpad.\n");
|
|
|
ee47b4 |
+ return -1;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ cli_attached = 1;
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
default:
|
|
|
ee47b4 |
usage();
|
|
|
ee47b4 |
ret = -1;
|
|
|
ee47b4 |
--
|
|
|
ee47b4 |
2.1.0
|
|
|
ee47b4 |
|