From 3a3fee0ef3c0310b0ccce2eaa1d729b038b6c35b Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakob.olsson@iopsys.eu>
Date: Fri, 7 May 2021 13:10:16 +0200
Subject: [PATCH] map-controller: prepare vendor extension through new wsc api

---
 src/core/cntlr_tlv_generator.c | 13 ++++++++++++-
 src/core/config.h              |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/core/cntlr_tlv_generator.c b/src/core/cntlr_tlv_generator.c
index a5de7837..984ce596 100644
--- a/src/core/cntlr_tlv_generator.c
+++ b/src/core/cntlr_tlv_generator.c
@@ -237,6 +237,9 @@ int cntlr_gen_wsc(struct controller *c, struct cmdu_buff *frm,
 	uint8_t *m2;
 	uint16_t m2_size;
 	int i, rv, ret;
+	uint8_t oui[3] = {IOP_VENDOR_ID_1, IOP_VENDOR_ID_2, IOP_VENDOR_ID_3};
+	uint8_t out[256] = {0};
+	size_t olen = 256;
 
 	t = cmdu_reserve_tlv(frm, 2000);
 	if (!t)
@@ -278,7 +281,15 @@ int cntlr_gen_wsc(struct controller *c, struct cmdu_buff *frm,
 	memcpy(cred.bk_ssid, iface_cred->bk_ssid, sizeof(iface_cred->bk_ssid));
 	memcpy(cred.bk_key, iface_cred->bk_key, sizeof(iface_cred->bk_key));
 
-	ret = wsc_build_m2(msg, msglen, &cred, &m2, &m2_size);
+	wsc_build_vendor_extension(out, &olen, oui,
+		ATTR_BRIDGE, strlen(iface_cred->br->network), iface_cred->br->network,
+		ATTR_PROTO, strlen(iface_cred->br->proto), iface_cred->br->proto,
+		ATTR_VID, 2, &(iface_cred->br->id),
+		ATTR_BK_KEY, strlen(iface_cred->bk_key), iface_cred->bk_key,
+		ATTR_BK_SSID, strlen(iface_cred->bk_ssid), iface_cred->bk_ssid,
+		-1);
+
+	ret = wsc_build_m2(msg, msglen, &cred, out, olen, &m2, &m2_size);
 	if (ret) {
 		dbg("Error building m2!\n");
 		return ret;
diff --git a/src/core/config.h b/src/core/config.h
index f2016903..537ca667 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -32,7 +32,7 @@ struct stax {
 struct netif_vlan {
 	char network[16];
 	char proto[8];
-	uint8_t id;
+	uint16_t id;
 	struct ip_address ipaddr;
 	struct list_head list;
 };
-- 
GitLab