Lines Matching refs:hapd
33 static int hostapd_wps_upnp_init(struct hostapd_data *hapd,
35 static void hostapd_wps_upnp_deinit(struct hostapd_data *hapd);
61 struct hostapd_data *hapd = iface->bss[j]; in wps_for_each() local
64 if (hapd != data->calling_hapd && in wps_for_each()
65 (hapd->conf->wps_independent || in wps_for_each()
69 ret = data->func(hapd, data->ctx); in wps_for_each()
78 static int hostapd_wps_for_each(struct hostapd_data *hapd, in hostapd_wps_for_each() argument
82 struct hostapd_iface *iface = hapd->iface; in hostapd_wps_for_each()
86 data.calling_hapd = hapd; in hostapd_wps_for_each()
99 struct hostapd_data *hapd = ctx; in hostapd_wps_new_psk_cb() local
101 struct hostapd_ssid *ssid = &hapd->conf->ssid; in hostapd_wps_new_psk_cb()
129 if (hapd->new_psk_cb) { in hostapd_wps_new_psk_cb()
130 hapd->new_psk_cb(hapd->new_psk_cb_ctx, mac_addr, p2p_dev_addr, in hostapd_wps_new_psk_cb()
160 struct hostapd_data *hapd = ctx; in hostapd_wps_set_ie_cb() local
161 wpabuf_free(hapd->wps_beacon_ie); in hostapd_wps_set_ie_cb()
162 hapd->wps_beacon_ie = beacon_ie; in hostapd_wps_set_ie_cb()
163 wpabuf_free(hapd->wps_probe_resp_ie); in hostapd_wps_set_ie_cb()
164 hapd->wps_probe_resp_ie = probe_resp_ie; in hostapd_wps_set_ie_cb()
165 if (hapd->beacon_set_done) in hostapd_wps_set_ie_cb()
166 ieee802_11_set_beacon(hapd); in hostapd_wps_set_ie_cb()
167 return hostapd_set_ap_wps_ie(hapd); in hostapd_wps_set_ie_cb()
174 struct hostapd_data *hapd = ctx; in hostapd_wps_pin_needed_cb() local
189 wpa_msg(hapd->msg_ctx, MSG_INFO, "%s", txt); in hostapd_wps_pin_needed_cb()
191 if (hapd->conf->wps_pin_requests) { in hostapd_wps_pin_needed_cb()
194 f = fopen(hapd->conf->wps_pin_requests, "a"); in hostapd_wps_pin_needed_cb()
217 static int wps_stop_registrar(struct hostapd_data *hapd, void *ctx) in wps_stop_registrar() argument
220 if (hapd != data->current_hapd && hapd->wps != NULL) in wps_stop_registrar()
221 wps_registrar_complete(hapd->wps->registrar, data->uuid_e, in wps_stop_registrar()
231 struct hostapd_data *hapd = ctx; in hostapd_wps_reg_success_cb() local
236 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_REG_SUCCESS MACSTR " %s", in hostapd_wps_reg_success_cb()
238 if (hapd->wps_reg_success_cb) in hostapd_wps_reg_success_cb()
239 hapd->wps_reg_success_cb(hapd->wps_reg_success_cb_ctx, in hostapd_wps_reg_success_cb()
241 data.current_hapd = hapd; in hostapd_wps_reg_success_cb()
245 hostapd_wps_for_each(hapd, wps_stop_registrar, &data); in hostapd_wps_reg_success_cb()
256 struct hostapd_data *hapd = ctx; in hostapd_wps_enrollee_seen_cb() local
263 wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, WPS_EVENT_ENROLLEE_SEEN MACSTR in hostapd_wps_enrollee_seen_cb()
285 void hostapd_wps_eap_completed(struct hostapd_data *hapd) in hostapd_wps_eap_completed() argument
293 if (eloop_deplete_timeout(0, 0, wps_reload_config, hapd->iface, NULL) == in hostapd_wps_eap_completed()
299 static void hapd_new_ap_event(struct hostapd_data *hapd, const u8 *attr, in hapd_new_ap_event() argument
306 wpa_msg(hapd->msg_ctx, MSG_INFO, in hapd_new_ap_event()
313 static int hapd_wps_reconfig_in_memory(struct hostapd_data *hapd, in hapd_wps_reconfig_in_memory() argument
316 struct hostapd_bss_config *bss = hapd->conf; in hapd_wps_reconfig_in_memory()
345 if (hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD) in hapd_wps_reconfig_in_memory()
357 if (hapd->conf->wps_cred_add_sae && in hapd_wps_reconfig_in_memory()
400 eloop_register_timeout(0, 100000, wps_reload_config, hapd->iface, in hapd_wps_reconfig_in_memory()
407 static int hapd_wps_cred_cb(struct hostapd_data *hapd, void *ctx) in hapd_wps_cred_cb() argument
418 if (hapd->wps == NULL) in hapd_wps_cred_cb()
435 if ((hapd->conf->wps_cred_processing == 1 || in hapd_wps_cred_cb()
436 hapd->conf->wps_cred_processing == 2) && cred->cred_attr) { in hapd_wps_cred_cb()
437 hapd_new_ap_event(hapd, cred->cred_attr, cred->cred_attr_len); in hapd_wps_cred_cb()
438 } else if (hapd->conf->wps_cred_processing == 1 || in hapd_wps_cred_cb()
439 hapd->conf->wps_cred_processing == 2) { in hapd_wps_cred_cb()
443 hapd_new_ap_event(hapd, wpabuf_head_u8(attr), in hapd_wps_cred_cb()
447 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_NEW_AP_SETTINGS); in hapd_wps_cred_cb()
449 if (hapd->conf->wps_cred_processing == 1) in hapd_wps_cred_cb()
452 os_memcpy(hapd->wps->ssid, cred->ssid, cred->ssid_len); in hapd_wps_cred_cb()
453 hapd->wps->ssid_len = cred->ssid_len; in hapd_wps_cred_cb()
454 hapd->wps->encr_types = cred->encr_type; in hapd_wps_cred_cb()
455 hapd->wps->encr_types_rsn = cred->encr_type; in hapd_wps_cred_cb()
456 hapd->wps->encr_types_wpa = cred->encr_type; in hapd_wps_cred_cb()
457 hapd->wps->auth_types = cred->auth_type; in hapd_wps_cred_cb()
458 hapd->wps->ap_encr_type = cred->encr_type; in hapd_wps_cred_cb()
459 hapd->wps->ap_auth_type = cred->auth_type; in hapd_wps_cred_cb()
461 os_free(hapd->wps->network_key); in hapd_wps_cred_cb()
462 hapd->wps->network_key = NULL; in hapd_wps_cred_cb()
463 hapd->wps->network_key_len = 0; in hapd_wps_cred_cb()
470 if (hapd->wps->network_key == NULL || in hapd_wps_cred_cb()
471 hapd->wps->network_key_len < cred->key_len) { in hapd_wps_cred_cb()
472 hapd->wps->network_key_len = 0; in hapd_wps_cred_cb()
473 os_free(hapd->wps->network_key); in hapd_wps_cred_cb()
474 hapd->wps->network_key = os_malloc(cred->key_len); in hapd_wps_cred_cb()
475 if (hapd->wps->network_key == NULL) in hapd_wps_cred_cb()
478 hapd->wps->network_key_len = cred->key_len; in hapd_wps_cred_cb()
479 os_memcpy(hapd->wps->network_key, cred->key, cred->key_len); in hapd_wps_cred_cb()
481 hapd->wps->wps_state = WPS_STATE_CONFIGURED; in hapd_wps_cred_cb()
483 if (hapd->iface->config_fname == NULL) in hapd_wps_cred_cb()
484 return hapd_wps_reconfig_in_memory(hapd, cred); in hapd_wps_cred_cb()
485 len = os_strlen(hapd->iface->config_fname) + 5; in hapd_wps_cred_cb()
489 os_snprintf(tmp_fname, len, "%s-new", hapd->iface->config_fname); in hapd_wps_cred_cb()
491 oconf = fopen(hapd->iface->config_fname, "r"); in hapd_wps_cred_cb()
552 if (hapd->conf->wps_cred_add_sae && in hapd_wps_cred_cb()
563 if (sae && hapd->conf->ieee80211w == NO_MGMT_FRAME_PROTECTION) { in hapd_wps_cred_cb()
575 if (hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD) in hapd_wps_cred_cb()
640 if (rename(tmp_fname, hapd->iface->config_fname) < 0) { in hapd_wps_cred_cb()
652 eloop_register_timeout(0, 100000, wps_reload_config, hapd->iface, in hapd_wps_cred_cb()
663 struct hostapd_data *hapd = ctx; in hostapd_wps_cred_cb() local
664 return hostapd_wps_for_each(hapd, hapd_wps_cred_cb, (void *) cred); in hostapd_wps_cred_cb()
670 struct hostapd_data *hapd = eloop_data; in hostapd_wps_reenable_ap_pin() local
672 if (hapd->conf->ap_setup_locked) in hostapd_wps_reenable_ap_pin()
674 if (hapd->ap_pin_failures_consecutive >= 10) in hostapd_wps_reenable_ap_pin()
678 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_UNLOCKED); in hostapd_wps_reenable_ap_pin()
679 hapd->wps->ap_setup_locked = 0; in hostapd_wps_reenable_ap_pin()
680 wps_registrar_update_ie(hapd->wps->registrar); in hostapd_wps_reenable_ap_pin()
684 static int wps_pwd_auth_fail(struct hostapd_data *hapd, void *ctx) in wps_pwd_auth_fail() argument
688 if (!data->enrollee || hapd->conf->ap_pin == NULL || hapd->wps == NULL) in wps_pwd_auth_fail()
696 hapd->ap_pin_failures++; in wps_pwd_auth_fail()
697 hapd->ap_pin_failures_consecutive++; in wps_pwd_auth_fail()
700 hapd->ap_pin_failures, hapd->ap_pin_failures_consecutive); in wps_pwd_auth_fail()
701 if (hapd->ap_pin_failures < 3) in wps_pwd_auth_fail()
704 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_LOCKED); in wps_pwd_auth_fail()
705 hapd->wps->ap_setup_locked = 1; in wps_pwd_auth_fail()
707 wps_registrar_update_ie(hapd->wps->registrar); in wps_pwd_auth_fail()
709 if (!hapd->conf->ap_setup_locked && in wps_pwd_auth_fail()
710 hapd->ap_pin_failures_consecutive >= 10) { in wps_pwd_auth_fail()
715 eloop_cancel_timeout(hostapd_wps_reenable_ap_pin, hapd, NULL); in wps_pwd_auth_fail()
717 } else if (!hapd->conf->ap_setup_locked) { in wps_pwd_auth_fail()
718 if (hapd->ap_pin_lockout_time == 0) in wps_pwd_auth_fail()
719 hapd->ap_pin_lockout_time = 60; in wps_pwd_auth_fail()
720 else if (hapd->ap_pin_lockout_time < 365 * 24 * 60 * 60 && in wps_pwd_auth_fail()
721 (hapd->ap_pin_failures % 3) == 0) in wps_pwd_auth_fail()
722 hapd->ap_pin_lockout_time *= 2; in wps_pwd_auth_fail()
725 hapd->ap_pin_lockout_time); in wps_pwd_auth_fail()
726 eloop_cancel_timeout(hostapd_wps_reenable_ap_pin, hapd, NULL); in wps_pwd_auth_fail()
727 eloop_register_timeout(hapd->ap_pin_lockout_time, 0, in wps_pwd_auth_fail()
728 hostapd_wps_reenable_ap_pin, hapd, in wps_pwd_auth_fail()
736 static void hostapd_pwd_auth_fail(struct hostapd_data *hapd, in hostapd_pwd_auth_fail() argument
741 hapd->wps_stats.status = WPS_STATUS_FAILURE; in hostapd_pwd_auth_fail()
742 hapd->wps_stats.failure_reason = WPS_EI_AUTH_FAILURE; in hostapd_pwd_auth_fail()
743 os_memcpy(hapd->wps_stats.peer_addr, data->peer_macaddr, ETH_ALEN); in hostapd_pwd_auth_fail()
745 hostapd_wps_for_each(hapd, wps_pwd_auth_fail, data); in hostapd_pwd_auth_fail()
749 static int wps_ap_pin_success(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_success() argument
751 if (hapd->conf->ap_pin == NULL || hapd->wps == NULL) in wps_ap_pin_success()
754 if (hapd->ap_pin_failures_consecutive == 0) in wps_ap_pin_success()
759 hapd->ap_pin_failures, hapd->ap_pin_failures_consecutive); in wps_ap_pin_success()
760 hapd->ap_pin_failures_consecutive = 0; in wps_ap_pin_success()
766 static void hostapd_wps_ap_pin_success(struct hostapd_data *hapd) in hostapd_wps_ap_pin_success() argument
768 hostapd_wps_for_each(hapd, wps_ap_pin_success, NULL); in hostapd_wps_ap_pin_success()
772 static void hostapd_wps_event_pbc_overlap(struct hostapd_data *hapd) in hostapd_wps_event_pbc_overlap() argument
775 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_OVERLAP; in hostapd_wps_event_pbc_overlap()
779 static void hostapd_wps_event_pbc_timeout(struct hostapd_data *hapd) in hostapd_wps_event_pbc_timeout() argument
782 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_TIMEOUT; in hostapd_wps_event_pbc_timeout()
786 static void hostapd_wps_event_pbc_active(struct hostapd_data *hapd) in hostapd_wps_event_pbc_active() argument
789 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_ACTIVE; in hostapd_wps_event_pbc_active()
793 static void hostapd_wps_event_pbc_disable(struct hostapd_data *hapd) in hostapd_wps_event_pbc_disable() argument
796 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_DISABLE; in hostapd_wps_event_pbc_disable()
800 static void hostapd_wps_event_success(struct hostapd_data *hapd, in hostapd_wps_event_success() argument
804 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_DISABLE; in hostapd_wps_event_success()
805 hapd->wps_stats.status = WPS_STATUS_SUCCESS; in hostapd_wps_event_success()
806 os_memcpy(hapd->wps_stats.peer_addr, success->peer_macaddr, ETH_ALEN); in hostapd_wps_event_success()
810 static void hostapd_wps_event_fail(struct hostapd_data *hapd, in hostapd_wps_event_fail() argument
814 hapd->wps_stats.status = WPS_STATUS_FAILURE; in hostapd_wps_event_fail()
815 os_memcpy(hapd->wps_stats.peer_addr, fail->peer_macaddr, ETH_ALEN); in hostapd_wps_event_fail()
817 hapd->wps_stats.failure_reason = fail->error_indication; in hostapd_wps_event_fail()
821 wpa_msg(hapd->msg_ctx, MSG_INFO, in hostapd_wps_event_fail()
826 wpa_msg(hapd->msg_ctx, MSG_INFO, in hostapd_wps_event_fail()
836 struct hostapd_data *hapd = ctx; in hostapd_wps_event_cb() local
840 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_M2D); in hostapd_wps_event_cb()
843 hostapd_wps_event_fail(hapd, &data->fail); in hostapd_wps_event_cb()
846 hostapd_wps_event_success(hapd, &data->success); in hostapd_wps_event_cb()
847 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_SUCCESS); in hostapd_wps_event_cb()
850 hostapd_pwd_auth_fail(hapd, &data->pwd_auth_fail); in hostapd_wps_event_cb()
853 hostapd_wps_event_pbc_overlap(hapd); in hostapd_wps_event_cb()
854 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_OVERLAP); in hostapd_wps_event_cb()
857 hostapd_wps_event_pbc_timeout(hapd); in hostapd_wps_event_cb()
858 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_TIMEOUT); in hostapd_wps_event_cb()
861 hostapd_wps_event_pbc_active(hapd); in hostapd_wps_event_cb()
862 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_ACTIVE); in hostapd_wps_event_cb()
865 hostapd_wps_event_pbc_disable(hapd); in hostapd_wps_event_cb()
866 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_DISABLE); in hostapd_wps_event_cb()
881 hostapd_wps_ap_pin_success(hapd); in hostapd_wps_event_cb()
884 if (hapd->wps_event_cb) in hostapd_wps_event_cb()
885 hapd->wps_event_cb(hapd->wps_event_cb_ctx, event, data); in hostapd_wps_event_cb()
891 struct hostapd_data *hapd = ctx; in hostapd_wps_rf_band_cb() local
893 return hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211A ? in hostapd_wps_rf_band_cb()
895 hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD ? in hostapd_wps_rf_band_cb()
900 static void hostapd_wps_clear_ies(struct hostapd_data *hapd, int deinit_only) in hostapd_wps_clear_ies() argument
902 wpabuf_free(hapd->wps_beacon_ie); in hostapd_wps_clear_ies()
903 hapd->wps_beacon_ie = NULL; in hostapd_wps_clear_ies()
905 wpabuf_free(hapd->wps_probe_resp_ie); in hostapd_wps_clear_ies()
906 hapd->wps_probe_resp_ie = NULL; in hostapd_wps_clear_ies()
909 if (hapd->drv_priv) in hostapd_wps_clear_ies()
910 hostapd_reset_ap_wps_ie(hapd); in hostapd_wps_clear_ies()
914 hostapd_set_ap_wps_ie(hapd); in hostapd_wps_clear_ies()
926 struct hostapd_data *hapd = iface->bss[j]; in get_uuid_cb() local
927 if (hapd->wps && !hapd->conf->wps_independent && in get_uuid_cb()
928 !is_nil_uuid(hapd->wps->uuid)) { in get_uuid_cb()
929 *uuid = hapd->wps->uuid; in get_uuid_cb()
971 static int hostapd_wps_set_vendor_ext(struct hostapd_data *hapd, in hostapd_wps_set_vendor_ext() argument
980 if (hapd->conf->wps_vendor_ext[i] == NULL) in hostapd_wps_set_vendor_ext()
984 wpabuf_dup(hapd->conf->wps_vendor_ext[i]); in hostapd_wps_set_vendor_ext()
1011 int hostapd_init_wps(struct hostapd_data *hapd, in hostapd_init_wps() argument
1019 hostapd_wps_clear_ies(hapd, 0); in hostapd_init_wps()
1030 wps->cb_ctx = hapd; in hostapd_init_wps()
1033 wps->wps_state = hapd->conf->wps_state; in hostapd_init_wps()
1034 wps->ap_setup_locked = hapd->conf->ap_setup_locked; in hostapd_init_wps()
1035 if (is_nil_uuid(hapd->conf->uuid)) { in hostapd_init_wps()
1037 uuid = get_own_uuid(hapd->iface); in hostapd_init_wps()
1043 uuid_gen_mac_addr(hapd->own_addr, wps->uuid); in hostapd_init_wps()
1048 os_memcpy(wps->uuid, hapd->conf->uuid, UUID_LEN); in hostapd_init_wps()
1052 wps->ssid_len = hapd->conf->ssid.ssid_len; in hostapd_init_wps()
1053 os_memcpy(wps->ssid, hapd->conf->ssid.ssid, wps->ssid_len); in hostapd_init_wps()
1055 os_memcpy(wps->dev.mac_addr, hapd->own_addr, ETH_ALEN); in hostapd_init_wps()
1056 wps->dev.device_name = hapd->conf->device_name ? in hostapd_init_wps()
1057 os_strdup(hapd->conf->device_name) : NULL; in hostapd_init_wps()
1058 wps->dev.manufacturer = hapd->conf->manufacturer ? in hostapd_init_wps()
1059 os_strdup(hapd->conf->manufacturer) : NULL; in hostapd_init_wps()
1060 wps->dev.model_name = hapd->conf->model_name ? in hostapd_init_wps()
1061 os_strdup(hapd->conf->model_name) : NULL; in hostapd_init_wps()
1062 wps->dev.model_number = hapd->conf->model_number ? in hostapd_init_wps()
1063 os_strdup(hapd->conf->model_number) : NULL; in hostapd_init_wps()
1064 wps->dev.serial_number = hapd->conf->serial_number ? in hostapd_init_wps()
1065 os_strdup(hapd->conf->serial_number) : NULL; in hostapd_init_wps()
1067 wps_config_methods_str2bin(hapd->conf->config_methods); in hostapd_init_wps()
1082 os_memcpy(wps->dev.pri_dev_type, hapd->conf->device_type, in hostapd_init_wps()
1085 if (hostapd_wps_set_vendor_ext(hapd, wps) < 0) in hostapd_init_wps()
1088 wps->dev.os_version = WPA_GET_BE32(hapd->conf->os_version); in hostapd_init_wps()
1094 hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211A ? in hostapd_init_wps()
1096 hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD ? in hostapd_init_wps()
1175 if ((hapd->conf->multi_ap & FRONTHAUL_BSS) && in hostapd_init_wps()
1176 hapd->conf->multi_ap_backhaul_ssid.ssid_len) { in hostapd_init_wps()
1178 hapd->conf->multi_ap_backhaul_ssid.ssid_len; in hostapd_init_wps()
1180 hapd->conf->multi_ap_backhaul_ssid.ssid; in hostapd_init_wps()
1208 cfg.cb_ctx = hapd; in hostapd_init_wps()
1212 cfg.disable_auto_conf = (hapd->conf->wps_cred_processing == 1) && in hostapd_init_wps()
1216 cfg.dualband = interface_count(hapd->iface) > 1; in hostapd_init_wps()
1231 wps->friendly_name = hapd->conf->friendly_name; in hostapd_init_wps()
1232 wps->manufacturer_url = hapd->conf->manufacturer_url; in hostapd_init_wps()
1233 wps->model_description = hapd->conf->model_description; in hostapd_init_wps()
1234 wps->model_url = hapd->conf->model_url; in hostapd_init_wps()
1235 wps->upc = hapd->conf->upc; in hostapd_init_wps()
1238 hostapd_register_probereq_cb(hapd, hostapd_wps_probe_req_rx, hapd); in hostapd_init_wps()
1240 hapd->wps = wps; in hostapd_init_wps()
1252 int hostapd_init_wps_complete(struct hostapd_data *hapd) in hostapd_init_wps_complete() argument
1254 struct wps_context *wps = hapd->wps; in hostapd_init_wps_complete()
1260 if (hostapd_wps_upnp_init(hapd, wps) < 0) { in hostapd_init_wps_complete()
1264 hapd->wps = NULL; in hostapd_init_wps_complete()
1288 void hostapd_deinit_wps(struct hostapd_data *hapd) in hostapd_deinit_wps() argument
1290 eloop_cancel_timeout(hostapd_wps_reenable_ap_pin, hapd, NULL); in hostapd_deinit_wps()
1291 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_deinit_wps()
1292 eloop_cancel_timeout(wps_reload_config, hapd->iface, NULL); in hostapd_deinit_wps()
1293 if (hapd->wps == NULL) { in hostapd_deinit_wps()
1294 hostapd_wps_clear_ies(hapd, 1); in hostapd_deinit_wps()
1298 hostapd_wps_upnp_deinit(hapd); in hostapd_deinit_wps()
1300 wps_registrar_deinit(hapd->wps->registrar); in hostapd_deinit_wps()
1301 wps_free_pending_msgs(hapd->wps->upnp_msgs); in hostapd_deinit_wps()
1302 hostapd_free_wps(hapd->wps); in hostapd_deinit_wps()
1303 hapd->wps = NULL; in hostapd_deinit_wps()
1304 hostapd_wps_clear_ies(hapd, 1); in hostapd_deinit_wps()
1308 void hostapd_update_wps(struct hostapd_data *hapd) in hostapd_update_wps() argument
1310 if (hapd->wps == NULL) in hostapd_update_wps()
1314 hapd->wps->friendly_name = hapd->conf->friendly_name; in hostapd_update_wps()
1315 hapd->wps->manufacturer_url = hapd->conf->manufacturer_url; in hostapd_update_wps()
1316 hapd->wps->model_description = hapd->conf->model_description; in hostapd_update_wps()
1317 hapd->wps->model_url = hapd->conf->model_url; in hostapd_update_wps()
1318 hapd->wps->upc = hapd->conf->upc; in hostapd_update_wps()
1321 hostapd_wps_set_vendor_ext(hapd, hapd->wps); in hostapd_update_wps()
1323 if (hapd->conf->wps_state) in hostapd_update_wps()
1324 wps_registrar_update_ie(hapd->wps->registrar); in hostapd_update_wps()
1326 hostapd_deinit_wps(hapd); in hostapd_update_wps()
1340 static int wps_add_pin(struct hostapd_data *hapd, void *ctx) in wps_add_pin() argument
1345 if (hapd->wps == NULL) in wps_add_pin()
1347 ret = wps_registrar_add_pin(hapd->wps->registrar, data->addr, in wps_add_pin()
1356 int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *addr, in hostapd_wps_add_pin() argument
1376 if (hostapd_wps_for_each(hapd, wps_add_pin, &data) < 0) in hostapd_wps_add_pin()
1387 static int wps_button_pushed(struct hostapd_data *hapd, void *ctx) in wps_button_pushed() argument
1391 if (hapd->wps) { in wps_button_pushed()
1393 return wps_registrar_button_pushed(hapd->wps->registrar, in wps_button_pushed()
1401 int hostapd_wps_button_pushed(struct hostapd_data *hapd, in hostapd_wps_button_pushed() argument
1409 ret = hostapd_wps_for_each(hapd, wps_button_pushed, &ctx); in hostapd_wps_button_pushed()
1420 static int wps_cancel(struct hostapd_data *hapd, void *ctx) in wps_cancel() argument
1424 if (hapd->wps) { in wps_cancel()
1426 wps_registrar_wps_cancel(hapd->wps->registrar); in wps_cancel()
1427 ap_for_each_sta(hapd, ap_sta_wps_cancel, NULL); in wps_cancel()
1434 int hostapd_wps_cancel(struct hostapd_data *hapd) in hostapd_wps_cancel() argument
1440 ret = hostapd_wps_for_each(hapd, wps_cancel, &ctx); in hostapd_wps_cancel()
1452 struct hostapd_data *hapd = ctx; in hostapd_wps_probe_req_rx() local
1456 if (hapd->wps == NULL) in hostapd_wps_probe_req_rx()
1466 (elems.ssid_len != hapd->conf->ssid.ssid_len || in hostapd_wps_probe_req_rx()
1467 os_memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) != in hostapd_wps_probe_req_rx()
1487 wps_registrar_probe_req_rx(hapd->wps->registrar, addr, wps_ie, in hostapd_wps_probe_req_rx()
1494 hapd->wps_upnp, addr, in hostapd_wps_probe_req_rx()
1512 struct hostapd_data *hapd = priv; in hostapd_rx_req_put_wlan_response() local
1531 sta = ap_get_sta(hapd, mac_addr); in hostapd_rx_req_put_wlan_response()
1541 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_rx_req_put_wlan_response()
1569 p->next = hapd->wps->upnp_msgs; in hostapd_rx_req_put_wlan_response()
1570 hapd->wps->upnp_msgs = p; in hostapd_rx_req_put_wlan_response()
1576 static int hostapd_wps_upnp_init(struct hostapd_data *hapd, in hostapd_wps_upnp_init() argument
1581 if (!hapd->conf->upnp_iface) in hostapd_wps_upnp_init()
1588 if (hapd->conf->ap_pin) in hostapd_wps_upnp_init()
1589 ctx->ap_pin = os_strdup(hapd->conf->ap_pin); in hostapd_wps_upnp_init()
1591 hapd->wps_upnp = upnp_wps_device_init(ctx, wps, hapd, in hostapd_wps_upnp_init()
1592 hapd->conf->upnp_iface); in hostapd_wps_upnp_init()
1593 if (hapd->wps_upnp == NULL) in hostapd_wps_upnp_init()
1595 wps->wps_upnp = hapd->wps_upnp; in hostapd_wps_upnp_init()
1601 static void hostapd_wps_upnp_deinit(struct hostapd_data *hapd) in hostapd_wps_upnp_deinit() argument
1603 upnp_wps_device_deinit(hapd->wps_upnp, hapd); in hostapd_wps_upnp_deinit()
1609 int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, const u8 *addr, in hostapd_wps_get_mib_sta() argument
1612 if (hapd->wps == NULL) in hostapd_wps_get_mib_sta()
1614 return wps_registrar_get_info(hapd->wps->registrar, addr, buf, buflen); in hostapd_wps_get_mib_sta()
1620 struct hostapd_data *hapd = eloop_data; in hostapd_wps_ap_pin_timeout() local
1622 hostapd_wps_ap_pin_disable(hapd); in hostapd_wps_ap_pin_timeout()
1623 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_PIN_DISABLED); in hostapd_wps_ap_pin_timeout()
1627 static void hostapd_wps_ap_pin_enable(struct hostapd_data *hapd, int timeout) in hostapd_wps_ap_pin_enable() argument
1630 hapd->ap_pin_failures = 0; in hostapd_wps_ap_pin_enable()
1631 hapd->ap_pin_failures_consecutive = 0; in hostapd_wps_ap_pin_enable()
1632 hapd->conf->ap_setup_locked = 0; in hostapd_wps_ap_pin_enable()
1633 if (hapd->wps->ap_setup_locked) { in hostapd_wps_ap_pin_enable()
1634 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_UNLOCKED); in hostapd_wps_ap_pin_enable()
1635 hapd->wps->ap_setup_locked = 0; in hostapd_wps_ap_pin_enable()
1636 wps_registrar_update_ie(hapd->wps->registrar); in hostapd_wps_ap_pin_enable()
1638 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_wps_ap_pin_enable()
1641 hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_wps_ap_pin_enable()
1645 static int wps_ap_pin_disable(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_disable() argument
1647 os_free(hapd->conf->ap_pin); in wps_ap_pin_disable()
1648 hapd->conf->ap_pin = NULL; in wps_ap_pin_disable()
1650 upnp_wps_set_ap_pin(hapd->wps_upnp, NULL); in wps_ap_pin_disable()
1652 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in wps_ap_pin_disable()
1657 void hostapd_wps_ap_pin_disable(struct hostapd_data *hapd) in hostapd_wps_ap_pin_disable() argument
1660 hostapd_wps_for_each(hapd, wps_ap_pin_disable, NULL); in hostapd_wps_ap_pin_disable()
1670 static int wps_ap_pin_set(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_set() argument
1674 if (!hapd->wps) in wps_ap_pin_set()
1677 os_free(hapd->conf->ap_pin); in wps_ap_pin_set()
1678 hapd->conf->ap_pin = os_strdup(data->pin_txt); in wps_ap_pin_set()
1680 upnp_wps_set_ap_pin(hapd->wps_upnp, data->pin_txt); in wps_ap_pin_set()
1682 hostapd_wps_ap_pin_enable(hapd, data->timeout); in wps_ap_pin_set()
1687 const char * hostapd_wps_ap_pin_random(struct hostapd_data *hapd, int timeout) in hostapd_wps_ap_pin_random() argument
1696 hostapd_wps_for_each(hapd, wps_ap_pin_set, &data); in hostapd_wps_ap_pin_random()
1697 return hapd->conf->ap_pin; in hostapd_wps_ap_pin_random()
1701 const char * hostapd_wps_ap_pin_get(struct hostapd_data *hapd) in hostapd_wps_ap_pin_get() argument
1703 return hapd->conf->ap_pin; in hostapd_wps_ap_pin_get()
1707 int hostapd_wps_ap_pin_set(struct hostapd_data *hapd, const char *pin, in hostapd_wps_ap_pin_set() argument
1717 return hostapd_wps_for_each(hapd, wps_ap_pin_set, &data); in hostapd_wps_ap_pin_set()
1721 static int wps_update_ie(struct hostapd_data *hapd, void *ctx) in wps_update_ie() argument
1723 if (hapd->wps) in wps_update_ie()
1724 wps_registrar_update_ie(hapd->wps->registrar); in wps_update_ie()
1729 void hostapd_wps_update_ie(struct hostapd_data *hapd) in hostapd_wps_update_ie() argument
1731 hostapd_wps_for_each(hapd, wps_update_ie, NULL); in hostapd_wps_update_ie()
1735 int hostapd_wps_config_ap(struct hostapd_data *hapd, const char *ssid, in hostapd_wps_config_ap() argument
1778 return wps_registrar_config_ap(hapd->wps->registrar, &cred); in hostapd_wps_config_ap()
1791 static int wps_add_nfc_password_token(struct hostapd_data *hapd, void *ctx) in wps_add_nfc_password_token() argument
1796 if (hapd->wps == NULL) in wps_add_nfc_password_token()
1798 ret = wps_registrar_add_nfc_password_token(hapd->wps->registrar, in wps_add_nfc_password_token()
1807 static int hostapd_wps_add_nfc_password_token(struct hostapd_data *hapd, in hostapd_wps_add_nfc_password_token() argument
1815 if (hostapd_wps_for_each(hapd, wps_add_nfc_password_token, &data) < 0) in hostapd_wps_add_nfc_password_token()
1821 static int hostapd_wps_nfc_tag_process(struct hostapd_data *hapd, in hostapd_wps_nfc_tag_process() argument
1834 return hostapd_wps_add_nfc_password_token(hapd, &attr); in hostapd_wps_nfc_tag_process()
1841 int hostapd_wps_nfc_tag_read(struct hostapd_data *hapd, in hostapd_wps_nfc_tag_read() argument
1861 ret = hostapd_wps_nfc_tag_process(hapd, wps); in hostapd_wps_nfc_tag_read()
1867 struct wpabuf * hostapd_wps_nfc_config_token(struct hostapd_data *hapd, in hostapd_wps_nfc_config_token() argument
1872 if (hapd->wps == NULL) in hostapd_wps_nfc_config_token()
1875 ret = wps_get_oob_cred(hapd->wps, hostapd_wps_rf_band_cb(hapd), in hostapd_wps_nfc_config_token()
1876 hapd->iconf->channel); in hostapd_wps_nfc_config_token()
1890 struct wpabuf * hostapd_wps_nfc_hs_cr(struct hostapd_data *hapd, int ndef) in hostapd_wps_nfc_hs_cr() argument
1894 if (hapd->wps == NULL) in hostapd_wps_nfc_hs_cr()
1897 if (hapd->conf->wps_nfc_dh_pubkey == NULL) { in hostapd_wps_nfc_hs_cr()
1898 struct wps_context *wps = hapd->wps; in hostapd_wps_nfc_hs_cr()
1899 if (wps_nfc_gen_dh(&hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_hs_cr()
1900 &hapd->conf->wps_nfc_dh_privkey) < 0) in hostapd_wps_nfc_hs_cr()
1905 wpabuf_dup(hapd->conf->wps_nfc_dh_pubkey); in hostapd_wps_nfc_hs_cr()
1907 wpabuf_dup(hapd->conf->wps_nfc_dh_privkey); in hostapd_wps_nfc_hs_cr()
1914 ret = wps_build_nfc_handover_sel(hapd->wps, in hostapd_wps_nfc_hs_cr()
1915 hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_hs_cr()
1916 hapd->own_addr, hapd->iface->freq); in hostapd_wps_nfc_hs_cr()
1931 int hostapd_wps_nfc_report_handover(struct hostapd_data *hapd, in hostapd_wps_nfc_report_handover() argument
2014 ret = wps_registrar_add_nfc_pw_token(hapd->wps->registrar, in hostapd_wps_nfc_report_handover()
2025 struct wpabuf * hostapd_wps_nfc_token_gen(struct hostapd_data *hapd, int ndef) in hostapd_wps_nfc_token_gen() argument
2027 if (hapd->conf->wps_nfc_pw_from_config) { in hostapd_wps_nfc_token_gen()
2029 hapd->conf->wps_nfc_dev_pw_id, in hostapd_wps_nfc_token_gen()
2030 hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_token_gen()
2031 hapd->conf->wps_nfc_dev_pw); in hostapd_wps_nfc_token_gen()
2034 return wps_nfc_token_gen(ndef, &hapd->conf->wps_nfc_dev_pw_id, in hostapd_wps_nfc_token_gen()
2035 &hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_token_gen()
2036 &hapd->conf->wps_nfc_dh_privkey, in hostapd_wps_nfc_token_gen()
2037 &hapd->conf->wps_nfc_dev_pw); in hostapd_wps_nfc_token_gen()
2041 int hostapd_wps_nfc_token_enable(struct hostapd_data *hapd) in hostapd_wps_nfc_token_enable() argument
2043 struct wps_context *wps = hapd->wps; in hostapd_wps_nfc_token_enable()
2049 if (!hapd->conf->wps_nfc_dh_pubkey || in hostapd_wps_nfc_token_enable()
2050 !hapd->conf->wps_nfc_dh_privkey || in hostapd_wps_nfc_token_enable()
2051 !hapd->conf->wps_nfc_dev_pw || in hostapd_wps_nfc_token_enable()
2052 !hapd->conf->wps_nfc_dev_pw_id) in hostapd_wps_nfc_token_enable()
2058 hapd->conf->wps_nfc_dev_pw_id, hapd->conf->iface, wps); in hostapd_wps_nfc_token_enable()
2059 wps->ap_nfc_dev_pw_id = hapd->conf->wps_nfc_dev_pw_id; in hostapd_wps_nfc_token_enable()
2060 wps->ap_nfc_dh_pubkey = wpabuf_dup(hapd->conf->wps_nfc_dh_pubkey); in hostapd_wps_nfc_token_enable()
2061 wps->ap_nfc_dh_privkey = wpabuf_dup(hapd->conf->wps_nfc_dh_privkey); in hostapd_wps_nfc_token_enable()
2062 pw = hapd->conf->wps_nfc_dev_pw; in hostapd_wps_nfc_token_enable()
2083 void hostapd_wps_nfc_token_disable(struct hostapd_data *hapd) in hostapd_wps_nfc_token_disable() argument
2086 hapd->conf->iface); in hostapd_wps_nfc_token_disable()
2087 hostapd_wps_nfc_clear(hapd->wps); in hostapd_wps_nfc_token_disable()