From b76f4c27638fe7b57a931c7e8b63386aebc536fb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 27 Dec 2013 19:24:24 +0200 Subject: [PATCH] hostapd: Make STA flags available through ctrl_iface STA command Signed-hostap: Jouni Malinen --- hostapd/dump_state.c | 26 +++++--------------------- src/ap/ctrl_iface_ap.c | 12 +++++++++++- src/ap/sta_info.c | 30 ++++++++++++++++++++++++++++++ src/ap/sta_info.h | 2 ++ 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/hostapd/dump_state.c b/hostapd/dump_state.c index 3c639f945..090343800 100644 --- a/hostapd/dump_state.c +++ b/hostapd/dump_state.c @@ -100,33 +100,17 @@ static void hostapd_dump_state(struct hostapd_data *hapd) hapd->iface->num_sta_no_short_preamble); for (sta = hapd->sta_list; sta != NULL; sta = sta->next) { + char flags[200]; + fprintf(f, "\nSTA=" MACSTR "\n", MAC2STR(sta->addr)); + ap_sta_flags_txt(sta->flags, flags, sizeof(flags)); fprintf(f, - " AID=%d flags=0x%x %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" - "\n" + " AID=%d flags=0x%x %s\n" " capability=0x%x listen_interval=%d\n", sta->aid, sta->flags, - (sta->flags & WLAN_STA_AUTH ? "[AUTH]" : ""), - (sta->flags & WLAN_STA_ASSOC ? "[ASSOC]" : ""), - (ap_sta_is_authorized(sta) ? "[AUTHORIZED]" : ""), - (sta->flags & WLAN_STA_PENDING_POLL ? "[PENDING_POLL" : - ""), - (sta->flags & WLAN_STA_SHORT_PREAMBLE ? - "[SHORT_PREAMBLE]" : ""), - (sta->flags & WLAN_STA_PREAUTH ? "[PREAUTH]" : ""), - (sta->flags & WLAN_STA_WMM ? "[WMM]" : ""), - (sta->flags & WLAN_STA_MFP ? "[MFP]" : ""), - (sta->flags & WLAN_STA_WPS ? "[WPS]" : ""), - (sta->flags & WLAN_STA_MAYBE_WPS ? "[MAYBE_WPS]" : ""), - (sta->flags & WLAN_STA_WDS ? "[WDS]" : ""), - (sta->flags & WLAN_STA_NONERP ? "[NonERP]" : ""), - (sta->flags & WLAN_STA_WPS2 ? "[WPS2]" : ""), - (sta->flags & WLAN_STA_GAS ? "[GAS]" : ""), - (sta->flags & WLAN_STA_VHT ? "[VHT]" : ""), - (sta->flags & WLAN_STA_WNM_SLEEP_MODE ? - "[WNM_SLEEP_MODE]" : ""), + flags, sta->capability, sta->listen_interval); diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c index 4125fd56b..0d46ea08b 100644 --- a/src/ap/ctrl_iface_ap.c +++ b/src/ap/ctrl_iface_ap.c @@ -56,12 +56,22 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd, } len = 0; - ret = os_snprintf(buf + len, buflen - len, MACSTR "\n", + ret = os_snprintf(buf + len, buflen - len, MACSTR "\nflags=", MAC2STR(sta->addr)); if (ret < 0 || (size_t) ret >= buflen - len) return len; len += ret; + ret = ap_sta_flags_txt(sta->flags, buf + len, buflen - len); + if (ret < 0) + return len; + len += ret; + + ret = os_snprintf(buf + len, buflen - len, "\n"); + if (ret < 0 || (size_t) ret >= buflen - len) + return len; + len += ret; + res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len); if (res >= 0) len += res; diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index c4a0a8697..4592cc85f 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -1011,3 +1011,33 @@ void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta) eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta); ap_sta_disassoc_cb_timeout(hapd, sta); } + + +int ap_sta_flags_txt(u32 flags, char *buf, size_t buflen) +{ + int res; + + buf[0] = '\0'; + res = os_snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + (flags & WLAN_STA_AUTH ? "[AUTH]" : ""), + (flags & WLAN_STA_ASSOC ? "[ASSOC]" : ""), + (flags & WLAN_STA_AUTHORIZED ? "[AUTHORIZED]" : ""), + (flags & WLAN_STA_PENDING_POLL ? "[PENDING_POLL" : + ""), + (flags & WLAN_STA_SHORT_PREAMBLE ? + "[SHORT_PREAMBLE]" : ""), + (flags & WLAN_STA_PREAUTH ? "[PREAUTH]" : ""), + (flags & WLAN_STA_WMM ? "[WMM]" : ""), + (flags & WLAN_STA_MFP ? "[MFP]" : ""), + (flags & WLAN_STA_WPS ? "[WPS]" : ""), + (flags & WLAN_STA_MAYBE_WPS ? "[MAYBE_WPS]" : ""), + (flags & WLAN_STA_WDS ? "[WDS]" : ""), + (flags & WLAN_STA_NONERP ? "[NonERP]" : ""), + (flags & WLAN_STA_WPS2 ? "[WPS2]" : ""), + (flags & WLAN_STA_GAS ? "[GAS]" : ""), + (flags & WLAN_STA_VHT ? "[VHT]" : ""), + (flags & WLAN_STA_WNM_SLEEP_MODE ? + "[WNM_SLEEP_MODE]" : "")); + + return res; +} diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h index 925d35ffc..9b77e0609 100644 --- a/src/ap/sta_info.h +++ b/src/ap/sta_info.h @@ -193,4 +193,6 @@ static inline int ap_sta_is_authorized(struct sta_info *sta) void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta); void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta); +int ap_sta_flags_txt(u32 flags, char *buf, size_t buflen); + #endif /* STA_INFO_H */