diff mbox

[v3] mesh: Display sae_group to result of status command

Message ID 1417659534-6759-1-git-send-email-masashi.honma@gmail.com
State Superseded
Headers show

Commit Message

Masashi Honma Dec. 4, 2014, 2:18 a.m. UTC
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 wpa_supplicant/ap.c         | 31 +++++++++++++++++++++++++++++++
 wpa_supplicant/ap.h         |  2 ++
 wpa_supplicant/ctrl_iface.c | 11 ++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)

Comments

Jouni Malinen Dec. 14, 2014, 6:12 p.m. UTC | #1
On Thu, Dec 04, 2014 at 11:18:54AM +0900, Masashi Honma wrote:
> +int ap_ctrl_iface_wpa_get_sae_status(struct wpa_supplicant *wpa_s, char *buf,
> +				     size_t buflen, int verbose)

> +	sta = hapd->sta_list;
> +
> +	while (sta) {
> +		if (sta->sae != NULL && 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;
> +	}

This would print out the sae_group that the first STA entry in
SAE_ACCEPTED state happened to use. That may not match what other STAs
used.
 
I'm not sure it really makes much sense to try to have a single
sae_group entry in the STATUS output for mesh, just like there is not
much point in trying to do that in AP mode. And if a single value is
needed, that should really come from the local configuration and not the
peer entry.

If the negotiated SAE group needs to be exposed through control
interface for mesh cases, this should be done through some per-STA
means. I think I'll extend mesh to support the existing STA control
interface command since that is a trivial change and can provide other
additional benefits as well (like TX/RX packets/bytes statistics).
Masashi Honma Dec. 16, 2014, 3:59 a.m. UTC | #2
On 2014年12月15日 03:12, Jouni Malinen wrote:
> This would print out the sae_group that the first STA entry in
> SAE_ACCEPTED state happened to use. That may not match what other STAs
> used.
>   
> I'm not sure it really makes much sense to try to have a single
> sae_group entry in the STATUS output for mesh, just like there is not
> much point in trying to do that in AP mode. And if a single value is
> needed, that should really come from the local configuration and not the
> peer entry.
Yes.
I had misunderstood that all STA has same Finite Cyclic Group.
>
> If the negotiated SAE group needs to be exposed through control
> interface for mesh cases, this should be done through some per-STA
> means. I think I'll extend mesh to support the existing STA control
> interface command since that is a trivial change and can provide other
> additional benefits as well (like TX/RX packets/bytes statistics).
>
Thank you.
diff mbox

Patch

diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index f3acbc1..dd4ff57 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -1064,6 +1064,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 != NULL && 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 961a79a..bb174aa 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -1701,12 +1701,21 @@  static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
 		if (ret < 0 || ret >= end - pos)
 			return pos - buf;
 		pos += ret;
-	}
+	} else {
+		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 == 0) {
 #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 &&