blob: 9a2598bd2bffb100f69808862752060e1c1e10e2 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
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 Shmidtc5ec7f52012-03-06 16:33:24 -08006 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07008 */
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 Shmidtb7b4d0e2013-08-26 12:09:05 -070017#include "eapol_supp/eapol_supp_sm.h"
Dmitry Shmidtcf32e602014-01-28 10:57:39 -080018#include "crypto/dh_group5.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070019#include "ap/hostapd.h"
20#include "ap/ap_config.h"
21#include "ap/ap_drv_ops.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080022#ifdef NEED_AP_MLME
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070023#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 Shmidt203eadb2015-03-05 14:16:04 -080029#include "ap/dfs.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070030#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
43static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx);
44#endif /* CONFIG_WPS */
45
46
Hai Shalom60840252021-02-19 19:02:11 -080047#ifdef CONFIG_P2P
Hsis-Chang Chen44b08ec2020-11-18 16:21:29 +053048static bool is_chanwidth160_supported(struct hostapd_hw_modes *mode,
49 struct hostapd_config *conf)
50{
51#ifdef CONFIG_IEEE80211AX
52 if (conf->ieee80211ax) {
53 struct he_capabilities *he_cap;
54
55 he_cap = &mode->he_capab[IEEE80211_MODE_AP];
56 if (he_cap->phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] &
57 (HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G |
58 HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G))
59 return true;
60 }
61#endif /* CONFIG_IEEE80211AX */
62 if (mode->vht_capab & (VHT_CAP_SUPP_CHAN_WIDTH_160MHZ |
63 VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ))
64 return true;
65 return false;
66}
Hai Shalom60840252021-02-19 19:02:11 -080067#endif /* CONFIG_P2P */
Hsis-Chang Chen44b08ec2020-11-18 16:21:29 +053068
69
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -070070static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070071 struct wpa_ssid *ssid,
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -070072 struct hostapd_config *conf,
73 struct hostapd_hw_modes *mode)
74{
Dmitry Shmidt21de2142014-04-08 10:50:52 -070075#ifdef CONFIG_P2P
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -070076 u8 center_chan = 0;
77 u8 channel = conf->channel;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070078#endif /* CONFIG_P2P */
Hai Shalom899fcc72020-10-19 14:38:18 -070079 u8 freq_seg_idx;
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -070080
81 if (!conf->secondary_channel)
82 goto no_vht;
83
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070084 /* Use the maximum oper channel width if it's given. */
85 if (ssid->max_oper_chwidth)
Hai Shalom899fcc72020-10-19 14:38:18 -070086 hostapd_set_oper_chwidth(conf, ssid->max_oper_chwidth);
Hai Shaloma20dcd72022-02-04 13:43:00 -080087 if (hostapd_get_oper_chwidth(conf))
88 ieee80211_freq_to_channel_ext(ssid->frequency, 0,
89 hostapd_get_oper_chwidth(conf),
90 &conf->op_class,
91 &conf->channel);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070092
Sunil8cd6f4d2022-06-28 18:40:46 +000093 if (hostapd_get_oper_chwidth(conf) == CONF_OPER_CHWIDTH_80P80MHZ) {
Hai Shalom899fcc72020-10-19 14:38:18 -070094 ieee80211_freq_to_chan(ssid->vht_center_freq2,
95 &freq_seg_idx);
96 hostapd_set_oper_centr_freq_seg1_idx(conf, freq_seg_idx);
97 }
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070098
99 if (!ssid->p2p_group) {
Hai Shalom899fcc72020-10-19 14:38:18 -0700100 if (!ssid->vht_center_freq1)
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700101 goto no_vht;
102 ieee80211_freq_to_chan(ssid->vht_center_freq1,
Hai Shalom899fcc72020-10-19 14:38:18 -0700103 &freq_seg_idx);
104 hostapd_set_oper_centr_freq_seg0_idx(conf, freq_seg_idx);
105
106 wpa_printf(MSG_DEBUG,
107 "VHT seg0 index %d and seg1 index %d for AP",
108 hostapd_get_oper_centr_freq_seg0_idx(conf),
109 hostapd_get_oper_centr_freq_seg1_idx(conf));
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700110 return;
111 }
112
113#ifdef CONFIG_P2P
Hai Shalom899fcc72020-10-19 14:38:18 -0700114 switch (hostapd_get_oper_chwidth(conf)) {
Sunil8cd6f4d2022-06-28 18:40:46 +0000115 case CONF_OPER_CHWIDTH_80MHZ:
116 case CONF_OPER_CHWIDTH_80P80MHZ:
Hai Shaloma20dcd72022-02-04 13:43:00 -0800117 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode, channel,
118 conf->op_class);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700119 wpa_printf(MSG_DEBUG,
120 "VHT center channel %u for 80 or 80+80 MHz bandwidth",
121 center_chan);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800122 break;
Sunil8cd6f4d2022-06-28 18:40:46 +0000123 case CONF_OPER_CHWIDTH_160MHZ:
Hai Shaloma20dcd72022-02-04 13:43:00 -0800124 center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel,
125 conf->op_class);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700126 wpa_printf(MSG_DEBUG,
127 "VHT center channel %u for 160 MHz bandwidth",
128 center_chan);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800129 break;
130 default:
131 /*
132 * conf->vht_oper_chwidth might not be set for non-P2P GO cases,
133 * try oper_cwidth 160 MHz first then VHT 80 MHz, if 160 MHz is
134 * not supported.
135 */
Sunil8cd6f4d2022-06-28 18:40:46 +0000136 hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_160MHZ);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800137 ieee80211_freq_to_channel_ext(ssid->frequency, 0,
138 conf->vht_oper_chwidth,
139 &conf->op_class,
140 &conf->channel);
141 center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel,
142 conf->op_class);
Hsis-Chang Chen44b08ec2020-11-18 16:21:29 +0530143 if (center_chan && is_chanwidth160_supported(mode, conf)) {
Roshan Pius3a1667e2018-07-03 15:17:14 -0700144 wpa_printf(MSG_DEBUG,
145 "VHT center channel %u for auto-selected 160 MHz bandwidth",
146 center_chan);
147 } else {
Sunil8cd6f4d2022-06-28 18:40:46 +0000148 hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_80MHZ);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800149 ieee80211_freq_to_channel_ext(ssid->frequency, 0,
150 conf->vht_oper_chwidth,
151 &conf->op_class,
152 &conf->channel);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800153 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800154 channel,
155 conf->op_class);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700156 wpa_printf(MSG_DEBUG,
157 "VHT center channel %u for auto-selected 80 MHz bandwidth",
158 center_chan);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800159 }
160 break;
161 }
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700162 if (!center_chan)
163 goto no_vht;
164
Hai Shalom899fcc72020-10-19 14:38:18 -0700165 hostapd_set_oper_centr_freq_seg0_idx(conf, center_chan);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700166 wpa_printf(MSG_DEBUG, "VHT seg0 index %d for P2P GO",
Hai Shalom899fcc72020-10-19 14:38:18 -0700167 hostapd_get_oper_centr_freq_seg0_idx(conf));
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700168 return;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700169#endif /* CONFIG_P2P */
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700170
171no_vht:
Roshan Pius3a1667e2018-07-03 15:17:14 -0700172 wpa_printf(MSG_DEBUG,
173 "No VHT higher bandwidth support for the selected channel %d",
174 conf->channel);
Hai Shalom899fcc72020-10-19 14:38:18 -0700175 hostapd_set_oper_centr_freq_seg0_idx(
176 conf, conf->channel + conf->secondary_channel * 2);
Sunil8cd6f4d2022-06-28 18:40:46 +0000177 hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_USE_HT);
Sunilaa7ae2b2022-07-19 00:04:20 +0000178 ieee80211_freq_to_channel_ext(ssid->frequency, 0,
Sunil Ravi89eba102022-09-13 21:04:37 -0700179 conf->vht_oper_chwidth,
180 &conf->op_class, &conf->channel);
Hai Shalom899fcc72020-10-19 14:38:18 -0700181}
182
183
184static struct hostapd_hw_modes *
185wpa_supplicant_find_hw_mode(struct wpa_supplicant *wpa_s,
186 enum hostapd_hw_mode hw_mode)
187{
188 struct hostapd_hw_modes *mode = NULL;
189 int i;
190
191 for (i = 0; i < wpa_s->hw.num_modes; i++) {
192 if (wpa_s->hw.modes[i].mode == hw_mode) {
193 mode = &wpa_s->hw.modes[i];
194 break;
195 }
196 }
197
198 return mode;
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700199}
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700200
201
Hai Shaloma20dcd72022-02-04 13:43:00 -0800202#ifdef CONFIG_P2P
203
204static int get_max_oper_chwidth_6ghz(int chwidth)
205{
206 switch (chwidth) {
Sunil8cd6f4d2022-06-28 18:40:46 +0000207 case CONF_OPER_CHWIDTH_USE_HT:
Hai Shaloma20dcd72022-02-04 13:43:00 -0800208 return 20;
Sunil8cd6f4d2022-06-28 18:40:46 +0000209 case CONF_OPER_CHWIDTH_40MHZ_6GHZ:
Hai Shaloma20dcd72022-02-04 13:43:00 -0800210 return 40;
Sunil8cd6f4d2022-06-28 18:40:46 +0000211 case CONF_OPER_CHWIDTH_80MHZ:
Hai Shaloma20dcd72022-02-04 13:43:00 -0800212 return 80;
Sunil8cd6f4d2022-06-28 18:40:46 +0000213 case CONF_OPER_CHWIDTH_80P80MHZ:
214 case CONF_OPER_CHWIDTH_160MHZ:
Hai Shaloma20dcd72022-02-04 13:43:00 -0800215 return 160;
216 default:
217 return 0;
218 }
219}
220
221
222static void wpas_conf_ap_he_6ghz(struct wpa_supplicant *wpa_s,
223 struct hostapd_hw_modes *mode,
224 struct wpa_ssid *ssid,
225 struct hostapd_config *conf)
226{
227 bool is_chanwidth_40_80, is_chanwidth_160;
228 int he_chanwidth;
229
230 he_chanwidth =
231 mode->he_capab[wpas_mode_to_ieee80211_mode(
232 ssid->mode)].phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX];
233 is_chanwidth_40_80 = he_chanwidth &
234 HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G;
235 is_chanwidth_160 = he_chanwidth &
236 HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
237
238 wpa_printf(MSG_DEBUG,
239 "Enable HE support (p2p_group=%d he_chwidth_cap=%d)",
240 ssid->p2p_group, he_chanwidth);
241
242 if (mode->he_capab[wpas_mode_to_ieee80211_mode(
243 ssid->mode)].he_supported &&
244 ssid->he)
245 conf->ieee80211ax = 1;
246
247 if (is_chanwidth_40_80 && ssid->p2p_group &&
248 get_max_oper_chwidth_6ghz(ssid->max_oper_chwidth) >= 40) {
249 conf->secondary_channel =
250 wpas_p2p_get_sec_channel_offset_40mhz(
251 wpa_s, mode, conf->channel);
252 wpa_printf(MSG_DEBUG,
253 "Secondary channel offset %d for P2P group",
254 conf->secondary_channel);
Sunil8cd6f4d2022-06-28 18:40:46 +0000255 if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_40MHZ_6GHZ)
256 ssid->max_oper_chwidth = CONF_OPER_CHWIDTH_USE_HT;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800257 }
258
259 if ((is_chanwidth_40_80 || is_chanwidth_160) && ssid->p2p_group &&
260 get_max_oper_chwidth_6ghz(ssid->max_oper_chwidth) >= 80)
261 wpas_conf_ap_vht(wpa_s, ssid, conf, mode);
262}
263
264#endif /* CONFIG_P2P */
265
266
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800267int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
268 struct wpa_ssid *ssid,
269 struct hostapd_config *conf)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700270{
Hai Shaloma20dcd72022-02-04 13:43:00 -0800271 conf->hw_mode = ieee80211_freq_to_channel_ext(ssid->frequency, 0,
Sunil8cd6f4d2022-06-28 18:40:46 +0000272 CONF_OPER_CHWIDTH_USE_HT,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800273 &conf->op_class,
274 &conf->channel);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800275 if (conf->hw_mode == NUM_HOSTAPD_MODES) {
276 wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
277 ssid->frequency);
278 return -1;
279 }
280
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700281 /*
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800282 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
283 * and a mask of allowed capabilities within conf->ht_capab.
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700284 * Using default config settings for: conf->ht_op_mode_fixed,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800285 * conf->secondary_channel, conf->require_ht
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700286 */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800287 if (wpa_s->hw.modes) {
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700288 struct hostapd_hw_modes *mode = NULL;
Hai Shalom899fcc72020-10-19 14:38:18 -0700289 int no_ht = 0;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700290
291 wpa_printf(MSG_DEBUG,
292 "Determining HT/VHT options based on driver capabilities (freq=%u chan=%u)",
293 ssid->frequency, conf->channel);
294
Hai Shaloma20dcd72022-02-04 13:43:00 -0800295 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
296 conf->hw_mode, is_6ghz_freq(ssid->frequency));
Hai Shalom899fcc72020-10-19 14:38:18 -0700297
298 /* May drop to IEEE 802.11b if the driver does not support IEEE
299 * 802.11g */
300 if (!mode && conf->hw_mode == HOSTAPD_MODE_IEEE80211G) {
301 conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
302 wpa_printf(MSG_INFO,
303 "Try downgrade to IEEE 802.11b as 802.11g is not supported by the current hardware");
304 mode = wpa_supplicant_find_hw_mode(wpa_s,
305 conf->hw_mode);
306 }
307
308 if (!mode) {
309 wpa_printf(MSG_ERROR,
310 "No match between requested and supported hw modes found");
311 return -1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700312 }
Dmitry Shmidt04949592012-07-19 12:16:46 -0700313
314#ifdef CONFIG_HT_OVERRIDES
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700315 if (ssid->disable_ht)
316 ssid->ht = 0;
317#endif /* CONFIG_HT_OVERRIDES */
318
319 if (!ssid->ht) {
Roshan Pius3a1667e2018-07-03 15:17:14 -0700320 wpa_printf(MSG_DEBUG,
321 "HT not enabled in network profile");
Dmitry Shmidt04949592012-07-19 12:16:46 -0700322 conf->ieee80211n = 0;
323 conf->ht_capab = 0;
324 no_ht = 1;
325 }
Dmitry Shmidt04949592012-07-19 12:16:46 -0700326
Hai Shaloma20dcd72022-02-04 13:43:00 -0800327 if (mode && is_6ghz_freq(ssid->frequency) &&
328 conf->hw_mode == HOSTAPD_MODE_IEEE80211A) {
Sunil Raviaf8751c2023-03-29 11:35:17 -0700329 if (mode->eht_capab[wpas_mode_to_ieee80211_mode(
330 ssid->mode)].eht_supported &&
331 ssid->eht)
332 conf->ieee80211be = 1;
333
334 if (mode->he_capab[wpas_mode_to_ieee80211_mode(
335 ssid->mode)].he_supported &&
336 ssid->he)
337 conf->ieee80211ax = 1;
338
Hai Shaloma20dcd72022-02-04 13:43:00 -0800339#ifdef CONFIG_P2P
340 wpas_conf_ap_he_6ghz(wpa_s, mode, ssid, conf);
341#endif /* CONFIG_P2P */
342 } else if (!no_ht && mode && mode->ht_capab) {
Roshan Pius3a1667e2018-07-03 15:17:14 -0700343 wpa_printf(MSG_DEBUG,
344 "Enable HT support (p2p_group=%d 11a=%d ht40_hw_capab=%d ssid->ht40=%d)",
345 ssid->p2p_group,
346 conf->hw_mode == HOSTAPD_MODE_IEEE80211A,
347 !!(mode->ht_capab &
348 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET),
349 ssid->ht40);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700350 conf->ieee80211n = 1;
Hai Shalom899fcc72020-10-19 14:38:18 -0700351
352 if (ssid->ht40 &&
353 (mode->ht_capab &
354 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
355 conf->secondary_channel = ssid->ht40;
356 else
357 conf->secondary_channel = 0;
358
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700359#ifdef CONFIG_P2P
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700360 if (ssid->p2p_group &&
361 conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700362 (mode->ht_capab &
363 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
Roshan Pius3a1667e2018-07-03 15:17:14 -0700364 ssid->ht40) {
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700365 conf->secondary_channel =
Hai Shaloma20dcd72022-02-04 13:43:00 -0800366 wpas_p2p_get_sec_channel_offset_40mhz(
367 wpa_s, mode, conf->channel);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700368 wpa_printf(MSG_DEBUG,
369 "HT secondary channel offset %d for P2P group",
370 conf->secondary_channel);
Hai Shalom60840252021-02-19 19:02:11 -0800371 } else if (ssid->p2p_group && conf->secondary_channel &&
372 conf->hw_mode != HOSTAPD_MODE_IEEE80211A) {
373 /* This ended up trying to configure invalid
374 * 2.4 GHz channels (e.g., HT40+ on channel 11)
375 * in some cases, so clear the secondary channel
376 * configuration now to avoid such cases that
377 * would lead to group formation failures. */
378 wpa_printf(MSG_DEBUG,
379 "Disable HT secondary channel for P2P group on 2.4 GHz");
380 conf->secondary_channel = 0;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700381 }
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700382#endif /* CONFIG_P2P */
383
384 if (!ssid->p2p_group &&
385 (mode->ht_capab &
Roshan Pius3a1667e2018-07-03 15:17:14 -0700386 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700387 conf->secondary_channel = ssid->ht40;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700388 wpa_printf(MSG_DEBUG,
389 "HT secondary channel offset %d for AP",
390 conf->secondary_channel);
391 }
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700392
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700393 if (conf->secondary_channel)
394 conf->ht_capab |=
395 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800396
397 /*
Hai Shaloma20dcd72022-02-04 13:43:00 -0800398 * include capabilities that won't cause issues
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800399 * to connecting stations, while leaving the current
400 * capabilities intact (currently disabled SMPS).
401 */
402 conf->ht_capab |= mode->ht_capab &
403 (HT_CAP_INFO_GREEN_FIELD |
404 HT_CAP_INFO_SHORT_GI20MHZ |
405 HT_CAP_INFO_SHORT_GI40MHZ |
406 HT_CAP_INFO_RX_STBC_MASK |
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800407 HT_CAP_INFO_TX_STBC |
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800408 HT_CAP_INFO_MAX_AMSDU_SIZE);
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700409
Hai Shalom899fcc72020-10-19 14:38:18 -0700410 /* check this before VHT, because setting oper chan
411 * width and friends is the same call for HE and VHT
412 * and checks if conf->ieee8021ax == 1 */
Sunil Raviaf8751c2023-03-29 11:35:17 -0700413 if (mode->eht_capab[wpas_mode_to_ieee80211_mode(
414 ssid->mode)].eht_supported &&
415 ssid->eht)
416 conf->ieee80211be = 1;
417
Hai Shalom899fcc72020-10-19 14:38:18 -0700418 if (mode->he_capab[wpas_mode_to_ieee80211_mode(
419 ssid->mode)].he_supported &&
420 ssid->he)
421 conf->ieee80211ax = 1;
422
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700423 if (mode->vht_capab && ssid->vht) {
424 conf->ieee80211ac = 1;
Dmitry Shmidtebd93af2017-02-21 13:40:44 -0800425 conf->vht_capab |= mode->vht_capab;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700426 wpas_conf_ap_vht(wpa_s, ssid, conf, mode);
Dmitry Shmidt68d0e3e2013-10-28 17:59:21 -0700427 }
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800428 }
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700429 }
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800430
Sunil Ravi77a0f092022-10-03 00:53:41 +0000431 if (wpa_s->p2p_go_no_pri_sec_switch) {
432 conf->no_pri_sec_switch = 1;
433 } else if (conf->secondary_channel) {
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800434 struct wpa_supplicant *iface;
435
436 for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
437 {
438 if (iface == wpa_s ||
439 iface->wpa_state < WPA_AUTHENTICATING ||
440 (int) iface->assoc_freq != ssid->frequency)
441 continue;
442
443 /*
444 * Do not allow 40 MHz co-ex PRI/SEC switch to force us
445 * to change our PRI channel since we have an existing,
446 * concurrent connection on that channel and doing
447 * multi-channel concurrency is likely to cause more
448 * harm than using different PRI/SEC selection in
449 * environment with multiple BSSes on these two channels
450 * with mixed 20 MHz or PRI channel selection.
451 */
452 conf->no_pri_sec_switch = 1;
453 }
454 }
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800455
456 return 0;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800457}
458
459
460static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
461 struct wpa_ssid *ssid,
462 struct hostapd_config *conf)
463{
464 struct hostapd_bss_config *bss = conf->bss[0];
465
466 conf->driver = wpa_s->driver;
467
468 os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));
469
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800470 if (wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf))
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800471 return -1;
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700472
Dmitry Shmidt849734c2016-05-27 09:59:01 -0700473 if (ssid->pbss > 1) {
474 wpa_printf(MSG_ERROR, "Invalid pbss value(%d) for AP mode",
475 ssid->pbss);
476 return -1;
477 }
478 bss->pbss = ssid->pbss;
479
Dmitry Shmidt014a3ff2015-12-28 13:27:49 -0800480#ifdef CONFIG_ACS
481 if (ssid->acs) {
482 /* Setting channel to 0 in order to enable ACS */
483 conf->channel = 0;
484 wpa_printf(MSG_DEBUG, "Use automatic channel selection");
485 }
486#endif /* CONFIG_ACS */
487
Roshan Pius3a1667e2018-07-03 15:17:14 -0700488 if (ieee80211_is_dfs(ssid->frequency, wpa_s->hw.modes,
489 wpa_s->hw.num_modes) && wpa_s->conf->country[0]) {
Dmitry Shmidt203eadb2015-03-05 14:16:04 -0800490 conf->ieee80211h = 1;
491 conf->ieee80211d = 1;
492 conf->country[0] = wpa_s->conf->country[0];
493 conf->country[1] = wpa_s->conf->country[1];
Paul Stewart092955c2017-02-06 09:13:09 -0800494 conf->country[2] = ' ';
Dmitry Shmidt203eadb2015-03-05 14:16:04 -0800495 }
496
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700497#ifdef CONFIG_P2P
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700498 if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G &&
499 (ssid->mode == WPAS_MODE_P2P_GO ||
500 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700501 /* Remove 802.11b rates from supported and basic rate sets */
502 int *list = os_malloc(4 * sizeof(int));
503 if (list) {
504 list[0] = 60;
505 list[1] = 120;
506 list[2] = 240;
507 list[3] = -1;
508 }
509 conf->basic_rates = list;
510
511 list = os_malloc(9 * sizeof(int));
512 if (list) {
513 list[0] = 60;
514 list[1] = 90;
515 list[2] = 120;
516 list[3] = 180;
517 list[4] = 240;
518 list[5] = 360;
519 list[6] = 480;
520 list[7] = 540;
521 list[8] = -1;
522 }
523 conf->supported_rates = list;
Hai Shalom021b0b52019-04-10 11:17:58 -0700524 }
525
Hai Shalom74f70d42019-02-11 14:42:39 -0800526#ifdef CONFIG_IEEE80211AX
Hai Shalom021b0b52019-04-10 11:17:58 -0700527 if (ssid->mode == WPAS_MODE_P2P_GO ||
528 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
Hai Shalom74f70d42019-02-11 14:42:39 -0800529 conf->ieee80211ax = ssid->he;
530#endif /* CONFIG_IEEE80211AX */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800531
532 bss->isolate = !wpa_s->conf->p2p_intra_bss;
Hai Shalomfdcde762020-04-02 11:19:20 -0700533 bss->extended_key_id = wpa_s->conf->extended_key_id;
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700534 bss->force_per_enrollee_psk = wpa_s->global->p2p_per_sta_psk;
Hai Shalomfdcde762020-04-02 11:19:20 -0700535 bss->wpa_deny_ptk0_rekey = ssid->wpa_deny_ptk0_rekey;
Dmitry Shmidtcf32e602014-01-28 10:57:39 -0800536
537 if (ssid->p2p_group) {
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800538 os_memcpy(bss->ip_addr_go, wpa_s->p2pdev->conf->ip_addr_go, 4);
539 os_memcpy(bss->ip_addr_mask, wpa_s->p2pdev->conf->ip_addr_mask,
Dmitry Shmidtcf32e602014-01-28 10:57:39 -0800540 4);
541 os_memcpy(bss->ip_addr_start,
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800542 wpa_s->p2pdev->conf->ip_addr_start, 4);
543 os_memcpy(bss->ip_addr_end, wpa_s->p2pdev->conf->ip_addr_end,
Dmitry Shmidtcf32e602014-01-28 10:57:39 -0800544 4);
545 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700546#endif /* CONFIG_P2P */
547
548 if (ssid->ssid_len == 0) {
549 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
550 return -1;
551 }
552 os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700553 bss->ssid.ssid_len = ssid->ssid_len;
554 bss->ssid.ssid_set = 1;
555
Dmitry Shmidt04949592012-07-19 12:16:46 -0700556 bss->ignore_broadcast_ssid = ssid->ignore_broadcast_ssid;
557
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800558 if (ssid->auth_alg)
559 bss->auth_algs = ssid->auth_alg;
560
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700561 if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt))
562 bss->wpa = ssid->proto;
Dmitry Shmidt849734c2016-05-27 09:59:01 -0700563 if (ssid->key_mgmt == DEFAULT_KEY_MGMT)
564 bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
565 else
566 bss->wpa_key_mgmt = ssid->key_mgmt;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700567 bss->wpa_pairwise = ssid->pairwise_cipher;
Hai Shalomc3565922019-10-28 11:58:20 -0700568 if (wpa_key_mgmt_sae(bss->wpa_key_mgmt) && ssid->passphrase) {
569 bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
570 } else if (ssid->psk_set) {
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800571 bin_clear_free(bss->ssid.wpa_psk, sizeof(*bss->ssid.wpa_psk));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700572 bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
573 if (bss->ssid.wpa_psk == NULL)
574 return -1;
575 os_memcpy(bss->ssid.wpa_psk->psk, ssid->psk, PMK_LEN);
576 bss->ssid.wpa_psk->group = 1;
Dmitry Shmidt849734c2016-05-27 09:59:01 -0700577 bss->ssid.wpa_psk_set = 1;
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800578 } else if (ssid->passphrase) {
579 bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
Hai Shalomfdcde762020-04-02 11:19:20 -0700580#ifdef CONFIG_WEP
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800581 } else if (ssid->wep_key_len[0] || ssid->wep_key_len[1] ||
582 ssid->wep_key_len[2] || ssid->wep_key_len[3]) {
583 struct hostapd_wep_keys *wep = &bss->ssid.wep;
584 int i;
585 for (i = 0; i < NUM_WEP_KEYS; i++) {
586 if (ssid->wep_key_len[i] == 0)
587 continue;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700588 wep->key[i] = os_memdup(ssid->wep_key[i],
589 ssid->wep_key_len[i]);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800590 if (wep->key[i] == NULL)
591 return -1;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800592 wep->len[i] = ssid->wep_key_len[i];
593 }
594 wep->idx = ssid->wep_tx_keyidx;
595 wep->keys_set = 1;
Hai Shalomfdcde762020-04-02 11:19:20 -0700596#endif /* CONFIG_WEP */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700597 }
Hai Shalomc3565922019-10-28 11:58:20 -0700598#ifdef CONFIG_SAE
599 if (ssid->sae_password) {
600 struct sae_password_entry *pw;
601
602 pw = os_zalloc(sizeof(*pw));
603 if (!pw)
604 return -1;
605 os_memset(pw->peer_addr, 0xff, ETH_ALEN);
606 pw->password = os_strdup(ssid->sae_password);
607 if (!pw->password) {
608 os_free(pw);
609 return -1;
610 }
611 if (ssid->sae_password_id) {
612 pw->identifier = os_strdup(ssid->sae_password_id);
613 if (!pw->identifier) {
614 str_clear_free(pw->password);
615 os_free(pw);
616 return -1;
617 }
618 }
619
620 pw->next = bss->sae_passwords;
621 bss->sae_passwords = pw;
622 }
623
Hai Shaloma20dcd72022-02-04 13:43:00 -0800624 if (ssid->sae_pwe != DEFAULT_SAE_PWE)
625 bss->sae_pwe = ssid->sae_pwe;
626 else
627 bss->sae_pwe = wpa_s->conf->sae_pwe;
Hai Shalomc3565922019-10-28 11:58:20 -0700628#endif /* CONFIG_SAE */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700629
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700630 if (wpa_s->conf->go_interworking) {
631 wpa_printf(MSG_DEBUG,
632 "P2P: Enable Interworking with access_network_type: %d",
633 wpa_s->conf->go_access_network_type);
634 bss->interworking = wpa_s->conf->go_interworking;
635 bss->access_network_type = wpa_s->conf->go_access_network_type;
636 bss->internet = wpa_s->conf->go_internet;
637 if (wpa_s->conf->go_venue_group) {
638 wpa_printf(MSG_DEBUG,
639 "P2P: Venue group: %d Venue type: %d",
640 wpa_s->conf->go_venue_group,
641 wpa_s->conf->go_venue_type);
642 bss->venue_group = wpa_s->conf->go_venue_group;
643 bss->venue_type = wpa_s->conf->go_venue_type;
644 bss->venue_info_set = 1;
645 }
646 }
647
Dmitry Shmidt04949592012-07-19 12:16:46 -0700648 if (ssid->ap_max_inactivity)
649 bss->ap_max_inactivity = ssid->ap_max_inactivity;
650
651 if (ssid->dtim_period)
652 bss->dtim_period = ssid->dtim_period;
Dmitry Shmidt7a5e50a2013-03-05 12:37:16 -0800653 else if (wpa_s->conf->dtim_period)
654 bss->dtim_period = wpa_s->conf->dtim_period;
655
656 if (ssid->beacon_int)
657 conf->beacon_int = ssid->beacon_int;
658 else if (wpa_s->conf->beacon_int)
659 conf->beacon_int = wpa_s->conf->beacon_int;
Dmitry Shmidt04949592012-07-19 12:16:46 -0700660
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800661#ifdef CONFIG_P2P
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800662 if (ssid->mode == WPAS_MODE_P2P_GO ||
663 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) {
664 if (wpa_s->conf->p2p_go_ctwindow > conf->beacon_int) {
665 wpa_printf(MSG_INFO,
666 "CTWindow (%d) is bigger than beacon interval (%d) - avoid configuring it",
667 wpa_s->conf->p2p_go_ctwindow,
668 conf->beacon_int);
669 conf->p2p_go_ctwindow = 0;
670 } else {
671 conf->p2p_go_ctwindow = wpa_s->conf->p2p_go_ctwindow;
672 }
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800673 }
674#endif /* CONFIG_P2P */
675
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800676 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
677 bss->rsn_pairwise = bss->wpa_pairwise;
678 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
679 bss->rsn_pairwise);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700680
Hai Shalomfdcde762020-04-02 11:19:20 -0700681 if (bss->wpa && bss->ieee802_1x) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700682 bss->ssid.security_policy = SECURITY_WPA;
Hai Shalomfdcde762020-04-02 11:19:20 -0700683 } else if (bss->wpa) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700684 bss->ssid.security_policy = SECURITY_WPA_PSK;
Hai Shalomfdcde762020-04-02 11:19:20 -0700685#ifdef CONFIG_WEP
686 } else if (bss->ieee802_1x) {
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800687 int cipher = WPA_CIPHER_NONE;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700688 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
689 bss->ssid.wep.default_len = bss->default_wep_key_len;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800690 if (bss->default_wep_key_len)
691 cipher = bss->default_wep_key_len >= 13 ?
692 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
693 bss->wpa_group = cipher;
694 bss->wpa_pairwise = cipher;
695 bss->rsn_pairwise = cipher;
696 } else if (bss->ssid.wep.keys_set) {
697 int cipher = WPA_CIPHER_WEP40;
698 if (bss->ssid.wep.len[0] >= 13)
699 cipher = WPA_CIPHER_WEP104;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700700 bss->ssid.security_policy = SECURITY_STATIC_WEP;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800701 bss->wpa_group = cipher;
702 bss->wpa_pairwise = cipher;
703 bss->rsn_pairwise = cipher;
Hai Shalomfdcde762020-04-02 11:19:20 -0700704#endif /* CONFIG_WEP */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800705 } else {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700706 bss->ssid.security_policy = SECURITY_PLAINTEXT;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800707 bss->wpa_group = WPA_CIPHER_NONE;
708 bss->wpa_pairwise = WPA_CIPHER_NONE;
709 bss->rsn_pairwise = WPA_CIPHER_NONE;
710 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700711
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700712 if (bss->wpa_group_rekey < 86400 && (bss->wpa & 2) &&
713 (bss->wpa_group == WPA_CIPHER_CCMP ||
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800714 bss->wpa_group == WPA_CIPHER_GCMP ||
715 bss->wpa_group == WPA_CIPHER_CCMP_256 ||
716 bss->wpa_group == WPA_CIPHER_GCMP_256)) {
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700717 /*
718 * Strong ciphers do not need frequent rekeying, so increase
719 * the default GTK rekeying period to 24 hours.
720 */
721 bss->wpa_group_rekey = 86400;
722 }
723
Sunil Ravi38ad1ed2023-01-17 23:58:31 +0000724 if (ssid->ieee80211w != MGMT_FRAME_PROTECTION_DEFAULT) {
Dmitry Shmidtb36ed7c2014-03-17 10:57:26 -0700725 bss->ieee80211w = ssid->ieee80211w;
Sunil Ravi38ad1ed2023-01-17 23:58:31 +0000726 } else if (wpa_s->conf->pmf != MGMT_FRAME_PROTECTION_DEFAULT) {
727 if (ssid->mode == WPAS_MODE_AP)
728 bss->ieee80211w = wpa_s->conf->pmf;
729 }
Dmitry Shmidtb36ed7c2014-03-17 10:57:26 -0700730
Hai Shalom74f70d42019-02-11 14:42:39 -0800731#ifdef CONFIG_OCV
732 bss->ocv = ssid->ocv;
733#endif /* CONFIG_OCV */
734
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700735#ifdef CONFIG_WPS
736 /*
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800737 * Enable WPS by default for open and WPA/WPA2-Personal network, but
738 * require user interaction to actually use it. Only the internal
739 * Registrar is supported.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700740 */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800741 if (bss->ssid.security_policy != SECURITY_WPA_PSK &&
742 bss->ssid.security_policy != SECURITY_PLAINTEXT)
743 goto no_wps;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800744 if (bss->ssid.security_policy == SECURITY_WPA_PSK &&
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800745 (!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)) ||
746 !(bss->wpa & 2)))
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800747 goto no_wps; /* WPS2 does not allow WPA/TKIP-only
748 * configuration */
Dmitry Shmidt849734c2016-05-27 09:59:01 -0700749 if (ssid->wps_disabled)
750 goto no_wps;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700751 bss->eap_server = 1;
Dmitry Shmidt04949592012-07-19 12:16:46 -0700752
753 if (!ssid->ignore_broadcast_ssid)
754 bss->wps_state = 2;
755
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700756 bss->ap_setup_locked = 2;
757 if (wpa_s->conf->config_methods)
758 bss->config_methods = os_strdup(wpa_s->conf->config_methods);
759 os_memcpy(bss->device_type, wpa_s->conf->device_type,
760 WPS_DEV_TYPE_LEN);
761 if (wpa_s->conf->device_name) {
762 bss->device_name = os_strdup(wpa_s->conf->device_name);
763 bss->friendly_name = os_strdup(wpa_s->conf->device_name);
764 }
765 if (wpa_s->conf->manufacturer)
766 bss->manufacturer = os_strdup(wpa_s->conf->manufacturer);
767 if (wpa_s->conf->model_name)
768 bss->model_name = os_strdup(wpa_s->conf->model_name);
769 if (wpa_s->conf->model_number)
770 bss->model_number = os_strdup(wpa_s->conf->model_number);
771 if (wpa_s->conf->serial_number)
772 bss->serial_number = os_strdup(wpa_s->conf->serial_number);
773 if (is_nil_uuid(wpa_s->conf->uuid))
774 os_memcpy(bss->uuid, wpa_s->wps->uuid, WPS_UUID_LEN);
775 else
776 os_memcpy(bss->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
777 os_memcpy(bss->os_version, wpa_s->conf->os_version, 4);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700778 bss->pbc_in_m1 = wpa_s->conf->pbc_in_m1;
Dmitry Shmidt4ae50e62016-06-27 13:48:39 -0700779 if (ssid->eap.fragment_size != DEFAULT_FRAGMENT_SIZE)
780 bss->fragment_size = ssid->eap.fragment_size;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800781no_wps:
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700782#endif /* CONFIG_WPS */
783
784 if (wpa_s->max_stations &&
785 wpa_s->max_stations < wpa_s->conf->max_num_sta)
786 bss->max_num_sta = wpa_s->max_stations;
787 else
788 bss->max_num_sta = wpa_s->conf->max_num_sta;
789
Roshan Pius3a1667e2018-07-03 15:17:14 -0700790 if (!bss->isolate)
791 bss->isolate = wpa_s->conf->ap_isolate;
792
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700793 bss->disassoc_low_ack = wpa_s->conf->disassoc_low_ack;
794
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -0700795 if (wpa_s->conf->ap_vendor_elements) {
796 bss->vendor_elements =
797 wpabuf_dup(wpa_s->conf->ap_vendor_elements);
798 }
Hai Shaloma20dcd72022-02-04 13:43:00 -0800799 if (wpa_s->conf->ap_assocresp_elements) {
800 bss->assocresp_elements =
801 wpabuf_dup(wpa_s->conf->ap_assocresp_elements);
802 }
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -0700803
Dmitry Shmidt7d175302016-09-06 13:11:34 -0700804 bss->ftm_responder = wpa_s->conf->ftm_responder;
805 bss->ftm_initiator = wpa_s->conf->ftm_initiator;
806
Hai Shalomfdcde762020-04-02 11:19:20 -0700807 bss->transition_disable = ssid->transition_disable;
808
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700809 return 0;
810}
811
812
813static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
814{
815#ifdef CONFIG_P2P
816 struct wpa_supplicant *wpa_s = ctx;
817 const struct ieee80211_mgmt *mgmt;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700818
819 mgmt = (const struct ieee80211_mgmt *) buf;
Dmitry Shmidt623d63a2014-06-13 11:05:14 -0700820 if (len < IEEE80211_HDRLEN + 1)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700821 return;
Dmitry Shmidt18463232014-01-24 12:29:41 -0800822 if (mgmt->u.action.category != WLAN_ACTION_PUBLIC)
823 return;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700824 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
825 mgmt->u.action.category,
Dmitry Shmidt623d63a2014-06-13 11:05:14 -0700826 buf + IEEE80211_HDRLEN + 1,
827 len - IEEE80211_HDRLEN - 1, freq);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700828#endif /* CONFIG_P2P */
829}
830
831
832static void ap_wps_event_cb(void *ctx, enum wps_event event,
833 union wps_event_data *data)
834{
835#ifdef CONFIG_P2P
836 struct wpa_supplicant *wpa_s = ctx;
837
Jouni Malinen75ecf522011-06-27 15:19:46 -0700838 if (event == WPS_EV_FAIL) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700839 struct wps_event_fail *fail = &data->fail;
840
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800841 if (wpa_s->p2pdev && wpa_s->p2pdev != wpa_s &&
Jouni Malinen75ecf522011-06-27 15:19:46 -0700842 wpa_s == wpa_s->global->p2p_group_formation) {
843 /*
844 * src/ap/wps_hostapd.c has already sent this on the
845 * main interface, so only send on the parent interface
846 * here if needed.
847 */
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800848 wpa_msg(wpa_s->p2pdev, MSG_INFO, WPS_EVENT_FAIL
Jouni Malinen75ecf522011-06-27 15:19:46 -0700849 "msg=%d config_error=%d",
850 fail->msg, fail->config_error);
851 }
852 wpas_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700853 }
854#endif /* CONFIG_P2P */
855}
856
857
858static void ap_sta_authorized_cb(void *ctx, const u8 *mac_addr,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800859 int authorized, const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700860{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800861 wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700862}
863
864
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700865#ifdef CONFIG_P2P
866static void ap_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
867 const u8 *psk, size_t psk_len)
868{
869
870 struct wpa_supplicant *wpa_s = ctx;
871 if (wpa_s->ap_iface == NULL || wpa_s->current_ssid == NULL)
872 return;
873 wpas_p2p_new_psk_cb(wpa_s, mac_addr, p2p_dev_addr, psk, psk_len);
874}
875#endif /* CONFIG_P2P */
876
877
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700878static int ap_vendor_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
879{
880#ifdef CONFIG_P2P
881 struct wpa_supplicant *wpa_s = ctx;
882 const struct ieee80211_mgmt *mgmt;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700883
884 mgmt = (const struct ieee80211_mgmt *) buf;
Dmitry Shmidt623d63a2014-06-13 11:05:14 -0700885 if (len < IEEE80211_HDRLEN + 1)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700886 return -1;
887 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
888 mgmt->u.action.category,
Dmitry Shmidt623d63a2014-06-13 11:05:14 -0700889 buf + IEEE80211_HDRLEN + 1,
890 len - IEEE80211_HDRLEN - 1, freq);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700891#endif /* CONFIG_P2P */
892 return 0;
893}
894
895
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800896static int ap_probe_req_rx(void *ctx, const u8 *sa, const u8 *da,
Dmitry Shmidt04949592012-07-19 12:16:46 -0700897 const u8 *bssid, const u8 *ie, size_t ie_len,
898 int ssi_signal)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700899{
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700900 struct wpa_supplicant *wpa_s = ctx;
Dmitry Shmidta3dc3092015-06-23 11:21:28 -0700901 unsigned int freq = 0;
902
903 if (wpa_s->ap_iface)
904 freq = wpa_s->ap_iface->freq;
905
Dmitry Shmidt04949592012-07-19 12:16:46 -0700906 return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len,
Dmitry Shmidta3dc3092015-06-23 11:21:28 -0700907 freq, ssi_signal);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700908}
909
910
911static void ap_wps_reg_success_cb(void *ctx, const u8 *mac_addr,
912 const u8 *uuid_e)
913{
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700914 struct wpa_supplicant *wpa_s = ctx;
915 wpas_p2p_wps_success(wpa_s, mac_addr, 1);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700916}
917
918
919static void wpas_ap_configured_cb(void *ctx)
920{
921 struct wpa_supplicant *wpa_s = ctx;
922
Roshan Pius3a1667e2018-07-03 15:17:14 -0700923 wpa_printf(MSG_DEBUG, "AP interface setup completed - state %s",
924 hostapd_state_text(wpa_s->ap_iface->state));
925 if (wpa_s->ap_iface->state == HAPD_IFACE_DISABLED) {
926 wpa_supplicant_ap_deinit(wpa_s);
927 return;
928 }
929
Sunil Ravi236f0f52021-06-29 11:18:20 -0700930 if (wpa_s->current_ssid) {
931 int acs = 0;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800932
Dmitry Shmidt014a3ff2015-12-28 13:27:49 -0800933#ifdef CONFIG_ACS
Sunil Ravi236f0f52021-06-29 11:18:20 -0700934 acs = wpa_s->current_ssid->acs;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800935#endif /* CONFIG_ACS */
Sunil Ravi236f0f52021-06-29 11:18:20 -0700936 if (acs || (wpa_s->assoc_freq && wpa_s->ap_iface->freq &&
Hai Shaloma20dcd72022-02-04 13:43:00 -0800937 (int) wpa_s->assoc_freq != wpa_s->ap_iface->freq)) {
Sunil Ravi236f0f52021-06-29 11:18:20 -0700938 wpa_s->assoc_freq = wpa_s->ap_iface->freq;
939 wpa_s->current_ssid->frequency = wpa_s->ap_iface->freq;
940 }
Roshan Pius3a1667e2018-07-03 15:17:14 -0700941 }
Dmitry Shmidt014a3ff2015-12-28 13:27:49 -0800942
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700943 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
944
945 if (wpa_s->ap_configured_cb)
946 wpa_s->ap_configured_cb(wpa_s->ap_configured_cb_ctx,
947 wpa_s->ap_configured_cb_data);
948}
949
950
951int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
952 struct wpa_ssid *ssid)
953{
954 struct wpa_driver_associate_params params;
955 struct hostapd_iface *hapd_iface;
956 struct hostapd_config *conf;
957 size_t i;
958
959 if (ssid->ssid == NULL || ssid->ssid_len == 0) {
960 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
961 return -1;
962 }
963
964 wpa_supplicant_ap_deinit(wpa_s);
965
966 wpa_printf(MSG_DEBUG, "Setting up AP (SSID='%s')",
967 wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
968
969 os_memset(&params, 0, sizeof(params));
970 params.ssid = ssid->ssid;
971 params.ssid_len = ssid->ssid_len;
972 switch (ssid->mode) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700973 case WPAS_MODE_AP:
974 case WPAS_MODE_P2P_GO:
975 case WPAS_MODE_P2P_GROUP_FORMATION:
976 params.mode = IEEE80211_MODE_AP;
977 break;
Dmitry Shmidt3c479372014-02-04 10:50:36 -0800978 default:
979 return -1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700980 }
Dmitry Shmidtb7b4d0e2013-08-26 12:09:05 -0700981 if (ssid->frequency == 0)
982 ssid->frequency = 2462; /* default channel 11 */
Dmitry Shmidt9ead16e2014-10-07 13:15:23 -0700983 params.freq.freq = ssid->frequency;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700984
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800985 if ((ssid->mode == WPAS_MODE_AP || ssid->mode == WPAS_MODE_P2P_GO) &&
986 ssid->enable_edmg) {
Hai Shalomc3565922019-10-28 11:58:20 -0700987 u8 primary_channel;
988
989 if (ieee80211_freq_to_chan(ssid->frequency, &primary_channel) ==
990 NUM_HOSTAPD_MODES) {
991 wpa_printf(MSG_WARNING,
992 "EDMG: Failed to get the primary channel");
993 return -1;
994 }
995
996 hostapd_encode_edmg_chan(ssid->enable_edmg, ssid->edmg_channel,
997 primary_channel, &params.freq.edmg);
998 }
999
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001000 params.wpa_proto = ssid->proto;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001001 if (ssid->key_mgmt & WPA_KEY_MGMT_PSK)
1002 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
Hai Shaloma20dcd72022-02-04 13:43:00 -08001003 else if (ssid->key_mgmt & WPA_KEY_MGMT_SAE)
1004 wpa_s->key_mgmt = WPA_KEY_MGMT_SAE;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001005 else
1006 wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001007 params.key_mgmt_suite = wpa_s->key_mgmt;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001008
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -08001009 wpa_s->pairwise_cipher = wpa_pick_pairwise_cipher(ssid->pairwise_cipher,
1010 1);
1011 if (wpa_s->pairwise_cipher < 0) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001012 wpa_printf(MSG_WARNING, "WPA: Failed to select pairwise "
1013 "cipher.");
1014 return -1;
1015 }
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001016 params.pairwise_suite = wpa_s->pairwise_cipher;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001017 params.group_suite = params.pairwise_suite;
1018
1019#ifdef CONFIG_P2P
1020 if (ssid->mode == WPAS_MODE_P2P_GO ||
1021 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
1022 params.p2p = 1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001023#endif /* CONFIG_P2P */
1024
Dmitry Shmidt9c175262016-03-03 10:20:07 -08001025 if (wpa_s->p2pdev->set_ap_uapsd)
1026 params.uapsd = wpa_s->p2pdev->ap_uapsd;
Dmitry Shmidtec58b162014-02-19 12:44:18 -08001027 else if (params.p2p && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_UAPSD))
1028 params.uapsd = 1; /* mandatory for P2P GO */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001029 else
1030 params.uapsd = -1;
1031
Roshan Pius3a1667e2018-07-03 15:17:14 -07001032 if (ieee80211_is_dfs(params.freq.freq, wpa_s->hw.modes,
1033 wpa_s->hw.num_modes))
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08001034 params.freq.freq = 0; /* set channel after CAC */
1035
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -07001036 if (params.p2p)
1037 wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_GO);
1038 else
1039 wpa_drv_get_ext_capa(wpa_s, WPA_IF_AP_BSS);
1040
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001041 if (wpa_drv_associate(wpa_s, &params) < 0) {
1042 wpa_msg(wpa_s, MSG_INFO, "Failed to start AP functionality");
1043 return -1;
1044 }
1045
Dmitry Shmidtaca489e2016-09-28 15:44:14 -07001046 wpa_s->ap_iface = hapd_iface = hostapd_alloc_iface();
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001047 if (hapd_iface == NULL)
1048 return -1;
1049 hapd_iface->owner = wpa_s;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001050 hapd_iface->drv_flags = wpa_s->drv_flags;
1051 hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads;
Dmitry Shmidt444d5672013-04-01 13:08:44 -07001052 hapd_iface->extended_capa = wpa_s->extended_capa;
1053 hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
1054 hapd_iface->extended_capa_len = wpa_s->extended_capa_len;
Sunil Ravia04bd252022-05-02 22:54:18 -07001055 hapd_iface->drv_max_acl_mac_addrs = wpa_s->drv_max_acl_mac_addrs;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001056
1057 wpa_s->ap_iface->conf = conf = hostapd_config_defaults();
1058 if (conf == NULL) {
1059 wpa_supplicant_ap_deinit(wpa_s);
1060 return -1;
1061 }
1062
Dmitry Shmidt61d9df32012-08-29 16:22:06 -07001063 os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params,
1064 wpa_s->conf->wmm_ac_params,
1065 sizeof(wpa_s->conf->wmm_ac_params));
1066
Hai Shalom899fcc72020-10-19 14:38:18 -07001067 os_memcpy(wpa_s->ap_iface->conf->tx_queue, wpa_s->conf->tx_queue,
1068 sizeof(wpa_s->conf->tx_queue));
1069
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001070 if (params.uapsd > 0) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001071 conf->bss[0]->wmm_enabled = 1;
1072 conf->bss[0]->wmm_uapsd = 1;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001073 }
1074
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001075 if (wpa_supplicant_conf_ap(wpa_s, ssid, conf)) {
1076 wpa_printf(MSG_ERROR, "Failed to create AP configuration");
1077 wpa_supplicant_ap_deinit(wpa_s);
1078 return -1;
1079 }
1080
1081#ifdef CONFIG_P2P
1082 if (ssid->mode == WPAS_MODE_P2P_GO)
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001083 conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001084 else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001085 conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001086 P2P_GROUP_FORMATION;
1087#endif /* CONFIG_P2P */
1088
1089 hapd_iface->num_bss = conf->num_bss;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -07001090 hapd_iface->bss = os_calloc(conf->num_bss,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001091 sizeof(struct hostapd_data *));
1092 if (hapd_iface->bss == NULL) {
1093 wpa_supplicant_ap_deinit(wpa_s);
1094 return -1;
1095 }
1096
1097 for (i = 0; i < conf->num_bss; i++) {
1098 hapd_iface->bss[i] =
1099 hostapd_alloc_bss_data(hapd_iface, conf,
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001100 conf->bss[i]);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001101 if (hapd_iface->bss[i] == NULL) {
1102 wpa_supplicant_ap_deinit(wpa_s);
1103 return -1;
1104 }
1105
1106 hapd_iface->bss[i]->msg_ctx = wpa_s;
Dmitry Shmidt9c175262016-03-03 10:20:07 -08001107 hapd_iface->bss[i]->msg_ctx_parent = wpa_s->p2pdev;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001108 hapd_iface->bss[i]->public_action_cb = ap_public_action_rx;
1109 hapd_iface->bss[i]->public_action_cb_ctx = wpa_s;
1110 hapd_iface->bss[i]->vendor_action_cb = ap_vendor_action_rx;
1111 hapd_iface->bss[i]->vendor_action_cb_ctx = wpa_s;
1112 hostapd_register_probereq_cb(hapd_iface->bss[i],
1113 ap_probe_req_rx, wpa_s);
1114 hapd_iface->bss[i]->wps_reg_success_cb = ap_wps_reg_success_cb;
1115 hapd_iface->bss[i]->wps_reg_success_cb_ctx = wpa_s;
1116 hapd_iface->bss[i]->wps_event_cb = ap_wps_event_cb;
1117 hapd_iface->bss[i]->wps_event_cb_ctx = wpa_s;
1118 hapd_iface->bss[i]->sta_authorized_cb = ap_sta_authorized_cb;
1119 hapd_iface->bss[i]->sta_authorized_cb_ctx = wpa_s;
1120#ifdef CONFIG_P2P
Dmitry Shmidt391c59f2013-09-03 12:16:28 -07001121 hapd_iface->bss[i]->new_psk_cb = ap_new_psk_cb;
1122 hapd_iface->bss[i]->new_psk_cb_ctx = wpa_s;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001123 hapd_iface->bss[i]->p2p = wpa_s->global->p2p;
Dmitry Shmidt04949592012-07-19 12:16:46 -07001124 hapd_iface->bss[i]->p2p_group = wpas_p2p_group_init(wpa_s,
1125 ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001126#endif /* CONFIG_P2P */
1127 hapd_iface->bss[i]->setup_complete_cb = wpas_ap_configured_cb;
1128 hapd_iface->bss[i]->setup_complete_cb_ctx = wpa_s;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001129#ifdef CONFIG_TESTING_OPTIONS
1130 hapd_iface->bss[i]->ext_eapol_frame_io =
1131 wpa_s->ext_eapol_frame_io;
1132#endif /* CONFIG_TESTING_OPTIONS */
Sunil Ravia04bd252022-05-02 22:54:18 -07001133
1134#ifdef CONFIG_WNM_AP
1135 if (ssid->mode == WPAS_MODE_AP)
1136 hapd_iface->bss[i]->conf->bss_transition = 1;
1137#endif /* CONFIG_WNM_AP */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001138 }
1139
1140 os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN);
1141 hapd_iface->bss[0]->driver = wpa_s->driver;
1142 hapd_iface->bss[0]->drv_priv = wpa_s->drv_priv;
1143
1144 wpa_s->current_ssid = ssid;
Dmitry Shmidtb7b4d0e2013-08-26 12:09:05 -07001145 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001146 os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN);
1147 wpa_s->assoc_freq = ssid->frequency;
Hai Shalomc3565922019-10-28 11:58:20 -07001148 wpa_s->ap_iface->conf->enable_edmg = ssid->enable_edmg;
1149 wpa_s->ap_iface->conf->edmg_channel = ssid->edmg_channel;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001150
Roshan Pius3a1667e2018-07-03 15:17:14 -07001151#if defined(CONFIG_P2P) && defined(CONFIG_ACS)
1152 if (wpa_s->p2p_go_do_acs) {
1153 wpa_s->ap_iface->conf->channel = 0;
1154 wpa_s->ap_iface->conf->hw_mode = wpa_s->p2p_go_acs_band;
1155 ssid->acs = 1;
1156 }
1157#endif /* CONFIG_P2P && CONFIG_ACS */
1158
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001159 if (hostapd_setup_interface(wpa_s->ap_iface)) {
1160 wpa_printf(MSG_ERROR, "Failed to initialize AP interface");
1161 wpa_supplicant_ap_deinit(wpa_s);
1162 return -1;
1163 }
1164
1165 return 0;
1166}
1167
1168
1169void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
1170{
1171#ifdef CONFIG_WPS
1172 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
1173#endif /* CONFIG_WPS */
1174
1175 if (wpa_s->ap_iface == NULL)
1176 return;
1177
1178 wpa_s->current_ssid = NULL;
Dmitry Shmidtb7b4d0e2013-08-26 12:09:05 -07001179 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001180 wpa_s->assoc_freq = 0;
Dmitry Shmidt43cb5782014-06-16 16:23:22 -07001181 wpas_p2p_ap_deinit(wpa_s);
Dmitry Shmidta38abf92014-03-06 13:38:44 -08001182 wpa_s->ap_iface->driver_ap_teardown =
1183 !!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
1184
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001185 hostapd_interface_deinit(wpa_s->ap_iface);
1186 hostapd_interface_free(wpa_s->ap_iface);
1187 wpa_s->ap_iface = NULL;
1188 wpa_drv_deinit_ap(wpa_s);
Dmitry Shmidtf73259c2015-03-17 11:00:54 -07001189 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
1190 " reason=%d locally_generated=1",
1191 MAC2STR(wpa_s->own_addr), WLAN_REASON_DEAUTH_LEAVING);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001192}
1193
1194
1195void ap_tx_status(void *ctx, const u8 *addr,
1196 const u8 *buf, size_t len, int ack)
1197{
1198#ifdef NEED_AP_MLME
1199 struct wpa_supplicant *wpa_s = ctx;
1200 hostapd_tx_status(wpa_s->ap_iface->bss[0], addr, buf, len, ack);
1201#endif /* NEED_AP_MLME */
1202}
1203
1204
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001205void ap_eapol_tx_status(void *ctx, const u8 *dst,
1206 const u8 *data, size_t len, int ack)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001207{
1208#ifdef NEED_AP_MLME
1209 struct wpa_supplicant *wpa_s = ctx;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001210 if (!wpa_s->ap_iface)
1211 return;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001212 hostapd_tx_status(wpa_s->ap_iface->bss[0], dst, data, len, ack);
1213#endif /* NEED_AP_MLME */
1214}
1215
1216
1217void ap_client_poll_ok(void *ctx, const u8 *addr)
1218{
1219#ifdef NEED_AP_MLME
1220 struct wpa_supplicant *wpa_s = ctx;
1221 if (wpa_s->ap_iface)
1222 hostapd_client_poll_ok(wpa_s->ap_iface->bss[0], addr);
1223#endif /* NEED_AP_MLME */
1224}
1225
1226
1227void ap_rx_from_unknown_sta(void *ctx, const u8 *addr, int wds)
1228{
1229#ifdef NEED_AP_MLME
1230 struct wpa_supplicant *wpa_s = ctx;
1231 ieee802_11_rx_from_unknown(wpa_s->ap_iface->bss[0], addr, wds);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001232#endif /* NEED_AP_MLME */
1233}
1234
1235
1236void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt)
1237{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001238#ifdef NEED_AP_MLME
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001239 struct wpa_supplicant *wpa_s = ctx;
1240 struct hostapd_frame_info fi;
1241 os_memset(&fi, 0, sizeof(fi));
Hai Shaloma20dcd72022-02-04 13:43:00 -08001242 fi.freq = rx_mgmt->freq;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001243 fi.datarate = rx_mgmt->datarate;
1244 fi.ssi_signal = rx_mgmt->ssi_signal;
1245 ieee802_11_mgmt(wpa_s->ap_iface->bss[0], rx_mgmt->frame,
1246 rx_mgmt->frame_len, &fi);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001247#endif /* NEED_AP_MLME */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001248}
1249
1250
1251void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok)
1252{
1253#ifdef NEED_AP_MLME
1254 struct wpa_supplicant *wpa_s = ctx;
1255 ieee802_11_mgmt_cb(wpa_s->ap_iface->bss[0], buf, len, stype, ok);
1256#endif /* NEED_AP_MLME */
1257}
1258
1259
1260void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s,
Sunil8cd6f4d2022-06-28 18:40:46 +00001261 const u8 *src_addr, const u8 *buf, size_t len,
1262 enum frame_encryption encrypted)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001263{
Sunil8cd6f4d2022-06-28 18:40:46 +00001264 ieee802_1x_receive(wpa_s->ap_iface->bss[0], src_addr, buf, len,
1265 encrypted);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001266}
1267
1268
1269#ifdef CONFIG_WPS
1270
1271int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
1272 const u8 *p2p_dev_addr)
1273{
1274 if (!wpa_s->ap_iface)
1275 return -1;
1276 return hostapd_wps_button_pushed(wpa_s->ap_iface->bss[0],
1277 p2p_dev_addr);
1278}
1279
1280
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001281int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s)
1282{
1283 struct wps_registrar *reg;
1284 int reg_sel = 0, wps_sta = 0;
1285
1286 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]->wps)
1287 return -1;
1288
1289 reg = wpa_s->ap_iface->bss[0]->wps->registrar;
1290 reg_sel = wps_registrar_wps_cancel(reg);
1291 wps_sta = ap_for_each_sta(wpa_s->ap_iface->bss[0],
Dmitry Shmidt04949592012-07-19 12:16:46 -07001292 ap_sta_wps_cancel, NULL);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001293
1294 if (!reg_sel && !wps_sta) {
1295 wpa_printf(MSG_DEBUG, "No WPS operation in progress at this "
1296 "time");
1297 return -1;
1298 }
1299
1300 /*
1301 * There are 2 cases to return wps cancel as success:
1302 * 1. When wps cancel was initiated but no connection has been
1303 * established with client yet.
1304 * 2. Client is in the middle of exchanging WPS messages.
1305 */
1306
1307 return 0;
1308}
1309
1310
1311int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -08001312 const char *pin, char *buf, size_t buflen,
1313 int timeout)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001314{
1315 int ret, ret_len = 0;
1316
1317 if (!wpa_s->ap_iface)
1318 return -1;
1319
1320 if (pin == NULL) {
Dmitry Shmidt57c2d392016-02-23 13:40:19 -08001321 unsigned int rpin;
1322
1323 if (wps_generate_pin(&rpin) < 0)
1324 return -1;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001325 ret_len = os_snprintf(buf, buflen, "%08d", rpin);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001326 if (os_snprintf_error(buflen, ret_len))
1327 return -1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001328 pin = buf;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001329 } else if (buf) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001330 ret_len = os_snprintf(buf, buflen, "%s", pin);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001331 if (os_snprintf_error(buflen, ret_len))
1332 return -1;
1333 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001334
1335 ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], bssid, "any", pin,
Dmitry Shmidtd5e49232012-12-03 15:08:10 -08001336 timeout);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001337 if (ret)
1338 return -1;
1339 return ret_len;
1340}
1341
1342
1343static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx)
1344{
1345 struct wpa_supplicant *wpa_s = eloop_data;
1346 wpa_printf(MSG_DEBUG, "WPS: AP PIN timed out");
1347 wpas_wps_ap_pin_disable(wpa_s);
1348}
1349
1350
1351static void wpas_wps_ap_pin_enable(struct wpa_supplicant *wpa_s, int timeout)
1352{
1353 struct hostapd_data *hapd;
1354
1355 if (wpa_s->ap_iface == NULL)
1356 return;
1357 hapd = wpa_s->ap_iface->bss[0];
1358 wpa_printf(MSG_DEBUG, "WPS: Enabling AP PIN (timeout=%d)", timeout);
1359 hapd->ap_pin_failures = 0;
1360 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
1361 if (timeout > 0)
1362 eloop_register_timeout(timeout, 0,
1363 wpas_wps_ap_pin_timeout, wpa_s, NULL);
1364}
1365
1366
1367void wpas_wps_ap_pin_disable(struct wpa_supplicant *wpa_s)
1368{
1369 struct hostapd_data *hapd;
1370
1371 if (wpa_s->ap_iface == NULL)
1372 return;
1373 wpa_printf(MSG_DEBUG, "WPS: Disabling AP PIN");
1374 hapd = wpa_s->ap_iface->bss[0];
1375 os_free(hapd->conf->ap_pin);
1376 hapd->conf->ap_pin = NULL;
1377 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
1378}
1379
1380
1381const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout)
1382{
1383 struct hostapd_data *hapd;
1384 unsigned int pin;
1385 char pin_txt[9];
1386
1387 if (wpa_s->ap_iface == NULL)
1388 return NULL;
1389 hapd = wpa_s->ap_iface->bss[0];
Dmitry Shmidt57c2d392016-02-23 13:40:19 -08001390 if (wps_generate_pin(&pin) < 0)
1391 return NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001392 os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001393 os_free(hapd->conf->ap_pin);
1394 hapd->conf->ap_pin = os_strdup(pin_txt);
1395 if (hapd->conf->ap_pin == NULL)
1396 return NULL;
1397 wpas_wps_ap_pin_enable(wpa_s, timeout);
1398
1399 return hapd->conf->ap_pin;
1400}
1401
1402
1403const char * wpas_wps_ap_pin_get(struct wpa_supplicant *wpa_s)
1404{
1405 struct hostapd_data *hapd;
1406 if (wpa_s->ap_iface == NULL)
1407 return NULL;
1408 hapd = wpa_s->ap_iface->bss[0];
1409 return hapd->conf->ap_pin;
1410}
1411
1412
1413int wpas_wps_ap_pin_set(struct wpa_supplicant *wpa_s, const char *pin,
1414 int timeout)
1415{
1416 struct hostapd_data *hapd;
1417 char pin_txt[9];
1418 int ret;
1419
1420 if (wpa_s->ap_iface == NULL)
1421 return -1;
1422 hapd = wpa_s->ap_iface->bss[0];
1423 ret = os_snprintf(pin_txt, sizeof(pin_txt), "%s", pin);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001424 if (os_snprintf_error(sizeof(pin_txt), ret))
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001425 return -1;
1426 os_free(hapd->conf->ap_pin);
1427 hapd->conf->ap_pin = os_strdup(pin_txt);
1428 if (hapd->conf->ap_pin == NULL)
1429 return -1;
1430 wpas_wps_ap_pin_enable(wpa_s, timeout);
1431
1432 return 0;
1433}
1434
1435
1436void wpa_supplicant_ap_pwd_auth_fail(struct wpa_supplicant *wpa_s)
1437{
1438 struct hostapd_data *hapd;
1439
1440 if (wpa_s->ap_iface == NULL)
1441 return;
1442 hapd = wpa_s->ap_iface->bss[0];
1443
1444 /*
1445 * Registrar failed to prove its knowledge of the AP PIN. Disable AP
1446 * PIN if this happens multiple times to slow down brute force attacks.
1447 */
1448 hapd->ap_pin_failures++;
1449 wpa_printf(MSG_DEBUG, "WPS: AP PIN authentication failure number %u",
1450 hapd->ap_pin_failures);
1451 if (hapd->ap_pin_failures < 3)
1452 return;
1453
1454 wpa_printf(MSG_DEBUG, "WPS: Disable AP PIN");
1455 hapd->ap_pin_failures = 0;
1456 os_free(hapd->conf->ap_pin);
1457 hapd->conf->ap_pin = NULL;
1458}
1459
Dmitry Shmidtf8623282013-02-20 14:34:59 -08001460
1461#ifdef CONFIG_WPS_NFC
1462
1463struct wpabuf * wpas_ap_wps_nfc_config_token(struct wpa_supplicant *wpa_s,
1464 int ndef)
1465{
1466 struct hostapd_data *hapd;
1467
1468 if (wpa_s->ap_iface == NULL)
1469 return NULL;
1470 hapd = wpa_s->ap_iface->bss[0];
1471 return hostapd_wps_nfc_config_token(hapd, ndef);
1472}
1473
1474
1475struct wpabuf * wpas_ap_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
1476 int ndef)
1477{
1478 struct hostapd_data *hapd;
1479
1480 if (wpa_s->ap_iface == NULL)
1481 return NULL;
1482 hapd = wpa_s->ap_iface->bss[0];
1483 return hostapd_wps_nfc_hs_cr(hapd, ndef);
1484}
1485
Dmitry Shmidtcf32e602014-01-28 10:57:39 -08001486
1487int wpas_ap_wps_nfc_report_handover(struct wpa_supplicant *wpa_s,
1488 const struct wpabuf *req,
1489 const struct wpabuf *sel)
1490{
1491 struct hostapd_data *hapd;
1492
1493 if (wpa_s->ap_iface == NULL)
1494 return -1;
1495 hapd = wpa_s->ap_iface->bss[0];
1496 return hostapd_wps_nfc_report_handover(hapd, req, sel);
1497}
1498
Dmitry Shmidtf8623282013-02-20 14:34:59 -08001499#endif /* CONFIG_WPS_NFC */
1500
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001501#endif /* CONFIG_WPS */
1502
1503
1504#ifdef CONFIG_CTRL_IFACE
1505
1506int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s,
1507 char *buf, size_t buflen)
1508{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001509 struct hostapd_data *hapd;
1510
1511 if (wpa_s->ap_iface)
1512 hapd = wpa_s->ap_iface->bss[0];
1513 else if (wpa_s->ifmsh)
1514 hapd = wpa_s->ifmsh->bss[0];
1515 else
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001516 return -1;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001517 return hostapd_ctrl_iface_sta_first(hapd, buf, buflen);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001518}
1519
1520
1521int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr,
1522 char *buf, size_t buflen)
1523{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001524 struct hostapd_data *hapd;
1525
1526 if (wpa_s->ap_iface)
1527 hapd = wpa_s->ap_iface->bss[0];
1528 else if (wpa_s->ifmsh)
1529 hapd = wpa_s->ifmsh->bss[0];
1530 else
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001531 return -1;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001532 return hostapd_ctrl_iface_sta(hapd, txtaddr, buf, buflen);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001533}
1534
1535
1536int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr,
1537 char *buf, size_t buflen)
1538{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001539 struct hostapd_data *hapd;
1540
1541 if (wpa_s->ap_iface)
1542 hapd = wpa_s->ap_iface->bss[0];
1543 else if (wpa_s->ifmsh)
1544 hapd = wpa_s->ifmsh->bss[0];
1545 else
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001546 return -1;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001547 return hostapd_ctrl_iface_sta_next(hapd, txtaddr, buf, buflen);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001548}
1549
1550
Dmitry Shmidt04949592012-07-19 12:16:46 -07001551int ap_ctrl_iface_sta_disassociate(struct wpa_supplicant *wpa_s,
1552 const char *txtaddr)
1553{
1554 if (wpa_s->ap_iface == NULL)
1555 return -1;
1556 return hostapd_ctrl_iface_disassociate(wpa_s->ap_iface->bss[0],
1557 txtaddr);
1558}
1559
1560
1561int ap_ctrl_iface_sta_deauthenticate(struct wpa_supplicant *wpa_s,
1562 const char *txtaddr)
1563{
1564 if (wpa_s->ap_iface == NULL)
1565 return -1;
1566 return hostapd_ctrl_iface_deauthenticate(wpa_s->ap_iface->bss[0],
1567 txtaddr);
1568}
1569
1570
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001571int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
1572 size_t buflen, int verbose)
1573{
1574 char *pos = buf, *end = buf + buflen;
1575 int ret;
1576 struct hostapd_bss_config *conf;
1577
1578 if (wpa_s->ap_iface == NULL)
1579 return -1;
1580
1581 conf = wpa_s->ap_iface->bss[0]->conf;
1582 if (conf->wpa == 0)
1583 return 0;
1584
1585 ret = os_snprintf(pos, end - pos,
1586 "pairwise_cipher=%s\n"
1587 "group_cipher=%s\n"
1588 "key_mgmt=%s\n",
1589 wpa_cipher_txt(conf->rsn_pairwise),
1590 wpa_cipher_txt(conf->wpa_group),
1591 wpa_key_mgmt_txt(conf->wpa_key_mgmt,
1592 conf->wpa));
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001593 if (os_snprintf_error(end - pos, ret))
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001594 return pos - buf;
1595 pos += ret;
1596 return pos - buf;
1597}
1598
Sunil Ravia04bd252022-05-02 22:54:18 -07001599
1600#ifdef CONFIG_WNM_AP
1601
1602int ap_ctrl_iface_disassoc_imminent(struct wpa_supplicant *wpa_s,
1603 const char *buf)
1604{
1605 struct hostapd_data *hapd;
1606
1607 if (wpa_s->ap_iface)
1608 hapd = wpa_s->ap_iface->bss[0];
1609 else
1610 return -1;
1611 return hostapd_ctrl_iface_disassoc_imminent(hapd, buf);
1612}
1613
1614
1615int ap_ctrl_iface_ess_disassoc(struct wpa_supplicant *wpa_s, const char *buf)
1616{
1617 struct hostapd_data *hapd;
1618
1619 if (wpa_s->ap_iface)
1620 hapd = wpa_s->ap_iface->bss[0];
1621 else
1622 return -1;
1623 return hostapd_ctrl_iface_ess_disassoc(hapd, buf);
1624}
1625
1626
1627int ap_ctrl_iface_bss_tm_req(struct wpa_supplicant *wpa_s, const char *buf)
1628{
1629 struct hostapd_data *hapd;
1630
1631 if (wpa_s->ap_iface)
1632 hapd = wpa_s->ap_iface->bss[0];
1633 else
1634 return -1;
1635 return hostapd_ctrl_iface_bss_tm_req(hapd, buf);
1636}
1637
1638#endif /* CONFIG_WNM_AP */
1639
1640
1641int ap_ctrl_iface_acl_add_mac(struct wpa_supplicant *wpa_s,
1642 enum macaddr_acl acl_type,
1643 const char *buf)
1644{
1645 struct hostapd_data *hapd;
1646
1647 if (wpa_s->ap_iface)
1648 hapd = wpa_s->ap_iface->bss[0];
1649 else
1650 return -1;
1651
1652 hapd->conf->macaddr_acl = acl_type;
1653
1654 if (acl_type == ACCEPT_UNLESS_DENIED)
1655 return hostapd_ctrl_iface_acl_add_mac(&hapd->conf->deny_mac,
1656 &hapd->conf->num_deny_mac,
1657 buf);
1658 if (acl_type == DENY_UNLESS_ACCEPTED)
1659 return hostapd_ctrl_iface_acl_add_mac(
1660 &hapd->conf->accept_mac,
1661 &hapd->conf->num_accept_mac, buf);
1662
1663 return -1;
1664}
1665
1666
1667int ap_ctrl_iface_acl_del_mac(struct wpa_supplicant *wpa_s,
1668 enum macaddr_acl acl_type,
1669 const char *buf)
1670{
1671 struct hostapd_data *hapd;
1672
1673 if (wpa_s->ap_iface)
1674 hapd = wpa_s->ap_iface->bss[0];
1675 else
1676 return -1;
1677
1678 hapd->conf->macaddr_acl = acl_type;
1679
1680 if (acl_type == ACCEPT_UNLESS_DENIED)
1681 return hostapd_ctrl_iface_acl_del_mac(&hapd->conf->deny_mac,
1682 &hapd->conf->num_deny_mac,
1683 buf);
1684 if (acl_type == DENY_UNLESS_ACCEPTED)
1685 return hostapd_ctrl_iface_acl_del_mac(
1686 &hapd->conf->accept_mac, &hapd->conf->num_accept_mac,
1687 buf);
1688
1689 return -1;
1690}
1691
1692
1693int ap_ctrl_iface_acl_show_mac(struct wpa_supplicant *wpa_s,
1694 enum macaddr_acl acl_type, char *buf,
1695 size_t buflen)
1696{
1697 struct hostapd_data *hapd;
1698
1699 if (wpa_s->ap_iface)
1700 hapd = wpa_s->ap_iface->bss[0];
1701 else
1702 return -1;
1703
1704 if (acl_type == ACCEPT_UNLESS_DENIED)
1705 return hostapd_ctrl_iface_acl_show_mac(hapd->conf->deny_mac,
1706 hapd->conf->num_deny_mac,
1707 buf, buflen);
1708 if (acl_type == DENY_UNLESS_ACCEPTED)
1709 return hostapd_ctrl_iface_acl_show_mac(
1710 hapd->conf->accept_mac, hapd->conf->num_accept_mac,
1711 buf, buflen);
1712
1713 return -1;
1714}
1715
1716
1717void ap_ctrl_iface_acl_clear_list(struct wpa_supplicant *wpa_s,
1718 enum macaddr_acl acl_type)
1719{
1720 struct hostapd_data *hapd;
1721
1722 if (wpa_s->ap_iface)
1723 hapd = wpa_s->ap_iface->bss[0];
1724 else
1725 return;
1726
1727 hapd->conf->macaddr_acl = acl_type;
1728
1729 if (acl_type == ACCEPT_UNLESS_DENIED)
1730 hostapd_ctrl_iface_acl_clear_list(&hapd->conf->deny_mac,
1731 &hapd->conf->num_deny_mac);
1732 else if (acl_type == DENY_UNLESS_ACCEPTED)
1733 hostapd_ctrl_iface_acl_clear_list(&hapd->conf->accept_mac,
1734 &hapd->conf->num_accept_mac);
1735}
1736
1737
1738int ap_ctrl_iface_disassoc_deny_mac(struct wpa_supplicant *wpa_s)
1739{
1740 struct hostapd_data *hapd;
1741
1742 if (wpa_s->ap_iface)
1743 hapd = wpa_s->ap_iface->bss[0];
1744 else
1745 return -1;
1746
1747 return hostapd_disassoc_deny_mac(hapd);
1748}
1749
1750
1751int ap_ctrl_iface_disassoc_accept_mac(struct wpa_supplicant *wpa_s)
1752{
1753 struct hostapd_data *hapd;
1754
1755 if (wpa_s->ap_iface)
1756 hapd = wpa_s->ap_iface->bss[0];
1757 else
1758 return -1;
1759
1760 return hostapd_disassoc_accept_mac(hapd);
1761}
1762
1763
1764int ap_ctrl_iface_set_acl(struct wpa_supplicant *wpa_s)
1765{
1766 struct hostapd_data *hapd;
1767
1768 if (wpa_s->ap_iface)
1769 hapd = wpa_s->ap_iface->bss[0];
1770 else
1771 return -1;
1772
1773 return hostapd_set_acl(hapd);
1774}
1775
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001776#endif /* CONFIG_CTRL_IFACE */
1777
1778
1779int wpa_supplicant_ap_update_beacon(struct wpa_supplicant *wpa_s)
1780{
1781 struct hostapd_iface *iface = wpa_s->ap_iface;
1782 struct wpa_ssid *ssid = wpa_s->current_ssid;
1783 struct hostapd_data *hapd;
1784
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001785 if (ssid == NULL || wpa_s->ap_iface == NULL ||
1786 ssid->mode == WPAS_MODE_INFRA ||
1787 ssid->mode == WPAS_MODE_IBSS)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001788 return -1;
1789
1790#ifdef CONFIG_P2P
1791 if (ssid->mode == WPAS_MODE_P2P_GO)
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001792 iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001793 else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001794 iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001795 P2P_GROUP_FORMATION;
1796#endif /* CONFIG_P2P */
1797
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001798 hapd = iface->bss[0];
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001799 if (hapd->drv_priv == NULL)
1800 return -1;
1801 ieee802_11_set_beacons(iface);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001802 hostapd_set_ap_wps_ie(hapd);
1803
1804 return 0;
1805}
1806
1807
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001808int ap_switch_channel(struct wpa_supplicant *wpa_s,
1809 struct csa_settings *settings)
1810{
1811#ifdef NEED_AP_MLME
Hai Shalom899fcc72020-10-19 14:38:18 -07001812 struct hostapd_iface *iface = NULL;
1813
1814 if (wpa_s->ap_iface)
1815 iface = wpa_s->ap_iface;
1816 else if (wpa_s->ifmsh)
1817 iface = wpa_s->ifmsh;
1818
1819 if (!iface || !iface->bss[0])
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001820 return -1;
1821
Hai Shalom899fcc72020-10-19 14:38:18 -07001822 return hostapd_switch_channel(iface->bss[0], settings);
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001823#else /* NEED_AP_MLME */
1824 return -1;
1825#endif /* NEED_AP_MLME */
1826}
1827
1828
Dmitry Shmidt83474442015-04-15 13:47:09 -07001829#ifdef CONFIG_CTRL_IFACE
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001830int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos)
1831{
1832 struct csa_settings settings;
1833 int ret = hostapd_parse_csa_settings(pos, &settings);
1834
1835 if (ret)
1836 return ret;
1837
1838 return ap_switch_channel(wpa_s, &settings);
1839}
Dmitry Shmidt83474442015-04-15 13:47:09 -07001840#endif /* CONFIG_CTRL_IFACE */
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001841
1842
Dmitry Shmidt04949592012-07-19 12:16:46 -07001843void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
Sunil Raviaf8751c2023-03-29 11:35:17 -07001844 int offset, int width, int cf1, int cf2,
1845 u16 punct_bitmap, int finished)
Dmitry Shmidt04949592012-07-19 12:16:46 -07001846{
Hai Shalom74f70d42019-02-11 14:42:39 -08001847 struct hostapd_iface *iface = wpa_s->ap_iface;
Hai Shalombf6e0ba2019-02-11 12:01:50 -08001848
Hai Shalom74f70d42019-02-11 14:42:39 -08001849 if (!iface)
1850 iface = wpa_s->ifmsh;
1851 if (!iface)
1852 return;
Dmitry Shmidt04949592012-07-19 12:16:46 -07001853 wpa_s->assoc_freq = freq;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001854 if (wpa_s->current_ssid)
1855 wpa_s->current_ssid->frequency = freq;
Hai Shalom74f70d42019-02-11 14:42:39 -08001856 hostapd_event_ch_switch(iface->bss[0], freq, ht,
Sunil Raviaf8751c2023-03-29 11:35:17 -07001857 offset, width, cf1, cf2, punct_bitmap,
1858 finished);
Dmitry Shmidt04949592012-07-19 12:16:46 -07001859}
1860
1861
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001862int wpa_supplicant_ap_mac_addr_filter(struct wpa_supplicant *wpa_s,
1863 const u8 *addr)
1864{
1865 struct hostapd_data *hapd;
1866 struct hostapd_bss_config *conf;
1867
1868 if (!wpa_s->ap_iface)
1869 return -1;
1870
1871 if (addr)
1872 wpa_printf(MSG_DEBUG, "AP: Set MAC address filter: " MACSTR,
1873 MAC2STR(addr));
1874 else
1875 wpa_printf(MSG_DEBUG, "AP: Clear MAC address filter");
1876
1877 hapd = wpa_s->ap_iface->bss[0];
1878 conf = hapd->conf;
1879
1880 os_free(conf->accept_mac);
1881 conf->accept_mac = NULL;
1882 conf->num_accept_mac = 0;
1883 os_free(conf->deny_mac);
1884 conf->deny_mac = NULL;
1885 conf->num_deny_mac = 0;
1886
1887 if (addr == NULL) {
1888 conf->macaddr_acl = ACCEPT_UNLESS_DENIED;
1889 return 0;
1890 }
1891
1892 conf->macaddr_acl = DENY_UNLESS_ACCEPTED;
1893 conf->accept_mac = os_zalloc(sizeof(struct mac_acl_entry));
1894 if (conf->accept_mac == NULL)
1895 return -1;
1896 os_memcpy(conf->accept_mac[0].addr, addr, ETH_ALEN);
1897 conf->num_accept_mac = 1;
1898
1899 return 0;
1900}
Dmitry Shmidtcf32e602014-01-28 10:57:39 -08001901
1902
1903#ifdef CONFIG_WPS_NFC
1904int wpas_ap_wps_add_nfc_pw(struct wpa_supplicant *wpa_s, u16 pw_id,
1905 const struct wpabuf *pw, const u8 *pubkey_hash)
1906{
1907 struct hostapd_data *hapd;
1908 struct wps_context *wps;
1909
1910 if (!wpa_s->ap_iface)
1911 return -1;
1912 hapd = wpa_s->ap_iface->bss[0];
1913 wps = hapd->wps;
1914
Dmitry Shmidt9c175262016-03-03 10:20:07 -08001915 if (wpa_s->p2pdev->conf->wps_nfc_dh_pubkey == NULL ||
1916 wpa_s->p2pdev->conf->wps_nfc_dh_privkey == NULL) {
Dmitry Shmidtcf32e602014-01-28 10:57:39 -08001917 wpa_printf(MSG_DEBUG, "P2P: No NFC DH key known");
1918 return -1;
1919 }
1920
1921 dh5_free(wps->dh_ctx);
1922 wpabuf_free(wps->dh_pubkey);
1923 wpabuf_free(wps->dh_privkey);
1924 wps->dh_privkey = wpabuf_dup(
Dmitry Shmidt9c175262016-03-03 10:20:07 -08001925 wpa_s->p2pdev->conf->wps_nfc_dh_privkey);
Dmitry Shmidtcf32e602014-01-28 10:57:39 -08001926 wps->dh_pubkey = wpabuf_dup(
Dmitry Shmidt9c175262016-03-03 10:20:07 -08001927 wpa_s->p2pdev->conf->wps_nfc_dh_pubkey);
Dmitry Shmidtcf32e602014-01-28 10:57:39 -08001928 if (wps->dh_privkey == NULL || wps->dh_pubkey == NULL) {
1929 wps->dh_ctx = NULL;
1930 wpabuf_free(wps->dh_pubkey);
1931 wps->dh_pubkey = NULL;
1932 wpabuf_free(wps->dh_privkey);
1933 wps->dh_privkey = NULL;
1934 return -1;
1935 }
1936 wps->dh_ctx = dh5_init_fixed(wps->dh_privkey, wps->dh_pubkey);
1937 if (wps->dh_ctx == NULL)
1938 return -1;
1939
1940 return wps_registrar_add_nfc_pw_token(hapd->wps->registrar, pubkey_hash,
1941 pw_id,
1942 pw ? wpabuf_head(pw) : NULL,
1943 pw ? wpabuf_len(pw) : 0, 1);
1944}
1945#endif /* CONFIG_WPS_NFC */
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001946
1947
Dmitry Shmidt83474442015-04-15 13:47:09 -07001948#ifdef CONFIG_CTRL_IFACE
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001949int wpas_ap_stop_ap(struct wpa_supplicant *wpa_s)
1950{
1951 struct hostapd_data *hapd;
1952
1953 if (!wpa_s->ap_iface)
1954 return -1;
1955 hapd = wpa_s->ap_iface->bss[0];
1956 return hostapd_ctrl_iface_stop_ap(hapd);
1957}
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08001958
1959
Dmitry Shmidte4663042016-04-04 10:07:49 -07001960int wpas_ap_pmksa_cache_list(struct wpa_supplicant *wpa_s, char *buf,
1961 size_t len)
1962{
1963 size_t reply_len = 0, i;
1964 char ap_delimiter[] = "---- AP ----\n";
1965 char mesh_delimiter[] = "---- mesh ----\n";
1966 size_t dlen;
1967
1968 if (wpa_s->ap_iface) {
1969 dlen = os_strlen(ap_delimiter);
1970 if (dlen > len - reply_len)
1971 return reply_len;
1972 os_memcpy(&buf[reply_len], ap_delimiter, dlen);
1973 reply_len += dlen;
1974
1975 for (i = 0; i < wpa_s->ap_iface->num_bss; i++) {
1976 reply_len += hostapd_ctrl_iface_pmksa_list(
1977 wpa_s->ap_iface->bss[i],
1978 &buf[reply_len], len - reply_len);
1979 }
1980 }
1981
1982 if (wpa_s->ifmsh) {
1983 dlen = os_strlen(mesh_delimiter);
1984 if (dlen > len - reply_len)
1985 return reply_len;
1986 os_memcpy(&buf[reply_len], mesh_delimiter, dlen);
1987 reply_len += dlen;
1988
1989 reply_len += hostapd_ctrl_iface_pmksa_list(
1990 wpa_s->ifmsh->bss[0], &buf[reply_len],
1991 len - reply_len);
1992 }
1993
1994 return reply_len;
1995}
1996
1997
1998void wpas_ap_pmksa_cache_flush(struct wpa_supplicant *wpa_s)
1999{
2000 size_t i;
2001
2002 if (wpa_s->ap_iface) {
2003 for (i = 0; i < wpa_s->ap_iface->num_bss; i++)
2004 hostapd_ctrl_iface_pmksa_flush(wpa_s->ap_iface->bss[i]);
2005 }
2006
2007 if (wpa_s->ifmsh)
2008 hostapd_ctrl_iface_pmksa_flush(wpa_s->ifmsh->bss[0]);
2009}
Paul Stewart092955c2017-02-06 09:13:09 -08002010
2011
2012#ifdef CONFIG_PMKSA_CACHE_EXTERNAL
2013#ifdef CONFIG_MESH
2014
2015int wpas_ap_pmksa_cache_list_mesh(struct wpa_supplicant *wpa_s, const u8 *addr,
2016 char *buf, size_t len)
2017{
2018 return hostapd_ctrl_iface_pmksa_list_mesh(wpa_s->ifmsh->bss[0], addr,
2019 &buf[0], len);
2020}
2021
2022
2023int wpas_ap_pmksa_cache_add_external(struct wpa_supplicant *wpa_s, char *cmd)
2024{
2025 struct external_pmksa_cache *entry;
2026 void *pmksa_cache;
2027
2028 pmksa_cache = hostapd_ctrl_iface_pmksa_create_entry(wpa_s->own_addr,
2029 cmd);
2030 if (!pmksa_cache)
2031 return -1;
2032
2033 entry = os_zalloc(sizeof(struct external_pmksa_cache));
2034 if (!entry)
2035 return -1;
2036
2037 entry->pmksa_cache = pmksa_cache;
2038
2039 dl_list_add(&wpa_s->mesh_external_pmksa_cache, &entry->list);
2040
2041 return 0;
2042}
2043
2044#endif /* CONFIG_MESH */
2045#endif /* CONFIG_PMKSA_CACHE_EXTERNAL */
2046
Hai Shaloma20dcd72022-02-04 13:43:00 -08002047
2048int wpas_ap_update_beacon(struct wpa_supplicant *wpa_s)
2049{
2050 struct hostapd_data *hapd;
2051
2052 if (!wpa_s->ap_iface)
2053 return -1;
2054 hapd = wpa_s->ap_iface->bss[0];
2055
2056 wpabuf_free(hapd->conf->assocresp_elements);
2057 hapd->conf->assocresp_elements = NULL;
2058 if (wpa_s->conf->ap_assocresp_elements) {
2059 hapd->conf->assocresp_elements =
2060 wpabuf_dup(wpa_s->conf->ap_assocresp_elements);
2061 }
2062
2063 wpabuf_free(hapd->conf->vendor_elements);
2064 hapd->conf->vendor_elements = NULL;
2065 if (wpa_s->conf->ap_vendor_elements) {
2066 hapd->conf->vendor_elements =
2067 wpabuf_dup(wpa_s->conf->ap_vendor_elements);
2068 }
2069
2070 return ieee802_11_set_beacon(hapd);
2071}
2072
Dmitry Shmidt849734c2016-05-27 09:59:01 -07002073#endif /* CONFIG_CTRL_IFACE */
Dmitry Shmidte4663042016-04-04 10:07:49 -07002074
2075
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002076#ifdef NEED_AP_MLME
Roshan Pius3a1667e2018-07-03 15:17:14 -07002077void wpas_ap_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
2078 struct dfs_event *radar)
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002079{
Hai Shalom74f70d42019-02-11 14:42:39 -08002080 struct hostapd_iface *iface = wpa_s->ap_iface;
2081
2082 if (!iface)
2083 iface = wpa_s->ifmsh;
2084 if (!iface || !iface->bss[0])
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002085 return;
2086 wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq);
Hai Shalom74f70d42019-02-11 14:42:39 -08002087 hostapd_dfs_radar_detected(iface, radar->freq,
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002088 radar->ht_enabled, radar->chan_offset,
2089 radar->chan_width,
2090 radar->cf1, radar->cf2);
2091}
2092
2093
Roshan Pius3a1667e2018-07-03 15:17:14 -07002094void wpas_ap_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
2095 struct dfs_event *radar)
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002096{
Hai Shalom74f70d42019-02-11 14:42:39 -08002097 struct hostapd_iface *iface = wpa_s->ap_iface;
2098
2099 if (!iface)
2100 iface = wpa_s->ifmsh;
2101 if (!iface || !iface->bss[0])
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002102 return;
2103 wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq);
Hai Shalom74f70d42019-02-11 14:42:39 -08002104 hostapd_dfs_start_cac(iface, radar->freq,
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002105 radar->ht_enabled, radar->chan_offset,
2106 radar->chan_width, radar->cf1, radar->cf2);
2107}
2108
2109
Roshan Pius3a1667e2018-07-03 15:17:14 -07002110void wpas_ap_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
2111 struct dfs_event *radar)
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002112{
Hai Shalom74f70d42019-02-11 14:42:39 -08002113 struct hostapd_iface *iface = wpa_s->ap_iface;
2114
2115 if (!iface)
2116 iface = wpa_s->ifmsh;
2117 if (!iface || !iface->bss[0])
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002118 return;
2119 wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq);
Hai Shalom74f70d42019-02-11 14:42:39 -08002120 hostapd_dfs_complete_cac(iface, 1, radar->freq,
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002121 radar->ht_enabled, radar->chan_offset,
2122 radar->chan_width, radar->cf1, radar->cf2);
2123}
2124
2125
Roshan Pius3a1667e2018-07-03 15:17:14 -07002126void wpas_ap_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
2127 struct dfs_event *radar)
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002128{
Hai Shalom74f70d42019-02-11 14:42:39 -08002129 struct hostapd_iface *iface = wpa_s->ap_iface;
2130
2131 if (!iface)
2132 iface = wpa_s->ifmsh;
2133 if (!iface || !iface->bss[0])
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002134 return;
2135 wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq);
Hai Shalom74f70d42019-02-11 14:42:39 -08002136 hostapd_dfs_complete_cac(iface, 0, radar->freq,
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002137 radar->ht_enabled, radar->chan_offset,
2138 radar->chan_width, radar->cf1, radar->cf2);
2139}
2140
2141
Roshan Pius3a1667e2018-07-03 15:17:14 -07002142void wpas_ap_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
2143 struct dfs_event *radar)
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002144{
Hai Shalom74f70d42019-02-11 14:42:39 -08002145 struct hostapd_iface *iface = wpa_s->ap_iface;
2146
2147 if (!iface)
2148 iface = wpa_s->ifmsh;
2149 if (!iface || !iface->bss[0])
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002150 return;
2151 wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq);
Hai Shalom74f70d42019-02-11 14:42:39 -08002152 hostapd_dfs_nop_finished(iface, radar->freq,
Dmitry Shmidt203eadb2015-03-05 14:16:04 -08002153 radar->ht_enabled, radar->chan_offset,
2154 radar->chan_width, radar->cf1, radar->cf2);
2155}
2156#endif /* NEED_AP_MLME */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08002157
2158
2159void ap_periodic(struct wpa_supplicant *wpa_s)
2160{
2161 if (wpa_s->ap_iface)
2162 hostapd_periodic_iface(wpa_s->ap_iface);
2163}