hostap: Fix WPA-PSK handling
WPA-PSK was added a bit late, so, it wasn't properly implemented, use both key management and protocol version to properly handle WPA-PSK in both connection and also in the status. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no> Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
786fee7ae5
commit
9e9a067c02
|
@ -294,13 +294,17 @@ static inline enum wifi_frequency_bands wpas_band_to_zephyr(enum wpa_radio_work_
|
|||
}
|
||||
}
|
||||
|
||||
static inline enum wifi_security_type wpas_key_mgmt_to_zephyr(int key_mgmt)
|
||||
static inline enum wifi_security_type wpas_key_mgmt_to_zephyr(int key_mgmt, int proto)
|
||||
{
|
||||
switch (key_mgmt) {
|
||||
case WPA_KEY_MGMT_NONE:
|
||||
return WIFI_SECURITY_TYPE_NONE;
|
||||
case WPA_KEY_MGMT_PSK:
|
||||
return WIFI_SECURITY_TYPE_PSK;
|
||||
if (proto == WPA_PROTO_RSN) {
|
||||
return WIFI_SECURITY_TYPE_PSK;
|
||||
} else {
|
||||
return WIFI_SECURITY_TYPE_WPA_PSK;
|
||||
}
|
||||
case WPA_KEY_MGMT_PSK_SHA256:
|
||||
return WIFI_SECURITY_TYPE_PSK_SHA256;
|
||||
case WPA_KEY_MGMT_SAE:
|
||||
|
@ -406,7 +410,8 @@ int supplicant_connect(const struct device *dev, struct wifi_connect_req_params
|
|||
resp.network_id)) {
|
||||
goto out;
|
||||
}
|
||||
} else if (params->security == WIFI_SECURITY_TYPE_PSK) {
|
||||
} else if (params->security == WIFI_SECURITY_TYPE_PSK ||
|
||||
params->security == WIFI_SECURITY_TYPE_WPA_PSK) {
|
||||
if (!wpa_cli_cmd_v("set_network %d psk \"%s\"",
|
||||
resp.network_id, params->psk)) {
|
||||
goto out;
|
||||
|
@ -416,6 +421,18 @@ int supplicant_connect(const struct device *dev, struct wifi_connect_req_params
|
|||
resp.network_id)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (params->security == WIFI_SECURITY_TYPE_WPA_PSK) {
|
||||
if (!wpa_cli_cmd_v("set_network %d proto WPA",
|
||||
resp.network_id)) {
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if (!wpa_cli_cmd_v("set_network %d proto RSN",
|
||||
resp.network_id)) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = -1;
|
||||
wpa_printf(MSG_ERROR, "Unsupported security type: %d",
|
||||
|
@ -567,7 +584,7 @@ int supplicant_status(const struct device *dev, struct wifi_iface_status *status
|
|||
|
||||
os_memcpy(status->bssid, wpa_s->bssid, WIFI_MAC_ADDR_LEN);
|
||||
status->band = wpas_band_to_zephyr(wpas_freq_to_band(wpa_s->assoc_freq));
|
||||
status->security = wpas_key_mgmt_to_zephyr(wpa_s->key_mgmt);
|
||||
status->security = wpas_key_mgmt_to_zephyr(wpa_s->key_mgmt, wpa_s->wpa_proto);
|
||||
status->mfp = ssid->ieee80211w; /* Same mapping */
|
||||
ieee80211_freq_to_chan(wpa_s->assoc_freq, &channel);
|
||||
status->channel = channel;
|
||||
|
|
Loading…
Reference in New Issue