Re: agent, route questions with 1.25

2014-09-05 Thread Patrik Flykt

Hi,

On Thu, 2014-09-04 at 15:07 -0400, Mike Purvis wrote:

 First, what's up with the change to make the agent only work in interactive
 mode? Having to do the whole agent/scan/connect dance inside the connmanctl
 prompt, and away from my bash history, is a pretty big pain.

When run in a script that has no terminal, the readline part of
connmanctl ended in a busy loop trying to calculate the terminal width.
Depending in which part of readline that problem was, it may be possible
to read the input from standard in. Unfortunately it did not look
trivial, so the input interaction was cancelled instead. It is also not
ensured that the next thing requested from the Agent really is a
passphrase, so trying to pipe a password to the interactive part of
connmanctl is not that reliable.

If the system does not expect a user to be present to type a passphrase,
doc/config-format.txt and /var/lib/connman/.config is the way to
go. If serious testing is needed, it is better to write a test program
in either C or e.g. python that contains the necessary test logic.

 Second, when I did get it connected, I had an issue where it left the
 default route on a class D ethernet port, rather than transferring it to
 the DHCP wifi. This seems very odd to me.

No idea with this one except that it shouldn't be doing such a thing in
the first place. If you can provide the steps and/or a log of how to
reproduce this, it would be fine.

 Finally, it doesn't seem able to reconnect automatically on system startup,
 the way 1.24 used to do. Has something changed about that behaviour, or
 something I need to do to enable it?

Works fine here. Did the network get configured or connect properly
before restarted?

Cheers,

Patrik

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


Re: agent, route questions with 1.25

2014-09-05 Thread Patrik Flykt

Hi,

On Thu, 2014-09-04 at 17:02 -0400, Mike Purvis wrote:
 - When I connect to my wifi, it no longer creates a directory for it under
 /var/lib/connman. Did this behaviour change? I'm assuming this is related
 to the not-reconnecting behaviour.

This means it did not get connected.

 - Running config wifi__managed_psk  --autoconnect yes tells me
 invalid service

The service wifi__managed_psk does not exist as connmanctl
cannot send a D-Bus method call to it. The cause is that the scan has
not been done recently enough and the WiFi network has therefore timed
out (in wpa_supplicant to be exact).

 - connmand is being executed by upstart. The invocation is connmand
 --nobacktrace.
 
 Is there a way for the daemon to tell me what its config is and where it
 came from? Would be really helpful for debugging to know if it's using the
 /var/lib/connman directory at all.

No. But if there expected directory is not in /var/lib/connman, it means
the network is not connected.

Cheers,

Patrik

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


[PATCH 1/2] manager: Recurse into a variant before getting its value

