From nobody Wed Jan 18 16:25:00 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NxrhF2LGZz2yJS2; Wed, 18 Jan 2023 16:25:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NxrhF0mcsz3FPX; Wed, 18 Jan 2023 16:25:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CJXA6E/8vg86uMSDHXiD44gq19n4D3QIAVrUrDrXeCU=; b=oEY5yyPIxRDzTPkPQs3Um05nFOW7KTI2fc7G+gmeR30vo0Erjp01sqWIZv4SjWuLCwPtcf QHoBGKTueQKlKeZKe9X4m/qEqkxWJrr5mxPe6KtjaJ9g7kGEryBbKbPuPSCAR+fgpw5dW+ r2x8e+C0pMwVerJm3F2sMyC3x3tYAiM6V4pbSQJ+1BEFOnHT3Bn9ThZTR7vHYz98z3xMm7 sZI22oQRilQD6twQZJ3A7Bn++qPn2DtLbrvtRj13h4FkFTJJJ1X1IjaImFHqm3gqxvJEhb s1/Rf8S8UMtWD3GgaVXSHI1ZvniSUFE07fN1+6hO7N+TfrkvI6F5lqWtTDC70g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CJXA6E/8vg86uMSDHXiD44gq19n4D3QIAVrUrDrXeCU=; b=hDvL70HqWNBuBWNonxQI9ZeQ/Ue/ZNRHqCdh/pR4QMrJm4tc9g2RwuT8/eKd4RlSbac6hr hSlB2TAYC15MuSgHXol569B2syIomolhIn9WgPViOREuSCpP1LspxrWBo3+0wzeYErRChb iJO0Mphd+EhAFktMF/4s888QSAjUrG7BQikqGqaLLlO28VQjTKV5K5RdREF3G1pjBMSIqs KBwPW/+H1cZBELfi2NThmmxgkQzrRu3y5IAhydZ2lh+VW7b0LfejfJBe/cdq43QooaIDZA JS+0tPlOFAjSaO3EX4x2FzF2dAddTv+9ZkvGr3uLU+Nf+gjZc7CpHE24pBQ4lw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674059101; a=rsa-sha256; cv=none; b=unFepYg+vL1W16vYQMMCtwdgvnJLPXgRlIAHCovyOboRpcfA5nWmcwK0QTffCAa78/9ZbL Sch8hJcvK9j6vtpDB9CzVw6GL7nCP3PayZgN00Ctx6QUWcpBGn5OJLu2UalJaq7uEdM7Fv ZVsxn/8i85hbZTx9C17WyC6RlXMgnSz1vRFy4eJIwTmtfHT5z3WHO9NDIdf00hJiKPF1Qi qCcneA/JjZ+DvtjnOUMjpGoM8CCuxWHQpogjWHa9yJNCwWK2fbQ/QdBfXUbJpDpdXVOOwJ 3OZPO6J5/qNCTHafvytDEXOIMcXtEWH3sGlazYnblkpDyi8vqJ+jpILp+x5Jyw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NxrhD70M1zJB4; Wed, 18 Jan 2023 16:25:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30IGP08h038202; Wed, 18 Jan 2023 16:25:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30IGP0Hg038201; Wed, 18 Jan 2023 16:25:00 GMT (envelope-from git) Date: Wed, 18 Jan 2023 16:25:00 GMT Message-Id: <202301181625.30IGP0Hg038201@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: ba26206ad9e3 - stable/13 - LinuxKPI: 802.11: implement some *eleme/ie* lookup functions List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ba26206ad9e34af730095f5e20f3ecf517dbd89c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=ba26206ad9e34af730095f5e20f3ecf517dbd89c commit ba26206ad9e34af730095f5e20f3ecf517dbd89c Author: Bjoern A. Zeeb AuthorDate: 2022-12-31 01:33:28 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-01-18 13:26:21 +0000 LinuxKPI: 802.11: implement some *eleme/ie* lookup functions Implement cfg80211_find_elem(), ieee80211_bss_get_elem(), ieee80211_bss_get_ie(), and cfg80211_find_vendor_ie() with the last one having a short cut always also checking oui_type in the pattern. Sponsored by: The FreeBSD Foundation (cherry picked from commit 5db817d864241232c51d654836996282c69f5e28) --- sys/compat/linuxkpi/common/include/net/cfg80211.h | 76 +++++++++++++++++++---- sys/compat/linuxkpi/common/include/net/mac80211.h | 14 ----- 2 files changed, 65 insertions(+), 25 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h index b5135f34981e..55a74227a338 100644 --- a/sys/compat/linuxkpi/common/include/net/cfg80211.h +++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h @@ -1321,13 +1321,75 @@ struct element { uint8_t data[0]; } __packed; -static __inline const struct element * -cfg80211_find_elem(enum ieee80211_eid eid, uint8_t *data, size_t len) +static inline const struct element * +lkpi_cfg80211_find_elem_pattern(enum ieee80211_eid eid, + const uint8_t *data, size_t len, uint8_t *pattern, size_t plen) { - TODO(); + const struct element *elem; + const uint8_t *p; + size_t ielen; + + p = data; + elem = (const struct element *)p; + ielen = len; + while (elem != NULL && ielen > 1) { + if ((2 + elem->datalen) > ielen) + /* Element overruns our memory. */ + return (NULL); + if (elem->id == eid) { + if (pattern == NULL) + return (elem); + if (elem->datalen >= plen && + memcmp(elem->data, pattern, plen) == 0) + return (elem); + } + ielen -= 2 + elem->datalen; + p += 2 + elem->datalen; + elem = (const struct element *)p; + } + return (NULL); } +static inline const struct element * +cfg80211_find_elem(enum ieee80211_eid eid, const uint8_t *data, size_t len) +{ + + return (lkpi_cfg80211_find_elem_pattern(eid, data, len, NULL, 0)); +} + +static inline const struct element * +ieee80211_bss_get_elem(struct cfg80211_bss *bss, uint32_t eid) +{ + + if (bss->ies == NULL) + return (NULL); + return (cfg80211_find_elem(eid, bss->ies->data, bss->ies->len)); +} + +static inline const uint8_t * +ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t eid) +{ + + return ((const uint8_t *)ieee80211_bss_get_elem(bss, eid)); +} + +static inline uint8_t * +cfg80211_find_vendor_ie(unsigned int oui, int oui_type, + uint8_t *data, size_t len) +{ + const struct element *elem; + uint8_t pattern[4] = { oui << 16, oui << 8, oui, oui_type }; + uint8_t plen = 4; /* >= 3? oui_type always part of this? */ + IMPROVE("plen currently always incl. oui_type"); + + elem = lkpi_cfg80211_find_elem_pattern(IEEE80211_ELEMID_VENDOR, + data, len, pattern, plen); + if (elem == NULL) + return (NULL); + return (__DECONST(uint8_t *, elem)); +} + static __inline uint32_t cfg80211_calculate_bitrate(struct rate_info *rate) { @@ -1439,14 +1501,6 @@ wiphy_read_of_freq_limits(struct wiphy *wiphy) #endif } -static __inline uint8_t * -cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type, - uint8_t *data, size_t len) -{ - TODO(); - return (NULL); -} - static __inline void wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef) { diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h index 230d42947e7b..d548b9bb956f 100644 --- a/sys/compat/linuxkpi/common/include/net/mac80211.h +++ b/sys/compat/linuxkpi/common/include/net/mac80211.h @@ -2183,13 +2183,6 @@ SET_IEEE80211_PERM_ADDR (struct ieee80211_hw *hw, uint8_t *addr) ether_addr_copy(hw->wiphy->perm_addr, addr); } -static __inline uint8_t * -ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t eid) -{ - TODO(); - return (NULL); -} - static __inline void ieee80211_report_low_ack(struct ieee80211_sta *sta, int x) { @@ -2368,13 +2361,6 @@ ieee80211_tx_status_ext(struct ieee80211_hw *hw, TODO(); } -static __inline const struct element * -ieee80211_bss_get_elem(struct cfg80211_bss *bss, uint32_t eid) -{ - TODO(); - return (NULL); -} - static __inline void ieee80211_color_change_finish(struct ieee80211_vif *vif) {