[lldp-devel] [PATCH v5 3/5] introduced changed config file interface

Jens Osterkamp jens at linux.vnet.ibm.com
Mon Aug 29 14:57:16 UTC 2011


This patch modifies all interface functions to get and set config file
values to use the agent type. The agent type will determine in which section
of the config file the values are located. The result is that now there are 3
sections in lldpad.conf for LLDP:

	- "lldp" or "nearest_bridge" (if newly created)
	- "nearest_customer_bridge"
	- "nearest_nontpmr_bridge"

So lldpad.conf will look similar like

	lldp {
		...
	}
	nearest_customer_bridge {
		...
	}
	nearest_nontmpr_bridge {
		...
	}

It also introduces a new lldptool parameter -g <agent>. Valid values for
<agent> are

	- "nearest_bridge" or "nb"
	- "nearest_customer_bridge" or "ncb"
	- "neareast_nontpmr_bridge" or "nntpmrb"

E.g. to enable the evbCfg TLV for the agent "nearest customer bridge" one
would use

	"lldptool -T -i eth8 -g ncb -V evbCfg -c enableTx=yes"

If no -g parameter is specified, this is assumed to remain "nearest bridge"
to preserve the existing behaviour.

It modifies the lldp_mod_* functions to supply the agent where appropriate.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
---
 config.c            |  183 +++++++++++++-------------------------
 include/config.h    |   54 +++++------
 include/lldp_dcbx.h |    2 +-
 lldp/agent.c        |   18 ++++-
 lldp/agent.h        |    2 +
 lldp/ports.c        |   10 ++-
 lldp/ports.h        |    2 +-
 lldp_8021qaz.c      |   45 +++++-----
 lldp_8021qaz_cmds.c |   33 ++++---
 lldp_8023.c         |   64 ++++++++-----
 lldp_8023_cmds.c    |   12 ++-
 lldp_basman.c       |   69 +++++++++------
 lldp_basman_cmds.c  |   21 +++--
 lldp_dcbx.c         |   29 +++---
 lldp_dcbx_cmds.c    |   15 ++--
 lldp_evb.c          |  246 +++++++++++++++++++++++++--------------------------
 lldp_evb_cmds.c     |   29 ++++--
 lldp_mand.c         |   34 ++++---
 lldp_mand_cmds.c    |    6 +-
 lldp_med.c          |  118 +++++++++++++++----------
 lldp_med_cmds.c     |   61 +++++++------
 lldp_vdp.c          |    6 +-
 lldp_vdp_cmds.c     |   10 ++-
 lldptool.c          |   26 +++++-
 lldptool_cmds.c     |    4 +-
 25 files changed, 574 insertions(+), 525 deletions(-)

diff --git a/config.c b/config.c
index 03e5c1a..d90db7e 100644
--- a/config.c
+++ b/config.c
@@ -432,7 +432,7 @@ static int lookup_config_value(char *path, void *value, int type)
 
 
 /*
- * get_config_setting_by_agent - get the setting from the given config file path by type
+ * get_config_setting - get the setting from the given config file path by type
  * @ifname: interface name
  * @agenttype: type of agent this needs to be retrieved from
  * @path: relative to LLDP_COMMON or ifname section of LLDP configuration.
@@ -443,96 +443,32 @@ static int lookup_config_value(char *path, void *value, int type)
  *
  * This function assumes init_cfg() has been called.
  */
-int get_config_setting_by_agent(const char *ifname, int agenttype, char *path,
+int get_config_setting(const char *ifname, int agenttype, char *path,
 				void *value, int type)
 {
 	char p[1024];
 	int rval = CONFIG_FALSE;
+	const char *section = agent_type2section(agenttype);
 
-	/* look for setting in ifname areas first */
-	if (ifname) {
-		switch(agenttype) {
-		case NEAREST_BRIDGE:
-			snprintf(p, sizeof(p), "%s.%s.%s",
-				 LLDP_SETTING, ifname, path);
-			rval = lookup_config_value(p, value, type);
-			if (rval == CONFIG_FALSE) {
-				snprintf(p, sizeof(p), "%s.%s.%s",
-					 LLDP_NB, ifname, path);
-			}
-			break;
-		case NEAREST_CUSTOMER_BRIDGE:
-			snprintf(p, sizeof(p), "%s.%s.%s",
-				 LLDP_NCB, ifname, path);
-			break;
-		case NEAREST_NONTPMR_BRIDGE:
-			snprintf(p, sizeof(p), "%s.%s.%s",
-				 LLDP_NNTPB, ifname, path);
-			break;
-		}
-		rval = lookup_config_value(p, value, type);
-	}
-
-	/* if not found look for setting in common area */
-	if (rval == CONFIG_FALSE) {
-		switch(agenttype) {
-		case NEAREST_BRIDGE:
-			snprintf(p, sizeof(p), "%s.%s.%s",
-				 LLDP_SETTING, LLDP_COMMON, path);
-			rval = lookup_config_value(p, value, type);
-			if (rval == CONFIG_FALSE) {
-				snprintf(p, sizeof(p), "%s.%s.%s",
-					 LLDP_NB, LLDP_COMMON, path);
-			}
-			break;
-		case NEAREST_CUSTOMER_BRIDGE:
-			snprintf(p, sizeof(p), "%s.%s.%s",
-				 LLDP_NCB, LLDP_COMMON, path);
-			break;
-		case NEAREST_NONTPMR_BRIDGE:
-			snprintf(p, sizeof(p), "%s.%s.%s",
-				 LLDP_NNTPB, LLDP_COMMON, path);
-			break;
-		}
-		rval = lookup_config_value(p, value, type);
-	}
-
-	return (rval == CONFIG_FALSE) ? cmd_failed : cmd_success;
-}
-
-/*
- * get_config_setting - get the setting from the given config file path by type
- * @ifname: interface name
- * @path: relative to LLDP_COMMON or ifname section of LLDP configuration.
- * @value: pointer to the value to be retrieved
- * @type: libconfig value types
- *
- * Returns cmd_success(0) for success, otherwise for failure.
- *
- * This function assumes init_cfg() has been called.
- */
-int get_config_setting(const char *ifname, char *path, void *value, int type)
-{
-	char p[1024];
-	int rval = CONFIG_FALSE;
-
-	/* look for setting in ifname area first */
+	/* look for setting in section->ifname area first */
 	if (ifname) {
 		snprintf(p, sizeof(p), "%s.%s.%s",
-			 LLDP_SETTING, ifname, path);
+			 section, ifname, path);
 		rval = lookup_config_value(p, value, type);
 	}
 
-	/* if not found look for setting in common area */
+	/* if not found look for setting in section->common area */
 	if (rval == CONFIG_FALSE) {
 		snprintf(p, sizeof(p), "%s.%s.%s",
-			 LLDP_SETTING, LLDP_COMMON, path);
+			 section, LLDP_COMMON, path);
 		rval = lookup_config_value(p, value, type);
 	}
+
 	return (rval == CONFIG_FALSE) ? cmd_failed : cmd_success;
 }
 
-int remove_config_setting(const char *ifname, char *parent, char *name)
+int remove_config_setting(const char *ifname, int agenttype, char *parent,
+			  char *name)
 {
 	char p[1024];
 	int rval = CONFIG_FALSE;
@@ -565,10 +501,10 @@ int remove_config_setting(const char *ifname, char *parent, char *name)
 }
 
 /* calling get_config_setting() w/ init_cfg()/destroy_cfg() */
-int get_cfg(const char *ifname, char *path, void *value, int type)
+int get_cfg(const char *ifname, int agenttype, char *path, void *value, int type)
 {
 	int rval;
-	rval = get_config_setting(ifname, path, value, type);
+	rval = get_config_setting(ifname, agenttype, path, value, type);
 	return rval;
 }
 
@@ -623,18 +559,22 @@ config_setting_t *find_or_create_setting(char *p, int type)
  *
  * This function assumes init_cfg() has been called.
  */
-int set_config_setting(const char *ifname, char *path, void *value, int type)
+int set_config_setting(const char *ifname, int agenttype, char *path,
+		       void *value, int type)
 {
 	config_setting_t *setting = NULL;
 	char p[1024];
 	int rval = cmd_success;
+	const char *section = agent_type2section(agenttype);
+
+	LLDPAD_DBG("%s(%i): \n", __func__, __LINE__);
 
 	if (strlen(ifname))
 		snprintf(p, sizeof(p), "%s.%s.%s",
-			 LLDP_SETTING, ifname, path);
+			 section, ifname, path);
 	else
 		snprintf(p, sizeof(p), "%s.%s.%s",
-			 LLDP_SETTING, LLDP_COMMON, path);
+			 section, LLDP_COMMON, path);
 	setting = find_or_create_setting(p, type);
 
 	if (setting) {
@@ -648,10 +588,11 @@ int set_config_setting(const char *ifname, char *path, void *value, int type)
 	return rval;
 }
 
-int set_cfg(const char *ifname, char *path, void *value, int type)
+int set_cfg(const char *ifname, int agenttype, char *path, void *value,
+	    int type)
 {
 	int rval = cmd_failed;
-	rval = set_config_setting(ifname, path, value, type);
+	rval = set_config_setting(ifname, agenttype, path, value, type);
 	return rval;
 }
 
@@ -667,14 +608,14 @@ int set_cfg(const char *ifname, char *path, void *value, int type)
  *
  * Note: must have called init_cfg() before calling this.
  */
