]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make EAPOL dump data available through ctrl_iface STA command
authorJouni Malinen <j@w1.fi>
Thu, 2 Jan 2014 15:49:48 +0000 (17:49 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 2 Jan 2014 15:49:48 +0000 (17:49 +0200)
The per-STA/Supplicant state information from the EAPOL authenticator
is now available through "STA <MAC Address> eapol" command.

Signed-hostap: Jouni Malinen <j@w1.fi>

hostapd/hostapd_cli.c
src/ap/ctrl_iface_ap.c

index 7a0ef0a06eaf16bd96dfd16c0d384d2977590058..2706412396bc5b0b35bfc1397256bc21f18c48aa 100644 (file)
@@ -281,12 +281,15 @@ static void hostapd_cli_action_process(char *msg, size_t len)
 static int hostapd_cli_cmd_sta(struct wpa_ctrl *ctrl, int argc, char *argv[])
 {
        char buf[64];
-       if (argc != 1) {
-               printf("Invalid 'sta' command - exactly one argument, STA "
+       if (argc < 1) {
+               printf("Invalid 'sta' command - at least one argument, STA "
                       "address, is required.\n");
                return -1;
        }
-       snprintf(buf, sizeof(buf), "STA %s", argv[0]);
+       if (argc > 1)
+               snprintf(buf, sizeof(buf), "STA %s %s", argv[0], argv[1]);
+       else
+               snprintf(buf, sizeof(buf), "STA %s", argv[0]);
        return wpa_ctrl_command(ctrl, buf);
 }
 
index 5ecafe396a348e31ba8147355e773373c01bd796..3fb9e04bbf7499a102734438f68ac249ca4ab4ea 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "utils/common.h"
 #include "common/ieee802_11_defs.h"
+#include "eapol_auth/eapol_auth_sm.h"
 #include "hostapd.h"
 #include "ieee802_1x.h"
 #include "wpa_auth.h"
@@ -85,13 +86,6 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
 {
        int len, res, ret, i;
 
-       if (sta == NULL) {
-               ret = os_snprintf(buf, buflen, "FAIL\n");
-               if (ret < 0 || (size_t) ret >= buflen)
-                       return 0;
-               return ret;
-       }
-
        len = 0;
        ret = os_snprintf(buf + len, buflen - len, MACSTR "\nflags=",
                          MAC2STR(sta->addr));
@@ -162,6 +156,8 @@ int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr,
 {
        u8 addr[ETH_ALEN];
        int ret;
+       const char *pos;
+       struct sta_info *sta;
 
        if (hwaddr_aton(txtaddr, addr)) {
                ret = os_snprintf(buf, buflen, "FAIL\n");
@@ -169,8 +165,28 @@ int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr,
                        return 0;
                return ret;
        }
-       return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr),
-                                         buf, buflen);
+
+       sta = ap_get_sta(hapd, addr);
+       if (sta == NULL)
+               return -1;
+
+       pos = os_strchr(txtaddr, ' ');
+       if (pos) {
+               pos++;
+
+#ifdef HOSTAPD_DUMP_STATE
+               if (os_strcmp(pos, "eapol") == 0) {
+                       if (sta->eapol_sm == NULL)
+                               return -1;
+                       return eapol_auth_dump_state(sta->eapol_sm, buf,
+                                                    buflen);
+               }
+#endif /* HOSTAPD_DUMP_STATE */
+
+               return -1;
+       }
+
+       return hostapd_ctrl_iface_sta_mib(hapd, sta, buf, buflen);
 }