Home | History | Annotate | Download | only in ap

Lines Matching defs:wps

2  * hostapd / WPS integration
19 #include "wps/wps.h"
20 #include "wps/wps_defs.h"
21 #include "wps/wps_dev_attr.h"
22 #include "wps/wps_attr_parse.h"
32 #include "wps/wps_upnp.h"
34 struct wps_context *wps);
104 "Received new WPA/WPA2-PSK from WPS for STA " MACSTR,
108 "Received new WPA/WPA2-PSK from WPS for STA " MACSTR
179 wpa_printf(MSG_DEBUG, "WPS: PIN needed for E-UUID %s", uuid);
219 if (hapd != data->current_hapd && hapd->wps != NULL)
220 wps_registrar_complete(hapd->wps->registrar, data->uuid_e,
281 wpa_printf(MSG_DEBUG, "WPS: Reload configuration data");
284 wpa_printf(MSG_WARNING, "WPS: Failed to reload the updated "
309 wpa_printf(MSG_DEBUG, "WPS: Updating in-memory configuration");
422 if (hapd->wps == NULL)
425 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
428 wpa_printf(MSG_DEBUG, "WPS: Received new AP Settings");
429 wpa_hexdump_ascii(MSG_DEBUG, "WPS: SSID", cred->ssid, cred->ssid_len);
430 wpa_printf(MSG_DEBUG, "WPS: Authentication Type 0x%x",
432 wpa_printf(MSG_DEBUG, "WPS: Encryption Type 0x%x", cred->encr_type);
433 wpa_printf(MSG_DEBUG, "WPS: Network Key Index %d", cred->key_idx);
434 wpa_hexdump_key(MSG_DEBUG, "WPS: Network Key",
436 wpa_printf(MSG_DEBUG, "WPS: MAC Address " MACSTR,
456 os_memcpy(hapd->wps->ssid, cred->ssid, cred->ssid_len);
457 hapd->wps->ssid_len = cred->ssid_len;
458 hapd->wps->encr_types = cred->encr_type;
459 hapd->wps->auth_types = cred->auth_type;
461 os_free(hapd->wps->network_key);
462 hapd->wps->network_key = NULL;
463 hapd->wps->network_key_len = 0;
465 if (hapd->wps->network_key == NULL ||
466 hapd->wps->network_key_len < cred->key_len) {
467 hapd->wps->network_key_len = 0;
468 os_free(hapd->wps->network_key);
469 hapd->wps->network_key = os_malloc(cred->key_len);
470 if (hapd->wps->network_key == NULL)
473 hapd->wps->network_key_len = cred->key_len;
474 os_memcpy(hapd->wps->network_key, cred->key, cred->key_len);
476 hapd->wps->wps_state = WPS_STATE_CONFIGURED;
488 wpa_printf(MSG_WARNING, "WPS: Could not open current "
496 wpa_printf(MSG_WARNING, "WPS: Could not write updated "
503 fprintf(nconf, "# WPS configuration - START\n");
565 wpa_printf(MSG_WARNING, "WPS: Invalid key length %lu "
599 fprintf(nconf, "# WPS configuration - END\n");
618 fprintf(nconf, "#WPS# %s", buf);
627 wpa_printf(MSG_WARNING, "WPS: Failed to rename the updated "
641 wpa_printf(MSG_DEBUG, "WPS: AP configuration updated");
663 wpa_printf(MSG_DEBUG, "WPS: Re-enable AP PIN");
665 hapd->wps->ap_setup_locked = 0;
666 wps_registrar_update_ie(hapd->wps->registrar);
674 if (!data->enrollee || hapd->conf->ap_pin == NULL || hapd->wps == NULL)
684 wpa_printf(MSG_DEBUG, "WPS: AP PIN authentication failure number %u "
691 hapd->wps->ap_setup_locked = 1;
693 wps_registrar_update_ie(hapd->wps->registrar);
702 wpa_printf(MSG_DEBUG, "WPS: AP PIN disabled indefinitely");
710 wpa_printf(MSG_DEBUG, "WPS: Disable AP PIN for %u seconds",
725 /* Update WPS Status - Authentication Failure */
726 wpa_printf(MSG_DEBUG, "WPS: Authentication failure update");
737 if (hapd->conf->ap_pin == NULL || hapd->wps == NULL)
743 wpa_printf(MSG_DEBUG, "WPS: Clear consecutive AP PIN failure counter "
760 /* Update WPS Status - PBC Overlap */
767 /* Update WPS PBC Status:PBC Timeout */
774 /* Update WPS PBC status - Active */
781 /* Update WPS PBC status - Active */
789 /* Update WPS status - Success */
799 /* Update WPS status - Failure */
905 if (hapd->wps && !hapd->conf->wps_independent &&
906 !is_nil_uuid(hapd->wps->uuid)) {
907 *uuid = hapd->wps->uuid;
950 struct wps_context *wps)
955 wpabuf_free(wps->dev.vendor_ext[i]);
956 wps->dev.vendor_ext[i] = NULL;
961 wps->dev.vendor_ext[i] =
963 if (wps->dev.vendor_ext[i] == NULL) {
965 wpabuf_free(wps->dev.vendor_ext[i]);
977 struct wps_context *wps;
985 wps = os_zalloc(sizeof(*wps));
986 if (wps == NULL)
989 wps->cred_cb = hostapd_wps_cred_cb;
990 wps->event_cb = hostapd_wps_event_cb;
991 wps->rf_band_cb = hostapd_wps_rf_band_cb;
992 wps->cb_ctx = hapd;
995 wps->wps_state = hapd->conf->wps_state;
996 wps->ap_setup_locked = hapd->conf->ap_setup_locked;
1001 os_memcpy(wps->uuid, uuid, UUID_LEN);
1002 wpa_hexdump(MSG_DEBUG, "WPS: Clone UUID from another "
1003 "interface", wps->uuid, UUID_LEN);
1005 uuid_gen_mac_addr(hapd->own_addr, wps->uuid);
1006 wpa_hexdump(MSG_DEBUG, "WPS: UUID based on MAC "
1007 "address", wps->uuid, UUID_LEN);
1010 os_memcpy(wps->uuid, hapd->conf->uuid, UUID_LEN);
1011 wpa_hexdump(MSG_DEBUG, "WPS: Use configured UUID",
1012 wps->uuid, UUID_LEN);
1014 wps->ssid_len = hapd->conf->ssid.ssid_len;
1015 os_memcpy(wps->ssid, hapd->conf->ssid.ssid, wps->ssid_len);
1016 wps->ap = 1;
1017 os_memcpy(wps->dev.mac_addr, hapd->own_addr, ETH_ALEN);
1018 wps->dev.device_name = hapd->conf->device_name ?
1020 wps->dev.manufacturer = hapd->conf->manufacturer ?
1022 wps->dev.model_name = hapd->conf->model_name ?
1024 wps->dev.model_number = hapd->conf->model_number ?
1026 wps->dev.serial_number = hapd->conf->serial_number ?
1028 wps->config_methods =
1031 if ((wps->config_methods &
1034 wpa_printf(MSG_INFO, "WPS: Converting display to "
1035 "virtual_display for WPS 2.0 compliance");
1036 wps->config_methods |= WPS_CONFIG_VIRT_DISPLAY;
1038 if ((wps->config_methods &
1041 wpa_printf(MSG_INFO, "WPS: Converting push_button to "
1042 "virtual_push_button for WPS 2.0 compliance");
1043 wps->config_methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
1046 os_memcpy(wps->dev.pri_dev_type, hapd->conf->device_type,
1049 if (hostapd_wps_set_vendor_ext(hapd, wps) < 0) {
1050 os_free(wps);
1054 wps->dev.os_version = WPA_GET_BE32(hapd->conf->os_version);
1057 wps->dev.rf_bands = conf->wps_rf_bands;
1059 wps->dev.rf_bands =
1066 wps->auth_types |= WPS_AUTH_WPA2PSK;
1068 wps->auth_types |= WPS_AUTH_WPA2;
1071 wps->encr_types |= WPS_ENCR_AES;
1073 wps->encr_types |= WPS_ENCR_TKIP;
1078 wps->auth_types |= WPS_AUTH_WPAPSK;
1080 wps->auth_types |= WPS_AUTH_WPA;
1083 wps->encr_types |= WPS_ENCR_AES;
1085 wps->encr_types |= WPS_ENCR_TKIP;
1089 wps->encr_types |= WPS_ENCR_NONE;
1090 wps->auth_types |= WPS_AUTH_OPEN;
1092 wps->encr_types |= WPS_ENCR_WEP;
1094 wps->auth_types |= WPS_AUTH_OPEN;
1096 wps->auth_types |= WPS_AUTH_SHARED;
1098 wps->auth_types |= WPS_AUTH_OPEN;
1100 wps->encr_types |= WPS_ENCR_WEP;
1102 wps->encr_types |= WPS_ENCR_NONE;
1108 wps->network_key = (u8 *) os_strdup(conf->ssid.wpa_passphrase);
1109 wps->network_key_len = os_strlen(conf->ssid.wpa_passphrase);
1111 wps->network_key = os_malloc(2 * PMK_LEN + 1);
1112 if (wps->network_key == NULL) {
1113 os_free(wps);
1116 wpa_snprintf_hex((char *) wps->network_key, 2 * PMK_LEN + 1,
1118 wps->network_key_len = 2 * PMK_LEN;
1120 wps->network_key = os_malloc(conf->ssid.wep.len[0]);
1121 if (wps->network_key == NULL) {
1122 os_free(wps);
1125 os_memcpy(wps->network_key, conf->ssid.wep.key[0],
1127 wps->network_key_len = conf->ssid.wep.len[0];
1131 os_memcpy(wps->psk, conf->ssid.wpa_psk->psk, PMK_LEN);
1132 wps->psk_set = 1;
1137 wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK;
1138 wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP;
1141 wps->ap_settings = conf->ap_settings;
1142 wps->ap_settings_len = conf->ap_settings_len;
1158 if ((wps->dev.rf_bands & (WPS_RF_50GHZ | WPS_RF_24GHZ)) ==
1162 wpa_printf(MSG_DEBUG, "WPS: Dualband AP");
1165 wps->registrar = wps_registrar_init(wps, &cfg);
1166 if (wps->registrar == NULL) {
1167 wpa_printf(MSG_ERROR, "Failed to initialize WPS Registrar");
1168 os_free(wps->network_key);
1169 os_free(wps);
1174 wps->friendly_name = hapd->conf->friendly_name;
1175 wps->manufacturer_url = hapd->conf->manufacturer_url;
1176 wps->model_description = hapd->conf->model_description;
1177 wps->model_url = hapd->conf->model_url;
1178 wps->upc = hapd->conf->upc;
1183 hapd->wps = wps;
1191 struct wps_context *wps = hapd->wps;
1193 if (wps == NULL)
1197 if (hostapd_wps_upnp_init(hapd, wps) < 0) {
1198 wpa_printf(MSG_ERROR, "Failed to initialize WPS UPnP");
1199 wps_registrar_deinit(wps->registrar);
1200 os_free(wps->network_key);
1201 os_free(wps);
1202 hapd->wps = NULL;
1211 static void hostapd_wps_nfc_clear(struct wps_context *wps)
1214 wps->ap_nfc_dev_pw_id = 0;
1215 wpabuf_free(wps->ap_nfc_dh_pubkey);
1216 wps->ap_nfc_dh_pubkey = NULL;
1217 wpabuf_free(wps->ap_nfc_dh_privkey);
1218 wps->ap_nfc_dh_privkey = NULL;
1219 wpabuf_free(wps->ap_nfc_dev_pw);
1220 wps->ap_nfc_dev_pw = NULL;
1229 if (hapd->wps == NULL)
1234 wps_registrar_deinit(hapd->wps->registrar);
1235 os_free(hapd->wps->network_key);
1236 wps_device_data_free(&hapd->wps->dev);
1237 wpabuf_free(hapd->wps->dh_pubkey);
1238 wpabuf_free(hapd->wps->dh_privkey);
1239 wps_free_pending_msgs(hapd->wps->upnp_msgs);
1240 hostapd_wps_nfc_clear(hapd->wps);
1241 os_free(hapd->wps);
1242 hapd->wps = NULL;
1249 if (hapd->wps == NULL)
1253 hapd->wps->friendly_name = hapd->conf->friendly_name;
1254 hapd->wps->manufacturer_url = hapd->conf->manufacturer_url;
1255 hapd->wps->model_description = hapd->conf->model_description;
1256 hapd->wps->model_url = hapd->conf->model_url;
1257 hapd->wps->upc = hapd->conf->upc;
1260 hostapd_wps_set_vendor_ext(hapd, hapd->wps);
1263 wps_registrar_update_ie(hapd->wps->registrar);
1284 if (hapd->wps == NULL)
1286 ret = wps_registrar_add_pin(hapd->wps->registrar, data->addr,
1324 if (hapd->wps == NULL)
1326 return wps_registrar_button_pushed(hapd->wps->registrar, p2p_dev_addr);
1340 if (hapd->wps == NULL)
1343 wps_registrar_wps_cancel(hapd->wps->registrar);
1365 if (hapd->wps == NULL)
1369 wpa_printf(MSG_DEBUG, "WPS: Could not parse ProbeReq from "
1396 wps_registrar_probe_req_rx(hapd->wps->registrar, addr, wps_ie,
1400 * WPS attributes? Full ProbeReq frame? */
1425 wpa_printf(MSG_DEBUG, "WPS UPnP: PutWLANResponse ev_type=%d mac_addr="
1427 wpa_hexdump(MSG_MSGDUMP, "WPS UPnP: PutWLANResponse NewMessage",
1430 wpa_printf(MSG_DEBUG, "WPS UPnP: Ignored unexpected "
1436 * EAP response to ongoing to WPS Registration. Send it to EAP-WSC
1445 * Pick STA that is in an ongoing WPS registration without
1448 wpa_printf(MSG_DEBUG, "WPS UPnP: No matching STA found based "
1458 wpa_printf(MSG_DEBUG, "WPS UPnP: No matching STA found");
1468 p->next = hapd->wps->upnp_msgs;
1469 hapd->wps->upnp_msgs = p;
1476 struct wps_context *wps)
1490 hapd->wps_upnp = upnp_wps_device_init(ctx, wps, hapd,
1494 wps->wps_upnp = hapd->wps_upnp;
1511 if (hapd->wps == NULL)
1513 return wps_registrar_get_info(hapd->wps->registrar, addr, buf, buflen);
1520 wpa_printf(MSG_DEBUG, "WPS: AP PIN timed out");
1528 wpa_printf(MSG_DEBUG, "WPS: Enabling AP PIN (timeout=%d)", timeout);
1532 if (hapd->wps->ap_setup_locked) {
1534 hapd->wps->ap_setup_locked = 0;
1535 wps_registrar_update_ie(hapd->wps->registrar);
1558 wpa_printf(MSG_DEBUG, "WPS: Disabling AP PIN");
1617 if (hapd->wps)
1618 wps_registrar_update_ie(hapd->wps->registrar);
1674 return wps_registrar_config_ap(hapd->wps->registrar, &cred);
1692 if (hapd->wps == NULL)
1694 ret = wps_registrar_add_nfc_password_token(hapd->wps->registrar,
1718 const struct wpabuf *wps)
1722 wpa_hexdump_buf(MSG_DEBUG, "WPS: Received NFC tag payload", wps);
1724 if (wps_parse_msg(wps, &attr)) {
1725 wpa_printf(MSG_DEBUG, "WPS: Ignore invalid data from NFC tag");
1732 wpa_printf(MSG_DEBUG, "WPS: Ignore unrecognized NFC tag");
1740 const struct wpabuf *wps = data;
1751 wpa_printf(MSG_DEBUG, "WPS: Could not parse NDEF");
1754 wps = tmp;
1757 ret = hostapd_wps_nfc_tag_process(hapd, wps);
1768 if (hapd->wps == NULL)
1771 ret = wps_get_oob_cred(hapd->wps);
1788 * Handover Select carrier record for WPS uses the same format as
1813 struct wps_context *wps = hapd->wps;
1816 if (wps == NULL)
1825 hostapd_wps_nfc_clear(wps);
1826 wps->ap_nfc_dev_pw_id = hapd->conf->wps_nfc_dev_pw_id;
1827 wps->ap_nfc_dh_pubkey = wpabuf_dup(hapd->conf->wps_nfc_dh_pubkey);
1828 wps->ap_nfc_dh_privkey = wpabuf_dup(hapd->conf->wps_nfc_dh_privkey);
1830 wps->ap_nfc_dev_pw = wpabuf_alloc(
1832 if (wps->ap_nfc_dev_pw) {
1834 (char *) wpabuf_put(wps->ap_nfc_dev_pw,
1840 wps->ap_nfc_dh_pubkey || !wps->ap_nfc_dh_privkey ||
1841 !wps->ap_nfc_dev_pw) {
1842 hostapd_wps_nfc_clear(wps);
1852 hostapd_wps_nfc_clear(hapd->wps);