2014-09-05 Thread Tomasz Bursztyka
Fix an error on bonjour byte arrays where it does not open the variant
container.
---
 src/manager.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index 95b2be7..e97921b 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -390,14 +390,16 @@ static int parse_peers_service_specs(DBusMessageIter 
*array,
 
while (dbus_message_iter_get_arg_type(array) ==
DBUS_TYPE_DICT_ENTRY) {
-   DBusMessageIter entry, value;
+   DBusMessageIter entry, inter, value;
const char *key;
 
dbus_message_iter_recurse(array, entry);
dbus_message_iter_get_basic(entry, key);
 
dbus_message_iter_next(entry);
-   dbus_message_iter_recurse(entry, value);
+
+   dbus_message_iter_recurse(entry, inter);
+   dbus_message_iter_recurse(inter, value);
 
if  (!g_strcmp0(key, BonjourResponse)) {
dbus_message_iter_get_fixed_array(value,
-- 
1.8.5.5

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


[PATCH 0/2] Peer services bug fix

2014-09-05 Thread Tomasz Bursztyka
Found 2 obvious bugs in my previous patch-set. One on manger's API parameter
parsing and the other one about the logic on listening to p2p frames while
2+ services are registered.

Tomasz Bursztyka (2):
  manager: Recurse into a variant before getting its value
  wifi: Add the proper logic when to start/stop listening to P2P frames

 plugins/wifi.c | 18 +++---
 src/manager.c  |  6 --
 2 files changed, 19 insertions(+), 5 deletions(-)

-- 
1.8.5.5

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


[PATCH 2/2] wifi: Add the proper logic when to start/stop listening to P2P frames

2014-09-05 Thread Tomasz Bursztyka
This fixes an obvious bug when 2+ services are registered, wifi plugin
will blindly request the already listening interface to start listening
on a new registration. As well as it will immediatly stop the interface
forme listening at the very first unregistration.
Adding a service count inside the wifi plugin fixes it. I put this logic
in the wifi plugin since it should not be up to the core to know about
such information.
---
 plugins/wifi.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 0632ba0..f16c3fe 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -125,6 +125,7 @@ struct wifi_data {
struct connman_peer *pending_peer;
bool p2p_connecting;
bool p2p_device;
+   int servicing;
 };
 
 static GList *iface_list = NULL;
@@ -360,13 +361,20 @@ struct peer_service_registration {
 static void register_peer_service_cb(int result,
GSupplicantInterface *iface, void *user_data)
 {
+   struct wifi_data *wifi = g_supplicant_interface_get_data(iface);
struct peer_service_registration *reg_data = user_data;
 
DBG();
 
-   if (result == 0)
-   g_supplicant_interface_p2p_listen(iface, P2P_LISTEN_PERIOD,
+   if (result == 0) {
+   if (!wifi-servicing) {
+   g_supplicant_interface_p2p_listen(iface,
+   P2P_LISTEN_PERIOD,
P2P_LISTEN_INTERVAL);
+   }
+
+   wifi-servicing++;
+   }
 
if (reg_data-callback)
reg_data-callback(result, reg_data-user_data);
@@ -497,7 +505,11 @@ static int peer_unregister_service(const unsigned char 
*specification,
if (ret != 0  ret != -EINPROGRESS)
free_peer_service_params(params);
 
-   g_supplicant_interface_p2p_listen(iface, 0, 0);
+   wifi-servicing--;
+   if (!wifi-servicing || wifi-servicing  0) {
+   g_supplicant_interface_p2p_listen(iface, 0, 0);
+   wifi-servicing = 0;
+   }
}
 
return 0;
-- 
1.8.5.5

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


[PATCH] gsupplicant: Defer group request to peer property

2014-09-05 Thread Eduardo Abinader
There exists scenarios, when connman receives a group
request and the requesting peer hasn't been discovered
yet, wpa_supplicant issues a peer found just before
signaling group request. However, the just signaled peer
found have its properties published by wpa_s on a timeout
basis (dbus property), thus causing group request signal
to be lost, as the ident and other peer information
are not available until this timeout expires in wpa_supplicant.

That said, this patch defers the signaled group request to
be concluded after peer property has been properly filled
in, when, of course, the described scenario occurs.
---
 gsupplicant/supplicant.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index b796524..fd16caf 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -139,6 +139,7 @@ static GHashTable *interface_table;
 static GHashTable *bss_mapping;
 static GHashTable *peer_mapping;
 static GHashTable *group_mapping;
+static GHashTable *pending_peer_connection;
 
 struct _GSupplicantWpsCredentials {
unsigned char ssid[32];
@@ -599,6 +600,9 @@ static void remove_peer(gpointer data)
if (peer_mapping)
g_hash_table_remove(peer_mapping, peer-path);
 
+   if (pending_peer_connection)
+   g_hash_table_remove(pending_peer_connection, peer-path);
+
g_free(peer-path);
g_free(peer-name);
g_free(peer-identifier);
@@ -2575,6 +2579,7 @@ static void peer_groups_relation(DBusMessageIter *iter, 
void *user_data)
 static void peer_property(const char *key, DBusMessageIter *iter,
void *user_data)
 {
+   GSupplicantPeer *pending_peer;
GSupplicantPeer *peer = user_data;
 
SUPPLICANT_DBG(key: %s, key);
@@ -2586,6 +2591,14 @@ static void peer_property(const char *key, 
DBusMessageIter *iter,
if (peer-name) {
create_peer_identifier(peer);
callback_peer_found(peer);
+   pending_peer = g_hash_table_lookup(
+   pending_peer_connection, peer-path);
+
+   if (pending_peer  pending_peer == peer) {
+   callback_peer_request(peer);
+   g_hash_table_remove(pending_peer_connection,
+   peer-path);
+   }
}
 
return;
@@ -2929,7 +2942,15 @@ static void signal_group_request(const char *path, 
DBusMessageIter *iter)
if (!peer)
return;
 
-   callback_peer_request(peer);
+   /*
+* Peer has been previously found and property set,
+* otherwise, defer connection to when peer property
+* is set.
+*/
+   if (peer-identifier)
+   callback_peer_request(peer);
+   else
+   g_hash_table_replace(pending_peer_connection, peer-path, peer);
 }
 
 static void signal_group_peer_joined(const char *path, DBusMessageIter *iter)
@@ -5082,6 +5103,8 @@ int g_supplicant_register(const GSupplicantCallbacks 
*callbacks)
NULL, NULL);
group_mapping = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL);
+   pending_peer_connection = g_hash_table_new_full(g_str_hash, g_str_equal,
+   NULL, NULL);
 
supplicant_dbus_setup(connection);
 
-- 
1.9.1

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


Re: [PATCH 0/2] Peer services bug fix

2014-09-05 Thread Patrik Flykt
On Fri, 2014-09-05 at 14:41 +0300, Tomasz Bursztyka wrote:
 Found 2 obvious bugs in my previous patch-set. One on manger's API parameter
 parsing and the other one about the logic on listening to p2p frames while
 2+ services are registered.

Applied, thanks!

Patrik

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


Re: [PATCH] gsupplicant: Defer group request to peer property

2014-09-05 Thread Patrik Flykt
On Fri, 2014-09-05 at 07:45 -0400, Eduardo Abinader wrote:
 There exists scenarios, when connman receives a group
 request and the requesting peer hasn't been discovered
 yet, wpa_supplicant issues a peer found just before
 signaling group request. However, the just signaled peer
 found have its properties published by wpa_s on a timeout
 basis (dbus property), thus causing group request signal
 to be lost, as the ident and other peer information
 are not available until this timeout expires in wpa_supplicant.
 
 That said, this patch defers the signaled group request to
 be concluded after peer property has been properly filled
 in, when, of course, the described scenario occurs.

Applied, thanks!

Patrik

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


Re: [PATCH pacrunner] client: Detach threads since they are never joined

2014-09-05 Thread Patrik Flykt
On Wed, 2014-09-03 at 11:31 +0300, Slava Monich wrote:
 By default, a new thread is created in a joinable state.

Applied with the following commit message:

Unless the threads are created as detached (or joined, which is not the
case here), not all resources will be released when the thread exits.
If not handled, this causes unlimited memory usage over time.


Patrik


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


[RFC/PATCH 00/13] Support for WiFi Display as a Peer Service

2014-09-05 Thread Tomasz Bursztyka
Hi,

Here is an rfc patch-set to support WiFi Display as Peer Service.

This patch-set cannot work without this wpa_supplicant pending patch-set:
http://lists.shmoo.com/pipermail/hostap/2014-August/030783.html

As usual connmanctl comes with a dummy test command, which is now 
peer_service register wfd_ies the wfd ies

Since wfd is a global setting on wpa_s, it's not possible to register
more than 1 wfd service.

Tomasz Bursztyka (13):
  gsupplicant: Add a callback enabled setter for the WFD IEs
  manager: Support WiFiDisplayIEs as a new Peer Service to handle
  wifi: Support registering WiFi Display IEs when relevant
  client: Support basic WiFi Display IEs (un)registration
  gsupplicant: Refactor how Peer's groups is detected to have changed
  gsupplicant: Get Peer's WiFi Display information elements if present
  gsupplicant: Add a getter for the WiFi Display information elements
  gsupplicant: Rename the peer state enum for future changes
  gsupplicant: Add a Peer service changed dedicated state
  gsupplicant: Notify about peer's services on WiFi Display IEs change
  peer: Add the core logic to handle a peer service list
  peer: Implement peer's Services DBus property
  wifi: Expose WiFi Display IEs as a peer service

 client/commands.c |  60 ++---
 gsupplicant/gsupplicant.h |  13 +++-
 gsupplicant/supplicant.c  | 148 ++---
 include/peer.h|  10 +++
 plugins/wifi.c| 165 +-
 src/manager.c |   8 ++-
 src/peer.c|  86 +++-
 7 files changed, 439 insertions(+), 51 deletions(-)

-- 
1.8.5.5

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


[PATCH 01/13] gsupplicant: Add a callback enabled setter for the WFD IEs

2014-09-05 Thread Tomasz Bursztyka
Wifi plugin will be able to update the WFD IEs through that function and
will know if it has been successfully set or not by a callback.
---
 gsupplicant/gsupplicant.h |  6 +
 gsupplicant/supplicant.c  | 56 +++
 2 files changed, 62 insertions(+)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index e820381..c9aad8d 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -183,6 +183,8 @@ struct _GSupplicantP2PServiceParams {
int query_length;
unsigned char *response;
int response_length;
+   unsigned char *wfd_ies;
+   int wfd_ies_length;
 };
 
 typedef struct _GSupplicantP2PServiceParams GSupplicantP2PServiceParams;
@@ -251,6 +253,10 @@ int 
g_supplicant_interface_p2p_add_service(GSupplicantInterface *interface,
 int g_supplicant_interface_p2p_del_service(GSupplicantInterface *interface,
GSupplicantP2PServiceParams 
*p2p_service_params);
 
+int g_supplicant_set_widi_ies(GSupplicantP2PServiceParams *p2p_service_params,
+   GSupplicantInterfaceCallback callback,
+   void *user_data);
+
 int g_supplicant_interface_connect(GSupplicantInterface *interface,
GSupplicantSSID *ssid,
GSupplicantInterfaceCallback callback,
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index b796524..e96d80b 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4879,6 +4879,7 @@ static void interface_p2p_service_result(const char 
*error,
g_free(data-service-query);
g_free(data-service-response);
g_free(data-service-service);
+   g_free(data-service-wfd_ies);
g_free(data-service);
dbus_free(data);
 }
@@ -5017,6 +5018,61 @@ int 
g_supplicant_interface_p2p_listen(GSupplicantInterface *interface,
NULL, params, NULL);
 }
 
+static void widi_ies_params(DBusMessageIter *iter, void *user_data)
+{
+   struct p2p_service_data *data = user_data;
+   GSupplicantP2PServiceParams *service = data-service;
+   DBusMessageIter array;
+
+   SUPPLICANT_DBG(%p - %d, service-wfd_ies, service-wfd_ies_length);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   DBUS_TYPE_BYTE_AS_STRING, array);
+
+   if (service-wfd_ies  service-wfd_ies_length  0) {
+   dbus_message_iter_append_fixed_array(array, DBUS_TYPE_BYTE,
+   service-wfd_ies, service-wfd_ies_length);
+   }
+
+   dbus_message_iter_close_container(iter, array);
+}
+
+int g_supplicant_set_widi_ies(GSupplicantP2PServiceParams *p2p_service_params,
+   GSupplicantInterfaceCallback callback,
+   void *user_data)
+{
+   struct p2p_service_data *data;
+   int ret;
+
+   SUPPLICANT_DBG();
+
+   if (!system_available)
+   return -EFAULT;
+
+   data = dbus_malloc0(sizeof(*data));
+   data-service = p2p_service_params;
+   data-callback = callback;
+   data-user_data = user_data;
+
+   if (p2p_service_params-wfd_ies)
+   data-registration = true;
+
+   ret = supplicant_dbus_property_set(SUPPLICANT_PATH,
+   SUPPLICANT_INTERFACE, WFDIEs,
+   DBUS_TYPE_ARRAY_AS_STRING
+   DBUS_TYPE_BYTE_AS_STRING,
+   widi_ies_params,
+   interface_p2p_service_result,
+   data, NULL);
+   if (ret  0  ret != -EINPROGRESS) {
+   dbus_free(data);
+   return ret;
+   }
+
+   return -EINPROGRESS;
+}
+
+
 static const char *g_supplicant_rule0 = type=signal,
path= DBUS_PATH_DBUS ,
sender= DBUS_SERVICE_DBUS ,
-- 
1.8.5.5

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


[PATCH 09/13] gsupplicant: Add a Peer service changed dedicated state

2014-09-05 Thread Tomasz Bursztyka
This will be possible then to get those services and ask the peer core
to raise a proper DBus update on it.
---
 gsupplicant/gsupplicant.h | 1 +
 plugins/wifi.c| 2 ++
 2 files changed, 3 insertions(+)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index ca4f05d..29e54b6 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -120,6 +120,7 @@ typedef enum {
 } GSupplicantWpsState;
 
 typedef enum {
+   G_SUPPLICANT_PEER_SERVICES_CHANGED,
G_SUPPLICANT_PEER_GROUP_CHANGED,
G_SUPPLICANT_PEER_GROUP_STARTED,
G_SUPPLICANT_PEER_GROUP_FINISHED,
diff --git a/plugins/wifi.c b/plugins/wifi.c
index db76535..7b19673 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2677,6 +2677,8 @@ static void peer_changed(GSupplicantPeer *peer, 
GSupplicantPeerState state)
return;
 
switch (state) {
+   case G_SUPPLICANT_PEER_SERVICES_CHANGED:
+   return;
case G_SUPPLICANT_PEER_GROUP_CHANGED:
if (!g_supplicant_peer_is_in_a_group(peer))
p_state = CONNMAN_PEER_STATE_IDLE;
-- 
1.8.5.5

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


[PATCH 03/13] wifi: Support registering WiFi Display IEs when relevant

2014-09-05 Thread Tomasz Bursztyka
Wifi plugin will detect if the provided specifications of the service to
be registered are WiFi Display IEs. If so, it will request the proper
gsupplicant function to set those since WiFi Display IEs are a global
setting in wpa_supplicanct.
---
 plugins/wifi.c | 140 +++--
 1 file changed, 127 insertions(+), 13 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index f16c3fe..e714fe1 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -132,6 +132,7 @@ static GList *iface_list = NULL;
 
 static GList *pending_wifi_device = NULL;
 static GList *p2p_iface_list = NULL;
+bool wfd_service_registered = false;
 
 static void start_autoscan(struct connman_device *device);
 
@@ -358,23 +359,38 @@ struct peer_service_registration {
void *user_data;
 };
 
-static void register_peer_service_cb(int result,
+static bool is_service_wfd(const unsigned char *specs, int length)
+{
+   if (length  9 || specs[0] != 0 || specs[1] != 0 || specs[2] != 6)
+   return false;
+
+   return true;
+}
+
+static void apply_p2p_listen_on_iface(gpointer data, gpointer user_data)
+{
+   struct wifi_data *wifi = data;
+
+   if (!wifi-interface)
+   return;
+
+   if (!wifi-servicing) {
+   g_supplicant_interface_p2p_listen(wifi-interface,
+   P2P_LISTEN_PERIOD, P2P_LISTEN_INTERVAL);
+   }
+
+   wifi-servicing++;
+}
+
+static void register_wfd_service_cb(int result,
GSupplicantInterface *iface, void *user_data)
 {
-   struct wifi_data *wifi = g_supplicant_interface_get_data(iface);
struct peer_service_registration *reg_data = user_data;
 
DBG();
 
-   if (result == 0) {
-   if (!wifi-servicing) {
-   g_supplicant_interface_p2p_listen(iface,
-   P2P_LISTEN_PERIOD,
-   P2P_LISTEN_INTERVAL);
-   }
-
-   wifi-servicing++;
-   }
+   if (result == 0)
+   g_list_foreach(iface_list, apply_p2p_listen_on_iface, NULL);
 
if (reg_data-callback)
reg_data-callback(result, reg_data-user_data);
@@ -396,12 +412,15 @@ static GSupplicantP2PServiceParams 
*fill_in_peer_service_params(
if (version  0) {
params-version = version;
params-service = g_memdup(spec, spec_length);
-   } else {
+   } else if (query_length  0  spec_length  0) {
params-query = g_memdup(query, query_length);
params-query_length = query_length;
 
params-response = g_memdup(spec, spec_length);
params-response_length = spec_length;
+   } else {
+   params-wfd_ies = g_memdup(spec, spec_length);
+   params-wfd_ies_length = spec_length;
}
 
return params;
@@ -415,10 +434,71 @@ static void 
free_peer_service_params(GSupplicantP2PServiceParams *params)
g_free(params-service);
g_free(params-query);
g_free(params-response);
+   g_free(params-wfd_ies);
 
g_free(params);
 }
 
+static int peer_register_wfd_service(const unsigned char *specification,
+   int specification_length,
+   peer_service_registration_cb_t callback,
+   void *user_data)
+{
+   struct peer_service_registration *reg_data = NULL;
+   static GSupplicantP2PServiceParams *params;
+   int ret;
+
+   DBG();
+
+   if (wfd_service_registered)
+   return -EBUSY;
+
+   params = fill_in_peer_service_params(specification,
+   specification_length, NULL, 0, 0);
+   if (!params)
+   return -ENOMEM;
+
+   reg_data = g_try_malloc0(sizeof(*reg_data));
+   if (!reg_data) {
+   ret = -ENOMEM;
+   goto error;
+   }
+
+   reg_data-callback = callback;
+   reg_data-user_data = user_data;
+
+   ret = g_supplicant_set_widi_ies(params,
+   register_wfd_service_cb, reg_data);
+   if (ret  0  ret != -EINPROGRESS)
+   goto error;
+
+   wfd_service_registered = true;
+
+   return ret;
+error:
+   free_peer_service_params(params);
+   g_free(reg_data);
+
+   return ret;
+}
+
+static void register_peer_service_cb(int result,
+   GSupplicantInterface *iface, void *user_data)
+{
+   struct wifi_data *wifi = g_supplicant_interface_get_data(iface);
+   struct peer_service_registration *reg_data = user_data;
+
+   DBG();
+
+   if (result == 0)
+   apply_p2p_listen_on_iface(wifi, NULL);
+
+   if (reg_data-callback)
+   reg_data-callback(result, reg_data-user_data);
+
+   g_free(reg_data);
+}
+
 static int 

[PATCH 05/13] gsupplicant: Refactor how Peer's groups is detected to have changed

2014-09-05 Thread Tomasz Bursztyka
Same structure will be then used to check whether or not the IEs
property has changed as well.
---
 gsupplicant/supplicant.c | 47 ---
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index e96d80b..4122182 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -231,7 +231,6 @@ struct _GSupplicantPeer {
char *identifier;
unsigned int wps_capabilities;
GSList *groups;
-   bool groups_changed;
const GSupplicantInterface *current_group_iface;
 };
 
@@ -2541,14 +2540,15 @@ static void create_peer_identifier(GSupplicantPeer 
*peer)
peer-device_address[5]);
 }
 
-struct peer_group_data {
+struct peer_property_data {
GSupplicantPeer *peer;
GSList *old_groups;
+   bool groups_changed;
 };
 
 static void peer_groups_relation(DBusMessageIter *iter, void *user_data)
 {
-   struct peer_group_data *data = user_data;
+   struct peer_property_data *data = user_data;
GSupplicantPeer *peer = data-peer;
GSupplicantGroup *group;
const char *str = NULL;
@@ -2568,14 +2568,15 @@ static void peer_groups_relation(DBusMessageIter *iter, 
void *user_data)
peer-groups = g_slist_concat(elem, peer-groups);
} else {
peer-groups = g_slist_prepend(peer-groups, g_strdup(str));
-   peer-groups_changed = true;
+   data-groups_changed = true;
}
 }
 
 static void peer_property(const char *key, DBusMessageIter *iter,
void *user_data)
 {
-   GSupplicantPeer *peer = user_data;
+   struct peer_property_data *data = user_data;
+   GSupplicantPeer *peer = data-peer;
 
SUPPLICANT_DBG(key: %s, key);
 
@@ -2588,6 +2589,8 @@ static void peer_property(const char *key, 
DBusMessageIter *iter,
callback_peer_found(peer);
}
 
+   dbus_free(data);
+
return;
}
 
@@ -2617,23 +2620,21 @@ static void peer_property(const char *key, 
DBusMessageIter *iter,
if (wps_config  ~G_SUPPLICANT_WPS_CONFIG_PBC)
peer-wps_capabilities |= G_SUPPLICANT_WPS_PIN;
} else if (g_strcmp0(key, Groups) == 0) {
-   struct peer_group_data data = {
-   .peer = peer,
-   .old_groups = peer-groups,
-   };
+   data-old_groups = peer-groups;
peer-groups = NULL;
 
supplicant_dbus_array_foreach(iter,
-   peer_groups_relation, data);
-   if (g_slist_length(data.old_groups)  0) {
-   g_slist_free_full(data.old_groups, g_free);
-   peer-groups_changed = true;
+   peer_groups_relation, data);
+   if (g_slist_length(data-old_groups)  0) {
+   g_slist_free_full(data-old_groups, g_free);
+   data-groups_changed = true;
}
}
 }
 
 static void signal_peer_found(const char *path, DBusMessageIter *iter)
 {
+   struct peer_property_data *property_data;
GSupplicantInterface *interface;
const char *obj_path = NULL;
GSupplicantPeer *peer;
@@ -2661,16 +2662,20 @@ static void signal_peer_found(const char *path, 
DBusMessageIter *iter)
g_hash_table_insert(interface-peer_table, peer-path, peer);
g_hash_table_replace(peer_mapping, peer-path, interface);
 
+   property_data = dbus_malloc0(sizeof(struct peer_property_data));
+   property_data-peer = peer;
+
dbus_message_iter_next(iter);
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) {
-   supplicant_dbus_property_foreach(iter, peer_property, peer);
-   peer_property(NULL, NULL, peer);
+   supplicant_dbus_property_foreach(iter, peer_property,
+   property_data);
+   peer_property(NULL, NULL, property_data);
return;
}
 
supplicant_dbus_property_get_all(obj_path,
SUPPLICANT_INTERFACE .Peer,
-   peer_property, peer, NULL);
+   peer_property, property_data, NULL);
 }
 
 static void signal_peer_lost(const char *path, DBusMessageIter *iter)
@@ -2698,6 +2703,7 @@ static void signal_peer_lost(const char *path, 
DBusMessageIter *iter)
 
 static void signal_peer_changed(const char *path, DBusMessageIter *iter)
 {
+   struct peer_property_data *property_data;
GSupplicantInterface *interface;
GSupplicantPeer *peer;
 
@@ -2713,13 +2719,16 @@ static void signal_peer_changed(const char *path, 

[PATCH 04/13] client: Support basic WiFi Display IEs (un)registration

2014-09-05 Thread Tomasz Bursztyka
This is a useful addition only for testing purposes as connmanctl will
never serve any WiFi Display service. The wfd_ies is the tlv formated
array of WiFi Display IE expressed in hexadecimal.
---
 client/commands.c | 60 +--
 1 file changed, 50 insertions(+), 10 deletions(-)

diff --git a/client/commands.c b/client/commands.c
index d7b76a6..ed38cb8 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -2117,6 +2117,8 @@ struct _peer_service {
int bjr_query_len;
unsigned char *bjr_response;
int bjr_response_len;
+   unsigned char *wfd_ies;
+   int wfd_ies_len;
char *upnp_service;
int version;
int master;
@@ -2157,6 +2159,9 @@ static void append_peer_service_dict(DBusMessageIter 
*iter, void *user_data)
DBUS_TYPE_INT32, service-version);
__connmanctl_dbus_append_dict_entry(iter, UpnpService,
DBUS_TYPE_STRING, service-upnp_service);
+   } else if (service-wfd_ies) {
+   append_dict_entry_fixed_array(iter, WiFiDisplayIEs,
+   service-wfd_ies, service-wfd_ies_len);
}
 }
 
@@ -2177,7 +2182,8 @@ static void peer_service_append(DBusMessageIter *iter, 
void *user_data)
 static struct _peer_service *fill_in_peer_service(unsigned char *bjr_query,
int bjr_query_len, unsigned char *bjr_response,
int bjr_response_len, char *upnp_service,
-   int version)
+   int version, unsigned char *wfd_ies,
+   int wfd_ies_len)
 {
struct _peer_service *service;
 
@@ -2194,6 +2200,13 @@ static struct _peer_service 
*fill_in_peer_service(unsigned char *bjr_query,
} else if (upnp_service  version) {
service-upnp_service = strdup(upnp_service);
service-version = version;
+   } else if (wfd_ies  wfd_ies_len) {
+   service-wfd_ies = dbus_malloc0(wfd_ies_len);
+   memcpy(service-wfd_ies, wfd_ies, wfd_ies_len);
+   service-wfd_ies_len = wfd_ies_len;
+   } else {
+   dbus_free(service);
+   service = NULL;
}
 
return service;
@@ -2203,20 +2216,26 @@ static void free_peer_service(struct _peer_service 
*service)
 {
dbus_free(service-bjr_query);
dbus_free(service-bjr_response);
+   dbus_free(service-wfd_ies);
free(service-upnp_service);
dbus_free(service);
 }
 
 static int peer_service_register(unsigned char *bjr_query, int bjr_query_len,
unsigned char *bjr_response, int bjr_response_len,
-   char *upnp_service, int version, int master)
+   char *upnp_service, int version,
+   unsigned char *wfd_ies, int wfd_ies_len, int master)
 {
struct _peer_service *service;
bool registration = true;
int ret;
 
service = fill_in_peer_service(bjr_query, bjr_query_len, bjr_response,
-   bjr_response_len, upnp_service, version);
+   bjr_response_len, upnp_service, version,
+   wfd_ies, wfd_ies_len);
+   if (!service)
+   return -EINVAL;
+
service-master = master;
 
ret = __connmanctl_dbus_method_call(connection, net.connman, /,
@@ -2231,14 +2250,19 @@ static int peer_service_register(unsigned char 
*bjr_query, int bjr_query_len,
 
 static int peer_service_unregister(unsigned char *bjr_query, int bjr_query_len,
unsigned char *bjr_response, int bjr_response_len,
-   char *upnp_service, int version)
+   char *upnp_service, int version,
+   unsigned char *wfd_ies, int wfd_ies_len)
 {
struct _peer_service *service;
bool registration = false;
int ret;
 
service = fill_in_peer_service(bjr_query, bjr_query_len, bjr_response,
-   bjr_response_len, upnp_service, version);
+   bjr_response_len, upnp_service, version,
+   wfd_ies, wfd_ies_len);
+   if (!service)
+   return -EINVAL;
+
service-master = -1;
 
ret = __connmanctl_dbus_method_call(connection, net.connman, /,
@@ -2280,13 +2304,27 @@ static int cmd_peer_service(char *args[], int num,
 {
unsigned char bjr_query[1024] = {};
unsigned char bjr_response[1024] = {};
+   unsigned char wfd_ies[1024] = {};
char *upnp_service = NULL;
int bjr_query_len = 0, bjr_response_len = 0;
-   int version = 0, master = 0;
+   int version = 0, master = 0, wfd_ies_len = 0;;
+   int limit;
+
+   if (num  4)
+   return -EINVAL;
+
+   if (!strcmp(args[2], 

[PATCH 07/13] gsupplicant: Add a getter for the WiFi Display information elements

2014-09-05 Thread Tomasz Bursztyka
This will be then pushed to Peer's core, as is, without any
interpretation and then provided as a Peer Service of the Peer.
---
 gsupplicant/gsupplicant.h |  2 ++
 gsupplicant/supplicant.c  | 10 ++
 2 files changed, 12 insertions(+)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index c9aad8d..62c6adb 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -324,6 +324,8 @@ const char *g_supplicant_peer_get_path(GSupplicantPeer 
*peer);
 const char *g_supplicant_peer_get_identifier(GSupplicantPeer *peer);
 const void *g_supplicant_peer_get_device_address(GSupplicantPeer *peer);
 const char *g_supplicant_peer_get_name(GSupplicantPeer *peer);
+const unsigned char *g_supplicant_peer_get_widi_ies(GSupplicantPeer *peer,
+   int *length);
 bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer);
 bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer);
 bool g_supplicant_peer_is_in_a_group(GSupplicantPeer *peer);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 67a3791..8d19b6d 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -1079,6 +1079,16 @@ const char *g_supplicant_peer_get_name(GSupplicantPeer 
*peer)
return peer-name;
 }
 
+const unsigned char *g_supplicant_peer_get_widi_ies(GSupplicantPeer *peer,
+   int *length)
+{
+   if (!peer || !length)
+   return NULL;
+
+   *length = peer-widi_ies_length;
+   return peer-widi_ies;
+}
+
 bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer)
 {
if (!peer)
-- 
1.8.5.5

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


[PATCH 11/13] peer: Add the core logic to handle a peer service list

2014-09-05 Thread Tomasz Bursztyka
Basically maintaining a simple list of byte arrays, provided by the wifi
plugin in use.
---
 include/peer.h |  9 +
 src/peer.c | 47 +++
 2 files changed, 56 insertions(+)

diff --git a/include/peer.h b/include/peer.h
index 5e1795f..b667003 100644
--- a/include/peer.h
+++ b/include/peer.h
@@ -42,6 +42,11 @@ enum connman_peer_wps_method {
CONNMAN_PEER_WPS_PIN = 2,
 };
 
+enum connman_peer_service_type {
+   CONNMAN_PEER_SERVICE_UNKNOWN  = 0,
+   CONNMAN_PEER_SERVICE_WIFI_DISPLAY = 1,
+};
+
 struct connman_peer;
 
 struct connman_peer *connman_peer_create(const char *identifier);
@@ -68,6 +73,10 @@ void connman_peer_set_as_master(struct connman_peer *peer, 
bool master);
 int connman_peer_set_state(struct connman_peer *peer,
enum connman_peer_state new_state);
 int connman_peer_request_connection(struct connman_peer *peer);
+void connman_peer_reset_services(struct connman_peer *peer);
+void connman_peer_add_service(struct connman_peer *peer,
+   enum connman_peer_service_type type,
+   const unsigned char *data, int data_length);
 
 int connman_peer_register(struct connman_peer *peer);
 void connman_peer_unregister(struct connman_peer *peer);
diff --git a/src/peer.c b/src/peer.c
index 5f2a699..cf4f0e7 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -44,6 +44,12 @@ struct _peers_notify {
GHashTable *remove;
 } *peers_notify;
 
+struct _peer_service {
+   enum connman_peer_service_type type;
+   unsigned char *data;
+   int length;
+};
+
 struct connman_peer {
int refcount;
struct connman_device *device;
@@ -58,6 +64,7 @@ struct connman_peer {
bool connection_master;
struct connman_ippool *ip_pool;
GDHCPServer *dhcp_server;
+   GSList *services;
 };
 
 static void stop_dhcp_server(struct connman_peer *peer)
@@ -188,6 +195,9 @@ static void peer_free(gpointer data)
peer-device = NULL;
}
 
+   if (peer-services)
+   connman_peer_reset_services(peer);
+
g_free(peer-identifier);
g_free(peer-name);
 
@@ -840,6 +850,43 @@ int connman_peer_request_connection(struct connman_peer 
*peer)
NULL, NULL);
 }
 
+static void peer_service_free(gpointer data)
+{
+   struct _peer_service *service = data;
+
+   if (!service)
+   return;
+
+   g_free(service-data);
+   g_free(service);
+}
+
+void connman_peer_reset_services(struct connman_peer *peer)
+{
+   if (!peer)
+   return;
+
+   g_slist_free_full(peer-services, peer_service_free);
+   peer-services = NULL;
+}
+
+void connman_peer_add_service(struct connman_peer *peer,
+   enum connman_peer_service_type type,
+   const unsigned char *data, int data_length)
+{
+   struct _peer_service *service;
+
+   if (!peer || !data || type == CONNMAN_PEER_SERVICE_UNKNOWN)
+   return;
+
+   service = g_malloc0(sizeof(struct _peer_service));
+   service-type = type;
+   service-data = g_memdup(data, data_length * sizeof(unsigned char));
+   service-length = data_length;
+
+   peer-services = g_slist_prepend(peer-services, service);
+}
+
 static void peer_up(struct connman_ipconfig *ipconfig, const char *ifname)
 {
DBG(%s up, ifname);
-- 
1.8.5.5

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


[PATCH 08/13] gsupplicant: Rename the peer state enum for future changes

2014-09-05 Thread Tomasz Bursztyka
In order to use peer_changed() callback also for peer's property
changed, let's rename GSupplicantPeerGroupState to GSupplicantPeerState
which then becomes semantically more generic.
---
 gsupplicant/gsupplicant.h | 4 ++--
 gsupplicant/supplicant.c  | 2 +-
 plugins/wifi.c| 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 62c6adb..ca4f05d 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -126,7 +126,7 @@ typedef enum {
G_SUPPLICANT_PEER_GROUP_JOINED,
G_SUPPLICANT_PEER_GROUP_DISCONNECTED,
G_SUPPLICANT_PEER_GROUP_FAILED,
-} GSupplicantPeerGroupState;
+} GSupplicantPeerState;
 
 struct _GSupplicantSSID {
const void *ssid;
@@ -348,7 +348,7 @@ struct _GSupplicantCallbacks {
void (*peer_found) (GSupplicantPeer *peer);
void (*peer_lost) (GSupplicantPeer *peer);
void (*peer_changed) (GSupplicantPeer *peer,
-   GSupplicantPeerGroupState state);
+   GSupplicantPeerState state);
void (*peer_request) (GSupplicantPeer *peer);
void (*debug) (const char *str);
 };
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 8d19b6d..298f2a9 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -495,7 +495,7 @@ static void callback_peer_lost(GSupplicantPeer *peer)
 }
 
 static void callback_peer_changed(GSupplicantPeer *peer,
-   GSupplicantPeerGroupState state)
+   GSupplicantPeerState state)
 {
if (!callbacks_pointer)
return;
diff --git a/plugins/wifi.c b/plugins/wifi.c
index e714fe1..db76535 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2660,8 +2660,7 @@ static void peer_lost(GSupplicantPeer *peer)
}
 }
 
-static void peer_changed(GSupplicantPeer *peer,
-   GSupplicantPeerGroupState state)
+static void peer_changed(GSupplicantPeer *peer, GSupplicantPeerState state)
 {
GSupplicantInterface *iface = g_supplicant_peer_get_interface(peer);
struct wifi_data *wifi = g_supplicant_interface_get_data(iface);
-- 
1.8.5.5

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


[PATCH 12/13] peer: Implement peer's Services DBus property

2014-09-05 Thread Tomasz Bursztyka
The peer P2P services are provided through an array of byte arrays.
Each of those represent a P2P service at its bare level.
---
 include/peer.h |  1 +
 src/peer.c | 39 ++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/include/peer.h b/include/peer.h
index b667003..e98e442 100644
--- a/include/peer.h
+++ b/include/peer.h
@@ -77,6 +77,7 @@ void connman_peer_reset_services(struct connman_peer *peer);
 void connman_peer_add_service(struct connman_peer *peer,
enum connman_peer_service_type type,
const unsigned char *data, int data_length);
+void connman_peer_services_changed(struct connman_peer *peer);
 
 int connman_peer_register(struct connman_peer *peer);
 void connman_peer_unregister(struct connman_peer *peer);
diff --git a/src/peer.c b/src/peer.c
index cf4f0e7..5d0f19f 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -288,6 +288,31 @@ static void append_ipv4(DBusMessageIter *iter, void 
*user_data)
__connman_ipconfig_append_ipv4(peer-ipconfig, iter);
 }
 
+static void append_peer_services(DBusMessageIter *iter, void *user_data)
+{
+   struct connman_peer *peer = user_data;
+   DBusMessageIter dict;
+   GSList *list;
+
+   for (list = peer-services; list; list = list-next) {
+   struct _peer_service *service = list-data;
+
+   connman_dbus_dict_open(iter, dict);
+
+   switch (service-type) {
+   case CONNMAN_PEER_SERVICE_UNKNOWN:
+   /* Should never happen */
+   break;
+   case CONNMAN_PEER_SERVICE_WIFI_DISPLAY:
+   connman_dbus_property_append_fixed_array(dict,
+   WiFiDisplayIEs, DBUS_TYPE_BYTE,
+   service-data, service-length);
+   break;
+   }
+   connman_dbus_dict_close(iter, dict);
+   }
+}
+
 static void append_properties(DBusMessageIter *iter, struct connman_peer *peer)
 {
const char *state = state2string(peer-state);
@@ -300,7 +325,9 @@ static void append_properties(DBusMessageIter *iter, struct 
connman_peer *peer)
connman_dbus_dict_append_basic(dict, Name,
DBUS_TYPE_STRING, peer-name);
connman_dbus_dict_append_dict(dict, IPv4, append_ipv4, peer);
-
+   connman_dbus_dict_append_array(dict, Services,
+   DBUS_TYPE_DICT_ENTRY,
+   append_peer_services, peer);
connman_dbus_dict_close(iter, dict);
 }
 
@@ -870,6 +897,16 @@ void connman_peer_reset_services(struct connman_peer *peer)
peer-services = NULL;
 }
 
+void connman_peer_services_changed(struct connman_peer *peer)
+{
+   if (!peer || !peer-registered || !allow_property_changed(peer))
+   return;
+
+   connman_dbus_property_changed_array(peer-path,
+   CONNMAN_PEER_INTERFACE, Services,
+   DBUS_TYPE_DICT_ENTRY, append_peer_services, peer);
+}
+
 void connman_peer_add_service(struct connman_peer *peer,
enum connman_peer_service_type type,
const unsigned char *data, int data_length)
-- 
1.8.5.5

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


[PATCH 10/13] gsupplicant: Notify about peer's services on WiFi Display IEs change

2014-09-05 Thread Tomasz Bursztyka
Notify such change to the wifi plugin, which will in return properly
update peer's services.
---
 gsupplicant/supplicant.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 298f2a9..a796924 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2556,6 +2556,7 @@ struct peer_property_data {
GSupplicantPeer *peer;
GSList *old_groups;
bool groups_changed;
+   bool services_changed;
 };
 
 static void peer_groups_relation(DBusMessageIter *iter, void *user_data)
@@ -2653,6 +2654,9 @@ static void peer_property(const char *key, 
DBusMessageIter *iter,
return;
 
if (peer-widi_ies) {
+   if (memcmp(peer-widi_ies, ie, ie_len) == 0)
+   return;
+
g_free(peer-widi_ies);
peer-widi_ies_length = 0;
}
@@ -2661,6 +2665,7 @@ static void peer_property(const char *key, 
DBusMessageIter *iter,
 
memcpy(peer-widi_ies, ie, ie_len);
peer-widi_ies_length = ie_len;
+   data-services_changed = true;
}
 }
 
@@ -2755,10 +2760,12 @@ static void signal_peer_changed(const char *path, 
DBusMessageIter *iter)
property_data-peer = peer;
 
supplicant_dbus_property_foreach(iter, peer_property, property_data);
-   if (!property_data-groups_changed)
-   return;
+   if (property_data-services_changed)
+   callback_peer_changed(peer,
+   G_SUPPLICANT_PEER_SERVICES_CHANGED);
 
-   callback_peer_changed(peer, G_SUPPLICANT_PEER_GROUP_CHANGED);
+   if (property_data-groups_changed)
+   callback_peer_changed(peer, G_SUPPLICANT_PEER_GROUP_CHANGED);
 
dbus_free(property_data);
 }
-- 
1.8.5.5

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


[PATCH 06/13] gsupplicant: Get Peer's WiFi Display information elements if present

2014-09-05 Thread Tomasz Bursztyka
Such IEs will be then presented to users through ConnMan's Peer service
API.
---
 gsupplicant/supplicant.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 4122182..67a3791 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -228,6 +228,8 @@ struct _GSupplicantPeer {
unsigned char device_address[ETH_ALEN];
unsigned char iface_address[ETH_ALEN];
char *name;
+   unsigned char *widi_ies;
+   int widi_ies_length;
char *identifier;
unsigned int wps_capabilities;
GSList *groups;
@@ -2629,6 +2631,26 @@ static void peer_property(const char *key, 
DBusMessageIter *iter,
g_slist_free_full(data-old_groups, g_free);
data-groups_changed = true;
}
+   } else if (g_strcmp0(key, IEs) == 0) {
+   DBusMessageIter array;
+   unsigned char *ie;
+   int ie_len;
+
+   dbus_message_iter_recurse(iter, array);
+   dbus_message_iter_get_fixed_array(array, ie, ie_len);
+
+   if (!ie || ie_len  2)
+   return;
+
+   if (peer-widi_ies) {
+   g_free(peer-widi_ies);
+   peer-widi_ies_length = 0;
+   }
+
+   peer-widi_ies = g_malloc0(ie_len * sizeof(unsigned char));
+
+   memcpy(peer-widi_ies, ie, ie_len);
+   peer-widi_ies_length = ie_len;
}
 }
 
