Re: [PATCH] gsupplicant: Detect p2p support based on capability modes

2014-08-05 Thread Tomasz Bursztyka

ACK from me

Thanks Eduardo

Tomasz
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] gsupplicant: Detect p2p support based on capability modes

2014-08-05 Thread Patrik Flykt
On Tue, 2014-08-05 at 00:20 -0400, Eduardo Abinader wrote:
 The use of p2p_stop_find to detect p2p support
 is not a trusted approach, due to p2p_stop_find currently
 implemented in wpa_supplicant does not check p2p
 availability, as p2p_find does, for instance. Therefore,
 capabilitiy modes property, retrieved on interface added
 signal, is a proper way to define if a wifi device has
 p2p support.

Applied, thanks!

Patrik

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] gsupplicant: Detect p2p support based on capability modes

2014-08-04 Thread Eduardo Abinader
The use of p2p_stop_find to detect p2p support
is not a trusted approach, due to p2p_stop_find currently
implemented in wpa_supplicant does not check p2p
availability, as p2p_find does, for instance. Therefore,
capabilitiy modes property, retrieved on interface added
signal, is a proper way to define if a wifi device has
p2p support.
---
 gsupplicant/gsupplicant.h |  1 +
 gsupplicant/supplicant.c  | 35 +++
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 387a3aa..344459b 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -49,6 +49,7 @@ extern C {
 #define G_SUPPLICANT_CAPABILITY_MODE_INFRA (1  0)
 #define G_SUPPLICANT_CAPABILITY_MODE_IBSS  (1  1)
 #define G_SUPPLICANT_CAPABILITY_MODE_AP(1  2)
+#define G_SUPPLICANT_CAPABILITY_MODE_P2P   (1  3)
 
 #define G_SUPPLICANT_KEYMGMT_NONE  (1  0)
 #define G_SUPPLICANT_KEYMGMT_IEEE8021X (1  1)
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 1886a40..6337650 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -131,6 +131,7 @@ static struct strvalmap mode_capa_map[] = {
{ infrastructure, G_SUPPLICANT_CAPABILITY_MODE_INFRA  },
{ ad-hoc, G_SUPPLICANT_CAPABILITY_MODE_IBSS   },
{ ap, G_SUPPLICANT_CAPABILITY_MODE_AP },
+   { p2p,G_SUPPLICANT_CAPABILITY_MODE_P2P},
{ }
 };
 
@@ -2039,25 +2040,6 @@ static GSupplicantInterface *interface_alloc(const char 
*path)
return interface;
 }
 
-static void interface_p2p_stop_find(const char *error,
-   DBusMessageIter *iter, void *user_data)
-{
-   GSupplicantInterface *interface = user_data;
-
-   if (error) {
-   if (!g_strcmp0(error,
-   org.freedesktop.DBus.Error.UnknownMethod)) {
-   SUPPLICANT_DBG(wpa_supplicant does not support P2P);
-   } else {
-   SUPPLICANT_DBG(interface %s does not support P2P,
-   interface-ifname);
-   }
-   } else
-   interface-p2p_support = true;
-
-   callback_p2p_support(interface);
-}
-
 static void interface_added(DBusMessageIter *iter, void *user_data)
 {
GSupplicantInterface *interface;
@@ -2080,22 +2062,27 @@ static void interface_added(DBusMessageIter *iter, void 
*user_data)
if (!interface)
return;
 
-   supplicant_dbus_method_call(path,
-   SUPPLICANT_INTERFACE .Interface.P2PDevice, StopFind,
-   NULL, interface_p2p_stop_find, interface, interface);
-
dbus_message_iter_next(iter);
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) {
supplicant_dbus_property_foreach(iter, interface_property,
interface);
interface_property(NULL, NULL, interface);
-   return;
+   goto p2p_detection;
}
 
supplicant_dbus_property_get_all(path,
SUPPLICANT_INTERFACE .Interface,
interface_property, interface,
interface);
+
+p2p_detection:
+
+   if (interface-mode_capa  G_SUPPLICANT_CAPABILITY_MODE_P2P) {
+   interface-p2p_support = true;
+   callback_p2p_support(interface);
+   }
+
+   return;
 }
 
 static void interface_removed(DBusMessageIter *iter, void *user_data)
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman