git: 586aaa8ac53a - stable/14 - net80211: adjust more VHT structures/fields
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 18 Feb 2024 21:11:21 UTC
The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=586aaa8ac53a44d37cd35cdad58462e2739576fe commit 586aaa8ac53a44d37cd35cdad58462e2739576fe Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2023-12-02 20:40:51 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2024-02-18 18:31:15 +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 Reviewed by: adrian (earlier), cc Differential Revision: https://reviews.freebsd.org/D42901 (cherry picked from commit e85eb4c8d7bd8051c351a6fc6982a8b3bcfdbb2d) --- 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 <net/if_media.h> #include <net/route.h> +#define WANT_NET80211 1 #include <net80211/ieee80211_ioctl.h> #include <net80211/ieee80211_freebsd.h> #include <net80211/ieee80211_superg.h> @@ -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("<err: vht_cap inval. length>"); + return; + } + /* Skip Element ID and Length. */ + vhtcap = (const struct ieee80211_vht_cap *)(ie + 2); + + vhtcap_info = LE_READ_4(&vhtcap->vht_cap_info); printf("<cap 0x%08x", vhtcap_info); printf(" rx_mcs_map 0x%x", LE_READ_2(&vhtcap->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("<err: vht_operation inval. length>"); + return; + } + /* Skip Element ID and Length. */ + vhtinfo = (const struct ieee80211_vht_operation *)(ie + 2); - printf("<chw %d freq1_idx %d freq2_idx %d basic_mcs_set 0x%04x>", + printf("<chw %d freq0_idx %d freq1_idx %d basic_mcs_set 0x%04x>", 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 22e4cfd54536..b7a328ee06be 100644 --- a/sys/net80211/ieee80211_hostap.c +++ b/sys/net80211/ieee80211_hostap.c @@ -2129,12 +2129,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 1561255be101..77a36a395d5c 100644 --- a/sys/net80211/ieee80211_vht.c +++ b/sys/net80211/ieee80211_vht.c @@ -342,7 +342,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; @@ -350,9 +350,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. @@ -680,19 +677,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 */ @@ -775,10 +765,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 */ @@ -886,7 +875,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_ */