blob: e361c90dc7f0f19a17b2fbfcd8d3b68d34a174db [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001/*
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 *
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
8 */
9
10#include "utils/includes.h"
11
12#include "utils/common.h"
13#include "utils/eloop.h"
14#include "utils/uuid.h"
15#include "common/ieee802_11_defs.h"
16#include "common/wpa_ctrl.h"
17#include "eapol_supp/eapol_supp_sm.h"
18#include "crypto/dh_group5.h"
19#include "ap/hostapd.h"
20#include "ap/ap_config.h"
21#include "ap/ap_drv_ops.h"
22#ifdef NEED_AP_MLME
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"
29#include "ap/dfs.h"
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
43static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx);
44#endif /* CONFIG_WPS */
45
46
47#ifdef CONFIG_IEEE80211N
48static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s,
49 struct wpa_ssid *ssid,
50 struct hostapd_config *conf,
51 struct hostapd_hw_modes *mode)
52{
53#ifdef CONFIG_P2P
54 u8 center_chan = 0;
55 u8 channel = conf->channel;
56#endif /* CONFIG_P2P */
57
58 if (!conf->secondary_channel)
59 goto no_vht;
60 /* Use the maximum oper channel width if it's given. */
61 if (ssid->max_oper_chwidth)
62 conf->vht_oper_chwidth = ssid->max_oper_chwidth;
63
64 ieee80211_freq_to_chan(ssid->vht_center_freq2,
65 &conf->vht_oper_centr_freq_seg1_idx);
66
67 if (!ssid->p2p_group) {
68 if(!ssid->vht_center_freq1 && conf->vht_oper_chwidth == CHANWIDTH_80MHZ) {
69 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode, channel);
70 } else if (!ssid->vht_center_freq1 ||
71 conf->vht_oper_chwidth == CHANWIDTH_USE_HT)
72 goto no_vht;
73 if(center_chan)
74 conf->vht_oper_centr_freq_seg0_idx = center_chan;
75 wpa_printf(MSG_DEBUG, "VHT seg0 index %d for AP",
76 conf->vht_oper_centr_freq_seg0_idx);
77 return;
78 }
79#if defined(CONFIG_BRCM_RSDB)
80 if (wpa_s->conf->p2p_pref_freq_2g && wpa_s->conf->p2p_pref_freq_5g) {
81 int freq, num;
82 num = get_shared_radio_freqs(wpa_s, &freq, 1);
83 if (num > 0) {
84 if (freq > 2484) {
85 /* STA freq is in 5G, choose 2.4 G */
86 wpa_printf(MSG_ERROR, "Choosing 2.4G for AP mod");
87 ssid->frequency = wpa_s->conf->p2p_pref_freq_2g;
88 } else {
89 wpa_printf(MSG_ERROR, "Choosing 5G for AP mode");
90 ssid->frequency = wpa_s->conf->p2p_pref_freq_5g;
91 }
92 } else {
93 wpa_printf(MSG_ERROR, "No shared frequency. "
94 "Start AP on default channel");
95 ssid->frequency = 2412;
96 }
97 }
98#endif /* CONFIG_BRCM_RSDB */
99#ifdef CONFIG_P2P
100 switch (conf->vht_oper_chwidth) {
101 case CHANWIDTH_80MHZ:
102 case CHANWIDTH_80P80MHZ:
103 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode, channel);
104 wpa_printf(MSG_DEBUG,
105 "VHT center channel %u for 80 or 80+80 MHz bandwidth",
106 center_chan);
107 break;
108 case CHANWIDTH_160MHZ:
109 center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel);
110 wpa_printf(MSG_DEBUG,
111 "VHT center channel %u for 160 MHz bandwidth",
112 center_chan);
113 break;
114 default:
115 /*
116 * conf->vht_oper_chwidth might not be set for non-P2P GO cases,
117 * try oper_cwidth 160 MHz first then VHT 80 MHz, if 160 MHz is
118 * not supported.
119 */
120 conf->vht_oper_chwidth = CHANWIDTH_160MHZ;
121 center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel);
122 if (center_chan) {
123 wpa_printf(MSG_DEBUG,
124 "VHT center channel %u for auto-selected 160 MHz bandwidth",
125 center_chan);
126 } else {
127 conf->vht_oper_chwidth = CHANWIDTH_80MHZ;
128 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode,
129 channel);
130 wpa_printf(MSG_DEBUG,
131 "VHT center channel %u for auto-selected 80 MHz bandwidth",
132 center_chan);
133 }
134 break;
135 }
136 if (!center_chan)
137 goto no_vht;
138
139 conf->vht_oper_centr_freq_seg0_idx = center_chan;
140 wpa_printf(MSG_DEBUG, "VHT seg0 index %d for P2P GO",
141 conf->vht_oper_centr_freq_seg0_idx);
142 return;
143#endif /* CONFIG_P2P */
144
145no_vht:
146 wpa_printf(MSG_DEBUG,
147 "No VHT higher bandwidth support for the selected channel %d",
148 conf->channel);
149 conf->vht_oper_centr_freq_seg0_idx =
150 conf->channel + conf->secondary_channel * 2;
151 conf->vht_oper_chwidth = CHANWIDTH_USE_HT;
152}
153#endif /* CONFIG_IEEE80211N */
154
155#ifdef CONFIG_SAE
156static int wpas_conf_ap_sae_password(struct hostapd_bss_config *bss, const char *sae_pwd)
157{
158 struct sae_password_entry *pw;
159
160 pw = os_zalloc(sizeof(*pw));
161 if (!pw)
162 return -1;
163 os_memset(pw->peer_addr, 0xff, ETH_ALEN); /* default to wildcard */
164
165 pw->password = os_strdup(sae_pwd);
166 if (!pw->password)
167 goto fail;
168
169 pw->next = bss->sae_passwords;
170 bss->sae_passwords = pw;
171
172 return 0;
173fail:
174 str_clear_free(pw->password);
175 os_free(pw);
176 return -1;
177}
178#endif
179
180int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
181 struct wpa_ssid *ssid,
182 struct hostapd_config *conf)
183{
184 conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
185 &conf->channel);
186
187 if (conf->hw_mode == NUM_HOSTAPD_MODES) {
188 wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
189 ssid->frequency);
190 return -1;
191 }
192#if defined(CONFIG_BRCM_RSDB)
193 if (wpa_s->conf->p2p_pref_freq_2g && wpa_s->conf->p2p_pref_freq_5g) {
194 int freq, num;
195 num = get_shared_radio_freqs(wpa_s, &freq, 1);
196 if (num > 0) {
197 if (freq > 2484) {
198 /* STA freq is in 5G, choose 2.4 G */
199 wpa_printf(MSG_ERROR, "Choosing 2.4G for AP mod");
200 ssid->frequency = wpa_s->conf->p2p_pref_freq_2g;
201 } else {
202 wpa_printf(MSG_ERROR, "Choosing 5G for AP mode");
203 ssid->frequency = wpa_s->conf->p2p_pref_freq_5g;
204 }
205 } else {
206 wpa_printf(MSG_ERROR, "No shared frequency. "
207 "Start AP on default channel");
208 ssid->frequency = 2412;
209 }
210 }
211#endif /* CONFIG_BRCM_RSDB */
212
213
214 /* TODO: enable HT40 if driver supports it;
215 * drop to 11b if driver does not support 11g */
216
217#ifdef CONFIG_IEEE80211N
218 /*
219 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
220 * and a mask of allowed capabilities within conf->ht_capab.
221 * Using default config settings for: conf->ht_op_mode_fixed,
222 * conf->secondary_channel, conf->require_ht
223 */
224 if (wpa_s->hw.modes) {
225 struct hostapd_hw_modes *mode = NULL;
226 int i, no_ht = 0;
227
228 wpa_printf(MSG_DEBUG,
229 "Determining HT/VHT options based on driver capabilities (freq=%u chan=%u)",
230 ssid->frequency, conf->channel);
231
232 for (i = 0; i < wpa_s->hw.num_modes; i++) {
233 if (wpa_s->hw.modes[i].mode == conf->hw_mode) {
234 mode = &wpa_s->hw.modes[i];
235 break;
236 }
237 }
238
239#ifdef CONFIG_HT_OVERRIDES
240 if (ssid->disable_ht)
241 ssid->ht = 0;
242#endif /* CONFIG_HT_OVERRIDES */
243
244 if (!ssid->ht) {
245 wpa_printf(MSG_DEBUG,
246 "HT not enabled in network profile");
247 conf->ieee80211n = 0;
248 conf->ht_capab = 0;
249 no_ht = 1;
250 }
251
252 if (!no_ht && mode && mode->ht_capab) {
253 wpa_printf(MSG_DEBUG,
254 "Enable HT support (p2p_group=%d 11a=%d ht40_hw_capab=%d ssid->ht40=%d)",
255 ssid->p2p_group,
256 conf->hw_mode == HOSTAPD_MODE_IEEE80211A,
257 !!(mode->ht_capab &
258 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET),
259 ssid->ht40);
260 conf->ieee80211n = 1;
261#ifdef CONFIG_P2P
262 if (ssid->p2p_group &&
263 conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&
264 (mode->ht_capab &
265 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
266 ssid->ht40) {
267 conf->secondary_channel =
268 wpas_p2p_get_ht40_mode(wpa_s, mode,
269 conf->channel);
270 wpa_printf(MSG_DEBUG,
271 "HT secondary channel offset %d for P2P group",
272 conf->secondary_channel);
273 }
274#endif /* CONFIG_P2P */
275
276 if (!ssid->p2p_group &&
277 (mode->ht_capab &
278 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
279 ssid->ht40) {
280 conf->secondary_channel = wpas_p2p_get_ht40_mode(wpa_s, mode,
281 conf->channel);
282 wpa_printf(MSG_DEBUG,
283 "HT secondary channel offset %d for AP",
284 conf->secondary_channel);
285 }
286
287 if (conf->secondary_channel)
288 conf->ht_capab |=
289 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
290
291 /*
292 * white-list capabilities that won't cause issues
293 * to connecting stations, while leaving the current
294 * capabilities intact (currently disabled SMPS).
295 */
296 conf->ht_capab |= mode->ht_capab &
297 (HT_CAP_INFO_GREEN_FIELD |
298 HT_CAP_INFO_SHORT_GI20MHZ |
299 HT_CAP_INFO_SHORT_GI40MHZ |
300 HT_CAP_INFO_RX_STBC_MASK |
301 HT_CAP_INFO_TX_STBC |
302 HT_CAP_INFO_MAX_AMSDU_SIZE);
303
304 if (mode->vht_capab && ssid->vht) {
305 conf->ieee80211ac = 1;
306 conf->vht_capab |= mode->vht_capab;
307 wpas_conf_ap_vht(wpa_s, ssid, conf, mode);
308 }
309
310 if (mode->he_capab[wpas_mode_to_ieee80211_mode(
311 ssid->mode)].he_supported &&
312 ssid->he)
313 conf->ieee80211ax = 1;
314 }
315 }
316
317 if (conf->secondary_channel) {
318 struct wpa_supplicant *iface;
319
320 for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
321 {
322 if (iface == wpa_s ||
323 iface->wpa_state < WPA_AUTHENTICATING ||
324 (int) iface->assoc_freq != ssid->frequency)
325 continue;
326
327 /*
328 * Do not allow 40 MHz co-ex PRI/SEC switch to force us
329 * to change our PRI channel since we have an existing,
330 * concurrent connection on that channel and doing
331 * multi-channel concurrency is likely to cause more
332 * harm than using different PRI/SEC selection in
333 * environment with multiple BSSes on these two channels
334 * with mixed 20 MHz or PRI channel selection.
335 */
336 conf->no_pri_sec_switch = 1;
337 }
338 }
339#endif /* CONFIG_IEEE80211N */
340
341 return 0;
342}
343
344
345static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
346 struct wpa_ssid *ssid,
347 struct hostapd_config *conf)
348{
349 struct hostapd_bss_config *bss = conf->bss[0];
350
351 conf->driver = wpa_s->driver;
352
353 os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));
354
355 if (wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf))
356 return -1;
357
358 if (ssid->pbss > 1) {
359 wpa_printf(MSG_ERROR, "Invalid pbss value(%d) for AP mode",
360 ssid->pbss);
361 return -1;
362 }
363 bss->pbss = ssid->pbss;
364
365#ifdef CONFIG_ACS
366 if (ssid->acs) {
367 /* Setting channel to 0 in order to enable ACS */
368 conf->channel = 0;
369 wpa_printf(MSG_DEBUG, "Use automatic channel selection");
370 }
371#endif /* CONFIG_ACS */
372
373 if (ieee80211_is_dfs(ssid->frequency, wpa_s->hw.modes,
374 wpa_s->hw.num_modes) && wpa_s->conf->country[0]) {
375 conf->ieee80211h = 1;
376 conf->ieee80211d = 1;
377 conf->country[0] = wpa_s->conf->country[0];
378 conf->country[1] = wpa_s->conf->country[1];
379 conf->country[2] = ' ';
380 }
381
382#ifdef CONFIG_P2P
383 if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G &&
384 (ssid->mode == WPAS_MODE_P2P_GO ||
385 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)) {
386 /* Remove 802.11b rates from supported and basic rate sets */
387 int *list = os_malloc(4 * sizeof(int));
388 if (list) {
389 list[0] = 60;
390 list[1] = 120;
391 list[2] = 240;
392 list[3] = -1;
393 }
394 conf->basic_rates = list;
395
396 list = os_malloc(9 * sizeof(int));
397 if (list) {
398 list[0] = 60;
399 list[1] = 90;
400 list[2] = 120;
401 list[3] = 180;
402 list[4] = 240;
403 list[5] = 360;
404 list[6] = 480;
405 list[7] = 540;
406 list[8] = -1;
407 }
408 conf->supported_rates = list;
409 }
410
411#ifdef CONFIG_IEEE80211AX
412 if (ssid->mode == WPAS_MODE_P2P_GO ||
413 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
414 conf->ieee80211ax = ssid->he;
415#endif /* CONFIG_IEEE80211AX */
416
417 bss->isolate = !wpa_s->conf->p2p_intra_bss;
418 bss->force_per_enrollee_psk = wpa_s->global->p2p_per_sta_psk;
419
420 if (ssid->p2p_group) {
421 os_memcpy(bss->ip_addr_go, wpa_s->p2pdev->conf->ip_addr_go, 4);
422 os_memcpy(bss->ip_addr_mask, wpa_s->p2pdev->conf->ip_addr_mask,
423 4);
424 os_memcpy(bss->ip_addr_start,
425 wpa_s->p2pdev->conf->ip_addr_start, 4);
426 os_memcpy(bss->ip_addr_end, wpa_s->p2pdev->conf->ip_addr_end,
427 4);
428 }
429#endif /* CONFIG_P2P */
430
431 if (ssid->ssid_len == 0) {
432 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
433 return -1;
434 }
435 os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len);
436 bss->ssid.ssid_len = ssid->ssid_len;
437 bss->ssid.ssid_set = 1;
438
439 bss->ignore_broadcast_ssid = ssid->ignore_broadcast_ssid;
440
441 if (ssid->auth_alg)
442 bss->auth_algs = ssid->auth_alg;
443
444 if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt))
445 bss->wpa = ssid->proto;
446 if (ssid->key_mgmt == DEFAULT_KEY_MGMT)
447 bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
448 else
449 bss->wpa_key_mgmt = ssid->key_mgmt;
450 bss->wpa_pairwise = ssid->pairwise_cipher;
451 if (ssid->psk_set) {
452 bin_clear_free(bss->ssid.wpa_psk, sizeof(*bss->ssid.wpa_psk));
453 bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
454 if (bss->ssid.wpa_psk == NULL)
455 return -1;
456 os_memcpy(bss->ssid.wpa_psk->psk, ssid->psk, PMK_LEN);
457 bss->ssid.wpa_psk->group = 1;
458 bss->ssid.wpa_psk_set = 1;
459 } else if (ssid->passphrase) {
460 bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
461 } else if (ssid->wep_key_len[0] || ssid->wep_key_len[1] ||
462 ssid->wep_key_len[2] || ssid->wep_key_len[3]) {
463 struct hostapd_wep_keys *wep = &bss->ssid.wep;
464 int i;
465 for (i = 0; i < NUM_WEP_KEYS; i++) {
466 if (ssid->wep_key_len[i] == 0)
467 continue;
468 wep->key[i] = os_memdup(ssid->wep_key[i],
469 ssid->wep_key_len[i]);
470 if (wep->key[i] == NULL)
471 return -1;
472 wep->len[i] = ssid->wep_key_len[i];
473 }
474 wep->idx = ssid->wep_tx_keyidx;
475 wep->keys_set = 1;
476 }
477
478#ifdef CONFIG_SAE
479 if (ssid->sae_password &&
480 wpas_conf_ap_sae_password(bss, ssid->sae_password) < 0) {
481 wpa_printf(MSG_ERROR, "Failed to configure sae_password for AP mode");
482 return -1;
483 }
484#endif /* CONFIG_SAE */
485
486 if (wpa_s->conf->go_interworking) {
487 wpa_printf(MSG_DEBUG,
488 "P2P: Enable Interworking with access_network_type: %d",
489 wpa_s->conf->go_access_network_type);
490 bss->interworking = wpa_s->conf->go_interworking;
491 bss->access_network_type = wpa_s->conf->go_access_network_type;
492 bss->internet = wpa_s->conf->go_internet;
493 if (wpa_s->conf->go_venue_group) {
494 wpa_printf(MSG_DEBUG,
495 "P2P: Venue group: %d Venue type: %d",
496 wpa_s->conf->go_venue_group,
497 wpa_s->conf->go_venue_type);
498 bss->venue_group = wpa_s->conf->go_venue_group;
499 bss->venue_type = wpa_s->conf->go_venue_type;
500 bss->venue_info_set = 1;
501 }
502 }
503
504 if (ssid->ap_max_inactivity)
505 bss->ap_max_inactivity = ssid->ap_max_inactivity;
506
507 if (ssid->dtim_period)
508 bss->dtim_period = ssid->dtim_period;
509 else if (wpa_s->conf->dtim_period)
510 bss->dtim_period = wpa_s->conf->dtim_period;
511
512 if (ssid->beacon_int)
513 conf->beacon_int = ssid->beacon_int;
514 else if (wpa_s->conf->beacon_int)
515 conf->beacon_int = wpa_s->conf->beacon_int;
516
517#ifdef CONFIG_P2P
518 if (ssid->mode == WPAS_MODE_P2P_GO ||
519 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) {
520 if (wpa_s->conf->p2p_go_ctwindow > conf->beacon_int) {
521 wpa_printf(MSG_INFO,
522 "CTWindow (%d) is bigger than beacon interval (%d) - avoid configuring it",
523 wpa_s->conf->p2p_go_ctwindow,
524 conf->beacon_int);
525 conf->p2p_go_ctwindow = 0;
526 } else {
527 conf->p2p_go_ctwindow = wpa_s->conf->p2p_go_ctwindow;
528 }
529 }
530#endif /* CONFIG_P2P */
531
532 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
533 bss->rsn_pairwise = bss->wpa_pairwise;
534 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
535 bss->rsn_pairwise);
536
537 if (bss->wpa && bss->ieee802_1x)
538 bss->ssid.security_policy = SECURITY_WPA;
539 else if (bss->wpa)
540 bss->ssid.security_policy = SECURITY_WPA_PSK;
541 else if (bss->ieee802_1x) {
542 int cipher = WPA_CIPHER_NONE;
543 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
544 bss->ssid.wep.default_len = bss->default_wep_key_len;
545 if (bss->default_wep_key_len)
546 cipher = bss->default_wep_key_len >= 13 ?
547 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
548 bss->wpa_group = cipher;
549 bss->wpa_pairwise = cipher;
550 bss->rsn_pairwise = cipher;
551 } else if (bss->ssid.wep.keys_set) {
552 int cipher = WPA_CIPHER_WEP40;
553 if (bss->ssid.wep.len[0] >= 13)
554 cipher = WPA_CIPHER_WEP104;
555 bss->ssid.security_policy = SECURITY_STATIC_WEP;
556 bss->wpa_group = cipher;
557 bss->wpa_pairwise = cipher;
558 bss->rsn_pairwise = cipher;
559 } else {
560 bss->ssid.security_policy = SECURITY_PLAINTEXT;
561 bss->wpa_group = WPA_CIPHER_NONE;
562 bss->wpa_pairwise = WPA_CIPHER_NONE;
563 bss->rsn_pairwise = WPA_CIPHER_NONE;
564 }
565
566 if (bss->wpa_group_rekey < 86400 && (bss->wpa & 2) &&
567 (bss->wpa_group == WPA_CIPHER_CCMP ||
568 bss->wpa_group == WPA_CIPHER_GCMP ||
569 bss->wpa_group == WPA_CIPHER_CCMP_256 ||
570 bss->wpa_group == WPA_CIPHER_GCMP_256)) {
571 /*
572 * Strong ciphers do not need frequent rekeying, so increase
573 * the default GTK rekeying period to 24 hours.
574 */
575 bss->wpa_group_rekey = 86400;
576 }
577
578#ifdef CONFIG_IEEE80211W
579 if (ssid->ieee80211w != MGMT_FRAME_PROTECTION_DEFAULT)
580 bss->ieee80211w = ssid->ieee80211w;
581#endif /* CONFIG_IEEE80211W */
582
583#ifdef CONFIG_OCV
584 bss->ocv = ssid->ocv;
585#endif /* CONFIG_OCV */
586
587#ifdef CONFIG_WPS
588 /*
589 * Enable WPS by default for open and WPA/WPA2-Personal network, but
590 * require user interaction to actually use it. Only the internal
591 * Registrar is supported.
592 */
593 if (bss->ssid.security_policy != SECURITY_WPA_PSK &&
594 bss->ssid.security_policy != SECURITY_PLAINTEXT)
595 goto no_wps;
596 if (bss->ssid.security_policy == SECURITY_WPA_PSK &&
597 (!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)) ||
598 !(bss->wpa & 2)))
599 goto no_wps; /* WPS2 does not allow WPA/TKIP-only
600 * configuration */
601 if (ssid->wps_disabled)
602 goto no_wps;
603 bss->eap_server = 1;
604
605 if (!ssid->ignore_broadcast_ssid)
606 bss->wps_state = 2;
607
608 bss->ap_setup_locked = 2;
609 if (wpa_s->conf->config_methods)
610 bss->config_methods = os_strdup(wpa_s->conf->config_methods);
611 os_memcpy(bss->device_type, wpa_s->conf->device_type,
612 WPS_DEV_TYPE_LEN);
613 if (wpa_s->conf->device_name) {
614 bss->device_name = os_strdup(wpa_s->conf->device_name);
615 bss->friendly_name = os_strdup(wpa_s->conf->device_name);
616 }
617 if (wpa_s->conf->manufacturer)
618 bss->manufacturer = os_strdup(wpa_s->conf->manufacturer);
619 if (wpa_s->conf->model_name)
620 bss->model_name = os_strdup(wpa_s->conf->model_name);
621 if (wpa_s->conf->model_number)
622 bss->model_number = os_strdup(wpa_s->conf->model_number);
623 if (wpa_s->conf->serial_number)
624 bss->serial_number = os_strdup(wpa_s->conf->serial_number);
625 if (is_nil_uuid(wpa_s->conf->uuid))
626 os_memcpy(bss->uuid, wpa_s->wps->uuid, WPS_UUID_LEN);
627 else
628 os_memcpy(bss->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
629 os_memcpy(bss->os_version, wpa_s->conf->os_version, 4);
630 bss->pbc_in_m1 = wpa_s->conf->pbc_in_m1;
631 if (ssid->eap.fragment_size != DEFAULT_FRAGMENT_SIZE)
632 bss->fragment_size = ssid->eap.fragment_size;
633no_wps:
634#endif /* CONFIG_WPS */
635
636 if (wpa_s->max_stations &&
637 wpa_s->max_stations < wpa_s->conf->max_num_sta)
638 bss->max_num_sta = wpa_s->max_stations;
639 else
640 bss->max_num_sta = wpa_s->conf->max_num_sta;
641
642 if (!bss->isolate)
643 bss->isolate = wpa_s->conf->ap_isolate;
644
645 bss->disassoc_low_ack = wpa_s->conf->disassoc_low_ack;
646
647 if (wpa_s->conf->ap_vendor_elements) {
648 bss->vendor_elements =
649 wpabuf_dup(wpa_s->conf->ap_vendor_elements);
650 }
651
652 bss->ftm_responder = wpa_s->conf->ftm_responder;
653 bss->ftm_initiator = wpa_s->conf->ftm_initiator;
654
655 return 0;
656}
657
658
659static void ap_public_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
660{
661#ifdef CONFIG_P2P
662 struct wpa_supplicant *wpa_s = ctx;
663 const struct ieee80211_mgmt *mgmt;
664
665 mgmt = (const struct ieee80211_mgmt *) buf;
666 if (len < IEEE80211_HDRLEN + 1)
667 return;
668 if (mgmt->u.action.category != WLAN_ACTION_PUBLIC)
669 return;
670 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
671 mgmt->u.action.category,
672 buf + IEEE80211_HDRLEN + 1,
673 len - IEEE80211_HDRLEN - 1, freq);
674#endif /* CONFIG_P2P */
675}
676
677
678static void ap_wps_event_cb(void *ctx, enum wps_event event,
679 union wps_event_data *data)
680{
681#ifdef CONFIG_P2P
682 struct wpa_supplicant *wpa_s = ctx;
683
684 if (event == WPS_EV_FAIL) {
685 struct wps_event_fail *fail = &data->fail;
686
687 if (wpa_s->p2pdev && wpa_s->p2pdev != wpa_s &&
688 wpa_s == wpa_s->global->p2p_group_formation) {
689 /*
690 * src/ap/wps_hostapd.c has already sent this on the
691 * main interface, so only send on the parent interface
692 * here if needed.
693 */
694 wpa_msg(wpa_s->p2pdev, MSG_INFO, WPS_EVENT_FAIL
695 "msg=%d config_error=%d",
696 fail->msg, fail->config_error);
697 }
698 wpas_p2p_wps_failed(wpa_s, fail);
699 }
700#endif /* CONFIG_P2P */
701}
702
703
704static void ap_sta_authorized_cb(void *ctx, const u8 *mac_addr,
705 int authorized, const u8 *p2p_dev_addr)
706{
707 wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr);
708}
709
710
711#ifdef CONFIG_P2P
712static void ap_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
713 const u8 *psk, size_t psk_len)
714{
715
716 struct wpa_supplicant *wpa_s = ctx;
717 if (wpa_s->ap_iface == NULL || wpa_s->current_ssid == NULL)
718 return;
719 wpas_p2p_new_psk_cb(wpa_s, mac_addr, p2p_dev_addr, psk, psk_len);
720}
721#endif /* CONFIG_P2P */
722
723
724static int ap_vendor_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
725{
726#ifdef CONFIG_P2P
727 struct wpa_supplicant *wpa_s = ctx;
728 const struct ieee80211_mgmt *mgmt;
729
730 mgmt = (const struct ieee80211_mgmt *) buf;
731 if (len < IEEE80211_HDRLEN + 1)
732 return -1;
733 wpas_p2p_rx_action(wpa_s, mgmt->da, mgmt->sa, mgmt->bssid,
734 mgmt->u.action.category,
735 buf + IEEE80211_HDRLEN + 1,
736 len - IEEE80211_HDRLEN - 1, freq);
737#endif /* CONFIG_P2P */
738 return 0;
739}
740
741
742static int ap_probe_req_rx(void *ctx, const u8 *sa, const u8 *da,
743 const u8 *bssid, const u8 *ie, size_t ie_len,
744 int ssi_signal)
745{
746 struct wpa_supplicant *wpa_s = ctx;
747 unsigned int freq = 0;
748
749 if (wpa_s->ap_iface)
750 freq = wpa_s->ap_iface->freq;
751
752 return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len,
753 freq, ssi_signal);
754}
755
756
757static void ap_wps_reg_success_cb(void *ctx, const u8 *mac_addr,
758 const u8 *uuid_e)
759{
760 struct wpa_supplicant *wpa_s = ctx;
761 wpas_p2p_wps_success(wpa_s, mac_addr, 1);
762}
763
764
765static void wpas_ap_configured_cb(void *ctx)
766{
767 struct wpa_supplicant *wpa_s = ctx;
768
769 wpa_printf(MSG_DEBUG, "AP interface setup completed - state %s",
770 hostapd_state_text(wpa_s->ap_iface->state));
771 if (wpa_s->ap_iface->state == HAPD_IFACE_DISABLED) {
772 wpa_supplicant_ap_deinit(wpa_s);
773 return;
774 }
775
776#ifdef CONFIG_ACS
777 if (wpa_s->current_ssid && wpa_s->current_ssid->acs) {
778 wpa_s->assoc_freq = wpa_s->ap_iface->freq;
779 wpa_s->current_ssid->frequency = wpa_s->ap_iface->freq;
780 }
781#endif /* CONFIG_ACS */
782
783 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
784
785 if (wpa_s->ap_configured_cb)
786 wpa_s->ap_configured_cb(wpa_s->ap_configured_cb_ctx,
787 wpa_s->ap_configured_cb_data);
788}
789
790
791int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
792 struct wpa_ssid *ssid)
793{
794 struct wpa_driver_associate_params params;
795 struct hostapd_iface *hapd_iface;
796 struct hostapd_config *conf;
797 size_t i;
798 char buf[64];
799 int chan,freq;
800 u8 opclass;
801
802 if (ssid->ssid == NULL || ssid->ssid_len == 0) {
803 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
804 return -1;
805 }
806
807#ifdef CONFIG_BRCM_AUTOMOTIVE
808 if (ssid->vht == -1 && ssid->ht40 == -1) {
809 wpa_printf(MSG_ERROR, "No Channel width configured for AP mode");
810 return -1;
811 }
812#endif
813 wpa_supplicant_ap_deinit(wpa_s);
814
815 wpa_printf(MSG_DEBUG, "Setting up AP (SSID='%s')",
816 wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
817
818
819 os_memset(&params, 0, sizeof(params));
820 params.ssid = ssid->ssid;
821 params.ssid_len = ssid->ssid_len;
822 switch (ssid->mode) {
823 case WPAS_MODE_AP:
824 case WPAS_MODE_P2P_GO:
825 case WPAS_MODE_P2P_GROUP_FORMATION:
826 params.mode = IEEE80211_MODE_AP;
827 break;
828 default:
829 return -1;
830 }
831
832 wpa_s->ap_iface = hapd_iface = hostapd_alloc_iface();
833 if (hapd_iface == NULL)
834 return -1;
835 hapd_iface->owner = wpa_s;
836 hapd_iface->drv_flags = wpa_s->drv_flags;
837 hapd_iface->smps_modes = wpa_s->drv_smps_modes;
838 hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads;
839 hapd_iface->extended_capa = wpa_s->extended_capa;
840 hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
841 hapd_iface->extended_capa_len = wpa_s->extended_capa_len;
842
843 wpa_s->ap_iface->conf = conf = hostapd_config_defaults();
844 if (conf == NULL) {
845 wpa_supplicant_ap_deinit(wpa_s);
846 return -1;
847 }
848 if (ssid->frequency == 5 || ssid->frequency == 2) {
849 if (ssid->frequency == 5)
850 wpa_s->driver->driver_cmd(wpa_s->drv_priv, "HAPD_AUTO_CHANNEL band=5G", buf, sizeof(buf));
851 else
852 wpa_s->driver->driver_cmd(wpa_s->drv_priv, "HAPD_AUTO_CHANNEL band=2G", buf, sizeof(buf));
853 chan = atoi(buf);
854 /* Convert channel to frequency */
855 if (chan >= 1 && chan <= 13)
856 freq = 2407 + chan * 5;
857 else if (chan == 14)
858 freq = 2484;
859 else if (chan >= 36 && chan <= 169)
860 freq = 5000 + chan * 5;
861 ssid->frequency = freq;
862 wpa_msg(wpa_s, MSG_INFO, "\nChannel from ACS is %d and freq %d \n", chan, freq);
863 }
864 params.freq.freq = ssid->frequency;
865
866 params.wpa_proto = ssid->proto;
867 if (ssid->key_mgmt & WPA_KEY_MGMT_PSK)
868 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
869 else
870 wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
871 params.key_mgmt_suite = wpa_s->key_mgmt;
872
873 wpa_s->pairwise_cipher = wpa_pick_pairwise_cipher(ssid->pairwise_cipher,
874 1);
875 if (wpa_s->pairwise_cipher < 0) {
876 wpa_printf(MSG_WARNING, "WPA: Failed to select pairwise "
877 "cipher.");
878 return -1;
879 }
880 params.pairwise_suite = wpa_s->pairwise_cipher;
881 params.group_suite = params.pairwise_suite;
882
883#ifdef CONFIG_P2P
884 if (ssid->mode == WPAS_MODE_P2P_GO ||
885 ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
886 params.p2p = 1;
887#endif /* CONFIG_P2P */
888
889 if (wpa_s->p2pdev->set_ap_uapsd)
890 params.uapsd = wpa_s->p2pdev->ap_uapsd;
891 else if (params.p2p && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_UAPSD))
892 params.uapsd = 1; /* mandatory for P2P GO */
893 else
894 params.uapsd = -1;
895
896 if (ieee80211_is_dfs(params.freq.freq, wpa_s->hw.modes,
897 wpa_s->hw.num_modes))
898 params.freq.freq = 0; /* set channel after CAC */
899
900 if (params.p2p)
901 wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_GO);
902 else
903 wpa_drv_get_ext_capa(wpa_s, WPA_IF_AP_BSS);
904
905 if (wpa_drv_associate(wpa_s, &params) < 0) {
906 wpa_msg(wpa_s, MSG_INFO, "Failed to start AP functionality");
907 return -1;
908 }
909
910 os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params,
911 wpa_s->conf->wmm_ac_params,
912 sizeof(wpa_s->conf->wmm_ac_params));
913
914 if (params.uapsd > 0) {
915 conf->bss[0]->wmm_enabled = 1;
916 conf->bss[0]->wmm_uapsd = 1;
917 }
918
919#ifdef CONFIG_BRCM_RSN_CNTRS
920 if (wpa_s->conf->replay_cntrs) {
921 conf->bss[0]->replay_cntrs = wpa_s->conf->replay_cntrs;
922 }
923#endif /* CONFIG_BRCM_RSN_CNTRS */
924 if (wpa_supplicant_conf_ap(wpa_s, ssid, conf)) {
925 wpa_printf(MSG_ERROR, "Failed to create AP configuration");
926 wpa_supplicant_ap_deinit(wpa_s);
927 return -1;
928 }
929
930#ifdef CONFIG_P2P
931 if (ssid->mode == WPAS_MODE_P2P_GO)
932 conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
933 else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
934 conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
935 P2P_GROUP_FORMATION;
936#endif /* CONFIG_P2P */
937
938 hapd_iface->num_bss = conf->num_bss;
939 hapd_iface->bss = os_calloc(conf->num_bss,
940 sizeof(struct hostapd_data *));
941 if (hapd_iface->bss == NULL) {
942 wpa_supplicant_ap_deinit(wpa_s);
943 return -1;
944 }
945
946 for (i = 0; i < conf->num_bss; i++) {
947 hapd_iface->bss[i] =
948 hostapd_alloc_bss_data(hapd_iface, conf,
949 conf->bss[i]);
950 if (hapd_iface->bss[i] == NULL) {
951 wpa_supplicant_ap_deinit(wpa_s);
952 return -1;
953 }
954
955 hapd_iface->bss[i]->msg_ctx = wpa_s;
956 hapd_iface->bss[i]->msg_ctx_parent = wpa_s->p2pdev;
957 hapd_iface->bss[i]->public_action_cb = ap_public_action_rx;
958 hapd_iface->bss[i]->public_action_cb_ctx = wpa_s;
959 hapd_iface->bss[i]->vendor_action_cb = ap_vendor_action_rx;
960 hapd_iface->bss[i]->vendor_action_cb_ctx = wpa_s;
961 hostapd_register_probereq_cb(hapd_iface->bss[i],
962 ap_probe_req_rx, wpa_s);
963 hapd_iface->bss[i]->wps_reg_success_cb = ap_wps_reg_success_cb;
964 hapd_iface->bss[i]->wps_reg_success_cb_ctx = wpa_s;
965 hapd_iface->bss[i]->wps_event_cb = ap_wps_event_cb;
966 hapd_iface->bss[i]->wps_event_cb_ctx = wpa_s;
967 hapd_iface->bss[i]->sta_authorized_cb = ap_sta_authorized_cb;
968 hapd_iface->bss[i]->sta_authorized_cb_ctx = wpa_s;
969#ifdef CONFIG_P2P
970 hapd_iface->bss[i]->new_psk_cb = ap_new_psk_cb;
971 hapd_iface->bss[i]->new_psk_cb_ctx = wpa_s;
972 hapd_iface->bss[i]->p2p = wpa_s->global->p2p;
973 hapd_iface->bss[i]->p2p_group = wpas_p2p_group_init(wpa_s,
974 ssid);
975#endif /* CONFIG_P2P */
976 hapd_iface->bss[i]->setup_complete_cb = wpas_ap_configured_cb;
977 hapd_iface->bss[i]->setup_complete_cb_ctx = wpa_s;
978#ifdef CONFIG_TESTING_OPTIONS
979 hapd_iface->bss[i]->ext_eapol_frame_io =
980 wpa_s->ext_eapol_frame_io;
981#endif /* CONFIG_TESTING_OPTIONS */
982#ifdef CONFIG_BRCM_AUTOMOTIVE
983 if (wpa_s->conf)
984 hapd_iface->bss[i]->conf->ignore_broadcast_ssid = wpa_s->conf->ignore_broadcast_ssid;
985#endif /* CONFIG_BRCM_AUTOMOTIVE */
986 }
987
988 os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN);
989 hapd_iface->bss[0]->driver = wpa_s->driver;
990 hapd_iface->bss[0]->drv_priv = wpa_s->drv_priv;
991
992 wpa_s->current_ssid = ssid;
993 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
994 os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN);
995 wpa_s->assoc_freq = ssid->frequency;
996
997#if defined(CONFIG_P2P) && defined(CONFIG_ACS)
998 if (wpa_s->p2p_go_do_acs) {
999 wpa_s->ap_iface->conf->channel = 0;
1000 wpa_s->ap_iface->conf->hw_mode = wpa_s->p2p_go_acs_band;
1001 ssid->acs = 1;
1002 }
1003#endif /* CONFIG_P2P && CONFIG_ACS */
1004
1005 if (hostapd_setup_interface(wpa_s->ap_iface)) {
1006 wpa_printf(MSG_ERROR, "Failed to initialize AP interface");
1007 wpa_supplicant_ap_deinit(wpa_s);
1008 return -1;
1009 }
1010
1011 return 0;
1012}
1013
1014
1015void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
1016{
1017#ifdef CONFIG_WPS
1018 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
1019#endif /* CONFIG_WPS */
1020
1021 if (wpa_s->ap_iface == NULL)
1022 return;
1023
1024 wpa_s->current_ssid = NULL;
1025 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
1026 wpa_s->assoc_freq = 0;
1027 wpas_p2p_ap_deinit(wpa_s);
1028 wpa_s->ap_iface->driver_ap_teardown =
1029 !!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
1030
1031 hostapd_interface_deinit(wpa_s->ap_iface);
1032 hostapd_interface_free(wpa_s->ap_iface);
1033 wpa_s->ap_iface = NULL;
1034 wpa_drv_deinit_ap(wpa_s);
1035 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid=" MACSTR
1036 " reason=%d locally_generated=1",
1037 MAC2STR(wpa_s->own_addr), WLAN_REASON_DEAUTH_LEAVING);
1038}
1039
1040
1041void ap_tx_status(void *ctx, const u8 *addr,
1042 const u8 *buf, size_t len, int ack)
1043{
1044#ifdef NEED_AP_MLME
1045 struct wpa_supplicant *wpa_s = ctx;
1046 hostapd_tx_status(wpa_s->ap_iface->bss[0], addr, buf, len, ack);
1047#endif /* NEED_AP_MLME */
1048}
1049
1050
1051void ap_eapol_tx_status(void *ctx, const u8 *dst,
1052 const u8 *data, size_t len, int ack)
1053{
1054#ifdef NEED_AP_MLME
1055 struct wpa_supplicant *wpa_s = ctx;
1056 if (!wpa_s->ap_iface)
1057 return;
1058 hostapd_tx_status(wpa_s->ap_iface->bss[0], dst, data, len, ack);
1059#endif /* NEED_AP_MLME */
1060}
1061
1062
1063void ap_client_poll_ok(void *ctx, const u8 *addr)
1064{
1065#ifdef NEED_AP_MLME
1066 struct wpa_supplicant *wpa_s = ctx;
1067 if (wpa_s->ap_iface)
1068 hostapd_client_poll_ok(wpa_s->ap_iface->bss[0], addr);
1069#endif /* NEED_AP_MLME */
1070}
1071
1072
1073void ap_rx_from_unknown_sta(void *ctx, const u8 *addr, int wds)
1074{
1075#ifdef NEED_AP_MLME
1076 struct wpa_supplicant *wpa_s = ctx;
1077 ieee802_11_rx_from_unknown(wpa_s->ap_iface->bss[0], addr, wds);
1078#endif /* NEED_AP_MLME */
1079}
1080
1081
1082void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt)
1083{
1084#ifdef NEED_AP_MLME
1085 struct wpa_supplicant *wpa_s = ctx;
1086 struct hostapd_frame_info fi;
1087 os_memset(&fi, 0, sizeof(fi));
1088 fi.datarate = rx_mgmt->datarate;
1089 fi.ssi_signal = rx_mgmt->ssi_signal;
1090 ieee802_11_mgmt(wpa_s->ap_iface->bss[0], rx_mgmt->frame,
1091 rx_mgmt->frame_len, &fi);
1092#endif /* NEED_AP_MLME */
1093}
1094
1095
1096void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok)
1097{
1098#ifdef NEED_AP_MLME
1099 struct wpa_supplicant *wpa_s = ctx;
1100 ieee802_11_mgmt_cb(wpa_s->ap_iface->bss[0], buf, len, stype, ok);
1101#endif /* NEED_AP_MLME */
1102}
1103
1104
1105void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s,
1106 const u8 *src_addr, const u8 *buf, size_t len)
1107{
1108 ieee802_1x_receive(wpa_s->ap_iface->bss[0], src_addr, buf, len);
1109}
1110
1111
1112#ifdef CONFIG_WPS
1113
1114int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
1115 const u8 *p2p_dev_addr)
1116{
1117 if (!wpa_s->ap_iface)
1118 return -1;
1119 return hostapd_wps_button_pushed(wpa_s->ap_iface->bss[0],
1120 p2p_dev_addr);
1121}
1122
1123
1124int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s)
1125{
1126 struct wps_registrar *reg;
1127 int reg_sel = 0, wps_sta = 0;
1128
1129 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]->wps)
1130 return -1;
1131
1132 reg = wpa_s->ap_iface->bss[0]->wps->registrar;
1133 reg_sel = wps_registrar_wps_cancel(reg);
1134 wps_sta = ap_for_each_sta(wpa_s->ap_iface->bss[0],
1135 ap_sta_wps_cancel, NULL);
1136
1137 if (!reg_sel && !wps_sta) {
1138 wpa_printf(MSG_DEBUG, "No WPS operation in progress at this "
1139 "time");
1140 return -1;
1141 }
1142
1143 /*
1144 * There are 2 cases to return wps cancel as success:
1145 * 1. When wps cancel was initiated but no connection has been
1146 * established with client yet.
1147 * 2. Client is in the middle of exchanging WPS messages.
1148 */
1149
1150 return 0;
1151}
1152
1153
1154int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
1155 const char *pin, char *buf, size_t buflen,
1156 int timeout)
1157{
1158 int ret, ret_len = 0;
1159
1160 if (!wpa_s->ap_iface)
1161 return -1;
1162
1163 if (pin == NULL) {
1164 unsigned int rpin;
1165
1166 if (wps_generate_pin(&rpin) < 0)
1167 return -1;
1168 ret_len = os_snprintf(buf, buflen, "%08d", rpin);
1169 if (os_snprintf_error(buflen, ret_len))
1170 return -1;
1171 pin = buf;
1172 } else if (buf) {
1173 ret_len = os_snprintf(buf, buflen, "%s", pin);
1174 if (os_snprintf_error(buflen, ret_len))
1175 return -1;
1176 }
1177
1178 ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], bssid, "any", pin,
1179 timeout);
1180 if (ret)
1181 return -1;
1182 return ret_len;
1183}
1184
1185
1186static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx)
1187{
1188 struct wpa_supplicant *wpa_s = eloop_data;
1189 wpa_printf(MSG_DEBUG, "WPS: AP PIN timed out");
1190 wpas_wps_ap_pin_disable(wpa_s);
1191}
1192
1193
1194static void wpas_wps_ap_pin_enable(struct wpa_supplicant *wpa_s, int timeout)
1195{
1196 struct hostapd_data *hapd;
1197
1198 if (wpa_s->ap_iface == NULL)
1199 return;
1200 hapd = wpa_s->ap_iface->bss[0];
1201 wpa_printf(MSG_DEBUG, "WPS: Enabling AP PIN (timeout=%d)", timeout);
1202 hapd->ap_pin_failures = 0;
1203 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
1204 if (timeout > 0)
1205 eloop_register_timeout(timeout, 0,
1206 wpas_wps_ap_pin_timeout, wpa_s, NULL);
1207}
1208
1209
1210void wpas_wps_ap_pin_disable(struct wpa_supplicant *wpa_s)
1211{
1212 struct hostapd_data *hapd;
1213
1214 if (wpa_s->ap_iface == NULL)
1215 return;
1216 wpa_printf(MSG_DEBUG, "WPS: Disabling AP PIN");
1217 hapd = wpa_s->ap_iface->bss[0];
1218 os_free(hapd->conf->ap_pin);
1219 hapd->conf->ap_pin = NULL;
1220 eloop_cancel_timeout(wpas_wps_ap_pin_timeout, wpa_s, NULL);
1221}
1222
1223
1224const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout)
1225{
1226 struct hostapd_data *hapd;
1227 unsigned int pin;
1228 char pin_txt[9];
1229
1230 if (wpa_s->ap_iface == NULL)
1231 return NULL;
1232 hapd = wpa_s->ap_iface->bss[0];
1233 if (wps_generate_pin(&pin) < 0)
1234 return NULL;
1235 os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin);
1236 os_free(hapd->conf->ap_pin);
1237 hapd->conf->ap_pin = os_strdup(pin_txt);
1238 if (hapd->conf->ap_pin == NULL)
1239 return NULL;
1240 wpas_wps_ap_pin_enable(wpa_s, timeout);
1241
1242 return hapd->conf->ap_pin;
1243}
1244
1245
1246const char * wpas_wps_ap_pin_get(struct wpa_supplicant *wpa_s)
1247{
1248 struct hostapd_data *hapd;
1249 if (wpa_s->ap_iface == NULL)
1250 return NULL;
1251 hapd = wpa_s->ap_iface->bss[0];
1252 return hapd->conf->ap_pin;
1253}
1254
1255
1256int wpas_wps_ap_pin_set(struct wpa_supplicant *wpa_s, const char *pin,
1257 int timeout)
1258{
1259 struct hostapd_data *hapd;
1260 char pin_txt[9];
1261 int ret;
1262
1263 if (wpa_s->ap_iface == NULL)
1264 return -1;
1265 hapd = wpa_s->ap_iface->bss[0];
1266 ret = os_snprintf(pin_txt, sizeof(pin_txt), "%s", pin);
1267 if (os_snprintf_error(sizeof(pin_txt), ret))
1268 return -1;
1269 os_free(hapd->conf->ap_pin);
1270 hapd->conf->ap_pin = os_strdup(pin_txt);
1271 if (hapd->conf->ap_pin == NULL)
1272 return -1;
1273 wpas_wps_ap_pin_enable(wpa_s, timeout);
1274
1275 return 0;
1276}
1277
1278
1279void wpa_supplicant_ap_pwd_auth_fail(struct wpa_supplicant *wpa_s)
1280{
1281 struct hostapd_data *hapd;
1282
1283 if (wpa_s->ap_iface == NULL)
1284 return;
1285 hapd = wpa_s->ap_iface->bss[0];
1286
1287 /*
1288 * Registrar failed to prove its knowledge of the AP PIN. Disable AP
1289 * PIN if this happens multiple times to slow down brute force attacks.
1290 */
1291 hapd->ap_pin_failures++;
1292 wpa_printf(MSG_DEBUG, "WPS: AP PIN authentication failure number %u",
1293 hapd->ap_pin_failures);
1294 if (hapd->ap_pin_failures < 3)
1295 return;
1296
1297 wpa_printf(MSG_DEBUG, "WPS: Disable AP PIN");
1298 hapd->ap_pin_failures = 0;
1299 os_free(hapd->conf->ap_pin);
1300 hapd->conf->ap_pin = NULL;
1301}
1302
1303
1304#ifdef CONFIG_WPS_NFC
1305
1306struct wpabuf * wpas_ap_wps_nfc_config_token(struct wpa_supplicant *wpa_s,
1307 int ndef)
1308{
1309 struct hostapd_data *hapd;
1310
1311 if (wpa_s->ap_iface == NULL)
1312 return NULL;
1313 hapd = wpa_s->ap_iface->bss[0];
1314 return hostapd_wps_nfc_config_token(hapd, ndef);
1315}
1316
1317
1318struct wpabuf * wpas_ap_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
1319 int ndef)
1320{
1321 struct hostapd_data *hapd;
1322
1323 if (wpa_s->ap_iface == NULL)
1324 return NULL;
1325 hapd = wpa_s->ap_iface->bss[0];
1326 return hostapd_wps_nfc_hs_cr(hapd, ndef);
1327}
1328
1329
1330int wpas_ap_wps_nfc_report_handover(struct wpa_supplicant *wpa_s,
1331 const struct wpabuf *req,
1332 const struct wpabuf *sel)
1333{
1334 struct hostapd_data *hapd;
1335
1336 if (wpa_s->ap_iface == NULL)
1337 return -1;
1338 hapd = wpa_s->ap_iface->bss[0];
1339 return hostapd_wps_nfc_report_handover(hapd, req, sel);
1340}
1341
1342#endif /* CONFIG_WPS_NFC */
1343
1344#endif /* CONFIG_WPS */
1345
1346
1347#ifdef CONFIG_CTRL_IFACE
1348
1349int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s,
1350 char *buf, size_t buflen)
1351{
1352 struct hostapd_data *hapd;
1353
1354 if (wpa_s->ap_iface)
1355 hapd = wpa_s->ap_iface->bss[0];
1356 else if (wpa_s->ifmsh)
1357 hapd = wpa_s->ifmsh->bss[0];
1358 else
1359 return -1;
1360 return hostapd_ctrl_iface_sta_first(hapd, buf, buflen);
1361}
1362
1363
1364int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr,
1365 char *buf, size_t buflen)
1366{
1367 struct hostapd_data *hapd;
1368
1369 if (wpa_s->ap_iface)
1370 hapd = wpa_s->ap_iface->bss[0];
1371 else if (wpa_s->ifmsh)
1372 hapd = wpa_s->ifmsh->bss[0];
1373 else
1374 return -1;
1375 return hostapd_ctrl_iface_sta(hapd, txtaddr, buf, buflen);
1376}
1377
1378
1379int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr,
1380 char *buf, size_t buflen)
1381{
1382 struct hostapd_data *hapd;
1383
1384 if (wpa_s->ap_iface)
1385 hapd = wpa_s->ap_iface->bss[0];
1386 else if (wpa_s->ifmsh)
1387 hapd = wpa_s->ifmsh->bss[0];
1388 else
1389 return -1;
1390 return hostapd_ctrl_iface_sta_next(hapd, txtaddr, buf, buflen);
1391}
1392
1393
1394int ap_ctrl_iface_sta_disassociate(struct wpa_supplicant *wpa_s,
1395 const char *txtaddr)
1396{
1397 if (wpa_s->ap_iface == NULL)
1398 return -1;
1399 return hostapd_ctrl_iface_disassociate(wpa_s->ap_iface->bss[0],
1400 txtaddr);
1401}
1402
1403
1404int ap_ctrl_iface_sta_deauthenticate(struct wpa_supplicant *wpa_s,
1405 const char *txtaddr)
1406{
1407 if (wpa_s->ap_iface == NULL)
1408 return -1;
1409 return hostapd_ctrl_iface_deauthenticate(wpa_s->ap_iface->bss[0],
1410 txtaddr);
1411}
1412
1413
1414int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
1415 size_t buflen, int verbose)
1416{
1417 char *pos = buf, *end = buf + buflen;
1418 int ret;
1419 struct hostapd_bss_config *conf;
1420
1421 if (wpa_s->ap_iface == NULL)
1422 return -1;
1423
1424 conf = wpa_s->ap_iface->bss[0]->conf;
1425 if (conf->wpa == 0)
1426 return 0;
1427
1428 ret = os_snprintf(pos, end - pos,
1429 "pairwise_cipher=%s\n"
1430 "group_cipher=%s\n"
1431 "key_mgmt=%s\n",
1432 wpa_cipher_txt(conf->rsn_pairwise),
1433 wpa_cipher_txt(conf->wpa_group),
1434 wpa_key_mgmt_txt(conf->wpa_key_mgmt,
1435 conf->wpa));
1436 if (os_snprintf_error(end - pos, ret))
1437 return pos - buf;
1438 pos += ret;
1439 return pos - buf;
1440}
1441
1442#endif /* CONFIG_CTRL_IFACE */
1443
1444
1445int wpa_supplicant_ap_update_beacon(struct wpa_supplicant *wpa_s)
1446{
1447 struct hostapd_iface *iface = wpa_s->ap_iface;
1448 struct wpa_ssid *ssid = wpa_s->current_ssid;
1449 struct hostapd_data *hapd;
1450
1451 if (ssid == NULL || wpa_s->ap_iface == NULL ||
1452 ssid->mode == WPAS_MODE_INFRA ||
1453 ssid->mode == WPAS_MODE_IBSS)
1454 return -1;
1455
1456#ifdef CONFIG_P2P
1457 if (ssid->mode == WPAS_MODE_P2P_GO)
1458 iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER;
1459 else if (ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
1460 iface->conf->bss[0]->p2p = P2P_ENABLED | P2P_GROUP_OWNER |
1461 P2P_GROUP_FORMATION;
1462#endif /* CONFIG_P2P */
1463
1464 hapd = iface->bss[0];
1465 if (hapd->drv_priv == NULL)
1466 return -1;
1467 ieee802_11_set_beacons(iface);
1468 hostapd_set_ap_wps_ie(hapd);
1469
1470 return 0;
1471}
1472
1473
1474int ap_switch_channel(struct wpa_supplicant *wpa_s,
1475 struct csa_settings *settings)
1476{
1477#ifdef NEED_AP_MLME
1478 if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
1479 return -1;
1480
1481 return hostapd_switch_channel(wpa_s->ap_iface->bss[0], settings);
1482#else /* NEED_AP_MLME */
1483 return -1;
1484#endif /* NEED_AP_MLME */
1485}
1486
1487
1488#ifdef CONFIG_CTRL_IFACE
1489int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos)
1490{
1491 struct csa_settings settings;
1492 int ret = hostapd_parse_csa_settings(pos, &settings);
1493
1494 if (ret)
1495 return ret;
1496
1497 return ap_switch_channel(wpa_s, &settings);
1498}
1499#endif /* CONFIG_CTRL_IFACE */
1500
1501
1502void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
1503 int offset, int width, int cf1, int cf2, int finished)
1504{
1505 struct hostapd_iface *iface = wpa_s->ap_iface;
1506
1507 if (!iface)
1508 iface = wpa_s->ifmsh;
1509 if (!iface)
1510 return;
1511 wpa_s->assoc_freq = freq;
1512#ifdef CONFIG_BRCM_GO_CH_SWITCH_NOTIFY
1513 wpa_s->current_ssid->frequency = freq;
1514#else
1515 if (wpa_s->current_ssid)
1516 wpa_s->current_ssid->frequency = freq;
1517 hostapd_event_ch_switch(iface->bss[0], freq, ht,
1518 offset, width, cf1, cf2, finished);
1519#endif /* CONFIG_BRCM_GO_CH_SWITCH_NOTIFY */
1520
1521}
1522
1523
1524int wpa_supplicant_ap_mac_addr_filter(struct wpa_supplicant *wpa_s,
1525 const u8 *addr)
1526{
1527 struct hostapd_data *hapd;
1528 struct hostapd_bss_config *conf;
1529
1530 if (!wpa_s->ap_iface)
1531 return -1;
1532
1533 if (addr)
1534 wpa_printf(MSG_DEBUG, "AP: Set MAC address filter: " MACSTR,
1535 MAC2STR(addr));
1536 else
1537 wpa_printf(MSG_DEBUG, "AP: Clear MAC address filter");
1538
1539 hapd = wpa_s->ap_iface->bss[0];
1540 conf = hapd->conf;
1541
1542 os_free(conf->accept_mac);
1543 conf->accept_mac = NULL;
1544 conf->num_accept_mac = 0;
1545 os_free(conf->deny_mac);
1546 conf->deny_mac = NULL;
1547 conf->num_deny_mac = 0;
1548
1549 if (addr == NULL) {
1550 conf->macaddr_acl = ACCEPT_UNLESS_DENIED;
1551 return 0;
1552 }
1553
1554 conf->macaddr_acl = DENY_UNLESS_ACCEPTED;
1555 conf->accept_mac = os_zalloc(sizeof(struct mac_acl_entry));
1556 if (conf->accept_mac == NULL)
1557 return -1;
1558 os_memcpy(conf->accept_mac[0].addr, addr, ETH_ALEN);
1559 conf->num_accept_mac = 1;
1560
1561 return 0;
1562}
1563
1564
1565#ifdef CONFIG_WPS_NFC
1566int wpas_ap_wps_add_nfc_pw(struct wpa_supplicant *wpa_s, u16 pw_id,
1567 const struct wpabuf *pw, const u8 *pubkey_hash)
1568{
1569 struct hostapd_data *hapd;
1570 struct wps_context *wps;
1571
1572 if (!wpa_s->ap_iface)
1573 return -1;
1574 hapd = wpa_s->ap_iface->bss[0];
1575 wps = hapd->wps;
1576
1577 if (wpa_s->p2pdev->conf->wps_nfc_dh_pubkey == NULL ||
1578 wpa_s->p2pdev->conf->wps_nfc_dh_privkey == NULL) {
1579 wpa_printf(MSG_DEBUG, "P2P: No NFC DH key known");
1580 return -1;
1581 }
1582
1583 dh5_free(wps->dh_ctx);
1584 wpabuf_free(wps->dh_pubkey);
1585 wpabuf_free(wps->dh_privkey);
1586 wps->dh_privkey = wpabuf_dup(
1587 wpa_s->p2pdev->conf->wps_nfc_dh_privkey);
1588 wps->dh_pubkey = wpabuf_dup(
1589 wpa_s->p2pdev->conf->wps_nfc_dh_pubkey);
1590 if (wps->dh_privkey == NULL || wps->dh_pubkey == NULL) {
1591 wps->dh_ctx = NULL;
1592 wpabuf_free(wps->dh_pubkey);
1593 wps->dh_pubkey = NULL;
1594 wpabuf_free(wps->dh_privkey);
1595 wps->dh_privkey = NULL;
1596 return -1;
1597 }
1598 wps->dh_ctx = dh5_init_fixed(wps->dh_privkey, wps->dh_pubkey);
1599 if (wps->dh_ctx == NULL)
1600 return -1;
1601
1602 return wps_registrar_add_nfc_pw_token(hapd->wps->registrar, pubkey_hash,
1603 pw_id,
1604 pw ? wpabuf_head(pw) : NULL,
1605 pw ? wpabuf_len(pw) : 0, 1);
1606}
1607#endif /* CONFIG_WPS_NFC */
1608
1609
1610#ifdef CONFIG_CTRL_IFACE
1611int wpas_ap_stop_ap(struct wpa_supplicant *wpa_s)
1612{
1613 struct hostapd_data *hapd;
1614
1615 if (!wpa_s->ap_iface)
1616 return -1;
1617 hapd = wpa_s->ap_iface->bss[0];
1618 return hostapd_ctrl_iface_stop_ap(hapd);
1619}
1620
1621
1622int wpas_ap_pmksa_cache_list(struct wpa_supplicant *wpa_s, char *buf,
1623 size_t len)
1624{
1625 size_t reply_len = 0, i;
1626 char ap_delimiter[] = "---- AP ----\n";
1627 char mesh_delimiter[] = "---- mesh ----\n";
1628 size_t dlen;
1629
1630 if (wpa_s->ap_iface) {
1631 dlen = os_strlen(ap_delimiter);
1632 if (dlen > len - reply_len)
1633 return reply_len;
1634 os_memcpy(&buf[reply_len], ap_delimiter, dlen);
1635 reply_len += dlen;
1636
1637 for (i = 0; i < wpa_s->ap_iface->num_bss; i++) {
1638 reply_len += hostapd_ctrl_iface_pmksa_list(
1639 wpa_s->ap_iface->bss[i],
1640 &buf[reply_len], len - reply_len);
1641 }
1642 }
1643
1644 if (wpa_s->ifmsh) {
1645 dlen = os_strlen(mesh_delimiter);
1646 if (dlen > len - reply_len)
1647 return reply_len;
1648 os_memcpy(&buf[reply_len], mesh_delimiter, dlen);
1649 reply_len += dlen;
1650
1651 reply_len += hostapd_ctrl_iface_pmksa_list(
1652 wpa_s->ifmsh->bss[0], &buf[reply_len],
1653 len - reply_len);
1654 }
1655
1656 return reply_len;
1657}
1658
1659
1660void wpas_ap_pmksa_cache_flush(struct wpa_supplicant *wpa_s)
1661{
1662 size_t i;
1663
1664 if (wpa_s->ap_iface) {
1665 for (i = 0; i < wpa_s->ap_iface->num_bss; i++)
1666 hostapd_ctrl_iface_pmksa_flush(wpa_s->ap_iface->bss[i]);
1667 }
1668
1669 if (wpa_s->ifmsh)
1670 hostapd_ctrl_iface_pmksa_flush(wpa_s->ifmsh->bss[0]);
1671}
1672
1673
1674#ifdef CONFIG_PMKSA_CACHE_EXTERNAL
1675#ifdef CONFIG_MESH
1676
1677int wpas_ap_pmksa_cache_list_mesh(struct wpa_supplicant *wpa_s, const u8 *addr,
1678 char *buf, size_t len)
1679{
1680 return hostapd_ctrl_iface_pmksa_list_mesh(wpa_s->ifmsh->bss[0], addr,
1681 &buf[0], len);
1682}
1683
1684
1685int wpas_ap_pmksa_cache_add_external(struct wpa_supplicant *wpa_s, char *cmd)
1686{
1687 struct external_pmksa_cache *entry;
1688 void *pmksa_cache;
1689
1690 pmksa_cache = hostapd_ctrl_iface_pmksa_create_entry(wpa_s->own_addr,
1691 cmd);
1692 if (!pmksa_cache)
1693 return -1;
1694
1695 entry = os_zalloc(sizeof(struct external_pmksa_cache));
1696 if (!entry)
1697 return -1;
1698
1699 entry->pmksa_cache = pmksa_cache;
1700
1701 dl_list_add(&wpa_s->mesh_external_pmksa_cache, &entry->list);
1702
1703 return 0;
1704}
1705
1706#endif /* CONFIG_MESH */
1707#endif /* CONFIG_PMKSA_CACHE_EXTERNAL */
1708
1709#endif /* CONFIG_CTRL_IFACE */
1710
1711
1712#ifdef NEED_AP_MLME
1713void wpas_ap_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
1714 struct dfs_event *radar)
1715{
1716 struct hostapd_iface *iface = wpa_s->ap_iface;
1717
1718 if (!iface)
1719 iface = wpa_s->ifmsh;
1720 if (!iface || !iface->bss[0])
1721 return;
1722 wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq);
1723 hostapd_dfs_radar_detected(iface, radar->freq,
1724 radar->ht_enabled, radar->chan_offset,
1725 radar->chan_width,
1726 radar->cf1, radar->cf2);
1727}
1728
1729
1730void wpas_ap_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
1731 struct dfs_event *radar)
1732{
1733 struct hostapd_iface *iface = wpa_s->ap_iface;
1734
1735 if (!iface)
1736 iface = wpa_s->ifmsh;
1737 if (!iface || !iface->bss[0])
1738 return;
1739 wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq);
1740 hostapd_dfs_start_cac(iface, radar->freq,
1741 radar->ht_enabled, radar->chan_offset,
1742 radar->chan_width, radar->cf1, radar->cf2);
1743}
1744
1745
1746void wpas_ap_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
1747 struct dfs_event *radar)
1748{
1749 struct hostapd_iface *iface = wpa_s->ap_iface;
1750
1751 if (!iface)
1752 iface = wpa_s->ifmsh;
1753 if (!iface || !iface->bss[0])
1754 return;
1755 wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq);
1756 hostapd_dfs_complete_cac(iface, 1, radar->freq,
1757 radar->ht_enabled, radar->chan_offset,
1758 radar->chan_width, radar->cf1, radar->cf2);
1759}
1760
1761
1762void wpas_ap_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
1763 struct dfs_event *radar)
1764{
1765 struct hostapd_iface *iface = wpa_s->ap_iface;
1766
1767 if (!iface)
1768 iface = wpa_s->ifmsh;
1769 if (!iface || !iface->bss[0])
1770 return;
1771 wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq);
1772 hostapd_dfs_complete_cac(iface, 0, radar->freq,
1773 radar->ht_enabled, radar->chan_offset,
1774 radar->chan_width, radar->cf1, radar->cf2);
1775}
1776
1777
1778void wpas_ap_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
1779 struct dfs_event *radar)
1780{
1781 struct hostapd_iface *iface = wpa_s->ap_iface;
1782
1783 if (!iface)
1784 iface = wpa_s->ifmsh;
1785 if (!iface || !iface->bss[0])
1786 return;
1787 wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq);
1788 hostapd_dfs_nop_finished(iface, radar->freq,
1789 radar->ht_enabled, radar->chan_offset,
1790 radar->chan_width, radar->cf1, radar->cf2);
1791}
1792#endif /* NEED_AP_MLME */
1793
1794
1795void ap_periodic(struct wpa_supplicant *wpa_s)
1796{
1797 if (wpa_s->ap_iface)
1798 hostapd_periodic_iface(wpa_s->ap_iface);
1799}
1800
1801#ifdef CONFIG_BRCM_AUTOMOTIVE
1802void wpas_ap_set_interworking_ie(struct wpa_supplicant *wpa_s)
1803{
1804 int ret = 0;
1805 ret = wpa_supplicant_ap_update_beacon(wpa_s);
1806 wpa_printf(MSG_DEBUG, "%s: ret:%d\n", __FUNCTION__, ret);
1807}
1808#endif