-int get_config_tlvfield(const char *ifname, u32 tlvid, const char *field, void *val, int type)
+int get_config_tlvfield(const char *ifname, int agenttype, u32 tlvid, const char *field, void *val, int type)
 {
 	int rc;
 	char path[256];
 
 	memset(path, 0, sizeof(path));
 	rc = snprintf(path, sizeof(path), "tlvid%08x.%s", tlvid, field);
-	if (get_config_setting(ifname, path, val, type)) {
+	if (get_config_setting(ifname, agenttype, path, val, type)) {
 		rc = EIO;
 		goto out_err;
 	}
@@ -685,75 +626,75 @@ out_err:
 }
 
 /* libconfig uses long for int */
-int get_config_tlvfield_int(const char *ifname, u32 tlvid, const char *field, int *value)
+int get_config_tlvfield_int(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value)
 {
 	int rc = 0;
 	long int val = (long int) *value;
 
-	rc = get_config_tlvfield(ifname, tlvid, field, &val, CONFIG_TYPE_INT);
+	rc = get_config_tlvfield(ifname, agenttype, tlvid, field, &val, CONFIG_TYPE_INT);
 	*value = (int) val;
 	return rc;
 }
 
-int get_config_tlvfield_bool(const char *ifname, u32 tlvid, const char *field, int *value)
+int get_config_tlvfield_bool(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value)
 {
-	return get_config_tlvfield(ifname, tlvid, field, value, CONFIG_TYPE_BOOL);
+	return get_config_tlvfield(ifname, agenttype, tlvid, field, value, CONFIG_TYPE_BOOL);
 }
 
-int get_config_tlvfield_bin(const char *ifname, u32 tlvid, const char *field, void *value, size_t size)
+int get_config_tlvfield_bin(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size)
 {
 	int rc = 0;
 	char *str = NULL;
 
-	rc = get_config_tlvfield(ifname, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
+	rc = get_config_tlvfield(ifname, agenttype, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
 	if ((rc == 0) && (str != NULL))
 		rc = hexstr2bin(str, value, size);
 	return rc;
 }
 
-int get_config_tlvfield_str(const char *ifname, u32 tlvid, const char *field, void *value, size_t size)
+int get_config_tlvfield_str(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size)
 {
 	int rc = 0;
 	char *str = NULL;
 
-	rc = get_config_tlvfield(ifname, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
+	rc = get_config_tlvfield(ifname, agenttype, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
 	if ((rc == 0) && (str != NULL))
 		strncpy(value, str, size);
 	return rc;
 }
 
-int get_config_tlvinfo_bin(const char *ifname, u32 tlvid, void *value, size_t size)
+int get_config_tlvinfo_bin(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size)
 {
-	return	get_config_tlvfield_bin(ifname, tlvid, ARG_TLVINFO, value, size);
+	return	get_config_tlvfield_bin(ifname, agenttype, tlvid, ARG_TLVINFO, value, size);
 }
 
-int get_config_tlvinfo_str(const char *ifname, u32 tlvid, void *value, size_t size)
+int get_config_tlvinfo_str(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size)
 {
-	return	get_config_tlvfield_str(ifname, tlvid, ARG_TLVINFO, value, size);
+	return	get_config_tlvfield_str(ifname, agenttype, tlvid, ARG_TLVINFO, value, size);
 }
 
-int set_config_tlvfield(const char *ifname, u32 tlvid, const char *field, void *val, int type)
+int set_config_tlvfield(const char *ifname, int agenttype, u32 tlvid, const char *field, void *val, int type)
 {
 	char path[256];
 
 	memset(path, 0, sizeof(path));
 	snprintf(path, sizeof(path), "tlvid%08x.%s", tlvid, field);
-	return set_config_setting(ifname, path, val, type);
+	return set_config_setting(ifname, agenttype, path, val, type);
 }
 
-int set_config_tlvfield_str(const char *ifname, u32 tlvid, const char *field, void *value, size_t size)
+int set_config_tlvfield_str(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size)
 {
 	int rc = EINVAL;
 	char *str = NULL;
 
 	if (value) {
 		str = (char *)value;
-		rc = set_config_tlvfield(ifname, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
+		rc = set_config_tlvfield(ifname, agenttype, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
 	}
 	return rc;
 }
 
-int set_config_tlvfield_bin(const char *ifname, u32 tlvid, const char *field, void *value, size_t size)
+int set_config_tlvfield_bin(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size)
 {
 	int rc = EINVAL;
 	char *str = NULL;
@@ -772,35 +713,35 @@ int set_config_tlvfield_bin(const char *ifname, u32 tlvid, const char *field, vo
 	if (rc)
 		goto out_free;
 	str[bsize - 1] = '\0';
-	rc = set_config_tlvfield(ifname, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
+	rc = set_config_tlvfield(ifname, agenttype, tlvid, field, (void *)&str, CONFIG_TYPE_STRING);
 out_free:
 	free(str);
 out_err:
 	return rc;
 }
 
-int set_config_tlvinfo_bin(const char *ifname, u32 tlvid, void *value, size_t size)
+int set_config_tlvinfo_bin(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size)
 {
-	return	set_config_tlvfield_bin(ifname, tlvid, "info", value, size);
+	return	set_config_tlvfield_bin(ifname, agenttype, tlvid, "info", value, size);
 }
 
-int set_config_tlvinfo_str(const char *ifname, u32 tlvid, void *value, size_t size)
+int set_config_tlvinfo_str(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size)
 {
-	return	set_config_tlvfield_str(ifname, tlvid, "info", value, size);
+	return	set_config_tlvfield_str(ifname, agenttype, tlvid, "info", value, size);
 }
 
-int set_config_tlvfield_int(const char *ifname, u32 tlvid, const char *field, int *value)
+int set_config_tlvfield_int(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value)
 {
 	long int val = (long int )*value;
-	return set_config_tlvfield(ifname, tlvid, field, &val, CONFIG_TYPE_INT);
+	return set_config_tlvfield(ifname, agenttype, tlvid, field, &val, CONFIG_TYPE_INT);
 }
 
-int set_config_tlvfield_bool(const char *ifname, u32 tlvid, const char *field, int *value)
+int set_config_tlvfield_bool(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value)
 {
-	return set_config_tlvfield(ifname, tlvid, field, value, CONFIG_TYPE_BOOL);
+	return set_config_tlvfield(ifname, agenttype, tlvid, field, value, CONFIG_TYPE_BOOL);
 }
 
-int is_tlv_txdisabled(const char *ifname, u32 tlvid)
+int is_tlv_txdisabled(const char *ifname, int agenttype, u32 tlvid)
 {
 	char arg[64];
 	int enabletx = true;
@@ -808,12 +749,12 @@ int is_tlv_txdisabled(const char *ifname, u32 tlvid)
 	snprintf(arg, sizeof(arg), "%s%08x.%s", TLVID_PREFIX,
 		 tlvid, ARG_TLVTXENABLE);
 
-	get_config_setting(ifname, arg, (void *)&enabletx, CONFIG_TYPE_BOOL);
+	get_config_setting(ifname, agenttype, arg, (void *)&enabletx, CONFIG_TYPE_BOOL);
 
 	return !enabletx;
 }
 
-int is_tlv_txenabled(const char *ifname, u32 tlvid)
+int is_tlv_txenabled(const char *ifname, int agenttype, u32 tlvid)
 {
 	char arg[64];
 	int enabletx = false;
@@ -821,38 +762,38 @@ int is_tlv_txenabled(const char *ifname, u32 tlvid)
 	snprintf(arg, sizeof(arg), "%s%08x.%s", TLVID_PREFIX,
 		 tlvid, ARG_TLVTXENABLE);
 
-	get_config_setting(ifname, arg, (void *)&enabletx, CONFIG_TYPE_BOOL);
+	get_config_setting(ifname, agenttype, arg, (void *)&enabletx, CONFIG_TYPE_BOOL);
 
 	return enabletx;
 }
 
-int tlv_enabletx(const char *ifname, u32 tlvid)
+int tlv_enabletx(const char *ifname, int agenttype, u32 tlvid)
 {
 	int enabletx = true;
-	return set_config_tlvfield_bool(ifname, tlvid,
+	return set_config_tlvfield_bool(ifname, agenttype, tlvid,
 					ARG_TLVTXENABLE, (void *)&enabletx);
 }
 
-int tlv_disabletx(const char *ifname, u32 tlvid)
+int tlv_disabletx(const char *ifname, int agenttype, u32 tlvid)
 {
 	int enabletx = false;
-	return set_config_tlvfield_bool(ifname, tlvid,
+	return set_config_tlvfield_bool(ifname, agenttype, tlvid,
 					ARG_TLVTXENABLE, (void *)&enabletx);
 }
 
-void set_med_devtype(const char *ifname, int devtype)
+void set_med_devtype(const char *ifname, int agenttype, int devtype)
 {
 	if (LLDP_MED_DEVTYPE_INVALID(devtype))
 		return;
-	set_config_tlvfield_int(ifname, TLVID_MED(LLDP_MED_RESERVED),
+	set_config_tlvfield_int(ifname, agenttype, TLVID_MED(LLDP_MED_RESERVED),
 				"devtype", &devtype);
 }
 
-int get_med_devtype(const char *ifname)
+int get_med_devtype(const char *ifname, int agenttype)
 {
 	int devtype;
 
-	get_config_tlvfield_int(ifname, TLVID_MED(LLDP_MED_RESERVED),
+	get_config_tlvfield_int(ifname, agenttype, TLVID_MED(LLDP_MED_RESERVED),
 				"devtype", &devtype);
 	return devtype;
 }
diff --git a/include/config.h b/include/config.h
index 553149d..12acb2c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -33,9 +33,6 @@
 #define DEFAULT_CFG_FILE "/var/lib/lldpad/lldpad.conf"
 
 #define LLDP_SETTING	"lldp"
-#define LLDP_NB		"nearest_bridge"
-#define LLDP_NCB	"nearest_customer_bridge"
-#define LLDP_NNTPB	"nearest_nontpmr_bridge"
 #define LLDP_COMMON	"common"
 
 #define INI_TIMER	5
@@ -50,32 +47,31 @@
 extern char *cfg_file_name;
 
 void scan_port(void *eloop_data, void *user_ctx);
-int get_cfg(const char *ifname, char *path, void *value, int type);
-int set_cfg(const char *ifname, char *path, void *value, int type);
-int get_config_setting(const char *ifname, char *path, void *value, int type);
-int get_config_setting_by_agent(const char *ifname, int agenttype, char *path, void *value, int type);
-int set_config_setting(const char *ifname, char *path, void *value, int type);
-int remove_config_setting(const char *ifname, char *parent, char *name);
-int get_config_tlvfield(const char *ifname, u32 tlvid, const char *field, void *value, int type);
-int get_config_tlvfield_int(const char *ifname, u32 tlvid, const char *field, int *value);
-int get_config_tlvfield_bool(const char *ifname, u32 tlvid, const char *field, int *value);
-int get_config_tlvfield_bin(const char *ifname, u32 tlvid, const char *field, void *value, size_t size);
-int get_config_tlvfield_str(const char *ifname, u32 tlvid, const char *field, void *value, size_t size);
-int get_config_tlvinfo_bin(const char *ifname, u32 tlvid, void *value, size_t size);
-int get_config_tlvinfo_str(const char *ifname, u32 tlvid, void *value, size_t size);
-int set_config_tlvfield(const char *ifname, u32 tlvid, const char *field, void *value, int type);
-int set_config_tlvfield_int(const char *ifname, u32 tlvid, const char *field, int *value);
-int set_config_tlvfield_bool(const char *ifname, u32 tlvid, const char *field, int *value);
-int set_config_tlvfield_bin(const char *ifname, u32 tlvid, const char *field, void *value, size_t size);
-int set_config_tlvfield_str(const char *ifname, u32 tlvid, const char *field, void *value, size_t size);
-int set_config_tlvinfo_bin(const char *ifname, u32 tlvid, void *value, size_t size);
-int set_config_tlvinfo_str(const char *ifname, u32 tlvid, void *value, size_t size);
-int is_tlv_txdisabled(const char *ifname, u32 tlvid);
-int is_tlv_txenabled(const char *ifname, u32 tlvid);
-int tlv_enabletx(const char *ifname, u32 tlvid);
-int tlv_disabletx(const char *ifname, u32 tlvid);
-int get_med_devtype(const char *ifname);
-void set_med_devtype(const char *ifname, int devtype);
+int get_cfg(const char *ifname, int agenttype, char *path, void *value, int type);
+int set_cfg(const char *ifname, int agenttype, char *path, void *value, int type);
+int get_config_setting(const char *ifname, int agenttype, char *path, void *value, int type);
+int set_config_setting(const char *ifname, int agenttype, char *path, void *value, int type);
+int remove_config_setting(const char *ifname, int agenttype, char *parent, char *name);
+int get_config_tlvfield(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, int type);
+int get_config_tlvfield_int(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value);
+int get_config_tlvfield_bool(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value);
+int get_config_tlvfield_bin(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size);
+int get_config_tlvfield_str(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size);
+int get_config_tlvinfo_bin(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size);
+int get_config_tlvinfo_str(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size);
+int set_config_tlvfield(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, int type);
+int set_config_tlvfield_int(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value);
+int set_config_tlvfield_bool(const char *ifname, int agenttype, u32 tlvid, const char *field, int *value);
+int set_config_tlvfield_bin(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size);
+int set_config_tlvfield_str(const char *ifname, int agenttype, u32 tlvid, const char *field, void *value, size_t size);
+int set_config_tlvinfo_bin(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size);
+int set_config_tlvinfo_str(const char *ifname, int agenttype, u32 tlvid, void *value, size_t size);
+int is_tlv_txdisabled(const char *ifname, int agenttype, u32 tlvid);
+int is_tlv_txenabled(const char *ifname, int agenttype, u32 tlvid);
+int tlv_enabletx(const char *ifname, int agenttype, u32 tlvid);
+int tlv_disabletx(const char *ifname, int agenttype, u32 tlvid);
+int get_med_devtype(const char *ifname, int agenttype);
+void set_med_devtype(const char *ifname, int agenttype, int devtype);
 
 void create_default_cfg_file(void);
 int get_int_config(config_setting_t *s, char *attr, int int_type, int *result);
diff --git a/include/lldp_dcbx.h b/include/lldp_dcbx.h
index e7a69e8..4c12c6a 100644
--- a/include/lldp_dcbx.h
+++ b/include/lldp_dcbx.h
@@ -76,7 +76,7 @@ struct dcbx_tlvs *dcbx_data(const char *);
 }
 #endif
 
-int dcbx_tlvs_rxed(const char *ifname);
+int dcbx_tlvs_rxed(const char *ifname, struct lldp_agent *);
 int dcbx_check_active(const char *ifname);
 int dcbx_get_legacy_version();
 
diff --git a/lldp/agent.c b/lldp/agent.c
index 0bb0107..7eadeda 100644
--- a/lldp/agent.c
+++ b/lldp/agent.c
@@ -42,6 +42,12 @@ static const u8 * agent_groupmacs[AGENT_MAX] = {
 	nearest_customer_bridge,
 };
 
+static const char *agent_sections[AGENT_MAX] = {
+	[NEAREST_BRIDGE] = "nearest_bridge",
+	[NEAREST_NONTPMR_BRIDGE] = "nearest_nontpmr_bridge",
+	[NEAREST_CUSTOMER_BRIDGE] = "nearest_customer_bridge",
+};
+
 struct lldp_agent *lldp_agent_find_by_type(const char *ifname, int type)
 {
 	struct port *port;
@@ -60,6 +66,14 @@ struct lldp_agent *lldp_agent_find_by_type(const char *ifname, int type)
 	return NULL;
 }
 
+const char *agent_type2section(int agenttype)
+{
+	if ((agenttype > NEAREST_BRIDGE) && (agenttype < AGENT_MAX))
+		return agent_sections[agenttype];
+	else
+		return LLDP_SETTING;
+}
+
 void lldp_init_agent(struct port *port, struct lldp_agent *agent, int type)
 {
 	char macstring[30];
@@ -77,7 +91,7 @@ void lldp_init_agent(struct port *port, struct lldp_agent *agent, int type)
 	agent->rx.state = LLDP_WAIT_PORT_OPERATIONAL;
 	agent->type = type;
 
-	if (get_config_setting_by_agent(port->ifname, type, ARG_ADMINSTATUS,
+	if (get_config_setting(port->ifname, type, ARG_ADMINSTATUS,
 			(void *)&agent->adminStatus, CONFIG_TYPE_INT)) {
 		LLDPAD_DBG("%s: agent->adminStatus = disabled.\n", __func__);
 		agent->adminStatus = disabled;
@@ -124,7 +138,7 @@ int lldp_add_agent(const char *ifname, int type)
 
 	lldp_init_agent(port, newagent, type);
 
-	if (get_config_setting_by_agent(ifname, newagent->type, ARG_ADMINSTATUS,
+	if (get_config_setting(ifname, newagent->type, ARG_ADMINSTATUS,
 			(void *)&newagent->adminStatus, CONFIG_TYPE_INT))
 			newagent->adminStatus = disabled;
 
diff --git a/lldp/agent.h b/lldp/agent.h
index 59bf650..36b227c 100644
--- a/lldp/agent.h
+++ b/lldp/agent.h
@@ -158,6 +158,8 @@ void set_lldp_agent_admin(const char *ifname, int type, int enable);
 int get_lldp_agent_admin(const char *ifname, int type);
 int get_lldp_agent_statistics(const char *ifname, struct agentstats *, int);
 
+const char *agent_type2section(int agenttype);
+
 int start_lldp_agents(void);
 void stop_lldp_agents(void);
 void clean_lldp_agents(void);
diff --git a/lldp/ports.c b/lldp/ports.c
index 10eecd8..f40c04e 100644
--- a/lldp/ports.c
+++ b/lldp/ports.c
@@ -40,6 +40,7 @@
 #include "lldp_rtnl.h"
 #include "lldp_dcbx_nl.h"
 #include "agent.h"
+#include "lldp_dcbx_nl.h"
 
 struct port *porthead = NULL; /* port Head pointer */
 
@@ -136,9 +137,10 @@ void set_lldp_agent_admin(const char *ifname, int type, int admin)
 			 * on a global setting change
 			 */
 			if (all && (!get_config_setting(port->ifname,
-						      ARG_ADMINSTATUS,
-			                             (void *)&tmp,
-						      CONFIG_TYPE_INT))) {
+							type,
+							ARG_ADMINSTATUS,
+							(void *)&tmp,
+							CONFIG_TYPE_INT))) {
 				port = port->next;
 				continue;
 			}
@@ -320,7 +322,7 @@ fail:
 	return NULL;
 }
 
-int remove_port(const char *ifname)
+int remove_port(char *ifname)
 {
 	struct port *port = NULL;    /* Pointer to port to remove */
 	struct port *parent = NULL;  /* Pointer to previous on port stack */
diff --git a/lldp/ports.h b/lldp/ports.h
index 845e40f..2f429ad 100644
--- a/lldp/ports.h
+++ b/lldp/ports.h
@@ -96,7 +96,7 @@ extern struct port *porthead;
 extern "C" {
 #endif
 struct port *add_port(const char *);
-int remove_port(const char *);
+int remove_port(char *);
 #ifdef __cplusplus
 }
 #endif
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
index ca4bd93..2436fa1 100644
--- a/lldp_8021qaz.c
+++ b/lldp_8021qaz.c
@@ -208,7 +208,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	/* Read ETS-CFG willing bit -- default willing enabled */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_ETSCFG), ARG_WILLING);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &willing,
+	res = get_config_setting(ifname, agent->type, arg_path, &willing,
 				 CONFIG_TYPE_INT);
 	if (!res)
 		tlvs->ets->cfgl->willing = !!willing;
@@ -218,7 +218,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	/* Read PFC willing bit -- default willing enabled */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_PFC), ARG_WILLING);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &willing,
+	res = get_config_setting(ifname, agent->type, arg_path, &willing,
 				 CONFIG_TYPE_INT);
 	if (!res)
 		tlvs->pfc->local.willing = !!willing;
@@ -230,7 +230,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_ETSCFG), ARG_ETS_UP2TC);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &arg,
+	res = get_config_setting(ifname, agent->type, arg_path, &arg,
 				 CONFIG_TYPE_STRING);
 	if (!res)
 		set_ets_prio_map(arg, &tlvs->ets->cfgl->prio_map);
@@ -243,7 +243,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_ETSREC), ARG_ETS_UP2TC);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &arg,
+	res = get_config_setting(ifname, agent->type, arg_path, &arg,
 				 CONFIG_TYPE_STRING);
 	if (!res)
 		set_ets_prio_map(arg, &tlvs->ets->recl->prio_map);
@@ -255,7 +255,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_ETSCFG), ARG_ETS_TCBW);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &arg,
+	res = get_config_setting(ifname, agent->type, arg_path, &arg,
 				 CONFIG_TYPE_STRING);
 	if (!res) {
 		char *argcpy = strdup(arg);
@@ -277,7 +277,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_ETSREC), ARG_ETS_TCBW);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &arg,
+	res = get_config_setting(ifname, agent->type, arg_path, &arg,
 				 CONFIG_TYPE_STRING);
 	if (!res) {
 		char *argcpy = strdup(arg);
@@ -303,7 +303,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	for (i = 0x80, numtcs = 8; i > 0; i = i>>1, numtcs--)
 		if (i & dcb_support->traffic_classes)
 			break;
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &numtcs,
+	res = get_config_setting(ifname, agent->type, arg_path, &numtcs,
 				 CONFIG_TYPE_INT);
 	tlvs->ets->cfgl->max_tcs = numtcs;
 
@@ -312,7 +312,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_ETSCFG), ARG_ETS_TSA);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &arg,
+	res = get_config_setting(ifname, agent->type, arg_path, &arg,
 				 CONFIG_TYPE_STRING);
 	if (!res) {
 		set_ets_tsa_map(arg, tlvs->ets->cfgl->tsa_map);
@@ -326,7 +326,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_ETSREC), ARG_ETS_TSA);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &arg,
+	res = get_config_setting(ifname, agent->type, arg_path, &arg,
 				 CONFIG_TYPE_STRING);
 	if (!res) {
 		set_ets_tsa_map(arg, tlvs->ets->recl->tsa_map);
@@ -338,7 +338,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	/* Read and parse PFC enable bitmask -- default 0x00 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_PFC), ARG_PFC_ENABLED);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &pfc_mask,
+	res = get_config_setting(ifname, agent->type, arg_path, &pfc_mask,
 				 CONFIG_TYPE_INT);
 	if (!res)
 		tlvs->pfc->local.pfc_enable = pfc_mask;
@@ -346,7 +346,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	/* Read and parse PFC delay -- default 0x00 */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 TLVID_8021(LLDP_8021QAZ_PFC), ARG_PFC_DELAY);
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &delay,
+	res = get_config_setting(ifname, agent->type, arg_path, &delay,
 				 CONFIG_TYPE_INT);
 	if (!res)
 		tlvs->pfc->local.delay = delay;
@@ -360,7 +360,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 	for (i = 0x80, numtcs = 8; i > 0; i = i>>1, numtcs--)
 		if (i & dcb_support->pfc_traffic_classes)
 			break;
-	res = get_config_setting_by_agent(ifname, agent->type, arg_path, &numtcs,
+	res = get_config_setting(ifname, agent->type, arg_path, &numtcs,
 				 CONFIG_TYPE_INT);
 	tlvs->pfc->local.pfc_cap = numtcs;
 
@@ -373,7 +373,7 @@ static int read_cfg_file(char *ifname, struct lldp_agent *agent,
 
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s%i", TLVID_PREFIX,
 			 TLVID_8021(LLDP_8021QAZ_APP), ARG_APP, i);
-		res = get_config_setting_by_agent(ifname, agent->type, arg_path, &arg,
+		res = get_config_setting(ifname, agent->type, arg_path, &arg,
 					 CONFIG_TYPE_STRING);
 
 		if (res)
@@ -464,7 +464,7 @@ void ieee8021qaz_ifup(char *ifname, struct lldp_agent *agent)
 	/* if there is no persistent adminStatus setting then set to enabledRx
 	 * but do not persist that as a setting.
 	 */
-	if (get_config_setting_by_agent(ifname, agent->type, ARG_ADMINSTATUS,
+	if (get_config_setting(ifname, agent->type, ARG_ADMINSTATUS,
 			       (void *)&adminstatus, CONFIG_TYPE_INT)) {
 		set_lldp_agent_admin(ifname, agent->type, enabledRxOnly);
 	}
@@ -1020,7 +1020,7 @@ void run_all_sm(struct port *port, struct lldp_agent *agent)
 	if (!tlvs)
 		return;
 
-	if (!is_tlv_txdisabled(port->ifname, TLVID_8021(LLDP_8021QAZ_ETSCFG))) {
+	if (!is_tlv_txdisabled(port->ifname, agent->type, TLVID_8021(LLDP_8021QAZ_ETSCFG))) {
 		ets_sm(tlvs->ets->cfgl, tlvs->ets->recr,
 		       &tlvs->ets->current_state);
 	}
@@ -1039,7 +1039,7 @@ void run_all_sm(struct port *port, struct lldp_agent *agent)
 	else
 		ets_cfg_to_ieee(ets, tlvs->ets->cfgl);
 
-	if (!is_tlv_txdisabled(port->ifname, TLVID_8021(LLDP_8021QAZ_PFC)))
+	if (!is_tlv_txdisabled(port->ifname, agent->type, TLVID_8021(LLDP_8021QAZ_PFC)))
 		pfc_sm(tlvs);
 
 	if (tlvs->pfc->current_state == RX_RECOMMEND)
@@ -1314,13 +1314,13 @@ static struct packed_tlv *ieee8021qaz_bld_tlv(struct port *port,
 	if (!data->active)
 		return ptlv;
 
-	if (!is_tlv_txdisabled(port->ifname, TLVID_8021(LLDP_8021QAZ_ETSCFG)))
+	if (!is_tlv_txdisabled(port->ifname, agent->type, TLVID_8021(LLDP_8021QAZ_ETSCFG)))
 		etscfg_tlv = bld_ieee8021qaz_etscfg_tlv(data);
-	if (is_tlv_txenabled(port->ifname, TLVID_8021(LLDP_8021QAZ_ETSREC)))
+	if (is_tlv_txenabled(port->ifname, agent->type, TLVID_8021(LLDP_8021QAZ_ETSREC)))
 		etsrec_tlv = bld_ieee8021qaz_etsrec_tlv(data);
-	if (!is_tlv_txdisabled(port->ifname, TLVID_8021(LLDP_8021QAZ_PFC)))
+	if (!is_tlv_txdisabled(port->ifname, agent->type, TLVID_8021(LLDP_8021QAZ_PFC)))
 		pfc_tlv = bld_ieee8021qaz_pfc_tlv(data);
-	if (is_tlv_txenabled(port->ifname, TLVID_8021(LLDP_8021QAZ_APP)))
+	if (is_tlv_txenabled(port->ifname, agent->type, TLVID_8021(LLDP_8021QAZ_APP)))
 		app_tlv = bld_ieee8021qaz_app_tlv(port->ifname);
 
 	size = TLVSIZE(etscfg_tlv)
@@ -1768,7 +1768,7 @@ int ieee8021qaz_rchange(struct port *port, struct lldp_agent *agent,
 
 	if (tlv->type == TYPE_0) {
 		if (qaz_tlvs->active &&
-		    dcbx_tlvs_rxed(qaz_tlvs->ifname) &&
+		    dcbx_tlvs_rxed(qaz_tlvs->ifname, agent) &&
 		   !qaz_tlvs->ieee8021qazdu) {
 			qaz_tlvs->active = false;
 			LLDPAD_INFO("IEEE DCBX on %s going INACTIVE\n",
@@ -1782,7 +1782,7 @@ int ieee8021qaz_rchange(struct port *port, struct lldp_agent *agent,
 			 */
 			long adminstatus;
 			if (qaz_tlvs->ieee8021qazdu &&
-				get_config_setting_by_agent(qaz_tlvs->ifname,
+				get_config_setting(qaz_tlvs->ifname,
 						   agent->type,
 						   ARG_ADMINSTATUS,
 						   (void *)&adminstatus,
@@ -1792,6 +1792,7 @@ int ieee8021qaz_rchange(struct port *port, struct lldp_agent *agent,
 						    enabledRxOnly) {
 				adminstatus = enabledRxTx;
 				if (set_config_setting(qaz_tlvs->ifname,
+						       agent->type,
 						       ARG_ADMINSTATUS,
 						      (void *)&adminstatus,
 						       CONFIG_TYPE_INT) ==
diff --git a/lldp_8021qaz_cmds.c b/lldp_8021qaz_cmds.c
index 1a64c24..5a44f84 100644
--- a/lldp_8021qaz_cmds.c
+++ b/lldp_8021qaz_cmds.c
@@ -199,7 +199,8 @@ static int _set_arg_willing(struct cmd *cmd, char *args,
 
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, args);
-	set_config_setting(cmd->ifname, arg_path, &willing, CONFIG_TYPE_INT);
+	set_config_setting(cmd->ifname, cmd->type, arg_path, &willing,
+			   CONFIG_TYPE_INT);
 	somethingChangedLocal(cmd->ifname, cmd->type);
 
 	return cmd_success;
@@ -382,7 +383,7 @@ static int _set_arg_up2tc(struct cmd *cmd, char *args,
 	/* Update configuration file with new attribute */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, args);
-	set_config_setting(cmd->ifname, arg_path, &arg_value,
+	set_config_setting(cmd->ifname, cmd->type, arg_path, &arg_value,
 			   CONFIG_TYPE_STRING);
 	somethingChangedLocal(cmd->ifname, cmd->type);
 invalid:
@@ -509,7 +510,7 @@ static int _set_arg_tcbw(struct cmd *cmd, char *args,
 
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, args);
-	set_config_setting(cmd->ifname, arg_path, &arg_value,
+	set_config_setting(cmd->ifname, cmd->type, arg_path, &arg_value,
 			   CONFIG_TYPE_STRING);
 	somethingChangedLocal(cmd->ifname, cmd->type);
 invalid:
@@ -703,7 +704,7 @@ static int _set_arg_tsa(struct cmd *cmd, char *args, char *arg_value,
 
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 		 TLVID_PREFIX, cmd->tlvid, args);
-	set_config_setting(cmd->ifname, arg_path, &arg_value,
+	set_config_setting(cmd->ifname, cmd->type, arg_path, &arg_value,
 			   CONFIG_TYPE_STRING);
 	somethingChangedLocal(cmd->ifname, cmd->type);
 invalid:
@@ -844,7 +845,8 @@ static int _set_arg_enabled(struct cmd *cmd, char *args,
 	/* Set configuration */
 	snprintf(arg_path, sizeof(arg_path),
 		 "%s%08x.%s", TLVID_PREFIX, cmd->tlvid, args);
-	set_config_setting(cmd->ifname, arg_path, &mask, CONFIG_TYPE_INT);
+	set_config_setting(cmd->ifname, cmd->type, arg_path, &mask,
+			   CONFIG_TYPE_INT);
 	tlvs->pfc->local.pfc_enable = mask;
 	somethingChangedLocal(cmd->ifname, cmd->type);
 invalid:
@@ -925,7 +927,8 @@ static int _set_arg_delay(struct cmd *cmd, char *args,
 	/* Set configuration */
 	snprintf(arg_path, sizeof(arg_path),
 		 "%s%08x.%s", TLVID_PREFIX, cmd->tlvid, args);
-	set_config_setting(cmd->ifname, arg_path, &delay, CONFIG_TYPE_INT);
+	set_config_setting(cmd->ifname, cmd->type, arg_path, &delay,
+			   CONFIG_TYPE_INT);
 
 	somethingChangedLocal(cmd->ifname, cmd->type);
 
@@ -1099,8 +1102,8 @@ static int _set_arg_app(struct cmd *cmd, char *args, char *arg_value,
 
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s%i", TLVID_PREFIX,
 			 TLVID_8021(LLDP_8021QAZ_APP), ARG_APP, i);
-		res = get_config_setting(cmd->ifname, arg_path, &dummy,
-					 CONFIG_TYPE_STRING);
+		res = get_config_setting(cmd->ifname, cmd->type, arg_path,
+					 &dummy, CONFIG_TYPE_STRING);
 
 		if (res) {
 			if (unused < 0)
@@ -1118,7 +1121,8 @@ static int _set_arg_app(struct cmd *cmd, char *args, char *arg_value,
 				snprintf(arg_name, sizeof(arg_name), "%s%i",
 					 ARG_APP, i);
 				res = remove_config_setting(cmd->ifname,
-						arg_parent, arg_name);
+						cmd->type, arg_parent,
+						arg_name);
 			}
 		}
 	}
@@ -1181,7 +1185,7 @@ static int _set_arg_app(struct cmd *cmd, char *args, char *arg_value,
 	snprintf(arg_path, sizeof(arg_path),
 		 "%s%08x.%s%i", TLVID_PREFIX, cmd->tlvid, args, unused);
 
-	set_config_setting(cmd->ifname, arg_path, &pp,
+	set_config_setting(cmd->ifname, cmd->type, arg_path, &pp,
 			   CONFIG_TYPE_STRING);
 
 	return cmd_success;
@@ -1218,7 +1222,7 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 			 TLVID_PREFIX, cmd->tlvid, arg);
 
-		if (!is_tlv_txdisabled(cmd->ifname, cmd->tlvid))
+		if (!is_tlv_txdisabled(cmd->ifname, cmd->type, cmd->tlvid))
 			value = true;
 		else
 			value = false;
@@ -1228,7 +1232,7 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 			 TLVID_PREFIX, cmd->tlvid, arg);
 
-		if (is_tlv_txenabled(cmd->ifname, cmd->tlvid))
+		if (is_tlv_txenabled(cmd->ifname, cmd->type, cmd->tlvid))
 			value = true;
 		else
 			value = false;
@@ -1281,7 +1285,7 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, ARG_TLVTXENABLE);
-	err = get_config_setting(cmd->ifname, arg_path,
+	err = get_config_setting(cmd->ifname, cmd->type, arg_path,
 				(void *)&curr, CONFIG_TYPE_BOOL);
 
 	if (test)
@@ -1295,7 +1299,8 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, arg);
 
-	if (set_cfg(cmd->ifname, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
+	if (set_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value,
+		    CONFIG_TYPE_BOOL))
 		return cmd_failed;
 
 
diff --git a/lldp_8023.c b/lldp_8023.c
index a6c2eb8..a1227ce 100644
--- a/lldp_8023.c
+++ b/lldp_8023.c
@@ -71,8 +71,8 @@ struct tlv_info_8023_powvmdi {
 } __attribute__ ((__packed__));
 
 static const struct lldp_mod_ops ieee8023_ops =  {
-	.lldp_mod_register 	= ieee8023_register,
-	.lldp_mod_unregister 	= ieee8023_unregister,
+	.lldp_mod_register	= ieee8023_register,
+	.lldp_mod_unregister	= ieee8023_unregister,
 	.lldp_mod_gettlv	= ieee8023_gettlv,
 	.lldp_mod_ifup		= ieee8023_ifup,
 	.lldp_mod_ifdown	= ieee8023_ifdown,
@@ -101,7 +101,8 @@ static struct ieee8023_data *ieee8023_data(const char *ifname, enum agent_type t
  *
  * Returns 0 on success
  */
-static int ieee8023_bld_maccfg_tlv(struct ieee8023_data *bd)
+static int ieee8023_bld_maccfg_tlv(struct ieee8023_data *bd,
+				   struct lldp_agent *agent)
 {
 	int rc = 0;
 	struct unpacked_tlv *tlv = NULL;
@@ -111,14 +112,16 @@ static int ieee8023_bld_maccfg_tlv(struct ieee8023_data *bd)
 	FREE_UNPKD_TLV(bd, maccfg);
 
 	/* mandatory for LLDP-MED */
-	if (!is_tlv_txenabled(bd->ifname, TLVID_8023(LLDP_8023_MACPHY_CONFIG_STATUS))) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type,
+			      TLVID_8023(LLDP_8023_MACPHY_CONFIG_STATUS))) {
 		goto out_err;
 	}
 
 	/* load from config */
 	memset(&maccfg, 0, sizeof(maccfg));
-	if (get_config_tlvinfo_bin(bd->ifname, TLVID_8023(LLDP_8023_MACPHY_CONFIG_STATUS),
-			       (void *)&maccfg, sizeof(maccfg))) {
+	if (get_config_tlvinfo_bin(bd->ifname, agent->type,
+				   TLVID_8023(LLDP_8023_MACPHY_CONFIG_STATUS),
+				   (void *)&maccfg, sizeof(maccfg))) {
 		hton24(maccfg.oui, OUI_IEEE_8023);
 		maccfg.sub = LLDP_8023_MACPHY_CONFIG_STATUS;
 		if (is_autoneg_supported(bd->ifname))
@@ -154,7 +157,8 @@ out_err:
  *
  * Returns 0 on success
  */
-static int ieee8023_bld_maxfs_tlv(struct ieee8023_data *bd)
+static int ieee8023_bld_maxfs_tlv(struct ieee8023_data *bd,
+				  struct lldp_agent *agent)
 {
 	int rc = 0;
 	struct unpacked_tlv *tlv = NULL;
@@ -163,13 +167,15 @@ static int ieee8023_bld_maxfs_tlv(struct ieee8023_data *bd)
 	/* free old one if it exists */
 	FREE_UNPKD_TLV(bd, maxfs);
 
-	if (!is_tlv_txenabled(bd->ifname, TLVID_8023(LLDP_8023_MAXIMUM_FRAME_SIZE))) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type,
+			      TLVID_8023(LLDP_8023_MAXIMUM_FRAME_SIZE))) {
 		goto out_err;
 	}
 
 	/* load from config */
 	memset(&maxfs, 0, sizeof(maxfs));
-	if (get_config_tlvinfo_bin(bd->ifname, TLVID_8023(LLDP_8023_MAXIMUM_FRAME_SIZE),
+	if (get_config_tlvinfo_bin(bd->ifname, agent->type,
+				   TLVID_8023(LLDP_8023_MAXIMUM_FRAME_SIZE),
 			       (void *)&maxfs, sizeof(maxfs))) {
 		hton24(maxfs.oui, OUI_IEEE_8023);
 		maxfs.sub = LLDP_8023_MAXIMUM_FRAME_SIZE;
@@ -201,7 +207,8 @@ out_err:
  *
  * Returns 0 on success
  */
-static int ieee8023_bld_linkagg_tlv(struct ieee8023_data *bd)
+static int ieee8023_bld_linkagg_tlv(struct ieee8023_data *bd,
+				    struct lldp_agent *agent)
 {
 	int rc = 0;
 	struct unpacked_tlv *tlv = NULL;
@@ -210,14 +217,16 @@ static int ieee8023_bld_linkagg_tlv(struct ieee8023_data *bd)
 	/* free old one if it exists */
 	FREE_UNPKD_TLV(bd, linkagg);
 
-	if (!is_tlv_txenabled(bd->ifname, TLVID_8023(LLDP_8023_LINK_AGGREGATION))) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type,
+			      TLVID_8023(LLDP_8023_LINK_AGGREGATION))) {
 		goto out_err;
 	}
 
 	/* load from config */
 	memset(&linkagg, 0, sizeof(linkagg));
-	if (get_config_tlvinfo_bin(bd->ifname, TLVID_8023(LLDP_8023_LINK_AGGREGATION),
-			       (void *)&linkagg, sizeof(linkagg))) {
+	if (get_config_tlvinfo_bin(bd->ifname, agent->type,
+				   TLVID_8023(LLDP_8023_LINK_AGGREGATION),
+				   (void *)&linkagg, sizeof(linkagg))) {
 		hton24(linkagg.oui, OUI_IEEE_8023);
 		linkagg.sub = LLDP_8023_LINK_AGGREGATION;
 		if (is_bond(bd->ifname)) {
@@ -252,7 +261,8 @@ out_err:
  *
  * Returns 0 on success
  */
-static int ieee8023_bld_powvmdi_tlv(struct ieee8023_data *bd)
+static int ieee8023_bld_powvmdi_tlv(struct ieee8023_data *bd,
+				    struct lldp_agent *agent)
 {
 	int rc = 0;
 	struct unpacked_tlv *tlv = NULL;
@@ -261,20 +271,23 @@ static int ieee8023_bld_powvmdi_tlv(struct ieee8023_data *bd)
 	/* free old one if it exists */
 	FREE_UNPKD_TLV(bd, powvmdi);
 
-	if (!is_tlv_txenabled(bd->ifname, TLVID_8023(LLDP_8023_POWER_VIA_MDI))) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type,
+			      TLVID_8023(LLDP_8023_POWER_VIA_MDI))) {
 		goto out_err;
 	}
 
 	/* not recommended for LLDP-MED */
-	if (is_tlv_txenabled(bd->ifname, TLVID_MED(LLDP_MED_RESERVED))) {
+	if (is_tlv_txenabled(bd->ifname, agent->type,
+			     TLVID_MED(LLDP_MED_RESERVED))) {
 		/* do not fail */
 		goto out_err;
 	}
 
 	/* TODO: currently only supports config */
 	memset(&powvmdi, 0, sizeof(powvmdi));
-	if (get_config_tlvinfo_bin(bd->ifname, TLVID_8023(LLDP_8023_POWER_VIA_MDI),
-			       (void *)&powvmdi, sizeof(powvmdi))) {
+	if (get_config_tlvinfo_bin(bd->ifname, agent->type,
+				   TLVID_8023(LLDP_8023_POWER_VIA_MDI),
+				   (void *)&powvmdi, sizeof(powvmdi))) {
 		goto out_err;
 	}
 
@@ -307,7 +320,8 @@ static void ieee8023_free_tlv(struct ieee8023_data *bd)
 	}
 }
 
-static int ieee8023_bld_tlv(struct ieee8023_data *bd)
+static int ieee8023_bld_tlv(struct ieee8023_data *bd,
+			    struct lldp_agent *agent)
 {
 	int rc = 0;
 
@@ -316,22 +330,22 @@ static int ieee8023_bld_tlv(struct ieee8023_data *bd)
 		goto out_err;
 	}
 
-	if (ieee8023_bld_maccfg_tlv(bd)) {
+	if (ieee8023_bld_maccfg_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:ieee8023_bld_macfg_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
 	}
-	if (ieee8023_bld_powvmdi_tlv(bd)) {
+	if (ieee8023_bld_powvmdi_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:ieee8023_bld_powvmdi_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
 	}
-	if (ieee8023_bld_linkagg_tlv(bd)) {
+	if (ieee8023_bld_linkagg_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:ieee8023_bld_linkagg_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
 	}
-	if (ieee8023_bld_maxfs_tlv(bd)) {
+	if (ieee8023_bld_maxfs_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:ieee8023_bld_maxfs_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
@@ -367,7 +381,7 @@ struct packed_tlv *ieee8023_gettlv(struct port *port,
 		goto out_err;
 
 	ieee8023_free_tlv(bd);
-	if (ieee8023_bld_tlv(bd)) {
+	if (ieee8023_bld_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s ieee8023_bld_tlv failed\n",
 			__func__, port->ifname);
 		goto out_err;
@@ -444,7 +458,7 @@ void ieee8023_ifup(char *ifname, struct lldp_agent *agent)
 	strncpy(bd->ifname, ifname, IFNAMSIZ);
 	bd->agenttype = agent->type;
 
-	if (ieee8023_bld_tlv(bd)) {
+	if (ieee8023_bld_tlv(bd, agent)) {
 		LLDPAD_INFO("%s:%s mand_bld_tlv failed\n", __func__, ifname);
 		free(bd);
 		goto out_err;
diff --git a/lldp_8023_cmds.c b/lldp_8023_cmds.c
index e7d16a4..2be923b 100644
--- a/lldp_8023_cmds.c
+++ b/lldp_8023_cmds.c
@@ -69,9 +69,10 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	case (LLDP_MOD_8023 << 8) | LLDP_8023_MAXIMUM_FRAME_SIZE:
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 			 TLVID_PREFIX, cmd->tlvid, arg);
-		
-		if (get_config_setting(cmd->ifname, arg_path, (void *)&value,
-					CONFIG_TYPE_BOOL))
+
+		if (get_config_setting(cmd->ifname, cmd->type, arg_path,
+				       (void *)&value,
+				       CONFIG_TYPE_BOOL))
 			value = false;
 		break;
 	case INVALID_TLVID:
@@ -84,7 +85,7 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 		s = VAL_YES;
 	else
 		s = VAL_NO;
-	
+
 	snprintf(obuf, obuf_len, "%02x%s%04x%s", (unsigned int)strlen(arg), arg,
 		(unsigned int)strlen(s), s);
 
@@ -125,7 +126,8 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, arg);
 
-	if (set_cfg(cmd->ifname, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
+	if (set_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value,
+		    CONFIG_TYPE_BOOL))
 		return cmd_failed;
 
 	sprintf(obuf + strlen(obuf), "enableTx = %s\n", value ? "yes" : "no");
diff --git a/lldp_basman.c b/lldp_basman.c
index 13b7d38..a260e9e 100644
--- a/lldp_basman.c
+++ b/lldp_basman.c
@@ -108,7 +108,8 @@ static struct basman_data *basman_data(const char *ifname, enum agent_type type)
  *
  * Returns 0 for success or error code for failure
  */
-static int basman_bld_portdesc_tlv(struct basman_data *bd)
+static int basman_bld_portdesc_tlv(struct basman_data *bd,
+				   struct lldp_agent *agent)
 {
 	int length;
 	int rc = 0;
@@ -118,14 +119,15 @@ static int basman_bld_portdesc_tlv(struct basman_data *bd)
 	/* free old if it's there */
 	FREE_UNPKD_TLV(bd, portdesc);
 
-	if (!is_tlv_txenabled(bd->ifname, PORT_DESCRIPTION_TLV)) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type, PORT_DESCRIPTION_TLV)) {
 		LLDPAD_DBG("%s:%s:Port Description disabled\n",
 			__func__, bd->ifname);
 		goto out_err;
 	}
 
 	/* load from config */
-	if (!get_config_tlvinfo_str(bd->ifname, TLVID_NOUI(PORT_DESCRIPTION_TLV),
+	if (!get_config_tlvinfo_str(bd->ifname, agent->type,
+				    TLVID_NOUI(PORT_DESCRIPTION_TLV),
 				    desc, sizeof(desc))) {
 		/* use what's in the config */
 		length = strlen(desc);
@@ -163,7 +165,8 @@ out_err:
  *
  * Returns 0 for success or error code for failure
  */
-static int basman_bld_sysname_tlv(struct basman_data *bd)
+static int basman_bld_sysname_tlv(struct basman_data *bd,
+				  struct lldp_agent *agent)
 {
 	int length;
 	int rc = 0;
@@ -174,14 +177,15 @@ static int basman_bld_sysname_tlv(struct basman_data *bd)
 	/* free old if it's there */
 	FREE_UNPKD_TLV(bd, sysname);
 
-	if (!is_tlv_txenabled(bd->ifname, SYSTEM_NAME_TLV)) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type, SYSTEM_NAME_TLV)) {
 		LLDPAD_DBG("%s:%s:System Name disabled\n",
 			__func__, bd->ifname);
 		goto out_err;
 	}
 
 	/* load from config */
-	if (!get_config_tlvinfo_str(bd->ifname, TLVID_NOUI(SYSTEM_NAME_TLV),
+	if (!get_config_tlvinfo_str(bd->ifname, agent->type,
+				    TLVID_NOUI(SYSTEM_NAME_TLV),
 				    desc, sizeof(desc))) {
 		/* use what's in the config */
 		length = strlen(desc);
@@ -226,7 +230,8 @@ out_err:
  *
  * net-snmp-utils: snmptest returns the following for sysDesr: `uname-a`
  */
-static int basman_bld_sysdesc_tlv(struct basman_data *bd)
+static int basman_bld_sysdesc_tlv(struct basman_data *bd,
+				  struct lldp_agent *agent)
 {
 	int length;
 	int rc = 0;
@@ -237,14 +242,16 @@ static int basman_bld_sysdesc_tlv(struct basman_data *bd)
 	/* free old if it's there */
 	FREE_UNPKD_TLV(bd, sysdesc);
 
-	if (!is_tlv_txenabled(bd->ifname, SYSTEM_DESCRIPTION_TLV)) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type,
+			      SYSTEM_DESCRIPTION_TLV)) {
 		LLDPAD_DBG("%s:%s:System Description disabled\n",
 			__func__, bd->ifname);
 		goto out_err;
 	}
 
 	/* load from config */
-	if (!get_config_tlvinfo_str(bd->ifname, TLVID_NOUI(SYSTEM_DESCRIPTION_TLV),
+	if (!get_config_tlvinfo_str(bd->ifname, agent->type,
+				    TLVID_NOUI(SYSTEM_DESCRIPTION_TLV),
 				    desc, sizeof(desc))) {
 		/* use what's in the config */
 		length = strlen(desc);
@@ -293,7 +300,8 @@ out_err:
  *  - This is mandatory for LLDP-MED Class III
  *  - TPID to determine C-VLAN vs. S-VLAN ?
  */
-static int basman_bld_syscaps_tlv(struct basman_data *bd)
+static int basman_bld_syscaps_tlv(struct basman_data *bd,
+				  struct lldp_agent *agent)
 {
 	int rc = 0;
 	u16 syscaps[2];
@@ -302,14 +310,16 @@ static int basman_bld_syscaps_tlv(struct basman_data *bd)
 	/* free old if it's there */
 	FREE_UNPKD_TLV(bd, syscaps);
 
-	if (!is_tlv_txenabled(bd->ifname, SYSTEM_CAPABILITIES_TLV)) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type,
+			      SYSTEM_CAPABILITIES_TLV)) {
 		LLDPAD_DBG("%s:%s:System Capabilities disabled\n",
 			__func__, bd->ifname);
 		goto out_err;
 	}
 
 	/* load from config */
-	if (get_config_tlvinfo_bin(bd->ifname, TLVID_NOUI(SYSTEM_CAPABILITIES_TLV),
+	if (get_config_tlvinfo_bin(bd->ifname, agent->type,
+				   TLVID_NOUI(SYSTEM_CAPABILITIES_TLV),
 			      (void *)&syscaps, sizeof(syscaps))) {
 		LLDPAD_DBG("%s:%s:Build System Caps from scratch\n",
 			__func__, bd->ifname);
@@ -346,7 +356,8 @@ out_err:
  * Currently supports only IPv4, IPv6, and MAC address types.
  *
  */
-static int basman_get_manaddr_sub(struct basman_data *bd, u8 masub)
+static int basman_get_manaddr_sub(struct basman_data *bd,
+				  struct lldp_agent *agent, u8 masub)
 {
 	int domain;
 	int length = 0;
@@ -370,7 +381,7 @@ static int basman_get_manaddr_sub(struct basman_data *bd, u8 masub)
 	memset(&manaddr, 0, sizeof(manaddr));
 	m = &manaddr.m;
 	m->sub = masub;
- 	switch(m->sub) {
+	switch(m->sub) {
 	case MANADDR_IPV4:
 		field = "ipv4";
 		domain = AF_INET;
@@ -395,6 +406,7 @@ static int basman_get_manaddr_sub(struct basman_data *bd, u8 masub)
 
 	/* read from the config first */
 	if (get_config_tlvfield_str(bd->ifname,
+				    agent->type,
 				    TLVID_NOUI(MANAGEMENT_ADDRESS_TLV),
 				    field, (void *)maddr, sizeof(maddr))) {
 		LLDPAD_DBG("%s:%s:failed to get %s from config\n",
@@ -420,6 +432,7 @@ out_bld:
 
 out_set:
 	set_config_tlvfield_str(bd->ifname,
+				agent->type,
 				TLVID_NOUI(MANAGEMENT_ADDRESS_TLV),
 				field, (void *)maddr, sizeof(maddr));
 
@@ -477,7 +490,8 @@ out_err:
  * TODO:
  *  - No support for OID yet
  */
-static int basman_bld_manaddr_tlv(struct basman_data *bd)
+static int basman_bld_manaddr_tlv(struct basman_data *bd,
+				  struct lldp_agent *agent)
 {
 	int i;
 	int rc = 0;
@@ -488,18 +502,19 @@ static int basman_bld_manaddr_tlv(struct basman_data *bd)
 	bd->macnt = 0;
 
 	/* ignore manaddr if it's not enabled for tx */
-	if (!is_tlv_txenabled(bd->ifname, MANAGEMENT_ADDRESS_TLV)) {
+	if (!is_tlv_txenabled(bd->ifname, agent->type,
+			      MANAGEMENT_ADDRESS_TLV)) {
 		LLDPAD_DBG("%s:%s:Management Address disabled\n",
 			__func__, bd->ifname);
 		goto out_err;
 	}
 
 	/* management addr preference: ipv4, ipv6, mac */
-	rc = basman_get_manaddr_sub(bd, MANADDR_IPV4);
+	rc = basman_get_manaddr_sub(bd, agent, MANADDR_IPV4);
 	if (rc) {
-		rc = basman_get_manaddr_sub(bd, MANADDR_IPV6);
+		rc = basman_get_manaddr_sub(bd, agent, MANADDR_IPV6);
 		if (rc)
-			basman_get_manaddr_sub(bd, MANADDR_ALL802);
+			basman_get_manaddr_sub(bd, agent, MANADDR_ALL802);
 	}
 out_err:
 	return rc;
@@ -521,7 +536,7 @@ static void basman_free_tlv(struct basman_data *bd)
 }
 
 /* build unpacked tlvs */
-static int basman_bld_tlv(struct basman_data *bd)
+static int basman_bld_tlv(struct basman_data *bd, struct lldp_agent *agent)
 {
 	int rc = EPERM;
 
@@ -530,27 +545,27 @@ static int basman_bld_tlv(struct basman_data *bd)
 		goto out_err;
 	}
 
-	if (basman_bld_portdesc_tlv(bd)) {
+	if (basman_bld_portdesc_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:basman_bld_portdesc_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
 	}
-	if (basman_bld_sysname_tlv(bd)) {
+	if (basman_bld_sysname_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:basman_bld_sysname_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
 	}
-	if (basman_bld_sysdesc_tlv(bd)) {
+	if (basman_bld_sysdesc_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:basman_bld_sysdesc_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
 	}
-	if (basman_bld_syscaps_tlv(bd)) {
+	if (basman_bld_syscaps_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:basman_bld_syscaps_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
 	}
-	if (basman_bld_manaddr_tlv(bd)) {
+	if (basman_bld_manaddr_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s:basman_bld_manaddr_tlv() failed\n",
 				__func__, bd->ifname);
 		goto out_err;
@@ -587,7 +602,7 @@ struct packed_tlv *basman_gettlv(struct port *port, struct lldp_agent *agent)
 
 	/* free and rebuild the TLVs */
 	basman_free_tlv(bd);
-	if (basman_bld_tlv(bd)) {
+	if (basman_bld_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s basman_bld_tlv failed\n",
 			__func__, port->ifname);
 		goto out_err;
@@ -671,7 +686,7 @@ void basman_ifup(char *ifname, struct lldp_agent *agent)
 	strncpy(bd->ifname, ifname, IFNAMSIZ);
 	bd->agenttype = agent->type;
 
-	if (basman_bld_tlv(bd)) {
+	if (basman_bld_tlv(bd, agent)) {
 		LLDPAD_DBG("%s:%s mand_bld_tlv failed\n", __func__, ifname);
 		free(bd);
 		goto out_err;
diff --git a/lldp_basman_cmds.c b/lldp_basman_cmds.c
index bb3e5be..5ec2886 100644
--- a/lldp_basman_cmds.c
+++ b/lldp_basman_cmds.c
@@ -80,9 +80,10 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	case MANAGEMENT_ADDRESS_TLV:
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 			 TLVID_PREFIX, cmd->tlvid, arg);
-		
-		if (get_config_setting(cmd->ifname, arg_path, (void *)&value,
-					CONFIG_TYPE_BOOL))
+
+		if (get_config_setting(cmd->ifname, cmd->type, arg_path,
+				       (void *)&value,
+				       CONFIG_TYPE_BOOL))
 			value = false;
 		break;
 	case INVALID_TLVID:
@@ -95,7 +96,6 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 		s = VAL_YES;
 	else
 		s = VAL_NO;
-	
 	snprintf(obuf, obuf_len, "%02x%s%04x%s",
 		 (unsigned int)strlen(arg), arg, (unsigned int)strlen(s), s);
 
@@ -137,7 +137,8 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, arg);
 
-	if (set_cfg(cmd->ifname, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
+	if (set_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value,
+		    CONFIG_TYPE_BOOL))
 		return cmd_failed;
 
 	sprintf(obuf + strlen(obuf), "enableTx = %s\n", value ? "yes" : "no");
@@ -179,7 +180,7 @@ int get_arg_ipv4(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 		 TLVID_PREFIX, cmd->tlvid, arg);
 
-	if (get_config_setting(cmd->ifname, arg_path, (void *)&p,
+	if (get_config_setting(cmd->ifname, cmd->type, arg_path, (void *)&p,
 				CONFIG_TYPE_STRING))
 		return cmd_failed;
 
@@ -202,8 +203,8 @@ int get_arg_ipv6(struct cmd *cmd, char *arg, char *argvalue,
 
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 		 TLVID_PREFIX, cmd->tlvid, arg);
-		
-	if (get_config_setting(cmd->ifname, arg_path, (void *)&p,
+
+	if (get_config_setting(cmd->ifname, cmd->type, arg_path, (void *)&p,
 					CONFIG_TYPE_STRING))
 		return cmd_failed;
 
@@ -233,7 +234,7 @@ int _set_arg_ipv4(struct cmd *cmd, char *arg, char *argvalue,
 		 cmd->tlvid, arg);
 
 	p = &argvalue[0];
-	if (set_config_setting(cmd->ifname, arg_path, (void *)&p,
+	if (set_config_setting(cmd->ifname, cmd->type, arg_path, (void *)&p,
 		    CONFIG_TYPE_STRING))
 		return cmd_failed;
 
@@ -276,7 +277,7 @@ int _set_arg_ipv6(struct cmd *cmd, char *arg, char *argvalue,
 		 cmd->tlvid, arg);
 
 	p = &argvalue[0];
-	if (set_config_setting(cmd->ifname, arg_path, (void *)&p,
+	if (set_config_setting(cmd->ifname, cmd->type, arg_path, (void *)&p,
 		    CONFIG_TYPE_STRING))
 		return cmd_failed;
 
diff --git a/lldp_dcbx.c b/lldp_dcbx.c
index c2011ff..755e899 100644
--- a/lldp_dcbx.c
+++ b/lldp_dcbx.c
@@ -126,7 +126,7 @@ struct dcbx_tlvs *dcbx_data(const char *ifname)
 	return NULL;
 }
 
-int dcbx_tlvs_rxed(const char *ifname)
+int dcbx_tlvs_rxed(const char *ifname, struct lldp_agent *agent)
 {
 	struct dcbd_user_data *dud;
 	struct dcbx_tlvs *tlv = NULL;
@@ -163,7 +163,7 @@ int dcbx_check_active(const char *ifname)
 	return 0;
 }
 
-int dcbx_bld_tlv(struct port *newport)
+int dcbx_bld_tlv(struct port *newport, struct lldp_agent *agent)
 {
 	bool success;
 	struct dcbx_tlvs *tlvs;
@@ -172,11 +172,11 @@ int dcbx_bld_tlv(struct port *newport)
 
 	tlvs = dcbx_data(newport->ifname);
 
-	get_config_setting(newport->ifname, ARG_ADMINSTATUS,
+	get_config_setting(newport->ifname, agent->type, ARG_ADMINSTATUS,
 			  (void *)&adminstatus, CONFIG_TYPE_INT);
 
-	enabletx = is_tlv_txenabled(newport->ifname, (OUI_CEE_DCBX << 8) |
-				  tlvs->dcbx_st);
+	enabletx = is_tlv_txenabled(newport->ifname, agent->type,
+				    (OUI_CEE_DCBX << 8) | tlvs->dcbx_st);
 
 	if (!tlvs->active || !enabletx || adminstatus != enabledRxTx)
 		return 0;
@@ -337,7 +337,7 @@ struct packed_tlv* dcbx_gettlv(struct port *port, struct lldp_agent *agent)
 
 	dcbx_free_tlv(tlvs);
 
-	dcbx_bld_tlv(port);
+	dcbx_bld_tlv(port, agent);
 	if (tlvs->dcbx_st == dcbx_subtype2) {
 		/* Load Type127 - dcbx subtype 2*/
 		if (tlv_ok(tlvs->dcbx2))
@@ -489,7 +489,8 @@ void dcbx_ifup(char *ifname, struct lldp_agent *agent)
 	/* if no adminStatus setting or wrong setting for adminStatus,
 	 * then set adminStatus to enabledRxTx.
 	 */
-	if (get_config_setting(ifname, ARG_ADMINSTATUS, (void *)&adminstatus,
+	if (get_config_setting(ifname, agent->type, ARG_ADMINSTATUS,
+			       (void *)&adminstatus,
 				CONFIG_TYPE_INT) ||
 				adminstatus == enabledTxOnly ||
 				adminstatus == enabledRxOnly) {
@@ -497,24 +498,24 @@ void dcbx_ifup(char *ifname, struct lldp_agent *agent)
 		/* set enableTx to true if it is not already set */
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 			(OUI_CEE_DCBX << 8) | 1, ARG_TLVTXENABLE);
-		if (get_config_setting(ifname, arg_path,
+		if (get_config_setting(ifname, agent->type, arg_path,
 				(void *)&enabletx, CONFIG_TYPE_BOOL)) {
 			enabletx = true;
-			set_config_setting(ifname, arg_path,
+			set_config_setting(ifname, agent->type, arg_path,
 			              (void *)&enabletx, CONFIG_TYPE_BOOL);
 		}
 
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 			(OUI_CEE_DCBX << 8) | 2, ARG_TLVTXENABLE);
-		if (get_config_setting(ifname, arg_path,
+		if (get_config_setting(ifname, agent->type, arg_path,
 				(void *)&enabletx, CONFIG_TYPE_BOOL)) {
 			enabletx = true;
-			set_config_setting(ifname, arg_path,
+			set_config_setting(ifname, agent->type, arg_path,
 			              (void *)&enabletx, CONFIG_TYPE_BOOL);
 		}
 
 		adminstatus = enabledRxTx;
-		if (set_config_setting(ifname, ARG_ADMINSTATUS,
+		if (set_config_setting(ifname, agent->type, ARG_ADMINSTATUS,
 			              (void *)&adminstatus, CONFIG_TYPE_INT) ==
 				       cmd_success)
 			set_lldp_agent_admin(ifname, agent->type, (int)adminstatus);
@@ -548,13 +549,13 @@ initialized:
 	/* ensure advertise bits are set consistently with enabletx */
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 (OUI_CEE_DCBX << 8) | tlvs->dcbx_st, ARG_TLVTXENABLE);
-	exists = get_config_setting(ifname, arg_path,
+	exists = get_config_setting(ifname, agent->type, arg_path,
 				    &enabletx, CONFIG_TYPE_BOOL);
 
 	if (!exists || enabletx)
 		dont_advertise_dcbx_all(ifname, 1);
 
-	dcbx_bld_tlv(port);
+	dcbx_bld_tlv(port, agent);
 
 	/* if the dcbx field is not filled in by the capabilities
 	 * query, then the kernel is older and does not support
diff --git a/lldp_dcbx_cmds.c b/lldp_dcbx_cmds.c
index ee9dbcf..5cb38e4 100644
--- a/lldp_dcbx_cmds.c
+++ b/lldp_dcbx_cmds.c
@@ -103,8 +103,8 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	case (OUI_CEE_DCBX << 8) | 2:
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 			 TLVID_PREFIX, cmd->tlvid, arg);
-		
-		if (get_config_setting(cmd->ifname, arg_path, (void *)&value,
+
+		if (get_config_setting(cmd->ifname, cmd->type, arg_path, (void *)&value,
 					CONFIG_TYPE_BOOL))
 			value = false;
 		break;
@@ -193,7 +193,7 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	if (test)
 		return cmd_success;
 
-	current_value = is_tlv_txenabled(cmd->ifname, cmd->tlvid);
+	current_value = is_tlv_txenabled(cmd->ifname, cmd->type, cmd->tlvid);
 
 	snprintf(obuf, obuf_len, "enabled = %s\n", value ? "yes" : "no");
 
@@ -203,7 +203,8 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, arg);
 
-	if (set_cfg(cmd->ifname, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
+	if (set_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value,
+		    CONFIG_TYPE_BOOL))
 		return cmd_failed;
 
 	dont_advertise_dcbx_all(cmd->ifname, value);
@@ -377,7 +378,7 @@ static dcb_result set_bwg_desc(char *port_id, char *ibuf, int ilen)
 }
 
 static void set_protocol_data(feature_protocol_attribs *protocol, char *ifname,
-			      char *ibuf, int plen, int type)
+			      char *ibuf, int plen, int agenttype)
 {
 	u8 flag;
 	int last;
@@ -391,9 +392,9 @@ static void set_protocol_data(feature_protocol_attribs *protocol, char *ifname,
 		last = protocol->Advertise;
 		protocol->Advertise = flag & 0x01;
 		if (last != protocol->Advertise && protocol->Advertise) {
-			tlv_enabletx(ifname, (OUI_CEE_DCBX << 8) |
+			tlv_enabletx(ifname, agenttype, (OUI_CEE_DCBX << 8) |
 				     protocol->dcbx_st);
-			somethingChangedLocal(ifname, type);
+			somethingChangedLocal(ifname, agenttype);
 		}
 	}
 
diff --git a/lldp_evb.c b/lldp_evb.c
index 2e20a7d..810e561 100644
--- a/lldp_evb.c
+++ b/lldp_evb.c
@@ -46,6 +46,7 @@
 
 
 extern struct lldp_head lldp_head;
+extern int vdp_vsis(char *ifname);
 
 struct evb_data *evb_data(char *ifname, enum agent_type type)
 {
@@ -100,11 +101,90 @@ static void evb_dump_tlv(struct unpacked_tlv *tlv)
 
 unsigned int evb_get_rte(char *ifname)
 {
+	/* TODO: fixed to ncb for now */
 	struct evb_data *ed = evb_data(ifname, NEAREST_CUSTOMER_BRIDGE);
 
 	return (unsigned int) ed->tie->rte;
 }
 
+/* evb_check_and_fill
+ *
+ * checks values received in TLV and takes over some values
+ */
+int evb_check_and_fill(struct evb_data *ed, struct tlv_info_evb *tie)
+{
+	/* sanity check of received data in tie */
+	if ((tie->smode & (LLDP_EVB_CAPABILITY_FORWARD_STANDARD |
+			  LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)) == 0) {
+		LLDPAD_ERR("Neither standard nor rr set as forwarding mode !");
+		return TLV_ERR;
+	}
+
+	if ((tie->svsi < 0) || (tie->svsi > LLDP_EVB_DEFAULT_MAX_VSI)) {
+		LLDPAD_ERR("nr of supported vsis (%i) exceeds allow value range !", ntohs(tie->svsi));
+		return TLV_ERR;
+	}
+
+	if ((tie->cvsi < 0) || (tie->cvsi > LLDP_EVB_DEFAULT_MAX_VSI)) {
+		LLDPAD_ERR("nr of configured vsis (%i) exceeds allow value range !", ntohs(tie->cvsi));
+		return TLV_ERR;
+	}
+
+	/* check bridge capabilities against local policy*/
+	/* if bridge supports RR and we support it as well, request it
+	 * by setting smode in tlv to be sent out (ed->tie->smode) */
+	if ((tie->smode & LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY) &&
+	     (ed->policy->smode & LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)) {
+		ed->tie->smode = LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY;
+	} else {
+		ed->tie->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
+	}
+
+	/* maybe switch has already set the mode based on the saved info sent
+	 * out on ifup */
+	if (tie->cmode == ed->tie->smode)
+		ed->tie->cmode = tie->cmode;
+
+	ed->tie->scap = ed->policy->scap;
+
+	/* If both sides support RTE, support and configure it */
+	if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_RTE) {
+		ed->tie->ccap |= LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
+	} else {
+		ed->tie->ccap &= ~LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
+	}
+
+	/* If both sides support ECP, set it */
+	if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_ECP) {
+		ed->tie->ccap |= LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
+	} else {
+		ed->tie->ccap &= ~LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
+	}
+
+	/* If both sides support VDP, set it */
+	if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_VDP) {
+		ed->tie->ccap |= LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
+	} else {
+		ed->tie->ccap &= ~LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
+	}
+
+	/* If supported caps include VDP take over min value of both */
+	if (ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_VDP) {
+		ed->tie->svsi = tie->svsi;
+		ed->tie->cvsi = htons(vdp_vsis(ed->ifname));
+	} else {
+		ed->tie->svsi = 0;
+		ed->tie->cvsi = 0;
+	}
+
+	/* If both sides support RTE and value offer is > 0, set it */
+	if ((ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_RTE) &&
+		(tie->rte > 0) && (ed->policy->rte > 0))
+		ed->tie->rte = MAX(ed->policy->rte,tie->rte);
+
+	return TLV_OK;
+}
+
 /* evb_process_tlv - processes the tlv
  * @ed: evb_data for the interface
  * @tie: incoming tlv
@@ -134,7 +214,7 @@ static void evb_update_tlv(struct evb_data *ed)
  *
  * Returns 0 on success
  */
-static int evb_bld_cfg_tlv(struct evb_data *ed)
+static int evb_bld_cfg_tlv(struct evb_data *ed, struct lldp_agent *agent)
 {
 	int rc = 0;
 	struct unpacked_tlv *tlv = NULL;
@@ -142,7 +222,8 @@ static int evb_bld_cfg_tlv(struct evb_data *ed)
 	/* free ed->evb if it exists */
 	FREE_UNPKD_TLV(ed, evb);
 
-	if (!is_tlv_txenabled(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
+	if (!is_tlv_txenabled(ed->ifname, agent->type,
+			      TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
 		LLDPAD_DBG("%s:%s:EVB tx is currently disabled !\n",
 			__func__, ed->ifname);
 		rc = EINVAL;
@@ -188,7 +269,7 @@ static void evb_free_tlv(struct evb_data *ed)
  *
  * fill up tlv_info_evb structure with reasonable info
  */
-static int evb_init_cfg_tlv(struct evb_data *ed)
+static int evb_init_cfg_tlv(struct evb_data *ed, struct lldp_agent *agent)
 {
 	char arg_path[EVB_BUF_SIZE];
 	char *param;
@@ -213,15 +294,16 @@ static int evb_init_cfg_tlv(struct evb_data *ed)
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.fmode",
 		 TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
 
-	if (get_cfg(ed->ifname, arg_path, (void *) &param, CONFIG_TYPE_STRING)) {
+	if (get_cfg(ed->ifname, agent->type, arg_path,
+		    (void *) &param, CONFIG_TYPE_STRING)) {
 		LLDPAD_INFO("%s:%s: loading EVB policy for forwarding mode failed, using default.\n",
 			__func__, ed->ifname);
 	} else {
-		if (strcasestr(param, VAL_EVB_FMODE_BRIDGE)) {
+		if (strstr(param, VAL_EVB_FMODE_BRIDGE)) {
 			ed->policy->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
 		}
 
-		if (strcasestr(param, VAL_EVB_FMODE_REFLECTIVE_RELAY)) {
+		if (strstr(param, VAL_EVB_FMODE_REFLECTIVE_RELAY)) {
 			ed->policy->smode = LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY;
 		}
 
@@ -233,23 +315,24 @@ static int evb_init_cfg_tlv(struct evb_data *ed)
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.capabilities",
 		 TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
 
-	if (get_cfg(ed->ifname, arg_path, (void *) &param, CONFIG_TYPE_STRING)) {
+	if (get_cfg(ed->ifname, agent->type, arg_path,
+		    (void *) &param, CONFIG_TYPE_STRING)) {
 		LLDPAD_INFO("%s:%s: loading EVB policy for capabilities failed, using default.\n",
 			__func__, ed->ifname);
 	} else {
-		if (strcasestr(param, VAL_EVB_CAPA_RTE)) {
+		if (strstr(param, VAL_EVB_CAPA_RTE)) {
 			ed->policy->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
 		}
 
-		if (strcasestr(param, VAL_EVB_CAPA_ECP)) {
+		if (strstr(param, VAL_EVB_CAPA_ECP)) {
 			ed->policy->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
 		}
 
-		if (strcasestr(param, VAL_EVB_CAPA_VDP)) {
+		if (strstr(param, VAL_EVB_CAPA_VDP)) {
 			ed->policy->scap |= LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
 		}
 
-		if (strcasestr(param, VAL_EVB_CAPA_NONE)) {
+		if (strstr(param, VAL_EVB_CAPA_NONE)) {
 			ed->policy->scap = 0;
 		}
 
@@ -261,7 +344,8 @@ static int evb_init_cfg_tlv(struct evb_data *ed)
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.rte",
 		 TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
 
-	if (get_cfg(ed->ifname, arg_path, (void *) &param, CONFIG_TYPE_STRING)) {
+	if (get_cfg(ed->ifname, NEAREST_CUSTOMER_BRIDGE, arg_path,
+		    (void *) &param, CONFIG_TYPE_STRING)) {
 		LLDPAD_INFO("%s:%s: loading EVB policy for rte failed, using default.\n",
 			__func__, ed->ifname);
 	} else {
@@ -275,7 +359,8 @@ static int evb_init_cfg_tlv(struct evb_data *ed)
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.vsis",
 		 TLVID_PREFIX, TLVID_8021Qbg(LLDP_EVB_SUBTYPE));
 
-	if (get_cfg(ed->ifname, arg_path, (void *) &param, CONFIG_TYPE_STRING)) {
+	if (get_cfg(ed->ifname, agent->type, arg_path,
+		    (void *) &param, CONFIG_TYPE_STRING)) {
 		LLDPAD_INFO("%s:%s: loading EVB policy for vsis failed, using default.\n",
 			__func__, ed->ifname);
 	} else {
@@ -285,7 +370,6 @@ static int evb_init_cfg_tlv(struct evb_data *ed)
 		LLDPAD_DBG("%s:%s: policy param vsis = %i.\n", __func__, ed->ifname, ntohs(ed->policy->svsi));
 	}
 
-	/* load last used EVB TLV ... */
 	ed->tie = (struct tlv_info_evb *) calloc(1, sizeof(struct tlv_info_evb));
 
 	if (!ed->tie) {
@@ -294,22 +378,17 @@ static int evb_init_cfg_tlv(struct evb_data *ed)
 		return ENOMEM;
 	}
 
-	if (get_config_tlvinfo_bin(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE),
-			       (void *)ed->tie, sizeof(struct tlv_info_evb))) {
-		LLDPAD_INFO("%s:%s: loading last used EVB TLV failed, using default.\n",
-			__func__, ed->ifname);
-		hton24(ed->tie->oui, LLDP_MOD_EVB);
-		ed->tie->smode = ed->policy->smode;
-		ed->tie->cmode = 0x0;
-		ed->tie->scap  = ed->policy->scap;
-		ed->tie->ccap = 0x0;
-		ed->tie->svsi = htons(LLDP_EVB_DEFAULT_SVSI);
-		ed->tie->cvsi = htons(0x0);
-		ed->tie->rte = LLDP_EVB_DEFAULT_RTE;
-	} else {
-		LLDPAD_INFO("%s(%i): loaded last used EVB TLV from file.\n", __FILE__, __LINE__);
-	}
+	hton24(ed->tie->oui, LLDP_MOD_EVB);
+	ed->tie->smode = ed->policy->smode;
+	ed->tie->cmode = 0x0;
+	ed->tie->scap  = ed->policy->scap;
+	ed->tie->ccap = 0x0;
+	ed->tie->svsi = htons(LLDP_EVB_DEFAULT_SVSI);
+	ed->tie->cvsi = htons(0x0);
+	ed->tie->rte = LLDP_EVB_DEFAULT_RTE;
 
+	LLDPAD_INFO("%s:%s: filling last used EVB TLV, using default.\n",
+		__func__, ed->ifname);
 	ed->last = (struct tlv_info_evb *) calloc(1, sizeof(struct tlv_info_evb));
 
 	if (!ed->last) {
@@ -320,12 +399,13 @@ static int evb_init_cfg_tlv(struct evb_data *ed)
 		return ENOMEM;
 	}
 
-	ed->last->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
+	ed->last->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD | \
+			  LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY;
 
 	return 0;
 }
 
-static int evb_bld_tlv(struct evb_data *ed)
+static int evb_bld_tlv(struct evb_data *ed, struct lldp_agent *agent)
 {
 	int rc = 0;
 
@@ -334,7 +414,7 @@ static int evb_bld_tlv(struct evb_data *ed)
 		goto out_err;
 	}
 
-	if (evb_bld_cfg_tlv(ed)) {
+	if (evb_bld_cfg_tlv(ed, agent)) {
 		LLDPAD_DBG("%s:%s:evb_bld_cfg_tlv() failed\n",
 				__func__, ed->ifname);
 		rc = EINVAL;
@@ -369,7 +449,7 @@ struct packed_tlv *evb_gettlv(struct port *port, struct lldp_agent *agent)
 
 	evb_free_tlv(ed);
 
-	if (evb_bld_tlv(ed)) {
+	if (evb_bld_tlv(ed, agent)) {
 		LLDPAD_DBG("%s:%s evb_bld_tlv failed\n",
 			__func__, port->ifname);
 		goto disabled;
@@ -400,92 +480,6 @@ out_err:
 	return NULL;
 }
 
-/* evb_check_and_fill
- *
- * checks values received in TLV and takes over some values
- */
-int evb_check_and_fill(struct evb_data *ed, struct tlv_info_evb *tie)
-{
-	/* sanity check of received data in tie */
-	if ((tie->smode & (LLDP_EVB_CAPABILITY_FORWARD_STANDARD |
-			  LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)) == 0) {
-		LLDPAD_ERR("Neither standard nor rr set as forwarding mode !");
-		return TLV_ERR;
-	}
-
-	if ((tie->svsi < 0) || (tie->svsi > LLDP_EVB_DEFAULT_MAX_VSI)) {
-		LLDPAD_ERR("nr of supported vsis (%i) exceeds allow value range !", ntohs(tie->svsi));
-		return TLV_ERR;
-	}
-
-	if ((tie->cvsi < 0) || (tie->cvsi > LLDP_EVB_DEFAULT_MAX_VSI)) {
-		LLDPAD_ERR("nr of configured vsis (%i) exceeds allow value range !", ntohs(tie->cvsi));
-		return TLV_ERR;
-	}
-
-	/* check bridge capabilities against local policy*/
-	/* if bridge supports RR and we support it as well, request it
-	 * by setting smode in tlv to be sent out (ed->tie->smode) */
-	if ((tie->smode & LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY) &&
-	     (ed->policy->smode & LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY)) {
-		ed->tie->smode = LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY;
-	} else {
-		ed->tie->smode = LLDP_EVB_CAPABILITY_FORWARD_STANDARD;
-	}
-
-	/* maybe switch has already set the mode based on the saved info sent
-	 * out on ifup */
-
-	if (tie->cmode == ed->tie->smode)
-		ed->tie->cmode = tie->cmode;
-
-	ed->tie->scap = ed->policy->scap;
-
-	/* If both sides support RTE, support and configure it */
-	if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_RTE) {
-		ed->tie->ccap |= LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
-	} else {
-		ed->tie->ccap &= ~LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
-	}
-
-	/* If both sides support ECP, set it */
-	if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_ECP) {
-		ed->tie->ccap |= LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
-	} else {
-		ed->tie->ccap &= ~LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
-	}
-
-	/* If both sides support VDP, set it */
-	if ((tie->scap & ed->policy->scap) & LLDP_EVB_CAPABILITY_PROTOCOL_VDP) {
-		ed->tie->ccap |= LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
-	} else {
-		ed->tie->ccap &= ~LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
-	}
-
-	/* If supported caps include VDP take over min value of both */
-	if (ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_VDP) {
-		ed->tie->svsi = tie->svsi;
-		ed->tie->cvsi = htons(vdp_vsis(ed->ifname));
-	} else {
-		ed->tie->svsi = 0;
-		ed->tie->cvsi = 0;
-	}
-
-	/* If both sides support RTE and value offer is > 0, set it */
-	if ((ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_RTE) &&
-		(tie->rte > 0) && (ed->policy->rte > 0))
-		ed->tie->rte = MAX(ed->policy->rte,tie->rte);
-
-	if (set_config_tlvinfo_bin(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE),
-			       (void *)ed->tie, sizeof(struct tlv_info_evb))) {
-		LLDPAD_ERR("%s(%i): error saving tlv_info_evb !\n", __FILE__, __LINE__);
-	} else {
-		LLDPAD_INFO("%s(%i): saved tlv_info_evb to config !\n", __FILE__, __LINE__);
-	}
-
-	return TLV_OK;
-}
-
 /*
  * evb_rchange: process RX TLV LLDPDU
  *
@@ -514,7 +508,8 @@ static int evb_rchange(struct port *port, struct lldp_agent *agent,
 		}
 
 		/* disable rx if tx has been disabled by administrator */
-		if (!is_tlv_txenabled(ed->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
+		if (!is_tlv_txenabled(ed->ifname, agent->type,
+				      TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
 			LLDPAD_WARN("%s:%s:EVB Config disabled\n",
 				__func__, ed->ifname);
 			return TLV_OK;
@@ -579,12 +574,12 @@ void evb_ifup(char *ifname, struct lldp_agent *agent)
 	strncpy(ed->ifname, ifname, IFNAMSIZ);
 	ed->agenttype = agent->type;
 
-	if (evb_init_cfg_tlv(ed)) {
+	if (evb_init_cfg_tlv(ed, agent)) {
 		LLDPAD_ERR("%s:%s evb_init_cfg_tlv failed\n", __func__, ifname);
 		goto out_free;
 	}
 
-	evb_bld_tlv(ed);
+	evb_bld_tlv(ed, agent);
 
 	ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_EVB);
 	LIST_INSERT_HEAD(&ud->head, ed, entry);
@@ -605,7 +600,8 @@ u8 evb_mibdelete(struct port *port, struct lldp_agent *agent)
 {
 	struct evb_data *ed;
 
-	if (!is_tlv_txenabled(port->ifname, TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
+	if (!is_tlv_txenabled(port->ifname, agent->type,
+			      TLVID_8021Qbg(LLDP_EVB_SUBTYPE))) {
 		goto out_err;
 	}
 
@@ -619,12 +615,12 @@ u8 evb_mibdelete(struct port *port, struct lldp_agent *agent)
 	free(ed->last);
 	free(ed->policy);
 
-	if (evb_init_cfg_tlv(ed)) {
+	if (evb_init_cfg_tlv(ed, agent)) {
 		LLDPAD_ERR("%s:%s evb_init_cfg_tlv failed\n", __func__, port->ifname);
 		goto out_err;
 	}
 
-	evb_bld_tlv(ed);
+	evb_bld_tlv(ed, agent);
 
 out_err:
 	return 0;
diff --git a/lldp_evb_cmds.c b/lldp_evb_cmds.c
index 18db0d9..835bfca 100644
--- a/lldp_evb_cmds.c
+++ b/lldp_evb_cmds.c
@@ -44,6 +44,7 @@
 #include "config.h"
 #include "clif_msgs.h"
 #include "lldp/states.h"
+#include "messages.h"
 
 static int get_arg_tlvtxenable(struct cmd *, char *, char *, char *, int);
 static int set_arg_tlvtxenable(struct cmd *, char *, char *, char *, int);
@@ -88,6 +89,8 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	char *s;
 	char arg_path[EVB_BUF_SIZE];
 
+	LLDPAD_DBG("%s(%i): \n", __func__, __LINE__);
+
 	if (cmd->cmd != cmd_gettlv)
 		return cmd_invalid;
 
@@ -96,7 +99,7 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 			 TLVID_PREFIX, cmd->tlvid, arg);
 
-		if (get_cfg(cmd->ifname, arg_path, (void *)&value,
+		if (get_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value,
 					CONFIG_TYPE_BOOL))
 			value = false;
 		break;
@@ -123,6 +126,8 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	int value;
 	char arg_path[EVB_BUF_SIZE];
 
+	LLDPAD_DBG("%s(%i): \n", __func__, __LINE__);
+
 	if (cmd->cmd != cmd_settlv)
 		return cmd_invalid;
 
@@ -148,7 +153,7 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 		 TLVID_PREFIX, cmd->tlvid, arg);
 
-	if (set_cfg(cmd->ifname, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
+	if (set_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
 		return cmd_failed;
 
 	somethingChangedLocal(cmd->ifname, cmd->type);
@@ -247,7 +252,8 @@ static int _set_arg_fmode(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.fmode",
 		 TLVID_PREFIX, cmd->tlvid);
 
-	if (set_cfg(ed->ifname, arg_path, (void *) &argvalue, CONFIG_TYPE_STRING)) {
+	if (set_cfg(ed->ifname, cmd->type, arg_path, (void *) &argvalue,
+		    CONFIG_TYPE_STRING)) {
 		printf("%s:%s: saving EVB forwarding mode failed.\n",
 			__func__, ed->ifname);
 		return cmd_invalid;
@@ -359,16 +365,16 @@ static int _set_arg_capabilities(struct cmd *cmd, char *arg, char *argvalue,
 	if (!ed)
 		return cmd_invalid;
 
-	if (strcasestr(argvalue, VAL_EVB_CAPA_RTE))
+	if (strstr(argvalue, VAL_EVB_CAPA_RTE))
 		scap |= LLDP_EVB_CAPABILITY_PROTOCOL_RTE;
 
-	if (strcasestr(argvalue, VAL_EVB_CAPA_ECP))
+	if (strstr(argvalue, VAL_EVB_CAPA_ECP))
 		scap |= LLDP_EVB_CAPABILITY_PROTOCOL_ECP;
 
-	if (strcasestr(argvalue, VAL_EVB_CAPA_VDP))
+	if (strstr(argvalue, VAL_EVB_CAPA_VDP))
 		scap |= LLDP_EVB_CAPABILITY_PROTOCOL_VDP;
 
-	if (strcasestr(argvalue, VAL_EVB_CAPA_NONE))
+	if (strstr(argvalue, VAL_EVB_CAPA_NONE))
 		scap = 0;
 
 	if (test)
@@ -379,7 +385,8 @@ static int _set_arg_capabilities(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.capabilities",
 		 TLVID_PREFIX, cmd->tlvid);
 
-	if (set_cfg(ed->ifname, arg_path, (void *) &argvalue, CONFIG_TYPE_STRING)) {
+	if (set_cfg(ed->ifname, cmd->type, arg_path, (void *) &argvalue,
+		    CONFIG_TYPE_STRING)) {
 		printf("%s:%s: saving EVB capabilities failed.\n",
 			__func__, ed->ifname);
 		return cmd_invalid;
@@ -476,7 +483,8 @@ static int _set_arg_rte(struct cmd *cmd, char *arg, char *argvalue,
 	if (err < 0)
 		goto out_err;
 
-	if (set_cfg(ed->ifname, arg_path, (void *) &argvalue, CONFIG_TYPE_STRING))
+	if (set_cfg(ed->ifname, cmd->type, arg_path, (void *) &argvalue,
+		    CONFIG_TYPE_STRING))
 		goto out_err;
 
 	somethingChangedLocal(cmd->ifname, cmd->type);
@@ -580,7 +588,8 @@ static int _set_arg_vsis(struct cmd *cmd, char *arg, char *argvalue,
 
 	sv = &svalue[0];
 
-	if (set_cfg(ed->ifname, arg_path, (void *) &sv, CONFIG_TYPE_STRING))
+	if (set_cfg(ed->ifname, cmd->type, arg_path, (void *) &sv,
+		    CONFIG_TYPE_STRING))
 		goto out_err;
 
 	somethingChangedLocal(cmd->ifname, cmd->type);
diff --git a/lldp_mand.c b/lldp_mand.c
index b17cc67..53a707c 100644
--- a/lldp_mand.c
+++ b/lldp_mand.c
@@ -160,7 +160,7 @@ static int mand_bld_end_tlv(struct mand_data *md)
  * - No validation on data loaded from config other than the subtype
  *
  */
-static int mand_bld_chassis_tlv(struct mand_data *md)
+static int mand_bld_chassis_tlv(struct mand_data *md, struct lldp_agent *agent)
 {
 	int rc = EINVAL;
 	int devtype;
@@ -185,10 +185,10 @@ static int mand_bld_chassis_tlv(struct mand_data *md)
 		goto bld_tlv;
 	
 	/* subtype may differ when LLDP-MED is enabled */
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_RESERVED)))
+	if (!is_tlv_txenabled(md->ifname, agent->type, TLVID_MED(LLDP_MED_RESERVED)))
 		goto bld_config;
 
-	devtype = get_med_devtype(md->ifname);
+	devtype = get_med_devtype(md->ifname, agent->type);
 	LLDPAD_DBG("%s:%s:MED enabled w/ devtype=%d)\n",
 			__func__, md->ifname, devtype);
 	if (devtype == LLDP_MED_DEVTYPE_NETWORK_CONNECTIVITY)
@@ -203,7 +203,7 @@ bld_config:
 	memset(chastr, 0, sizeof(chastr));
 
 	/* load from config */
-	if (get_config_tlvinfo_str(md->ifname, TLVID_NOUI(CHASSIS_ID_TLV),
+	if (get_config_tlvinfo_str(md->ifname, agent->type, TLVID_NOUI(CHASSIS_ID_TLV),
 		 		   chastr, sizeof(chastr)))
 		goto bld_macaddr;
 	length = strlen(chastr) / 2;
@@ -273,8 +273,9 @@ bld_tlv:
 	lldpad_shm_set_msap(md->ifname, CHASSIS_ID_TLV, (char *)tlv->info,
 			    tlv->length);
 
-	set_config_tlvinfo_bin(md->ifname, TLVID_NOUI(CHASSIS_ID_TLV),
-		 	       tlv->info, tlv->length);
+	set_config_tlvinfo_bin(md->ifname, agent->type,
+			       TLVID_NOUI(CHASSIS_ID_TLV),
+			       tlv->info, tlv->length);
 
 	rc = 0;
 out_err:
@@ -310,7 +311,7 @@ out_err:
  * - No validation on data loaded from config other than the subtype
  *
  */
-static int mand_bld_portid_tlv(struct mand_data *md)
+static int mand_bld_portid_tlv(struct mand_data *md, struct lldp_agent *agent)
 {
 	int rc = EINVAL;
 	int devtype;
@@ -336,10 +337,11 @@ static int mand_bld_portid_tlv(struct mand_data *md)
 		goto bld_tlv;
 
 	/* subtype may differ when LLDP-MED is enabled */
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_RESERVED)))
+	if (!is_tlv_txenabled(md->ifname, agent->type,
+			      TLVID_MED(LLDP_MED_RESERVED)))
 		goto bld_config;
 
-	devtype = get_med_devtype(md->ifname);
+	devtype = get_med_devtype(md->ifname, agent->type);
 	LLDPAD_DBG("%s:%s:MED enabled w/ devtype=%d)\n",
 			__func__, md->ifname, devtype);
 
@@ -350,8 +352,9 @@ bld_config:
 	/* load from config */
 
 	memset(porstr, 0, sizeof(porstr));
-	if (get_config_tlvinfo_str(md->ifname, TLVID_NOUI(PORT_ID_TLV),
-		 		   porstr, sizeof(porstr)))
+	if (get_config_tlvinfo_str(md->ifname, agent->type,
+				   TLVID_NOUI(PORT_ID_TLV),
+				   porstr, sizeof(porstr)))
 		goto bld_macaddr;
 	length = strlen(porstr) / 2;
 	if (hexstr2bin(porstr, (u8 *)&portid, length))
@@ -419,8 +422,9 @@ bld_tlv:
 	lldpad_shm_set_msap(md->ifname, PORT_ID_TLV, (char *)tlv->info,
 			    tlv->length);
 
-	set_config_tlvinfo_bin(md->ifname, TLVID_NOUI(PORT_ID_TLV),
-		 	       tlv->info, tlv->length);
+	set_config_tlvinfo_bin(md->ifname, agent->type,
+			       TLVID_NOUI(PORT_ID_TLV),
+			       tlv->info, tlv->length);
 	rc = 0;
 out_err:
 	return rc;
@@ -518,12 +522,12 @@ static int mand_bld_tlv(struct mand_data *md, struct lldp_agent *agent)
 		goto out_err;
 	}
 
-	if (mand_bld_chassis_tlv(md)) {
+	if (mand_bld_chassis_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s:mand_bld_chassis_tlv() failed\n",
 				__func__, md->ifname);
 		goto out_err;
 	}
-	if (mand_bld_portid_tlv(md)) {
+	if (mand_bld_portid_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s:mand_bld_portid_tlv() failed\n",
 				__func__, md->ifname);
 		goto out_err;
diff --git a/lldp_mand_cmds.c b/lldp_mand_cmds.c
index 07df099..cb95415 100644
--- a/lldp_mand_cmds.c
+++ b/lldp_mand_cmds.c
@@ -77,9 +77,9 @@ int get_arg_adminstatus(struct cmd *cmd, char *arg, char *argvalue,
 		return cmd_bad_params;
 
 	if (cmd->tlvid != INVALID_TLVID)
-    		return cmd_bad_params;
+		return cmd_bad_params;
 
-	if (get_config_setting(cmd->ifname, arg, (void *)&value,
+	if (get_config_setting(cmd->ifname, cmd->type, arg, (void *)&value,
 				CONFIG_TYPE_INT))
 		value = disabled;
 
@@ -226,7 +226,7 @@ int _set_arg_adminstatus(struct cmd *cmd, char *arg, char *argvalue,
 	if (test)
 		return cmd_success;
 
-	if (set_config_setting(cmd->ifname, arg, (void *)&value,
+	if (set_config_setting(cmd->ifname, cmd->type, arg, (void *)&value,
 			       CONFIG_TYPE_INT)) {
 		return cmd_failed;
 	}
diff --git a/lldp_med.c b/lldp_med.c
index ca79b7e..1804def 100644
--- a/lldp_med.c
+++ b/lldp_med.c
@@ -82,8 +82,8 @@ struct tlv_info_locid {
 } __attribute__ ((__packed__));
 
 static const struct lldp_mod_ops med_ops =  {
-	.lldp_mod_register 	= med_register,
-	.lldp_mod_unregister 	= med_unregister,
+	.lldp_mod_register	= med_register,
+	.lldp_mod_unregister	= med_unregister,
 	.lldp_mod_gettlv	= med_gettlv,
 	.lldp_mod_ifup		= med_ifup,
 	.lldp_mod_ifdown	= med_ifdown,
@@ -150,7 +150,8 @@ static u16 med_get_caps(u8 devtype)
  *
  * Returns 0 on success
  */
-static int med_bld_medcaps_tlv(struct med_data *md)
+static int med_bld_medcaps_tlv(struct med_data *md,
+			       struct lldp_agent *agent)
 {
 	int rc = EPERM;
 	struct tlv_info_medcaps medcaps;
@@ -160,7 +161,8 @@ static int med_bld_medcaps_tlv(struct med_data *md)
 	FREE_UNPKD_TLV(md, medcaps);
 
 	/* must be enabled */
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_CAPABILITIES))) {
+	if (!is_tlv_txenabled(md->ifname, agent->type,
+			      TLVID_MED(LLDP_MED_CAPABILITIES))) {
 		LLDPAD_DBG("%s:%s:MED Caps is not enabled\n",
 			__func__, md->ifname);
 		rc = 0;
@@ -169,7 +171,8 @@ static int med_bld_medcaps_tlv(struct med_data *md)
 
 	/* load cap tlv info from config */
 	memset(&medcaps, 0, sizeof(medcaps));
-	if (get_config_tlvinfo_bin(md->ifname, TLVID_MED(LLDP_MED_CAPABILITIES),
+	if (get_config_tlvinfo_bin(md->ifname, agent->type,
+				   TLVID_MED(LLDP_MED_CAPABILITIES),
 			  (void *)&medcaps, sizeof(medcaps))) {
 		LLDPAD_DBG("%s:%s:Build MED Caps as Endpoint Class I\n",
 			__func__, md->ifname);
@@ -178,7 +181,7 @@ static int med_bld_medcaps_tlv(struct med_data *md)
 
 	/* validate the data loaded */
 	if (LLDP_MED_DEVTYPE_DEFINED(medcaps.devtype) &&
-	    (medcaps.devtype == get_med_devtype(md->ifname))) {
+	    (medcaps.devtype == get_med_devtype(md->ifname, agent->type))) {
 		LLDPAD_DBG("%s:%s:MED Caps loaded from config as type %d\n",
 			__func__, md->ifname, medcaps.devtype);
 		goto out_create;
@@ -190,7 +193,7 @@ out_bld:
 	/* Not in config, build from scratch */
 	hton24(medcaps.oui, OUI_TIA_TR41);
 	medcaps.subtype = LLDP_MED_CAPABILITIES;
-	medcaps.devtype = get_med_devtype(md->ifname);
+	medcaps.devtype = get_med_devtype(md->ifname, agent->type);
 	medcaps.medcaps = htons(med_get_caps(medcaps.devtype));
 
 out_create:
@@ -211,8 +214,9 @@ out_create:
 	}
 	memcpy(tlv->info, &medcaps, tlv->length);
 	md->medcaps = tlv;
-	set_med_devtype(md->ifname, medcaps.devtype);
-	set_config_tlvinfo_bin(md->ifname, TLVID_MED(LLDP_MED_CAPABILITIES),
+	set_med_devtype(md->ifname, agent->type, medcaps.devtype);
+	set_config_tlvinfo_bin(md->ifname, agent->type,
+			       TLVID_MED(LLDP_MED_CAPABILITIES),
 			       &medcaps, sizeof(medcaps));
 	rc = 0;
 out_err:
@@ -294,13 +298,16 @@ out_err:
  * @md: the med data struct
  * @subtype: LLDP-MED inventory tlv subtype
  */
-static struct unpacked_tlv *med_bld_invtlv(struct med_data *md, u8 subtype)
+static struct unpacked_tlv *med_bld_invtlv(struct med_data *md,
+					   struct lldp_agent *agent,
+					   u8 subtype)
 {
 	int length;
 	u8 desc[33];
 	struct unpacked_tlv *tlv = NULL;
 
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(subtype))) {
+	if (!is_tlv_txenabled(md->ifname, agent->type,
+			      TLVID_MED(subtype))) {
 		LLDPAD_DBG("%s:%s:subtype %d tx disabled\n",
 			__func__, md->ifname, subtype);
 		goto out_err;
@@ -344,7 +351,8 @@ out_err:
  * @md: the med data struct
  *
  */
-static int med_bld_inventory_tlv(struct med_data *md)
+static int med_bld_inventory_tlv(struct med_data *md,
+				 struct lldp_agent *agent)
 {
 	FREE_UNPKD_TLV(md, inv_hwrev);
 	FREE_UNPKD_TLV(md, inv_fwrev);
@@ -353,13 +361,13 @@ static int med_bld_inventory_tlv(struct med_data *md)
 	FREE_UNPKD_TLV(md, inv_manufacturer);
 	FREE_UNPKD_TLV(md, inv_modelname);
 	FREE_UNPKD_TLV(md, inv_assetid);
-	md->inv_hwrev = med_bld_invtlv(md, LLDP_MED_INV_HWREV);
-	md->inv_fwrev = med_bld_invtlv(md, LLDP_MED_INV_FWREV);
-	md->inv_swrev = med_bld_invtlv(md, LLDP_MED_INV_SWREV);
-	md->inv_serial = med_bld_invtlv(md, LLDP_MED_INV_SERIAL);
-	md->inv_manufacturer = 	med_bld_invtlv(md, LLDP_MED_INV_MANUFACTURER);
-	md->inv_modelname = med_bld_invtlv(md, LLDP_MED_INV_MODELNAME);
-	md->inv_assetid = med_bld_invtlv(md, LLDP_MED_INV_ASSETID);
+	md->inv_hwrev = med_bld_invtlv(md, agent, LLDP_MED_INV_HWREV);
+	md->inv_fwrev = med_bld_invtlv(md, agent, LLDP_MED_INV_FWREV);
+	md->inv_swrev = med_bld_invtlv(md, agent, LLDP_MED_INV_SWREV);
+	md->inv_serial = med_bld_invtlv(md, agent, LLDP_MED_INV_SERIAL);
+	md->inv_manufacturer = med_bld_invtlv(md, agent, LLDP_MED_INV_MANUFACTURER);
+	md->inv_modelname = med_bld_invtlv(md, agent, LLDP_MED_INV_MODELNAME);
+	md->inv_assetid = med_bld_invtlv(md, agent, LLDP_MED_INV_ASSETID);
 	return 0;
 }
 
@@ -388,7 +396,8 @@ static int med_is_pse(const char *ifname)
  * Optional Power via MDI TLV.
  *
  */
-static int med_bld_powvmdi_tlv(struct med_data *md)
+static int med_bld_powvmdi_tlv(struct med_data *md,
+			       struct lldp_agent *agent)
 {
 	int rc = EINVAL;
 	int devtype;
@@ -399,7 +408,7 @@ static int med_bld_powvmdi_tlv(struct med_data *md)
 	/* free old one if it exists */
 	FREE_UNPKD_TLV(md, extpvm);
 
-	devtype = get_med_devtype(md->ifname);
+	devtype = get_med_devtype(md->ifname, agent->type);
 	switch (devtype) {
 	case LLDP_MED_DEVTYPE_NETWORK_CONNECTIVITY:
 		mandatory = med_is_pse(md->ifname);
@@ -423,7 +432,8 @@ static int med_bld_powvmdi_tlv(struct med_data *md)
 		goto out_err;
 	}
 	/* Mandatory */
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_EXTENDED_PVMDI))) {
+	if (!is_tlv_txenabled(md->ifname, agent->type,
+			      TLVID_MED(LLDP_MED_EXTENDED_PVMDI))) {
 		LLDPAD_DBG("%s:%s: Must enable Extended Power via MDI TLV as it"
 			" mandatory for device type %d\n",
 			__func__, md->ifname, devtype);
@@ -431,7 +441,8 @@ static int med_bld_powvmdi_tlv(struct med_data *md)
 		goto out_err;
 	}
 	/* Load from config */
-	if (get_config_tlvinfo_bin(md->ifname, TLVID_MED(LLDP_MED_NETWORK_POLICY),
+	if (get_config_tlvinfo_bin(md->ifname, agent->type,
+				   TLVID_MED(LLDP_MED_NETWORK_POLICY),
 			       (void *)&extpvm, sizeof(extpvm))) {
 		LLDPAD_DBG("%s:%s: Must configure Extended Power via MDI TLV as "
 			" currently it has to be manually configured\n",
@@ -440,7 +451,8 @@ static int med_bld_powvmdi_tlv(struct med_data *md)
 		goto out_err;
 	}
 	/* disable Optional Power via MDI */
-	tlv_disabletx(md->ifname, TLVID_8023(LLDP_8023_POWER_VIA_MDI));
+	tlv_disabletx(md->ifname, agent->type,
+		      TLVID_8023(LLDP_8023_POWER_VIA_MDI));
 
 	/* We should have a valid tlv_info_extpvm here */
 	if (extpvm.subtype != LLDP_MED_EXTENDED_PVMDI) {
@@ -481,7 +493,8 @@ out_err:
  * if it's not configured
  *
  */
-static int med_bld_locid_tlv(struct med_data *md)
+static int med_bld_locid_tlv(struct med_data *md,
+			     struct lldp_agent *agent)
 {
 	int rc = 0;
 	size_t length;
@@ -492,7 +505,8 @@ static int med_bld_locid_tlv(struct med_data *md)
 	/* free old one if it exists */
 	FREE_UNPKD_TLV(md, locid);
 
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_LOCATION_ID))) {
+	if (!is_tlv_txenabled(md->ifname, agent->type,
+			      TLVID_MED(LLDP_MED_LOCATION_ID))) {
 		LLDPAD_DBG("%s:%s:Location Id TLV is not enabled\n",
 			__func__, md->ifname);
 		rc = 0;
@@ -506,8 +520,9 @@ static int med_bld_locid_tlv(struct med_data *md)
 		goto out_err;
 
 	memset(locstr, 0, length);
-	if (get_config_tlvinfo_str(md->ifname, TLVID_MED(LLDP_MED_LOCATION_ID),
-			       	      (void *)locstr, length)) {
+	if (get_config_tlvinfo_str(md->ifname, agent->type,
+				   TLVID_MED(LLDP_MED_LOCATION_ID),
+				   (void *)locstr, length)) {
 		LLDPAD_DBG("%s:%s:Location Id TLV must be"
 			" administratively configured\n",
 			__func__, md->ifname);
@@ -562,12 +577,16 @@ out_err:
  * TODO: currently only supports load from config, will fail if it's
  * not configured
  */
-static int med_get_netpoli(struct med_data *md, struct tlv_info_netpoli *n)
+static int med_get_netpoli(struct med_data *md,
+			   struct lldp_agent *agent,
+			   struct tlv_info_netpoli *n)
 {
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_NETWORK_POLICY)))
+	if (!is_tlv_txenabled(md->ifname, agent->type,
+			      TLVID_MED(LLDP_MED_NETWORK_POLICY)))
 		return ENOENT;
 
-	if (!get_config_tlvinfo_bin(md->ifname, TLVID_MED(LLDP_MED_NETWORK_POLICY),
+	if (!get_config_tlvinfo_bin(md->ifname, agent->type,
+				    TLVID_MED(LLDP_MED_NETWORK_POLICY),
 			       (void *)n, sizeof(*n)))
 		return 0;
 	return EPERM;
@@ -579,7 +598,8 @@ static int med_get_netpoli(struct med_data *md, struct tlv_info_netpoli *n)
  *
  * Returns 0 for success or error code for failure
  */
-static int med_bld_netpoli_tlv(struct med_data *md)
+static int med_bld_netpoli_tlv(struct med_data *md,
+			       struct lldp_agent *agent)
 {
 	int rc = EPERM;
 	int devtype;
@@ -589,11 +609,11 @@ static int med_bld_netpoli_tlv(struct med_data *md)
 	/* free old one if it exists */
 	FREE_UNPKD_TLV(md, netpoli);
 
-	devtype = get_med_devtype(md->ifname);
+	devtype = get_med_devtype(md->ifname, agent->type);
 	switch (devtype) {
 	case LLDP_MED_DEVTYPE_NETWORK_CONNECTIVITY:
 		/* Only transmit if it is administratively configured */
-		rc = med_get_netpoli(md, &netpoli);
+		rc = med_get_netpoli(md, agent, &netpoli);
 		if (rc == ENOENT)
 			goto out_nobld;
 		if (rc == EPERM) {
@@ -606,7 +626,7 @@ static int med_bld_netpoli_tlv(struct med_data *md)
 		break;
 	case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_I:
 		/* Optional: skip if failed to get it */
-		if (med_get_netpoli(md, &netpoli)) {
+		if (med_get_netpoli(md, agent, &netpoli)) {
 			LLDPAD_DBG("%s:%s: Skipping"
 				" Network Policy TLV for Class I Device\n",
 			 	__func__, md->ifname);
@@ -616,7 +636,7 @@ static int med_bld_netpoli_tlv(struct med_data *md)
 	case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_II:
 	case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_III:
 		/* Mandatory */
-		if (med_get_netpoli(md, &netpoli)) {
+		if (med_get_netpoli(md, agent, &netpoli)) {
 			LLDPAD_DBG("%s:%s: Must enable and configure"
 				" Network Policy TLV for Class II/III Device\n",
 			 	__func__, md->ifname);
@@ -668,7 +688,8 @@ out_err:
  * Returns 0 for success or error code for failure
  *
  */
-static int med_bld_tlv(struct med_data *md)
+static int med_bld_tlv(struct med_data *md,
+		       struct lldp_agent *agent)
 {
 	int rc = EPERM;
 
@@ -678,7 +699,8 @@ static int med_bld_tlv(struct med_data *md)
 	}
 
 	/* no build if not enabled */
-	if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_RESERVED))) {
+	if (!is_tlv_txenabled(md->ifname, agent->type,
+			      TLVID_MED(LLDP_MED_RESERVED))) {
 		LLDPAD_DBG("%s:%s:LLDP-MED is not enabled\n",
 			__func__, md->ifname);
 		rc = 0;
@@ -686,21 +708,21 @@ static int med_bld_tlv(struct med_data *md)
 	}
 
 	/* no build if enabled no devtype is given */
-	if (!LLDP_MED_DEVTYPE_DEFINED(get_med_devtype(md->ifname))) {
+	if (!LLDP_MED_DEVTYPE_DEFINED(get_med_devtype(md->ifname, agent->type))) {
 		LLDPAD_DBG("%s:%s:LLDP-MED devtype is not defined\n",
 			__func__, md->ifname);
 		goto out_err;
 	}
 
 	/* MED Cap is always mandatory for MED */
-	if (med_bld_medcaps_tlv(md)) {
+	if (med_bld_medcaps_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s:MED Capabilities TLV is mandatory!\n",
 			__func__, md->ifname);
 		goto out_err;
 	}
 
 	/* MAC PHY TLV is mandatory for MED */
-	if (!is_tlv_txenabled(md->ifname, 
+	if (!is_tlv_txenabled(md->ifname, agent->type, 
 			      TLVID_8023(LLDP_8023_MACPHY_CONFIG_STATUS))) {
 		LLDPAD_DBG("%s:%s MAC PHY Config is mandatory for MED\n",
 				__func__, md->ifname);
@@ -709,7 +731,7 @@ static int med_bld_tlv(struct med_data *md)
 	}
 
 	/* Build optional and conditional ones based on device type:
- 	 *
+	 *
 	 * LLDP-MED Endpoint Class I TLV Set: ANSI/TIA-1057-2006, 10.2.1.2
 	 *	- Capabilities: mandatory
 	 * 	- Network Policy: optional
@@ -737,22 +759,22 @@ static int med_bld_tlv(struct med_data *md)
 	 * 	- Inventory: optional
 	 *
 	 */
-	if (med_bld_netpoli_tlv(md)) {
+	if (med_bld_netpoli_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s:med_bld_netpoli_tlv() failed\n",
 				__func__, md->ifname);
 		goto out_err;
 	}
-	if (med_bld_locid_tlv(md)) {
+	if (med_bld_locid_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s:med_bld_locid_tlv() failed\n",
 				__func__, md->ifname);
 		goto out_err;
 	}
-	if (med_bld_powvmdi_tlv(md)) {
+	if (med_bld_powvmdi_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s:med_bld_powvmdi_tlv() failed\n",
 				__func__, md->ifname);
 		goto out_err;
 	}
-	if (med_bld_inventory_tlv(md)) {
+	if (med_bld_inventory_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s:med_bld_inventory_tlv() failed\n",
 				__func__, md->ifname);
 		goto out_err;
@@ -810,7 +832,7 @@ struct packed_tlv *med_gettlv(struct port *port,
 		goto out_err;
 
 	med_free_tlv(md);
-	if (med_bld_tlv(md)) {
+	if (med_bld_tlv(md, agent)) {
 		goto out_err;
 	}
 
@@ -898,7 +920,7 @@ void med_ifup(char *ifname, struct lldp_agent *agent)
 	strncpy(md->ifname, ifname, IFNAMSIZ);
 	md->agenttype = agent->type;
 
-	if (med_bld_tlv(md)) {
+	if (med_bld_tlv(md, agent)) {
 		LLDPAD_DBG("%s:%s med_bld_tlv failed\n",
 			__func__, ifname);
 		free(md);
diff --git a/lldp_med_cmds.c b/lldp_med_cmds.c
index a5a4db8..66a08ae 100644
--- a/lldp_med_cmds.c
+++ b/lldp_med_cmds.c
@@ -85,8 +85,9 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 		snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
 			 TLVID_PREFIX, cmd->tlvid, arg);
 
-		if (get_config_setting(cmd->ifname, arg_path, (void *)&value,
-					CONFIG_TYPE_BOOL))
+		if (get_config_setting(cmd->ifname, cmd->type, arg_path,
+				       (void *)&value,
+				       CONFIG_TYPE_BOOL))
 			value = false;
 		break;
 	case INVALID_TLVID:
@@ -148,8 +149,8 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
 		 cmd->tlvid, arg);
 
-	if (set_config_setting(cmd->ifname, arg_path, (void *)&value,
-			       CONFIG_TYPE_BOOL))
+	if (set_config_setting(cmd->ifname, cmd->type, arg_path,
+			       (void *)&value, CONFIG_TYPE_BOOL))
 		return cmd_failed;
 
 	snprintf(obuf, obuf_len, "enableTx = %s\n", value ? "yes" : "no");
@@ -182,7 +183,7 @@ static int get_arg_med_devtype(struct cmd *cmd, char *arg, char *argvalue,
 
 	switch (cmd->tlvid) {
 	case (OUI_TIA_TR41 << 8):
-		value = get_med_devtype(cmd->ifname);
+		value = get_med_devtype(cmd->ifname, cmd->type);
 		break;
 	case (OUI_TIA_TR41 << 8) | LLDP_MED_CAPABILITIES:
 	case (OUI_TIA_TR41 << 8) | LLDP_MED_NETWORK_POLICY:
@@ -276,41 +277,41 @@ static int _set_arg_med_devtype(struct cmd *cmd, char *arg, char *argvalue,
 	if (test)
 		return cmd_success;
 
-	set_med_devtype(cmd->ifname, value);
+	set_med_devtype(cmd->ifname, cmd->type, value);
 
 	/* set up default enabletx values based on class type */
 	switch (value) {
 	case LLDP_MED_DEVTYPE_NOT_DEFINED:
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_RESERVED);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_CAPABILITIES);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_NETWORK_POLICY);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_LOCATION_ID);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_EXTENDED_PVMDI);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_HWREV);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_FWREV);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SWREV);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SERIAL);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MANUFACTURER);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MODELNAME);
-		tlv_disabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_ASSETID);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_RESERVED);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_CAPABILITIES);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_NETWORK_POLICY);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_LOCATION_ID);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_EXTENDED_PVMDI);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_HWREV);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_FWREV);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SWREV);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SERIAL);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MANUFACTURER);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MODELNAME);
+		tlv_disabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_ASSETID);
 		break;
 
 	case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_III:
 	case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_II:
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_NETWORK_POLICY);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_NETWORK_POLICY);
 	case LLDP_MED_DEVTYPE_ENDPOINT_CLASS_I:
 	case LLDP_MED_DEVTYPE_NETWORK_CONNECTIVITY:
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_RESERVED);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_CAPABILITIES);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_HWREV);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_FWREV);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SWREV);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SERIAL);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MANUFACTURER);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MODELNAME);
-		tlv_enabletx(cmd->ifname, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_ASSETID);
-		tlv_enabletx(cmd->ifname, SYSTEM_CAPABILITIES_TLV);
-		tlv_enabletx(cmd->ifname, (LLDP_MOD_8023 << 8) | LLDP_8023_MACPHY_CONFIG_STATUS);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_RESERVED);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_CAPABILITIES);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_HWREV);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_FWREV);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SWREV);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_SERIAL);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MANUFACTURER);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_MODELNAME);
+		tlv_enabletx(cmd->ifname, cmd->type, (OUI_TIA_TR41 << 8) | LLDP_MED_INV_ASSETID);
+		tlv_enabletx(cmd->ifname, cmd->type, SYSTEM_CAPABILITIES_TLV);
+		tlv_enabletx(cmd->ifname, cmd->type, (LLDP_MOD_8023 << 8) | LLDP_8023_MACPHY_CONFIG_STATUS);
 		break;
 	default:
 		return cmd_failed;
diff --git a/lldp_vdp.c b/lldp_vdp.c
index b0edaab..8581849 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -1382,8 +1382,8 @@ void vdp_ifup(char *ifname, struct lldp_agent *agent)
 	snprintf(config_path, sizeof(config_path), "%s.%s",
 		 VDP_PREFIX, ARG_TLVTXENABLE);
 
-	if (get_config_setting(ifname, config_path, (void *)&enabletx,
-		    CONFIG_TYPE_BOOL))
+	if (get_config_setting(ifname, NEAREST_BRIDGE, config_path,
+			       (void *)&enabletx, CONFIG_TYPE_BOOL))
 			enabletx = false;
 
 	if (enabletx == false) {
@@ -1413,7 +1413,7 @@ void vdp_ifup(char *ifname, struct lldp_agent *agent)
 	vd->role = VDP_ROLE_STATION;
 	vd->enabletx = enabletx;
 
-	if (!get_cfg(ifname, "vdp.role", (void *)&role,
+	if (!get_cfg(ifname, NEAREST_BRIDGE, "vdp.role", (void *)&role,
 		    CONFIG_TYPE_STRING)) {
 		if (!strcasecmp(role, VAL_BRIDGE)) {
 			vd->role = VDP_ROLE_BRIDGE;
diff --git a/lldp_vdp_cmds.c b/lldp_vdp_cmds.c
index 04f6fc1..5549981 100644
--- a/lldp_vdp_cmds.c
+++ b/lldp_vdp_cmds.c
@@ -166,7 +166,7 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 		snprintf(arg_path, sizeof(arg_path), "%s.%s",
 			 VDP_PREFIX, arg);
 
-		if (get_cfg(cmd->ifname, arg_path, (void *)&value,
+		if (get_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value,
 		    CONFIG_TYPE_BOOL))
 			value = false;
 		break;
@@ -217,10 +217,11 @@ static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
 
 	snprintf(arg_path, sizeof(arg_path), "%s.%s", VDP_PREFIX, arg);
 
-	if (set_cfg(cmd->ifname, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
-		return cmd_failed;
+       if (set_cfg(cmd->ifname, cmd->type, arg_path, (void *)&value, CONFIG_TYPE_BOOL))
+               return cmd_failed;
 
 	return cmd_success;
+
 }
 
 static int set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
@@ -527,7 +528,8 @@ static int _set_arg_role(struct cmd *cmd, char *arg, char *argvalue,
 	snprintf(arg_path, sizeof(arg_path), "%s.%s", VDP_PREFIX, arg);
 
 	char *p = &argvalue[0];
-	if (set_cfg(cmd->ifname, arg_path, (void *)&p, CONFIG_TYPE_STRING))
+	if (set_cfg(cmd->ifname, cmd->type, arg_path, (void *)&p,
+		    CONFIG_TYPE_STRING))
 		return cmd_failed;
 
 	return cmd_success;
diff --git a/lldptool.c b/lldptool.c
index db77a6e..fccda6a 100644
--- a/lldptool.c
+++ b/lldptool.c
@@ -139,7 +139,11 @@ static const char *commands_options =
 "                                       implemented for DCBX App TLV settings)\n"
 "  -n                                   \"neighbor\" option for command\n"
 "  -r                                   show raw message\n"
-"  -R                                   show only raw messages\n";
+"  -R                                   show only raw messages\n"
+"  -g					destination agent (may be one of):\n"
+"						- nearestbridge (nb) (default)\n"
+"						- nearestcustomerbridge (ncb)\n"
+"						- nearestnontpmrbridge (nntpmrb)\n";
 
 static const char *commands_help =
 "Commands:\n"
@@ -214,7 +218,7 @@ int hex2int(char *b)
 	int i;
 	int n=0;
 	int m;
-	
+
 	for (i=0,m=1; i<2; i++,m--) {
 		if (isxdigit(*(b+i))) {
 			if (*(b+i) <= '9')
@@ -443,12 +447,13 @@ static int request(struct clif *clif, int argc, char *argv[])
 
 	memset((void *)&command, 0, sizeof(command));
 	command.cmd = cmd_nop;
+	command.type = NEAREST_BRIDGE;
 	command.module_id = LLDP_MOD_MAND;
 	command.tlvid = INVALID_TLVID;
 
 	opterr = 0;
 	for (;;) {
-		c = getopt(argc, argv, "Si:tTlLhcdnvrRqV:");
+		c = getopt(argc, argv, "Si:tTlLhcdnvrRqV:g:");
 		if (c < 0)
 			break;
 		switch (c) {
@@ -463,6 +468,21 @@ static int request(struct clif *clif, int argc, char *argv[])
 			strncpy(command.ifname, optarg, IFNAMSIZ);
 			command.ifname[IFNAMSIZ] ='\0';
 			break;
+		case 'g':
+			if (!strcasecmp(optarg, "nearestbridge") ||
+			    !strcasecmp(optarg, "nb"))
+				command.type = NEAREST_BRIDGE;
+			else if (!strcasecmp(optarg, "nearestcustomerbridge") ||
+				 !strcasecmp(optarg, "ncb"))
+				command.type = NEAREST_CUSTOMER_BRIDGE;
+			else if (!strcasecmp(optarg, "nearestnontmprbridge") ||
+				 !strcasecmp(optarg, "nntpmrb"))
+				command.type = NEAREST_NONTPMR_BRIDGE;
+			else {
+				printf("Invalid agent specified !\n\n");
+				return -1;
+			}
+			break;
 		case 'V':
 			if (command.tlvid != INVALID_TLVID) {
 				printf("\nInvalid command: multiple TLV "
diff --git a/lldptool_cmds.c b/lldptool_cmds.c
index d0985f6..26d4e33 100644
--- a/lldptool_cmds.c
+++ b/lldptool_cmds.c
@@ -48,10 +48,10 @@ static int render_cmd(struct cmd *cmd, int argc, char **args, char **argvals)
 	len = sizeof(cmd->obuf);
 
 	/* all command messages begin this way */
-	snprintf(cmd->obuf, len, "%c%08x%c%1x%02x%08x%02x%s",
+	snprintf(cmd->obuf, len, "%c%08x%c%1x%02x%08x%02x%s%02x",
 		MOD_CMD, cmd->module_id, CMD_REQUEST, CLIF_MSG_VERSION,
 		cmd->cmd, cmd->ops, (unsigned int) strlen(cmd->ifname),
-		cmd->ifname);
+		cmd->ifname, cmd->type);
 
 	/* if the command is a tlv command, add the tlvid to the message */
 	if (cmd->cmd == cmd_gettlv || cmd->cmd == cmd_settlv)
-- 
1.7.4.4




More information about the lldp-devel mailing list