[PATCH v2 09/10] mesh: Display sae_group to result of status command

Masashi Honma masashi.honma
Fri Nov 14 17:35:31 PST 2014


Existing code does not display sae_group.

Signed-off-by: Masashi Honma <masashi.honma at gmail.com>
---
 wpa_supplicant/ap.c         | 31 +++++++++++++++++++++++++++++++
 wpa_supplicant/ap.h         |  2 ++
 wpa_supplicant/ctrl_iface.c | 18 +++++++-----------
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index a39399e..908062f 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -1063,6 +1063,37 @@ int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
 	return pos - buf;
 }
 
+
+#ifdef CONFIG_SAE
+int ap_ctrl_iface_wpa_get_sae_status(struct wpa_supplicant *wpa_s, char *buf,
+				     size_t buflen, int verbose)
+{
+	char *pos = buf, *end = buf + buflen;
+	int ret;
+	struct hostapd_data *hapd;
+	struct sta_info *sta;
+
+	if (wpa_s->ifmsh == NULL)
+		return 0;
+
+	hapd = wpa_s->ifmsh->bss[0];
+	sta = hapd->sta_list;
+
+	while (sta) {
+		if (sta->sae->state == SAE_ACCEPTED) {
+			ret = os_snprintf(pos, end - pos, "sae_group=%d\n",
+					  sta->sae->group);
+			if (ret < 0 || ret >= end - pos)
+				return pos - buf;
+			pos += ret;
+			break;
+		}
+		sta = sta->next;
+	}
+	return pos - buf;
+}
+#endif /* CONFIG_SAE */
+
 #endif /* CONFIG_CTRL_IFACE */
 
 
diff --git a/wpa_supplicant/ap.h b/wpa_supplicant/ap.h
index 4d80c7a..554ff54 100644
--- a/wpa_supplicant/ap.h
+++ b/wpa_supplicant/ap.h
@@ -38,6 +38,8 @@ int ap_ctrl_iface_sta_disassociate(struct wpa_supplicant *wpa_s,
 				   const char *txtaddr);
 int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
 				 size_t buflen, int verbose);
+int ap_ctrl_iface_wpa_get_sae_status(struct wpa_supplicant *wpa_s, char *buf,
+				     size_t buflen, int verbose);
 void ap_tx_status(void *ctx, const u8 *addr,
 		  const u8 *buf, size_t len, int ack);
 void ap_eapol_tx_status(void *ctx, const u8 *dst,
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index a1b5328..d0a71a5 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -1641,22 +1641,18 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
 		pos += wpa_sm_get_status(wpa_s->wpa, pos, end - pos, verbose);
 	}
 #ifdef CONFIG_SAE
-	if (wpa_s->wpa_state >= WPA_ASSOCIATED &&
-#ifdef CONFIG_AP
-	    !wpa_s->ap_iface &&
-#endif /* CONFIG_AP */
-	    wpa_s->sme.sae.state == SAE_ACCEPTED) {
-		ret = os_snprintf(pos, end - pos, "sae_group=%d\n",
-				  wpa_s->sme.sae.group);
-		if (ret < 0 || ret >= end - pos)
-			return pos - buf;
-		pos += ret;
-	}
+	ret = ap_ctrl_iface_wpa_get_sae_status(wpa_s, pos, end - pos, verbose);
+	if (ret < 0 || ret >= end - pos)
+		return pos - buf;
+	if (ret < 1) {
 #endif /* CONFIG_SAE */
 	ret = os_snprintf(pos, end - pos, "wpa_state=%s\n",
 			  wpa_supplicant_state_txt(wpa_s->wpa_state));
 	if (ret < 0 || ret >= end - pos)
 		return pos - buf;
+#ifdef CONFIG_SAE
+	}
+#endif /* CONFIG_SAE */
 	pos += ret;
 
 	if (wpa_s->l2 &&
-- 
1.9.1




More information about the Hostap mailing list