developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From e415e499c9ea0939f0c286c5c0422acbc3491756 Mon Sep 17 00:00:00 2001 |
| 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Tue, 20 Sep 2022 19:33:45 +0800 |
| 4 | Subject: [PATCH 013/126] mtk: hostapd: print some sae info by hostapd ctrl |
| 5 | |
| 6 | root@OpenWrt:~# hostapd_cli -i phy0-ap0 pmksa |
| 7 | Setup at link 0: |
| 8 | Index / SPA / PMKID / PMK / expiration (in seconds) / opportunistic |
| 9 | Setup at link 1: |
| 10 | Index / SPA / PMKID / PMK / expiration (in seconds) / opportunistic |
| 11 | 0 02:0c:43:b2:01:1c b5706f5f53117e00fa46fcf94c225009 7505eb11319fa94add14d0fd091caadf9be2c642aa7363a96e1efa575e794420 43180 0 |
| 12 | Setup at link 2: |
| 13 | Index / SPA / PMKID / PMK / expiration (in seconds) / opportunistic |
| 14 | |
| 15 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 16 | --- |
| 17 | hostapd/ctrl_iface.c | 14 ++++++++++++++ |
| 18 | src/ap/ctrl_iface_ap.c | 22 +++++++++++++++++++++- |
| 19 | src/ap/pmksa_cache_auth.c | 5 ++++- |
| 20 | 3 files changed, 39 insertions(+), 2 deletions(-) |
| 21 | |
| 22 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 23 | index f2733687c..2d90d77c6 100644 |
| 24 | --- a/hostapd/ctrl_iface.c |
| 25 | +++ b/hostapd/ctrl_iface.c |
| 26 | @@ -70,6 +70,7 @@ |
| 27 | #include "fst/fst_ctrl_iface.h" |
| 28 | #include "config_file.h" |
| 29 | #include "ctrl_iface.h" |
| 30 | +#include "crypto/dh_groups.h" |
| 31 | |
| 32 | |
| 33 | #define HOSTAPD_CLI_DUP_VALUE_MAX_LEN 256 |
| 34 | @@ -1376,6 +1377,19 @@ static int hostapd_ctrl_iface_get(struct hostapd_data *hapd, char *cmd, |
| 35 | if (os_snprintf_error(buflen, res)) |
| 36 | return -1; |
| 37 | return res; |
| 38 | + } else if (os_strcmp(cmd, "sae_group_capability") == 0) { |
| 39 | +#ifdef CONFIG_SAE |
| 40 | + /* see sae_set_group() */ |
| 41 | + res = os_snprintf(buf, buflen, "%s%s%s%s19 20 21", |
| 42 | + dh_groups_get(15) ? "15 ": "", |
| 43 | + dh_groups_get(16) ? "16 ": "", |
| 44 | + dh_groups_get(17) ? "17 ": "", |
| 45 | + dh_groups_get(18) ? "18 ": ""); |
| 46 | + |
| 47 | + if (os_snprintf_error(buflen, res)) |
| 48 | + return -1; |
| 49 | + return res; |
| 50 | +#endif /* CONFIG_SAE */ |
| 51 | } |
| 52 | |
| 53 | return -1; |
| 54 | diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c |
| 55 | index 50f993253..4d3c7e529 100644 |
| 56 | --- a/src/ap/ctrl_iface_ap.c |
| 57 | +++ b/src/ap/ctrl_iface_ap.c |
| 58 | @@ -1157,7 +1157,27 @@ int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd) |
| 59 | int hostapd_ctrl_iface_pmksa_list(struct hostapd_data *hapd, char *buf, |
| 60 | size_t len) |
| 61 | { |
| 62 | - return wpa_auth_pmksa_list(hapd->wpa_auth, buf, len); |
| 63 | + char *pos = buf; |
| 64 | + int ret, link_id; |
| 65 | + |
| 66 | + if (!hapd->conf->mld_ap) |
| 67 | + return wpa_auth_pmksa_list(hapd->wpa_auth, buf, len); |
| 68 | + |
| 69 | + for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) { |
| 70 | + struct hostapd_data *h = hostapd_mld_get_link_bss(hapd, link_id); |
| 71 | + |
| 72 | + if (!h) |
| 73 | + continue; |
| 74 | + |
| 75 | + ret = os_snprintf(pos, len - (pos - buf), "Setup at link %u:\n", h->mld_link_id); |
| 76 | + if (os_snprintf_error(len - (pos - buf), ret)) |
| 77 | + return pos - buf; |
| 78 | + pos += ret; |
| 79 | + |
| 80 | + pos += wpa_auth_pmksa_list(h->wpa_auth, pos, len - (pos - buf)); |
| 81 | + } |
| 82 | + |
| 83 | + return pos - buf; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | diff --git a/src/ap/pmksa_cache_auth.c b/src/ap/pmksa_cache_auth.c |
| 88 | index 2fce8383d..8a63cb682 100644 |
| 89 | --- a/src/ap/pmksa_cache_auth.c |
| 90 | +++ b/src/ap/pmksa_cache_auth.c |
| 91 | @@ -658,7 +658,7 @@ int pmksa_cache_auth_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len) |
| 92 | |
| 93 | os_get_reltime(&now); |
| 94 | ret = os_snprintf(pos, buf + len - pos, |
| 95 | - "Index / SPA / PMKID / expiration (in seconds) / opportunistic\n"); |
| 96 | + "Index / SPA / PMKID / PMK / expiration (in seconds) / opportunistic\n"); |
| 97 | if (os_snprintf_error(buf + len - pos, ret)) |
| 98 | return pos - buf; |
| 99 | pos += ret; |
| 100 | @@ -672,6 +672,9 @@ int pmksa_cache_auth_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len) |
| 101 | pos += ret; |
| 102 | pos += wpa_snprintf_hex(pos, buf + len - pos, entry->pmkid, |
| 103 | PMKID_LEN); |
| 104 | + *pos++ = ' '; |
| 105 | + pos += wpa_snprintf_hex(pos, buf + len - pos, entry->pmk, |
| 106 | + entry->pmk_len); |
| 107 | ret = os_snprintf(pos, buf + len - pos, " %d %d\n", |
| 108 | (int) (entry->expiration - now.sec), |
| 109 | entry->opportunistic); |
| 110 | -- |
| 111 | 2.18.0 |
| 112 | |