[PATCH 25/25] MBO: send WNM notification when cellular capabilities change

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Avraham Stern <avraham.stern@xxxxxxxxx>

Send a WNM notification to the connected AP to indicate changes
in cellular data capabilities.

Signed-off-by: Avraham Stern <avraham.stern@xxxxxxxxx>
---
 wpa_supplicant/ctrl_iface.c       |  2 ++
 wpa_supplicant/mbo.c              | 46 +++++++++++++++++++++++++++++++++++----
 wpa_supplicant/wpa_supplicant_i.h |  1 +
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 311bbe1..eb6d842 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -493,6 +493,8 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
 #ifdef CONFIG_MBO
 	} else if (os_strcasecmp(cmd, "np_chan") == 0) {
 		ret = wpas_mbo_update_np_chan(wpa_s, value);
+	} else if (os_strcasecmp(cmd, "mbo_cell_capa") == 0) {
+		wpas_mbo_update_cell_capa(wpa_s, atoi(value));
 #endif
 	} else {
 		value[-1] = '=';
diff --git a/wpa_supplicant/mbo.c b/wpa_supplicant/mbo.c
index af7edde..55961bc 100644
--- a/wpa_supplicant/mbo.c
+++ b/wpa_supplicant/mbo.c
@@ -178,7 +178,8 @@ int wpas_mbo_ie(struct wpa_supplicant *wpa_s, u8 *buf, size_t len)
 }
 
 
-static void wpas_mbo_send_wnm_notification(struct wpa_supplicant *wpa_s)
+static void wpas_mbo_send_wnm_notification(struct wpa_supplicant *wpa_s,
+					   const u8 *data, size_t len)
 {
 	struct wpabuf *buf;
 	int res;
@@ -191,7 +192,7 @@ static void wpas_mbo_send_wnm_notification(struct wpa_supplicant *wpa_s)
 					   MBO_OUI_TYPE))
 		return;
 
-	buf = wpabuf_alloc(512);
+	buf = wpabuf_alloc(4 + len);
 	if (!buf)
 		return;
 
@@ -200,7 +201,7 @@ static void wpas_mbo_send_wnm_notification(struct wpa_supplicant *wpa_s)
 	wpabuf_put_u8(buf, ++wpa_s->mbo_wnm_token);
 	wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC); /* Type */
 
-	wpas_mbo_np_chan_attrs(wpa_s, buf, 1);
+	wpabuf_put_data(buf, data, len);
 
 	res = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
 				  wpa_s->own_addr, wpa_s->bssid,
@@ -213,6 +214,20 @@ static void wpas_mbo_send_wnm_notification(struct wpa_supplicant *wpa_s)
 }
 
 
+static void wpas_mbo_np_chan_changed(struct wpa_supplicant *wpa_s)
+{
+	struct wpabuf *buf = wpabuf_alloc(512);
+
+	if (!buf)
+		return;
+
+	wpas_mbo_np_chan_attrs(wpa_s, buf, 1);
+	wpas_mbo_send_wnm_notification(wpa_s, wpabuf_head_u8(buf),
+				       wpabuf_len(buf));
+	wpabuf_free(buf);
+}
+
+
 static int wpa_np_chan_is_eq(struct wpa_mbo_np_channel *a,
 			     struct wpa_mbo_np_channel *b)
 {
@@ -322,7 +337,7 @@ update:
 	os_free(wpa_s->np_chan);
 	wpa_s->np_chan = chans;
 	wpa_s->np_chan_num = num;
-	wpas_mbo_send_wnm_notification(wpa_s);
+	wpas_mbo_np_chan_changed(wpa_s);
 
 	return 0;
 
@@ -719,3 +734,26 @@ size_t wpas_mbo_ie_bss_trans_reject(struct wpa_supplicant *wpa_s, u8 *pos,
 	res = mbo_add_ie(pos, len, reject_attr, sizeof(reject_attr));
 	return res;
 }
+
+
+void wpas_mbo_update_cell_capa(struct wpa_supplicant *wpa_s, u8 mbo_cell_capa)
+{
+	u8 cell_capa[7];
+
+	if (wpa_s->conf->mbo_cell_capa == mbo_cell_capa) {
+		wpa_printf(MSG_DEBUG,
+			   "MBO: Cellular capability already set to %hhu",
+			   mbo_cell_capa);
+		return;
+	}
+
+	wpa_s->conf->mbo_cell_capa = mbo_cell_capa;
+
+	cell_capa[0] = WLAN_EID_VENDOR_SPECIFIC;
+	cell_capa[1] = 5; /* Length */
+	WPA_PUT_BE24(cell_capa + 2, OUI_WFA);
+	cell_capa[5] = MBO_ATTR_ID_CELL_CAPA;
+	cell_capa[6] = mbo_cell_capa;
+
+	wpas_mbo_send_wnm_notification(wpa_s, cell_capa, 7);
+}
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index ac45fcf..6c827b5 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1167,6 +1167,7 @@ void wpas_mbo_ie_trans_req(struct wpa_supplicant *wpa_s, const u8 *ie,
 size_t wpas_mbo_ie_bss_trans_reject(struct wpa_supplicant *wpa_s, u8 *pos,
 				    size_t len,
 				    enum mbo_transition_reject_reason reason);
+void wpas_mbo_update_cell_capa(struct wpa_supplicant *wpa_s, u8 mbo_cell_capa);
 
 /**
  * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response
-- 
1.9.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux