[PATCH 2/3] wifi: Check peer_service user_data before invoking cb

2014-09-17 Thread Eduardo Abinader
A check was added, due to the occurrence of peer service
registration without callback. Such scenarios takes place,
when a previous peer service was registered with a proper
callback, on a distinct interface.
---
 plugins/wifi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index f16c3fe..45d88b8 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -376,10 +376,10 @@ static void register_peer_service_cb(int result,
wifi-servicing++;
}
 
-   if (reg_data-callback)
+   if (reg_data  reg_data-callback) {
reg_data-callback(result, reg_data-user_data);
-
-   g_free(reg_data);
+   g_free(reg_data);
+   }
 }
 
 static GSupplicantP2PServiceParams *fill_in_peer_service_params(
-- 
1.9.1

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


[PATCH 0/3] Peer service registration fixes

2014-09-17 Thread Eduardo Abinader
This set aims to solve observed issues during peer service
register and unregister scenarios.

Eduardo Abinader (3):
  gsupplicant: Check interface on interface_has_p2p
  wifi: Check peer_service user_data before invoking cb
  manager: Do not recurse one more level for upnp basic type

 gsupplicant/supplicant.c | 3 +++
 plugins/wifi.c   | 6 +++---
 src/manager.c| 7 ---
 3 files changed, 10 insertions(+), 6 deletions(-)

-- 
1.9.1

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


[PATCH 1/3] gsupplicant: Check interface on interface_has_p2p

2014-09-17 Thread Eduardo Abinader
Solves a segmentation fault occuring on peer service
registration, when a wifi plugin did not have an
associated interface while looping in peer service
registration.
---
 gsupplicant/supplicant.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index fd16caf..b5e3930 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -3181,6 +3181,9 @@ int 
g_supplicant_interface_set_country(GSupplicantInterface *interface,
 
 bool g_supplicant_interface_has_p2p(GSupplicantInterface *interface)
 {
+   if (!interface)
+   return false;
+
return interface-p2p_support;
 }
 
-- 
1.9.1

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


Re: [PATCH 0/3] Peer service registration fixes

2014-09-17 Thread Eduardo Abinader
Thanks, Tomasz.

But I just mixed things here: patch 3/3 is actually a separate patch I
sent yesterday to ML. Patch 3/3 is actually another one regarding
peer_driver unregister.

Resending a v2.



On Wed, Sep 17, 2014 at 8:01 AM, Tomasz Bursztyka
tomasz.burszt...@linux.intel.com wrote:
 Thanks Eduardo,

 ACK from me.

 Tomasz
 ___
 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


[PATCH v2 0/3] Peer service registration fixes

2014-09-17 Thread Eduardo Abinader
This set aims to solve observed issues during peer service
register and unregister scenarios.

Eduardo Abinader (3):
  gsupplicant: Check interface on interface_has_p2p
  wifi: Check peer_service user_data before invoking cb
  peer: Unset peer service driver upon peer unregister

 gsupplicant/supplicant.c | 3 +++
 plugins/wifi.c   | 6 +++---
 src/peer.c   | 2 ++
 3 files changed, 8 insertions(+), 3 deletions(-)

-- 
1.9.1

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


[PATCH 1/3] gsupplicant: Check interface on interface_has_p2p

2014-09-17 Thread Eduardo Abinader
Solves a segmentation fault occuring on peer service
registration, when a wifi plugin did not have an
associated interface while looping in peer service
registration.
---
 gsupplicant/supplicant.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index fd16caf..b5e3930 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -3181,6 +3181,9 @@ int 
g_supplicant_interface_set_country(GSupplicantInterface *interface,
 
 bool g_supplicant_interface_has_p2p(GSupplicantInterface *interface)
 {
+   if (!interface)
+   return false;
+
return interface-p2p_support;
 }
 
-- 
1.9.1

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


[PATCH 3/3] peer: Unset peer service driver upon peer unregister

2014-09-17 Thread Eduardo Abinader
When peer driver is unregistered, peer service driver should
be unregistered as well, in order to ensure proper queueing
of peer service registration for later conclusion, when a
p2p enabled device is connected.
---
 src/peer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/peer.c b/src/peer.c
index 5f2a699..d339dd3 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -1012,6 +1012,8 @@ void connman_peer_driver_unregister(struct 
connman_peer_driver *driver)
return;
 
peer_driver = NULL;
+
+   __connman_peer_service_set_driver(NULL);
 }
 
 void __connman_peer_list_struct(DBusMessageIter *array)
-- 
1.9.1

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


[PATCH 2/3] wifi: Check peer_service user_data before invoking cb

2014-09-17 Thread Eduardo Abinader
A check was added, due to the occurrence of peer service
registration without callback. Such scenarios takes place,
when a previous peer service was registered with a proper
callback, on a distinct interface.
---
 plugins/wifi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index f16c3fe..45d88b8 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -376,10 +376,10 @@ static void register_peer_service_cb(int result,
wifi-servicing++;
}
 
-   if (reg_data-callback)
+   if (reg_data  reg_data-callback) {
reg_data-callback(result, reg_data-user_data);
-
-   g_free(reg_data);
+   g_free(reg_data);
+   }
 }
 
 static GSupplicantP2PServiceParams *fill_in_peer_service_params(
-- 
1.9.1

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


[PATCH] manager: Do not recurse one more level for upnp basic type

2014-09-16 Thread Eduardo Abinader
Just recurse one more level for the byte array that
corresponds to bonjour data and not for the variant holding
upnp data. This patch prevents a segmentation fault
occuring by dereferencing null upnp data.
---
 src/manager.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index e97921b..17fd7ee 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -399,19 +399,20 @@ static int parse_peers_service_specs(DBusMessageIter 
*array,
dbus_message_iter_next(entry);
 
dbus_message_iter_recurse(entry, inter);
-   dbus_message_iter_recurse(inter, value);
 
if  (!g_strcmp0(key, BonjourResponse)) {
+   dbus_message_iter_recurse(inter, value);
dbus_message_iter_get_fixed_array(value,
spec, spec_len);
} else if (!g_strcmp0(key, BonjourQuery)) {
+   dbus_message_iter_recurse(inter, value);
dbus_message_iter_get_fixed_array(value,
query, query_len);
} else if (!g_strcmp0(key, UpnpService)) {
-   dbus_message_iter_get_basic(value, spec);
+   dbus_message_iter_get_basic(inter, spec);
*spec_len = strlen((const char *)*spec)+1;
} else if (!g_strcmp0(key, UpnpVersion)) {
-   dbus_message_iter_get_basic(value, version);
+   dbus_message_iter_get_basic(inter, version);
} else
return -EINVAL;
 
-- 
1.9.1

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


[PATCH 0/2] Code cleanup in inet

2014-09-09 Thread Eduardo Abinader
Remove two unused functions in inet.

Eduardo Abinader (2):
  Remove unused function connman_inet_ifflags
  Remove unused function connman_inet_is_cfg80211

 include/inet.h |  4 
 src/inet.c | 60 --
 2 files changed, 64 deletions(-)

-- 
1.9.1

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


[PATCH 2/2] Remove unused function connman_inet_is_cfg80211

2014-09-09 Thread Eduardo Abinader
Removing as this function is no longer being used.
---
 include/inet.h |  2 --
 src/inet.c | 30 --
 2 files changed, 32 deletions(-)

diff --git a/include/inet.h b/include/inet.h
index 807febb..6482934 100644
--- a/include/inet.h
+++ b/include/inet.h
@@ -39,8 +39,6 @@ char *connman_inet_ifname(int index);
 int connman_inet_ifup(int index);
 int connman_inet_ifdown(int index);
 
-bool connman_inet_is_cfg80211(int index);
-
 int connman_inet_set_address(int index, struct connman_ipaddress *ipaddress);
 int connman_inet_clear_address(int index, struct connman_ipaddress *ipaddress);
 int connman_inet_add_host_route(int index, const char *host, const char 
*gateway);
diff --git a/src/inet.c b/src/inet.c
index f0144de..cd220ff 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -330,36 +330,6 @@ done:
return err;
 }
 
-bool connman_inet_is_cfg80211(int index)
-{
-   bool result = false;
-   char phy80211_path[PATH_MAX];
-   struct stat st;
-   struct ifreq ifr;
-   int sk;
-
-   sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-   if (sk  0)
-   return false;
-
-   memset(ifr, 0, sizeof(ifr));
-   ifr.ifr_ifindex = index;
-
-   if (ioctl(sk, SIOCGIFNAME, ifr)  0)
-   goto done;
-
-   snprintf(phy80211_path, PATH_MAX,
-   /sys/class/net/%s/phy80211, ifr.ifr_name);
-
-   if (stat(phy80211_path, st) == 0  (st.st_mode  S_IFDIR))
-   result = true;
-
-done:
-   close(sk);
-
-   return result;
-}
-
 struct in6_ifreq {
struct in6_addr ifr6_addr;
__u32 ifr6_prefixlen;
-- 
1.9.1

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


[PATCH 1/2] Remove unused function connman_inet_ifflags

2014-09-09 Thread Eduardo Abinader
As the referred function is no longer called in code,
it should be removed as well.
---
 include/inet.h |  2 --
 src/inet.c | 30 --
 2 files changed, 32 deletions(-)

diff --git a/include/inet.h b/include/inet.h
index a836a5b..807febb 100644
--- a/include/inet.h
+++ b/include/inet.h
@@ -36,8 +36,6 @@ extern C {
 int connman_inet_ifindex(const char *name);
 char *connman_inet_ifname(int index);
 
-short int connman_inet_ifflags(int index);
-
 int connman_inet_ifup(int index);
 int connman_inet_ifdown(int index);
 
diff --git a/src/inet.c b/src/inet.c
index fb37143..f0144de 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -240,36 +240,6 @@ char *connman_inet_ifname(int index)
return g_strdup(ifr.ifr_name);
 }
 
-short int connman_inet_ifflags(int index)
-{
-   struct ifreq ifr;
-   int sk, err;
-
-   sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-   if (sk  0)
-   return -errno;
-
-   memset(ifr, 0, sizeof(ifr));
-   ifr.ifr_ifindex = index;
-
-   if (ioctl(sk, SIOCGIFNAME, ifr)  0) {
-   err = -errno;
-   goto done;
-   }
-
-   if (ioctl(sk, SIOCGIFFLAGS, ifr)  0) {
-   err = -errno;
-   goto done;
-   }
-
-   err = ifr.ifr_flags;
-
-done:
-   close(sk);
-
-   return err;
-}
-
 int connman_inet_ifup(int index)
 {
struct ifreq ifr;
-- 
1.9.1

___
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


[PATCH 0/2] Clean group interface and mapping

2014-09-02 Thread Eduardo Abinader
When a p2p group is finished, the peers holding the just
removed group interface shall be updated accordingly. The 
same must happen to group_mapping, as the p2p group was
finished.

Eduardo Abinader (2):
  gsupplicant: Remove peer group interface when group finished
  gsupplicant: Update group_mapping when group finished

 gsupplicant/supplicant.c | 29 +
 1 file changed, 29 insertions(+)

-- 
1.9.1

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


[PATCH 2/2] gsupplicant: Update group_mapping when group finished

2014-09-02 Thread Eduardo Abinader
Just updating group_mapping accordingly, as a p2p group
has been signaled as finished.
---
 gsupplicant/supplicant.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 903def7..9796fe8 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2915,6 +2915,8 @@ static void signal_group_finished(const char *path, 
DBusMessageIter *iter)
 
remove_peer_group_interface(interface-group_table, 
data.group_obj_path);
 
+   g_hash_table_remove(group_mapping, data.group_obj_path);
+
g_hash_table_remove(interface-group_table, data.group_obj_path);
 }
 
-- 
1.9.1

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


[PATCH 1/2] gsupplicant: Remove peer group interface when group finished

2014-09-02 Thread Eduardo Abinader
When a p2p group has finished, update corresponding peers
group interface.
---
 gsupplicant/supplicant.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 049a5b2..903def7 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2873,6 +2873,31 @@ static void signal_group_started(const char *path, 
DBusMessageIter *iter)
callback_peer_changed(peer, G_SUPPLICANT_PEER_GROUP_STARTED);
 }
 
+static void remove_peer_group_interface(GHashTable *group_table,
+   const char* path)
+{
+   GSupplicantGroup *group;
+   GHashTableIter iter;
+   gpointer value, key;
+
+   if (!group_table)
+   return;
+
+   group = g_hash_table_lookup(group_table, path);
+
+   if (!group || !group-orig_interface)
+   return;
+
+   g_hash_table_iter_init(iter, group-orig_interface-peer_table);
+
+   while (g_hash_table_iter_next(iter, key, value)) {
+   GSupplicantPeer *peer = value;
+
+   if (peer-current_group_iface == group-interface)
+   peer-current_group_iface = NULL;
+   }
+}
+
 static void signal_group_finished(const char *path, DBusMessageIter *iter)
 {
GSupplicantInterface *interface;
@@ -2888,6 +2913,8 @@ static void signal_group_finished(const char *path, 
DBusMessageIter *iter)
if (!data.interface_obj_path || !data.group_obj_path)
return;
 
+   remove_peer_group_interface(interface-group_table, 
data.group_obj_path);
+
g_hash_table_remove(interface-group_table, data.group_obj_path);
 }
 
-- 
1.9.1

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


[PATCH] service: Move dbg on service_schedule_removed after sanity check

2014-09-02 Thread Eduardo Abinader
Avoid an invalid read by moving debug message after
sanity check.
---
 src/service.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/service.c b/src/service.c
index f5c0a23..d5f95ed 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4358,13 +4358,13 @@ static void service_schedule_added(struct 
connman_service *service)
 
 static void service_schedule_removed(struct connman_service *service)
 {
-   DBG(service %p %s, service, service-path);
-
if (!service || !service-path) {
DBG(service %p or path is NULL, service);
return;
}
 
+   DBG(service %p %s, service, service-path);
+
g_hash_table_remove(services_notify-add, service-path);
g_hash_table_replace(services_notify-remove, g_strdup(service-path),
NULL);
-- 
1.9.1

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


[PATCH] gsupplicant: Add property calls to property_calls list

2014-09-02 Thread Eduardo Abinader
Although the logic for handling property call list was
available, the property call list was not being populated.
---
 gsupplicant/dbus.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gsupplicant/dbus.c b/gsupplicant/dbus.c
index 130306e..4ff5d50 100644
--- a/gsupplicant/dbus.c
+++ b/gsupplicant/dbus.c
@@ -240,6 +240,8 @@ int supplicant_dbus_property_get_all(const char *path, 
const char *interface,
property_call-function = function;
property_call-user_data = user_data;
 
+   property_calls = g_slist_prepend(property_calls, property_call);
+
dbus_pending_call_set_notify(call, property_get_all_reply,
property_call, property_call_free);
 
@@ -327,6 +329,8 @@ int supplicant_dbus_property_get(const char *path, const 
char *interface,
property_call-function = function;
property_call-user_data = user_data;
 
+   property_calls = g_slist_prepend(property_calls, property_call);
+
dbus_pending_call_set_notify(call, property_get_reply,
property_call, property_call_free);
 
@@ -419,6 +423,8 @@ int supplicant_dbus_property_set(const char *path, const 
char *interface,
property_call-function = function;
property_call-user_data = user_data;
 
+   property_calls = g_slist_prepend(property_calls, property_call);
+
dbus_pending_call_set_notify(call, property_set_reply,
property_call, property_call_free);
 
-- 
1.9.1

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


[PATCH] peer: Add debug msg for peer state

2014-08-28 Thread Eduardo Abinader
In order to ease the debug task of peer state changes, inserted
this old state/new state track.
---
 src/peer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/peer.c b/src/peer.c
index 7e733d3..d5d7c8e 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -786,6 +786,9 @@ int connman_peer_set_state(struct connman_peer *peer,
enum connman_peer_state old_state = peer-state;
int err;
 
+   DBG(peer (%s) old state %d new state %d, peer-name,
+   old_state, new_state);
+
if (old_state == new_state)
return -EALREADY;
 
-- 
1.9.1

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


[PATCH 1/2] wifi: Add an extra check for pending wifi data

2014-08-20 Thread Eduardo Abinader
Got another segmentation fault on chicken and egg issue. Now,
it is necessary to check device pointer.
---
 plugins/wifi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index f5af702..bdb4c24 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -182,7 +182,7 @@ static struct wifi_data *get_pending_wifi_data(const char 
*ifname)
const char *dev_name;
 
wifi = list-data;
-   if (!wifi)
+   if (!wifi || !wifi-device)
continue;
 
dev_name = connman_device_get_string(wifi-device, Interface);
-- 
1.9.1

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


[PATCH 0/3] Some improvement in p2p find

2014-08-15 Thread Eduardo Abinader
Hi,

Patchset v2 with Tomasz's recommendation.

The following patchset tries to improve the peer discovery,
by antecipating p2p find start, if requested, despite a wifi 
scan running. Furthermore, detects if there's an ongoing p2p 
find and returns earlier.

Thanks for feedback from Tomasz Bursztyka

Eduardo Abinader (3):
  gsupplicant: Start p2p finding even if scanning
  supplicant: Added a function to detect if p2p is finding
  wifi: Start P2P find if there's no ongoing discovery

 gsupplicant/gsupplicant.h |  1 +
 gsupplicant/supplicant.c  | 10 +-
 plugins/wifi.c|  7 ++-
 3 files changed, 16 insertions(+), 2 deletions(-)

-- 
1.9.1

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


[PATCH 2/3] supplicant: Added a function to detect if p2p is finding

2014-08-15 Thread Eduardo Abinader
Just a getter for p2p_finding status.
---
 gsupplicant/gsupplicant.h | 1 +
 gsupplicant/supplicant.c  | 8 
 2 files changed, 9 insertions(+)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 207e281..28cfe10 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -300,6 +300,7 @@ bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer);
 bool g_supplicant_peer_is_in_a_group(GSupplicantPeer *peer);
 GSupplicantInterface *g_supplicant_peer_get_group_interface(GSupplicantPeer 
*peer);
 bool g_supplicant_peer_is_client(GSupplicantPeer *peer);
+bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface);
 
 struct _GSupplicantCallbacks {
void (*system_ready) (void);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index f188d0c..1d5c813 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4647,6 +4647,14 @@ int g_supplicant_interface_p2p_find(GSupplicantInterface 
*interface,
return ret;
 }
 
+bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface)
+{
+   if (!interface)
+   return false;
+
+   return interface-p2p_finding;
+}
+
 int g_supplicant_interface_p2p_stop_find(GSupplicantInterface *interface)
 {
if (!interface-p2p_finding)
-- 
1.9.1

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


[PATCH 3/3] wifi: Start P2P find if there's no ongoing discovery

2014-08-15 Thread Eduardo Abinader
Just to avoid an amount of p2p_call, if another is
already taking place.
---
 plugins/wifi.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index f741bec..f5af702 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1376,7 +1376,7 @@ error:
 
 static int p2p_find(struct connman_device *device)
 {
-   struct wifi_data *wifi = connman_device_get_data(device);
+   struct wifi_data *wifi;
int ret;
 
DBG();
@@ -1384,6 +1384,11 @@ static int p2p_find(struct connman_device *device)
if (!p2p_technology)
return -ENOTSUP;
 
+   wifi = connman_device_get_data(device);
+
+   if (g_supplicant_interface_is_p2p_finding(wifi-interface))
+   return -EALREADY;
+
reset_autoscan(device);
connman_device_ref(device);
 
-- 
1.9.1

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


Re: [PATCH 2/3] supplicant: Added a function to detect if p2p is finding

2014-08-15 Thread Eduardo Abinader
Oh, sorry, Tomasz.

Should I resend the patchet?

On Fri, Aug 15, 2014 at 7:15 AM, Tomasz Bursztyka
tomasz.burszt...@linux.intel.com wrote:
 Very minor nitpick here: supplicant: Added a function to detect if p2p is
 finding -- gsupplicant: Add a function to detect if p2p is finding
 ___
 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: [PATCH 2/3] supplicant: Added a function to detect if p2p is finding

2014-08-15 Thread Eduardo Abinader
Thanks, Patrik.
On Aug 15, 2014 7:31 AM, Patrik Flykt patrik.fl...@linux.intel.com
wrote:

 On Fri, 2014-08-15 at 07:29 -0400, Eduardo Abinader wrote:
  Should I resend the patchet?

 I'll fix in when applying.

 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


[PATCH 2/2] wifi: Start P2P find if there's no ongoing discovery

2014-08-13 Thread Eduardo Abinader
Just to avoid an amount of p2p_call, if another is
already taking place.
---
 gsupplicant/gsupplicant.h | 2 ++
 gsupplicant/supplicant.c  | 8 
 plugins/wifi.c| 8 +++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 207e281..1e9812e 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -268,6 +268,8 @@ int 
g_supplicant_interface_set_p2p_device_config(GSupplicantInterface *interface
 GSupplicantPeer *g_supplicant_interface_peer_lookup(GSupplicantInterface 
*interface,
const char *identifier);
 
+bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface);
+
 /* Network and Peer API */
 struct _GSupplicantNetwork;
 struct _GSupplicantGroup;
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index f188d0c..1d5c813 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4647,6 +4647,14 @@ int g_supplicant_interface_p2p_find(GSupplicantInterface 
*interface,
return ret;
 }
 
+bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface)
+{
+   if (!interface)
+   return false;
+
+   return interface-p2p_finding;
+}
+
 int g_supplicant_interface_p2p_stop_find(GSupplicantInterface *interface)
 {
if (!interface-p2p_finding)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index f741bec..cd13fee 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1376,7 +1376,7 @@ error:
 
 static int p2p_find(struct connman_device *device)
 {
-   struct wifi_data *wifi = connman_device_get_data(device);
+   struct wifi_data *wifi;
int ret;
 
DBG();
@@ -1384,11 +1384,17 @@ static int p2p_find(struct connman_device *device)
if (!p2p_technology)
return -ENOTSUP;
 
+   wifi = connman_device_get_data(device);
+
+   if (g_supplicant_interface_is_p2p_finding(wifi-interface))
+   return -EALREADY;
+
reset_autoscan(device);
connman_device_ref(device);
 
ret = g_supplicant_interface_p2p_find(wifi-interface,
p2p_find_callback, device);
+
if (ret) {
connman_device_unref(device);
start_autoscan(device);
-- 
1.9.1

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


[PATCH 0/2] Some improvement in p2p find

2014-08-13 Thread Eduardo Abinader
The following patchset tries to improve the peer discovery,
by antecipating p2p find start, if requested, despite a wifi 
scan running. Furthermore, detects if there's an ongoing p2p 
find and returns earlier.

Thanks for feedback from Tomasz Bursztyka

Eduardo Abinader (2):
  gsupplicant: Start p2p finding even if scanning
  wifi: Start P2P find if there's no ongoing discovery

 gsupplicant/gsupplicant.h |  2 ++
 gsupplicant/supplicant.c  | 10 +-
 plugins/wifi.c|  8 +++-
 3 files changed, 18 insertions(+), 2 deletions(-)

-- 
1.9.1

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


[PATCH 1/2] gsupplicant: Start p2p finding even if scanning

2014-08-13 Thread Eduardo Abinader
In order to avoid deferred p2p find, if a scan is taking
place, a request to start a p2p discovery could be initiated
or scheduled (radio work add in wpa_suplicant) despite
wifi scanning.
---
 gsupplicant/supplicant.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 6dad7a9..f188d0c 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4623,7 +4623,7 @@ int g_supplicant_interface_p2p_find(GSupplicantInterface 
*interface,
return -ENOTSUP;
 
ret = interface_ready_to_scan(interface);
-   if (ret)
+   if (ret  ret != -EALREADY)
return ret;
 
data = dbus_malloc0(sizeof(*data));
-- 
1.9.1

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


[PATCH] wifi: Add sanity check in the middle of chicken and egg issue

2014-08-10 Thread Eduardo Abinader
Got a segmentation fault in the middle of a group
configuration, where the pending p2p-wlan was no
more available. This check actually comes ahead of
another one in interface_added.
---
 plugins/wifi.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 861304b..f741bec 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -178,9 +178,14 @@ static struct wifi_data *get_pending_wifi_data(const char 
*ifname)
GList *list;
 
for (list = pending_wifi_device; list; list = list-next) {
-   struct wifi_data *wifi = list-data;
-   const char *dev_name = connman_device_get_string(wifi-device,
-   Interface);
+   struct wifi_data *wifi;
+   const char *dev_name;
+
+   wifi = list-data;
+   if (!wifi)
+   continue;
+
+   dev_name = connman_device_get_string(wifi-device, Interface);
if (!g_strcmp0(ifname, dev_name)) {
pending_wifi_device = g_list_delete_link(
pending_wifi_device, list);
-- 
1.9.1

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


[PATCH] main: Change cleanup order for proper peer deinit

2014-08-10 Thread Eduardo Abinader
Cleanup is causing an invalid read during deinitialization
of an already freed ippool. Just moving the cleanup order,
ensures proper deinitialization of ippool references.
---
 src/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index 4f635de..7cf6c9a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -713,12 +713,12 @@ int main(int argc, char *argv[])
__connman_nat_cleanup();
__connman_firewall_cleanup();
__connman_iptables_cleanup();
+   __connman_peer_cleanup();
__connman_ippool_cleanup();
__connman_device_cleanup();
__connman_network_cleanup();
__connman_dhcp_cleanup();
__connman_service_cleanup();
-   __connman_peer_cleanup();
__connman_agent_cleanup();
__connman_ipconfig_cleanup();
__connman_notifier_cleanup();
-- 
1.9.1

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


[PATCH] gsupplicant: Avoid invalid read during system_killed

2014-08-10 Thread Eduardo Abinader
When terminating a connman instance with ready p2p
connection, interface_table was trying to free a
removed interface, so just inverting the deinit order,
solves the issue.
---
 gsupplicant/supplicant.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 9f63d63..6dad7a9 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4935,9 +4935,6 @@ void g_supplicant_unregister(const GSupplicantCallbacks 
*callbacks)
group_mapping = NULL;
}
 
-   if (system_available)
-   callback_system_killed();
-
if (interface_table) {
g_hash_table_foreach(interface_table,
unregister_remove_interface, NULL);
@@ -4945,6 +4942,9 @@ void g_supplicant_unregister(const GSupplicantCallbacks 
*callbacks)
interface_table = NULL;
}
 
+   if (system_available)
+   callback_system_killed();
+
if (connection) {
dbus_connection_unref(connection);
connection = NULL;
-- 
1.9.1

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


Re: [PATCH] gsupplicant: Do P2P detection after interface property load

2014-08-07 Thread Eduardo Abinader
Good news!

Thanks, Tomasz.

On Thu, Aug 7, 2014 at 7:43 AM, Tomasz Bursztyka
tomasz.burszt...@linux.intel.com wrote:
 Hi Eduardo,

 Finally it seems possible for connman to sync up with wpa_supplicant and
 existing interface
 (see patch [PATCH v2] device: Make sure the device is up and running before
 enabling it and logs
 from Richard Röjfors http://pastebin.com/4Bsk5B2N )

 So ACK to this patch!

 Tomasz
 ___
 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

[PATCH] wifi: Remove useless return statement in interface_added

2014-08-06 Thread Eduardo Abinader
Just code cleaning a meaningless return on the last
line of a void function.
---
 plugins/wifi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 70eb661..861304b 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1828,9 +1828,6 @@ static void interface_added(GSupplicantInterface 
*interface)
}
 
connman_device_set_powered(wifi-device, true);
-
-   if (wifi-tethering)
-   return;
 }
 
 static bool is_idle(struct wifi_data *wifi)
-- 
1.9.1

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


[PATCH] gsupplicant: Do P2P detection after interface property load

2014-08-06 Thread Eduardo Abinader
When interface was already created in wpa_supplicant,
p2p detection was failing. Thus, calling p2p detection
after interface property has been signaled fixes this
detection failure.
---
 gsupplicant/supplicant.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index b8ad5a2..715bac2 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -1874,6 +1874,15 @@ static void interface_bss_removed(DBusMessageIter *iter, 
void *user_data)
g_hash_table_remove(interface-network_table, network-group);
 }
 
+static void interface_detect_p2p_support(GSupplicantInterface *interface)
+{
+   SUPPLICANT_DBG(p2p detect);
+   if (interface-mode_capa  G_SUPPLICANT_CAPABILITY_MODE_P2P) {
+   interface-p2p_support = true;
+   callback_p2p_support(interface);
+   }
+}
+
 static void interface_property(const char *key, DBusMessageIter *iter,
void *user_data)
 {
@@ -1909,6 +1918,7 @@ static void interface_property(const char *key, 
DBusMessageIter *iter,
if (g_strcmp0(key, Capabilities) == 0) {
supplicant_dbus_property_foreach(iter, interface_capability,
interface);
+   interface_detect_p2p_support(interface);
} else if (g_strcmp0(key, State) == 0) {
const char *str = NULL;
 
@@ -2075,22 +2085,13 @@ static void interface_added(DBusMessageIter *iter, void 
*user_data)
supplicant_dbus_property_foreach(iter, interface_property,
interface);
interface_property(NULL, NULL, interface);
-   goto p2p_detection;
+   return;
}
 
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


[PATCH] gsupplicant: Remove duplicated interface assignment on GroupStarted

2014-08-06 Thread Eduardo Abinader
Removing a previous interface assignment, although the correct value
was assigned at last.
---
 gsupplicant/supplicant.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index b8ad5a2..61cbd93 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2844,7 +2844,6 @@ static void signal_group_started(const char *path, 
DBusMessageIter *iter)
if (!group)
return;
 
-   group-interface = interface;
group-interface = g_interface;
group-orig_interface = interface;
group-path = g_strdup(data.group_obj_path);
-- 
1.9.1

___
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


[PATCH] wifi: Free g_hash_table_get_values on connect_peer

2014-08-01 Thread Eduardo Abinader
Glist returned from g_hash_table_get_values was not
being freed during p2p connect, causing a leak.
---
 src/peer.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/peer.c b/src/peer.c
index 7f23059..1d802e1 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -480,7 +480,7 @@ static DBusMessage *connect_peer(DBusConnection *conn,
DBusMessage *msg, void *user_data)
 {
struct connman_peer *peer = user_data;
-   GList *list;
+   GList *list, *start;
int err;
 
DBG(peer %p, peer);
@@ -489,6 +489,7 @@ static DBusMessage *connect_peer(DBusConnection *conn,
return __connman_error_in_progress(msg);
 
list = g_hash_table_get_values(peers_table);
+   start = list;
for (; list; list = list-next) {
struct connman_peer *temp = list-data;
 
@@ -496,11 +497,15 @@ static DBusMessage *connect_peer(DBusConnection *conn,
continue;
 
if (is_connecting(temp) || is_connected(temp)) {
-   if (peer_disconnect(temp) == -EINPROGRESS)
+   if (peer_disconnect(temp) == -EINPROGRESS) {
+   g_list_free(start);
return __connman_error_in_progress(msg);
+   }
}
}
 
+   g_list_free(start);
+
peer-pending = dbus_message_ref(msg);
 
err = peer_connect(peer);
-- 
1.9.1

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


[PATCH] wifi: Don't allow autoscan for p2p interfaces

2014-07-31 Thread Eduardo Abinader
Accordding to p2p spec, a p2p device is not supposed to carry
wifi scan, specially a client device. Thus this patch avoids
autoscan and solves a segmentation fault issue occuring in
g_supplicant_interface_autoscan, due to a null interface
pointer.
---
 plugins/wifi.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index ce6d7e7..a44eb37 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -955,6 +955,9 @@ static void start_autoscan(struct connman_device *device)
if (!wifi)
return;
 
+   if (wifi-p2p_device)
+   return;
+
autoscan = wifi-autoscan;
if (!autoscan)
return;
@@ -1039,6 +1042,9 @@ static void finalize_interface_creation(struct wifi_data 
*wifi)
if (!connman_setting_get_bool(BackgroundScanning))
return;
 
+   if (wifi-p2p_device)
+   return;
+
/* Setting up automatic scanning */
if (g_supplicant_interface_autoscan(interface, AUTOSCAN_DEFAULT,
interface_autoscan_callback, wifi)  0) {
-- 
1.9.1

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


[PATCH 1/1] Update p2p scan status, when disabling wifi

2014-07-29 Thread Eduardo Abinader
Whenever wifi plugin is disabled and p2p find is running,
a double device unref was occurring. By setting scanning to
false, avoids duplicated device unref.
---
 plugins/wifi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index ce6d7e7..5f383bd 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1119,6 +1119,7 @@ static int wifi_disable(struct connman_device *device)
if (wifi-p2p_find_timeout) {
g_source_remove(wifi-p2p_find_timeout);
wifi-p2p_find_timeout = 0;
+   connman_device_set_scanning(device, CONNMAN_SERVICE_TYPE_P2P, 
false);
connman_device_unref(wifi-device);
}
 
-- 
1.9.1

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


[PATCH 1/1 v2] wifi: Update p2p scan status, when disabling wifi

2014-07-29 Thread Eduardo Abinader
Whenever wifi plugin is disabled and p2p find is running,
a double device unref was occurring. By setting scanning to
false, avoids duplicated device unref.
---
 plugins/wifi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index ce6d7e7..5f383bd 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1119,6 +1119,7 @@ static int wifi_disable(struct connman_device *device)
if (wifi-p2p_find_timeout) {
g_source_remove(wifi-p2p_find_timeout);
wifi-p2p_find_timeout = 0;
+   connman_device_set_scanning(device, CONNMAN_SERVICE_TYPE_P2P, 
false);
connman_device_unref(wifi-device);
}
 
-- 
1.9.1

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


[PATCH 2/2] Let dhcp_server_unref stop dhcp_server

2014-07-24 Thread Eduardo Abinader
P2P peer was explicit stopping dhcp_server besides dhcp_server_unref,
which already takes care of server stopping.
---
 src/peer.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/peer.c b/src/peer.c
index 39877ec..3107f0a 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -62,7 +62,6 @@ static void stop_dhcp_server(struct connman_peer *peer)
DBG();
 
if (peer-dhcp_server) {
-   g_dhcp_server_stop(peer-dhcp_server);
g_dhcp_server_unref(peer-dhcp_server);
}
peer-dhcp_server = NULL;
-- 
1.9.1

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


[PATCH 1/2] Check wifi plugin exists before removing peer

2014-07-24 Thread Eduardo Abinader
Do sanity check before using wifi pointer on
peer_lost.
---
 plugins/wifi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index eb1fad0..ce6d7e7 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2291,6 +2291,9 @@ static void peer_lost(GSupplicantPeer *peer)
struct connman_peer *connman_peer;
const char *identifier;
 
+   if (!wifi)
+   return;
+
identifier = g_supplicant_peer_get_identifier(peer);
 
DBG(ident: %s, identifier);
-- 
1.9.1

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


[PATCH 2/2] Let dhcp_server_unref stop dhcp_server

2014-07-24 Thread Eduardo Abinader
P2P peer was explicit stopping dhcp_server besides dhcp_server_unref,
which already takes care of server stopping.
---
 src/peer.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/peer.c b/src/peer.c
index 39877ec..d627487 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -61,10 +61,9 @@ static void stop_dhcp_server(struct connman_peer *peer)
 {
DBG();
 
-   if (peer-dhcp_server) {
-   g_dhcp_server_stop(peer-dhcp_server);
+   if (peer-dhcp_server)
g_dhcp_server_unref(peer-dhcp_server);
-   }
+
peer-dhcp_server = NULL;
 
if (peer-ip_pool)
-- 
1.9.1

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


[PATCH 0/2 v2] Avoid segfault on connman deinitialization

2014-07-24 Thread Eduardo Abinader
Applied change Tomasz has requested on this patchset v2.

Eduardo Abinader (2):
  Check wifi plugin exists before removing peer
  Let dhcp_server_unref stop dhcp_server

 plugins/wifi.c | 3 +++
 src/peer.c | 5 ++---
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
1.9.1

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


[PATCH 1/1] test: Set command_list properly

2014-05-28 Thread Eduardo Abinader
Command list passed to wpa_s was not being extracted from
arg list, but storing the whole list. This caused the help
to be buggy.
---
 test/p2p-on-supplicant | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 3e6f277..826656e 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -351,7 +351,7 @@ class Wpa_s:
 
 @checkarg(nb_args=1)
 def set_command_list(self, command_list):
-self.command_list = command_list
+self.command_list = command_list[0]
 
 @checkarg()
 def p2p_find(self, args = None):
-- 
1.9.1

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


Re: [PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-14 Thread Eduardo Abinader
Hi Tomasz,
On Wed, May 14, 2014 at 2:54 AM, Tomasz Bursztyka
tomasz.burszt...@linux.intel.com wrote:
 Hi Eduardo,

 Minor issue:

 @@ -100,37 +105,33 @@ class Wpa_s:
   bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
   signal_name='InterfaceRemoved')
   self.__reset()
 +
 +self.debug = False


 unnecessary since it's done below already.

Should I resend the patch or send a new one fixing this issue?


 +
 +self.bus = bus
 +
   self.debug = False




 Rest is fine.

 Thanks,

Thanks.


 Tomasz

 ___
 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


[PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-14 Thread Eduardo Abinader
Argument parsing functionality for commands and options:
- dbus is now wpa_s property
- help is being shown from the command_list built in arg
parse time
- Added enum like class (ArgFields) for future options in arg
parsing
---
 test/p2p-on-supplicant | 174 +++--
 1 file changed, 126 insertions(+), 48 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 734396e..025bf6e 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -1,12 +1,13 @@
 #!/usr/bin/python
 
 from os import O_NONBLOCK
-from sys import stdin, stdout, exit, version_info
+from sys import stdin, stdout, exit, version_info, argv
 from fcntl import fcntl, F_GETFL, F_SETFL
 import glib
 import dbus
 import dbus.mainloop.glib
 import gobject
+import argparse
 
 WPA_NAME='fi.w1.wpa_supplicant1'
 WPA_INTF='fi.w1.wpa_supplicant1'
@@ -19,6 +20,10 @@ DBUS_PROPERTIES_INTF = 'org.freedesktop.DBus.Properties'
 
 P2P_GROUP_CAPAB_GROUP_OWNER = 1  0
 
+class ArgFields:
+for i in ('help','metavar'):
+exec('{}={}'.format(i,i))
+
 class InputLine:
 def __init__(self, handler):
 self.line = ''
@@ -91,7 +96,7 @@ def print_tuple(t):
 print 'Element: %s' % e
 
 class Wpa_s:
-def __init__(self, iface_name = None):
+def __init__(self, bus, iface_name, command):
 self.wpa = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), WPA_INTF)
 bus.add_signal_receiver(self.__wpa_property_changed, path=WPA_PATH,
 member_keyword='signal')
@@ -100,37 +105,31 @@ class Wpa_s:
 bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
 signal_name='InterfaceRemoved')
 self.__reset()
+
+self.bus = bus
+
 self.debug = False
 
 self.line_in = InputLine(self.__command)
 
-if self.iface_name != None:
-self.create_if(self.iface_name)
+if iface_name:
+try:
+self.create_if([iface_name])
+except:
+print Error creating interface: %s % iface_name
+
+if len(command.strip(' ')):
+self.__command(command)
 
 def help(self, args):
-print 'Commands:'
-print 'quit'
-print 'enable_debug'
-print 'disable_debug'
-print 'create_if iface_name'
-print 'get_if iface_name'
-print 'del_if'
-print 'scan'
-print 'p2p_find'
-print 'p2p_stop_find'
-print 'p2p_flush'
-print 'p2p_group_add'
-print 'p2p_group_remove'
-print 'p2p_group'
-print 'p2p_peers'
-print 'p2p_peer p2p device name'
-print 'p2p_connect p2p device name'
-print 'p2p_disconnect p2p device name'
-print 'p2p_serv_disc_req'
-print 'p2p_serv_disc_cancel_req identifier'
-print 'p2p_service_add service type version/query 
service/response'
-print 'p2p_service_del service type version/query [service]'
-print 'p2p_service_flush'
+list = self.command_list.keys()
+list.sort()
+for key in list:
+help = ''
+if (self.command_list[key].has_key(ArgFields.help)):
+help = self.command_list[key][ArgFields.help]
+
+print %s\t%s % (key.rjust(25), help.ljust(50))
 
 def __command(self, cmd_line):
 cmd = cmd_line.split(' ')
@@ -172,7 +171,7 @@ class Wpa_s:
 def __DeviceFound(self, object_path):
 self.peers[object_path] = None
 
-peer = bus.get_object(WPA_INTF, object_path)
+peer = self.bus.get_object(WPA_INTF, object_path)
 peer_if = dbus.Interface(peer, DBUS_PROPERTIES_INTF)
 
 self.peers[object_path] = peer_if.GetAll(WPA_PEER_INTF)
@@ -201,35 +200,36 @@ class Wpa_s:
 
 def __GroupStarted(self, properties):
 self.group_obj = properties['group_object']
-bus.add_signal_receiver(self.__PeerJoined,
+self.bus.add_signal_receiver(self.__PeerJoined,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerJoined')
-bus.add_signal_receiver(self.__PeerDisconnected,
+self.bus.add_signal_receiver(self.__PeerDisconnected,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerDisconnected')
 
 self.group_iface_path = properties['interface_object']
-self.group_if = dbus.Interface(bus.get_object(WPA_INTF,
+self.group_if = dbus.Interface(self.bus.get_object(WPA_INTF,
self.group_iface_path),
WPA_P2P_INTF)
-bus.add_signal_receiver(self.__group_if_property_changed,
+

[PATCH 1/2] test: Minor typos removal in p2p-on-supplicant

2014-05-14 Thread Eduardo Abinader
Removed minor typo issues in p2p-on-supplicant.
---
 test/p2p-on-supplicant | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index e845c88..734396e 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -185,7 +185,7 @@ class Wpa_s:
 print 'Peer %s joined' % object_path
 
 def __PeerDisconnected(self, object_path):
-print 'Peer %s dictonnected' % object_path
+print 'Peer %s disconnected' % object_path
 
 def __group_if_property_changed(*args, **kwargs):
 print 'Group - ',
@@ -299,7 +299,7 @@ class Wpa_s:
 self.debug = True
 
 @checkarg()
-def disable_debug(serf, args):
+def disable_debug(self, args):
 self.debug = False
 
 @checkarg(nb_args=1)
-- 
1.9.1

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


[PATCH 2/2] test: Added P2P invite call and signal result

2014-05-14 Thread Eduardo Abinader
Invite discovered P2P peer to join or form a
group.
---
 test/p2p-on-supplicant | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 68b4996..3e6f277 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -198,6 +198,15 @@ class Wpa_s:
 print 'Group running on %s is being removed' % ifname
 self.group_obj = self.group_if = self.group_iface_path = None
 
+def __InvitationResult(self, response):
+print 'Invitation result status: %d ' % response['status']
+
+if response.has_key('bssid'):
+print 'bssid: %s' % response['bssid']
+
+if self.debug:
+print_dict(response)
+
 def __GroupStarted(self, properties):
 self.group_obj = properties['group_object']
 self.bus.add_signal_receiver(self.__PeerJoined,
@@ -225,6 +234,10 @@ class Wpa_s:
 dbus_interface=WPA_P2P_INTF,
 path=self.group_iface_path,
 member_keyword='signal')
+self.bus.add_signal_receiver(self.__InvitationResult,
+dbus_interface=WPA_P2P_INTF,
+path=self.iface_path,
+signal_name='InvitationResult')
 
 if self.debug:
 group = dbus.Interface(self.bus.get_object(WPA_INTF,
@@ -521,6 +534,18 @@ class Wpa_s:
 
 self.p2p.FlushService()
 
+@checkarg(nb_args = 1)
+def p2p_invite(self, args):
+if not self.p2p or not self.group_if:
+return
+
+peer_path = self.__find_peer(args[0], True)
+
+if not peer_path:
+return
+
+self.group_if.Invite({ 'peer' : peer_path})
+
 def build_args(parser):
 parser.add_argument('-d', default=False, action='store_true',
dest='debug', help='enable debug')
@@ -553,6 +578,7 @@ def build_args(parser):
 command['p2p_service_del'] = {ArgFields.help:'service type '
   'version/query [service]'}
 command['p2p_service_flush'] = {}
+command['p2p_invite'] = {ArgFields.help:'p2p device name'}
 
 command_list = command.keys()
 command_list.sort()
-- 
1.9.1

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


[PATCH 1/2] test: Fix code style in p2p-on-supplicant

2014-05-14 Thread Eduardo Abinader
Just complying to code style.
---
 test/p2p-on-supplicant | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 025bf6e..68b4996 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -21,8 +21,8 @@ DBUS_PROPERTIES_INTF = 'org.freedesktop.DBus.Properties'
 P2P_GROUP_CAPAB_GROUP_OWNER = 1  0
 
 class ArgFields:
-for i in ('help','metavar'):
-exec('{}={}'.format(i,i))
+for field in ('help', 'metavar'):
+exec('{}={}'.format(field, field))
 
 class InputLine:
 def __init__(self, handler):
@@ -522,7 +522,6 @@ class Wpa_s:
 self.p2p.FlushService()
 
 def build_args(parser):
-
 parser.add_argument('-d', default=False, action='store_true',
dest='debug', help='enable debug')
 parser.add_argument('-i', metavar='interface', dest='ifname',
-- 
1.9.1

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


[PATCH 0/2] test: Code style issues and P2P Invite

2014-05-14 Thread Eduardo Abinader
This patchset solves code style minor issues and adds
P2P invite and its signal.

Eduardo Abinader (2):
  test: Fix code style in p2p-on-supplicant
  test: Added P2P invite call and signal result

 test/p2p-on-supplicant | 31 ---
 1 file changed, 28 insertions(+), 3 deletions(-)

-- 
1.9.1

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


[PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-13 Thread Eduardo Abinader
Argument parsing functionality for commands and options.
---
 test/p2p-on-supplicant | 176 +++--
 1 file changed, 128 insertions(+), 48 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 734396e..bc10ad2 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -1,12 +1,13 @@
 #!/usr/bin/python
 
 from os import O_NONBLOCK
-from sys import stdin, stdout, exit, version_info
+from sys import stdin, stdout, exit, version_info, argv
 from fcntl import fcntl, F_GETFL, F_SETFL
 import glib
 import dbus
 import dbus.mainloop.glib
 import gobject
+import argparse
 
 WPA_NAME='fi.w1.wpa_supplicant1'
 WPA_INTF='fi.w1.wpa_supplicant1'
@@ -19,6 +20,10 @@ DBUS_PROPERTIES_INTF = 'org.freedesktop.DBus.Properties'
 
 P2P_GROUP_CAPAB_GROUP_OWNER = 1  0
 
+class ArgFields:
+for i in ('help','metavar'):
+exec('{}={}'.format(i,i))
+
 class InputLine:
 def __init__(self, handler):
 self.line = ''
@@ -91,7 +96,7 @@ def print_tuple(t):
 print 'Element: %s' % e
 
 class Wpa_s:
-def __init__(self, iface_name = None):
+def __init__(self, bus, iface_name, command):
 self.wpa = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), WPA_INTF)
 bus.add_signal_receiver(self.__wpa_property_changed, path=WPA_PATH,
 member_keyword='signal')
@@ -100,37 +105,33 @@ class Wpa_s:
 bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
 signal_name='InterfaceRemoved')
 self.__reset()
+
+self.debug = False
+
+self.bus = bus
+
 self.debug = False
 
 self.line_in = InputLine(self.__command)
 
-if self.iface_name != None:
-self.create_if(self.iface_name)
+if iface_name:
+try:
+self.create_if([iface_name])
+except:
+print Error creating interface: %s % iface_name
+
+if len(command.strip(' ')):
+self.__command(command)
 
 def help(self, args):
-print 'Commands:'
-print 'quit'
-print 'enable_debug'
-print 'disable_debug'
-print 'create_if iface_name'
-print 'get_if iface_name'
-print 'del_if'
-print 'scan'
-print 'p2p_find'
-print 'p2p_stop_find'
-print 'p2p_flush'
-print 'p2p_group_add'
-print 'p2p_group_remove'
-print 'p2p_group'
-print 'p2p_peers'
-print 'p2p_peer p2p device name'
-print 'p2p_connect p2p device name'
-print 'p2p_disconnect p2p device name'
-print 'p2p_serv_disc_req'
-print 'p2p_serv_disc_cancel_req identifier'
-print 'p2p_service_add service type version/query 
service/response'
-print 'p2p_service_del service type version/query [service]'
-print 'p2p_service_flush'
+list = self.command_list.keys()
+list.sort()
+for key in list:
+help = ''
+if (self.command_list[key].has_key(ArgFields.help)):
+help = self.command_list[key][ArgFields.help]
+
+print %s\t%s % (key.rjust(25), help.ljust(50))
 
 def __command(self, cmd_line):
 cmd = cmd_line.split(' ')
@@ -172,7 +173,7 @@ class Wpa_s:
 def __DeviceFound(self, object_path):
 self.peers[object_path] = None
 
-peer = bus.get_object(WPA_INTF, object_path)
+peer = self.bus.get_object(WPA_INTF, object_path)
 peer_if = dbus.Interface(peer, DBUS_PROPERTIES_INTF)
 
 self.peers[object_path] = peer_if.GetAll(WPA_PEER_INTF)
@@ -201,35 +202,36 @@ class Wpa_s:
 
 def __GroupStarted(self, properties):
 self.group_obj = properties['group_object']
-bus.add_signal_receiver(self.__PeerJoined,
+self.bus.add_signal_receiver(self.__PeerJoined,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerJoined')
-bus.add_signal_receiver(self.__PeerDisconnected,
+self.bus.add_signal_receiver(self.__PeerDisconnected,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerDisconnected')
 
 self.group_iface_path = properties['interface_object']
-self.group_if = dbus.Interface(bus.get_object(WPA_INTF,
+self.group_if = dbus.Interface(self.bus.get_object(WPA_INTF,
self.group_iface_path),
WPA_P2P_INTF)
-bus.add_signal_receiver(self.__group_if_property_changed,
+self.bus.add_signal_receiver(self.__group_if_property_changed,
 dbus_interface=WPA_IF_INTF,
 path=self.group_iface_path,
  

[PATCH 1/2] test: Minor typos removal in p2p-on-supplicant

2014-05-13 Thread Eduardo Abinader
Removed minor typo issues in p2p-on-supplicant.
---
 test/p2p-on-supplicant | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index e845c88..734396e 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -185,7 +185,7 @@ class Wpa_s:
 print 'Peer %s joined' % object_path
 
 def __PeerDisconnected(self, object_path):
-print 'Peer %s dictonnected' % object_path
+print 'Peer %s disconnected' % object_path
 
 def __group_if_property_changed(*args, **kwargs):
 print 'Group - ',
@@ -299,7 +299,7 @@ class Wpa_s:
 self.debug = True
 
 @checkarg()
-def disable_debug(serf, args):
+def disable_debug(self, args):
 self.debug = False
 
 @checkarg(nb_args=1)
-- 
1.9.1

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


[PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-13 Thread Eduardo Abinader
Argument parsing functionality for commands and options.
---
 test/p2p-on-supplicant | 176 +++--
 1 file changed, 128 insertions(+), 48 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 734396e..7930242 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -1,12 +1,13 @@
 #!/usr/bin/python
 
 from os import O_NONBLOCK
-from sys import stdin, stdout, exit, version_info
+from sys import stdin, stdout, exit, version_info, argv
 from fcntl import fcntl, F_GETFL, F_SETFL
 import glib
 import dbus
 import dbus.mainloop.glib
 import gobject
+import argparse
 
 WPA_NAME='fi.w1.wpa_supplicant1'
 WPA_INTF='fi.w1.wpa_supplicant1'
@@ -19,6 +20,10 @@ DBUS_PROPERTIES_INTF = 'org.freedesktop.DBus.Properties'
 
 P2P_GROUP_CAPAB_GROUP_OWNER = 1  0
 
+class ArgFields:
+for i in ('help','metavar'):
+exec('{}={}'.format(i,i))
+
 class InputLine:
 def __init__(self, handler):
 self.line = ''
@@ -91,7 +96,7 @@ def print_tuple(t):
 print 'Element: %s' % e
 
 class Wpa_s:
-def __init__(self, iface_name = None):
+def __init__(self, bus, iface_name, command):
 self.wpa = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), WPA_INTF)
 bus.add_signal_receiver(self.__wpa_property_changed, path=WPA_PATH,
 member_keyword='signal')
@@ -100,37 +105,33 @@ class Wpa_s:
 bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
 signal_name='InterfaceRemoved')
 self.__reset()
+
+self.debug = False
+
+self.bus = bus
+
 self.debug = False
 
 self.line_in = InputLine(self.__command)
 
-if self.iface_name != None:
-self.create_if(self.iface_name)
+if iface_name:
+try:
+self.create_if([iface_name])
+except:
+print Error creating interface: %s % iface_name
+
+if len(command.strip(' ')):
+self.__command(command)
 
 def help(self, args):
-print 'Commands:'
-print 'quit'
-print 'enable_debug'
-print 'disable_debug'
-print 'create_if iface_name'
-print 'get_if iface_name'
-print 'del_if'
-print 'scan'
-print 'p2p_find'
-print 'p2p_stop_find'
-print 'p2p_flush'
-print 'p2p_group_add'
-print 'p2p_group_remove'
-print 'p2p_group'
-print 'p2p_peers'
-print 'p2p_peer p2p device name'
-print 'p2p_connect p2p device name'
-print 'p2p_disconnect p2p device name'
-print 'p2p_serv_disc_req'
-print 'p2p_serv_disc_cancel_req identifier'
-print 'p2p_service_add service type version/query 
service/response'
-print 'p2p_service_del service type version/query [service]'
-print 'p2p_service_flush'
+list = self.command_list.keys()
+list.sort()
+for key in list:
+help = ''
+if (self.command_list[key].has_key(ArgFields.help)):
+help = self.command_list[key][ArgFields.help]
+
+print %s\t%s % (key.rjust(25), help.ljust(50))
 
 def __command(self, cmd_line):
 cmd = cmd_line.split(' ')
@@ -172,7 +173,7 @@ class Wpa_s:
 def __DeviceFound(self, object_path):
 self.peers[object_path] = None
 
-peer = bus.get_object(WPA_INTF, object_path)
+peer = self.bus.get_object(WPA_INTF, object_path)
 peer_if = dbus.Interface(peer, DBUS_PROPERTIES_INTF)
 
 self.peers[object_path] = peer_if.GetAll(WPA_PEER_INTF)
@@ -201,35 +202,36 @@ class Wpa_s:
 
 def __GroupStarted(self, properties):
 self.group_obj = properties['group_object']
-bus.add_signal_receiver(self.__PeerJoined,
+self.bus.add_signal_receiver(self.__PeerJoined,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerJoined')
-bus.add_signal_receiver(self.__PeerDisconnected,
+self.bus.add_signal_receiver(self.__PeerDisconnected,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerDisconnected')
 
 self.group_iface_path = properties['interface_object']
-self.group_if = dbus.Interface(bus.get_object(WPA_INTF,
+self.group_if = dbus.Interface(self.bus.get_object(WPA_INTF,
self.group_iface_path),
WPA_P2P_INTF)
-bus.add_signal_receiver(self.__group_if_property_changed,
+self.bus.add_signal_receiver(self.__group_if_property_changed,
 dbus_interface=WPA_IF_INTF,
 path=self.group_iface_path,
  

[PATCH 1/2] test: Minor typos removal in p2p-on-supplicant

2014-05-13 Thread Eduardo Abinader
Removed minor typo issues in p2p-on-supplicant.
---
 test/p2p-on-supplicant | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index e845c88..734396e 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -185,7 +185,7 @@ class Wpa_s:
 print 'Peer %s joined' % object_path
 
 def __PeerDisconnected(self, object_path):
-print 'Peer %s dictonnected' % object_path
+print 'Peer %s disconnected' % object_path
 
 def __group_if_property_changed(*args, **kwargs):
 print 'Group - ',
@@ -299,7 +299,7 @@ class Wpa_s:
 self.debug = True
 
 @checkarg()
-def disable_debug(serf, args):
+def disable_debug(self, args):
 self.debug = False
 
 @checkarg(nb_args=1)
-- 
1.9.1

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


[PATCH 0/2] Improvements for p2p-on-supplicant

2014-05-13 Thread Eduardo Abinader
Please consider this patchset, instead of previously sent
patchset. 

Eduardo Abinader (2):
  test: Minor typos removal in p2p-on-supplicant
  test: Arg parsing for p2p-on-supplication

 test/p2p-on-supplicant | 180 +++--
 1 file changed, 130 insertions(+), 50 deletions(-)

-- 
1.9.1

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


Re: Connman crashes when loosing network

2014-05-01 Thread Eduardo Abinader
Could you please try with HEAD version and pastebin the logs? Saw a
refcount issue in:
05/01/14 09:56:55 AM   connmand[26030]:
src/ipconfig.c:__connman_ipconfig_unref_debug() 0xa9fd8 ref -1 by
src/ipconfig.c:1707:__connman_ipconfig_disable()

But I don't know which version your are actually running.


On Thu, May 1, 2014 at 4:05 AM, Marcel Mulder mmul...@victronenergy.comwrote:

 Hi All,

 I experience reproducible connman crashes with version v1.20, v1.21,
 v1.22, v1.23 and HEAD of git. Older version I did not try.
 The situation is as follow:
 I have a controller (AM3547 from TI, ARM Cortex-A8) attached to a Wifi
 extender by wire. The Wifi extender is connected to a Wifi access point
 which is connect to our network. If the connection are up and running
 everything works well. When I however turn off the Wifi access point
 connman crashes with a segmentation fault (see log below). I have seen more
 connman crashes when networks are coming and going but there were not so
 nicely reproducible as this one.

 For cross compiling I use Yocto-Poky (OpenEmbedded).
 If you need more information, e.g. Wireshark logs or other kind of
 information I am happy to provide this.
 Connman was started with: connmand -d -n --nobacktrace -r
 But also with dnsproxy connman crashes. When I restart connman in this
 situation it ends in a seg fault again. When the connection to the Wifi
 access point is restored connman starts without problems.

 Hope someone can help me because this is a serious problem for us.

 Best regards,

 Marcel

 

 05/01/14 09:56:37 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_append_ipv4()
 05/01/14 09:56:37 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_append_ipv4config()
 05/01/14 09:56:37 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_append_ipv6config()
 05/01/14 09:56:37 AM   connmand[26030]:
 src/service.c:append_nameservers() servers[0] 192.168.4.13 available 1
 05/01/14 09:56:37 AM   connmand[26030]:
 src/service.c:append_nameservers() servers[1] 192.168.1.26 available 1
 05/01/14 09:56:37 AM   connmand[26030]:
 src/storage.c:storage_load() Loading /var/lib/connman/settings
 05/01/14 09:56:45 AM   connmand[26030]: src/rtnl.c:rtnl_message()
 buf 0xbea8ab18 len 576
 05/01/14 09:56:45 AM   connmand[26030]: src/rtnl.c:rtnl_message()
 NEWLINK len 576 type 16 flags 0x seq 0 pid 0
 05/01/14 09:56:45 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_newlink() index 3
 05/01/14 09:56:45 AM   connmand[26030]: eth0 {RX} 38268 packets
 4322051 bytes
 05/01/14 09:56:45 AM   connmand[26030]: eth0 {TX} 31213 packets
 3869059 bytes
 05/01/14 09:56:45 AM   connmand[26030]:
 src/service.c:stats_update() service 0xad800
 05/01/14 09:56:45 AM   connmand[26030]: eth0 {update} flags 36867
 UP
 05/01/14 09:56:45 AM   connmand[26030]:
 src/service.c:service_lower_down() eth0 lower down
 05/01/14 09:56:45 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_disable() ipconfig 0xac3e0
 05/01/14 09:56:45 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_unref_debug() 0xac3e0 ref 1 by
 src/ipconfig.c:1694:__connman_ipconfig_disable()
 05/01/14 09:56:45 AM   connmand[26030]: src/service.c:stats_stop()
 service 0xad800
 05/01/14 09:56:45 AM   connmand[26030]:
 src/service.c:service_save() service 0xad800 new 0
 05/01/14 09:56:45 AM   connmand[26030]:
 src/storage.c:storage_load() Loading
 /var/lib/connman/ethernet_5056631d05ad_cable/settings
 05/01/14 09:56:45 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_save() ipconfig 0xac3e0 identifier
 ethernet_5056631d05ad_cable method dhcp
 05/01/14 09:56:45 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_save() ipconfig 0xa9fd8 identifier
 ethernet_5056631d05ad_cable method off
 05/01/14 09:56:45 AM   connmand[26030]:
 src/ipconfig.c:__connman_ipconfig_lower_down() ipconfig ipv4 (nil) ipv6
 0xa9fd8
 05/01/14 09:56:45 AM   connmand[26030]:
 src/inet.c:connman_inet_clear_ipv6_address() index 3 address (null)
 prefix_len 0
 05/01/14 09:56:45 AM   connmand[26030]: eth0 {newlink} index 3
 address 50:56:63:1D:05:AD mtu 1500
 05/01/14 09:56:45 AM   connmand[26030]: eth0 {newlink} index 3
 operstate 2 DOWN
 05/01/14 09:56:45 AM   connmand[26030]:
 src/detect.c:detect_newlink() type 1 index 3
 05/01/14 09:56:45 AM   connmand[26030]:
 plugins/ethernet.c:ethernet_newlink() index 3 flags 36867 change 0
 05/01/14 09:56:45 AM   connmand[26030]:
 plugins/ethernet.c:ethernet_newlink() carrier off
 05/01/14 09:56:45 AM   connmand[26030]:
 src/device.c:connman_device_remove_network() device 0xacf88 network 0xaaf10
 05/01/14 09:56:45 AM   connmand[26030]:
 src/device.c:free_network() network 0xaaf10
 

[PATCH 0/2] Device detection upon systemd-udev renaming

2014-04-29 Thread Eduardo Abinader
The following two patches are related somehow in the
scenario where wifi dongle is removed and inserted again,
and systemd-udev renames device. 
Sytemd-udev may have predefined device names, which does 
not necessarily follow kernel device sequential 
numbering. The renaming of the device causes the kernel 
to issue a new RTM_NEWLINK, but keeping same ifindex, thus 
falling in a scenario where connman is unable to handle 
currently. Observe there is no RTM_DELLINK message being 
issued in this rename action.

Patch(1/2): tried to rely on ifi_change, but I do not feel
secure to use it, as it is still stated to be set as
0xfff and reserved for future use, although have found
a pattern for the values filled in by rtnetlink by running and 
also taking a look at kernel code. 
(refer also to this link: 
https://lists.connman.net/pipermail/connman/2012-September/011232.html)

Patch(2/2): while preparing this patch, noticed segfault in 
scan_callback, when removing wifi dongle. Thus the second 
patch refers to this occurrence.

Eduardo Abinader (2):
  Don't ignore RTM_NEWLINK, when ifname has changed
  Avoid invalid read in scan_callback

 gsupplicant/supplicant.c |  3 +++
 include/device.h |  1 +
 src/detect.c | 15 +--
 src/device.c | 20 
 4 files changed, 37 insertions(+), 2 deletions(-)

-- 
1.9.1

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


[PATCH 1/2] Don't ignore RTM_NEWLINK, when ifname has changed

2014-04-29 Thread Eduardo Abinader
Whenever systemd-udev renames a device, the orginal ifindex
is kept and consequently connman is unable to issue a proper
create interface to reflect such device change.
---
 include/device.h |  1 +
 src/detect.c | 15 +--
 src/device.c | 20 
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/include/device.h b/include/device.h
index 57b925c..9d4fa35 100644
--- a/include/device.h
+++ b/include/device.h
@@ -114,6 +114,7 @@ void connman_device_regdom_notify(struct connman_device 
*device,
 struct connman_device *connman_device_create_from_index(int index);
 struct connman_device *connman_device_find_by_index(int index);
 int connman_device_reconnect_service(struct connman_device *device);
+bool connman_device_ifname_changed(struct connman_device *device, int index);
 
 struct connman_device_driver {
const char *name;
diff --git a/src/detect.c b/src/detect.c
index 6c03920..2fc7f0a 100644
--- a/src/detect.c
+++ b/src/detect.c
@@ -43,6 +43,9 @@ static struct connman_device *find_device(int index)
return NULL;
 }
 
+static void detect_dellink(unsigned short type, int index,
+   unsigned flags, unsigned change);
+
 static void detect_newlink(unsigned short type, int index,
unsigned flags, unsigned change)
 {
@@ -67,8 +70,16 @@ static void detect_newlink(unsigned short type, int index,
}
 
device = find_device(index);
-   if (device)
-   return;
+   if (device) {
+   /*
+* Detect if device name has changed, despite same index
+* If so, proceed with dellink and new device registering.
+*/
+   if (!connman_device_ifname_changed(device, index))
+   return;
+   else
+   detect_dellink(type, index, flags, change);
+   }
 
device = connman_device_create_from_index(index);
if (!device)
diff --git a/src/device.c b/src/device.c
index f0b7a4f..789c586 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1456,3 +1456,23 @@ void __connman_device_cleanup(void)
g_strfreev(nodevice_filter);
g_strfreev(device_filter);
 }
+
+bool connman_device_ifname_changed(struct connman_device *device, int index)
+{
+   char *ifname;
+   bool ret = false;
+
+   DBG();
+
+   ifname = connman_inet_ifname(index);
+   if (!ifname)
+   return ret;
+
+   if (strcmp(device-interface, ifname) != 0) {
+   ret = true;
+   }
+
+   g_free(ifname);
+
+   return ret;
+}
-- 
1.9.1

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


[PATCH 2/2] Avoid invalid read in scan_callback

2014-04-29 Thread Eduardo Abinader
If a pending scan_callback is called after a dongle removal,
invalid reads occur in connman_device_reset_scanning, for
instance. This patch cleans the callback, before dbus remove
interface is returned.
---
 gsupplicant/supplicant.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 9734e48..8a16663 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -745,6 +745,9 @@ void g_supplicant_interface_set_data(GSupplicantInterface 
*interface,
return;
 
interface-data = data;
+
+   if (!data)
+   interface-scan_callback = NULL;
 }
 
 void *g_supplicant_interface_get_data(GSupplicantInterface *interface)
-- 
1.9.1

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


Re: [PATCH 2/2] Avoid network duplicate unref for eth_dev_remote

2014-04-17 Thread Eduardo Abinader
Hi Tomasz,

Below you find my valgrind output.

As you mentioned, the network reference device is freeing is the the one it
creates, in this case, it is created in eth_newlink. I could not see any
network referenced by eth which is not via device, so that's the reason I
patched by removing network_unref and letting device manage it by its own.


Cheers.

=
==23771== Invalid read of size 4
==23771==at 0x445A0F: connman_network_unref_debug (network.c:1037)
==23771==by 0x41F5A5: remove_network (ethernet.c:131)
==23771==by 0x41F86E: eth_dev_remove (ethernet.c:197)
==23771==by 0x4420C6: remove_device (device.c:295)
==23771==by 0x442149: remove_driver (device.c:310)
==23771==by 0x44229C: connman_device_driver_unregister (device.c:363)
==23771==by 0x41FCBD: ethernet_exit (ethernet.c:365)
==23771==by 0x440C45: __connman_plugin_cleanup (plugin.c:200)
==23771==by 0x43F5FB: main (main.c:697)
==23771==  Address 0x7917d20 is 0 bytes inside a block of size 232 free'd
==23771==at 0x4C2BCD7: free (vg_replace_malloc.c:469)
==23771==by 0x445863: network_destruct (network.c:968)
==23771==by 0x445A98: connman_network_unref_debug (network.c:1045)
==23771==by 0x44230B: free_network (device.c:374)
==23771==by 0x4E6D8F9: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==23771==by 0x44310F: connman_device_remove_network (device.c:901)
==23771==by 0x41F586: remove_network (ethernet.c:130)
==23771==by 0x41F86E: eth_dev_remove (ethernet.c:197)
==23771==by 0x4420C6: remove_device (device.c:295)
==23771==by 0x442149: remove_driver (device.c:310)
==23771==by 0x44229C: connman_device_driver_unregister (device.c:363)
==23771==by 0x41FCBD: ethernet_exit (ethernet.c:365)
==23771==
==23771== Invalid read of size 8
==23771==at 0x445A18: connman_network_unref_debug (network.c:1037)
==23771==by 0x41F5A5: remove_network (ethernet.c:131)
==23771==by 0x41F86E: eth_dev_remove (ethernet.c:197)
==23771==by 0x4420C6: remove_device (device.c:295)
==23771==by 0x442149: remove_driver (device.c:310)
==23771==by 0x44229C: connman_device_driver_unregister (device.c:363)
==23771==by 0x41FCBD: ethernet_exit (ethernet.c:365)
==23771==by 0x440C45: __connman_plugin_cleanup (plugin.c:200)
==23771==by 0x43F5FB: main (main.c:697)
==23771==  Address 0x7917d38 is 24 bytes inside a block of size 232 free'd
==23771==at 0x4C2BCD7: free (vg_replace_malloc.c:469)
==23771==by 0x445863: network_destruct (network.c:968)
==23771==by 0x445A98: connman_network_unref_debug (network.c:1045)
==23771==by 0x44230B: free_network (device.c:374)
==23771==by 0x4E6D8F9: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==23771==by 0x44310F: connman_device_remove_network (device.c:901)
==23771==by 0x41F586: remove_network (ethernet.c:130)
==23771==by 0x41F86E: eth_dev_remove (ethernet.c:197)
==23771==by 0x4420C6: remove_device (device.c:295)
==23771==by 0x442149: remove_driver (device.c:310)
==23771==by 0x44229C: connman_device_driver_unregister (device.c:363)
==23771==by 0x41FCBD: ethernet_exit (ethernet.c:365)




On Thu, Apr 17, 2014 at 3:37 AM, Tomasz Bursztyka 
tomasz.burszt...@linux.intel.com wrote:

 Hi Eduardo,


  Network unreference is already being done by free_network,
 called by g_hash_table_remove. This patche prevents from
 an invalid read during nework removal.


 I would be curious to see your valgrind output.

 The reference ethernet.c is removing is the one which is set when the
 network is created.
 device.c remove it's own reference (added in connman_device_add_network).

 If there is a reference bug, it does not seem to be where you found it.

 Tomasz
 ___
 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: [PATCH 2/2] Avoid network duplicate unref for eth_dev_remote

2014-04-17 Thread Eduardo Abinader
Hi Tomasz,

Connman logs: http://pastebin.com/qFGaw29x


Cheers.


On Thu, Apr 17, 2014 at 9:35 AM, Tomasz Bursztyka 
tomasz.burszt...@linux.intel.com wrote:

 Hi Eduardo,


  As you mentioned, the network reference device is freeing is the the one
 it
 creates, in this case, it is created in eth_newlink. I could not see any
 network referenced by eth which is not via device, so that's the reason I
 patched by removing network_unref and letting device manage it by its own.


 connman_network_create() sets a reference to 1. That's the first reference.
 The one who create - then get that first reference - should unreference it.
 This is what ethernet plugin is doing, logically in
 add_network/remove_network.

 According to your valgrind output, you have found a reference issue, but
 your
 fix is not proper.

 There is most probably a place which is unreferencing one time too much the
 network, thus breaking the logic in plugins/ethernet.c

 Hopefully, it's possible to follow who calls ref/unref functions.
 Could you send your connman debug logs? It will help to clarify the
 valgrind output.

 Cheers,


 Tomasz
 ___
 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: [PATCH 2/2] Avoid network duplicate unref for eth_dev_remote

2014-04-17 Thread Eduardo Abinader
Surely.

anyway, please check my first patch, applied in dhcp_invalidate.
I going to investigate further this issue you just mentioned.


BR.


On Thu, Apr 17, 2014 at 10:08 AM, Tomasz Bursztyka 
tomasz.burszt...@linux.intel.com wrote:

 Thanks,

 Now it's possible to pin point which part is bogus:

 - connman_network_create() network 0x749d890
 - connman_network_ref_debug() 0x749d890 name Wired ref 2 by
 src/device.c:858:connman_device_add_network()
 - connman_network_ref_debug() 0x749d890 name Wired ref 3 by
 src/service.c:6670:update_from_network()
 - connman_network_ref_debug() 0x749d890 name Wired ref 4 by
 src/network.c:570:autoconf_ipv6_set()
 - connman_network_ref_debug() 0x749d890 name Wired ref 5 by
 src/dhcp.c:608:__connman_dhcp_start()
 - connman_network_unref_debug() 0x749d890 name Wired ref 4 by
 src/network.c:455:check_dhcpv6()
 - connman_network_unref_debug() 0x749d890 name Wired ref 3 by
 src/dhcp.c:145:dhcp_invalidate()
 - connman_network_unref_debug() 0x749d890 name Wired ref 2 by
 src/dhcp.c:145:dhcp_invalidate()
 - connman_network_unref_debug() 0x749d890 name Wired ref 1 by
 src/service.c:4455:service_free()
 - connman_network_unref_debug() 0x749d890 name Wired ref 0 by
 src/device.c:374:free_network()
 - connman_network_unref_debug() 0x749d890 name Wired ref -1 by
 plugins/ethernet.c:131:remove_network()

 Looks like the dhcp process is the culprit: it's unreferencing the network
 twice though it referenced it only once.
 2 times dhcp_invalidate().

 Can you check what's the proper fix there and resend a patch?

 Thanks,


 Tomasz


 ___
 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


[PATCH 1/1] Avoid invalid reads in dhcp_invalidate

2014-04-17 Thread Eduardo Abinader
dhcp_invalidate was freeing dhcp and duplicating network unref
(reported by Tomasz Bursztyka), thus causinhg invalid reads,
when ipv4ll_announce_timeout was triggered. The patch consists
of freeing dhcp only when dhcp is stopped and network removal
and unref are previously checked against network_list.
---
 src/dhcp.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index e4bac67..eb37cfe 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -86,7 +86,6 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, bool 
callback)
 {
struct connman_service *service;
struct connman_ipconfig *ipconfig;
-   bool network_removed = false;
int i;
 
DBG(dhcp %p callback %u, dhcp, callback);
@@ -132,18 +131,14 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, 
bool callback)
__connman_ipconfig_set_gateway(ipconfig, NULL);
__connman_ipconfig_set_prefixlen(ipconfig, 0);
 
-   if (dhcp-callback  callback) {
-   g_hash_table_remove(network_table, dhcp-network);
-   network_removed = true;
+   if (dhcp-callback  callback)
dhcp-callback(dhcp-network, false, NULL);
-   }
 
 out:
-   if (!network_removed)
+   if (g_hash_table_contains(network_table, dhcp-network)) {
g_hash_table_remove(network_table, dhcp-network);
-
-   connman_network_unref(dhcp-network);
-   dhcp_free(dhcp);
+   connman_network_unref(dhcp-network);
+   }
 }
 
 static void dhcp_valid(struct connman_dhcp *dhcp)
@@ -627,6 +622,7 @@ void __connman_dhcp_stop(struct connman_network *network)
if (dhcp) {
dhcp_release(dhcp);
dhcp_invalidate(dhcp, false);
+   dhcp_free(dhcp);
}
 }
 
-- 
1.8.3.2

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


[PATCH 0/2] Invalid reads found

2014-04-16 Thread Eduardo Abinader
Noticed some invalid reads in two scenarios:

1) ipv4ll_available_cb (timeout triggered) referenced 
freed dhcp. 

2) On connmand termination, invalid read was found in 
eth_dev_remote, due to duplicate network unref.

The next two patches fix the issues above. 

Eduardo Abinader (2):
  Free dhcp only when dhcp is stopped
  Avoid network duplicate unref for eth_dev_remote

 plugins/ethernet.c | 1 -
 src/dhcp.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

-- 
1.8.3.2

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


[PATCH 2/2] Avoid network duplicate unref for eth_dev_remote

2014-04-16 Thread Eduardo Abinader
Network unreference is already being done by free_network,
called by g_hash_table_remove. This patche prevents from
an invalid read during nework removal.
---
 plugins/ethernet.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/plugins/ethernet.c b/plugins/ethernet.c
index b8e52ce..aa1153b 100644
--- a/plugins/ethernet.c
+++ b/plugins/ethernet.c
@@ -128,7 +128,6 @@ static void remove_network(struct connman_device *device,
return;
 
connman_device_remove_network(device, ethernet-network);
-   connman_network_unref(ethernet-network);
 
ethernet-network = NULL;
 }
-- 
1.8.3.2

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


[PATCH 1/2] Free dhcp only when dhcp is stopped

2014-04-16 Thread Eduardo Abinader
Freeing dhcp in dhcp_invalidate is causing invalid reads in
ipv4ll_available_cb, called by annouce timeout. Just freeing
the dhcp struct, when dhcp is stopped is more suitable.
---
 src/dhcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index e4bac67..5f40c1b 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -143,7 +143,6 @@ out:
g_hash_table_remove(network_table, dhcp-network);
 
connman_network_unref(dhcp-network);
-   dhcp_free(dhcp);
 }
 
 static void dhcp_valid(struct connman_dhcp *dhcp)
@@ -627,6 +626,7 @@ void __connman_dhcp_stop(struct connman_network *network)
if (dhcp) {
dhcp_release(dhcp);
dhcp_invalidate(dhcp, false);
+   dhcp_free(dhcp);
}
 }
 
-- 
1.8.3.2

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


[PATCH 1/1] Fix p2p driver probe

2014-04-03 Thread Eduardo Abinader
For a p2p driver previously registered, after disabling wifi and
enabling again, p2p driver probe was missing.
---
 src/technology.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/technology.c b/src/technology.c
index 5a12202..fdb429a 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1220,6 +1220,7 @@ int connman_technology_driver_register(struct 
connman_technology_driver *driver)
GSList *list;
struct connman_device *device;
enum connman_service_type type;
+   struct connman_technology *technology;
 
for (list = driver_list; list; list = list-next) {
if (list-data == driver)
@@ -1254,8 +1255,11 @@ int connman_technology_driver_register(struct 
connman_technology_driver *driver)
 
 exist:
if (driver-type == CONNMAN_SERVICE_TYPE_P2P) {
-   if (!technology_get(CONNMAN_SERVICE_TYPE_P2P))
+   technology = technology_get(CONNMAN_SERVICE_TYPE_P2P);
+   if (!technology)
return -ENOMEM;
+   else if (driver-probe)
+   driver-probe(technology);
}
 
return 0;
-- 
1.8.3.2

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


[PATCH 1/1] Fix typo p2p-on-supplicant

2014-03-18 Thread Eduardo Abinader
fix typo on p2p_service_flush
---
 test/p2p-on-supplicant | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 2bb02ba..b59c11c 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -374,7 +374,7 @@ class Wpa_s:
 self.p2p.DeleteService((service))
 
 @checkarg()
-def p2p_service_flush(self, args = None)
+def p2p_service_flush(self, args = None):
 if not self.p2p:
 return
 
-- 
1.8.3.2

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