From nobody Fri Dec 22 00:21:33 2023 X-Original-To: dev-commits-src-main@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 4Sx7JY5MjPz54SNc; Fri, 22 Dec 2023 00:21:33 +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 4Sx7JY4wTbz3C9c; Fri, 22 Dec 2023 00:21:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703204493; 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=QFyveAP4P8La/HwORG6pKv4J1aSHXyai+JSntdt1oQE=; b=CDUPkW3I5HtfE9VFgW9Eq50ChR80dW5Kt31eNb43on98K0N0IhQdXVTHJ7vAx359CyF3fx OrnE8B7AsoGT1rux1Ek7kPlD75rdbzTMJBKZIWGWeOuksZMlJtLlcmwixxSXWNavVasGMX SSeDK1OrVtN/W2qdWafbeSN9AfTiWCRnUWzX8Y43O5uqAgnSppLcHlROFn9qY+EfY8AjtR n9DepEl/3oHAbW8SL3NGbtG956z55Y8w/ILl9DrAOYRXYLHPExEqyYF4/AOwtK0XIk4UVf m2jnRny1h3xL3SxKFV/crfgpVgaFSozxyfDoAoWnPJgWdnHf7yNp1DRUUoSthw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703204493; a=rsa-sha256; cv=none; b=Q9bOFMxhwe8yifxPFY0+xqh45tw7Isc/UWu1TJgNFyTmHubjBz5VY1azSFV0VYGJu/bVuF hfVYzNK9YQcQjwczUPKF99yfneVen+vuysHusv9BHDyn3rvy0XuDWbdzbTw43PHGWvDAeD R4UiYNXB6vJyi/mDw7WsRgSambCWaF/rcFW2V70xWcF/8ziDgZnRTWUBevpa3dw5Lyvnji /zq30ED1+Nq1LWudyt0KcW/UQO4M1eujW2AJS2nZuYkkFkFnPCdiuPYXl7O1W2/8quaNc0 PbSIOIBS86LMtoQ33GgOroXncfDzFodmcUbusWwH8LqEdV402mHvuPNfBhBIjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703204493; 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=QFyveAP4P8La/HwORG6pKv4J1aSHXyai+JSntdt1oQE=; b=lGt1L+HJB2Td9rU8vhM3UBYlxyndONHqdPfHDnJ0JOb1Ec5ktLbtj+dB2LBMNhlTilZeNj y7zDBRSOUZMHoqcNqmQIjszfNOZaRDOm8eFljSUhfIDaHQN+/xdWKVPRSNi0sHVirPRt9P dXG00f7uHeUxfDt2xgoPQlqDbbLLysB+5+M9WptTYenk+xaSG3Wi3tNwy+647qjpVQ1EXf 22zv7GAlcuI2fr2UKBM7zuyzN+aOnFaTaUOAMeFIvm4OUawjQm+fdT1jJ6zuKfExLbkuyn DCOwcEYOZZm4F//GB/VOunFIZptLQMFIcEqHasFa7RTyLH2THa273x6H9KxAqw== 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 4Sx7JY3zXQztrr; Fri, 22 Dec 2023 00:21:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BM0LXZK050293; Fri, 22 Dec 2023 00:21:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BM0LXCG050290; Fri, 22 Dec 2023 00:21:33 GMT (envelope-from git) Date: Fri, 22 Dec 2023 00:21:33 GMT Message-Id: <202312220021.3BM0LXCG050290@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: e85eb4c8d7bd - main - net80211: adjust more VHT structures/fields List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: e85eb4c8d7bd8051c351a6fc6982a8b3bcfdbb2d Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e85eb4c8d7bd8051c351a6fc6982a8b3bcfdbb2d commit e85eb4c8d7bd8051c351a6fc6982a8b3bcfdbb2d Author: Bjoern A. Zeeb AuthorDate: 2023-12-02 20:40:51 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-12-22 00:20:19 +0000 net80211: adjust more VHT structures/fields Replace ieee80211_ie_vhtcap with ieee80211_vht_cap and ieee80211_ie_vht_operation with ieee80211_vht_operation. The "ie" version has the two bytes type/length at the beginning which we did not actually use as such (the one place doing did just as unused extra work). Using the non-"ie" versions allows us to re-use them on shared code. Using an enum helps us to not accidentally get unsuppored or unhandled values tough we cannot use it in the struct as we need to ensure the field width. ieee80211_vht_operation is guarded by _KERNEL/WANT_NET80211. While the header is supposed to be exported to user land historically, software such as wpa bring their own structure definitions. For in-tree usage it is only ifconfig which really cares (at least for now). Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: adrian (earlier), cc Differential Revision: https://reviews.freebsd.org/D42901 --- sbin/ifconfig/ifieee80211.c | 32 ++++++++++++++++++++++++-------- sys/net80211/ieee80211.h | 38 +++++++++++++++++--------------------- sys/net80211/ieee80211_hostap.c | 4 ++-- sys/net80211/ieee80211_input.c | 4 ++-- sys/net80211/ieee80211_output.c | 16 ++++++++-------- sys/net80211/ieee80211_vht.c | 23 ++++++----------------- sys/net80211/ieee80211_vht.h | 4 ++-- 7 files changed, 61 insertions(+), 60 deletions(-) diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 42ef6d731662..bde079deb4c6 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -70,6 +70,7 @@ #include #include +#define WANT_NET80211 1 #include #include #include @@ -2780,10 +2781,18 @@ printvhtcap(if_ctx *ctx, const char *tag, const u_int8_t *ie) { printf("%s", tag); if (ctx->args->verbose) { - const struct ieee80211_ie_vhtcap *vhtcap = - (const struct ieee80211_ie_vhtcap *) ie; - uint32_t vhtcap_info = LE_READ_4(&vhtcap->vht_cap_info); + const struct ieee80211_vht_cap *vhtcap; + uint32_t vhtcap_info; + /* Check that the the right size. */ + if (ie[1] != sizeof(*vhtcap)) { + printf(""); + return; + } + /* Skip Element ID and Length. */ + vhtcap = (const struct ieee80211_vht_cap *)(ie + 2); + + vhtcap_info = LE_READ_4(&vhtcap->vht_cap_info); printf("supp_mcs.rx_mcs_map)); @@ -2803,13 +2812,20 @@ printvhtinfo(if_ctx *ctx, const char *tag, const u_int8_t *ie) { printf("%s", tag); if (ctx->args->verbose) { - const struct ieee80211_ie_vht_operation *vhtinfo = - (const struct ieee80211_ie_vht_operation *) ie; + const struct ieee80211_vht_operation *vhtinfo; + + /* Check that the the right size. */ + if (ie[1] != sizeof(*vhtinfo)) { + printf(""); + return; + } + /* Skip Element ID and Length. */ + vhtinfo = (const struct ieee80211_vht_operation *)(ie + 2); - printf("", + printf("", vhtinfo->chan_width, - vhtinfo->center_freq_seg1_idx, - vhtinfo->center_freq_seg2_idx, + vhtinfo->center_freq_seq0_idx, + vhtinfo->center_freq_seq1_idx, LE_READ_2(&vhtinfo->basic_mcs_set)); } } diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index b3fbd0a27b51..47e496bf42a1 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -869,29 +869,25 @@ struct ieee80211_vht_cap { struct ieee80211_vht_mcs_info supp_mcs; } __packed; -/* VHT capabilities element: 802.11ac-2013 8.4.2.160 */ -struct ieee80211_ie_vhtcap { - uint8_t ie; - uint8_t len; - uint32_t vht_cap_info; - struct ieee80211_vht_mcs_info supp_mcs; -} __packed; - -/* VHT operation mode subfields - 802.11ac-2013 Table 8.183x */ -#define IEEE80211_VHT_CHANWIDTH_USE_HT 0 /* Use HT IE for chw */ -#define IEEE80211_VHT_CHANWIDTH_80MHZ 1 /* 80MHz */ -#define IEEE80211_VHT_CHANWIDTH_160MHZ 2 /* 160MHz */ -#define IEEE80211_VHT_CHANWIDTH_80P80MHZ 3 /* 80+80MHz */ +/* 802.11ac-2013, Table 8-183x-VHT Operation Information subfields */ +enum ieee80211_vht_chanwidth { + IEEE80211_VHT_CHANWIDTH_USE_HT = 0, /* 20 MHz or 40 MHz */ + IEEE80211_VHT_CHANWIDTH_80MHZ = 1, /* 80MHz */ + IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz */ + IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz */ + /* 4..255 reserved. */ +}; -/* VHT operation IE - 802.11ac-2013 8.4.2.161 */ -struct ieee80211_ie_vht_operation { - uint8_t ie; - uint8_t len; - uint8_t chan_width; - uint8_t center_freq_seg1_idx; - uint8_t center_freq_seg2_idx; - uint16_t basic_mcs_set; +/* The name conflicts with the same structure in wpa. Only ifconfig needs this. */ +#if defined(_KERNEL) || defined(WANT_NET80211) +/* 802.11ac-2013 8.4.2.161 VHT Operation element */ +struct ieee80211_vht_operation { + uint8_t chan_width; /* enum ieee80211_vht_chanwidth */ + uint8_t center_freq_seq0_idx; /* 20/40/80/160 - VHT chan1 */ + uint8_t center_freq_seq1_idx; /* 80+80 - VHT chan2 */ + uint16_t basic_mcs_set; /* Basic VHT-MCS and NSS Set */ } __packed; +#endif /* 802.11ac VHT Capabilities */ #define IEEE80211_VHTCAP_MAX_MPDU_LENGTH_3895 0x00000000 diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c index c1196961ad54..67c45bd38935 100644 --- a/sys/net80211/ieee80211_hostap.c +++ b/sys/net80211/ieee80211_hostap.c @@ -2125,12 +2125,12 @@ hostap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, /* Validate VHT IEs */ if (vhtcap != NULL) { IEEE80211_VERIFY_LENGTH(vhtcap[1], - sizeof(struct ieee80211_ie_vhtcap) - 2, + sizeof(struct ieee80211_vht_cap), return); } if (vhtinfo != NULL) { IEEE80211_VERIFY_LENGTH(vhtinfo[1], - sizeof(struct ieee80211_ie_vht_operation) - 2, + sizeof(struct ieee80211_vht_operation), return); } diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index a4bfe49bd8c4..925918c872dc 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -773,12 +773,12 @@ ieee80211_parse_beacon(struct ieee80211_node *ni, struct mbuf *m, /* Process VHT IEs */ if (scan->vhtcap != NULL) { IEEE80211_VERIFY_LENGTH(scan->vhtcap[1], - sizeof(struct ieee80211_ie_vhtcap) - 2, + sizeof(struct ieee80211_vht_cap), scan->vhtcap = NULL); } if (scan->vhtopmode != NULL) { IEEE80211_VERIFY_LENGTH(scan->vhtopmode[1], - sizeof(struct ieee80211_ie_vht_operation) - 2, + sizeof(struct ieee80211_vht_operation), scan->vhtopmode = NULL); } diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index a5fad2462598..22bbfe98f4b5 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -2456,7 +2456,7 @@ ieee80211_probereq_ie_len(struct ieee80211vap *vap, struct ieee80211com *ic) sizeof(struct ieee80211_ie_htcap) : 0) #ifdef notyet + sizeof(struct ieee80211_ie_htinfo) /* XXX not needed? */ - + sizeof(struct ieee80211_ie_vhtcap) + + 2 + sizeof(struct ieee80211_vht_cap) #endif + ((vap->iv_flags & IEEE80211_F_WPA1 && vap->iv_wpa_ie != NULL) ? vap->iv_wpa_ie[1] : 0) @@ -2821,7 +2821,7 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) + 2 + 26 + sizeof(struct ieee80211_wme_info) + sizeof(struct ieee80211_ie_htcap) - + sizeof(struct ieee80211_ie_vhtcap) + + 2 + sizeof(struct ieee80211_vht_cap) + 4 + sizeof(struct ieee80211_ie_htcap) #ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) @@ -2954,8 +2954,8 @@ ieee80211_send_mgmt(struct ieee80211_node *ni, int type, int arg) + 2 + (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) + sizeof(struct ieee80211_ie_htcap) + 4 + sizeof(struct ieee80211_ie_htinfo) + 4 - + sizeof(struct ieee80211_ie_vhtcap) - + sizeof(struct ieee80211_ie_vht_operation) + + 2 + sizeof(struct ieee80211_vht_cap) + + 2 + sizeof(struct ieee80211_vht_operation) + sizeof(struct ieee80211_wme_param) #ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) @@ -3113,8 +3113,8 @@ ieee80211_alloc_proberesp(struct ieee80211_node *bss, int legacy) + sizeof(struct ieee80211_wme_param) + 4 + sizeof(struct ieee80211_ie_htcap) + 4 + sizeof(struct ieee80211_ie_htinfo) - + sizeof(struct ieee80211_ie_vhtcap) - + sizeof(struct ieee80211_ie_vht_operation) + + 2 + sizeof(struct ieee80211_vht_cap) + + 2 + sizeof(struct ieee80211_vht_operation) #ifdef IEEE80211_SUPPORT_SUPERG + sizeof(struct ieee80211_ath_ie) #endif @@ -3728,8 +3728,8 @@ ieee80211_beacon_alloc(struct ieee80211_node *ni) /* XXX conditional? */ + 4+2*sizeof(struct ieee80211_ie_htcap)/* HT caps */ + 4+2*sizeof(struct ieee80211_ie_htinfo)/* HT info */ - + sizeof(struct ieee80211_ie_vhtcap)/* VHT caps */ - + sizeof(struct ieee80211_ie_vht_operation)/* VHT info */ + + 2 + sizeof(struct ieee80211_vht_cap)/* VHT caps */ + + 2 + sizeof(struct ieee80211_vht_operation)/* VHT info */ + (vap->iv_caps & IEEE80211_C_WME ? /* WME */ sizeof(struct ieee80211_wme_param) : 0) #ifdef IEEE80211_SUPPORT_SUPERG diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c index 4b5a53d583ce..0839f426e09c 100644 --- a/sys/net80211/ieee80211_vht.c +++ b/sys/net80211/ieee80211_vht.c @@ -338,7 +338,7 @@ ieee80211_vht_node_leave(struct ieee80211_node *ni) */ void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vhtcap *vhtcap, int opmode) + struct ieee80211_vht_cap *vhtcap, int opmode) { struct ieee80211vap *vap = ni->ni_vap; // struct ieee80211com *ic = vap->iv_ic; @@ -346,9 +346,6 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, uint32_t new_vhtcap; int i; - vhtcap->ie = IEEE80211_ELEMID_VHT_CAP; - vhtcap->len = sizeof(struct ieee80211_ie_vhtcap) - 2; - /* * Capabilities - it depends on whether we are a station * or not. @@ -676,19 +673,12 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, uint8_t * ieee80211_add_vhtcap(uint8_t *frm, struct ieee80211_node *ni) { - struct ieee80211_ie_vhtcap vhtcap; - int opmode; - - opmode = 0; - if (ni->ni_vap->iv_opmode == IEEE80211_M_STA) - opmode = 1; - - ieee80211_vht_get_vhtcap_ie(ni, &vhtcap, opmode); + struct ieee80211_vht_cap vhtcap; - memset(frm, '\0', sizeof(struct ieee80211_ie_vhtcap)); + ieee80211_vht_get_vhtcap_ie(ni, &vhtcap, 1); frm[0] = IEEE80211_ELEMID_VHT_CAP; - frm[1] = sizeof(struct ieee80211_ie_vhtcap) - 2; + frm[1] = sizeof(vhtcap); frm += 2; /* 32-bit VHT capability */ @@ -771,10 +761,9 @@ ieee80211_vht_get_chwidth_ie(struct ieee80211_channel *c) uint8_t * ieee80211_add_vhtinfo(uint8_t *frm, struct ieee80211_node *ni) { - memset(frm, '\0', sizeof(struct ieee80211_ie_vht_operation)); frm[0] = IEEE80211_ELEMID_VHT_OPMODE; - frm[1] = sizeof(struct ieee80211_ie_vht_operation) - 2; + frm[1] = sizeof(struct ieee80211_vht_operation); frm += 2; /* 8-bit chanwidth */ @@ -882,7 +871,7 @@ ieee80211_vht_adjust_channel(struct ieee80211com *ic, */ void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vht_operation *vhtop, int opmode) + struct ieee80211_vht_operation *vhtop, int opmode) { printf("%s: called; TODO!\n", __func__); } diff --git a/sys/net80211/ieee80211_vht.h b/sys/net80211/ieee80211_vht.h index 756c2e367485..f2d1706ea0f2 100644 --- a/sys/net80211/ieee80211_vht.h +++ b/sys/net80211/ieee80211_vht.h @@ -61,8 +61,8 @@ struct ieee80211_channel * struct ieee80211_channel *, int); void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vhtcap *, int); + struct ieee80211_vht_cap *, int); void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, - struct ieee80211_ie_vht_operation *, int); + struct ieee80211_vht_operation *, int); #endif /* _NET80211_IEEE80211_VHT_H_ */