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()
130 if (hapd->new_psk_cb) { in hostapd_wps_new_psk_cb()
131 hapd->new_psk_cb(hapd->new_psk_cb_ctx, mac_addr, p2p_dev_addr, in hostapd_wps_new_psk_cb()
162 struct hostapd_data *hapd = ctx; in hostapd_wps_set_ie_cb() local
163 wpabuf_free(hapd->wps_beacon_ie); in hostapd_wps_set_ie_cb()
164 hapd->wps_beacon_ie = beacon_ie; in hostapd_wps_set_ie_cb()
165 wpabuf_free(hapd->wps_probe_resp_ie); in hostapd_wps_set_ie_cb()
166 hapd->wps_probe_resp_ie = probe_resp_ie; in hostapd_wps_set_ie_cb()
167 if (hapd->beacon_set_done) in hostapd_wps_set_ie_cb()
168 ieee802_11_set_beacon(hapd); in hostapd_wps_set_ie_cb()
169 return hostapd_set_ap_wps_ie(hapd); in hostapd_wps_set_ie_cb()
176 struct hostapd_data *hapd = ctx; in hostapd_wps_pin_needed_cb() local
191 wpa_msg(hapd->msg_ctx, MSG_INFO, "%s", txt); in hostapd_wps_pin_needed_cb()
193 if (hapd->conf->wps_pin_requests) { in hostapd_wps_pin_needed_cb()
196 f = fopen(hapd->conf->wps_pin_requests, "a"); in hostapd_wps_pin_needed_cb()
219 static int wps_stop_registrar(struct hostapd_data *hapd, void *ctx) in wps_stop_registrar() argument
222 if (hapd != data->current_hapd && hapd->wps != NULL) in wps_stop_registrar()
223 wps_registrar_complete(hapd->wps->registrar, data->uuid_e, in wps_stop_registrar()
233 struct hostapd_data *hapd = ctx; in hostapd_wps_reg_success_cb() local
238 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_REG_SUCCESS MACSTR " %s", in hostapd_wps_reg_success_cb()
240 if (hapd->wps_reg_success_cb) in hostapd_wps_reg_success_cb()
241 hapd->wps_reg_success_cb(hapd->wps_reg_success_cb_ctx, in hostapd_wps_reg_success_cb()
243 data.current_hapd = hapd; in hostapd_wps_reg_success_cb()
247 hostapd_wps_for_each(hapd, wps_stop_registrar, &data); in hostapd_wps_reg_success_cb()
258 struct hostapd_data *hapd = ctx; in hostapd_wps_enrollee_seen_cb() local
265 wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, WPS_EVENT_ENROLLEE_SEEN MACSTR in hostapd_wps_enrollee_seen_cb()
277 const struct hostapd_data *hapd = ctx; in hostapd_wps_lookup_pskfile_cb() local
282 for (wpa_psk = hapd->conf->ssid.wpa_psk; wpa_psk; in hostapd_wps_lookup_pskfile_cb()
325 void hostapd_wps_eap_completed(struct hostapd_data *hapd) in hostapd_wps_eap_completed() argument
333 if (eloop_deplete_timeout(0, 0, wps_reload_config, hapd->iface, NULL) == in hostapd_wps_eap_completed()
339 static void hapd_new_ap_event(struct hostapd_data *hapd, const u8 *attr, in hapd_new_ap_event() argument
346 wpa_msg(hapd->msg_ctx, MSG_INFO, in hapd_new_ap_event()
353 static int hapd_wps_reconfig_in_memory(struct hostapd_data *hapd, in hapd_wps_reconfig_in_memory() argument
356 struct hostapd_bss_config *bss = hapd->conf; in hapd_wps_reconfig_in_memory()
393 if (hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD) in hapd_wps_reconfig_in_memory()
407 if (hapd->conf->wps_cred_add_sae && in hapd_wps_reconfig_in_memory()
448 eloop_register_timeout(0, 100000, wps_reload_config, hapd->iface, in hapd_wps_reconfig_in_memory()
455 static int hapd_wps_cred_cb(struct hostapd_data *hapd, void *ctx) in hapd_wps_cred_cb() argument
466 if (hapd->wps == NULL) in hapd_wps_cred_cb()
483 if ((hapd->conf->wps_cred_processing == 1 || in hapd_wps_cred_cb()
484 hapd->conf->wps_cred_processing == 2) && cred->cred_attr) { in hapd_wps_cred_cb()
485 hapd_new_ap_event(hapd, cred->cred_attr, cred->cred_attr_len); in hapd_wps_cred_cb()
486 } else if (hapd->conf->wps_cred_processing == 1 || in hapd_wps_cred_cb()
487 hapd->conf->wps_cred_processing == 2) { in hapd_wps_cred_cb()
491 hapd_new_ap_event(hapd, wpabuf_head_u8(attr), in hapd_wps_cred_cb()
495 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_NEW_AP_SETTINGS); in hapd_wps_cred_cb()
497 if (hapd->conf->wps_cred_processing == 1) in hapd_wps_cred_cb()
500 os_memcpy(hapd->wps->ssid, cred->ssid, cred->ssid_len); in hapd_wps_cred_cb()
501 hapd->wps->ssid_len = cred->ssid_len; in hapd_wps_cred_cb()
502 hapd->wps->encr_types = cred->encr_type; in hapd_wps_cred_cb()
503 hapd->wps->encr_types_rsn = cred->encr_type; in hapd_wps_cred_cb()
504 hapd->wps->encr_types_wpa = cred->encr_type; in hapd_wps_cred_cb()
505 hapd->wps->auth_types = cred->auth_type; in hapd_wps_cred_cb()
506 hapd->wps->ap_encr_type = cred->encr_type; in hapd_wps_cred_cb()
507 hapd->wps->ap_auth_type = cred->auth_type; in hapd_wps_cred_cb()
509 os_free(hapd->wps->network_key); in hapd_wps_cred_cb()
510 hapd->wps->network_key = NULL; in hapd_wps_cred_cb()
511 hapd->wps->network_key_len = 0; in hapd_wps_cred_cb()
518 if (hapd->wps->network_key == NULL || in hapd_wps_cred_cb()
519 hapd->wps->network_key_len < cred->key_len) { in hapd_wps_cred_cb()
520 hapd->wps->network_key_len = 0; in hapd_wps_cred_cb()
521 os_free(hapd->wps->network_key); in hapd_wps_cred_cb()
522 hapd->wps->network_key = os_malloc(cred->key_len); in hapd_wps_cred_cb()
523 if (hapd->wps->network_key == NULL) in hapd_wps_cred_cb()
526 hapd->wps->network_key_len = cred->key_len; in hapd_wps_cred_cb()
527 os_memcpy(hapd->wps->network_key, cred->key, cred->key_len); in hapd_wps_cred_cb()
529 hapd->wps->wps_state = WPS_STATE_CONFIGURED; in hapd_wps_cred_cb()
531 if (hapd->iface->config_fname == NULL) in hapd_wps_cred_cb()
532 return hapd_wps_reconfig_in_memory(hapd, cred); in hapd_wps_cred_cb()
533 len = os_strlen(hapd->iface->config_fname) + 5; in hapd_wps_cred_cb()
537 os_snprintf(tmp_fname, len, "%s-new", hapd->iface->config_fname); in hapd_wps_cred_cb()
539 oconf = fopen(hapd->iface->config_fname, "r"); in hapd_wps_cred_cb()
606 if (hapd->conf->wps_cred_add_sae && in hapd_wps_cred_cb()
614 if (sae && hapd->conf->ieee80211w == NO_MGMT_FRAME_PROTECTION) { in hapd_wps_cred_cb()
625 if (hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD) in hapd_wps_cred_cb()
694 if (rename(tmp_fname, hapd->iface->config_fname) < 0) { in hapd_wps_cred_cb()
706 eloop_register_timeout(0, 100000, wps_reload_config, hapd->iface, in hapd_wps_cred_cb()
717 struct hostapd_data *hapd = ctx; in hostapd_wps_cred_cb() local
718 return hostapd_wps_for_each(hapd, hapd_wps_cred_cb, (void *) cred); in hostapd_wps_cred_cb()
724 struct hostapd_data *hapd = eloop_data; in hostapd_wps_reenable_ap_pin() local
726 if (hapd->conf->ap_setup_locked) in hostapd_wps_reenable_ap_pin()
728 if (hapd->ap_pin_failures_consecutive >= 10) in hostapd_wps_reenable_ap_pin()
732 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_UNLOCKED); in hostapd_wps_reenable_ap_pin()
733 hapd->wps->ap_setup_locked = 0; in hostapd_wps_reenable_ap_pin()
734 wps_registrar_update_ie(hapd->wps->registrar); in hostapd_wps_reenable_ap_pin()
738 static int wps_pwd_auth_fail(struct hostapd_data *hapd, void *ctx) in wps_pwd_auth_fail() argument
742 if (!data->enrollee || hapd->conf->ap_pin == NULL || hapd->wps == NULL) in wps_pwd_auth_fail()
750 hapd->ap_pin_failures++; in wps_pwd_auth_fail()
751 hapd->ap_pin_failures_consecutive++; in wps_pwd_auth_fail()
754 hapd->ap_pin_failures, hapd->ap_pin_failures_consecutive); in wps_pwd_auth_fail()
755 if (hapd->ap_pin_failures < 3) in wps_pwd_auth_fail()
758 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_LOCKED); in wps_pwd_auth_fail()
759 hapd->wps->ap_setup_locked = 1; in wps_pwd_auth_fail()
761 wps_registrar_update_ie(hapd->wps->registrar); in wps_pwd_auth_fail()
763 if (!hapd->conf->ap_setup_locked && in wps_pwd_auth_fail()
764 hapd->ap_pin_failures_consecutive >= 10) { in wps_pwd_auth_fail()
769 eloop_cancel_timeout(hostapd_wps_reenable_ap_pin, hapd, NULL); in wps_pwd_auth_fail()
771 } else if (!hapd->conf->ap_setup_locked) { in wps_pwd_auth_fail()
772 if (hapd->ap_pin_lockout_time == 0) in wps_pwd_auth_fail()
773 hapd->ap_pin_lockout_time = 60; in wps_pwd_auth_fail()
774 else if (hapd->ap_pin_lockout_time < 365 * 24 * 60 * 60 && in wps_pwd_auth_fail()
775 (hapd->ap_pin_failures % 3) == 0) in wps_pwd_auth_fail()
776 hapd->ap_pin_lockout_time *= 2; in wps_pwd_auth_fail()
779 hapd->ap_pin_lockout_time); in wps_pwd_auth_fail()
780 eloop_cancel_timeout(hostapd_wps_reenable_ap_pin, hapd, NULL); in wps_pwd_auth_fail()
781 eloop_register_timeout(hapd->ap_pin_lockout_time, 0, in wps_pwd_auth_fail()
782 hostapd_wps_reenable_ap_pin, hapd, in wps_pwd_auth_fail()
790 static void hostapd_pwd_auth_fail(struct hostapd_data *hapd, in hostapd_pwd_auth_fail() argument
795 hapd->wps_stats.status = WPS_STATUS_FAILURE; in hostapd_pwd_auth_fail()
796 hapd->wps_stats.failure_reason = WPS_EI_AUTH_FAILURE; in hostapd_pwd_auth_fail()
797 os_memcpy(hapd->wps_stats.peer_addr, data->peer_macaddr, ETH_ALEN); in hostapd_pwd_auth_fail()
799 hostapd_wps_for_each(hapd, wps_pwd_auth_fail, data); in hostapd_pwd_auth_fail()
803 static int wps_ap_pin_success(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_success() argument
805 if (hapd->conf->ap_pin == NULL || hapd->wps == NULL) in wps_ap_pin_success()
808 if (hapd->ap_pin_failures_consecutive == 0) in wps_ap_pin_success()
813 hapd->ap_pin_failures, hapd->ap_pin_failures_consecutive); in wps_ap_pin_success()
814 hapd->ap_pin_failures_consecutive = 0; in wps_ap_pin_success()
820 static void hostapd_wps_ap_pin_success(struct hostapd_data *hapd) in hostapd_wps_ap_pin_success() argument
822 hostapd_wps_for_each(hapd, wps_ap_pin_success, NULL); in hostapd_wps_ap_pin_success()
826 static void hostapd_wps_event_pbc_overlap(struct hostapd_data *hapd) in hostapd_wps_event_pbc_overlap() argument
829 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_OVERLAP; in hostapd_wps_event_pbc_overlap()
833 static void hostapd_wps_event_pbc_timeout(struct hostapd_data *hapd) in hostapd_wps_event_pbc_timeout() argument
836 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_TIMEOUT; in hostapd_wps_event_pbc_timeout()
840 static void hostapd_wps_event_pbc_active(struct hostapd_data *hapd) in hostapd_wps_event_pbc_active() argument
843 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_ACTIVE; in hostapd_wps_event_pbc_active()
847 static void hostapd_wps_event_pbc_disable(struct hostapd_data *hapd) in hostapd_wps_event_pbc_disable() argument
850 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_DISABLE; in hostapd_wps_event_pbc_disable()
854 static void hostapd_wps_event_success(struct hostapd_data *hapd, in hostapd_wps_event_success() argument
858 hapd->wps_stats.pbc_status = WPS_PBC_STATUS_DISABLE; in hostapd_wps_event_success()
859 hapd->wps_stats.status = WPS_STATUS_SUCCESS; in hostapd_wps_event_success()
860 os_memcpy(hapd->wps_stats.peer_addr, success->peer_macaddr, ETH_ALEN); in hostapd_wps_event_success()
864 static void hostapd_wps_event_fail(struct hostapd_data *hapd, in hostapd_wps_event_fail() argument
868 hapd->wps_stats.status = WPS_STATUS_FAILURE; in hostapd_wps_event_fail()
869 os_memcpy(hapd->wps_stats.peer_addr, fail->peer_macaddr, ETH_ALEN); in hostapd_wps_event_fail()
871 hapd->wps_stats.failure_reason = fail->error_indication; in hostapd_wps_event_fail()
875 wpa_msg(hapd->msg_ctx, MSG_INFO, in hostapd_wps_event_fail()
880 wpa_msg(hapd->msg_ctx, MSG_INFO, in hostapd_wps_event_fail()
890 struct hostapd_data *hapd = ctx; in hostapd_wps_event_cb() local
894 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_M2D); in hostapd_wps_event_cb()
897 hostapd_wps_event_fail(hapd, &data->fail); in hostapd_wps_event_cb()
900 hostapd_wps_event_success(hapd, &data->success); in hostapd_wps_event_cb()
901 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_SUCCESS); in hostapd_wps_event_cb()
904 hostapd_pwd_auth_fail(hapd, &data->pwd_auth_fail); in hostapd_wps_event_cb()
907 hostapd_wps_event_pbc_overlap(hapd); in hostapd_wps_event_cb()
908 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_OVERLAP); in hostapd_wps_event_cb()
911 hostapd_wps_event_pbc_timeout(hapd); in hostapd_wps_event_cb()
912 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_TIMEOUT); in hostapd_wps_event_cb()
915 hostapd_wps_event_pbc_active(hapd); in hostapd_wps_event_cb()
916 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_ACTIVE); in hostapd_wps_event_cb()
919 hostapd_wps_event_pbc_disable(hapd); in hostapd_wps_event_cb()
920 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_DISABLE); in hostapd_wps_event_cb()
935 hostapd_wps_ap_pin_success(hapd); in hostapd_wps_event_cb()
938 if (hapd->wps_event_cb) in hostapd_wps_event_cb()
939 hapd->wps_event_cb(hapd->wps_event_cb_ctx, event, data); in hostapd_wps_event_cb()
945 struct hostapd_data *hapd = ctx; in hostapd_wps_rf_band_cb() local
947 return hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211A ? in hostapd_wps_rf_band_cb()
949 hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD ? in hostapd_wps_rf_band_cb()
954 static void hostapd_wps_clear_ies(struct hostapd_data *hapd, int deinit_only) in hostapd_wps_clear_ies() argument
956 wpabuf_free(hapd->wps_beacon_ie); in hostapd_wps_clear_ies()
957 hapd->wps_beacon_ie = NULL; in hostapd_wps_clear_ies()
959 wpabuf_free(hapd->wps_probe_resp_ie); in hostapd_wps_clear_ies()
960 hapd->wps_probe_resp_ie = NULL; in hostapd_wps_clear_ies()
963 if (hapd->drv_priv) in hostapd_wps_clear_ies()
964 hostapd_reset_ap_wps_ie(hapd); in hostapd_wps_clear_ies()
968 hostapd_set_ap_wps_ie(hapd); in hostapd_wps_clear_ies()
980 struct hostapd_data *hapd = iface->bss[j]; in get_uuid_cb() local
981 if (hapd->wps && !hapd->conf->wps_independent && in get_uuid_cb()
982 !is_nil_uuid(hapd->wps->uuid)) { in get_uuid_cb()
983 *uuid = hapd->wps->uuid; in get_uuid_cb()
1025 static int hostapd_wps_set_vendor_ext(struct hostapd_data *hapd, in hostapd_wps_set_vendor_ext() argument
1034 if (hapd->conf->wps_vendor_ext[i] == NULL) in hostapd_wps_set_vendor_ext()
1038 wpabuf_dup(hapd->conf->wps_vendor_ext[i]); in hostapd_wps_set_vendor_ext()
1050 static int hostapd_wps_set_application_ext(struct hostapd_data *hapd, in hostapd_wps_set_application_ext() argument
1055 if (!hapd->conf->wps_application_ext) { in hostapd_wps_set_application_ext()
1060 wps->dev.application_ext = wpabuf_dup(hapd->conf->wps_application_ext); in hostapd_wps_set_application_ext()
1081 int hostapd_init_wps(struct hostapd_data *hapd, in hostapd_init_wps() argument
1089 hostapd_wps_clear_ies(hapd, 0); in hostapd_init_wps()
1100 wps->cb_ctx = hapd; in hostapd_init_wps()
1103 wps->wps_state = hapd->conf->wps_state; in hostapd_init_wps()
1104 wps->ap_setup_locked = hapd->conf->ap_setup_locked; in hostapd_init_wps()
1105 if (is_nil_uuid(hapd->conf->uuid)) { in hostapd_init_wps()
1107 uuid = get_own_uuid(hapd->iface); in hostapd_init_wps()
1113 uuid_gen_mac_addr(hapd->own_addr, wps->uuid); in hostapd_init_wps()
1118 os_memcpy(wps->uuid, hapd->conf->uuid, UUID_LEN); in hostapd_init_wps()
1122 wps->ssid_len = hapd->conf->ssid.ssid_len; in hostapd_init_wps()
1123 os_memcpy(wps->ssid, hapd->conf->ssid.ssid, wps->ssid_len); in hostapd_init_wps()
1125 os_memcpy(wps->dev.mac_addr, hapd->own_addr, ETH_ALEN); in hostapd_init_wps()
1126 wps->dev.device_name = hapd->conf->device_name ? in hostapd_init_wps()
1127 os_strdup(hapd->conf->device_name) : NULL; in hostapd_init_wps()
1128 wps->dev.manufacturer = hapd->conf->manufacturer ? in hostapd_init_wps()
1129 os_strdup(hapd->conf->manufacturer) : NULL; in hostapd_init_wps()
1130 wps->dev.model_name = hapd->conf->model_name ? in hostapd_init_wps()
1131 os_strdup(hapd->conf->model_name) : NULL; in hostapd_init_wps()
1132 wps->dev.model_number = hapd->conf->model_number ? in hostapd_init_wps()
1133 os_strdup(hapd->conf->model_number) : NULL; in hostapd_init_wps()
1134 wps->dev.serial_number = hapd->conf->serial_number ? in hostapd_init_wps()
1135 os_strdup(hapd->conf->serial_number) : NULL; in hostapd_init_wps()
1137 wps_config_methods_str2bin(hapd->conf->config_methods); in hostapd_init_wps()
1152 os_memcpy(wps->dev.pri_dev_type, hapd->conf->device_type, in hostapd_init_wps()
1155 if (hostapd_wps_set_vendor_ext(hapd, wps) < 0 || in hostapd_init_wps()
1156 hostapd_wps_set_application_ext(hapd, wps) < 0) in hostapd_init_wps()
1159 wps->dev.os_version = WPA_GET_BE32(hapd->conf->os_version); in hostapd_init_wps()
1165 hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211A ? in hostapd_init_wps()
1167 hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211AD ? in hostapd_init_wps()
1270 if ((hapd->conf->multi_ap & FRONTHAUL_BSS) && in hostapd_init_wps()
1271 hapd->conf->multi_ap_backhaul_ssid.ssid_len) { in hostapd_init_wps()
1273 hapd->conf->multi_ap_backhaul_ssid.ssid_len; in hostapd_init_wps()
1275 hapd->conf->multi_ap_backhaul_ssid.ssid; in hostapd_init_wps()
1304 cfg.cb_ctx = hapd; in hostapd_init_wps()
1308 cfg.disable_auto_conf = (hapd->conf->wps_cred_processing == 1) && in hostapd_init_wps()
1310 cfg.dualband = interface_count(hapd->iface) > 1; in hostapd_init_wps()
1325 wps->friendly_name = hapd->conf->friendly_name; in hostapd_init_wps()
1326 wps->manufacturer_url = hapd->conf->manufacturer_url; in hostapd_init_wps()
1327 wps->model_description = hapd->conf->model_description; in hostapd_init_wps()
1328 wps->model_url = hapd->conf->model_url; in hostapd_init_wps()
1329 wps->upc = hapd->conf->upc; in hostapd_init_wps()
1332 hostapd_register_probereq_cb(hapd, hostapd_wps_probe_req_rx, hapd); in hostapd_init_wps()
1335 if ((hapd->conf->p2p & P2P_ENABLED) && in hostapd_init_wps()
1336 is_6ghz_op_class(hapd->iconf->op_class)) in hostapd_init_wps()
1339 hapd->wps = wps; in hostapd_init_wps()
1351 int hostapd_init_wps_complete(struct hostapd_data *hapd) in hostapd_init_wps_complete() argument
1353 struct wps_context *wps = hapd->wps; in hostapd_init_wps_complete()
1359 if (hostapd_wps_upnp_init(hapd, wps) < 0) { in hostapd_init_wps_complete()
1363 hapd->wps = NULL; in hostapd_init_wps_complete()
1387 static int hostapd_wps_update_multi_ap(struct hostapd_data *hapd, in hostapd_wps_update_multi_ap() argument
1390 struct hostapd_bss_config *conf = hapd->conf; in hostapd_wps_update_multi_ap()
1429 void hostapd_deinit_wps(struct hostapd_data *hapd) in hostapd_deinit_wps() argument
1431 eloop_cancel_timeout(hostapd_wps_reenable_ap_pin, hapd, NULL); in hostapd_deinit_wps()
1432 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_deinit_wps()
1433 eloop_cancel_timeout(wps_reload_config, hapd->iface, NULL); in hostapd_deinit_wps()
1434 if (hapd->wps == NULL) { in hostapd_deinit_wps()
1435 hostapd_wps_clear_ies(hapd, 1); in hostapd_deinit_wps()
1439 hostapd_wps_upnp_deinit(hapd); in hostapd_deinit_wps()
1441 wps_registrar_deinit(hapd->wps->registrar); in hostapd_deinit_wps()
1442 wps_free_pending_msgs(hapd->wps->upnp_msgs); in hostapd_deinit_wps()
1443 hostapd_free_wps(hapd->wps); in hostapd_deinit_wps()
1444 hapd->wps = NULL; in hostapd_deinit_wps()
1445 hostapd_wps_clear_ies(hapd, 1); in hostapd_deinit_wps()
1449 void hostapd_update_wps(struct hostapd_data *hapd) in hostapd_update_wps() argument
1451 struct wps_context *wps = hapd->wps; in hostapd_update_wps()
1452 struct hostapd_bss_config *conf = hapd->conf; in hostapd_update_wps()
1503 hostapd_wps_update_multi_ap(hapd, wps->registrar); in hostapd_update_wps()
1505 hostapd_wps_set_vendor_ext(hapd, wps); in hostapd_update_wps()
1506 hostapd_wps_set_application_ext(hapd, wps); in hostapd_update_wps()
1511 hostapd_deinit_wps(hapd); in hostapd_update_wps()
1525 static int wps_add_pin(struct hostapd_data *hapd, void *ctx) in wps_add_pin() argument
1530 if (hapd->wps == NULL) in wps_add_pin()
1532 ret = wps_registrar_add_pin(hapd->wps->registrar, data->addr, in wps_add_pin()
1541 int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *addr, in hostapd_wps_add_pin() argument
1561 if (hostapd_wps_for_each(hapd, wps_add_pin, &data) < 0) in hostapd_wps_add_pin()
1572 static int wps_button_pushed(struct hostapd_data *hapd, void *ctx) in wps_button_pushed() argument
1576 if (hapd->wps) { in wps_button_pushed()
1578 return wps_registrar_button_pushed(hapd->wps->registrar, in wps_button_pushed()
1586 int hostapd_wps_button_pushed(struct hostapd_data *hapd, in hostapd_wps_button_pushed() argument
1594 ret = hostapd_wps_for_each(hapd, wps_button_pushed, &ctx); in hostapd_wps_button_pushed()
1605 static int wps_cancel(struct hostapd_data *hapd, void *ctx) in wps_cancel() argument
1609 if (hapd->wps) { in wps_cancel()
1611 wps_registrar_wps_cancel(hapd->wps->registrar); in wps_cancel()
1612 ap_for_each_sta(hapd, ap_sta_wps_cancel, NULL); in wps_cancel()
1613 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_CANCEL); in wps_cancel()
1620 int hostapd_wps_cancel(struct hostapd_data *hapd) in hostapd_wps_cancel() argument
1626 ret = hostapd_wps_for_each(hapd, wps_cancel, &ctx); in hostapd_wps_cancel()
1638 struct hostapd_data *hapd = ctx; in hostapd_wps_probe_req_rx() local
1642 if (hapd->wps == NULL) in hostapd_wps_probe_req_rx()
1652 (elems.ssid_len != hapd->conf->ssid.ssid_len || in hostapd_wps_probe_req_rx()
1653 os_memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) != in hostapd_wps_probe_req_rx()
1673 wps_registrar_probe_req_rx(hapd->wps->registrar, addr, wps_ie, in hostapd_wps_probe_req_rx()
1680 hapd->wps_upnp, addr, in hostapd_wps_probe_req_rx()
1698 struct hostapd_data *hapd = priv; in hostapd_rx_req_put_wlan_response() local
1717 sta = ap_get_sta(hapd, mac_addr); in hostapd_rx_req_put_wlan_response()
1727 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_rx_req_put_wlan_response()
1755 p->next = hapd->wps->upnp_msgs; in hostapd_rx_req_put_wlan_response()
1756 hapd->wps->upnp_msgs = p; in hostapd_rx_req_put_wlan_response()
1762 static int hostapd_wps_upnp_init(struct hostapd_data *hapd, in hostapd_wps_upnp_init() argument
1767 if (!hapd->conf->upnp_iface) in hostapd_wps_upnp_init()
1774 if (hapd->conf->ap_pin) in hostapd_wps_upnp_init()
1775 ctx->ap_pin = os_strdup(hapd->conf->ap_pin); in hostapd_wps_upnp_init()
1777 hapd->wps_upnp = upnp_wps_device_init(ctx, wps, hapd, in hostapd_wps_upnp_init()
1778 hapd->conf->upnp_iface); in hostapd_wps_upnp_init()
1779 if (hapd->wps_upnp == NULL) in hostapd_wps_upnp_init()
1781 wps->wps_upnp = hapd->wps_upnp; in hostapd_wps_upnp_init()
1787 static void hostapd_wps_upnp_deinit(struct hostapd_data *hapd) in hostapd_wps_upnp_deinit() argument
1789 upnp_wps_device_deinit(hapd->wps_upnp, hapd); in hostapd_wps_upnp_deinit()
1795 int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, const u8 *addr, in hostapd_wps_get_mib_sta() argument
1798 if (hapd->wps == NULL) in hostapd_wps_get_mib_sta()
1800 return wps_registrar_get_info(hapd->wps->registrar, addr, buf, buflen); in hostapd_wps_get_mib_sta()
1806 struct hostapd_data *hapd = eloop_data; in hostapd_wps_ap_pin_timeout() local
1808 hostapd_wps_ap_pin_disable(hapd); in hostapd_wps_ap_pin_timeout()
1809 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_PIN_DISABLED); in hostapd_wps_ap_pin_timeout()
1813 static void hostapd_wps_ap_pin_enable(struct hostapd_data *hapd, int timeout) in hostapd_wps_ap_pin_enable() argument
1816 hapd->ap_pin_failures = 0; in hostapd_wps_ap_pin_enable()
1817 hapd->ap_pin_failures_consecutive = 0; in hostapd_wps_ap_pin_enable()
1818 hapd->conf->ap_setup_locked = 0; in hostapd_wps_ap_pin_enable()
1819 if (hapd->wps->ap_setup_locked) { in hostapd_wps_ap_pin_enable()
1820 wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_UNLOCKED); in hostapd_wps_ap_pin_enable()
1821 hapd->wps->ap_setup_locked = 0; in hostapd_wps_ap_pin_enable()
1822 wps_registrar_update_ie(hapd->wps->registrar); in hostapd_wps_ap_pin_enable()
1824 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_wps_ap_pin_enable()
1827 hostapd_wps_ap_pin_timeout, hapd, NULL); in hostapd_wps_ap_pin_enable()
1831 static int wps_ap_pin_disable(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_disable() argument
1833 os_free(hapd->conf->ap_pin); in wps_ap_pin_disable()
1834 hapd->conf->ap_pin = NULL; in wps_ap_pin_disable()
1836 upnp_wps_set_ap_pin(hapd->wps_upnp, NULL); in wps_ap_pin_disable()
1838 eloop_cancel_timeout(hostapd_wps_ap_pin_timeout, hapd, NULL); in wps_ap_pin_disable()
1843 void hostapd_wps_ap_pin_disable(struct hostapd_data *hapd) in hostapd_wps_ap_pin_disable() argument
1846 hostapd_wps_for_each(hapd, wps_ap_pin_disable, NULL); in hostapd_wps_ap_pin_disable()
1856 static int wps_ap_pin_set(struct hostapd_data *hapd, void *ctx) in wps_ap_pin_set() argument
1860 if (!hapd->wps) in wps_ap_pin_set()
1863 os_free(hapd->conf->ap_pin); in wps_ap_pin_set()
1864 hapd->conf->ap_pin = os_strdup(data->pin_txt); in wps_ap_pin_set()
1866 upnp_wps_set_ap_pin(hapd->wps_upnp, data->pin_txt); in wps_ap_pin_set()
1868 hostapd_wps_ap_pin_enable(hapd, data->timeout); in wps_ap_pin_set()
1873 const char * hostapd_wps_ap_pin_random(struct hostapd_data *hapd, int timeout) in hostapd_wps_ap_pin_random() argument
1882 hostapd_wps_for_each(hapd, wps_ap_pin_set, &data); in hostapd_wps_ap_pin_random()
1883 return hapd->conf->ap_pin; in hostapd_wps_ap_pin_random()
1887 const char * hostapd_wps_ap_pin_get(struct hostapd_data *hapd) in hostapd_wps_ap_pin_get() argument
1889 return hapd->conf->ap_pin; in hostapd_wps_ap_pin_get()
1893 int hostapd_wps_ap_pin_set(struct hostapd_data *hapd, const char *pin, in hostapd_wps_ap_pin_set() argument
1903 return hostapd_wps_for_each(hapd, wps_ap_pin_set, &data); in hostapd_wps_ap_pin_set()
1907 static int wps_update_ie(struct hostapd_data *hapd, void *ctx) in wps_update_ie() argument
1909 if (hapd->wps) in wps_update_ie()
1910 wps_registrar_update_ie(hapd->wps->registrar); in wps_update_ie()
1915 void hostapd_wps_update_ie(struct hostapd_data *hapd) in hostapd_wps_update_ie() argument
1917 hostapd_wps_for_each(hapd, wps_update_ie, NULL); in hostapd_wps_update_ie()
1921 int hostapd_wps_config_ap(struct hostapd_data *hapd, const char *ssid, in hostapd_wps_config_ap() argument
1968 if (!hapd->wps) { in hostapd_wps_config_ap()
1973 return wps_registrar_config_ap(hapd->wps->registrar, &cred); in hostapd_wps_config_ap()
1986 static int wps_add_nfc_password_token(struct hostapd_data *hapd, void *ctx) in wps_add_nfc_password_token() argument
1991 if (hapd->wps == NULL) in wps_add_nfc_password_token()
1993 ret = wps_registrar_add_nfc_password_token(hapd->wps->registrar, in wps_add_nfc_password_token()
2002 static int hostapd_wps_add_nfc_password_token(struct hostapd_data *hapd, in hostapd_wps_add_nfc_password_token() argument
2010 if (hostapd_wps_for_each(hapd, wps_add_nfc_password_token, &data) < 0) in hostapd_wps_add_nfc_password_token()
2016 static int hostapd_wps_nfc_tag_process(struct hostapd_data *hapd, in hostapd_wps_nfc_tag_process() argument
2029 return hostapd_wps_add_nfc_password_token(hapd, &attr); in hostapd_wps_nfc_tag_process()
2036 int hostapd_wps_nfc_tag_read(struct hostapd_data *hapd, in hostapd_wps_nfc_tag_read() argument
2056 ret = hostapd_wps_nfc_tag_process(hapd, wps); in hostapd_wps_nfc_tag_read()
2062 struct wpabuf * hostapd_wps_nfc_config_token(struct hostapd_data *hapd, in hostapd_wps_nfc_config_token() argument
2067 if (hapd->wps == NULL) in hostapd_wps_nfc_config_token()
2070 ret = wps_get_oob_cred(hapd->wps, hostapd_wps_rf_band_cb(hapd), in hostapd_wps_nfc_config_token()
2071 hapd->iconf->channel); in hostapd_wps_nfc_config_token()
2085 struct wpabuf * hostapd_wps_nfc_hs_cr(struct hostapd_data *hapd, int ndef) in hostapd_wps_nfc_hs_cr() argument
2089 if (hapd->wps == NULL) in hostapd_wps_nfc_hs_cr()
2092 if (hapd->conf->wps_nfc_dh_pubkey == NULL) { in hostapd_wps_nfc_hs_cr()
2093 struct wps_context *wps = hapd->wps; in hostapd_wps_nfc_hs_cr()
2094 if (wps_nfc_gen_dh(&hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_hs_cr()
2095 &hapd->conf->wps_nfc_dh_privkey) < 0) in hostapd_wps_nfc_hs_cr()
2100 wpabuf_dup(hapd->conf->wps_nfc_dh_pubkey); in hostapd_wps_nfc_hs_cr()
2102 wpabuf_dup(hapd->conf->wps_nfc_dh_privkey); in hostapd_wps_nfc_hs_cr()
2109 ret = wps_build_nfc_handover_sel(hapd->wps, in hostapd_wps_nfc_hs_cr()
2110 hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_hs_cr()
2111 hapd->own_addr, hapd->iface->freq); in hostapd_wps_nfc_hs_cr()
2126 int hostapd_wps_nfc_report_handover(struct hostapd_data *hapd, in hostapd_wps_nfc_report_handover() argument
2209 ret = wps_registrar_add_nfc_pw_token(hapd->wps->registrar, in hostapd_wps_nfc_report_handover()
2220 struct wpabuf * hostapd_wps_nfc_token_gen(struct hostapd_data *hapd, int ndef) in hostapd_wps_nfc_token_gen() argument
2222 if (hapd->conf->wps_nfc_pw_from_config) { in hostapd_wps_nfc_token_gen()
2224 hapd->conf->wps_nfc_dev_pw_id, in hostapd_wps_nfc_token_gen()
2225 hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_token_gen()
2226 hapd->conf->wps_nfc_dev_pw); in hostapd_wps_nfc_token_gen()
2229 return wps_nfc_token_gen(ndef, &hapd->conf->wps_nfc_dev_pw_id, in hostapd_wps_nfc_token_gen()
2230 &hapd->conf->wps_nfc_dh_pubkey, in hostapd_wps_nfc_token_gen()
2231 &hapd->conf->wps_nfc_dh_privkey, in hostapd_wps_nfc_token_gen()
2232 &hapd->conf->wps_nfc_dev_pw); in hostapd_wps_nfc_token_gen()
2236 int hostapd_wps_nfc_token_enable(struct hostapd_data *hapd) in hostapd_wps_nfc_token_enable() argument
2238 struct wps_context *wps = hapd->wps; in hostapd_wps_nfc_token_enable()
2244 if (!hapd->conf->wps_nfc_dh_pubkey || in hostapd_wps_nfc_token_enable()
2245 !hapd->conf->wps_nfc_dh_privkey || in hostapd_wps_nfc_token_enable()
2246 !hapd->conf->wps_nfc_dev_pw || in hostapd_wps_nfc_token_enable()
2247 !hapd->conf->wps_nfc_dev_pw_id) in hostapd_wps_nfc_token_enable()
2253 hapd->conf->wps_nfc_dev_pw_id, hapd->conf->iface, wps); in hostapd_wps_nfc_token_enable()
2254 wps->ap_nfc_dev_pw_id = hapd->conf->wps_nfc_dev_pw_id; in hostapd_wps_nfc_token_enable()
2255 wps->ap_nfc_dh_pubkey = wpabuf_dup(hapd->conf->wps_nfc_dh_pubkey); in hostapd_wps_nfc_token_enable()
2256 wps->ap_nfc_dh_privkey = wpabuf_dup(hapd->conf->wps_nfc_dh_privkey); in hostapd_wps_nfc_token_enable()
2257 pw = hapd->conf->wps_nfc_dev_pw; in hostapd_wps_nfc_token_enable()
2278 void hostapd_wps_nfc_token_disable(struct hostapd_data *hapd) in hostapd_wps_nfc_token_disable() argument
2281 hapd->conf->iface); in hostapd_wps_nfc_token_disable()
2282 hostapd_wps_nfc_clear(hapd->wps); in hostapd_wps_nfc_token_disable()