-- 
1.8.5.5

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


[PATCH 02/13] manager: Support WiFiDisplayIEs as a new Peer Service to handle

2014-09-05 Thread Tomasz Bursztyka
WiFiDisplayIEs is a tlv formatted byte array following the WiDi
specifications. ConnMan won't interpret anything about it in its core.
---
 src/manager.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/manager.c b/src/manager.c
index e97921b..a06cdcf 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -412,13 +412,19 @@ static int parse_peers_service_specs(DBusMessageIter 
*array,
*spec_len = strlen((const char *)*spec)+1;
} else if (!g_strcmp0(key, UpnpVersion)) {
dbus_message_iter_get_basic(value, version);
+   } else if (!g_strcmp0(key, WiFiDisplayIEs)) {
+   if (*spec || *query)
+   return -EINVAL;
+   dbus_message_iter_get_fixed_array(value,
+   spec, spec_len);
} else
return -EINVAL;
 
dbus_message_iter_next(array);
}
 
-   if ((*query  *version) || (!*spec  *query) || (!spec  *version))
+   if ((*query  !*version) ||
+   (!*spec  !*query) || (!*spec  *version))
return -EINVAL;
 
return 0;
-- 
1.8.5.5

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


[PATCH 13/13] wifi: Expose WiFi Display IEs as a peer service

