[PATCH] twt: Allow specifying control field in twt request.

greearb at candelatech.com greearb at candelatech.com
Wed Mar 10 17:28:12 GMT 2021


From: Ben Greear <greearb at candelatech.com>

See ieee 802.11 spec table 9-687 for details.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
 wpa_supplicant/ctrl_iface.c       | 9 ++++++++-
 wpa_supplicant/twt.c              | 5 ++---
 wpa_supplicant/wpa_cli.c          | 2 +-
 wpa_supplicant/wpa_supplicant_i.h | 2 +-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 4b9b5d1bf..c8f0ed241 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -9851,6 +9851,8 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s,
 	int flow_id = 0;
 	bool protection = false;
 	u8 twt_channel = 0;
+	u8 control = BIT(4); /* Control field:  Table 9-687
+			      * B4 = TWT Information Frame Disabled */
 	const char *tok_s;
 
 	tok_s = os_strstr(cmd, " dialog=");
@@ -9905,9 +9907,14 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s,
 	if (tok_s)
 		twt_channel = atoi(tok_s + os_strlen(" twt_channel="));
 
+	tok_s = os_strstr(cmd, " control=");
+	if (tok_s)
+		control = atoi(tok_s + os_strlen(" control="));
+
 	return wpas_twt_send_setup(wpa_s, dtok, exponent, mantissa, min_twt,
 				   setup_cmd, twt, requestor, trigger, implicit,
-				   flow_type, flow_id, protection, twt_channel);
+				   flow_type, flow_id, protection, twt_channel,
+				   control);
 }
 
 
diff --git a/wpa_supplicant/twt.c b/wpa_supplicant/twt.c
index d77cea227..8ec2c85ac 100644
--- a/wpa_supplicant/twt.c
+++ b/wpa_supplicant/twt.c
@@ -30,7 +30,7 @@ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
 			int mantissa, u8 min_twt, int setup_cmd, u64 twt,
 			bool requestor, bool trigger, bool implicit,
 			bool flow_type, u8 flow_id, bool protection,
-			u8 twt_channel)
+			u8 twt_channel, u8 control)
 {
 	struct wpabuf *buf;
 	u16 req_type = 0;
@@ -62,8 +62,7 @@ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
 	wpabuf_put_u8(buf, WLAN_EID_TWT);
 	wpabuf_put_u8(buf, 15); /* len */
 
-	wpabuf_put_u8(buf, BIT(4)); /* Control field:
-				     * B4 = TWT Information Frame Disabled */
+	wpabuf_put_u8(buf, control);
 
 	if (requestor)
 		req_type |= BIT(0); /* This STA is a TWT Requesting STA */
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 2d63060e3..9099b0cbc 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -3838,7 +3838,7 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = {
 	},
 	{ "twt_setup",
 	  wpa_cli_cmd_twt_setup, NULL, cli_cmd_flag_none,
-	  "[dialog=<token>] [exponent=<exponent>] [mantissa=<mantissa>] [min_twt=<Min TWT>] [setup_cmd=<setup-cmd>] [twt=<u64>] [requestor=0|1] [trigger=0|1] [implicit=0|1] [flow_type=0|1] [flow_id=<3-bit-id>] [protection=0|1] [twt_channel=<twt chanel id>] = Send TWT Setup frame"
+	  "[dialog=<token>] [exponent=<exponent>] [mantissa=<mantissa>] [min_twt=<Min TWT>] [setup_cmd=<setup-cmd>] [twt=<u64>] [requestor=0|1] [trigger=0|1] [implicit=0|1] [flow_type=0|1] [flow_id=<3-bit-id>] [protection=0|1] [twt_channel=<twt chanel id>] [control=<control-u8>] = Send TWT Setup frame"
 	},
 	{ "twt_teardown",
 	  wpa_cli_cmd_twt_teardown, NULL, cli_cmd_flag_none,
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index df6de6b87..8847f483f 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1563,7 +1563,7 @@ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, u8 dtok, int exponent,
 			int mantissa, u8 min_twt, int setup_cmd, u64 twt,
 			bool requestor, bool trigger, bool implicit,
 			bool flow_type, u8 flow_id, bool protection,
-			u8 twt_channel);
+			u8 twt_channel, u8 control);
 int wpas_twt_send_teardown(struct wpa_supplicant *wpa_s, u8 flags);
 
 void wpas_rrm_reset(struct wpa_supplicant *wpa_s);
-- 
2.26.2




More information about the Hostap mailing list