18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/* 28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * hostapd / IEEE 802.11 Management: Beacon and Probe Request/Response 38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2002-2004, Instant802 Networks, Inc. 48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2005-2006, Devicescape Software, Inc. 5a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt * Copyright (c) 2008-2012, Jouni Malinen <j@w1.fi> 68d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * 7fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt * This software may be distributed under the terms of the BSD license. 8fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt * See README for more details. 98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */ 108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "utils/includes.h" 128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef CONFIG_NATIVE_WINDOWS 148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "utils/common.h" 168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "common/ieee802_11_defs.h" 178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "common/ieee802_11_common.h" 187f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt#include "common/hw_features_common.h" 198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "wps/wps_defs.h" 208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "p2p/p2p.h" 218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "hostapd.h" 228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "ieee802_11.h" 238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "wpa_auth.h" 248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "wmm.h" 258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "ap_config.h" 268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "sta_info.h" 278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "p2p_hostapd.h" 288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "ap_drv_ops.h" 298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "beacon.h" 3061d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt#include "hs20.h" 31f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt#include "dfs.h" 328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 341f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef NEED_AP_MLME 351f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 366c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidtstatic u8 * hostapd_eid_rm_enabled_capab(struct hostapd_data *hapd, u8 *eid, 376c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt size_t len) 386c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt{ 396c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt if (!hapd->conf->radio_measurements || len < 2 + 4) 406c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt return eid; 416c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt 426c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = WLAN_EID_RRM_ENABLED_CAPABILITIES; 436c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = 5; 446c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = (hapd->conf->radio_measurements & BIT(0)) ? 456c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt WLAN_RRM_CAPS_NEIGHBOR_REPORT : 0x00; 466c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = 0x00; 476c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = 0x00; 486c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = 0x00; 496c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = 0x00; 506c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt return eid; 516c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt} 526c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt 536c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt 54051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidtstatic u8 * hostapd_eid_bss_load(struct hostapd_data *hapd, u8 *eid, size_t len) 55051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt{ 566c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt if (len < 2 + 5) 576c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt return eid; 586c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt 59051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt#ifdef CONFIG_TESTING_OPTIONS 60051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt if (hapd->conf->bss_load_test_set) { 61051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt *eid++ = WLAN_EID_BSS_LOAD; 62051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt *eid++ = 5; 63051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt os_memcpy(eid, hapd->conf->bss_load_test, 5); 64051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt eid += 5; 656c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt return eid; 66051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt } 67051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt#endif /* CONFIG_TESTING_OPTIONS */ 686c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt if (hapd->conf->bss_load_update_period) { 696c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = WLAN_EID_BSS_LOAD; 706c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = 5; 716c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt WPA_PUT_LE16(eid, hapd->num_sta); 726c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt eid += 2; 736c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt *eid++ = hapd->iface->channel_utilization; 746c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt WPA_PUT_LE16(eid, 0); /* no available admission capabity */ 756c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt eid += 2; 766c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt } 77051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt return eid; 78051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt} 79051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt 80051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt 818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic u8 ieee802_11_erp_info(struct hostapd_data *hapd) 828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 erp = 0; 848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->iface->current_mode == NULL || 868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G) 878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return 0; 888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 891f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->iface->olbc) 901f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt erp |= ERP_INFO_USE_PROTECTION; 911f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->iface->num_sta_non_erp > 0) { 921f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt erp |= ERP_INFO_NON_ERP_PRESENT | 931f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt ERP_INFO_USE_PROTECTION; 948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->iface->num_sta_no_short_preamble > 0 || 968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt hapd->iconf->preamble == LONG_PREAMBLE) 978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt erp |= ERP_INFO_BARKER_PREAMBLE_MODE; 988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return erp; 1008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 1018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic u8 * hostapd_eid_ds_params(struct hostapd_data *hapd, u8 *eid) 1048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 1058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *eid++ = WLAN_EID_DS_PARAMS; 1068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *eid++ = 1; 1078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *eid++ = hapd->iconf->channel; 1088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return eid; 1098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 1108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic u8 * hostapd_eid_erp_info(struct hostapd_data *hapd, u8 *eid) 1138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 1148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->iface->current_mode == NULL || 1158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G) 1168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return eid; 1178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* Set NonERP_present and use_protection bits if there 1198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * are any associated NonERP stations. */ 1208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* TODO: use_protection bit can be set to zero even if 1218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * there are NonERP stations present. This optimization 1228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * might be useful if NonERP stations are "quiet". 1238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * See 802.11g/D6 E-1 for recommended practice. 1248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * In addition, Non ERP present might be set, if AP detects Non ERP 1258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * operation on other APs. */ 1268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* Add ERP Information element */ 1288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *eid++ = WLAN_EID_ERP_INFO; 1298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *eid++ = 1; 1308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *eid++ = ieee802_11_erp_info(hapd); 1318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return eid; 1338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 1348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 136f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidtstatic u8 * hostapd_eid_pwr_constraint(struct hostapd_data *hapd, u8 *eid) 137f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt{ 138f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt u8 *pos = eid; 139f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt u8 local_pwr_constraint = 0; 140f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt int dfs; 141f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 142f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt if (hapd->iface->current_mode == NULL || 143f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A) 144f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt return eid; 145f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 146661b4f78e48c697429dc46154a4125892c001718Dmitry Shmidt /* Let host drivers add this IE if DFS support is offloaded */ 147661b4f78e48c697429dc46154a4125892c001718Dmitry Shmidt if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) 148661b4f78e48c697429dc46154a4125892c001718Dmitry Shmidt return eid; 149661b4f78e48c697429dc46154a4125892c001718Dmitry Shmidt 150f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* 151f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * There is no DFS support and power constraint was not directly 152f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * requested by config option. 153f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt */ 154f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt if (!hapd->iconf->ieee80211h && 155f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt hapd->iconf->local_pwr_constraint == -1) 156f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt return eid; 157f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 158f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* Check if DFS is required by regulatory. */ 159f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt dfs = hostapd_is_dfs_required(hapd->iface); 160f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt if (dfs < 0) { 161f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt wpa_printf(MSG_WARNING, "Failed to check if DFS is required; ret=%d", 162f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt dfs); 163f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt dfs = 0; 164f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt } 165f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 166f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt if (dfs == 0 && hapd->iconf->local_pwr_constraint == -1) 167f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt return eid; 168f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 169f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* 170f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * ieee80211h (DFS) is enabled so Power Constraint element shall 171f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * be added when running on DFS channel whenever local_pwr_constraint 172f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * is configured or not. In order to meet regulations when TPC is not 173f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * implemented using a transmit power that is below the legal maximum 174f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * (including any mitigation factor) should help. In this case, 175f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * indicate 3 dB below maximum allowed transmit power. 176f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt */ 177f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt if (hapd->iconf->local_pwr_constraint == -1) 178f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt local_pwr_constraint = 3; 179f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 180f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* 181f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * A STA that is not an AP shall use a transmit power less than or 182f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * equal to the local maximum transmit power level for the channel. 183f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * The local maximum transmit power can be calculated from the formula: 184f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * local max TX pwr = max TX pwr - local pwr constraint 185f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * Where max TX pwr is maximum transmit power level specified for 186f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * channel in Country element and local pwr constraint is specified 187f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt * for channel in this Power Constraint element. 188f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt */ 189f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 190f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* Element ID */ 191f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt *pos++ = WLAN_EID_PWR_CONSTRAINT; 192f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* Length */ 193f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt *pos++ = 1; 194f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* Local Power Constraint */ 195f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt if (local_pwr_constraint) 196f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt *pos++ = local_pwr_constraint; 197f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt else 198f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt *pos++ = hapd->iconf->local_pwr_constraint; 199f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 200f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt return pos; 201f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt} 202f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 203f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 2048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic u8 * hostapd_eid_country_add(u8 *pos, u8 *end, int chan_spacing, 2058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct hostapd_channel_data *start, 2068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct hostapd_channel_data *prev) 2078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 2088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (end - pos < 3) 2098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return pos; 2108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* first channel number */ 2128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = start->chan; 2138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* number of channels */ 2148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = (prev->chan - start->chan) / chan_spacing + 1; 2158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* maximum transmit power level */ 2168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = start->max_tx_power; 2178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return pos; 2198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 2208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid, 2238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt int max_len) 2248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 2258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *pos = eid; 2268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *end = eid + max_len; 2278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt int i; 2288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct hostapd_hw_modes *mode; 2298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct hostapd_channel_data *start, *prev; 2308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt int chan_spacing = 1; 2318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (!hapd->iconf->ieee80211d || max_len < 6 || 2338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt hapd->iface->current_mode == NULL) 2348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return eid; 2358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = WLAN_EID_COUNTRY; 2378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos++; /* length will be set later */ 2388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */ 2398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos += 3; 2408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt mode = hapd->iface->current_mode; 2428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (mode->mode == HOSTAPD_MODE_IEEE80211A) 2438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt chan_spacing = 4; 2448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt start = prev = NULL; 2468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt for (i = 0; i < mode->num_channels; i++) { 2478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct hostapd_channel_data *chan = &mode->channels[i]; 2488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (chan->flag & HOSTAPD_CHAN_DISABLED) 2498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt continue; 2508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (start && prev && 2518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt prev->chan + chan_spacing == chan->chan && 2528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt start->max_tx_power == chan->max_tx_power) { 2538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt prev = chan; 2548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt continue; /* can use same entry */ 2558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 2568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 25709f57babfc1e4473db20ced4f58a4c9f082c8ed8Dmitry Shmidt if (start && prev) { 2588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos = hostapd_eid_country_add(pos, end, chan_spacing, 2598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt start, prev); 2608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt start = NULL; 2618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 2628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* Start new group */ 2648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt start = prev = chan; 2658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 2668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (start) { 2688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos = hostapd_eid_country_add(pos, end, chan_spacing, 2698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt start, prev); 2708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 2718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if ((pos - eid) & 1) { 2738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (end - pos < 1) 2748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return eid; 2758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = 0; /* pad for 16-bit alignment */ 2768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 2778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt eid[1] = (pos - eid) - 2; 2798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return pos; 2818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 2828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2841f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtstatic u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len) 2858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 2868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *ie; 2878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t ielen; 2888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ielen); 2908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (ie == NULL || ielen > len) 2918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return eid; 2928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcpy(eid, ie, ielen); 2948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return eid + ielen; 2958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 2968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 2978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 298e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidtstatic u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid) 299e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt{ 300d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#ifdef CONFIG_TESTING_OPTIONS 301d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->iface->cs_oper_class && hapd->iconf->ecsa_ie_only) 302e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt return eid; 303d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#endif /* CONFIG_TESTING_OPTIONS */ 304e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 305d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (!hapd->cs_freq_params.channel) 306e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt return eid; 307e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 308e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt *eid++ = WLAN_EID_CHANNEL_SWITCH; 309e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt *eid++ = 3; 310d30ac604c9f6da71a0dd7f46d25be05a2a62cfbbDmitry Shmidt *eid++ = hapd->cs_block_tx; 311d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = hapd->cs_freq_params.channel; 312d30ac604c9f6da71a0dd7f46d25be05a2a62cfbbDmitry Shmidt *eid++ = hapd->cs_count; 313e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 314e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt return eid; 315e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt} 316e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 317e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 318d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtstatic u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid) 319fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt{ 320d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (!hapd->cs_freq_params.channel || !hapd->iface->cs_oper_class) 321fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt return eid; 322fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 323d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = WLAN_EID_EXT_CHANSWITCH_ANN; 324d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = 4; 325d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = hapd->cs_block_tx; 326d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = hapd->iface->cs_oper_class; 327d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = hapd->cs_freq_params.channel; 328d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = hapd->cs_count; 329fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 330fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt return eid; 331fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt} 332fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 333fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 334d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtstatic u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid) 335fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt{ 336d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt u8 op_class, channel; 337fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 338d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA) || 339d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt !hapd->iface->freq) 340d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return eid; 341fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 342d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (ieee80211_freq_to_channel_ext(hapd->iface->freq, 343d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->iconf->secondary_channel, 344d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->iconf->vht_oper_chwidth, 345d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt &op_class, &channel) == 346d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt NUM_HOSTAPD_MODES) 347d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return eid; 348fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 349d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES; 350d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = 2; 351fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 352d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* Current Operating Class */ 353d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = op_class; 354d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 355d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* TODO: Advertise all the supported operating classes */ 356d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt *eid++ = 0; 357d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 358d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return eid; 359fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt} 360fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 361fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 3621f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtstatic u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd, 3631f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt const struct ieee80211_mgmt *req, 3641f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt int is_p2p, size_t *resp_len) 3651f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt{ 3661f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt struct ieee80211_mgmt *resp; 367d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt u8 *pos, *epos, *csa_pos; 3681f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt size_t buflen; 3691f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 3701f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#define MAX_PROBERESP_LEN 768 3711f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt buflen = MAX_PROBERESP_LEN; 3721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_WPS 3731f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->wps_probe_resp_ie) 3741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt buflen += wpabuf_len(hapd->wps_probe_resp_ie); 3751f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_WPS */ 3761f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_P2P 3771f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->p2p_probe_resp_ie) 3781f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt buflen += wpabuf_len(hapd->p2p_probe_resp_ie); 3791f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_P2P */ 380d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#ifdef CONFIG_FST 381d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->iface->fst_ies) 382d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt buflen += wpabuf_len(hapd->iface->fst_ies); 383d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#endif /* CONFIG_FST */ 38461d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt if (hapd->conf->vendor_elements) 38561d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt buflen += wpabuf_len(hapd->conf->vendor_elements); 3862f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt if (hapd->conf->vendor_vht) { 3872f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt buflen += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + 3882f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt 2 + sizeof(struct ieee80211_vht_operation); 3892f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt } 39057c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt 39157c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt buflen += hostapd_mbo_ie_len(hapd); 39257c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt 3931f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt resp = os_zalloc(buflen); 3941f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (resp == NULL) 3951f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt return NULL; 3961f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 3971f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt epos = ((u8 *) resp) + MAX_PROBERESP_LEN; 3981f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 3991f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, 4001f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt WLAN_FC_STYPE_PROBE_RESP); 4011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (req) 4021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_memcpy(resp->da, req->sa, ETH_ALEN); 4031f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN); 4041f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN); 4061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt resp->u.probe_resp.beacon_int = 4071f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt host_to_le16(hapd->iconf->beacon_int); 4081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4091f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* hardware or low-level driver will setup seq_ctrl and timestamp */ 4101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt resp->u.probe_resp.capab_info = 4119d9e60286e05ae45025b672636490bd12586138dDmitry Shmidt host_to_le16(hostapd_own_capab_info(hapd)); 4121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = resp->u.probe_resp.variable; 4141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt *pos++ = WLAN_EID_SSID; 4151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt *pos++ = hapd->conf->ssid.ssid_len; 4161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len); 4171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos += hapd->conf->ssid.ssid_len; 4181f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* Supported rates */ 4201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_supp_rates(hapd, pos); 4211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4221f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* DS Params */ 4231f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_ds_params(hapd, pos); 4241f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4251f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_country(hapd, pos, epos - pos); 4261f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 427f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* Power Constraint element */ 428f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt pos = hostapd_eid_pwr_constraint(hapd, pos); 429f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 430d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* CSA IE */ 431d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_pos = hostapd_eid_csa(hapd, pos); 432d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (csa_pos != pos) 433d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->cs_c_off_proberesp = csa_pos - (u8 *) resp - 1; 434d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt pos = csa_pos; 435d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 4361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* ERP Information element */ 4371f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_erp_info(hapd, pos); 4381f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4391f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* Extended supported rates */ 4401f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_ext_supp_rates(hapd, pos); 4411f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4421f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* RSN, MDIE, WPA */ 4431f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_wpa(hapd, pos, epos - pos); 4441f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 445051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt pos = hostapd_eid_bss_load(hapd, pos, epos - pos); 446051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt 4476c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt pos = hostapd_eid_rm_enabled_capab(hapd, pos, epos - pos); 4486c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt 449d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* eCSA IE */ 450d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_pos = hostapd_eid_ecsa(hapd, pos); 451d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (csa_pos != pos) 452d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *) resp - 1; 453d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt pos = csa_pos; 454d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 455d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt pos = hostapd_eid_supported_op_classes(hapd, pos); 456d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 4571f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_IEEE80211N 458d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* Secondary Channel Offset element */ 459d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* TODO: The standard doesn't specify a position for this element. */ 460d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt pos = hostapd_eid_secondary_channel(hapd, pos); 461d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 4621f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_ht_capabilities(hapd, pos); 4631f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_ht_operation(hapd, pos); 4641f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_IEEE80211N */ 4651f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4661f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_ext_capab(hapd, pos); 4671f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4681f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_time_adv(hapd, pos); 4691f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_time_zone(hapd, pos); 4701f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4711f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_interworking(hapd, pos); 4721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_adv_proto(hapd, pos); 4731f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_roaming_consortium(hapd, pos); 4741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 475d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#ifdef CONFIG_FST 476d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->iface->fst_ies) { 477d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_memcpy(pos, wpabuf_head(hapd->iface->fst_ies), 478d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpabuf_len(hapd->iface->fst_ies)); 479d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt pos += wpabuf_len(hapd->iface->fst_ies); 480d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 481d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#endif /* CONFIG_FST */ 482d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 48304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_IEEE80211AC 4842f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) { 4852f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt pos = hostapd_eid_vht_capabilities(hapd, pos); 4862f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt pos = hostapd_eid_vht_operation(hapd, pos); 487d7ff03d48f825360eec2a371e3361306f2fd721bDmitry Shmidt pos = hostapd_eid_txpower_envelope(hapd, pos); 488d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt pos = hostapd_eid_wb_chsw_wrapper(hapd, pos); 4892f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt } 4902f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt if (hapd->conf->vendor_vht) 4912f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt pos = hostapd_eid_vendor_vht(hapd, pos); 49204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_IEEE80211AC */ 49304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt 4941f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* Wi-Fi Alliance WMM */ 4951f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_wmm(hapd, pos); 4961f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 4971f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_WPS 4981f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) { 4991f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie), 5001f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpabuf_len(hapd->wps_probe_resp_ie)); 5011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos += wpabuf_len(hapd->wps_probe_resp_ie); 5021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt } 5031f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_WPS */ 5041f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 5051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_P2P 5061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if ((hapd->conf->p2p & P2P_ENABLED) && is_p2p && 5071f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hapd->p2p_probe_resp_ie) { 5081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie), 5091f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpabuf_len(hapd->p2p_probe_resp_ie)); 5101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos += wpabuf_len(hapd->p2p_probe_resp_ie); 5111f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt } 5121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_P2P */ 5131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_P2P_MANAGER 5141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == 5151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt P2P_MANAGE) 5161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt pos = hostapd_eid_p2p_manage(hapd, pos); 5171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_P2P_MANAGER */ 5181f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 51961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt#ifdef CONFIG_HS20 52061d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt pos = hostapd_eid_hs20_indication(hapd, pos); 521f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt pos = hostapd_eid_osen(hapd, pos); 52261d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt#endif /* CONFIG_HS20 */ 52361d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt 52457c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt pos = hostapd_eid_mbo(hapd, pos, (u8 *) resp + buflen - pos); 52557c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt 52661d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt if (hapd->conf->vendor_elements) { 52761d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt os_memcpy(pos, wpabuf_head(hapd->conf->vendor_elements), 52861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt wpabuf_len(hapd->conf->vendor_elements)); 52961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt pos += wpabuf_len(hapd->conf->vendor_elements); 53061d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt } 53161d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt 5321f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt *resp_len = pos - (u8 *) resp; 5331f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt return (u8 *) resp; 5341f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt} 5351f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 5361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 537a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidtenum ssid_match_result { 538a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt NO_SSID_MATCH, 539a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt EXACT_SSID_MATCH, 540a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt WILDCARD_SSID_MATCH 541a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt}; 542a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt 543a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidtstatic enum ssid_match_result ssid_match(struct hostapd_data *hapd, 544a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt const u8 *ssid, size_t ssid_len, 545a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt const u8 *ssid_list, 546a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt size_t ssid_list_len) 547a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt{ 548a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt const u8 *pos, *end; 549a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt int wildcard = 0; 550a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt 551a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt if (ssid_len == 0) 552a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt wildcard = 1; 553a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt if (ssid_len == hapd->conf->ssid.ssid_len && 554a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0) 555a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt return EXACT_SSID_MATCH; 556a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt 557a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt if (ssid_list == NULL) 558a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH; 559a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt 560a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt pos = ssid_list; 561a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt end = ssid_list + ssid_list_len; 562d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt while (end - pos >= 1) { 563d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (2 + pos[1] > end - pos) 564a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt break; 565a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt if (pos[1] == 0) 566a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt wildcard = 1; 567a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt if (pos[1] == hapd->conf->ssid.ssid_len && 568a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt os_memcmp(pos + 2, hapd->conf->ssid.ssid, pos[1]) == 0) 569a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt return EXACT_SSID_MATCH; 570a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt pos += 2 + pos[1]; 571a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt } 572a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt 573a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH; 574a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt} 575a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt 576a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt 577d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtvoid sta_track_expire(struct hostapd_iface *iface, int force) 578d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 579d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct os_reltime now; 580d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct hostapd_sta_info *info; 581d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 582d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (!iface->num_sta_seen) 583d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return; 584d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 585d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_get_reltime(&now); 586d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info, 587d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt list))) { 588d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (!force && 589d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt !os_reltime_expired(&now, &info->last_seen, 590d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt iface->conf->track_sta_max_age)) 591d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt break; 592d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt force = 0; 593d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 594d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "%s: Expire STA tracking entry for " 595d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt MACSTR, iface->bss[0]->conf->iface, 596d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt MAC2STR(info->addr)); 597d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt dl_list_del(&info->list); 598d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt iface->num_sta_seen--; 599d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_free(info); 600d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 601d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 602d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 603d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 604d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtstatic struct hostapd_sta_info * sta_track_get(struct hostapd_iface *iface, 605d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt const u8 *addr) 606d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 607d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct hostapd_sta_info *info; 608d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 609d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt dl_list_for_each(info, &iface->sta_seen, struct hostapd_sta_info, list) 610d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (os_memcmp(addr, info->addr, ETH_ALEN) == 0) 611d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return info; 612d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 613d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return NULL; 614d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 615d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 616d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 617d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtvoid sta_track_add(struct hostapd_iface *iface, const u8 *addr) 618d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 619d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct hostapd_sta_info *info; 620d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 621d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt info = sta_track_get(iface, addr); 622d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (info) { 623d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* Move the most recent entry to the end of the list */ 624d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt dl_list_del(&info->list); 625d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt dl_list_add_tail(&iface->sta_seen, &info->list); 626d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_get_reltime(&info->last_seen); 627d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return; 628d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 629d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 630d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* Add a new entry */ 631d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt info = os_zalloc(sizeof(*info)); 632d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_memcpy(info->addr, addr, ETH_ALEN); 633d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_get_reltime(&info->last_seen); 634d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 635d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (iface->num_sta_seen >= iface->conf->track_sta_max_num) { 636d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* Expire oldest entry to make room for a new one */ 637d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt sta_track_expire(iface, 1); 638d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 639d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 640d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "%s: Add STA tracking entry for " 641d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt MACSTR, iface->bss[0]->conf->iface, MAC2STR(addr)); 642d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt dl_list_add_tail(&iface->sta_seen, &info->list); 643d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt iface->num_sta_seen++; 644d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 645d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 646d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 647d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtstruct hostapd_data * 648d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtsta_track_seen_on(struct hostapd_iface *iface, const u8 *addr, 649d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt const char *ifname) 650d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 651d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct hapd_interfaces *interfaces = iface->interfaces; 652d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt size_t i, j; 653d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 654d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt for (i = 0; i < interfaces->count; i++) { 655d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct hostapd_data *hapd = NULL; 656d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 657d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt iface = interfaces->iface[i]; 658d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt for (j = 0; j < iface->num_bss; j++) { 659d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd = iface->bss[j]; 660d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (os_strcmp(ifname, hapd->conf->iface) == 0) 661d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt break; 662d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd = NULL; 663d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 664d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 665d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd && sta_track_get(iface, addr)) 666d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return hapd; 667d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 668d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 669d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return NULL; 670d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 671d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 672d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 6738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid handle_probe_req(struct hostapd_data *hapd, 67404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt const struct ieee80211_mgmt *mgmt, size_t len, 67504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt int ssi_signal) 6768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 6771f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt u8 *resp; 6788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct ieee802_11_elems elems; 6798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *ie; 6801f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt size_t ie_len; 6811f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt size_t i, resp_len; 6821f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt int noack; 683a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt enum ssid_match_result res; 684d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt int ret; 685d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt u16 csa_offs[2]; 686d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt size_t csa_offs_len; 6878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 688e4663044d3a689fb5458247e9bc0f8b58cf72fcaDmitry Shmidt if (len < IEEE80211_HDRLEN) 6898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 690e4663044d3a689fb5458247e9bc0f8b58cf72fcaDmitry Shmidt ie = ((const u8 *) mgmt) + IEEE80211_HDRLEN; 691d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->iconf->track_sta_max_num) 692d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt sta_track_add(hapd->iface, mgmt->sa); 693e4663044d3a689fb5458247e9bc0f8b58cf72fcaDmitry Shmidt ie_len = len - IEEE80211_HDRLEN; 6948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 6958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) 6968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, 6971f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt mgmt->sa, mgmt->da, mgmt->bssid, 69804949598a23f501be6eec21697465fd46a28840aDmitry Shmidt ie, ie_len, ssi_signal) > 0) 6998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 7001f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 7018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (!hapd->iconf->send_probe_response) 7028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 7038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 7048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) { 7058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR, 7068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt MAC2STR(mgmt->sa)); 7078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 7088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 7098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 7108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if ((!elems.ssid || !elems.supp_rates)) { 7118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request " 7128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt "without SSID or supported rates element", 7138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt MAC2STR(mgmt->sa)); 7148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 7158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 7168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 7177f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt /* 7187f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * No need to reply if the Probe Request frame was sent on an adjacent 7197f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * channel. IEEE Std 802.11-2012 describes this as a requirement for an 7207f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * AP with dot11RadioMeasurementActivated set to true, but strictly 7217f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * speaking does not allow such ignoring of Probe Request frames if 7227f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * dot11RadioMeasurementActivated is false. Anyway, this can help reduce 7237f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * number of unnecessary Probe Response frames for cases where the STA 7247f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * is less likely to see them (Probe Request frame sent on a 7257f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt * neighboring, but partially overlapping, channel). 7267f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt */ 7279d9e60286e05ae45025b672636490bd12586138dDmitry Shmidt if (elems.ds_params && 7287f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt hapd->iface->current_mode && 7297f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G || 7307f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B) && 7317f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt hapd->iconf->channel != elems.ds_params[0]) { 7327f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt wpa_printf(MSG_DEBUG, 7337f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u", 7347f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt hapd->iconf->channel, elems.ds_params[0]); 7357f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt return; 7367f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt } 7377f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt 7388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P 739de47be75037bccd4a11b62eedb3d4aed1b36fa67Dmitry Shmidt if (hapd->p2p && hapd->p2p_group && elems.wps_ie) { 7408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt struct wpabuf *wps; 7418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA); 7428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) { 7438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " 7448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt "due to mismatch with Requested Device " 7458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt "Type"); 7468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpabuf_free(wps); 7478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 7488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 7498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpabuf_free(wps); 7508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 751c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt 752de47be75037bccd4a11b62eedb3d4aed1b36fa67Dmitry Shmidt if (hapd->p2p && hapd->p2p_group && elems.p2p) { 753c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt struct wpabuf *p2p; 754c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt p2p = ieee802_11_vendor_ie_concat(ie, ie_len, P2P_IE_VENDOR_TYPE); 755c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) { 756c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " 757c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt "due to mismatch with Device ID"); 758c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt wpabuf_free(p2p); 759c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt return; 760c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt } 761c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt wpabuf_free(p2p); 762c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt } 7638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_P2P */ 7648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 765a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0 && 766a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt elems.ssid_list_len == 0) { 7678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for " 7688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt "broadcast SSID ignored", MAC2STR(mgmt->sa)); 7698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 7708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 7718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 7728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P 7738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if ((hapd->conf->p2p & P2P_GROUP_OWNER) && 7748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt elems.ssid_len == P2P_WILDCARD_SSID_LEN && 7758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcmp(elems.ssid, P2P_WILDCARD_SSID, 7768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt P2P_WILDCARD_SSID_LEN) == 0) { 7778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* Process P2P Wildcard SSID like Wildcard SSID */ 7788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt elems.ssid_len = 0; 7798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 7808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_P2P */ 7818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 782a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt res = ssid_match(hapd, elems.ssid, elems.ssid_len, 783a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt elems.ssid_list, elems.ssid_list_len); 7849d9e60286e05ae45025b672636490bd12586138dDmitry Shmidt if (res == NO_SSID_MATCH) { 7858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (!(mgmt->da[0] & 0x01)) { 7868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR 787a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt " for foreign SSID '%s' (DA " MACSTR ")%s", 7883c4793790bf06f1fe08a2ddf604c9caa855151f1Dmitry Shmidt MAC2STR(mgmt->sa), 7893c4793790bf06f1fe08a2ddf604c9caa855151f1Dmitry Shmidt wpa_ssid_txt(elems.ssid, elems.ssid_len), 790a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt MAC2STR(mgmt->da), 791a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt elems.ssid_list ? " (SSID list)" : ""); 7928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 7938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 7948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 7958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 7961f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef CONFIG_INTERWORKING 797f9bdef99ce3b2858f2812c745a3d6bb093fb0e5dDmitry Shmidt if (hapd->conf->interworking && 798f9bdef99ce3b2858f2812c745a3d6bb093fb0e5dDmitry Shmidt elems.interworking && elems.interworking_len >= 1) { 7991f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt u8 ant = elems.interworking[0] & 0x0f; 8001f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (ant != INTERWORKING_ANT_WILDCARD && 8011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt ant != hapd->conf->access_network_type) { 8021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR 8031f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt " for mismatching ANT %u ignored", 8041f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt MAC2STR(mgmt->sa), ant); 8051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt return; 8061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt } 8071f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt } 8081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 809f9bdef99ce3b2858f2812c745a3d6bb093fb0e5dDmitry Shmidt if (hapd->conf->interworking && elems.interworking && 8101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt (elems.interworking_len == 7 || elems.interworking_len == 9)) { 8111f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt const u8 *hessid; 8121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (elems.interworking_len == 7) 8131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hessid = elems.interworking + 1; 8141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt else 8151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hessid = elems.interworking + 1 + 2; 8161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (!is_broadcast_ether_addr(hessid) && 8171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) { 8181f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR 8191f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt " for mismatching HESSID " MACSTR 8201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt " ignored", 8211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt MAC2STR(mgmt->sa), MAC2STR(hessid)); 8221f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt return; 8231f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt } 8241f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt } 8251f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_INTERWORKING */ 8261f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 82734af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt#ifdef CONFIG_P2P 82834af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt if ((hapd->conf->p2p & P2P_GROUP_OWNER) && 82934af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt supp_rates_11b_only(&elems)) { 83034af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt /* Indicates support for 11b rates only */ 83134af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt wpa_printf(MSG_EXCESSIVE, "P2P: Ignore Probe Request from " 83234af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt MACSTR " with only 802.11b rates", 83334af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt MAC2STR(mgmt->sa)); 83434af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt return; 83534af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt } 83634af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt#endif /* CONFIG_P2P */ 83734af306c42b7ccf956508e7cd23f0ba90606e360Dmitry Shmidt 8388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* TODO: verify that supp_rates contains at least one matching rate 8398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * with AP configuration */ 8401f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 841d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->conf->no_probe_resp_if_seen_on && 842d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt is_multicast_ether_addr(mgmt->da) && 843d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt is_multicast_ether_addr(mgmt->bssid) && 844d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt sta_track_seen_on(hapd->iface, mgmt->sa, 845d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->conf->no_probe_resp_if_seen_on)) { 846d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR 847d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt " since STA has been seen on %s", 848d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->conf->iface, MAC2STR(mgmt->sa), 849d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->conf->no_probe_resp_if_seen_on); 850d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return; 851d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 852d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 853d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->conf->no_probe_resp_if_max_sta && 854d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt is_multicast_ether_addr(mgmt->da) && 855d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt is_multicast_ether_addr(mgmt->bssid) && 856d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->num_sta >= hapd->conf->max_num_sta && 857d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt !ap_get_sta(hapd, mgmt->sa)) { 858d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR 859d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt " since no room for additional STA", 860d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->conf->iface, MAC2STR(mgmt->sa)); 861d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return; 862d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 863d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 8648da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt#ifdef CONFIG_TESTING_OPTIONS 8657832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt if (hapd->iconf->ignore_probe_probability > 0.0 && 8668da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt drand48() < hapd->iconf->ignore_probe_probability) { 8678da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt wpa_printf(MSG_INFO, 8688da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt "TESTING: ignoring probe request from " MACSTR, 8698da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt MAC2STR(mgmt->sa)); 8708da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt return; 8718da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt } 8728da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt#endif /* CONFIG_TESTING_OPTIONS */ 8738da800a193fb6f8832218715f82a7b4e2d2ad338Dmitry Shmidt 8749d9e60286e05ae45025b672636490bd12586138dDmitry Shmidt resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL, 8751f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt &resp_len); 8768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (resp == NULL) 8778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt return; 8788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 8791f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* 8801f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * If this is a broadcast probe request, apply no ack policy to avoid 8811f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * excessive retries. 8821f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt */ 883a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt noack = !!(res == WILDCARD_SSID_MATCH && 884a54fa5fb807eaeff45464139b5a7759f060cec68Dmitry Shmidt is_broadcast_ether_addr(mgmt->da)); 8858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 886d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_offs_len = 0; 887d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->csa_in_progress) { 888d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->cs_c_off_proberesp) 889d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_offs[csa_offs_len++] = 890d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->cs_c_off_proberesp; 891d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 892d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->cs_c_off_ecsa_proberesp) 893d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_offs[csa_offs_len++] = 894d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->cs_c_off_ecsa_proberesp; 895d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 896d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 897d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt ret = hostapd_drv_send_mlme_csa(hapd, resp, resp_len, noack, 898d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_offs_len ? csa_offs : NULL, 899d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_offs_len); 900d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 901d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (ret < 0) 902cce06667447b5aec83452adb0c15100ada531095Dmitry Shmidt wpa_printf(MSG_INFO, "handle_probe_req: send failed"); 9038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9041f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt os_free(resp); 9058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s " 9071f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt "SSID", MAC2STR(mgmt->sa), 9081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt elems.ssid_len == 0 ? "broadcast" : "our"); 9091f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt} 9108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtstatic u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd, 9131f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt size_t *resp_len) 9141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt{ 9151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* check probe response offloading caps and print warnings */ 9161f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD)) 9171f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt return NULL; 9188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS 9201f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->conf->wps_state && hapd->wps_probe_resp_ie && 9211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt (!(hapd->iface->probe_resp_offloads & 9221f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS | 9231f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2)))) 9241f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpa_printf(MSG_WARNING, "Device is trying to offload WPS " 9251f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt "Probe Response while not supporting this"); 9268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */ 9278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P 9291f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_probe_resp_ie && 9301f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt !(hapd->iface->probe_resp_offloads & 9311f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P)) 9321f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpa_printf(MSG_WARNING, "Device is trying to offload P2P " 9331f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt "Probe Response while not supporting this"); 9341f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* CONFIG_P2P */ 9351f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 9361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->conf->interworking && 9371f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt !(hapd->iface->probe_resp_offloads & 9381f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING)) 9391f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt wpa_printf(MSG_WARNING, "Device is trying to offload " 9401f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt "Interworking Probe Response while not supporting " 9411f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt "this"); 9421f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 9431f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* Generate a Probe Response template for the non-P2P case */ 9449d9e60286e05ae45025b672636490bd12586138dDmitry Shmidt return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len); 9458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 9468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9471f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* NEED_AP_MLME */ 9481f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 9498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 950e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidtint ieee802_11_build_ap_params(struct hostapd_data *hapd, 951e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt struct wpa_driver_ap_params *params) 9528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 9531f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt struct ieee80211_mgmt *head = NULL; 9541f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt u8 *tail = NULL; 9551f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt size_t head_len = 0, tail_len = 0; 9561f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt u8 *resp = NULL; 9571f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt size_t resp_len = 0; 9581f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef NEED_AP_MLME 9598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u16 capab_info; 960d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt u8 *pos, *tailpos, *csa_pos; 9618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define BEACON_HEAD_BUF_SIZE 256 9638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define BEACON_TAIL_BUF_SIZE 512 9648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt head = os_zalloc(BEACON_HEAD_BUF_SIZE); 9658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tail_len = BEACON_TAIL_BUF_SIZE; 9668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS 9678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->conf->wps_state && hapd->wps_beacon_ie) 9688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tail_len += wpabuf_len(hapd->wps_beacon_ie); 9698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */ 9708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P 9718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->p2p_beacon_ie) 9728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tail_len += wpabuf_len(hapd->p2p_beacon_ie); 9738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_P2P */ 974d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#ifdef CONFIG_FST 975d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->iface->fst_ies) 976d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt tail_len += wpabuf_len(hapd->iface->fst_ies); 977d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#endif /* CONFIG_FST */ 97861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt if (hapd->conf->vendor_elements) 97961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt tail_len += wpabuf_len(hapd->conf->vendor_elements); 9802f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt 9812f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt#ifdef CONFIG_IEEE80211AC 9822f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt if (hapd->conf->vendor_vht) { 9832f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt tail_len += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + 9842f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt 2 + sizeof(struct ieee80211_vht_operation); 9852f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt } 9862f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt#endif /* CONFIG_IEEE80211AC */ 9872f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt 98857c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt tail_len += hostapd_mbo_ie_len(hapd); 98957c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt 9908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = tail = os_malloc(tail_len); 9918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (head == NULL || tail == NULL) { 9928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpa_printf(MSG_ERROR, "Failed to set beacon data"); 9938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_free(head); 9948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_free(tail); 995e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt return -1; 9968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 9978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 9988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, 9998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt WLAN_FC_STYPE_BEACON); 10008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt head->duration = host_to_le16(0); 10018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memset(head->da, 0xff, ETH_ALEN); 10028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcpy(head->sa, hapd->own_addr, ETH_ALEN); 10048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN); 10058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt head->u.beacon.beacon_int = 10068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt host_to_le16(hapd->iconf->beacon_int); 10078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* hardware or low-level driver will setup seq_ctrl and timestamp */ 10099d9e60286e05ae45025b672636490bd12586138dDmitry Shmidt capab_info = hostapd_own_capab_info(hapd); 10108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt head->u.beacon.capab_info = host_to_le16(capab_info); 10118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos = &head->u.beacon.variable[0]; 10128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* SSID */ 10148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = WLAN_EID_SSID; 10158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->conf->ignore_broadcast_ssid == 2) { 10168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* clear the data, but keep the correct length of the SSID */ 10178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = hapd->conf->ssid.ssid_len; 10188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memset(pos, 0, hapd->conf->ssid.ssid_len); 10198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos += hapd->conf->ssid.ssid_len; 10208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } else if (hapd->conf->ignore_broadcast_ssid) { 10218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = 0; /* empty SSID */ 10228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } else { 10238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *pos++ = hapd->conf->ssid.ssid_len; 10248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcpy(pos, hapd->conf->ssid.ssid, 10258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt hapd->conf->ssid.ssid_len); 10268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos += hapd->conf->ssid.ssid_len; 10278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 10288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* Supported rates */ 10308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos = hostapd_eid_supp_rates(hapd, pos); 10318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* DS Params */ 10338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt pos = hostapd_eid_ds_params(hapd, pos); 10348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt head_len = pos - (u8 *) head; 10368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_country(hapd, tailpos, 10388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tail + BEACON_TAIL_BUF_SIZE - tailpos); 10398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1040f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt /* Power Constraint element */ 1041f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt tailpos = hostapd_eid_pwr_constraint(hapd, tailpos); 1042f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt 1043d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* CSA IE */ 1044d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_pos = hostapd_eid_csa(hapd, tailpos); 1045d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (csa_pos != tailpos) 1046d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->cs_c_off_beacon = csa_pos - tail - 1; 1047d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt tailpos = csa_pos; 1048d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 10498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* ERP Information element */ 10508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_erp_info(hapd, tailpos); 10518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* Extended supported rates */ 10538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos); 10548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* RSN, MDIE, WPA */ 10568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE - 10571f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt tailpos); 10588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10596c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt tailpos = hostapd_eid_rm_enabled_capab(hapd, tailpos, 10606c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt tail + BEACON_TAIL_BUF_SIZE - 10616c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt tailpos); 10626c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt 1063051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt tailpos = hostapd_eid_bss_load(hapd, tailpos, 1064051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt tail + BEACON_TAIL_BUF_SIZE - tailpos); 1065051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt 1066d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* eCSA IE */ 1067d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt csa_pos = hostapd_eid_ecsa(hapd, tailpos); 1068d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (csa_pos != tailpos) 1069d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt hapd->cs_c_off_ecsa_beacon = csa_pos - tail - 1; 1070d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt tailpos = csa_pos; 1071d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 1072d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt tailpos = hostapd_eid_supported_op_classes(hapd, tailpos); 1073d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 10748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_IEEE80211N 1075d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* Secondary Channel Offset element */ 1076d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt /* TODO: The standard doesn't specify a position for this element. */ 1077d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt tailpos = hostapd_eid_secondary_channel(hapd, tailpos); 1078d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 10798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_ht_capabilities(hapd, tailpos); 10808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_ht_operation(hapd, tailpos); 10818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_IEEE80211N */ 10828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_ext_capab(hapd, tailpos); 10848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 10851f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt /* 10861f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * TODO: Time Advertisement element should only be included in some 10871f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt * DTIM Beacon frames. 10881f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt */ 10891f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt tailpos = hostapd_eid_time_adv(hapd, tailpos); 10901f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 10911f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt tailpos = hostapd_eid_interworking(hapd, tailpos); 10921f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt tailpos = hostapd_eid_adv_proto(hapd, tailpos); 10931f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt tailpos = hostapd_eid_roaming_consortium(hapd, tailpos); 1094d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 1095d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#ifdef CONFIG_FST 1096d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (hapd->iface->fst_ies) { 1097d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_memcpy(tailpos, wpabuf_head(hapd->iface->fst_ies), 1098d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpabuf_len(hapd->iface->fst_ies)); 1099d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt tailpos += wpabuf_len(hapd->iface->fst_ies); 1100d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 1101d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#endif /* CONFIG_FST */ 1102d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 110304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#ifdef CONFIG_IEEE80211AC 11042f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) { 11052f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt tailpos = hostapd_eid_vht_capabilities(hapd, tailpos); 11062f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt tailpos = hostapd_eid_vht_operation(hapd, tailpos); 1107d7ff03d48f825360eec2a371e3361306f2fd721bDmitry Shmidt tailpos = hostapd_eid_txpower_envelope(hapd, tailpos); 1108d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos); 11092f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt } 11102f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt if (hapd->conf->vendor_vht) 11112f74e36e84064ffa32f82f3decf36b653c7e4fadDmitry Shmidt tailpos = hostapd_eid_vendor_vht(hapd, tailpos); 111204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt#endif /* CONFIG_IEEE80211AC */ 111304949598a23f501be6eec21697465fd46a28840aDmitry Shmidt 11148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt /* Wi-Fi Alliance WMM */ 11158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_wmm(hapd, tailpos); 11168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 11178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_WPS 11188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if (hapd->conf->wps_state && hapd->wps_beacon_ie) { 11198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie), 11208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpabuf_len(hapd->wps_beacon_ie)); 11218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos += wpabuf_len(hapd->wps_beacon_ie); 11228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 11238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_WPS */ 11248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 11258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P 11268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) { 11278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie), 11288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt wpabuf_len(hapd->p2p_beacon_ie)); 11298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos += wpabuf_len(hapd->p2p_beacon_ie); 11308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt } 11318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_P2P */ 11328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifdef CONFIG_P2P_MANAGER 11338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == 11348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt P2P_MANAGE) 11358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tailpos = hostapd_eid_p2p_manage(hapd, tailpos); 11368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_P2P_MANAGER */ 11378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 113861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt#ifdef CONFIG_HS20 113961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt tailpos = hostapd_eid_hs20_indication(hapd, tailpos); 1140f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt tailpos = hostapd_eid_osen(hapd, tailpos); 114161d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt#endif /* CONFIG_HS20 */ 114261d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt 114357c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt tailpos = hostapd_eid_mbo(hapd, tailpos, tail + tail_len - tailpos); 114457c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt 114561d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt if (hapd->conf->vendor_elements) { 114661d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt os_memcpy(tailpos, wpabuf_head(hapd->conf->vendor_elements), 114761d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt wpabuf_len(hapd->conf->vendor_elements)); 114861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt tailpos += wpabuf_len(hapd->conf->vendor_elements); 114961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt } 115061d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt 11518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt tail_len = tailpos > tail ? tailpos - tail : 0; 11528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 11531f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt resp = hostapd_probe_resp_offloads(hapd, &resp_len); 11541f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* NEED_AP_MLME */ 11551f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt 1156e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt os_memset(params, 0, sizeof(*params)); 1157e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->head = (u8 *) head; 1158e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->head_len = head_len; 1159e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->tail = tail; 1160e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->tail_len = tail_len; 1161e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->proberesp = resp; 1162e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->proberesp_len = resp_len; 1163e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->dtim_period = hapd->conf->dtim_period; 1164e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->beacon_int = hapd->iconf->beacon_int; 1165e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->basic_rates = hapd->iface->basic_rates; 1166e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->ssid = hapd->conf->ssid.ssid; 1167e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->ssid_len = hapd->conf->ssid.ssid_len; 11687a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) == 11697a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt (WPA_PROTO_WPA | WPA_PROTO_RSN)) 11707a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt params->pairwise_ciphers = hapd->conf->wpa_pairwise | 11717a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt hapd->conf->rsn_pairwise; 11727a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt else if (hapd->conf->wpa & WPA_PROTO_RSN) 11737a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt params->pairwise_ciphers = hapd->conf->rsn_pairwise; 11747a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt else if (hapd->conf->wpa & WPA_PROTO_WPA) 11757a53dbb56693ee9f55c0cab1a8297436511e8613Dmitry Shmidt params->pairwise_ciphers = hapd->conf->wpa_pairwise; 1176e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->group_cipher = hapd->conf->wpa_group; 1177e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->key_mgmt_suites = hapd->conf->wpa_key_mgmt; 1178e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->auth_algs = hapd->conf->auth_algs; 1179e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->wpa_version = hapd->conf->wpa; 1180e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->privacy = hapd->conf->ssid.wep.keys_set || hapd->conf->wpa || 11811f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt (hapd->conf->ieee802_1x && 11821f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt (hapd->conf->default_wep_key_len || 11831f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hapd->conf->individual_wep_key_len)); 11841f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt switch (hapd->conf->ignore_broadcast_ssid) { 11851f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt case 0: 1186e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->hide_ssid = NO_SSID_HIDING; 11871f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt break; 11881f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt case 1: 1189e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->hide_ssid = HIDDEN_SSID_ZERO_LEN; 11901f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt break; 11911f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt case 2: 1192e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->hide_ssid = HIDDEN_SSID_ZERO_CONTENTS; 11931f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt break; 11941f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt } 1195e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->isolate = hapd->conf->isolate; 11966c0da2bb83f6915d8260912362692d1a742e057bDmitry Shmidt params->smps_mode = hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_MASK; 11971f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#ifdef NEED_AP_MLME 1198e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->cts_protect = !!(ieee802_11_erp_info(hapd) & 11991f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt ERP_INFO_USE_PROTECTION); 1200e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->preamble = hapd->iface->num_sta_no_short_preamble == 0 && 12011f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hapd->iconf->preamble == SHORT_PREAMBLE; 12021f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->iface->current_mode && 12031f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) 1204e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->short_slot_time = 12051f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1; 12061f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt else 1207e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->short_slot_time = -1; 12081f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n) 1209e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->ht_opmode = -1; 12101f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt else 1211e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->ht_opmode = hapd->iface->ht_op_mode; 12121f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt#endif /* NEED_AP_MLME */ 1213e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->interworking = hapd->conf->interworking; 12141f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt if (hapd->conf->interworking && 12151f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt !is_zero_ether_addr(hapd->conf->hessid)) 1216e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->hessid = hapd->conf->hessid; 1217e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->access_network_type = hapd->conf->access_network_type; 1218e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->ap_max_inactivity = hapd->conf->ap_max_inactivity; 12197f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt#ifdef CONFIG_P2P 12207f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt params->p2p_go_ctwindow = hapd->iconf->p2p_go_ctwindow; 12217f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt#endif /* CONFIG_P2P */ 122261d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt#ifdef CONFIG_HS20 1223e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->disable_dgaf = hapd->conf->disable_dgaf; 1224f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt if (hapd->conf->osen) { 1225f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt params->privacy = 1; 1226f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt params->osen = 1; 1227f21452aea786ac056eb01f1cbba4f553bd502747Dmitry Shmidt } 122861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt#endif /* CONFIG_HS20 */ 122957c2d39d85825f38c5fdac9b73bb0088406ffc85Dmitry Shmidt params->pbss = hapd->conf->pbss; 1230e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt return 0; 1231e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt} 1232e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1233e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1234e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidtvoid ieee802_11_free_ap_params(struct wpa_driver_ap_params *params) 1235e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt{ 1236e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt os_free(params->tail); 1237e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->tail = NULL; 1238e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt os_free(params->head); 1239e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->head = NULL; 1240e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt os_free(params->proberesp); 1241e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params->proberesp = NULL; 1242e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt} 1243e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1244e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1245fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidtint ieee802_11_set_beacon(struct hostapd_data *hapd) 1246e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt{ 1247e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt struct wpa_driver_ap_params params; 12487832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt struct hostapd_freq_params freq; 12497832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt struct hostapd_iface *iface = hapd->iface; 12507832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt struct hostapd_config *iconf = iface->conf; 1251e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt struct wpabuf *beacon, *proberesp, *assocresp; 1252fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt int res, ret = -1; 1253e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1254d30ac604c9f6da71a0dd7f46d25be05a2a62cfbbDmitry Shmidt if (hapd->csa_in_progress) { 1255e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period"); 1256fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt return -1; 1257e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt } 1258e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1259e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt hapd->beacon_set_done = 1; 1260e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1261e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt if (ieee802_11_build_ap_params(hapd, ¶ms) < 0) 1262fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt return -1; 1263e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1264e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < 1265e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 0) 1266e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt goto fail; 1267e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 1268e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params.beacon_ies = beacon; 1269e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params.proberesp_ies = proberesp; 1270e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt params.assocresp_ies = assocresp; 12717f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt params.reenable = hapd->reenable_beacon; 12727f65602d49069f96a7bb44da8bd79ffe8d4c6a98Dmitry Shmidt hapd->reenable_beacon = 0; 1273e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt 12747832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt if (iface->current_mode && 12757832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq, 12767832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt iconf->channel, iconf->ieee80211n, 12777832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt iconf->ieee80211ac, 12787832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt iconf->secondary_channel, 12797832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt iconf->vht_oper_chwidth, 12807832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt iconf->vht_oper_centr_freq_seg0_idx, 12817832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt iconf->vht_oper_centr_freq_seg1_idx, 12827832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt iface->current_mode->vht_capab) == 0) 12837832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt params.freq = &freq; 12847832adbbd72a1b784b7fb74a71a5d4085b0cb0d3Dmitry Shmidt 1285fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt res = hostapd_drv_set_ap(hapd, ¶ms); 12861f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); 1287fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt if (res) 1288fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt wpa_printf(MSG_ERROR, "Failed to set beacon parameters"); 1289fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt else 1290fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt ret = 0; 1291e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidtfail: 1292e0e48dc666fb14a7bb60264ca87463ba7bc1fe0bDmitry Shmidt ieee802_11_free_ap_params(¶ms); 1293fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt return ret; 12948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 12958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 12968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 1297fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidtint ieee802_11_set_beacons(struct hostapd_iface *iface) 12988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{ 12998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t i; 1300fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt int ret = 0; 1301fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 1302292b0c3a742226c295f8db76eaef9e90c90e7513Dmitry Shmidt for (i = 0; i < iface->num_bss; i++) { 1303fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt if (iface->bss[i]->started && 1304fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt ieee802_11_set_beacon(iface->bss[i]) < 0) 1305fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt ret = -1; 1306292b0c3a742226c295f8db76eaef9e90c90e7513Dmitry Shmidt } 1307fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 1308fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt return ret; 13098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 13108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 131104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt 131204949598a23f501be6eec21697465fd46a28840aDmitry Shmidt/* only update beacons if started */ 1313fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidtint ieee802_11_update_beacons(struct hostapd_iface *iface) 131404949598a23f501be6eec21697465fd46a28840aDmitry Shmidt{ 131504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt size_t i; 1316fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt int ret = 0; 1317fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 1318fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt for (i = 0; i < iface->num_bss; i++) { 1319fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt if (iface->bss[i]->beacon_set_done && iface->bss[i]->started && 1320fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt ieee802_11_set_beacon(iface->bss[i]) < 0) 1321fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt ret = -1; 1322fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt } 1323fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 1324fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt return ret; 132504949598a23f501be6eec21697465fd46a28840aDmitry Shmidt} 132604949598a23f501be6eec21697465fd46a28840aDmitry Shmidt 13278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* CONFIG_NATIVE_WINDOWS */ 1328