Blame SOURCES/open-lldp-v1.0.1-4-VDP-Changes-to-make-the-interface-to-VDP22-in-lldpad.patch

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