From patchwork Wed Oct 9 08:15:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Puzyniak X-Patchwork-Id: 1995320 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=PRN++9Iz; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Y9Dm4HdD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XPMgx1fN0z1xsc for ; Thu, 10 Oct 2024 19:03:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=WtqdDm8uZ0AU1W6iOoeLvyft1rn1GeW2kGeB7XTEsyY=; b=PRN++9IzVSKpZz A85byOsAinO+AwRdvibbReeNv1NkKoOyqeGV1W2FcBUxqZGIjbNKapVyBwOzDU6lZuIzCkIyW2MU1 7FEZh+crn78frElz2rWWt3U4Dw58Nwpy/eH2xDcdraHuy5EnW7p2FI6ORBEl/tAjjpacjHSk7GV3v eGwGBM233oRkAfNGW54hJ7x2g+Z7fN/MHwzPv/Vu5oBUqo3egn3wWxGxgXM4jF/bI+ppl2ZeILkK7 bVMWVEeOGVxWYOFLCCd6b4ZFuZtVhpNBQ84VavpggL26t/0nwG27H3+itY7HVwwwgqaA6aqfIuN+g pbd0cgi4cYbUFXyIzXvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syo7w-0000000BtUT-1f9x; Thu, 10 Oct 2024 08:02:28 +0000 Received: from mail-lj1-f170.google.com ([209.85.208.170]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syRqs-00000008Oke-0Gj5 for hostap@lists.infradead.org; Wed, 09 Oct 2024 08:15:23 +0000 Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2fabb837ddbso91353981fa.1 for ; Wed, 09 Oct 2024 01:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728461718; x=1729066518; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7YMxZ0Zy9RJ6xfaqQ5b0Str6T9+Fy7iFKfzRSfWPeRI=; b=Y9Dm4HdDIGj0UwKdPP7aIAoiq95eqxACFZGbTbqhCUQqQyOdYvKreV+7fI7Bwvia/l V6SIYu49ZmK837qhIeB06sp2+1/OMXEYHcCAhdF/QGbY5IGJQuWcE94mqjskBVP6W2sD yQ65Vnt1QM3ya/jYeG2aMdypi6yYsyOYj2NbOLwOpbcbKG6rMl/zd6SKkv+NZA9P9ZZ5 Sq1ewniCmcKx3EbMZFHT7FlmRHHAk2ncY/RNilXnbzpJNGa31mBtw1ZXoE1ymm3wkn7e ACYDvrB1XAk8Qbxx9Iq9DMtc/T2KmgJ6M+U8r5QpeltZ1ubKIuVm69sogsjXUoCwNE+B dHaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728461718; x=1729066518; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7YMxZ0Zy9RJ6xfaqQ5b0Str6T9+Fy7iFKfzRSfWPeRI=; b=wEUuDzB3V0Ib6lurem4u7GcPWf2AQmqOqHjPvnqzskfG0zbpjkPpJeatB9nuAynqub DevJSGi/rdYq3YRBd3bZxkxcTUUuqPG4XzxWX/u/HYmK+MH1uyT1g6eWK1mSV63+KU0F 3t05D9Lc9y7h7Yh+3q/7gDDHWXdXXI0XFeS0rAoX99QrjGujo1sfiHGF56FAWgXJfp+f ixTaudNQfRD3TarTi0qTQkl0Qqu7EU7TKG6YDYBT4e/+ZKiKD8uyYSSNCef6bcZo9JcG F2S3lSYk3g+e77/Z1QeWDES3u/6EuzeS5hQN1Mw3ZhsxwV/Kf6XmOZ0EMGJyb0IanXKT rnOA== X-Gm-Message-State: AOJu0YzUTmPj02xQkDPbASHDSrBVGaw/NRPk60m9VPRXf8IQmEnY1khy jo1iRsXqWsX798ZmxK3t1fifEfz9vgyzl8/vQ+r0wZ2dgMXn3lfkDx6lnA== X-Google-Smtp-Source: AGHT+IHkN6e781rk1DpZHhKMFlyqPURutmJt+wci4Zwh9Jx22s8dv7Mon7j8HzGdDC/t/PJoTduQ/Q== X-Received: by 2002:a2e:f1a:0:b0:2fa:fdd1:be23 with SMTP id 38308e7fff4ca-2fb187ca755mr11556791fa.28.1728461718071; Wed, 09 Oct 2024 01:15:18 -0700 (PDT) Received: from lap.home (178.43.18.231.ipv4.supernova.orange.pl. [178.43.18.231]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e5ba412sm631941666b.18.2024.10.09.01.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 01:15:17 -0700 (PDT) From: Marek Puzyniak X-Google-Original-From: Marek Puzyniak To: hostap@lists.infradead.org Cc: Marek Puzyniak Subject: [PATCH] Introduce DUMP_BEACON command Date: Wed, 9 Oct 2024 10:15:02 +0200 Message-ID: <20241009081502.4139823-1-marek.puzyniak@holisticon.pl> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_011522_132295_4D1A39BE X-CRM114-Status: GOOD ( 16.31 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.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: Occasionally, external applications require information about AP configurations and capabilities. The optimal source for this is the beacon frame content. To support this need, a new raw command is be [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.170 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [209.85.208.170 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [209.85.208.170 listed in sa-trusted.bondedsender.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.170 listed in wl.mailspike.net] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [209.85.208.170 listed in bl.score.senderscore.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [marek.puzyniak(at)gmail.com] X-Mailman-Approved-At: Thu, 10 Oct 2024 00:50:37 -0700 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 Occasionally, external applications require information about AP configurations and capabilities. The optimal source for this is the beacon frame content. To support this need, a new raw command is being introduced: DUMP_BEACON. Using wpa_cli or hostapd_cli to execute this command results in a hex dump of the beacon content. hostapd_cli -i wlxxx raw DUMP_BEACON 80000000ffffffffffff... dd180050f2020101010003a4000027a4000042435e0062322f007f080000000000000040 Signed-off-by: Marek Puzyniak --- hostapd/ctrl_iface.c | 72 ++++++++++++++++++++++++++++++++++++++++++++ src/ap/hostapd.c | 4 +-- src/ap/hostapd.h | 2 ++ 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 1fcefb355..371e3f2c5 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -1354,6 +1354,75 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd) } +static int hostapd_ctrl_iface_dump_beacon(struct hostapd_data *hapd, + char *buf, size_t buflen) +{ + struct ieee80211_mgmt *mgmt; + struct beacon_data beacon; + size_t ies_len, req_buf; + char *pos, *end; + u8 *ies_start; + int ret; + + pos = buf; + end = buf + buflen; + + ret = hostapd_build_beacon_data(hapd, &beacon); + if (ret) + return -1; + + /* calculate required buffer size to store beacon hex dump */ + /* beacon ies, first part */ + mgmt = (struct ieee80211_mgmt*)beacon.head; + ies_start = &mgmt->u.beacon.variable[0]; + ies_len = beacon.head_len - (ies_start - beacon.head); + + req_buf = 2 * (beacon.head_len + ies_len + beacon.tail_len + beacon.beacon_ies_len) + 1; + + if (req_buf > buflen) { + hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, + HOSTAPD_LEVEL_WARNING, + "Get beacon failed, required bufer %zu > %zu buffer", + req_buf, buflen); + ret = -1; + goto error_return; + } + + /* beacon head, management frame */ + ret = wpa_snprintf_hex(pos, end - pos, beacon.head, beacon.head_len); + pos += ret; + + /* beacon ies, first part */ + ret = wpa_snprintf_hex(pos, end - pos, ies_start, ies_len); + pos += ret; + + /* beacon tail, ie continuation */ + ret = wpa_snprintf_hex(pos, end - pos, beacon.tail, beacon.tail_len); + pos += ret; + + /* beacon extra ie */ + ret = wpa_snprintf_hex(pos, end - pos, beacon.beacon_ies, beacon.beacon_ies_len); + pos += ret; + + ret = os_snprintf(pos, end - pos, "\n"); + if (os_snprintf_error(end - pos, ret)) { + hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, + HOSTAPD_LEVEL_WARNING, + "Get beacon failed, used:%lu of %zu", + end - pos, buflen); + ret = -1; + goto error_return; + } + pos += ret; + + ret = pos - buf; +error_return: + free_beacon_data(&beacon); + + return ret; +} + + static int hostapd_ctrl_iface_get(struct hostapd_data *hapd, char *cmd, char *buf, size_t buflen) { @@ -4370,6 +4439,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, } else if (os_strncmp(buf, "REQ_BEACON ", 11) == 0) { reply_len = hostapd_ctrl_iface_req_beacon(hapd, buf + 11, reply, reply_size); + } else if (os_strcmp(buf, "DUMP_BEACON") == 0) { + reply_len = hostapd_ctrl_iface_dump_beacon(hapd, reply, + reply_size); } else if (os_strncmp(buf, "REQ_LINK_MEASUREMENT ", 21) == 0) { reply_len = hostapd_ctrl_iface_req_link_measurement( hapd, buf + 21, reply, reply_size); diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 5ba2cab2c..01a228c43 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -4200,8 +4200,8 @@ void free_beacon_data(struct beacon_data *beacon) } -static int hostapd_build_beacon_data(struct hostapd_data *hapd, - struct beacon_data *beacon) +int hostapd_build_beacon_data(struct hostapd_data *hapd, + struct beacon_data *beacon) { struct wpabuf *beacon_extra, *proberesp_extra, *assocresp_extra; struct wpa_driver_ap_params params; diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 7e72863af..6cc25e474 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -859,6 +859,8 @@ int hostapd_mld_add_link(struct hostapd_data *hapd); int hostapd_mld_remove_link(struct hostapd_data *hapd); struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd); +int hostapd_build_beacon_data(struct hostapd_data *hapd, + struct beacon_data *beacon); void free_beacon_data(struct beacon_data *beacon); int hostapd_fill_cca_settings(struct hostapd_data *hapd, struct cca_settings *settings);