From nobody Sat Dec 31 02:33:02 2022 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 4NkR4Z2pjfz2lB0T; Sat, 31 Dec 2022 02:33:02 +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 4NkR4Z2NpYz4HJ6; Sat, 31 Dec 2022 02:33:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672453982; 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=TKd0198vlYsAUdhpA3yaBvF8t8X5X6nFcSRoTYXp87c=; b=trg2L8I7GUFlMv9jUyByYVfbT6doNEyInbKbRwzhUcNbxcjE3QdbH/TcwMB09nw6f9lPa5 fisRfTtgq7lydX+hc7gLPfKl8vZesRneyYp5HJi2mzRw8aR+kIQSvkO0C5ljOFzP/2kt97 pgce7dQ9Wm/szcaj9BjwRmCY7fyHupPzN0v6xNBlbd0JpTp1TajYnZ9HH833HRh8xCSdig WtmD5t6fVhkbM1JfjdqsAt0b7XZXiF1Mauo8+JiBxnTjDlowiCI3UjVG+xoHZBgX+XuEuv fWBlvAlA1mhfHIP5PZ0JC9dzkR7oz4pRGDn759gBcbDMRoPUptfueXueGVyJ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672453982; 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=TKd0198vlYsAUdhpA3yaBvF8t8X5X6nFcSRoTYXp87c=; b=MydMzFlThRz6iWWr1/YF6GRiim9U2HGQ1qYuTgbFB0sKpdmqtX2XFZdRKF1FFC18SBnIjr VWdbs7HqFr1tdMb6GTyu4c6gz620Pz9UQhs7+lFJ1KCUncQ+3hcX6o1nS+SI3YTJg3rSFA j7i7GLgF5NlBdIP+ZfLMf7POcnEoChCaj/AjVU6G8cwI9v5ljNnJblk7HCraOGHN7W+sfk vKmvPOz0VG6XwBhBSaqabCMyx9XAJKBgRRDZMQ2sshHEbq+am8UBtRCUFzaXCHxSCDiM8D VgsSHTWnY0QOsA5j9z058UuT5oFh0IUP1xz6+a1QVY29inp+Pnqu2V3CRxI91w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672453982; a=rsa-sha256; cv=none; b=EpCoefe+18MXCvdNeb257sLWYmElDGXhQPjktcLa/XdsS5ByTsOtLLbXXcAJf0wH4d9E4b eP/ML2uExnHimSyQnioYYF8bI2nV6nnm+dkQ7VaPWTCf4xJRAU1IGZBGPyAeNYmLr6CtqJ kGQ+DctTMQAkrcz+FLwOIxb5R7GK2f3qacXv/mhJpvmDoEuveQqGyAtCKpnBrHWsL6bKMo 0wxR7UdkjEvz4CEzmOwAvqaKK5RgYtjeTL2ddZuorYHyyw8WpCc5eRp+pN4f+/iCsMF7Q5 uF0+nJJm6l4haO568NhTeMxyJp1bGlaZoHQkeLwG1DLtullcZ5637rHZe4GYmA== 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 4NkR4Z1MvJzXcs; Sat, 31 Dec 2022 02:33:02 +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 2BV2X2Yh021119; Sat, 31 Dec 2022 02:33:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BV2X2vS021118; Sat, 31 Dec 2022 02:33:02 GMT (envelope-from git) Date: Sat, 31 Dec 2022 02:33:02 GMT Message-Id: <202212310233.2BV2X2vS021118@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 5db817d86424 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 5db817d864241232c51d654836996282c69f5e28 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=5db817d864241232c51d654836996282c69f5e28 commit 5db817d864241232c51d654836996282c69f5e28 Author: Bjoern A. Zeeb AuthorDate: 2022-12-31 01:33:28 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-12-31 01:33:28 +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 MFC after: 10 days --- sys/compat/linuxkpi/common/include/net/cfg80211.h | 78 +++++++++++++++++++---- sys/compat/linuxkpi/common/include/net/mac80211.h | 14 ---- 2 files changed, 66 insertions(+), 26 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h index 5f7755b44ba7..7e8e1a3adab6 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) -{ - TODO(); +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) +{ + 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 75f2dac02be2..2e4051952818 100644 --- a/sys/compat/linuxkpi/common/include/net/mac80211.h +++ b/sys/compat/linuxkpi/common/include/net/mac80211.h @@ -2174,13 +2174,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) { @@ -2359,13 +2352,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) {