2014-09-05 Thread Tomasz Bursztyka
gsupplicant notifies the wifi plugin relevantly when such information
has changed, thus it's only a matter for the wifi plugin to update the
peer accordingly.
---
 plugins/wifi.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 7b19673..63f5828 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2607,6 +2607,23 @@ static void network_changed(GSupplicantNetwork *network, 
const char *property)
}
 }
 
+static void apply_peer_services(GSupplicantPeer *peer,
+   struct connman_peer *connman_peer)
+{
+   const unsigned char *data;
+   int length;
+
+   DBG();
+
+   connman_peer_reset_services(connman_peer);
+
+   data = g_supplicant_peer_get_widi_ies(peer, length);
+   if (data) {
+   connman_peer_add_service(connman_peer,
+   CONNMAN_PEER_SERVICE_WIFI_DISPLAY, data, length);
+   }
+}
+
 static void peer_found(GSupplicantPeer *peer)
 {
GSupplicantInterface *iface = g_supplicant_peer_get_interface(peer);
@@ -2627,6 +2644,7 @@ static void peer_found(GSupplicantPeer *peer)
connman_peer = connman_peer_create(identifier);
connman_peer_set_name(connman_peer, name);
connman_peer_set_device(connman_peer, wifi-device);
+   apply_peer_services(peer, connman_peer);
 
ret = connman_peer_register(connman_peer);
if (ret  0  ret != -EALREADY)
@@ -2678,6 +2696,8 @@ static void peer_changed(GSupplicantPeer *peer, 
GSupplicantPeerState state)
 
switch (state) {
case G_SUPPLICANT_PEER_SERVICES_CHANGED:
+   apply_peer_services(peer, connman_peer);
+   connman_peer_services_changed(connman_peer);
return;
case G_SUPPLICANT_PEER_GROUP_CHANGED:
if (!g_supplicant_peer_is_in_a_group(peer))
-- 
1.8.5.5

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


[PATCH 14/13] doc: Update peer Services property about WiFi Display IEs

2014-09-05 Thread Tomasz Bursztyka
If the peer advertizes about WFD capabilities, it will be visible
through it's Services WiFiDisplayIEs property as a byte array.
---

Forgot that one.

 doc/peer-api.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/doc/peer-api.txt b/doc/peer-api.txt
index ff1f899..e29eb6e 100644
--- a/doc/peer-api.txt
+++ b/doc/peer-api.txt
@@ -93,3 +93,8 @@ Propertiesstring State [readonly] [experimental]
 
Note: this will be the only bonjour related
information a Peer object will show.
+
+   array{byte} WiFiDisplayIEs [readonly]
+
+   The TLV formated byte array representing the
+   WiFi Display Informations Elements.
-- 
1.8.5.5

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


Re: agent, route questions with 1.25

2014-09-05 Thread Mike Purvis
Hmm. My exact command sequence from startup is:

$ connmanctl
connmanctl agent on
Agent registered
connmanctl enable wifi
Error wifi: Already enabled
connmanctl scan wifi
Scan completed for wifi
connmanctl connect wifi__managed_psk
Passphrase? x
Connected wifi__managed_psk
connmanctl config wifi__managed_psk  --autoconnect yes
connmanctl

I now have full internet connectivity, confirmed by ifconfig, iwconfig,
ping, wget. So yes, it does seem to help to run the config command
immediately following the scan.

However, when I now (in a different terminal) do

$ ls /var/lib/connman

I see only wired_x directories. Note that this is definitely the 1.25
daemon:

$ connmand --version
1.25

And I've also confirmed that I'm using the version of connmanctl from the
1.25 tarball.

Note that the above behaviour is 100% consistent whether connmand is run by
upstart, or launched in the foreground with

$ sudo connmand -d -n

What are the reasons that the /var/lib/connman directory might not get
written? Is there something particular I should look for in the debug
output regarding this? As it is, the debug output is mostly overrun with
NEWROUTE and DELROUTE messages from rtnl.c; seems to be several of them
every few seconds.




On 5 September 2014 06:07, Patrik Flykt patrik.fl...@linux.intel.com
wrote:


 Hi,

 On Thu, 2014-09-04 at 17:02 -0400, Mike Purvis wrote:
  - When I connect to my wifi, it no longer creates a directory for it
 under
  /var/lib/connman. Did this behaviour change? I'm assuming this is related
  to the not-reconnecting behaviour.

 This means it did not get connected.

  - Running config wifi__managed_psk  --autoconnect yes tells me
  invalid service

 The service wifi__managed_psk does not exist as connmanctl
 cannot send a D-Bus method call to it. The cause is that the scan has
 not been done recently enough and the WiFi network has therefore timed
 out (in wpa_supplicant to be exact).

  - connmand is being executed by upstart. The invocation is connmand
  --nobacktrace.
 
  Is there a way for the daemon to tell me what its config is and where it
  came from? Would be really helpful for debugging to know if it's using
 the
  /var/lib/connman directory at all.

 No. But if there expected directory is not in /var/lib/connman, it means
 the network is not connected.

 Cheers,

 Patrik

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

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


Re: agent, route questions with 1.25

2014-09-05 Thread Mike Purvis
Ah, looking through the debug output from launching connmand in the
foreground, I see that it was trying to access /usr/local/var/lib/connman
rather than /var/lib/connman. Once I created the /usr/local/var/lib path,
then it populated the directory with details about the wifi connection.

Unfortunately even with this change, it still failed to reconnect upon
reboot— or at least, it fails most of the time. I get a successful
connection probably 1 out of 5 startups (either via reboot or by manually
launching the daemon).

Is there some way to make connman more persistent in trying to achieve a
connection? My perception is that it basically tries once, fails, and then
gives up for good.

In any case, is /usr/local the default for a source installation? If so,
this should definitely be clearly documented, especially when users are
encouraged to install connman from source!

Mike


On 5 September 2014 09:29, Mike Purvis mpur...@clearpathrobotics.com
wrote:

 Hmm. My exact command sequence from startup is:

 $ connmanctl
 connmanctl agent on
 Agent registered
 connmanctl enable wifi
 Error wifi: Already enabled
 connmanctl scan wifi
 Scan completed for wifi
 connmanctl connect wifi__managed_psk
 Passphrase? x
 Connected wifi__managed_psk
 connmanctl config wifi__managed_psk  --autoconnect yes
 connmanctl

 I now have full internet connectivity, confirmed by ifconfig, iwconfig,
 ping, wget. So yes, it does seem to help to run the config command
 immediately following the scan.

 However, when I now (in a different terminal) do

 $ ls /var/lib/connman

 I see only wired_x directories. Note that this is definitely the 1.25
 daemon:

 $ connmand --version
 1.25

 And I've also confirmed that I'm using the version of connmanctl from the
 1.25 tarball.

 Note that the above behaviour is 100% consistent whether connmand is run
 by upstart, or launched in the foreground with

 $ sudo connmand -d -n

 What are the reasons that the /var/lib/connman directory might not get
 written? Is there something particular I should look for in the debug
 output regarding this? As it is, the debug output is mostly overrun with
 NEWROUTE and DELROUTE messages from rtnl.c; seems to be several of them
 every few seconds.




 On 5 September 2014 06:07, Patrik Flykt patrik.fl...@linux.intel.com
 wrote:


 Hi,

 On Thu, 2014-09-04 at 17:02 -0400, Mike Purvis wrote:
  - When I connect to my wifi, it no longer creates a directory for it
 under
  /var/lib/connman. Did this behaviour change? I'm assuming this is
 related
  to the not-reconnecting behaviour.

 This means it did not get connected.

  - Running config wifi__managed_psk  --autoconnect yes tells me
  invalid service

 The service wifi__managed_psk does not exist as connmanctl
 cannot send a D-Bus method call to it. The cause is that the scan has
 not been done recently enough and the WiFi network has therefore timed
 out (in wpa_supplicant to be exact).

  - connmand is being executed by upstart. The invocation is connmand
  --nobacktrace.
 
  Is there a way for the daemon to tell me what its config is and where it
  came from? Would be really helpful for debugging to know if it's using
 the
  /var/lib/connman directory at all.

 No. But if there expected directory is not in /var/lib/connman, it means
 the network is not connected.

 Cheers,

 Patrik

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



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