Patchwork TDLS: Add get_capability tdls command

login
register
mail settings
Submitter Dmitry Shmidt
Date March 13, 2014, 9:03 p.m.
Message ID <20140313210628.14E4F13F8B1@ushik.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/330123/
State Rejected
Headers show

Comments

Dmitry Shmidt - March 13, 2014, 9:03 p.m.
Command returns info in format:
  TDLS supported = YES / NO
  Driver uses INTERNAL / EXTERNAL link setup

Change-Id: I1c82e6bb4939c137dd3024531073af3ef2c9b862
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
---
 src/rsn_supp/tdls.c         |  6 ++++++
 src/rsn_supp/wpa.h          |  1 +
 wpa_supplicant/ctrl_iface.c | 21 +++++++++++++++++++++
 3 files changed, 28 insertions(+)
Jouni Malinen - March 13, 2014, 9:53 p.m.
On Thu, Mar 13, 2014 at 02:03:28PM -0700, Dmitry Shmidt wrote:
> Command returns info in format:
>   TDLS supported = YES / NO
>   Driver uses INTERNAL / EXTERNAL link setup

This looks pretty verbose and harder than necessary format to parse..
Why not simply return UNSUPPORTED/INTERNAL/EXTERNAL? In addition, this
information is available from wpa_s->drv_flags
(WPA_DRIVER_FLAGS_TDLS_SUPPORT and WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP
bits), so there is no need to add the new wpa_tdls_is_supported()
wrapper function (the core wpa_supplicant code sets that
sm->tdls_supported based on drv_flags anyway).
Dmitry Shmidt - March 13, 2014, 10:14 p.m.
On Thu, Mar 13, 2014 at 2:53 PM, Jouni Malinen <j@w1.fi> wrote:
> On Thu, Mar 13, 2014 at 02:03:28PM -0700, Dmitry Shmidt wrote:
>> Command returns info in format:
>>   TDLS supported = YES / NO
>>   Driver uses INTERNAL / EXTERNAL link setup
>
> This looks pretty verbose and harder than necessary format to parse..
> Why not simply return UNSUPPORTED/INTERNAL/EXTERNAL? In addition, this
> information is available from wpa_s->drv_flags
> (WPA_DRIVER_FLAGS_TDLS_SUPPORT and WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP
> bits), so there is no need to add the new wpa_tdls_is_supported()
> wrapper function (the core wpa_supplicant code sets that
> sm->tdls_supported based on drv_flags anyway).

Changed. Thanks!

>
> --
> Jouni Malinen                                            PGP id EFC895FA

Patch

diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c
index 8a978f7..3146b37 100644
--- a/src/rsn_supp/tdls.c
+++ b/src/rsn_supp/tdls.c
@@ -2632,6 +2632,12 @@  void wpa_tdls_enable(struct wpa_sm *sm, int enabled)
 }
 
 
+int wpa_tdls_is_supported(struct wpa_sm *sm)
+{
+	return sm->tdls_supported;
+}
+
+
 int wpa_tdls_is_external_setup(struct wpa_sm *sm)
 {
 	return sm->tdls_external_setup;
diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h
index 20b3f62..0b05cdf 100644
--- a/src/rsn_supp/wpa.h
+++ b/src/rsn_supp/wpa.h
@@ -395,6 +395,7 @@  void wpa_tdls_deinit(struct wpa_sm *sm);
 void wpa_tdls_enable(struct wpa_sm *sm, int enabled);
 void wpa_tdls_disable_link(struct wpa_sm *sm, const u8 *addr);
 const char * wpa_tdls_get_link_status(struct wpa_sm *sm, const u8 *addr);
+int wpa_tdls_is_supported(struct wpa_sm *sm);
 int wpa_tdls_is_external_setup(struct wpa_sm *sm);
 
 int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf);
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 98c4b65..f054f12 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -538,6 +538,22 @@  static int wpa_supplicant_ctrl_iface_tdls_teardown(
 	return ret;
 }
 
+
+static int ctrl_iface_get_capability_tdls(
+	struct wpa_supplicant *wpa_s, char *buf, size_t buflen)
+{
+	int ret;
+
+	ret = os_snprintf(buf, buflen, "TDLS supported = %s\n"
+			  "Driver uses %s link setup\n",
+			  wpa_tdls_is_supported(wpa_s->wpa) ? "YES" : "NO",
+			  wpa_tdls_is_external_setup(wpa_s->wpa) ? "EXTERNAL" :
+								   "INTERNAL");
+	if (ret < 0 || (size_t) ret > buflen)
+		return -1;
+	return ret;
+}
+
 #endif /* CONFIG_TDLS */
 
 
@@ -3180,6 +3196,11 @@  static int wpa_supplicant_ctrl_iface_get_capability(
 	if (os_strcmp(field, "freq") == 0)
 		return ctrl_iface_get_capability_freq(wpa_s, buf, buflen);
 
+#ifdef CONFIG_TDLS
+	if (os_strcmp(field, "tdls") == 0)
+		return ctrl_iface_get_capability_tdls(wpa_s, buf, buflen);
+#endif
+
 	wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown GET_CAPABILITY field '%s'",
 		   field);