Lines Matching refs:hapd
64 static int wps_stop_registrar(struct hostapd_data *hapd, void *ctx) in wps_stop_registrar() argument
67 if (hapd != data->current_hapd && hapd->wps != NULL) in wps_stop_registrar()
68 wps_registrar_complete(hapd->wps->registrar, data->uuid_e, in wps_stop_registrar()
73 void hostapd_wps_eap_completed(struct hostapd_data *hapd) in hostapd_wps_eap_completed() argument
81 struct hostapd_data *hapd = ctx; in hostapd_wps_reg_success_cb() local
86 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_REG_SUCCESS MACSTR " %s", in hostapd_wps_reg_success_cb()
88 data.current_hapd = hapd; in hostapd_wps_reg_success_cb()
92 wps_stop_registrar(hapd, &data); in hostapd_wps_reg_success_cb()
100 struct hostapd_data *hapd = eloop_data; in hostapd_wps_reenable_ap_pin() local
102 if (hapd->conf->ap_setup_locked) in hostapd_wps_reenable_ap_pin()
104 if (hapd->ap_pin_failures_consecutive >= 10) in hostapd_wps_reenable_ap_pin()
108 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_UNLOCKED); in hostapd_wps_reenable_ap_pin()
109 hapd->wps->ap_setup_locked = 0; in hostapd_wps_reenable_ap_pin()
110 wps_registrar_update_ie(hapd->wps->registrar); in hostapd_wps_reenable_ap_pin()
113 static void hostapd_pwd_auth_fail(struct hostapd_data *hapd, in hostapd_pwd_auth_fail() argument
120 hapd->wps_stats.status = WPS_FAILURE_STATUS; in hostapd_pwd_auth_fail()
121 os_memcpy(hapd->wps_stats.peer_addr, data->peer_macaddr, ETH_ALEN); in hostapd_pwd_auth_fail()
130 static int wps_ap_pin_success(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_success() argument
132 if (hapd->conf->ap_pin == NULL || hapd->wps == NULL) in wps_ap_pin_success()
135 if (hapd->ap_pin_failures_consecutive == 0) in wps_ap_pin_success()
140 hapd->ap_pin_failures, hapd->ap_pin_failures_consecutive); in wps_ap_pin_success()
141 hapd->ap_pin_failures_consecutive = 0; in wps_ap_pin_success()
147 static void hostapd_wps_event_pbc_overlap(struct hostapd_data *hapd) in hostapd_wps_event_pbc_overlap() argument
151 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_OVERLAP; in hostapd_wps_event_pbc_overlap()
156 static void hostapd_wps_event_pbc_timeout(struct hostapd_data *hapd) in hostapd_wps_event_pbc_timeout() argument
159 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_TIMEOUT; in hostapd_wps_event_pbc_timeout()
163 static void hostapd_wps_event_pin_timeout(struct hostapd_data *hapd) in hostapd_wps_event_pin_timeout() argument
168 static void hostapd_wps_event_pbc_disable(struct hostapd_data *hapd) in hostapd_wps_event_pbc_disable() argument
171 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_DISABLE; in hostapd_wps_event_pbc_disable()
175 static void hostapd_wps_event_success(struct hostapd_data *hapd, in hostapd_wps_event_success() argument
186 static void hostapd_wps_event_fail(struct hostapd_data *hapd, in hostapd_wps_event_fail() argument
203 struct hostapd_data *hapd = ctx; in hostapd_wps_event_cb() local
207 hostapd_wps_event_fail(hapd, &data->fail); in hostapd_wps_event_cb()
210 hostapd_wps_event_success(hapd, &data->success); in hostapd_wps_event_cb()
211 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_SUCCESS); in hostapd_wps_event_cb()
214 hostapd_pwd_auth_fail(hapd, &data->pwd_auth_fail); in hostapd_wps_event_cb()
217 hostapd_wps_event_pbc_overlap(hapd); in hostapd_wps_event_cb()
218 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_OVERLAP); in hostapd_wps_event_cb()
221 hostapd_wps_event_pbc_timeout(hapd); in hostapd_wps_event_cb()
222 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_TIMEOUT); in hostapd_wps_event_cb()
225 hostapd_wps_event_pin_timeout(hapd); in hostapd_wps_event_cb()
227 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_ACTIVE); in hostapd_wps_event_cb()
230 hostapd_wps_event_pbc_disable(hapd); in hostapd_wps_event_cb()
231 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_DISABLE); in hostapd_wps_event_cb()
246 wps_ap_pin_success(hapd, NULL); in hostapd_wps_event_cb()
251 if (hapd->wps_event_cb) in hostapd_wps_event_cb()
252 hapd->wps_event_cb(hapd, event, data); in hostapd_wps_event_cb()
262 static void hostapd_wps_clear_ies(struct hostapd_data *hapd, int deinit_only) in hostapd_wps_clear_ies() argument
281 int hostapd_init_wps(struct hostapd_data *hapd, struct wps_data *wps_data, struct wps_context *wps) in hostapd_init_wps() argument
287 wps->cb_ctx = hapd; in hostapd_init_wps()
294 hostapd_wps_config_ap(hapd, wps_data); in hostapd_init_wps()
299 cfg.cb_ctx = hapd; in hostapd_init_wps()
308 hapd->wps = wps; in hostapd_init_wps()
314 if (ieee802_1x_init(hapd) < 0) { in hostapd_init_wps()
325 static int ap_sta_server_sm_deinit(struct hostapd_data *hapd, in ap_sta_server_sm_deinit() argument
328 ieee802_1x_free_station(hapd, sta); in ap_sta_server_sm_deinit()
333 void hostapd_deinit_wps(struct hostapd_data *hapd) in hostapd_deinit_wps() argument
335 eloop_cancel_timeout(hostapd_wps_reenable_ap_pin, hapd, NULL); in hostapd_deinit_wps()
336 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_deinit_wps()
337 if (hapd->wps == NULL) { in hostapd_deinit_wps()
338 hostapd_wps_clear_ies(hapd, 1); in hostapd_deinit_wps()
341 wps_registrar_deinit(hapd->wps->registrar); in hostapd_deinit_wps()
342 hapd->wps->registrar = NULL; in hostapd_deinit_wps()
345 ap_for_each_sta(hapd, ap_sta_server_sm_deinit, NULL); in hostapd_deinit_wps()
349 hapd->wps = NULL; in hostapd_deinit_wps()
350 hostapd_wps_clear_ies(hapd, 1); in hostapd_deinit_wps()
354 void hostapd_update_wps(struct hostapd_data *hapd) in hostapd_update_wps() argument
356 struct wps_context *wps = hapd->wps; in hostapd_update_wps()
357 struct hostapd_bss_config *conf = hapd->conf; in hostapd_update_wps()
366 hostapd_wps_config_ap(hapd, NULL); in hostapd_update_wps()
371 int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *pin) in hostapd_wps_add_pin() argument
375 if (hapd->wps == NULL) in hostapd_wps_add_pin()
377 ret = wps_registrar_add_pin(hapd->wps->registrar, NULL, in hostapd_wps_add_pin()
382 int hostapd_wps_button_pushed(struct hostapd_data *hapd, in hostapd_wps_button_pushed() argument
385 if (hapd->wps) { in hostapd_wps_button_pushed()
386 return wps_registrar_button_pushed(hapd->wps->registrar, in hostapd_wps_button_pushed()
393 static int wps_cancel(struct hostapd_data *hapd) in wps_cancel() argument
395 if (hapd->wps) { in wps_cancel()
396 wps_registrar_wps_cancel(hapd->wps->registrar); in wps_cancel()
397 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_CANCEL); in wps_cancel()
404 int hostapd_wps_cancel(struct hostapd_data *hapd) in hostapd_wps_cancel() argument
408 ret = wps_cancel(hapd); in hostapd_wps_cancel()
415 struct hostapd_data *hapd = eloop_data; in hostapd_wps_ap_pin_timeout() local
417 hostapd_wps_ap_pin_disable(hapd); in hostapd_wps_ap_pin_timeout()
418 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_PIN_DISABLED); in hostapd_wps_ap_pin_timeout()
422 static void hostapd_wps_ap_pin_enable(struct hostapd_data *hapd, int timeout) in hostapd_wps_ap_pin_enable() argument
425 hapd->ap_pin_failures = 0; in hostapd_wps_ap_pin_enable()
426 hapd->ap_pin_failures_consecutive = 0; in hostapd_wps_ap_pin_enable()
427 hapd->conf->ap_setup_locked = 0; in hostapd_wps_ap_pin_enable()
428 if (hapd->wps->ap_setup_locked) { in hostapd_wps_ap_pin_enable()
429 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_UNLOCKED); in hostapd_wps_ap_pin_enable()
430 hapd->wps->ap_setup_locked = 0; in hostapd_wps_ap_pin_enable()
431 wps_registrar_update_ie(hapd->wps->registrar); in hostapd_wps_ap_pin_enable()
433 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_wps_ap_pin_enable()
436 hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_wps_ap_pin_enable()
439 static int wps_ap_pin_disable(struct hostapd_data *hapd) in wps_ap_pin_disable() argument
441 os_free(hapd->conf->ap_pin); in wps_ap_pin_disable()
442 hapd->conf->ap_pin = NULL; in wps_ap_pin_disable()
443 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in wps_ap_pin_disable()
448 void hostapd_wps_ap_pin_disable(struct hostapd_data *hapd) in hostapd_wps_ap_pin_disable() argument
451 wps_ap_pin_disable(hapd); in hostapd_wps_ap_pin_disable()
461 static int wps_ap_pin_set(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_set() argument
465 if (!hapd->wps) in wps_ap_pin_set()
468 os_free(hapd->conf->ap_pin); in wps_ap_pin_set()
469 hapd->conf->ap_pin = os_strdup(data->pin_txt); in wps_ap_pin_set()
470 hostapd_wps_ap_pin_enable(hapd, data->timeout); in wps_ap_pin_set()
475 const char * hostapd_wps_ap_pin_random(struct hostapd_data *hapd, int timeout) in hostapd_wps_ap_pin_random() argument
484 wps_ap_pin_set(hapd, &data); in hostapd_wps_ap_pin_random()
485 return hapd->conf->ap_pin; in hostapd_wps_ap_pin_random()
488 const char * hostapd_wps_ap_pin_get(struct hostapd_data *hapd) in hostapd_wps_ap_pin_get() argument
490 return hapd->conf->ap_pin; in hostapd_wps_ap_pin_get()
494 int hostapd_wps_ap_pin_set(struct hostapd_data *hapd, const char *pin, in hostapd_wps_ap_pin_set() argument
504 return wps_ap_pin_set(hapd, &data); in hostapd_wps_ap_pin_set()
508 int hostapd_wps_config_ap(struct hostapd_data *hapd, struct wps_data *wps_data) in hostapd_wps_config_ap() argument
512 os_memcpy(cred.ssid, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len); in hostapd_wps_config_ap()
513 cred.ssid_len = hapd->conf->ssid.ssid_len; in hostapd_wps_config_ap()
517 if (hapd->wpa_auth->conf.wpa == WPA_PROTO_WPA) { in hostapd_wps_config_ap()
520 } else if (hapd->wpa_auth->conf.wpa == WPA_PROTO_RSN) { in hostapd_wps_config_ap()
523 } else if (hapd->wpa_auth->conf.wpa == (WPA_PROTO_RSN | WPA_PROTO_WPA)) { in hostapd_wps_config_ap()
528 if (hapd->conf->ssid.wpa_passphrase) { in hostapd_wps_config_ap()
529 cred.key_len = os_strlen(hapd->conf->ssid.wpa_passphrase); in hostapd_wps_config_ap()
530 memcpy(cred.key, hapd->conf->ssid.wpa_passphrase, cred.key_len); in hostapd_wps_config_ap()