LCOV - code coverage report
Current view: top level - src/ap - ieee802_11_ht.c (source / functions) Hit Total Coverage
Test: wpa_supplicant/hostapd combined for hwsim test run 1475438200 Lines: 245 264 92.8 %
Date: 2016-10-02 Functions: 14 14 100.0 %

          Line data    Source code
       1             : /*
       2             :  * hostapd / IEEE 802.11n HT
       3             :  * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
       4             :  * Copyright (c) 2007-2008, Intel Corporation
       5             :  *
       6             :  * This software may be distributed under the terms of the BSD license.
       7             :  * See README for more details.
       8             :  */
       9             : 
      10             : #include "utils/includes.h"
      11             : 
      12             : #include "utils/common.h"
      13             : #include "utils/eloop.h"
      14             : #include "common/ieee802_11_defs.h"
      15             : #include "hostapd.h"
      16             : #include "ap_config.h"
      17             : #include "sta_info.h"
      18             : #include "beacon.h"
      19             : #include "ieee802_11.h"
      20             : #include "hw_features.h"
      21             : #include "ap_drv_ops.h"
      22             : 
      23             : 
      24       15251 : u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
      25             : {
      26             :         struct ieee80211_ht_capabilities *cap;
      27       15251 :         u8 *pos = eid;
      28             : 
      29       30413 :         if (!hapd->iconf->ieee80211n || !hapd->iface->current_mode ||
      30       15162 :             hapd->conf->disable_11n)
      31         294 :                 return eid;
      32             : 
      33       14957 :         *pos++ = WLAN_EID_HT_CAP;
      34       14957 :         *pos++ = sizeof(*cap);
      35             : 
      36       14957 :         cap = (struct ieee80211_ht_capabilities *) pos;
      37       14957 :         os_memset(cap, 0, sizeof(*cap));
      38       14957 :         cap->ht_capabilities_info = host_to_le16(hapd->iconf->ht_capab);
      39       14957 :         cap->a_mpdu_params = hapd->iface->current_mode->a_mpdu_params;
      40       14957 :         os_memcpy(cap->supported_mcs_set, hapd->iface->current_mode->mcs_set,
      41             :                   16);
      42             : 
      43             :         /* TODO: ht_extended_capabilities (now fully disabled) */
      44             :         /* TODO: tx_bf_capability_info (now fully disabled) */
      45             :         /* TODO: asel_capabilities (now fully disabled) */
      46             : 
      47       14957 :         pos += sizeof(*cap);
      48             : 
      49       14957 :         if (hapd->iconf->obss_interval) {
      50             :                 struct ieee80211_obss_scan_parameters *scan_params;
      51             : 
      52          23 :                 *pos++ = WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS;
      53          23 :                 *pos++ = sizeof(*scan_params);
      54             : 
      55          23 :                 scan_params = (struct ieee80211_obss_scan_parameters *) pos;
      56          23 :                 os_memset(scan_params, 0, sizeof(*scan_params));
      57          23 :                 scan_params->width_trigger_scan_interval =
      58          23 :                         host_to_le16(hapd->iconf->obss_interval);
      59             : 
      60             :                 /* Fill in default values for remaining parameters
      61             :                  * (IEEE Std 802.11-2012, 8.4.2.61 and MIB defval) */
      62          23 :                 scan_params->scan_passive_dwell =
      63             :                         host_to_le16(20);
      64          23 :                 scan_params->scan_active_dwell =
      65             :                         host_to_le16(10);
      66          23 :                 scan_params->scan_passive_total_per_channel =
      67             :                         host_to_le16(200);
      68          23 :                 scan_params->scan_active_total_per_channel =
      69             :                         host_to_le16(20);
      70          23 :                 scan_params->channel_transition_delay_factor =
      71             :                         host_to_le16(5);
      72          23 :                 scan_params->scan_activity_threshold =
      73             :                         host_to_le16(25);
      74             : 
      75          23 :                 pos += sizeof(*scan_params);
      76             :         }
      77             : 
      78       14957 :         return pos;
      79             : }
      80             : 
      81             : 
      82       15251 : u8 * hostapd_eid_ht_operation(struct hostapd_data *hapd, u8 *eid)
      83             : {
      84             :         struct ieee80211_ht_operation *oper;
      85       15251 :         u8 *pos = eid;
      86             : 
      87       15251 :         if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n)
      88         294 :                 return eid;
      89             : 
      90       14957 :         *pos++ = WLAN_EID_HT_OPERATION;
      91       14957 :         *pos++ = sizeof(*oper);
      92             : 
      93       14957 :         oper = (struct ieee80211_ht_operation *) pos;
      94       14957 :         os_memset(oper, 0, sizeof(*oper));
      95             : 
      96       14957 :         oper->primary_chan = hapd->iconf->channel;
      97       14957 :         oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
      98       14957 :         if (hapd->iconf->secondary_channel == 1)
      99         195 :                 oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
     100             :                         HT_INFO_HT_PARAM_STA_CHNL_WIDTH;
     101       14957 :         if (hapd->iconf->secondary_channel == -1)
     102          57 :                 oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
     103             :                         HT_INFO_HT_PARAM_STA_CHNL_WIDTH;
     104             : 
     105       14957 :         pos += sizeof(*oper);
     106             : 
     107       14957 :         return pos;
     108             : }
     109             : 
     110             : 
     111       10167 : u8 * hostapd_eid_secondary_channel(struct hostapd_data *hapd, u8 *eid)
     112             : {
     113             :         u8 sec_ch;
     114             : 
     115       10196 :         if (!hapd->cs_freq_params.channel ||
     116          29 :             !hapd->cs_freq_params.sec_channel_offset)
     117       10159 :                 return eid;
     118             : 
     119           8 :         if (hapd->cs_freq_params.sec_channel_offset == -1)
     120           2 :                 sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW;
     121           6 :         else if (hapd->cs_freq_params.sec_channel_offset == 1)
     122           6 :                 sec_ch = HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE;
     123             :         else
     124           0 :                 return eid;
     125             : 
     126           8 :         *eid++ = WLAN_EID_SECONDARY_CHANNEL_OFFSET;
     127           8 :         *eid++ = 1;
     128           8 :         *eid++ = sec_ch;
     129             : 
     130           8 :         return eid;
     131             : }
     132             : 
     133             : 
     134             : /*
     135             : op_mode
     136             : Set to 0 (HT pure) under the followign conditions
     137             :         - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
     138             :         - all STAs in the BSS are 20 MHz HT in 20 MHz BSS
     139             : Set to 1 (HT non-member protection) if there may be non-HT STAs
     140             :         in both the primary and the secondary channel
     141             : Set to 2 if only HT STAs are associated in BSS,
     142             :         however and at least one 20 MHz HT STA is associated
     143             : Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
     144             : */
     145        9437 : int hostapd_ht_operation_update(struct hostapd_iface *iface)
     146             : {
     147             :         u16 cur_op_mode, new_op_mode;
     148        9437 :         int op_mode_changes = 0;
     149             : 
     150        9437 :         if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed)
     151          32 :                 return 0;
     152             : 
     153        9405 :         wpa_printf(MSG_DEBUG, "%s current operation mode=0x%X",
     154        9405 :                    __func__, iface->ht_op_mode);
     155             : 
     156        9405 :         if (!(iface->ht_op_mode & HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT)
     157        9405 :             && iface->num_sta_ht_no_gf) {
     158           0 :                 iface->ht_op_mode |= HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT;
     159           0 :                 op_mode_changes++;
     160        9405 :         } else if ((iface->ht_op_mode &
     161           0 :                     HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT) &&
     162           0 :                    iface->num_sta_ht_no_gf == 0) {
     163           0 :                 iface->ht_op_mode &= ~HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT;
     164           0 :                 op_mode_changes++;
     165             :         }
     166             : 
     167       18741 :         if (!(iface->ht_op_mode & HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT) &&
     168       18634 :             (iface->num_sta_no_ht || iface->olbc_ht)) {
     169          44 :                 iface->ht_op_mode |= HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT;
     170          44 :                 op_mode_changes++;
     171        9361 :         } else if ((iface->ht_op_mode &
     172          69 :                     HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT) &&
     173         113 :                    (iface->num_sta_no_ht == 0 && !iface->olbc_ht)) {
     174          39 :                 iface->ht_op_mode &= ~HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT;
     175          39 :                 op_mode_changes++;
     176             :         }
     177             : 
     178        9405 :         if (iface->num_sta_no_ht)
     179          63 :                 new_op_mode = HT_PROT_NON_HT_MIXED;
     180        9342 :         else if (iface->conf->secondary_channel && iface->num_sta_ht_20mhz)
     181           0 :                 new_op_mode = HT_PROT_20MHZ_PROTECTION;
     182        9342 :         else if (iface->olbc_ht)
     183          11 :                 new_op_mode = HT_PROT_NONMEMBER_PROTECTION;
     184             :         else
     185        9331 :                 new_op_mode = HT_PROT_NO_PROTECTION;
     186             : 
     187        9405 :         cur_op_mode = iface->ht_op_mode & HT_OPER_OP_MODE_HT_PROT_MASK;
     188        9405 :         if (cur_op_mode != new_op_mode) {
     189          85 :                 iface->ht_op_mode &= ~HT_OPER_OP_MODE_HT_PROT_MASK;
     190          85 :                 iface->ht_op_mode |= new_op_mode;
     191          85 :                 op_mode_changes++;
     192             :         }
     193             : 
     194        9405 :         wpa_printf(MSG_DEBUG, "%s new operation mode=0x%X changes=%d",
     195        9405 :                    __func__, iface->ht_op_mode, op_mode_changes);
     196             : 
     197        9405 :         return op_mode_changes;
     198             : }
     199             : 
     200             : 
     201           4 : static int is_40_allowed(struct hostapd_iface *iface, int channel)
     202             : {
     203             :         int pri_freq, sec_freq;
     204             :         int affected_start, affected_end;
     205           4 :         int pri = 2407 + 5 * channel;
     206             : 
     207           4 :         if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
     208           0 :                 return 1;
     209             : 
     210           4 :         pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel);
     211             : 
     212           4 :         if (iface->conf->secondary_channel > 0)
     213           1 :                 sec_freq = pri_freq + 20;
     214             :         else
     215           3 :                 sec_freq = pri_freq - 20;
     216             : 
     217           4 :         affected_start = (pri_freq + sec_freq) / 2 - 25;
     218           4 :         affected_end = (pri_freq + sec_freq) / 2 + 25;
     219           4 :         if ((pri < affected_start || pri > affected_end))
     220           1 :                 return 1; /* not within affected channel range */
     221             : 
     222           3 :         wpa_printf(MSG_ERROR, "40 MHz affected channel range: [%d,%d] MHz",
     223             :                    affected_start, affected_end);
     224           3 :         wpa_printf(MSG_ERROR, "Neighboring BSS: freq=%d", pri);
     225           3 :         return 0;
     226             : }
     227             : 
     228             : 
     229          14 : void hostapd_2040_coex_action(struct hostapd_data *hapd,
     230             :                               const struct ieee80211_mgmt *mgmt, size_t len)
     231             : {
     232          14 :         struct hostapd_iface *iface = hapd->iface;
     233             :         struct ieee80211_2040_bss_coex_ie *bc_ie;
     234             :         struct ieee80211_2040_intol_chan_report *ic_report;
     235          14 :         int is_ht40_allowed = 1;
     236             :         int i;
     237          14 :         const u8 *start = (const u8 *) mgmt;
     238          14 :         const u8 *data = start + IEEE80211_HDRLEN + 2;
     239             : 
     240          14 :         hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
     241             :                        HOSTAPD_LEVEL_DEBUG, "hostapd_public_action - action=%d",
     242          14 :                        mgmt->u.action.u.public_action.action);
     243             : 
     244          14 :         if (!(iface->conf->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
     245           0 :                 return;
     246             : 
     247          14 :         if (len < IEEE80211_HDRLEN + 2 + sizeof(*bc_ie))
     248           3 :                 return;
     249             : 
     250          11 :         bc_ie = (struct ieee80211_2040_bss_coex_ie *) data;
     251          21 :         if (bc_ie->element_id != WLAN_EID_20_40_BSS_COEXISTENCE ||
     252          10 :             bc_ie->length < 1) {
     253           4 :                 wpa_printf(MSG_DEBUG, "Unexpected IE (%u,%u) in coex report",
     254           4 :                            bc_ie->element_id, bc_ie->length);
     255           2 :                 return;
     256             :         }
     257           9 :         if (len < IEEE80211_HDRLEN + 2 + 2 + bc_ie->length)
     258           1 :                 return;
     259           8 :         data += 2 + bc_ie->length;
     260             : 
     261           8 :         wpa_printf(MSG_DEBUG, "20/40 BSS Coexistence Information field: 0x%x",
     262           8 :                    bc_ie->coex_param);
     263           8 :         if (bc_ie->coex_param & WLAN_20_40_BSS_COEX_20MHZ_WIDTH_REQ) {
     264           4 :                 hostapd_logger(hapd, mgmt->sa,
     265             :                                HOSTAPD_MODULE_IEEE80211,
     266             :                                HOSTAPD_LEVEL_DEBUG,
     267             :                                "20 MHz BSS width request bit is set in BSS coexistence information field");
     268           4 :                 is_ht40_allowed = 0;
     269             :         }
     270             : 
     271           8 :         if (bc_ie->coex_param & WLAN_20_40_BSS_COEX_40MHZ_INTOL) {
     272           1 :                 hostapd_logger(hapd, mgmt->sa,
     273             :                                HOSTAPD_MODULE_IEEE80211,
     274             :                                HOSTAPD_LEVEL_DEBUG,
     275             :                                "40 MHz intolerant bit is set in BSS coexistence information field");
     276           1 :                 is_ht40_allowed = 0;
     277             :         }
     278             : 
     279          14 :         if (start + len - data >= 3 &&
     280          12 :             data[0] == WLAN_EID_20_40_BSS_INTOLERANT && data[1] >= 1) {
     281           6 :                 u8 ielen = data[1];
     282             : 
     283           6 :                 if (ielen > start + len - data - 2)
     284           1 :                         return;
     285           5 :                 ic_report = (struct ieee80211_2040_intol_chan_report *) data;
     286           5 :                 wpa_printf(MSG_DEBUG,
     287             :                            "20/40 BSS Intolerant Channel Report: Operating Class %u",
     288           5 :                            ic_report->op_class);
     289             : 
     290             :                 /* Go through the channel report to find any BSS there in the
     291             :                  * affected channel range */
     292           9 :                 for (i = 0; i < ielen - 1; i++) {
     293           4 :                         u8 chan = ic_report->variable[i];
     294             : 
     295           4 :                         if (is_40_allowed(iface, chan))
     296           1 :                                 continue;
     297           3 :                         hostapd_logger(hapd, mgmt->sa,
     298             :                                        HOSTAPD_MODULE_IEEE80211,
     299             :                                        HOSTAPD_LEVEL_DEBUG,
     300             :                                        "20_40_INTOLERANT channel %d reported",
     301             :                                        chan);
     302           3 :                         is_ht40_allowed = 0;
     303             :                 }
     304             :         }
     305           7 :         wpa_printf(MSG_DEBUG, "is_ht40_allowed=%d num_sta_ht40_intolerant=%d",
     306             :                    is_ht40_allowed, iface->num_sta_ht40_intolerant);
     307             : 
     308          10 :         if (!is_ht40_allowed &&
     309           3 :             (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX)) {
     310           3 :                 if (iface->conf->secondary_channel) {
     311           3 :                         hostapd_logger(hapd, mgmt->sa,
     312             :                                        HOSTAPD_MODULE_IEEE80211,
     313             :                                        HOSTAPD_LEVEL_INFO,
     314             :                                        "Switching to 20 MHz operation");
     315           3 :                         iface->conf->secondary_channel = 0;
     316           3 :                         ieee802_11_set_beacons(iface);
     317             :                 }
     318           6 :                 if (!iface->num_sta_ht40_intolerant &&
     319           3 :                     iface->conf->obss_interval) {
     320             :                         unsigned int delay_time;
     321           2 :                         delay_time = OVERLAPPING_BSS_TRANS_DELAY_FACTOR *
     322           2 :                                 iface->conf->obss_interval;
     323           2 :                         eloop_cancel_timeout(ap_ht2040_timeout, hapd->iface,
     324             :                                              NULL);
     325           2 :                         eloop_register_timeout(delay_time, 0, ap_ht2040_timeout,
     326           2 :                                                hapd->iface, NULL);
     327           2 :                         wpa_printf(MSG_DEBUG,
     328             :                                    "Reschedule HT 20/40 timeout to occur in %u seconds",
     329             :                                    delay_time);
     330             :                 }
     331             :         }
     332             : }
     333             : 
     334             : 
     335        4960 : u16 copy_sta_ht_capab(struct hostapd_data *hapd, struct sta_info *sta,
     336             :                       const u8 *ht_capab)
     337             : {
     338             :         /*
     339             :          * Disable HT caps for STAs associated to no-HT BSSes, or for stations
     340             :          * that did not specify a valid WMM IE in the (Re)Association Request
     341             :          * frame.
     342             :          */
     343        9833 :         if (!ht_capab ||
     344        9746 :             !(sta->flags & WLAN_STA_WMM) || hapd->conf->disable_11n) {
     345          87 :                 sta->flags &= ~WLAN_STA_HT;
     346          87 :                 os_free(sta->ht_capabilities);
     347          87 :                 sta->ht_capabilities = NULL;
     348          87 :                 return WLAN_STATUS_SUCCESS;
     349             :         }
     350             : 
     351        4873 :         if (sta->ht_capabilities == NULL) {
     352        4414 :                 sta->ht_capabilities =
     353        4414 :                         os_zalloc(sizeof(struct ieee80211_ht_capabilities));
     354        4414 :                 if (sta->ht_capabilities == NULL)
     355           0 :                         return WLAN_STATUS_UNSPECIFIED_FAILURE;
     356             :         }
     357             : 
     358        4873 :         sta->flags |= WLAN_STA_HT;
     359        4873 :         os_memcpy(sta->ht_capabilities, ht_capab,
     360             :                   sizeof(struct ieee80211_ht_capabilities));
     361             : 
     362        4873 :         return WLAN_STATUS_SUCCESS;
     363             : }
     364             : 
     365             : 
     366           1 : void ht40_intolerant_add(struct hostapd_iface *iface, struct sta_info *sta)
     367             : {
     368           1 :         if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
     369           0 :                 return;
     370             : 
     371           6 :         wpa_printf(MSG_INFO, "HT: Forty MHz Intolerant is set by STA " MACSTR
     372           6 :                    " in Association Request", MAC2STR(sta->addr));
     373             : 
     374           1 :         if (sta->ht40_intolerant_set)
     375           0 :                 return;
     376             : 
     377           1 :         sta->ht40_intolerant_set = 1;
     378           1 :         iface->num_sta_ht40_intolerant++;
     379           1 :         eloop_cancel_timeout(ap_ht2040_timeout, iface, NULL);
     380             : 
     381           2 :         if (iface->conf->secondary_channel &&
     382           1 :             (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX)) {
     383           1 :                 iface->conf->secondary_channel = 0;
     384           1 :                 ieee802_11_set_beacons(iface);
     385             :         }
     386             : }
     387             : 
     388             : 
     389        4517 : void ht40_intolerant_remove(struct hostapd_iface *iface, struct sta_info *sta)
     390             : {
     391        4517 :         if (!sta->ht40_intolerant_set)
     392        9033 :                 return;
     393             : 
     394           1 :         sta->ht40_intolerant_set = 0;
     395           1 :         iface->num_sta_ht40_intolerant--;
     396             : 
     397           2 :         if (iface->num_sta_ht40_intolerant == 0 &&
     398           2 :             (iface->conf->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
     399           1 :             (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX)) {
     400           1 :                 unsigned int delay_time = OVERLAPPING_BSS_TRANS_DELAY_FACTOR *
     401           1 :                         iface->conf->obss_interval;
     402           1 :                 wpa_printf(MSG_DEBUG,
     403             :                            "HT: Start 20->40 MHz transition timer (%d seconds)",
     404             :                            delay_time);
     405           1 :                 eloop_cancel_timeout(ap_ht2040_timeout, iface, NULL);
     406           1 :                 eloop_register_timeout(delay_time, 0, ap_ht2040_timeout,
     407             :                                        iface, NULL);
     408             :         }
     409             : }
     410             : 
     411             : 
     412        4856 : static void update_sta_ht(struct hostapd_data *hapd, struct sta_info *sta)
     413             : {
     414             :         u16 ht_capab;
     415             : 
     416        4856 :         ht_capab = le_to_host16(sta->ht_capabilities->ht_capabilities_info);
     417       33992 :         wpa_printf(MSG_DEBUG, "HT: STA " MACSTR " HT Capabilities Info: "
     418       29136 :                    "0x%04x", MAC2STR(sta->addr), ht_capab);
     419        4856 :         if ((ht_capab & HT_CAP_INFO_GREEN_FIELD) == 0) {
     420           0 :                 if (!sta->no_ht_gf_set) {
     421           0 :                         sta->no_ht_gf_set = 1;
     422           0 :                         hapd->iface->num_sta_ht_no_gf++;
     423             :                 }
     424           0 :                 wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - no greenfield, num "
     425             :                            "of non-gf stations %d",
     426           0 :                            __func__, MAC2STR(sta->addr),
     427           0 :                            hapd->iface->num_sta_ht_no_gf);
     428             :         }
     429        4856 :         if ((ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) == 0) {
     430        4647 :                 if (!sta->ht_20mhz_set) {
     431        4208 :                         sta->ht_20mhz_set = 1;
     432        4208 :                         hapd->iface->num_sta_ht_20mhz++;
     433             :                 }
     434       32529 :                 wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - 20 MHz HT, num of "
     435             :                            "20MHz HT STAs %d",
     436       27882 :                            __func__, MAC2STR(sta->addr),
     437        4647 :                            hapd->iface->num_sta_ht_20mhz);
     438             :         }
     439             : 
     440        4856 :         if (ht_capab & HT_CAP_INFO_40MHZ_INTOLERANT)
     441           1 :                 ht40_intolerant_add(hapd->iface, sta);
     442        4856 : }
     443             : 
     444             : 
     445          57 : static void update_sta_no_ht(struct hostapd_data *hapd, struct sta_info *sta)
     446             : {
     447          57 :         if (!sta->no_ht_set) {
     448          56 :                 sta->no_ht_set = 1;
     449          56 :                 hapd->iface->num_sta_no_ht++;
     450             :         }
     451          57 :         if (hapd->iconf->ieee80211n) {
     452         322 :                 wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - no HT, num of "
     453             :                            "non-HT stations %d",
     454         276 :                            __func__, MAC2STR(sta->addr),
     455          46 :                            hapd->iface->num_sta_no_ht);
     456             :         }
     457          57 : }
     458             : 
     459             : 
     460        4913 : void update_ht_state(struct hostapd_data *hapd, struct sta_info *sta)
     461             : {
     462        4913 :         if ((sta->flags & WLAN_STA_HT) && sta->ht_capabilities)
     463        4856 :                 update_sta_ht(hapd, sta);
     464             :         else
     465          57 :                 update_sta_no_ht(hapd, sta);
     466             : 
     467        4913 :         if (hostapd_ht_operation_update(hapd->iface) > 0)
     468          39 :                 ieee802_11_set_beacons(hapd->iface);
     469        4913 : }
     470             : 
     471             : 
     472        4699 : void hostapd_get_ht_capab(struct hostapd_data *hapd,
     473             :                           struct ieee80211_ht_capabilities *ht_cap,
     474             :                           struct ieee80211_ht_capabilities *neg_ht_cap)
     475             : {
     476             :         u16 cap;
     477             : 
     478        4699 :         if (ht_cap == NULL)
     479        4699 :                 return;
     480        4699 :         os_memcpy(neg_ht_cap, ht_cap, sizeof(*neg_ht_cap));
     481        4699 :         cap = le_to_host16(neg_ht_cap->ht_capabilities_info);
     482             : 
     483             :         /*
     484             :          * Mask out HT features we don't support, but don't overwrite
     485             :          * non-symmetric features like STBC and SMPS. Just because
     486             :          * we're not in dynamic SMPS mode the STA might still be.
     487             :          */
     488        4699 :         cap &= (hapd->iconf->ht_capab | HT_CAP_INFO_RX_STBC_MASK |
     489             :                 HT_CAP_INFO_TX_STBC | HT_CAP_INFO_SMPS_MASK);
     490             : 
     491             :         /*
     492             :          * STBC needs to be handled specially
     493             :          * if we don't support RX STBC, mask out TX STBC in the STA's HT caps
     494             :          * if we don't support TX STBC, mask out RX STBC in the STA's HT caps
     495             :          */
     496        4699 :         if (!(hapd->iconf->ht_capab & HT_CAP_INFO_RX_STBC_MASK))
     497        4699 :                 cap &= ~HT_CAP_INFO_TX_STBC;
     498        4699 :         if (!(hapd->iconf->ht_capab & HT_CAP_INFO_TX_STBC))
     499        4699 :                 cap &= ~HT_CAP_INFO_RX_STBC_MASK;
     500             : 
     501        4699 :         neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
     502             : }
     503             : 
     504             : 
     505           3 : void ap_ht2040_timeout(void *eloop_data, void *user_data)
     506             : {
     507           3 :         struct hostapd_iface *iface = eloop_data;
     508             : 
     509           3 :         wpa_printf(MSG_INFO, "Switching to 40 MHz operation");
     510             : 
     511           3 :         iface->conf->secondary_channel = iface->secondary_ch;
     512           3 :         ieee802_11_set_beacons(iface);
     513           3 : }

Generated by: LCOV version 1.10