Skip to content

Commit dabeb9c

Browse files
Rex-Chen-NXPkartben
authored andcommitted
net: wifi: shell: wifi status support all sae pwe types
Add support for wifi status show sae HNP,H2E and AUTO exactly. Signed-off-by: Rex Chen <[email protected]>
1 parent 2dc288c commit dabeb9c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

modules/hostap/src/supp_api.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static inline enum wifi_frequency_bands wpas_band_to_zephyr(enum wpa_radio_work_
362362
}
363363
}
364364

365-
static inline enum wifi_security_type wpas_key_mgmt_to_zephyr(int key_mgmt, int proto)
365+
static inline enum wifi_security_type wpas_key_mgmt_to_zephyr(int key_mgmt, int proto, int pwe)
366366
{
367367
switch (key_mgmt) {
368368
case WPA_KEY_MGMT_IEEE8021X:
@@ -380,7 +380,13 @@ static inline enum wifi_security_type wpas_key_mgmt_to_zephyr(int key_mgmt, int
380380
case WPA_KEY_MGMT_PSK_SHA256:
381381
return WIFI_SECURITY_TYPE_PSK_SHA256;
382382
case WPA_KEY_MGMT_SAE:
383-
return WIFI_SECURITY_TYPE_SAE;
383+
if (pwe == 1) {
384+
return WIFI_SECURITY_TYPE_SAE_H2E;
385+
} else if (pwe == 2) {
386+
return WIFI_SECURITY_TYPE_SAE_AUTO;
387+
} else {
388+
return WIFI_SECURITY_TYPE_SAE_HNP;
389+
}
384390
case WPA_KEY_MGMT_SAE | WPA_KEY_MGMT_PSK:
385391
return WIFI_SECURITY_TYPE_WPA_AUTO_PERSONAL;
386392
case WPA_KEY_MGMT_FT_PSK:
@@ -1520,22 +1526,21 @@ int supplicant_status(const struct device *dev, struct wifi_iface_status *status
15201526
u8 *_ssid = ssid->ssid;
15211527
size_t ssid_len = ssid->ssid_len;
15221528
struct status_resp cli_status;
1523-
bool is_ap;
15241529
int proto;
15251530
int key_mgmt;
1531+
int sae_pwe;
15261532

15271533
if (!ssid) {
15281534
wpa_printf(MSG_ERROR, "Failed to get current ssid");
15291535
goto out;
15301536
}
15311537

1532-
is_ap = ssid->mode == WPAS_MODE_AP;
1533-
/* For AP its always the configured one */
1534-
proto = is_ap ? ssid->proto : wpa_s->wpa_proto;
1535-
key_mgmt = is_ap ? ssid->key_mgmt : wpa_s->key_mgmt;
1538+
proto = ssid->proto;
1539+
key_mgmt = ssid->key_mgmt;
1540+
sae_pwe = wpa_s->conf->sae_pwe;
15361541
os_memcpy(status->bssid, wpa_s->bssid, WIFI_MAC_ADDR_LEN);
15371542
status->band = wpas_band_to_zephyr(wpas_freq_to_band(wpa_s->assoc_freq));
1538-
status->security = wpas_key_mgmt_to_zephyr(key_mgmt, proto);
1543+
status->security = wpas_key_mgmt_to_zephyr(key_mgmt, proto, sae_pwe);
15391544
status->mfp = get_mfp(ssid->ieee80211w);
15401545
ieee80211_freq_to_chan(wpa_s->assoc_freq, &channel);
15411546
status->channel = channel;
@@ -2483,6 +2488,7 @@ int supplicant_ap_status(const struct device *dev, struct wifi_iface_status *sta
24832488
struct hostapd_hw_modes *hw_mode;
24842489
int proto; /* Wi-Fi secure protocol */
24852490
int key_mgmt; /* Wi-Fi key management */
2491+
int sae_pwe;
24862492

24872493
k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);
24882494

@@ -2522,7 +2528,8 @@ int supplicant_ap_status(const struct device *dev, struct wifi_iface_status *sta
25222528
status->band = wpas_band_to_zephyr(wpas_freq_to_band(iface->freq));
25232529
key_mgmt = bss->wpa_key_mgmt;
25242530
proto = bss->wpa;
2525-
status->security = wpas_key_mgmt_to_zephyr(key_mgmt, proto);
2531+
sae_pwe = bss->sae_pwe;
2532+
status->security = wpas_key_mgmt_to_zephyr(key_mgmt, proto, sae_pwe);
25262533
status->mfp = get_mfp(bss->ieee80211w);
25272534
status->channel = conf->channel;
25282535
os_memcpy(status->ssid, ssid->ssid, ssid->ssid_len);

0 commit comments

Comments
 (0)