Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * WPA Supplicant - Basic AP mode support routines |
| 3 | * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi> |
| 4 | * Copyright (c) 2009, Atheros Communications |
| 5 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 6 | * This software may be distributed under the terms of the BSD license. |
| 7 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include "utils/includes.h" |
| 11 | |
| 12 | #include "utils/common.h" |
| 13 | #include "utils/eloop.h" |
| 14 | #include "utils/uuid.h" |
| 15 | #include "common/ieee802_11_defs.h" |
| 16 | #include "common/wpa_ctrl.h" |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 17 | #include "eapol_supp/eapol_supp_sm.h" |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 18 | #include "crypto/dh_group5.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 19 | #include "ap/hostapd.h" |
| 20 | #include "ap/ap_config.h" |
| 21 | #include "ap/ap_drv_ops.h" |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 22 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 23 | #include "ap/ieee802_11.h" |
| 24 | #endif /* NEED_AP_MLME */ |
| 25 | #include "ap/beacon.h" |
| 26 | #include "ap/ieee802_1x.h" |
| 27 | #include "ap/wps_hostapd.h" |
| 28 | #include "ap/ctrl_iface_ap.h" |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 29 | #include "ap/dfs.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 30 | #include "wps/wps.h" |
| 31 | #include "common/ieee802_11_defs.h" |
| 32 | #include "config_ssid.h" |
| 33 | #include "config.h" |
| 34 | #include "wpa_supplicant_i.h" |
| 35 | #include "driver_i.h" |
| 36 | #include "p2p_supplicant.h" |
| 37 | #include "ap.h" |
| 38 | #include "ap/sta_info.h" |
| 39 | #include "notify.h" |
| 40 | |
| 41 | |
| 42 | #ifdef CONFIG_WPS |
| 43 | static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx); |
| 44 | #endif /* CONFIG_WPS */ |
| 45 | |
| 46 | |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 47 | #ifdef CONFIG_IEEE80211N |
| 48 | static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s, |
| 49 | struct hostapd_config *conf, |
| 50 | struct hostapd_hw_modes *mode) |
| 51 | { |
Dmitry Shmidt | 21de214 | 2014-04-08 10:50:52 -0700 | [diff] [blame] | 52 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 53 | u8 center_chan = 0; |
| 54 | u8 channel = conf->channel; |
| 55 | |
| 56 | if (!conf->secondary_channel) |
| 57 | goto no_vht; |
| 58 | |
| 59 | center_chan = wpas_p2p_get_vht80_center(wpa_s, mode, channel); |
| 60 | if (!center_chan) |
| 61 | goto no_vht; |
| 62 | |
| 63 | /* Use 80 MHz channel */ |
| 64 | conf->vht_oper_chwidth = 1; |
| 65 | conf->vht_oper_centr_freq_seg0_idx = center_chan; |
| 66 | return; |
| 67 | |
| 68 | no_vht: |
| 69 | conf->vht_oper_centr_freq_seg0_idx = |
| 70 | channel + conf->secondary_channel * 2; |
Dmitry Shmidt | 21de214 | 2014-04-08 10:50:52 -0700 | [diff] [blame] | 71 | #else /* CONFIG_P2P */ |
| 72 | conf->vht_oper_centr_freq_seg0_idx = |
| 73 | conf->channel + conf->secondary_channel * 2; |
| 74 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 75 | } |
| 76 | #endif /* CONFIG_IEEE80211N */ |
| 77 | |
| 78 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 79 | int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s, |
| 80 | struct wpa_ssid *ssid, |
| 81 | struct hostapd_config *conf) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 82 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 83 | conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency, |
| 84 | &conf->channel); |
| 85 | |
| 86 | if (conf->hw_mode == NUM_HOSTAPD_MODES) { |
| 87 | wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz", |
| 88 | ssid->frequency); |
| 89 | return -1; |
| 90 | } |
| 91 | |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 92 | /* TODO: enable HT40 if driver supports it; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 93 | * drop to 11b if driver does not support 11g */ |
| 94 | |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 95 | #ifdef CONFIG_IEEE80211N |
| 96 | /* |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 97 | * Enable HT20 if the driver supports it, by setting conf->ieee80211n |
| 98 | * and a mask of allowed capabilities within conf->ht_capab. |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 99 | * Using default config settings for: conf->ht_op_mode_fixed, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 100 | * conf->secondary_channel, conf->require_ht |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 101 | */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 102 | if (wpa_s->hw.modes) { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 103 | struct hostapd_hw_modes *mode = NULL; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 104 | int i, no_ht = 0; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 105 | for (i = 0; i < wpa_s->hw.num_modes; i++) { |
| 106 | if (wpa_s->hw.modes[i].mode == conf->hw_mode) { |
| 107 | mode = &wpa_s->hw.modes[i]; |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 108 | break; |
| 109 | } |
| 110 | } |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 111 | |
| 112 | #ifdef CONFIG_HT_OVERRIDES |
| 113 | if (ssid->disable_ht) { |
| 114 | conf->ieee80211n = 0; |
| 115 | conf->ht_capab = 0; |
| 116 | no_ht = 1; |
| 117 | } |
| 118 | #endif /* CONFIG_HT_OVERRIDES */ |
| 119 | |
| 120 | if (!no_ht && mode && mode->ht_capab) { |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 121 | conf->ieee80211n = 1; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 122 | #ifdef CONFIG_P2P |
| 123 | if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A && |
| 124 | (mode->ht_capab & |
| 125 | HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) && |
| 126 | ssid->ht40) |
| 127 | conf->secondary_channel = |
| 128 | wpas_p2p_get_ht40_mode(wpa_s, mode, |
| 129 | conf->channel); |
| 130 | if (conf->secondary_channel) |
| 131 | conf->ht_capab |= |
| 132 | HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; |
| 133 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 134 | |
| 135 | /* |
| 136 | * white-list capabilities that won't cause issues |
| 137 | * to connecting stations, while leaving the current |
| 138 | * capabilities intact (currently disabled SMPS). |
| 139 | */ |
| 140 | conf->ht_capab |= mode->ht_capab & |
| 141 | (HT_CAP_INFO_GREEN_FIELD | |
| 142 | HT_CAP_INFO_SHORT_GI20MHZ | |
| 143 | HT_CAP_INFO_SHORT_GI40MHZ | |
| 144 | HT_CAP_INFO_RX_STBC_MASK | |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 145 | HT_CAP_INFO_TX_STBC | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 146 | HT_CAP_INFO_MAX_AMSDU_SIZE); |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 147 | |
| 148 | if (mode->vht_capab && ssid->vht) { |
| 149 | conf->ieee80211ac = 1; |
| 150 | wpas_conf_ap_vht(wpa_s, conf, mode); |
| 151 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 152 | } |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 153 | } |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 154 | |
| 155 | if (conf->secondary_channel) { |
| 156 | struct wpa_supplicant *iface; |
| 157 | |
| 158 | for (iface = wpa_s->global->ifaces; iface; iface = iface->next) |
| 159 | { |
| 160 | if (iface == wpa_s || |
| 161 | iface->wpa_state < WPA_AUTHENTICATING || |
| 162 | (int) iface->assoc_freq != ssid->frequency) |
| 163 | continue; |
| 164 | |
| 165 | /* |
| 166 | * Do not allow 40 MHz co-ex PRI/SEC switch to force us |
| 167 | * to change our PRI channel since we have an existing, |
| 168 | * concurrent connection on that channel and doing |
| 169 | * multi-channel concurrency is likely to cause more |
| 170 | * harm than using different PRI/SEC selection in |
| 171 | * environment with multiple BSSes on these two channels |
| 172 | * with mixed 20 MHz or PRI channel selection. |
| 173 | */ |
| 174 | conf->no_pri_sec_switch = 1; |
| 175 | } |
| 176 | } |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 177 | #endif /* CONFIG_IEEE80211N */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 178 | |
| 179 | return 0; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | |
| 183 | static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s, |
| 184 | struct wpa_ssid *ssid, |
| 185 | struct hostapd_config *conf) |
| 186 | { |
| 187 | struct hostapd_bss_config *bss = conf->bss[0]; |
| 188 | |
| 189 | conf->driver = wpa_s->driver; |
| 190 | |
| 191 | os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface)); |
| 192 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 193 | if (wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf)) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 194 | return -1; |
Dmitry Shmidt | c55524a | 2011-07-07 11:18:38 -0700 | [diff] [blame] | 195 | |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 196 | if (ieee80211_is_dfs(ssid->frequency) && wpa_s->conf->country[0]) { |
| 197 | conf->ieee80211h = 1; |
| 198 | conf->ieee80211d = 1; |
| 199 | conf->country[0] = wpa_s->conf->country[0]; |
| 200 | conf->country[1] = wpa_s->conf->country[1]; |
| 201 | } |
| 202 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 203 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 204 | if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G && |
| 205 | (ssid->mode == WPAS_MODE_P2P_GO || |
| 206 | ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 207 | /* Remove 802.11b rates from supported and basic rate sets */ |
| 208 | int *list = os_malloc(4 * sizeof(int)); |
| 209 | if (list) { |
| 210 | list[0] = 60; |
| 211 | list[1] = 120; |
| 212 | list[2] = 240; |
| 213 | list[3] = -1; |
| 214 | } |
| 215 | conf->basic_rates = list; |
| 216 | |
| 217 | list = os_malloc(9 * sizeof(int)); |
| 218 | if (list) { |
| 219 | list[0] = 60; |
| 220 | list[1] = 90; |
| 221 | list[2] = 120; |
| 222 | list[3] = 180; |
| 223 | list[4] = 240; |
| 224 | list[5] = 360; |
| 225 | list[6] = 480; |
| 226 | list[7] = 540; |
| 227 | list[8] = -1; |
| 228 | } |
| 229 | conf->supported_rates = list; |
| 230 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 231 | |
| 232 | bss->isolate = !wpa_s->conf->p2p_intra_bss; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 233 | bss->force_per_enrollee_psk = wpa_s->global->p2p_per_sta_psk; |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 234 | |
| 235 | if (ssid->p2p_group) { |
| 236 | os_memcpy(bss->ip_addr_go, wpa_s->parent->conf->ip_addr_go, 4); |
| 237 | os_memcpy(bss->ip_addr_mask, wpa_s->parent->conf->ip_addr_mask, |
| 238 | 4); |
| 239 | os_memcpy(bss->ip_addr_start, |
| 240 | wpa_s->parent->conf->ip_addr_start, 4); |
| 241 | os_memcpy(bss->ip_addr_end, wpa_s->parent->conf->ip_addr_end, |
| 242 | 4); |
| 243 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 244 | #endif /* CONFIG_P2P */ |
| 245 | |
| 246 | if (ssid->ssid_len == 0) { |
| 247 | wpa_printf(MSG_ERROR, "No SSID configured for AP mode"); |
| 248 | return -1; |
| 249 | } |
| 250 | os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 251 | bss->ssid.ssid_len = ssid->ssid_len; |
| 252 | bss->ssid.ssid_set = 1; |
| 253 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 254 | bss->ignore_broadcast_ssid = ssid->ignore_broadcast_ssid; |
| 255 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 256 | if (ssid->auth_alg) |
| 257 | bss->auth_algs = ssid->auth_alg; |
| 258 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 259 | if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt)) |
| 260 | bss->wpa = ssid->proto; |
| 261 | bss->wpa_key_mgmt = ssid->key_mgmt; |
| 262 | bss->wpa_pairwise = ssid->pairwise_cipher; |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 263 | if (ssid->psk_set) { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 264 | bin_clear_free(bss->ssid.wpa_psk, sizeof(*bss->ssid.wpa_psk)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 265 | bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk)); |
| 266 | if (bss->ssid.wpa_psk == NULL) |
| 267 | return -1; |
| 268 | os_memcpy(bss->ssid.wpa_psk->psk, ssid->psk, PMK_LEN); |
| 269 | bss->ssid.wpa_psk->group = 1; |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 270 | } else if (ssid->passphrase) { |
| 271 | bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 272 | } else if (ssid->wep_key_len[0] || ssid->wep_key_len[1] || |
| 273 | ssid->wep_key_len[2] || ssid->wep_key_len[3]) { |
| 274 | struct hostapd_wep_keys *wep = &bss->ssid.wep; |
| 275 | int i; |
| 276 | for (i = 0; i < NUM_WEP_KEYS; i++) { |
| 277 | if (ssid->wep_key_len[i] == 0) |
| 278 | continue; |
| 279 | wep->key[i] = os_malloc(ssid->wep_key_len[i]); |
| 280 | if (wep->key[i] == NULL) |
| 281 | return -1; |
| 282 | os_memcpy(wep->key[i], ssid->wep_key[i], |
| 283 | ssid->wep_key_len[i]); |
| 284 | wep->len[i] = ssid->wep_key_len[i]; |
| 285 | } |
| 286 | wep->idx = ssid->wep_tx_keyidx; |
| 287 | wep->keys_set = 1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 290 | if (ssid->ap_max_inactivity) |
| 291 | bss->ap_max_inactivity = ssid->ap_max_inactivity; |
| 292 | |
| 293 | if (ssid->dtim_period) |
| 294 | bss->dtim_period = ssid->dtim_period; |
Dmitry Shmidt | 7a5e50a | 2013-03-05 12:37:16 -0800 | [diff] [blame] | 295 | else if (wpa_s->conf->dtim_period) |
| 296 | bss->dtim_period = wpa_s->conf->dtim_period; |
| 297 | |
| 298 | if (ssid->beacon_int) |
| 299 | conf->beacon_int = ssid->beacon_int; |
| 300 | else if (wpa_s->conf->beacon_int) |
| 301 | conf->beacon_int = wpa_s->conf->beacon_int; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 302 | |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 303 | #ifdef CONFIG_P2P |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 304 | if (ssid->mode == WPAS_MODE_P2P_GO || |
| 305 | ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) { |
| 306 | if (wpa_s->conf->p2p_go_ctwindow > conf->beacon_int) { |
| 307 | wpa_printf(MSG_INFO, |
| 308 | "CTWindow (%d) is bigger than beacon interval (%d) - avoid configuring it", |
| 309 | wpa_s->conf->p2p_go_ctwindow, |
| 310 | conf->beacon_int); |
| 311 | conf->p2p_go_ctwindow = 0; |
| 312 | } else { |
| 313 | conf->p2p_go_ctwindow = wpa_s->conf->p2p_go_ctwindow; |
| 314 | } |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 315 | } |
| 316 | #endif /* CONFIG_P2P */ |
| 317 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 318 | if ((bss->wpa & 2) && bss->rsn_pairwise == 0) |
| 319 | bss->rsn_pairwise = bss->wpa_pairwise; |
| 320 | bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise, |
| 321 | bss->rsn_pairwise); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 322 | |
| 323 | if (bss->wpa && bss->ieee802_1x) |
| 324 | bss->ssid.security_policy = SECURITY_WPA; |
| 325 | else if (bss->wpa) |
| 326 | bss->ssid.security_policy = SECURITY_WPA_PSK; |
| 327 | else if (bss->ieee802_1x) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 328 | int cipher = WPA_CIPHER_NONE; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 329 | bss->ssid.security_policy = SECURITY_IEEE_802_1X; |
| 330 | bss->ssid.wep.default_len = bss->default_wep_key_len; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 331 | if (bss->default_wep_key_len) |
| 332 | cipher = bss->default_wep_key_len >= 13 ? |
| 333 | WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40; |
| 334 | bss->wpa_group = cipher; |
| 335 | bss->wpa_pairwise = cipher; |
| 336 | bss->rsn_pairwise = cipher; |
| 337 | } else if (bss->ssid.wep.keys_set) { |
| 338 | int cipher = WPA_CIPHER_WEP40; |
| 339 | if (bss->ssid.wep.len[0] >= 13) |
| 340 | cipher = WPA_CIPHER_WEP104; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 341 | bss->ssid.security_policy = SECURITY_STATIC_WEP; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 342 | bss->wpa_group = cipher; |
| 343 | bss->wpa_pairwise = cipher; |
| 344 | bss->rsn_pairwise = cipher; |
| 345 | } else { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 346 | bss->ssid.security_policy = SECURITY_PLAINTEXT; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 347 | bss->wpa_group = WPA_CIPHER_NONE; |
| 348 | bss->wpa_pairwise = WPA_CIPHER_NONE; |
| 349 | bss->rsn_pairwise = WPA_CIPHER_NONE; |
| 350 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 351 | |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 352 | if (bss->wpa_group_rekey < 86400 && (bss->wpa & 2) && |
| 353 | (bss->wpa_group == WPA_CIPHER_CCMP || |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 354 | bss->wpa_group == WPA_CIPHER_GCMP || |
| 355 | bss->wpa_group == WPA_CIPHER_CCMP_256 || |
| 356 | bss->wpa_group == WPA_CIPHER_GCMP_256)) { |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 357 | /* |
| 358 | * Strong ciphers do not need frequent rekeying, so increase |
| 359 | * the default GTK rekeying period to 24 hours. |
| 360 | */ |
| 361 | bss->wpa_group_rekey = 86400; |
| 362 | } |
| 363 | |
Dmitry Shmidt | b36ed7c | 2014-03-17 10:57:26 -0700 | [diff] [blame] | 364 | #ifdef CONFIG_IEEE80211W |
| 365 | if (ssid->ieee80211w != MGMT_FRAME_PROTECTION_DEFAULT) |
| 366 | bss->ieee80211w = ssid->ieee80211w; |
| 367 | #endif /* CONFIG_IEEE80211W */ |
| 368 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 369 | #ifdef CONFIG_WPS |
| 370 | /* |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 371 | * Enable WPS by default for open and WPA/WPA2-Personal network, but |
| 372 | * require user interaction to actually use it. Only the internal |
| 373 | * Registrar is supported. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 374 | */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 375 | if (bss->ssid.security_policy != SECURITY_WPA_PSK && |
| 376 | bss->ssid.security_policy != SECURITY_PLAINTEXT) |
| 377 | goto no_wps; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 378 | if (bss->ssid.security_policy == SECURITY_WPA_PSK && |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 379 | (!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)) || |
| 380 | !(bss->wpa & 2))) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 381 | goto no_wps; /* WPS2 does not allow WPA/TKIP-only |
| 382 | * configuration */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 383 | bss->eap_server = 1; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 384 | |
| 385 | if (!ssid->ignore_broadcast_ssid) |
| 386 | bss->wps_state = 2; |
| 387 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 388 | bss->ap_setup_locked = 2; |
| 389 | if (wpa_s->conf->config_methods) |
| 390 | bss->config_methods = os_strdup(wpa_s->conf->config_methods); |
| 391 | os_memcpy(bss->device_type, wpa_s->conf->device_type, |
| 392 | WPS_DEV_TYPE_LEN); |
| 393 | if (wpa_s->conf->device_name) { |
| 394 | bss->device_name = os_strdup(wpa_s->conf->device_name); |
| 395 | bss->friendly_name = os_strdup(wpa_s->conf->device_name); |
| 396 | } |
| 397 | if (wpa_s->conf->manufacturer) |
| 398 | bss->manufacturer = os_strdup(wpa_s->conf->manufacturer); |
| 399 | if (wpa_s->conf->model_name) |
| 400 | bss->model_name = os_strdup(wpa_s->conf->model_name); |
| 401 | if (wpa_s->conf->model_number) |
| 402 | bss->model_number = os_strdup(wpa_s->conf->model_number); |
| 403 | if (wpa_s->conf->serial_number) |
| 404 | bss->serial_number = os_strdup(wpa_s->conf->serial_number); |
| 405 | if (is_nil_uuid(wpa_s->conf->uuid)) |
| 406 | os_memcpy(bss->uuid, wpa_s->wps->uuid, WPS_UUID_LEN); |
| 407 | else |
| 408 | os_memcpy(bss->uuid, wpa_s->conf->uuid, WPS_UUID_LEN); |
| 409 | os_memcpy(bss->os_version, wpa_s->conf->os_version, 4); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 410 | bss->pbc_in_m1 = wpa_s->conf->pbc_in_m1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 411 | no_wps: |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 412 | #endif /* CONFIG_WPS */ |
| 413 | |
| 414 | if (wpa_s->max_stations && |
| 415 | wpa_s->max_stations < wpa_s->conf->max_num_sta) |
| 416 | bss->max_num_sta = wpa_s->max_stations; |
| 417 | else |
| 418 | bss->max_num_sta = wpa_s->conf->max_num_sta; |
| 419 | |
| 420 | bss->disassoc_low_ack = wpa_s->conf->disassoc_low_ack; |
| 421 | |
Dmitry Shmidt | 0ccb66e | 2013-03-29 16:41:28 -0700 | [diff] [blame] | 422 | if (wpa_s->conf->ap_vendor_elements) { |
| 423 | bss->vendor_elements = |
| 424 | wpabuf_dup(wpa_s->conf->ap_vendor_elements); |
| 425 | } |
| 426 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 427 | return 0; |
| 428 | } |
| 429 | |
| 430 | |
| 431 | static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq) |
| 432 | { |
| 433 | #ifdef CONFIG_P2P |
| 434 | struct wpa_supplicant *wpa_s = ctx; |
| 435 | const struct ieee80211_mgmt *mgmt; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 436 | |
| 437 | mgmt = (const struct ieee80211_mgmt *) buf; |
Dmitry Shmidt | 623d63a | 2014-06-13 11:05:14 -0700 | [diff] [blame] | 438 | if (len < IEEE80211_HDRLEN + 1) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 439 | return; |
Dmitry Shmidt | 1846323 | 2014-01-24 12:29:41 -0800 | [diff] [blame] | 440 | if (mgmt->u.action.category != WLAN_ACTION_PUBLIC) |
| 441 | return; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 442 | wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid, |
| 443 | mgmt->u.action.category, |
Dmitry Shmidt | 623d63a | 2014-06-13 11:05:14 -0700 | [diff] [blame] | 444 | buf + IEEE80211_HDRLEN + 1, |
| 445 | len - IEEE80211_HDRLEN - 1, freq); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 446 | #endif /* CONFIG_P2P */ |
| 447 | } |
| 448 | |
| 449 | |
| 450 | static void ap_wps_event_cb(void *ctx, enum wps_event event, |
| 451 | union wps_event_data *data) |
| 452 | { |
| 453 | #ifdef CONFIG_P2P |
| 454 | struct wpa_supplicant *wpa_s = ctx; |
| 455 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 456 | if (event == WPS_EV_FAIL) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 457 | struct wps_event_fail *fail = &data->fail; |
| 458 | |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 459 | if (wpa_s->parent && wpa_s->parent != wpa_s && |
| 460 | wpa_s == wpa_s->global->p2p_group_formation) { |
| 461 | /* |
| 462 | * src/ap/wps_hostapd.c has already sent this on the |
| 463 | * main interface, so only send on the parent interface |
| 464 | * here if needed. |
| 465 | */ |
| 466 | wpa_msg(wpa_s->parent, MSG_INFO, WPS_EVENT_FAIL |
| 467 | "msg=%d config_error=%d", |
| 468 | fail->msg, fail->config_error); |
| 469 | } |
| 470 | wpas_p2p_wps_failed(wpa_s, fail); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 471 | } |
| 472 | #endif /* CONFIG_P2P */ |
| 473 | } |
| 474 | |
| 475 | |
| 476 | static void ap_sta_authorized_cb(void *ctx, const u8 *mac_addr, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 477 | int authorized, const u8 *p2p_dev_addr) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 478 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 479 | wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 483 | #ifdef CONFIG_P2P |
| 484 | static void ap_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr, |
| 485 | const u8 *psk, size_t psk_len) |
| 486 | { |
| 487 | |
| 488 | struct wpa_supplicant *wpa_s = ctx; |
| 489 | if (wpa_s->ap_iface == NULL || wpa_s->current_ssid == NULL) |
| 490 | return; |
| 491 | wpas_p2p_new_psk_cb(wpa_s, mac_addr, p2p_dev_addr, psk, psk_len); |
| 492 | } |
| 493 | #endif /* CONFIG_P2P */ |
| 494 | |
| 495 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 496 | static int ap_vendor_action_rx(void *ctx, const u8 *buf, size_t len, int freq) |
| 497 | { |
| 498 | #ifdef CONFIG_P2P |
| 499 | struct wpa_supplicant *wpa_s = ctx; |
| 500 | const struct ieee80211_mgmt *mgmt; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 501 | |
| 502 | mgmt = (const struct ieee80211_mgmt *) buf; |
Dmitry Shmidt | 623d63a | 2014-06-13 11:05:14 -0700 | [diff] [blame] | 503 | if (len < IEEE80211_HDRLEN + 1) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 504 | return -1; |
| 505 | wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid, |
| 506 | mgmt->u.action.category, |
Dmitry Shmidt | 623d63a | 2014-06-13 11:05:14 -0700 | [diff] [blame] | 507 | buf + IEEE80211_HDRLEN + 1, |
| 508 | len - IEEE80211_HDRLEN - 1, freq); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 509 | #endif /* CONFIG_P2P */ |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 514 | static int ap_probe_req_rx(void *ctx, const u8 *sa, const u8 *da, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 515 | const u8 *bssid, const u8 *ie, size_t ie_len, |
| 516 | int ssi_signal) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 517 | { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 518 | struct wpa_supplicant *wpa_s = ctx; |
Dmitry Shmidt | a3dc309 | 2015-06-23 11:21:28 -0700 | [diff] [blame] | 519 | unsigned int freq = 0; |
| 520 | |
| 521 | if (wpa_s->ap_iface) |
| 522 | freq = wpa_s->ap_iface->freq; |
| 523 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 524 | return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len, |
Dmitry Shmidt | a3dc309 | 2015-06-23 11:21:28 -0700 | [diff] [blame] | 525 | freq, ssi_signal); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | |
| 529 | static void ap_wps_reg_success_cb(void *ctx, const u8 *mac_addr, |
| 530 | const u8 *uuid_e) |
| 531 | { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 532 | struct wpa_supplicant *wpa_s = ctx; |
| 533 | wpas_p2p_wps_success(wpa_s, mac_addr, 1); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | |
| 537 | static void wpas_ap_configured_cb(void *ctx) |
| 538 | { |
| 539 | struct wpa_supplicant *wpa_s = ctx; |
| 540 | |
| 541 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); |
| 542 | |
| 543 | if (wpa_s->ap_configured_cb) |
| 544 | wpa_s->ap_configured_cb(wpa_s->ap_configured_cb_ctx, |
| 545 | wpa_s->ap_configured_cb_data); |
| 546 | } |
| 547 | |
| 548 | |
| 549 | int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s, |
| 550 | struct wpa_ssid *ssid) |
| 551 | { |
| 552 | struct wpa_driver_associate_params params; |
| 553 | struct hostapd_iface *hapd_iface; |
| 554 | struct hostapd_config *conf; |
| 555 | size_t i; |
| 556 | |
| 557 | if (ssid->ssid == NULL || ssid->ssid_len == 0) { |
| 558 | wpa_printf(MSG_ERROR, "No SSID configured for AP mode"); |
| 559 | return -1; |
| 560 | } |
| 561 | |
| 562 | wpa_supplicant_ap_deinit(wpa_s); |
| 563 | |
| 564 | wpa_printf(MSG_DEBUG, "Setting up AP (SSID='%s')", |
| 565 | wpa_ssid_txt(ssid->ssid, ssid->ssid_len)); |
| 566 | |
| 567 | os_memset(¶ms, 0, sizeof(params)); |
| 568 | params.ssid = ssid->ssid; |
| 569 | params.ssid_len = ssid->ssid_len; |
| 570 | switch (ssid->mode) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 571 | case WPAS_MODE_AP: |
| 572 | case WPAS_MODE_P2P_GO: |
| 573 | case WPAS_MODE_P2P_GROUP_FORMATION: |
| 574 | params.mode = IEEE80211_MODE_AP; |
| 575 | break; |
Dmitry Shmidt | 3c47937 | 2014-02-04 10:50:36 -0800 | [diff] [blame] | 576 | default: |
| 577 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 578 | } |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 579 | if (ssid->frequency == 0) |
| 580 | ssid->frequency = 2462; /* default channel 11 */ |
Dmitry Shmidt | 9ead16e | 2014-10-07 13:15:23 -0700 | [diff] [blame] | 581 | params.freq.freq = ssid->frequency; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 582 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 583 | params.wpa_proto = ssid->proto; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 584 | if (ssid->key_mgmt & WPA_KEY_MGMT_PSK) |
| 585 | wpa_s->key_mgmt = WPA_KEY_MGMT_PSK; |
| 586 | else |
| 587 | wpa_s->key_mgmt = WPA_KEY_MGMT_NONE; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 588 | params.key_mgmt_suite = wpa_s->key_mgmt; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 589 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 590 | wpa_s->pairwise_cipher = wpa_pick_pairwise_cipher(ssid->pairwise_cipher, |
| 591 | 1); |
| 592 | if (wpa_s->pairwise_cipher < 0) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 593 | wpa_printf(MSG_WARNING, "WPA: Failed to select pairwise " |
| 594 | "cipher."); |
| 595 | return -1; |
| 596 | } |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 597 | params.pairwise_suite = wpa_s->pairwise_cipher; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 598 | params.group_suite = params.pairwise_suite; |
| 599 | |
| 600 | #ifdef CONFIG_P2P |
| 601 | if (ssid->mode == WPAS_MODE_P2P_GO || |
| 602 | ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) |
| 603 | params.p2p = 1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 604 | #endif /* CONFIG_P2P */ |
| 605 | |
| 606 | if (wpa_s->parent->set_ap_uapsd) |
| 607 | params.uapsd = wpa_s->parent->ap_uapsd; |
Dmitry Shmidt | ec58b16 | 2014-02-19 12:44:18 -0800 | [diff] [blame] | 608 | else if (params.p2p && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_UAPSD)) |
| 609 | params.uapsd = 1; /* mandatory for P2P GO */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 610 | else |
| 611 | params.uapsd = -1; |
| 612 | |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 613 | if (ieee80211_is_dfs(params.freq.freq)) |
| 614 | params.freq.freq = 0; /* set channel after CAC */ |
| 615 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 616 | if (wpa_drv_associate(wpa_s, ¶ms) < 0) { |
| 617 | wpa_msg(wpa_s, MSG_INFO, "Failed to start AP functionality"); |
| 618 | return -1; |
| 619 | } |
| 620 | |
| 621 | wpa_s->ap_iface = hapd_iface = os_zalloc(sizeof(*wpa_s->ap_iface)); |
| 622 | if (hapd_iface == NULL) |
| 623 | return -1; |
| 624 | hapd_iface->owner = wpa_s; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 625 | hapd_iface->drv_flags = wpa_s->drv_flags; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 626 | hapd_iface->smps_modes = wpa_s->drv_smps_modes; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 627 | hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads; |
Dmitry Shmidt | 444d567 | 2013-04-01 13:08:44 -0700 | [diff] [blame] | 628 | hapd_iface->extended_capa = wpa_s->extended_capa; |
| 629 | hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask; |
| 630 | hapd_iface->extended_capa_len = wpa_s->extended_capa_len; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 631 | |
| 632 | wpa_s->ap_iface->conf = conf = hostapd_config_defaults(); |
| 633 | if (conf == NULL) { |
| 634 | wpa_supplicant_ap_deinit(wpa_s); |
| 635 | return -1; |
| 636 | } |
| 637 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 638 | os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params, |
| 639 | wpa_s->conf->wmm_ac_params, |
| 640 | sizeof(wpa_s->conf->wmm_ac_params)); |
| 641 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 642 | if (params.uapsd > 0) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 643 | conf->bss[0]->wmm_enabled = 1; |
| 644 | conf->bss[0]->wmm_uapsd = 1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 645 | } |
| 646 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 647 | if (wpa_supplicant_conf_ap(wpa_s, ssid, conf)) { |
| 648 | wpa_printf(MSG_ERROR, "Failed to create AP configuration"); |
| 649 | wpa_supplicant_ap_deinit(wpa_s); |
| 650 | return -1; |
| 651 | } |
| 652 | |
| 653 | #ifdef CONFIG_P2P |
| 654 | if (ssid->mode == WPAS_MODE_P2P_GO) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 655 | conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 656 | else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 657 | conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 658 | P2P_GROUP_FORMATION; |
| 659 | #endif /* CONFIG_P2P */ |
| 660 | |
| 661 | hapd_iface->num_bss = conf->num_bss; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 662 | hapd_iface->bss = os_calloc(conf->num_bss, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 663 | sizeof(struct hostapd_data *)); |
| 664 | if (hapd_iface->bss == NULL) { |
| 665 | wpa_supplicant_ap_deinit(wpa_s); |
| 666 | return -1; |
| 667 | } |
| 668 | |
| 669 | for (i = 0; i < conf->num_bss; i++) { |
| 670 | hapd_iface->bss[i] = |
| 671 | hostapd_alloc_bss_data(hapd_iface, conf, |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 672 | conf->bss[i]); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 673 | if (hapd_iface->bss[i] == NULL) { |
| 674 | wpa_supplicant_ap_deinit(wpa_s); |
| 675 | return -1; |
| 676 | } |
| 677 | |
| 678 | hapd_iface->bss[i]->msg_ctx = wpa_s; |
Dmitry Shmidt | 497c1d5 | 2011-07-21 15:19:46 -0700 | [diff] [blame] | 679 | hapd_iface->bss[i]->msg_ctx_parent = wpa_s->parent; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 680 | hapd_iface->bss[i]->public_action_cb = ap_public_action_rx; |
| 681 | hapd_iface->bss[i]->public_action_cb_ctx = wpa_s; |
| 682 | hapd_iface->bss[i]->vendor_action_cb = ap_vendor_action_rx; |
| 683 | hapd_iface->bss[i]->vendor_action_cb_ctx = wpa_s; |
| 684 | hostapd_register_probereq_cb(hapd_iface->bss[i], |
| 685 | ap_probe_req_rx, wpa_s); |
| 686 | hapd_iface->bss[i]->wps_reg_success_cb = ap_wps_reg_success_cb; |
| 687 | hapd_iface->bss[i]->wps_reg_success_cb_ctx = wpa_s; |
| 688 | hapd_iface->bss[i]->wps_event_cb = ap_wps_event_cb; |
| 689 | hapd_iface->bss[i]->wps_event_cb_ctx = wpa_s; |
| 690 | hapd_iface->bss[i]->sta_authorized_cb = ap_sta_authorized_cb; |
| 691 | hapd_iface->bss[i]->sta_authorized_cb_ctx = wpa_s; |
| 692 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 693 | hapd_iface->bss[i]->new_psk_cb = ap_new_psk_cb; |
| 694 | hapd_iface->bss[i]->new_psk_cb_ctx = wpa_s; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 695 | hapd_iface->bss[i]->p2p = wpa_s->global->p2p; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 696 | hapd_iface->bss[i]->p2p_group = wpas_p2p_group_init(wpa_s, |
| 697 | ssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 698 | #endif /* CONFIG_P2P */ |
| 699 | hapd_iface->bss[i]->setup_complete_cb = wpas_ap_configured_cb; |
| 700 | hapd_iface->bss[i]->setup_complete_cb_ctx = wpa_s; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 701 | #ifdef CONFIG_TESTING_OPTIONS |
| 702 | hapd_iface->bss[i]->ext_eapol_frame_io = |
| 703 | wpa_s->ext_eapol_frame_io; |
| 704 | #endif /* CONFIG_TESTING_OPTIONS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN); |
| 708 | hapd_iface->bss[0]->driver = wpa_s->driver; |
| 709 | hapd_iface->bss[0]->drv_priv = wpa_s->drv_priv; |
| 710 | |
| 711 | wpa_s->current_ssid = ssid; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 712 | eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 713 | os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN); |
| 714 | wpa_s->assoc_freq = ssid->frequency; |
| 715 | |
| 716 | if (hostapd_setup_interface(wpa_s->ap_iface)) { |
| 717 | wpa_printf(MSG_ERROR, "Failed to initialize AP interface"); |
| 718 | wpa_supplicant_ap_deinit(wpa_s); |
| 719 | return -1; |
| 720 | } |
| 721 | |
| 722 | return 0; |
| 723 | } |
| 724 | |
| 725 | |
| 726 | void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s) |
| 727 | { |
| 728 | #ifdef CONFIG_WPS |
| 729 | eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL); |
| 730 | #endif /* CONFIG_WPS */ |
| 731 | |
| 732 | if (wpa_s->ap_iface == NULL) |
| 733 | return; |
| 734 | |
| 735 | wpa_s->current_ssid = NULL; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 736 | eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 737 | wpa_s->assoc_freq = 0; |
Dmitry Shmidt | 43cb578 | 2014-06-16 16:23:22 -0700 | [diff] [blame] | 738 | wpas_p2p_ap_deinit(wpa_s); |
Dmitry Shmidt | a38abf9 | 2014-03-06 13:38:44 -0800 | [diff] [blame] | 739 | wpa_s->ap_iface->driver_ap_teardown = |
| 740 | !!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT); |
| 741 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 742 | hostapd_interface_deinit(wpa_s->ap_iface); |
| 743 | hostapd_interface_free(wpa_s->ap_iface); |
| 744 | wpa_s->ap_iface = NULL; |
| 745 | wpa_drv_deinit_ap(wpa_s); |
Dmitry Shmidt | f73259c | 2015-03-17 11:00:54 -0700 | [diff] [blame] | 746 | wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR |
| 747 | " reason=%d locally_generated=1", |
| 748 | MAC2STR(wpa_s->own_addr), WLAN_REASON_DEAUTH_LEAVING); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | |
| 752 | void ap_tx_status(void *ctx, const u8 *addr, |
| 753 | const u8 *buf, size_t len, int ack) |
| 754 | { |
| 755 | #ifdef NEED_AP_MLME |
| 756 | struct wpa_supplicant *wpa_s = ctx; |
| 757 | hostapd_tx_status(wpa_s->ap_iface->bss[0], addr, buf, len, ack); |
| 758 | #endif /* NEED_AP_MLME */ |
| 759 | } |
| 760 | |
| 761 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 762 | void ap_eapol_tx_status(void *ctx, const u8 *dst, |
| 763 | const u8 *data, size_t len, int ack) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 764 | { |
| 765 | #ifdef NEED_AP_MLME |
| 766 | struct wpa_supplicant *wpa_s = ctx; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 767 | if (!wpa_s->ap_iface) |
| 768 | return; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 769 | hostapd_tx_status(wpa_s->ap_iface->bss[0], dst, data, len, ack); |
| 770 | #endif /* NEED_AP_MLME */ |
| 771 | } |
| 772 | |
| 773 | |
| 774 | void ap_client_poll_ok(void *ctx, const u8 *addr) |
| 775 | { |
| 776 | #ifdef NEED_AP_MLME |
| 777 | struct wpa_supplicant *wpa_s = ctx; |
| 778 | if (wpa_s->ap_iface) |
| 779 | hostapd_client_poll_ok(wpa_s->ap_iface->bss[0], addr); |
| 780 | #endif /* NEED_AP_MLME */ |
| 781 | } |
| 782 | |
| 783 | |
| 784 | void ap_rx_from_unknown_sta(void *ctx, const u8 *addr, int wds) |
| 785 | { |
| 786 | #ifdef NEED_AP_MLME |
| 787 | struct wpa_supplicant *wpa_s = ctx; |
| 788 | ieee802_11_rx_from_unknown(wpa_s->ap_iface->bss[0], addr, wds); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 789 | #endif /* NEED_AP_MLME */ |
| 790 | } |
| 791 | |
| 792 | |
| 793 | void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt) |
| 794 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 795 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 796 | struct wpa_supplicant *wpa_s = ctx; |
| 797 | struct hostapd_frame_info fi; |
| 798 | os_memset(&fi, 0, sizeof(fi)); |
| 799 | fi.datarate = rx_mgmt->datarate; |
| 800 | fi.ssi_signal = rx_mgmt->ssi_signal; |
| 801 | ieee802_11_mgmt(wpa_s->ap_iface->bss[0], rx_mgmt->frame, |
| 802 | rx_mgmt->frame_len, &fi); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 803 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | |
| 807 | void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok) |
| 808 | { |
| 809 | #ifdef NEED_AP_MLME |
| 810 | struct wpa_supplicant *wpa_s = ctx; |
| 811 | ieee802_11_mgmt_cb(wpa_s->ap_iface->bss[0], buf, len, stype, ok); |
| 812 | #endif /* NEED_AP_MLME */ |
| 813 | } |
| 814 | |
| 815 | |
| 816 | void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s, |
| 817 | const u8 *src_addr, const u8 *buf, size_t len) |
| 818 | { |
| 819 | ieee802_1x_receive(wpa_s->ap_iface->bss[0], src_addr, buf, len); |
| 820 | } |
| 821 | |
| 822 | |
| 823 | #ifdef CONFIG_WPS |
| 824 | |
| 825 | int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid, |
| 826 | const u8 *p2p_dev_addr) |
| 827 | { |
| 828 | if (!wpa_s->ap_iface) |
| 829 | return -1; |
| 830 | return hostapd_wps_button_pushed(wpa_s->ap_iface->bss[0], |
| 831 | p2p_dev_addr); |
| 832 | } |
| 833 | |
| 834 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 835 | int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s) |
| 836 | { |
| 837 | struct wps_registrar *reg; |
| 838 | int reg_sel = 0, wps_sta = 0; |
| 839 | |
| 840 | if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]->wps) |
| 841 | return -1; |
| 842 | |
| 843 | reg = wpa_s->ap_iface->bss[0]->wps->registrar; |
| 844 | reg_sel = wps_registrar_wps_cancel(reg); |
| 845 | wps_sta = ap_for_each_sta(wpa_s->ap_iface->bss[0], |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 846 | ap_sta_wps_cancel, NULL); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 847 | |
| 848 | if (!reg_sel && !wps_sta) { |
| 849 | wpa_printf(MSG_DEBUG, "No WPS operation in progress at this " |
| 850 | "time"); |
| 851 | return -1; |
| 852 | } |
| 853 | |
| 854 | /* |
| 855 | * There are 2 cases to return wps cancel as success: |
| 856 | * 1. When wps cancel was initiated but no connection has been |
| 857 | * established with client yet. |
| 858 | * 2. Client is in the middle of exchanging WPS messages. |
| 859 | */ |
| 860 | |
| 861 | return 0; |
| 862 | } |
| 863 | |
| 864 | |
| 865 | int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid, |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 866 | const char *pin, char *buf, size_t buflen, |
| 867 | int timeout) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 868 | { |
| 869 | int ret, ret_len = 0; |
| 870 | |
| 871 | if (!wpa_s->ap_iface) |
| 872 | return -1; |
| 873 | |
| 874 | if (pin == NULL) { |
| 875 | unsigned int rpin = wps_generate_pin(); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 876 | ret_len = os_snprintf(buf, buflen, "%08d", rpin); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 877 | if (os_snprintf_error(buflen, ret_len)) |
| 878 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 879 | pin = buf; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 880 | } else if (buf) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 881 | ret_len = os_snprintf(buf, buflen, "%s", pin); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 882 | if (os_snprintf_error(buflen, ret_len)) |
| 883 | return -1; |
| 884 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 885 | |
| 886 | ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], bssid, "any", pin, |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 887 | timeout); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 888 | if (ret) |
| 889 | return -1; |
| 890 | return ret_len; |
| 891 | } |
| 892 | |
| 893 | |
| 894 | static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx) |
| 895 | { |
| 896 | struct wpa_supplicant *wpa_s = eloop_data; |
| 897 | wpa_printf(MSG_DEBUG, "WPS: AP PIN timed out"); |
| 898 | wpas_wps_ap_pin_disable(wpa_s); |
| 899 | } |
| 900 | |
| 901 | |
| 902 | static void wpas_wps_ap_pin_enable(struct wpa_supplicant *wpa_s, int timeout) |
| 903 | { |
| 904 | struct hostapd_data *hapd; |
| 905 | |
| 906 | if (wpa_s->ap_iface == NULL) |
| 907 | return; |
| 908 | hapd = wpa_s->ap_iface->bss[0]; |
| 909 | wpa_printf(MSG_DEBUG, "WPS: Enabling AP PIN (timeout=%d)", timeout); |
| 910 | hapd->ap_pin_failures = 0; |
| 911 | eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL); |
| 912 | if (timeout > 0) |
| 913 | eloop_register_timeout(timeout, 0, |
| 914 | wpas_wps_ap_pin_timeout, wpa_s, NULL); |
| 915 | } |
| 916 | |
| 917 | |
| 918 | void wpas_wps_ap_pin_disable(struct wpa_supplicant *wpa_s) |
| 919 | { |
| 920 | struct hostapd_data *hapd; |
| 921 | |
| 922 | if (wpa_s->ap_iface == NULL) |
| 923 | return; |
| 924 | wpa_printf(MSG_DEBUG, "WPS: Disabling AP PIN"); |
| 925 | hapd = wpa_s->ap_iface->bss[0]; |
| 926 | os_free(hapd->conf->ap_pin); |
| 927 | hapd->conf->ap_pin = NULL; |
| 928 | eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL); |
| 929 | } |
| 930 | |
| 931 | |
| 932 | const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout) |
| 933 | { |
| 934 | struct hostapd_data *hapd; |
| 935 | unsigned int pin; |
| 936 | char pin_txt[9]; |
| 937 | |
| 938 | if (wpa_s->ap_iface == NULL) |
| 939 | return NULL; |
| 940 | hapd = wpa_s->ap_iface->bss[0]; |
| 941 | pin = wps_generate_pin(); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 942 | os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 943 | os_free(hapd->conf->ap_pin); |
| 944 | hapd->conf->ap_pin = os_strdup(pin_txt); |
| 945 | if (hapd->conf->ap_pin == NULL) |
| 946 | return NULL; |
| 947 | wpas_wps_ap_pin_enable(wpa_s, timeout); |
| 948 | |
| 949 | return hapd->conf->ap_pin; |
| 950 | } |
| 951 | |
| 952 | |
| 953 | const char * wpas_wps_ap_pin_get(struct wpa_supplicant *wpa_s) |
| 954 | { |
| 955 | struct hostapd_data *hapd; |
| 956 | if (wpa_s->ap_iface == NULL) |
| 957 | return NULL; |
| 958 | hapd = wpa_s->ap_iface->bss[0]; |
| 959 | return hapd->conf->ap_pin; |
| 960 | } |
| 961 | |
| 962 | |
| 963 | int wpas_wps_ap_pin_set(struct wpa_supplicant *wpa_s, const char *pin, |
| 964 | int timeout) |
| 965 | { |
| 966 | struct hostapd_data *hapd; |
| 967 | char pin_txt[9]; |
| 968 | int ret; |
| 969 | |
| 970 | if (wpa_s->ap_iface == NULL) |
| 971 | return -1; |
| 972 | hapd = wpa_s->ap_iface->bss[0]; |
| 973 | ret = os_snprintf(pin_txt, sizeof(pin_txt), "%s", pin); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 974 | if (os_snprintf_error(sizeof(pin_txt), ret)) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 975 | return -1; |
| 976 | os_free(hapd->conf->ap_pin); |
| 977 | hapd->conf->ap_pin = os_strdup(pin_txt); |
| 978 | if (hapd->conf->ap_pin == NULL) |
| 979 | return -1; |
| 980 | wpas_wps_ap_pin_enable(wpa_s, timeout); |
| 981 | |
| 982 | return 0; |
| 983 | } |
| 984 | |
| 985 | |
| 986 | void wpa_supplicant_ap_pwd_auth_fail(struct wpa_supplicant *wpa_s) |
| 987 | { |
| 988 | struct hostapd_data *hapd; |
| 989 | |
| 990 | if (wpa_s->ap_iface == NULL) |
| 991 | return; |
| 992 | hapd = wpa_s->ap_iface->bss[0]; |
| 993 | |
| 994 | /* |
| 995 | * Registrar failed to prove its knowledge of the AP PIN. Disable AP |
| 996 | * PIN if this happens multiple times to slow down brute force attacks. |
| 997 | */ |
| 998 | hapd->ap_pin_failures++; |
| 999 | wpa_printf(MSG_DEBUG, "WPS: AP PIN authentication failure number %u", |
| 1000 | hapd->ap_pin_failures); |
| 1001 | if (hapd->ap_pin_failures < 3) |
| 1002 | return; |
| 1003 | |
| 1004 | wpa_printf(MSG_DEBUG, "WPS: Disable AP PIN"); |
| 1005 | hapd->ap_pin_failures = 0; |
| 1006 | os_free(hapd->conf->ap_pin); |
| 1007 | hapd->conf->ap_pin = NULL; |
| 1008 | } |
| 1009 | |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 1010 | |
| 1011 | #ifdef CONFIG_WPS_NFC |
| 1012 | |
| 1013 | struct wpabuf * wpas_ap_wps_nfc_config_token(struct wpa_supplicant *wpa_s, |
| 1014 | int ndef) |
| 1015 | { |
| 1016 | struct hostapd_data *hapd; |
| 1017 | |
| 1018 | if (wpa_s->ap_iface == NULL) |
| 1019 | return NULL; |
| 1020 | hapd = wpa_s->ap_iface->bss[0]; |
| 1021 | return hostapd_wps_nfc_config_token(hapd, ndef); |
| 1022 | } |
| 1023 | |
| 1024 | |
| 1025 | struct wpabuf * wpas_ap_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s, |
| 1026 | int ndef) |
| 1027 | { |
| 1028 | struct hostapd_data *hapd; |
| 1029 | |
| 1030 | if (wpa_s->ap_iface == NULL) |
| 1031 | return NULL; |
| 1032 | hapd = wpa_s->ap_iface->bss[0]; |
| 1033 | return hostapd_wps_nfc_hs_cr(hapd, ndef); |
| 1034 | } |
| 1035 | |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 1036 | |
| 1037 | int wpas_ap_wps_nfc_report_handover(struct wpa_supplicant *wpa_s, |
| 1038 | const struct wpabuf *req, |
| 1039 | const struct wpabuf *sel) |
| 1040 | { |
| 1041 | struct hostapd_data *hapd; |
| 1042 | |
| 1043 | if (wpa_s->ap_iface == NULL) |
| 1044 | return -1; |
| 1045 | hapd = wpa_s->ap_iface->bss[0]; |
| 1046 | return hostapd_wps_nfc_report_handover(hapd, req, sel); |
| 1047 | } |
| 1048 | |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 1049 | #endif /* CONFIG_WPS_NFC */ |
| 1050 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1051 | #endif /* CONFIG_WPS */ |
| 1052 | |
| 1053 | |
| 1054 | #ifdef CONFIG_CTRL_IFACE |
| 1055 | |
| 1056 | int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s, |
| 1057 | char *buf, size_t buflen) |
| 1058 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1059 | struct hostapd_data *hapd; |
| 1060 | |
| 1061 | if (wpa_s->ap_iface) |
| 1062 | hapd = wpa_s->ap_iface->bss[0]; |
| 1063 | else if (wpa_s->ifmsh) |
| 1064 | hapd = wpa_s->ifmsh->bss[0]; |
| 1065 | else |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1066 | return -1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1067 | return hostapd_ctrl_iface_sta_first(hapd, buf, buflen); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | |
| 1071 | int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr, |
| 1072 | char *buf, size_t buflen) |
| 1073 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1074 | struct hostapd_data *hapd; |
| 1075 | |
| 1076 | if (wpa_s->ap_iface) |
| 1077 | hapd = wpa_s->ap_iface->bss[0]; |
| 1078 | else if (wpa_s->ifmsh) |
| 1079 | hapd = wpa_s->ifmsh->bss[0]; |
| 1080 | else |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1081 | return -1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1082 | return hostapd_ctrl_iface_sta(hapd, txtaddr, buf, buflen); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | |
| 1086 | int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr, |
| 1087 | char *buf, size_t buflen) |
| 1088 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1089 | struct hostapd_data *hapd; |
| 1090 | |
| 1091 | if (wpa_s->ap_iface) |
| 1092 | hapd = wpa_s->ap_iface->bss[0]; |
| 1093 | else if (wpa_s->ifmsh) |
| 1094 | hapd = wpa_s->ifmsh->bss[0]; |
| 1095 | else |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1096 | return -1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1097 | return hostapd_ctrl_iface_sta_next(hapd, txtaddr, buf, buflen); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1101 | int ap_ctrl_iface_sta_disassociate(struct wpa_supplicant *wpa_s, |
| 1102 | const char *txtaddr) |
| 1103 | { |
| 1104 | if (wpa_s->ap_iface == NULL) |
| 1105 | return -1; |
| 1106 | return hostapd_ctrl_iface_disassociate(wpa_s->ap_iface->bss[0], |
| 1107 | txtaddr); |
| 1108 | } |
| 1109 | |
| 1110 | |
| 1111 | int ap_ctrl_iface_sta_deauthenticate(struct wpa_supplicant *wpa_s, |
| 1112 | const char *txtaddr) |
| 1113 | { |
| 1114 | if (wpa_s->ap_iface == NULL) |
| 1115 | return -1; |
| 1116 | return hostapd_ctrl_iface_deauthenticate(wpa_s->ap_iface->bss[0], |
| 1117 | txtaddr); |
| 1118 | } |
| 1119 | |
| 1120 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1121 | int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf, |
| 1122 | size_t buflen, int verbose) |
| 1123 | { |
| 1124 | char *pos = buf, *end = buf + buflen; |
| 1125 | int ret; |
| 1126 | struct hostapd_bss_config *conf; |
| 1127 | |
| 1128 | if (wpa_s->ap_iface == NULL) |
| 1129 | return -1; |
| 1130 | |
| 1131 | conf = wpa_s->ap_iface->bss[0]->conf; |
| 1132 | if (conf->wpa == 0) |
| 1133 | return 0; |
| 1134 | |
| 1135 | ret = os_snprintf(pos, end - pos, |
| 1136 | "pairwise_cipher=%s\n" |
| 1137 | "group_cipher=%s\n" |
| 1138 | "key_mgmt=%s\n", |
| 1139 | wpa_cipher_txt(conf->rsn_pairwise), |
| 1140 | wpa_cipher_txt(conf->wpa_group), |
| 1141 | wpa_key_mgmt_txt(conf->wpa_key_mgmt, |
| 1142 | conf->wpa)); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1143 | if (os_snprintf_error(end - pos, ret)) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1144 | return pos - buf; |
| 1145 | pos += ret; |
| 1146 | return pos - buf; |
| 1147 | } |
| 1148 | |
| 1149 | #endif /* CONFIG_CTRL_IFACE */ |
| 1150 | |
| 1151 | |
| 1152 | int wpa_supplicant_ap_update_beacon(struct wpa_supplicant *wpa_s) |
| 1153 | { |
| 1154 | struct hostapd_iface *iface = wpa_s->ap_iface; |
| 1155 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
| 1156 | struct hostapd_data *hapd; |
| 1157 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1158 | if (ssid == NULL || wpa_s->ap_iface == NULL || |
| 1159 | ssid->mode == WPAS_MODE_INFRA || |
| 1160 | ssid->mode == WPAS_MODE_IBSS) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1161 | return -1; |
| 1162 | |
| 1163 | #ifdef CONFIG_P2P |
| 1164 | if (ssid->mode == WPAS_MODE_P2P_GO) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1165 | iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1166 | else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1167 | iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1168 | P2P_GROUP_FORMATION; |
| 1169 | #endif /* CONFIG_P2P */ |
| 1170 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1171 | hapd = iface->bss[0]; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1172 | if (hapd->drv_priv == NULL) |
| 1173 | return -1; |
| 1174 | ieee802_11_set_beacons(iface); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1175 | hostapd_set_ap_wps_ie(hapd); |
| 1176 | |
| 1177 | return 0; |
| 1178 | } |
| 1179 | |
| 1180 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1181 | int ap_switch_channel(struct wpa_supplicant *wpa_s, |
| 1182 | struct csa_settings *settings) |
| 1183 | { |
| 1184 | #ifdef NEED_AP_MLME |
| 1185 | if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) |
| 1186 | return -1; |
| 1187 | |
| 1188 | return hostapd_switch_channel(wpa_s->ap_iface->bss[0], settings); |
| 1189 | #else /* NEED_AP_MLME */ |
| 1190 | return -1; |
| 1191 | #endif /* NEED_AP_MLME */ |
| 1192 | } |
| 1193 | |
| 1194 | |
Dmitry Shmidt | 8347444 | 2015-04-15 13:47:09 -0700 | [diff] [blame] | 1195 | #ifdef CONFIG_CTRL_IFACE |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1196 | int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos) |
| 1197 | { |
| 1198 | struct csa_settings settings; |
| 1199 | int ret = hostapd_parse_csa_settings(pos, &settings); |
| 1200 | |
| 1201 | if (ret) |
| 1202 | return ret; |
| 1203 | |
| 1204 | return ap_switch_channel(wpa_s, &settings); |
| 1205 | } |
Dmitry Shmidt | 8347444 | 2015-04-15 13:47:09 -0700 | [diff] [blame] | 1206 | #endif /* CONFIG_CTRL_IFACE */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1207 | |
| 1208 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1209 | void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht, |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1210 | int offset, int width, int cf1, int cf2) |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1211 | { |
| 1212 | if (!wpa_s->ap_iface) |
| 1213 | return; |
| 1214 | |
| 1215 | wpa_s->assoc_freq = freq; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 1216 | if (wpa_s->current_ssid) |
| 1217 | wpa_s->current_ssid->frequency = freq; |
| 1218 | hostapd_event_ch_switch(wpa_s->ap_iface->bss[0], freq, ht, |
| 1219 | offset, width, cf1, cf2); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1223 | int wpa_supplicant_ap_mac_addr_filter(struct wpa_supplicant *wpa_s, |
| 1224 | const u8 *addr) |
| 1225 | { |
| 1226 | struct hostapd_data *hapd; |
| 1227 | struct hostapd_bss_config *conf; |
| 1228 | |
| 1229 | if (!wpa_s->ap_iface) |
| 1230 | return -1; |
| 1231 | |
| 1232 | if (addr) |
| 1233 | wpa_printf(MSG_DEBUG, "AP: Set MAC address filter: " MACSTR, |
| 1234 | MAC2STR(addr)); |
| 1235 | else |
| 1236 | wpa_printf(MSG_DEBUG, "AP: Clear MAC address filter"); |
| 1237 | |
| 1238 | hapd = wpa_s->ap_iface->bss[0]; |
| 1239 | conf = hapd->conf; |
| 1240 | |
| 1241 | os_free(conf->accept_mac); |
| 1242 | conf->accept_mac = NULL; |
| 1243 | conf->num_accept_mac = 0; |
| 1244 | os_free(conf->deny_mac); |
| 1245 | conf->deny_mac = NULL; |
| 1246 | conf->num_deny_mac = 0; |
| 1247 | |
| 1248 | if (addr == NULL) { |
| 1249 | conf->macaddr_acl = ACCEPT_UNLESS_DENIED; |
| 1250 | return 0; |
| 1251 | } |
| 1252 | |
| 1253 | conf->macaddr_acl = DENY_UNLESS_ACCEPTED; |
| 1254 | conf->accept_mac = os_zalloc(sizeof(struct mac_acl_entry)); |
| 1255 | if (conf->accept_mac == NULL) |
| 1256 | return -1; |
| 1257 | os_memcpy(conf->accept_mac[0].addr, addr, ETH_ALEN); |
| 1258 | conf->num_accept_mac = 1; |
| 1259 | |
| 1260 | return 0; |
| 1261 | } |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 1262 | |
| 1263 | |
| 1264 | #ifdef CONFIG_WPS_NFC |
| 1265 | int wpas_ap_wps_add_nfc_pw(struct wpa_supplicant *wpa_s, u16 pw_id, |
| 1266 | const struct wpabuf *pw, const u8 *pubkey_hash) |
| 1267 | { |
| 1268 | struct hostapd_data *hapd; |
| 1269 | struct wps_context *wps; |
| 1270 | |
| 1271 | if (!wpa_s->ap_iface) |
| 1272 | return -1; |
| 1273 | hapd = wpa_s->ap_iface->bss[0]; |
| 1274 | wps = hapd->wps; |
| 1275 | |
| 1276 | if (wpa_s->parent->conf->wps_nfc_dh_pubkey == NULL || |
| 1277 | wpa_s->parent->conf->wps_nfc_dh_privkey == NULL) { |
| 1278 | wpa_printf(MSG_DEBUG, "P2P: No NFC DH key known"); |
| 1279 | return -1; |
| 1280 | } |
| 1281 | |
| 1282 | dh5_free(wps->dh_ctx); |
| 1283 | wpabuf_free(wps->dh_pubkey); |
| 1284 | wpabuf_free(wps->dh_privkey); |
| 1285 | wps->dh_privkey = wpabuf_dup( |
| 1286 | wpa_s->parent->conf->wps_nfc_dh_privkey); |
| 1287 | wps->dh_pubkey = wpabuf_dup( |
| 1288 | wpa_s->parent->conf->wps_nfc_dh_pubkey); |
| 1289 | if (wps->dh_privkey == NULL || wps->dh_pubkey == NULL) { |
| 1290 | wps->dh_ctx = NULL; |
| 1291 | wpabuf_free(wps->dh_pubkey); |
| 1292 | wps->dh_pubkey = NULL; |
| 1293 | wpabuf_free(wps->dh_privkey); |
| 1294 | wps->dh_privkey = NULL; |
| 1295 | return -1; |
| 1296 | } |
| 1297 | wps->dh_ctx = dh5_init_fixed(wps->dh_privkey, wps->dh_pubkey); |
| 1298 | if (wps->dh_ctx == NULL) |
| 1299 | return -1; |
| 1300 | |
| 1301 | return wps_registrar_add_nfc_pw_token(hapd->wps->registrar, pubkey_hash, |
| 1302 | pw_id, |
| 1303 | pw ? wpabuf_head(pw) : NULL, |
| 1304 | pw ? wpabuf_len(pw) : 0, 1); |
| 1305 | } |
| 1306 | #endif /* CONFIG_WPS_NFC */ |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1307 | |
| 1308 | |
Dmitry Shmidt | 8347444 | 2015-04-15 13:47:09 -0700 | [diff] [blame] | 1309 | #ifdef CONFIG_CTRL_IFACE |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1310 | int wpas_ap_stop_ap(struct wpa_supplicant *wpa_s) |
| 1311 | { |
| 1312 | struct hostapd_data *hapd; |
| 1313 | |
| 1314 | if (!wpa_s->ap_iface) |
| 1315 | return -1; |
| 1316 | hapd = wpa_s->ap_iface->bss[0]; |
| 1317 | return hostapd_ctrl_iface_stop_ap(hapd); |
| 1318 | } |
Dmitry Shmidt | 8347444 | 2015-04-15 13:47:09 -0700 | [diff] [blame] | 1319 | #endif /* CONFIG_CTRL_IFACE */ |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1320 | |
| 1321 | |
| 1322 | #ifdef NEED_AP_MLME |
| 1323 | void wpas_event_dfs_radar_detected(struct wpa_supplicant *wpa_s, |
| 1324 | struct dfs_event *radar) |
| 1325 | { |
| 1326 | if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) |
| 1327 | return; |
| 1328 | wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq); |
| 1329 | hostapd_dfs_radar_detected(wpa_s->ap_iface, radar->freq, |
| 1330 | radar->ht_enabled, radar->chan_offset, |
| 1331 | radar->chan_width, |
| 1332 | radar->cf1, radar->cf2); |
| 1333 | } |
| 1334 | |
| 1335 | |
| 1336 | void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s, |
| 1337 | struct dfs_event *radar) |
| 1338 | { |
| 1339 | if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) |
| 1340 | return; |
| 1341 | wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq); |
| 1342 | hostapd_dfs_start_cac(wpa_s->ap_iface, radar->freq, |
| 1343 | radar->ht_enabled, radar->chan_offset, |
| 1344 | radar->chan_width, radar->cf1, radar->cf2); |
| 1345 | } |
| 1346 | |
| 1347 | |
| 1348 | void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s, |
| 1349 | struct dfs_event *radar) |
| 1350 | { |
| 1351 | if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) |
| 1352 | return; |
| 1353 | wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq); |
| 1354 | hostapd_dfs_complete_cac(wpa_s->ap_iface, 1, radar->freq, |
| 1355 | radar->ht_enabled, radar->chan_offset, |
| 1356 | radar->chan_width, radar->cf1, radar->cf2); |
| 1357 | } |
| 1358 | |
| 1359 | |
| 1360 | void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s, |
| 1361 | struct dfs_event *radar) |
| 1362 | { |
| 1363 | if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) |
| 1364 | return; |
| 1365 | wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq); |
| 1366 | hostapd_dfs_complete_cac(wpa_s->ap_iface, 0, radar->freq, |
| 1367 | radar->ht_enabled, radar->chan_offset, |
| 1368 | radar->chan_width, radar->cf1, radar->cf2); |
| 1369 | } |
| 1370 | |
| 1371 | |
| 1372 | void wpas_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s, |
| 1373 | struct dfs_event *radar) |
| 1374 | { |
| 1375 | if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) |
| 1376 | return; |
| 1377 | wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq); |
| 1378 | hostapd_dfs_nop_finished(wpa_s->ap_iface, radar->freq, |
| 1379 | radar->ht_enabled, radar->chan_offset, |
| 1380 | radar->chan_width, radar->cf1, radar->cf2); |
| 1381 | } |
| 1382 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame^] | 1383 | |
| 1384 | |
| 1385 | void ap_periodic(struct wpa_supplicant *wpa_s) |
| 1386 | { |
| 1387 | if (wpa_s->ap_iface) |
| 1388 | hostapd_periodic_iface(wpa_s->ap_iface); |
| 1389 | } |