]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/wpa/src/ap/ieee802_11_he.c
Update hostapd/wpa_supplicant to 2.8 to fix multiple vulnerabilities.
[FreeBSD/FreeBSD.git] / contrib / wpa / src / ap / ieee802_11_he.c
1 /*
2  * hostapd / IEEE 802.11ax HE
3  * Copyright (c) 2016-2017, Qualcomm Atheros, Inc.
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8
9 #include "utils/includes.h"
10
11 #include "utils/common.h"
12 #include "common/ieee802_11_defs.h"
13 #include "hostapd.h"
14 #include "ap_config.h"
15 #include "beacon.h"
16 #include "ieee802_11.h"
17 #include "dfs.h"
18
19 u8 * hostapd_eid_he_capab(struct hostapd_data *hapd, u8 *eid)
20 {
21         struct ieee80211_he_capabilities *cap;
22         u8 *pos = eid;
23
24         if (!hapd->iface->current_mode)
25                 return eid;
26
27         *pos++ = WLAN_EID_EXTENSION;
28         *pos++ = 1 + sizeof(struct ieee80211_he_capabilities);
29         *pos++ = WLAN_EID_EXT_HE_CAPABILITIES;
30
31         cap = (struct ieee80211_he_capabilities *) pos;
32         os_memset(cap, 0, sizeof(*cap));
33
34         if (hapd->iface->conf->he_phy_capab.he_su_beamformer)
35                 cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMER_CAPAB_IDX] |=
36                         HE_PHYCAP_SU_BEAMFORMER_CAPAB;
37
38         if (hapd->iface->conf->he_phy_capab.he_su_beamformee)
39                 cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMEE_CAPAB_IDX] |=
40                         HE_PHYCAP_SU_BEAMFORMEE_CAPAB;
41
42         if (hapd->iface->conf->he_phy_capab.he_mu_beamformer)
43                 cap->he_phy_capab_info[HE_PHYCAP_MU_BEAMFORMER_CAPAB_IDX] |=
44                         HE_PHYCAP_MU_BEAMFORMER_CAPAB;
45
46         pos += sizeof(*cap);
47
48         return pos;
49 }
50
51
52 u8 * hostapd_eid_he_operation(struct hostapd_data *hapd, u8 *eid)
53 {
54         struct ieee80211_he_operation *oper;
55         u8 *pos = eid;
56
57         if (!hapd->iface->current_mode)
58                 return eid;
59
60         *pos++ = WLAN_EID_EXTENSION;
61         *pos++ = 1 + sizeof(struct ieee80211_he_operation);
62         *pos++ = WLAN_EID_EXT_HE_OPERATION;
63
64         oper = (struct ieee80211_he_operation *) pos;
65         os_memset(oper, 0, sizeof(*oper));
66
67         if (hapd->iface->conf->he_op.he_bss_color)
68                 oper->he_oper_params |= hapd->iface->conf->he_op.he_bss_color;
69
70         if (hapd->iface->conf->he_op.he_default_pe_duration)
71                 oper->he_oper_params |=
72                         (hapd->iface->conf->he_op.he_default_pe_duration <<
73                          HE_OPERATION_DFLT_PE_DURATION_OFFSET);
74
75         if (hapd->iface->conf->he_op.he_twt_required)
76                 oper->he_oper_params |= HE_OPERATION_TWT_REQUIRED;
77
78         if (hapd->iface->conf->he_op.he_rts_threshold)
79                 oper->he_oper_params |=
80                         (hapd->iface->conf->he_op.he_rts_threshold <<
81                          HE_OPERATION_RTS_THRESHOLD_OFFSET);
82
83         /* TODO: conditional MaxBSSID Indicator subfield */
84
85         pos += sizeof(*oper);
86
87         return pos;
88 }
89
90
91 u8 * hostapd_eid_he_mu_edca_parameter_set(struct hostapd_data *hapd, u8 *eid)
92 {
93         struct ieee80211_he_mu_edca_parameter_set *edca;
94         u8 *pos;
95         size_t i;
96
97         pos = (u8 *) &hapd->iface->conf->he_mu_edca;
98         for (i = 0; i < sizeof(*edca); i++) {
99                 if (pos[i])
100                         break;
101         }
102         if (i == sizeof(*edca))
103                 return eid; /* no MU EDCA Parameters configured */
104
105         pos = eid;
106         *pos++ = WLAN_EID_EXTENSION;
107         *pos++ = 1 + sizeof(*edca);
108         *pos++ = WLAN_EID_EXT_HE_MU_EDCA_PARAMS;
109
110         edca = (struct ieee80211_he_mu_edca_parameter_set *) pos;
111         os_memcpy(edca, &hapd->iface->conf->he_mu_edca, sizeof(*edca));
112
113         wpa_hexdump(MSG_DEBUG, "HE: MU EDCA Parameter Set element",
114                     pos, sizeof(*edca));
115
116         pos += sizeof(*edca);
117
118         return pos;
119 }