From 5e463ee6acc8e58820f677eae8575a514b28c5c4 Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakob.olsson@iopsys.eu>
Date: Wed, 9 Jun 2021 10:14:57 +0200
Subject: [PATCH] cntlr_map: only discard self autoconfig search if
 supportedRole=cntlr

---
 src/core/cntlr_map.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/core/cntlr_map.c b/src/core/cntlr_map.c
index 67491ee3..e322e3db 100644
--- a/src/core/cntlr_map.c
+++ b/src/core/cntlr_map.c
@@ -210,11 +210,6 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rx_cmdu)
 		return -1;
 	}
 
-	if (!memcmp(aladdr_origin, c->almac, 6)) {
-		trace("%s: Discard ap-autoconfig search from self\n", __func__);
-		return -1;
-	}
-
 	if (tv[1][0]->data[0] != IEEE80211_ROLE_REGISTRAR) {
 		trace("%s: Discard ap-autoconfig search for role != registrar\n",
 			__func__);
@@ -247,12 +242,20 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rx_cmdu)
 			return -1;
 
 		for (i = 1; i <= tv[3][0]->data[0]; i++) {
-			if (tv[3][0]->data[i] != SUPPORTED_SERVICE_MULTIAP_AGENT)
-				continue;
-
-			ret = cntlr_config_add_agent(&c->cfg, mac_str);
-			if (!ret)
-				cntlr_config_reload(&c->cfg);
+			if (tv[3][0]->data[i] ==
+					SUPPORTED_SERVICE_MULTIAP_AGENT) {
+				ret = cntlr_config_add_agent(&c->cfg, mac_str);
+				if (!ret)
+					cntlr_config_reload(&c->cfg);
+			} else if (tv[3][0]->data[i] ==
+					SUPPORTED_SERVICE_MULTIAP_CONTROLLER) {
+				if (!memcmp(aladdr_origin, c->almac, 6)) {
+					trace("%s: Discard ap-autoconfig "\
+							"search from self\n",
+							__func__);
+					return -1;
+				}
+			}
 			break;
 		}
 	}
-- 
GitLab