Add AP mode WPA status into ctrl_iface
This commit is contained in:
parent
f730b421e9
commit
43fb529750
6 changed files with 109 additions and 61 deletions
|
@ -602,3 +602,70 @@ void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
|
|||
hmac_sha1_vector(pmk, pmk_len, 3, addr, len, hash);
|
||||
os_memcpy(pmkid, hash, PMKID_LEN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpa_cipher_txt - Convert cipher suite to a text string
|
||||
* @cipher: Cipher suite (WPA_CIPHER_* enum)
|
||||
* Returns: Pointer to a text string of the cipher suite name
|
||||
*/
|
||||
const char * wpa_cipher_txt(int cipher)
|
||||
{
|
||||
switch (cipher) {
|
||||
case WPA_CIPHER_NONE:
|
||||
return "NONE";
|
||||
case WPA_CIPHER_WEP40:
|
||||
return "WEP-40";
|
||||
case WPA_CIPHER_WEP104:
|
||||
return "WEP-104";
|
||||
case WPA_CIPHER_TKIP:
|
||||
return "TKIP";
|
||||
case WPA_CIPHER_CCMP:
|
||||
return "CCMP";
|
||||
case WPA_CIPHER_CCMP | WPA_CIPHER_TKIP:
|
||||
return "CCMP+TKIP";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpa_key_mgmt_txt - Convert key management suite to a text string
|
||||
* @key_mgmt: Key management suite (WPA_KEY_MGMT_* enum)
|
||||
* @proto: WPA/WPA2 version (WPA_PROTO_*)
|
||||
* Returns: Pointer to a text string of the key management suite name
|
||||
*/
|
||||
const char * wpa_key_mgmt_txt(int key_mgmt, int proto)
|
||||
{
|
||||
switch (key_mgmt) {
|
||||
case WPA_KEY_MGMT_IEEE8021X:
|
||||
if (proto == (WPA_PROTO_RSN | WPA_PROTO_WPA))
|
||||
return "WPA2+WPA/IEEE 802.1X/EAP";
|
||||
return proto == WPA_PROTO_RSN ?
|
||||
"WPA2/IEEE 802.1X/EAP" : "WPA/IEEE 802.1X/EAP";
|
||||
case WPA_KEY_MGMT_PSK:
|
||||
if (proto == (WPA_PROTO_RSN | WPA_PROTO_WPA))
|
||||
return "WPA2-PSK+WPA-PSK";
|
||||
return proto == WPA_PROTO_RSN ?
|
||||
"WPA2-PSK" : "WPA-PSK";
|
||||
case WPA_KEY_MGMT_NONE:
|
||||
return "NONE";
|
||||
case WPA_KEY_MGMT_IEEE8021X_NO_WPA:
|
||||
return "IEEE 802.1X (no WPA)";
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
case WPA_KEY_MGMT_FT_IEEE8021X:
|
||||
return "FT-EAP";
|
||||
case WPA_KEY_MGMT_FT_PSK:
|
||||
return "FT-PSK";
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
case WPA_KEY_MGMT_IEEE8021X_SHA256:
|
||||
return "WPA2-EAP-SHA256";
|
||||
case WPA_KEY_MGMT_PSK_SHA256:
|
||||
return "WPA2-PSK-SHA256";
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,4 +341,7 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
|
|||
void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
|
||||
u8 *pmkid, int use_sha256);
|
||||
|
||||
const char * wpa_cipher_txt(int cipher);
|
||||
const char * wpa_key_mgmt_txt(int key_mgmt, int proto);
|
||||
|
||||
#endif /* WPA_COMMON_H */
|
||||
|
|
|
@ -28,67 +28,6 @@
|
|||
#include "ieee802_11_defs.h"
|
||||
|
||||
|
||||
/**
|
||||
* wpa_cipher_txt - Convert cipher suite to a text string
|
||||
* @cipher: Cipher suite (WPA_CIPHER_* enum)
|
||||
* Returns: Pointer to a text string of the cipher suite name
|
||||
*/
|
||||
static const char * wpa_cipher_txt(int cipher)
|
||||
{
|
||||
switch (cipher) {
|
||||
case WPA_CIPHER_NONE:
|
||||
return "NONE";
|
||||
case WPA_CIPHER_WEP40:
|
||||
return "WEP-40";
|
||||
case WPA_CIPHER_WEP104:
|
||||
return "WEP-104";
|
||||
case WPA_CIPHER_TKIP:
|
||||
return "TKIP";
|
||||
case WPA_CIPHER_CCMP:
|
||||
return "CCMP";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpa_key_mgmt_txt - Convert key management suite to a text string
|
||||
* @key_mgmt: Key management suite (WPA_KEY_MGMT_* enum)
|
||||
* @proto: WPA/WPA2 version (WPA_PROTO_*)
|
||||
* Returns: Pointer to a text string of the key management suite name
|
||||
*/
|
||||
static const char * wpa_key_mgmt_txt(int key_mgmt, int proto)
|
||||
{
|
||||
switch (key_mgmt) {
|
||||
case WPA_KEY_MGMT_IEEE8021X:
|
||||
return proto == WPA_PROTO_RSN ?
|
||||
"WPA2/IEEE 802.1X/EAP" : "WPA/IEEE 802.1X/EAP";
|
||||
case WPA_KEY_MGMT_PSK:
|
||||
return proto == WPA_PROTO_RSN ?
|
||||
"WPA2-PSK" : "WPA-PSK";
|
||||
case WPA_KEY_MGMT_NONE:
|
||||
return "NONE";
|
||||
case WPA_KEY_MGMT_IEEE8021X_NO_WPA:
|
||||
return "IEEE 802.1X (no WPA)";
|
||||
#ifdef CONFIG_IEEE80211R
|
||||
case WPA_KEY_MGMT_FT_IEEE8021X:
|
||||
return "FT-EAP";
|
||||
case WPA_KEY_MGMT_FT_PSK:
|
||||
return "FT-PSK";
|
||||
#endif /* CONFIG_IEEE80211R */
|
||||
#ifdef CONFIG_IEEE80211W
|
||||
case WPA_KEY_MGMT_IEEE8021X_SHA256:
|
||||
return "WPA2-EAP-SHA256";
|
||||
case WPA_KEY_MGMT_PSK_SHA256:
|
||||
return "WPA2-PSK-SHA256";
|
||||
#endif /* CONFIG_IEEE80211W */
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wpa_eapol_key_send - Send WPA/RSN EAPOL-Key message
|
||||
* @sm: Pointer to WPA state machine data from wpa_sm_init()
|
||||
|
|
|
@ -473,6 +473,7 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
|
|||
}
|
||||
|
||||
wpa_s->current_ssid = ssid;
|
||||
os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN);
|
||||
wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
|
||||
|
||||
return 0;
|
||||
|
@ -587,4 +588,33 @@ int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr,
|
|||
buf, buflen);
|
||||
}
|
||||
|
||||
|
||||
int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
|
||||
size_t buflen, int verbose)
|
||||
{
|
||||
char *pos = buf, *end = buf + buflen;
|
||||
int ret;
|
||||
struct hostapd_bss_config *conf;
|
||||
|
||||
if (wpa_s->ap_iface == NULL)
|
||||
return -1;
|
||||
|
||||
conf = wpa_s->ap_iface->bss[0]->conf;
|
||||
if (conf->wpa == 0)
|
||||
return 0;
|
||||
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"pairwise_cipher=%s\n"
|
||||
"group_cipher=%s\n"
|
||||
"key_mgmt=%s\n",
|
||||
wpa_cipher_txt(conf->rsn_pairwise),
|
||||
wpa_cipher_txt(conf->wpa_group),
|
||||
wpa_key_mgmt_txt(conf->wpa_key_mgmt,
|
||||
conf->wpa));
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
return pos - buf;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_CTRL_IFACE */
|
||||
|
|
|
@ -30,5 +30,7 @@ int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr,
|
|||
char *buf, size_t buflen);
|
||||
int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr,
|
||||
char *buf, size_t buflen);
|
||||
int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
|
||||
size_t buflen, int verbose);
|
||||
|
||||
#endif /* AP_H */
|
||||
|
|
|
@ -448,6 +448,13 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_AP
|
||||
if (wpa_s->ap_iface) {
|
||||
pos += ap_ctrl_iface_wpa_get_status(wpa_s, pos,
|
||||
end - pos,
|
||||
verbose);
|
||||
} else
|
||||
#endif /* CONFIG_AP */
|
||||
pos += wpa_sm_get_status(wpa_s->wpa, pos, end - pos, verbose);
|
||||
}
|
||||
ret = os_snprintf(pos, end - pos, "wpa_state=%s\n",
|
||||
|
|
Loading…
Reference in a new issue