From patchwork Sat Mar 6 16:18:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 1448459 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=IfoQ7EM8; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=candelatech.com header.i=@candelatech.com header.a=rsa-sha256 header.s=default header.b=ZIC9lRwu; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dt8vV5f8bz9sWg for ; Sun, 7 Mar 2021 03:19:50 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=/wsaSXCMXVZotNQlVPBOW4mdXy6DXJPJmkmkSYs/bM0=; b=IfoQ7EM8naE2NtIwOyMNtgFhfw AnyDFFXUSeyAGQG/QWRWWVQDk09Qn2pG4fCXN4zw2i+QZjtuWqgxEv+YDwwV1fbRQrU5BmL1318KP dYAHPBig1ss8Kk+bRYho2LX8ubl+fRvf5lLgns9hHqTZir8v+CK3+rO12n/INp2NYeVJpNc5uw4fE sGEDEdpgdPw4qqIDUjwGTiIPC09DitUYhZ2VaMnX6Pup+E0Ce1pySBnk9F/E4u6gYZNsbIvC4GPLL AdYnS9vfFvA2WsJHP0Nqp6beN+Xg1RxpOEj26K9WA5DON2KjYUoWM5U8en5jCKJkU66TpW4mr5pF4 LBmQLGFQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZdn-003cHD-0c; Sat, 06 Mar 2021 16:18:55 +0000 Received: from mail2.candelatech.com ([208.74.158.173] helo=mail3.candelatech.com) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZdg-003cEB-UO for hostap@lists.infradead.org; Sat, 06 Mar 2021 16:18:51 +0000 Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 871BB13C2B0; Sat, 6 Mar 2021 08:18:45 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 871BB13C2B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1615047525; bh=GddsAHKeFh6Xnb0Fd+qlgeZBNkoCrVegMADmVmetoUk=; h=From:To:Cc:Subject:Date:From; b=ZIC9lRwujLXKBT3Sm1+7ZSpg82Ms4OOGS4hb8CH9Xo/HVAKw9eFQef0qhPCRbphXt 9a3xzJSI7+wf1EuoHlethUuOL81TDntMQbpMNsDx60RJLFb/k34ipIdHobeHg+oD0u 7TEJu8tF53Sc0F+6zY9mqurPMFRwRv6vPG6qTJm8= From: greearb@candelatech.com To: hostap@lists.infradead.org Cc: Ben Greear Subject: [PATCH 1/5] supplicant: Support disabling HE for stations. Date: Sat, 6 Mar 2021 08:18:37 -0800 Message-Id: <20210306161840.16652-1-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210306_161849_428598_710F297A X-CRM114-Status: UNSURE ( 8.16 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Ben Greear Send a flag to the kernel with user has specified disable_he in supplicant config file. Requires kernel patch to function as expected. Signed-off-by: Ben Greear --- src/drivers/driver_nl80211.c | 8 ++++++++ 1 file changed, 8 insertions(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ben Greear Send a flag to the kernel with user has specified disable_he in supplicant config file. Requires kernel patch to function as expected. Signed-off-by: Ben Greear --- src/drivers/driver_nl80211.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index a9d5fe3d8..f32890d1d 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -5913,6 +5913,14 @@ static int nl80211_ht_vht_overrides(struct nl_msg *msg, } #endif /* CONFIG_VHT_OVERRIDES */ +#ifdef CONFIG_VHT_OVERRIDES + if (params->disable_he) { + wpa_printf(MSG_DEBUG, " * HE disabled"); + if (nla_put_flag(msg, NL80211_ATTR_DISABLE_HE)) + return -1; + } +#endif + return 0; } From patchwork Sat Mar 6 16:18:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 1448458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=m2N0rtD7; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=candelatech.com header.i=@candelatech.com header.a=rsa-sha256 header.s=default header.b=p2Pl7UL4; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dt8vT6htRz9sWf for ; Sun, 7 Mar 2021 03:19:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dBy3aDeScHxRYusMWoZO/zkGPxqhgOnhTbTB4hZNaTs=; b=m2N0rtD7AOxAVAO9xRgUzElAH Tnr/QM47JaTl/xr5E2eVjJcEQZGd+Fi1pzH78Ri/sVy8h1o3KLwrY4/N0IzvZWHbmqxu4aNLzpM61 wIhjFpUCtVrKIjfCxAmG26NSxUp1quSz1oBJzDAZzvN5Hr2xG6dn6+iSm3pA8FX7PQZPnjZM8RjhP ekhg8d1RH0nzqAI7dxrBNd6CEag0IoDoBSvLmOlDn4IqCC3R3XKjMbrOl4tPzqYGReYBtvpFmbkkh n3OxLr2tzyhcuDqjcH7BWxh411i08U3md7WsoIKNBPIvP7G+C6w3U20XyGV39fh+OwX+YWKB+lkS/ r5J5iUrCw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZds-003cJH-5A; Sat, 06 Mar 2021 16:19:00 +0000 Received: from mail2.candelatech.com ([208.74.158.173] helo=mail3.candelatech.com) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZdg-003cEa-UM for hostap@lists.infradead.org; Sat, 06 Mar 2021 16:18:51 +0000 Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 7816113C2B3; Sat, 6 Mar 2021 08:18:47 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 7816113C2B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1615047527; bh=TgXsRSCsNKlXG5r7XZNqEggBS0sV0kPElwccxh4Izu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p2Pl7UL4lRx4zdyxNK5diAImU79ImfXDXrNkb1G2mq9XorEkq/oO296+FGyYFQjKJ eeS4vVK2AzXnCGnhirFcTLhAzBWV2wClySYjktrqg0zakrx5mjgr3Pz+tFCUPcMys/ W0nNxUoIRFseY1SI05U6Gp+09YREE6jZ2Hhu5xes= From: greearb@candelatech.com To: hostap@lists.infradead.org Cc: Ben Greear Subject: [PATCH 3/5] supplicant: Support sending twt-request action frames. Date: Sat, 6 Mar 2021 08:18:38 -0800 Message-Id: <20210306161840.16652-2-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210306161840.16652-1-greearb@candelatech.com> References: <20210306161840.16652-1-greearb@candelatech.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210306_161849_962355_C4F1AEF5 X-CRM114-Status: GOOD ( 21.16 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Ben Greear With ability to specify some options. Signed-off-by: Ben Greear --- src/common/ieee802_11_defs.h | 15 ++++++ wpa_supplicant/Makefile | 1 + wpa_supplicant/ctrl_iface.c | 29 ++++++++++ wpa_supplicant/twt.c | 90 +++ [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ben Greear With ability to specify some options. Signed-off-by: Ben Greear --- src/common/ieee802_11_defs.h | 15 ++++++ wpa_supplicant/Makefile | 1 + wpa_supplicant/ctrl_iface.c | 29 ++++++++++ wpa_supplicant/twt.c | 90 +++++++++++++++++++++++++++++++ wpa_supplicant/wpa_cli.c | 10 ++++ wpa_supplicant/wpa_supplicant_i.h | 4 ++ 6 files changed, 149 insertions(+) create mode 100644 wpa_supplicant/twt.c diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index b8dee8dbf..c67c6f46c 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -446,6 +446,7 @@ #define WLAN_EID_WHITE_SPACE_MAP 205 #define WLAN_EID_FTM_PARAMETERS 206 #define WLAN_EID_S1G_BCN_COMPAT 213 +#define WLAN_EID_TWT 216 #define WLAN_EID_S1G_CAPABILITIES 217 #define WLAN_EID_VENDOR_SPECIFIC 221 #define WLAN_EID_S1G_OPERATION 232 @@ -603,6 +604,7 @@ #define WLAN_ACTION_ROBUST_AV_STREAMING 19 #define WLAN_ACTION_UNPROTECTED_DMG 20 #define WLAN_ACTION_VHT 21 +#define WLAN_ACTION_S1G 22 #define WLAN_ACTION_FILS 26 #define WLAN_ACTION_PROTECTED_FTM 34 #define WLAN_ACTION_VENDOR_SPECIFIC_PROTECTED 126 @@ -820,6 +822,19 @@ enum nai_realm_eap_cred_type { NAI_REALM_CRED_TYPE_VENDOR_SPECIFIC = 10 }; +#define S1G_ACT_AID_SWITCH_REQUEST 0 +#define S1G_ACT_AID_SWITCH_RESPONSE 1 +#define S1G_ACT_SYNC_CONTROL 2 +#define S1G_ACT_STA_INFO_ANNOUNCE 3 +#define S1G_ACT_EDCA_PARAM_SET 4 +#define S1G_ACT_EL_OPERATION 5 +#define S1G_ACT_TWT_SETUP 6 +#define S1G_ACT_TWT_TEARDOWN 7 +#define S1G_ACT_SECT_GROUP_ID_LIST 8 +#define S1G_ACT_SECT_ID_FEEDBACK 9 +#define S1G_ACT_RESERVED 10 +#define S1G_ACT_TWT_INFORMATION 11 + /* * IEEE P802.11-REVmc/D5.0 Table 9-81 - Measurement type definitions for * measurement requests diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index fb665b160..77baa1bb5 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -95,6 +95,7 @@ OBJS += ../src/utils/ip_addr.o OBJS += ../src/utils/crc32.o OBJS += op_classes.o OBJS += rrm.o +OBJS += twt.o OBJS += robust_av.o OBJS_p = wpa_passphrase.o OBJS_p += ../src/utils/common.o diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index d679b56af..1a1c2ca82 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -10108,6 +10108,32 @@ static int wpas_ctrl_iface_send_neighbor_rep(struct wpa_supplicant *wpa_s, return ret; } +static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s, + char *cmd) +{ + int ret; + int dtok = 1; + int exponent = 10; + int mantissa = 8192; + int min_twt = 255; + + char* tok_s = os_strstr(cmd, "dialog="); + if (tok_s) + dtok = atoi(tok_s + strlen("dialog=")); + + tok_s = os_strstr(cmd, "exponent="); + if (tok_s) + exponent = atoi(tok_s + strlen("exponent=")); + + tok_s = os_strstr(cmd, "mantissa="); + if (tok_s) + exponent = atoi(tok_s + strlen("mantissa=")); + + ret = wpas_twt_send_setup(wpa_s, dtok, exponent, mantissa, min_twt); + + return ret; +} + static int wpas_ctrl_iface_erp_flush(struct wpa_supplicant *wpa_s) { @@ -11330,6 +11356,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strncmp(buf, "NEIGHBOR_REP_REQUEST", 20) == 0) { if (wpas_ctrl_iface_send_neighbor_rep(wpa_s, buf + 20)) reply_len = -1; + } else if (os_strncmp(buf, "TWT_SETUP", 20) == 0) { + if (wpas_ctrl_iface_send_twt_setup(wpa_s, buf + 9)) + reply_len = -1; } else if (os_strcmp(buf, "ERP_FLUSH") == 0) { wpas_ctrl_iface_erp_flush(wpa_s); } else if (os_strncmp(buf, "MAC_RAND_SCAN ", 14) == 0) { diff --git a/wpa_supplicant/twt.c b/wpa_supplicant/twt.c new file mode 100644 index 000000000..6b62631b7 --- /dev/null +++ b/wpa_supplicant/twt.c @@ -0,0 +1,90 @@ +/* + * wpa_supplicant - TWT + * Copyright (c) 2003-2016, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#include "includes.h" + +#include "utils/common.h" +#include "utils/eloop.h" +#include "common/ieee802_11_common.h" +#include "wpa_supplicant_i.h" +#include "driver_i.h" +#include "bss.h" +#include "scan.h" +#include "p2p_supplicant.h" + + +/** + * wpas_twt_send_setup - Send TWT setup request to our AP + * @wpa_s: Pointer to wpa_supplicant + * @dtok: Dialog token. + * @exponent: TWT wake-interval exponent + * @mantissa: TWT wake-interval Mantissa + * @min_twt: TWT Minimum TWT Wake Duration. + * Returns: 0 in case of success, negative error code otherwise + * + */ +int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, + int dtok, int exponent, int mantissa, int min_twt) +{ + struct wpabuf *buf; + u16 req_type = 0; + unsigned char targ_wait_time[8] = {0}; + + if (wpa_s->wpa_state != WPA_COMPLETED || wpa_s->current_ssid == NULL) { + wpa_dbg(wpa_s, MSG_DEBUG, "TWT: No connection, no TWT."); + return -ENOTCONN; + } + + /* 3 = action category + action code + dialog token */ + /* 17 = target wait time IE */ + buf = wpabuf_alloc(3 + 17); + + if (buf == NULL) { + wpa_dbg(wpa_s, MSG_DEBUG, + "TWT: Failed to allocate TWT Setup Request"); + return -ENOMEM; + } + + wpa_dbg(wpa_s, MSG_DEBUG, + "TWT: Setup request, dtok: %d exponent: %d mantissa: %d min-twt: %d", + dtok, exponent, mantissa, min_twt); + + wpabuf_put_u8(buf, WLAN_ACTION_S1G); + wpabuf_put_u8(buf, S1G_ACT_TWT_SETUP); + wpabuf_put_u8(buf, dtok); + + wpabuf_put_u8(buf, WLAN_EID_TWT); + wpabuf_put_u8(buf, 15); /* len */ + + wpabuf_put_u8(buf, 0x10); /* control field */ + + req_type |= (0x1); /* This STA is a TWT Requesting STA */ + req_type |= (0x70); /* TWT SP includes trigger frames, TWT Implicit, TWT un-announced */ + req_type |= ((exponent & 0x1f) << 10); + /* high bit is 'protection, leave it false for now */ + wpabuf_put_u8(buf, req_type); + wpabuf_put_u8(buf, req_type >> 8); + /* Not sure exactly how this is used */ + wpabuf_put_data(buf, targ_wait_time, sizeof(targ_wait_time)); + wpabuf_put_u8(buf, min_twt); /* minimum twt wake duration */ + wpabuf_put_u8(buf, mantissa); + wpabuf_put_u8(buf, mantissa >> 8); + wpabuf_put_u8(buf, 0); /* twt channel */ + + if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, + wpa_s->own_addr, wpa_s->bssid, + wpabuf_head(buf), wpabuf_len(buf), 0) < 0) { + wpa_dbg(wpa_s, MSG_DEBUG, + "TWT: Failed to send TWT Setup Request"); + wpabuf_free(buf); + return -ECANCELED; + } + + wpabuf_free(buf); + return 0; +} diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index b3e256b0f..b84670df9 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -2942,6 +2942,12 @@ static int wpa_cli_cmd_neighbor_rep_request(struct wpa_ctrl *ctrl, int argc, return wpa_cli_cmd(ctrl, "NEIGHBOR_REP_REQUEST", 0, argc, argv); } +static int wpa_cli_cmd_twt_setup(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_cli_cmd(ctrl, "TWT_SETUP", 0, argc, argv); +} + static int wpa_cli_cmd_erp_flush(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -3822,6 +3828,10 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = { wpa_cli_cmd_neighbor_rep_request, NULL, cli_cmd_flag_none, "[ssid=] [lci] [civic] = Trigger request to AP for neighboring AP report (with optional given SSID in hex or enclosed in double quotes, default: current SSID; with optional LCI and location civic request)" }, + { "twt_setup", + wpa_cli_cmd_twt_setup, NULL, cli_cmd_flag_none, + "[dialog=] [exponent=] [mantissa=]" + }, { "erp_flush", wpa_cli_cmd_erp_flush, NULL, cli_cmd_flag_none, "= flush ERP keys" }, { "mac_rand_scan", diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index dfd8c61eb..705352c17 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1557,6 +1557,10 @@ void add_freq(int *freqs, int *num_freqs, int freq); int wpas_get_op_chan_phy(int freq, const u8 *ies, size_t ies_len, u8 *op_class, u8 *chan, u8 *phy_type); + +int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, + int dtok, int exponent, int mantissa, int min_twt); + void wpas_rrm_reset(struct wpa_supplicant *wpa_s); void wpas_rrm_process_neighbor_rep(struct wpa_supplicant *wpa_s, const u8 *report, size_t report_len); From patchwork Sat Mar 6 16:18:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 1448456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=Pip4FGhD; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=candelatech.com header.i=@candelatech.com header.a=rsa-sha256 header.s=default header.b=b3SXciZ+; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dt8vS352Nz9sWc for ; Sun, 7 Mar 2021 03:19:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pKXoDm54zVRpBl+Zb3EDkOG4kKuQpfWM7qYuYc2y3QY=; b=Pip4FGhDlZwRpel/qVb1RQ7e0 cQSbYXHBHWa9Uitm8AZ2tvUsgMZBxIy2IcpnnKvVrkzLWaEcNejX6ZtddGyJ2L9cWeXZMMR2jUU6U oNTW2zlrXkZkdWD7B4Lo98kDf9ttdmkjWNcOmK49rsJlvEMUksOmDqkq+DUmCmR3xQKVnwtzZliaF 9FhvZFNCZIuEpQtjPivq6T5dUvPY59hIAJ+elLO8tjircrCfp96Rc8wTevSRKlgB8uBrZpjW4TAzx svpsGJUU/SAuzERXFmhDwC1OAmL/QC7/pJVJ4XaSto3J1tBylbT2qrPqBCh2G0eewD//DCQDvCKbU /TzSlhUig==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZdw-003cLM-Pj; Sat, 06 Mar 2021 16:19:04 +0000 Received: from mail2.candelatech.com ([208.74.158.173] helo=mail3.candelatech.com) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZdk-003cGG-F1 for hostap@lists.infradead.org; Sat, 06 Mar 2021 16:18:55 +0000 Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 724CA13C2B4; Sat, 6 Mar 2021 08:18:51 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 724CA13C2B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1615047531; bh=aoNEqBgdeGhY/yNDk/WpJVtK17YMLdm8NXSrmT+oiGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b3SXciZ+opTenh3byZHtzziYbXEUSzHPcMMjSTWw5Rh6gEQuAq7RaPOfkTJo5snzm IhZ68jd+hj6VZwGO9h0aOLAkDRRMB2laTIJiBaCXrW5DbGmAY9ECOPsFGYDa5Vtw3l SUx51ga+sY+qD3pVZJs+n5zbuqDQyCugwDE1gqMY= From: greearb@candelatech.com To: hostap@lists.infradead.org Cc: Ben Greear Subject: [PATCH 4/5] twt: Support sending teardown action frame. Date: Sat, 6 Mar 2021 08:18:39 -0800 Message-Id: <20210306161840.16652-3-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210306161840.16652-1-greearb@candelatech.com> References: <20210306161840.16652-1-greearb@candelatech.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210306_161853_421954_D34C2275 X-CRM114-Status: GOOD ( 12.89 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Ben Greear User can supply the 1-byte flags value. Signed-off-by: Ben Greear --- wpa_supplicant/ctrl_iface.c | 18 ++++++++++++ wpa_supplicant/twt.c | 47 +++++++++++++++++++++++++++++++ wpa_supplicant/wpa_cli.c | 9 ++++++ wpa_ [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ben Greear User can supply the 1-byte flags value. Signed-off-by: Ben Greear --- wpa_supplicant/ctrl_iface.c | 18 ++++++++++++ wpa_supplicant/twt.c | 47 +++++++++++++++++++++++++++++++ wpa_supplicant/wpa_cli.c | 9 ++++++ wpa_supplicant/wpa_supplicant_i.h | 2 ++ 4 files changed, 76 insertions(+) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 1a1c2ca82..0fb84e435 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -10134,6 +10134,21 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s, return ret; } +static int wpas_ctrl_iface_send_twt_teardown(struct wpa_supplicant *wpa_s, + char *cmd) +{ + int ret; + int flags = 0x1; + + char* tok_s = os_strstr(cmd, "flags="); + if (tok_s) + flags = atoi(tok_s + strlen("flags=")); + + ret = wpas_twt_send_teardown(wpa_s, flags); + + return ret; +} + static int wpas_ctrl_iface_erp_flush(struct wpa_supplicant *wpa_s) { @@ -11359,6 +11374,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strncmp(buf, "TWT_SETUP", 20) == 0) { if (wpas_ctrl_iface_send_twt_setup(wpa_s, buf + 9)) reply_len = -1; + } else if (os_strncmp(buf, "TWT_TEARDOWN", 20) == 0) { + if (wpas_ctrl_iface_send_twt_teardown(wpa_s, buf + 9)) + reply_len = -1; } else if (os_strcmp(buf, "ERP_FLUSH") == 0) { wpas_ctrl_iface_erp_flush(wpa_s); } else if (os_strncmp(buf, "MAC_RAND_SCAN ", 14) == 0) { diff --git a/wpa_supplicant/twt.c b/wpa_supplicant/twt.c index 6b62631b7..39fb5a629 100644 --- a/wpa_supplicant/twt.c +++ b/wpa_supplicant/twt.c @@ -88,3 +88,50 @@ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, wpabuf_free(buf); return 0; } + +/** + * wpas_twt_send_teardown - Send TWT teardown request to our AP + * @wpa_s: Pointer to wpa_supplicant + * @flags: The byte that goes inside the teardown IE + * Returns: 0 in case of success, negative error code otherwise + * + */ +int wpas_twt_send_teardown(struct wpa_supplicant *wpa_s, + int flags) +{ + struct wpabuf *buf; + + if (wpa_s->wpa_state != WPA_COMPLETED || wpa_s->current_ssid == NULL) { + wpa_dbg(wpa_s, MSG_DEBUG, "TWT: No connection, no TWT."); + return -ENOTCONN; + } + + /* 3 = action category + action code + flags */ + buf = wpabuf_alloc(3); + + if (buf == NULL) { + wpa_dbg(wpa_s, MSG_DEBUG, + "TWT: Failed to allocate TWT Teardown Request"); + return -ENOMEM; + } + + wpa_dbg(wpa_s, MSG_DEBUG, + "TWT: Teardown request, flags: 0x%x", + flags); + + wpabuf_put_u8(buf, WLAN_ACTION_S1G); + wpabuf_put_u8(buf, S1G_ACT_TWT_TEARDOWN); + wpabuf_put_u8(buf, flags); + + if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, + wpa_s->own_addr, wpa_s->bssid, + wpabuf_head(buf), wpabuf_len(buf), 0) < 0) { + wpa_dbg(wpa_s, MSG_DEBUG, + "TWT: Failed to send TWT Teardown Request"); + wpabuf_free(buf); + return -ECANCELED; + } + + wpabuf_free(buf); + return 0; +} diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index b84670df9..ba57d7d91 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -2948,6 +2948,11 @@ static int wpa_cli_cmd_twt_setup(struct wpa_ctrl *ctrl, int argc, return wpa_cli_cmd(ctrl, "TWT_SETUP", 0, argc, argv); } +static int wpa_cli_cmd_twt_teardown(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_cli_cmd(ctrl, "TWT_TEARDOWN", 0, argc, argv); +} static int wpa_cli_cmd_erp_flush(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -3832,6 +3837,10 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = { wpa_cli_cmd_twt_setup, NULL, cli_cmd_flag_none, "[dialog=] [exponent=] [mantissa=]" }, + { "twt_teardown", + wpa_cli_cmd_twt_teardown, NULL, cli_cmd_flag_none, + "[flags=]" + }, { "erp_flush", wpa_cli_cmd_erp_flush, NULL, cli_cmd_flag_none, "= flush ERP keys" }, { "mac_rand_scan", diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 705352c17..0271c5e24 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1560,6 +1560,8 @@ int wpas_get_op_chan_phy(int freq, const u8 *ies, size_t ies_len, int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, int dtok, int exponent, int mantissa, int min_twt); +int wpas_twt_send_teardown(struct wpa_supplicant *wpa_s, + int flags); void wpas_rrm_reset(struct wpa_supplicant *wpa_s); void wpas_rrm_process_neighbor_rep(struct wpa_supplicant *wpa_s, From patchwork Sat Mar 6 16:18:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 1448457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=YTUV3sLk; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=candelatech.com header.i=@candelatech.com header.a=rsa-sha256 header.s=default header.b=MLRDVMcm; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dt8vT1Qp6z9sW5 for ; Sun, 7 Mar 2021 03:19:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dvcc6WoEZJ8/e+c8Hsw/dJ2r08wYU/mpGukn3uAjiLU=; b=YTUV3sLkbtPsA2UJt05cfkOs4 ux4e10Sgd9fW+d4EV0ptac+hX8M5/POPbrQXSjCo8lxQE7HShrj7h7dPsGzhk8b4UrR3rhg9S5LlD 34JX/j2fPrkWJ0ijbDapu37yv91u0SH/9m+9ixRdIbUI+OAKmDqKJv7e9cWVobSWSpCeYSkWgrW1D a6HKM8Cl0lGgQRApC7Jo7jY7iBAJv6ENeHHQmUAVEExfLav7EEfYf0KwZIdWbxAFHoORDCsjNnYwF p42Ytig5+dv0M5x7n85TmiCaQWUca8t+W37wtVf0qiH4Z+pIh7R4OJieg+bcG/6nnWw+2c5/teNC5 zCo/Z2yIg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZe1-003cNR-5i; Sat, 06 Mar 2021 16:19:09 +0000 Received: from mail2.candelatech.com ([208.74.158.173] helo=mail3.candelatech.com) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIZdk-003cGL-Jh for hostap@lists.infradead.org; Sat, 06 Mar 2021 16:18:55 +0000 Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 9E53B13C2B6; Sat, 6 Mar 2021 08:18:51 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 9E53B13C2B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1615047531; bh=K+GmHfjI61pPyE4eKh0amk07pqTc5xCo0BEqp58CTnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLRDVMcmgk0amozBvnsM5GEpzQs+0iezDYt1v0qGtGIJB3BAf6U4xpPhnY5y16CN1 WZ8G2c5GkT02XNSbeZdg7b5kA+qqRR7fyZ8hgcz3mGmRphl54ZM2TgG0v0gldJtW2x icIoAjVe5huMFx6IDhn293NTDFp7CRDqmjPZ1Juo= From: greearb@candelatech.com To: hostap@lists.infradead.org Cc: Ben Greear Subject: [PATCH 5/5] twt: Add more options for sending twt-request packets. Date: Sat, 6 Mar 2021 08:18:40 -0800 Message-Id: <20210306161840.16652-4-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210306161840.16652-1-greearb@candelatech.com> References: <20210306161840.16652-1-greearb@candelatech.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210306_161853_456175_0C2F7C8B X-CRM114-Status: GOOD ( 15.13 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Ben Greear You can now specify every field. Signed-off-by: Ben Greear --- wpa_supplicant/ctrl_iface.c | 49 ++++++++++++++++++++++++++++++- wpa_supplicant/twt.c | 28 ++++++++++++------ wpa_supplicant/wpa_cli.c | 2 +- wp [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ben Greear You can now specify every field. Signed-off-by: Ben Greear --- wpa_supplicant/ctrl_iface.c | 49 ++++++++++++++++++++++++++++++- wpa_supplicant/twt.c | 28 ++++++++++++------ wpa_supplicant/wpa_cli.c | 2 +- wpa_supplicant/wpa_supplicant_i.h | 4 ++- 4 files changed, 71 insertions(+), 12 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 0fb84e435..126dfabea 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -10116,6 +10116,15 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s, int exponent = 10; int mantissa = 8192; int min_twt = 255; + unsigned long long twt = 0; + int requestor = 1; + int setup_cmd = 0; + int trigger = 1; + int implicit = 1; + int flow_type = 1; + int flow_id = 0; + int protection = 0; + int twt_channel = 0; char* tok_s = os_strstr(cmd, "dialog="); if (tok_s) @@ -10129,7 +10138,45 @@ static int wpas_ctrl_iface_send_twt_setup(struct wpa_supplicant *wpa_s, if (tok_s) exponent = atoi(tok_s + strlen("mantissa=")); - ret = wpas_twt_send_setup(wpa_s, dtok, exponent, mantissa, min_twt); + tok_s = os_strstr(cmd, "setup_cmd="); + if (tok_s) + setup_cmd = atoi(tok_s + strlen("setup_cmd=")); + + tok_s = os_strstr(cmd, "twt="); + if (tok_s) + sscanf(tok_s + strlen("twt="), "%llu", &twt); + + tok_s = os_strstr(cmd, "requestor="); + if (tok_s) + requestor = atoi(tok_s + strlen("requestor=")); + + tok_s = os_strstr(cmd, "trigger="); + if (tok_s) + trigger = atoi(tok_s + strlen("trigger=")); + + tok_s = os_strstr(cmd, "implicit="); + if (tok_s) + implicit = atoi(tok_s + strlen("implicit=")); + + tok_s = os_strstr(cmd, "flow_type="); + if (tok_s) + flow_type = atoi(tok_s + strlen("flow_type=")); + + tok_s = os_strstr(cmd, "flow_id="); + if (tok_s) + flow_id = atoi(tok_s + strlen("flow_id=")); + + tok_s = os_strstr(cmd, "protection="); + if (tok_s) + protection = atoi(tok_s + strlen("protection=")); + + tok_s = os_strstr(cmd, "twt_channel="); + if (tok_s) + twt_channel = atoi(tok_s + strlen("twt_channel=")); + + ret = wpas_twt_send_setup(wpa_s, dtok, exponent, mantissa, min_twt, setup_cmd, + twt, requestor, trigger, implicit, flow_type, flow_id, + protection, twt_channel); return ret; } diff --git a/wpa_supplicant/twt.c b/wpa_supplicant/twt.c index 39fb5a629..da54260fd 100644 --- a/wpa_supplicant/twt.c +++ b/wpa_supplicant/twt.c @@ -25,15 +25,18 @@ * @exponent: TWT wake-interval exponent * @mantissa: TWT wake-interval Mantissa * @min_twt: TWT Minimum TWT Wake Duration. + * @setup_cmd: 0 == request, 1 == suggest, etc. table 9-297 * Returns: 0 in case of success, negative error code otherwise * */ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, - int dtok, int exponent, int mantissa, int min_twt) + int dtok, int exponent, int mantissa, int min_twt, int setup_cmd, + u64 twt, int requestor, int trigger, int implicit, int flow_type, int flow_id, + int protection, int twt_channel) { struct wpabuf *buf; u16 req_type = 0; - unsigned char targ_wait_time[8] = {0}; + int i; if (wpa_s->wpa_state != WPA_COMPLETED || wpa_s->current_ssid == NULL) { wpa_dbg(wpa_s, MSG_DEBUG, "TWT: No connection, no TWT."); @@ -43,7 +46,7 @@ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, /* 3 = action category + action code + dialog token */ /* 17 = target wait time IE */ buf = wpabuf_alloc(3 + 17); - + if (buf == NULL) { wpa_dbg(wpa_s, MSG_DEBUG, "TWT: Failed to allocate TWT Setup Request"); @@ -63,18 +66,25 @@ int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, wpabuf_put_u8(buf, 0x10); /* control field */ - req_type |= (0x1); /* This STA is a TWT Requesting STA */ - req_type |= (0x70); /* TWT SP includes trigger frames, TWT Implicit, TWT un-announced */ + req_type |= (requestor & 0x1); /* This STA is a TWT Requesting STA */ + req_type |= (setup_cmd & 0x7) << 1; + req_type |= (trigger & 0x1) << 4; + req_type |= (implicit & 0x1) << 5; + req_type |= (flow_type & 0x1) << 6; + req_type |= (flow_id & 0x7) << 7; req_type |= ((exponent & 0x1f) << 10); - /* high bit is 'protection, leave it false for now */ + req_type |= (protection & 0x1) << 15; + wpabuf_put_u8(buf, req_type); wpabuf_put_u8(buf, req_type >> 8); - /* Not sure exactly how this is used */ - wpabuf_put_data(buf, targ_wait_time, sizeof(targ_wait_time)); + + for (i = 0; i<8; i++) { + wpabuf_put_u8(buf, twt >> i); + } wpabuf_put_u8(buf, min_twt); /* minimum twt wake duration */ wpabuf_put_u8(buf, mantissa); wpabuf_put_u8(buf, mantissa >> 8); - wpabuf_put_u8(buf, 0); /* twt channel */ + wpabuf_put_u8(buf, twt_channel); /* twt channel */ if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid, diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index ba57d7d91..942f64a9d 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -3835,7 +3835,7 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = { }, { "twt_setup", wpa_cli_cmd_twt_setup, NULL, cli_cmd_flag_none, - "[dialog=] [exponent=] [mantissa=]" + "[dialog=] [exponent=] [mantissa=] [setup_cmd=] [twt=] [requestor=0|1] [trigger=0|1] [implicit=0|1] [flow_type=0|1] [flow_id=<3-bit-id>] [protection=0|1] [twt_channel=]" }, { "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 0271c5e24..ce2586ac9 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1559,7 +1559,9 @@ int wpas_get_op_chan_phy(int freq, const u8 *ies, size_t ies_len, u8 *op_class, u8 *chan, u8 *phy_type); int wpas_twt_send_setup(struct wpa_supplicant *wpa_s, - int dtok, int exponent, int mantissa, int min_twt); + int dtok, int exponent, int mantissa, int min_twt, int setup_cmd, + u64 twt, int requestor, int trigger, int implicit, int flow_type, int flow_id, + int protection, int channel); int wpas_twt_send_teardown(struct wpa_supplicant *wpa_s, int flags);