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

Generated by: LCOV version 1.10