[PATCH 3/5] WNM: add option to configure candidates for BTM query candidate list

Andrei Otcheretianski andrei.otcheretianski at intel.com
Wed Mar 8 04:37:40 PST 2017


From: Avraham Stern <avraham.stern at intel.com>

Add a testing mechanism to configure the candidates for BTM query
candidate list manually. This can be used to verify AP behavior for
various candidates preferences.

usage:
wnm_bss_query <reason> [neighbor=<BSSID>,<BSSID information>,
	                <operating class>,<channel number>,
			<PHY type>[,<hexdump of optional subelements>]]

Signed-off-by: Avraham Stern <avraham.stern at intel.com>
---
 wpa_supplicant/ctrl_iface.c | 18 +++++++++++++++---
 wpa_supplicant/wnm_sta.c    | 28 +++++++++++++++++++++++++++-
 wpa_supplicant/wnm_sta.h    |  7 ++++++-
 3 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 14dcdcd..a35917b 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -7156,26 +7156,38 @@ static int wpas_ctrl_iface_wnm_sleep(struct wpa_supplicant *wpa_s, char *cmd)
 static int wpas_ctrl_iface_wnm_bss_query(struct wpa_supplicant *wpa_s, char *cmd)
 {
 	int query_reason, list = 0;
+#ifdef CONFIG_TESTING_OPTIONS
+	char *btm_candidates = NULL;
+#endif
 
 	query_reason = atoi(cmd);
 
 	cmd = os_strchr(cmd, ' ');
 	if (cmd) {
-		cmd++;
-		if (os_strncmp(cmd, "list", 4) == 0) {
+		if (os_strncmp(cmd, " list", 5) == 0) {
 			list = 1;
+#ifdef CONFIG_TESTING_OPTIONS
+		} else {
+			btm_candidates = cmd;
+		}
+#else
 		} else {
 			wpa_printf(MSG_DEBUG, "WNM Query: Invalid option %s",
 				   cmd);
 			return -1;
 		}
+#endif
 	}
 
 	wpa_printf(MSG_DEBUG,
 		   "CTRL_IFACE: WNM_BSS_QUERY query_reason=%d%s",
 		   query_reason, list ? " candidate list" : "");
 
-	return wnm_send_bss_transition_mgmt_query(wpa_s, query_reason, list);
+	return wnm_send_bss_transition_mgmt_query(wpa_s, query_reason,
+#ifdef CONFIG_TESTING_OPTIONS
+						  btm_candidates,
+#endif
+						  list);
 }
 
 #endif /* CONFIG_WNM */
diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index 3ac568e..e51c5d5 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -1486,7 +1486,11 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
 #define BTM_QUERY_MIN_SIZE	4
 
 int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s,
-				       u8 query_reason, int cand_list)
+				       u8 query_reason,
+#ifdef CONFIG_TESTING_OPTIONS
+				       char *btm_candidates,
+#endif
+				       int cand_list)
 {
 	struct wpabuf *buf;
 	int ret;
@@ -1508,6 +1512,28 @@ int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s,
 	if (cand_list)
 		wnm_add_cand_list(wpa_s, &buf);
 
+#ifdef CONFIG_TESTING_OPTIONS
+	if (btm_candidates) {
+		u8 *candidates;
+
+		ret = wpabuf_resize(&buf, 1000);
+		if (ret < 0) {
+			wpabuf_free(buf);
+			return ret;
+		}
+
+		candidates = wpabuf_put(buf, 0);
+		ret = ieee802_11_parse_candidate_list(btm_candidates,
+						      candidates, 1000);
+		if (ret < 0) {
+			wpabuf_free(buf);
+			return ret;
+		}
+
+		wpabuf_put(buf, ret);
+	}
+#endif
+
 	ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
 				  wpa_s->own_addr, wpa_s->bssid,
 				  wpabuf_head_u8(buf), wpabuf_len(buf), 0);
diff --git a/wpa_supplicant/wnm_sta.h b/wpa_supplicant/wnm_sta.h
index 78b87d0..167874d 100644
--- a/wpa_supplicant/wnm_sta.h
+++ b/wpa_supplicant/wnm_sta.h
@@ -60,7 +60,12 @@ void ieee802_11_rx_wnm_action(struct wpa_supplicant *wpa_s,
 			      const struct ieee80211_mgmt *mgmt, size_t len);
 
 int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s,
-				       u8 query_reason, int cand_list);
+				       u8 query_reason,
+#ifdef CONFIG_TESTING_OPTIONS
+				       char *btm_candidates,
+#endif
+				       int cand_list);
+
 void wnm_deallocate_memory(struct wpa_supplicant *wpa_s);
 
 
-- 
1.9.1




More information about the Hostap mailing list