[PATCH] dhcp: only apply dhcp result to service when network available

2014-08-04 Thread Guoqiang Liu
From: Guoqiang Liu guoqiang@archermind.com

network doesn't make sense to P2P, so only apply dhcp result to
service when network available.
---
 src/dhcp.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 132b787..eaff2ce 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -459,7 +459,8 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
__connman_ipconfig_set_gateway(dhcp-ipconfig, gateway);
}
 
-   if (!apply_lease_available_on_network(dhcp_client, dhcp))
+   if (dhcp-network
+!apply_lease_available_on_network(dhcp_client, dhcp))
return;
 
if (ip_change)
-- 
1.7.9.5

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


Re: [PATCH] Fix UTF-8 ssid's

2014-08-04 Thread Patrik Flykt

Hi,

On Mon, 2014-08-04 at 12:03 +1000, Lorn Potter wrote:
 My device seems to using ANSI_X3.4-1968

Which one? The one (Jolla??) you run ConnMan on?

 For an AP with ssid set to LT-Test-ÅÅЀ
 
 connman shows: LT-Test-??#1024;
 
 wpa_cli shows it as: LT-Test-\xc5\xc5#1024;
 
 (on my laptop it's LT-Test-__#1024;)
 (consequently, only nm-applet comes closest to showing it: 
 LT-Test-ÅÅ#1024;)

So ConnMan is quite close. Those ? were supposed to turn up as UTF
replacement character boxes. Apparently nm-applet just guesses, this
time correctly. And everybody gets É wrong, so not all parts of the SSID
is correctly configurable to the AP.

Are you watching ConnMan's SSID from the terminal? What does
'printenv | egrep LC_|LANG' show as locale settings?

Can you check with Wireshark/Kismet what the SSID actually looks like on
the wire?


Cheers,

Patrik

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

Re: [PATCH] dhcp: only apply dhcp result to service when network available

2014-08-04 Thread Tomasz Bursztyka

Hi,

+++ b/src/dhcp.c
@@ -459,7 +459,8 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
__connman_ipconfig_set_gateway(dhcp-ipconfig, gateway);
}
  
-	if (!apply_lease_available_on_network(dhcp_client, dhcp))

+   if (dhcp-network
+!apply_lease_available_on_network(dhcp_client, dhcp))
return;


Indeed, but do the test in apply_lease_available_on_network() preferably.
just a: if (!dhcp-network)
return true;

Thanks,

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


Re: [PATCH] dhcp: only apply dhcp result to service when network available

2014-08-04 Thread leonew

Hi Tomasz,

On 08/04/2014 03:52 PM, Tomasz Bursztyka wrote:

Hi,

+++ b/src/dhcp.c
@@ -459,7 +459,8 @@ static void lease_available_cb(GDHCPClient 
*dhcp_client, gpointer user_data)

  __connman_ipconfig_set_gateway(dhcp-ipconfig, gateway);
  }
  -if (!apply_lease_available_on_network(dhcp_client, dhcp))
+if (dhcp-network
+ !apply_lease_available_on_network(dhcp_client, dhcp))
  return;


Indeed, but do the test in apply_lease_available_on_network() preferably.
just a: if (!dhcp-network)
return true;

Here is my understanding:
1 From the name of the function, return true seemed to mean that apply 
lease available on network successful.

In fact. the network is NULL, and it should failed.
2 At the same time, what the function do is about service update. but 
the patch is about P2P.


In consideration of those reasons, I move the code to lease_available_cb.

Best Regards
Guoqiang

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


Re: [PATCH] dhcp: only apply dhcp result to service when network available

2014-08-04 Thread Tomasz Bursztyka

Hi,


+++ b/src/dhcp.c
@@ -459,7 +459,8 @@ static void lease_available_cb(GDHCPClient 
*dhcp_client, gpointer user_data)

  __connman_ipconfig_set_gateway(dhcp-ipconfig, gateway);
  }
  -if (!apply_lease_available_on_network(dhcp_client, dhcp))
+if (dhcp-network
+ !apply_lease_available_on_network(dhcp_client, dhcp))
  return;


Indeed, but do the test in apply_lease_available_on_network() 
preferably.

just a: if (!dhcp-network)
return true;

Here is my understanding:
1 From the name of the function, return true seemed to mean that 
apply lease available on network successful.


Don't interpret this, this function is just here because of my 
refactorization of dhcp.c
On network it will try to apply something yes: so it can return true 
or false in this specific case.
If there is no network is silently make the function to poss, so 
returning true.


Exactly as apply_dhcp_invalidate_on_network() does.

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


Re: [PATCH] dhcp: only apply dhcp result to service when network available

2014-08-04 Thread Tomasz Bursztyka


If there is no network is silently make the function to poss, so 
returning true.

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


Re: [PATCH] dhcp: only apply dhcp result to service when network available

2014-08-04 Thread leonew


Don't interpret this, this function is just here because of my 
refactorization of dhcp.c
On network it will try to apply something yes: so it can return true 
or false in this specific case.
If there is no network is silently make the function to poss, so 
returning true.


Exactly as apply_dhcp_invalidate_on_network() does.


Agree with you. I will update the patch.

Thanks
Guoqiang


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


Re: [PATCH] gsupplicant: Remove the dbus match when not needed

2014-08-04 Thread Patrik Flykt
On Fri, 2014-08-01 at 17:42 +0800, Guoqiang Liu wrote:
 From: Guoqiang Liu guoqiang@archermind.com
 
 Remove the dbus match when connman is no loger interested in.

Applied, thanks!

Patrik

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


Re: [PATCH] supplicant: Return -ECANCELED when error message iterator is NULL

2014-08-04 Thread Patrik Flykt
On Fri, 2014-08-01 at 14:23 +0300, Patrik Flykt wrote:
 On Fri, 2014-08-01 at 13:10 +0200, Richard Röjfors wrote:
  Except from that my name was incorrectly spelled, I ack this.
 
 Whoops. I'll fix.
 
  A stack trace says more than 1000 words ;-)
 
 I could add that one too...

Both fixed and applied.

Patrik

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

Re: [PATCH] wifi: Free g_hash_table_get_values on connect_peer

2014-08-04 Thread Patrik Flykt
On Fri, 2014-08-01 at 06:49 -0400, Eduardo Abinader wrote:
 Glist returned from g_hash_table_get_values was not
 being freed during p2p connect, causing a leak.

Applied, thanks!

Patrik

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


[PATCH] dhcp: Return true if network not available

2014-08-04 Thread Guoqiang Liu
From: Guoqiang Liu guoqiang@archermind.com

Here give a true return value as P2P doesn't care about network,
but P2P DHCP client need to do ipconfig if DHCP successful.
---
 src/dhcp.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/dhcp.c b/src/dhcp.c
index 132b787..d714f99 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -314,6 +314,9 @@ static bool apply_lease_available_on_network(GDHCPClient 
*dhcp_client,
int ns_entries;
int i;
 
+   if (!dhcp-network)
+   return true;
+
service = connman_service_lookup_from_network(dhcp-network);
if (!service) {
connman_error(Can not lookup service);
-- 
1.7.9.5

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


Re: [PATCH] dhcp: Return true if network not available

2014-08-04 Thread Tomasz Bursztyka

ACK from me.

Thank you

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


RE: [PATCH] dhcp: Fixed Crash on Switching Network

2014-08-04 Thread Chengyi Zhao
Hi

 Date: Wed, 30 Jul 2014 15:51:54 +0300
 From: tomasz.burszt...@linux.intel.com
 To: saurav.b...@samsung.com; connman@connman.net
 Subject: Re: [PATCH] dhcp: Fixed Crash on Switching Network
 
 Hi,
 
  Sometimes while switching network dhcp_initialize() fails because
  interface is not up and hence dhcp-dhcp_client remains NULL. Here we
  don't check return type of dhcp_initialize() and go on to call function
  g_dhcp_client_start() and crash occurs.
 
 Good catch, but this makes me think there is another bug: if the device 
 is down,
 connman should not even think of starting dhcp on it, so there might be 
 another issue
 to get fixed here. What version of connman are you using btw?

This issue can be found in ConnMan 1.24,
and you can reproduce it when repeatedly operated the following command:

./test-connman offlinemode on
./test-connman offlinemode off

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


RE: [PATCH] service: Fix connection logic when called from D-Bus

2014-08-04 Thread Chengyi Zhao
Hi,

 
 From: Chengyi Zhao chengyi1.z...@archermind.com
 
 When reconnected a same service which it has already been
 either connected or connecting before, this service doesn't
 need to be disconnected.
 ---
  src/service.c | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/src/service.c b/src/service.c
 index 9406bc3..2421215 100644
 --- a/src/service.c
 +++ b/src/service.c
 @@ -3968,6 +3968,9 @@ static DBusMessage *connect_service(DBusConnection 
 *conn,
   if (!is_connecting(temp)  !is_connected(temp))
   break;
  
 + if (g_strcmp0(service-path, temp-path) == 0)
 + break;
 +

I'd like to explain why committed this path.

Do the following operations before applying this patch:

root:/usr/lib/connman/test ./test-connman connect 
wifi_00dbdf140abe_54502d4c494e4b5f343736383741_managed_psk
root:/usr/lib/connman/test ./test-connman connect 
wifi_00dbdf140abe_54502d4c494e4b5f343736383741_managed_psk
net.connman.Error.Failed: Input/Output Error

I think this is a issue that user gets the IO error and network will be 
diconnected when reconnected 
the same service.

Do the following operations after applying this patch:

root:/usr/lib/connman/test ./test-connman connect 
wifi_00dbdf140abe_54502d4c494e4b5f343736383741_managed_psk
root:/usr/lib/connman/test ./test-connman connect 
wifi_00dbdf140abe_54502d4c494e4b5f343736383741_managed_psk
net.connman.Error.AlreadyConnected: Already connected

Perhaps the better patch will fix this issue, please check.

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


Re: Re: [PATCH] dhcp: Fixed Crash on Switching Network

2014-08-04 Thread Saurav Babu


0001-dhcp-Fixed-Crash-on-Switching-Network.patch
Description: Binary data
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Re: [PATCH] service: Fix connection logic when called from D-Bus

2014-08-04 Thread Tomasz Bursztyka

Hi,


root:/usr/lib/connman/test ./test-connman connect 
wifi_00dbdf140abe_54502d4c494e4b5f343736383741_managed_psk
root:/usr/lib/connman/test ./test-connman connect 
wifi_00dbdf140abe_54502d4c494e4b5f343736383741_managed_psk
net.connman.Error.Failed: Input/Output Error


There is actually an error yes, I could reproduce it easily.
The loop should ignore the same service. But fix is a bit overkill, just 
do this:


if (service == temp)
continue;

That should do the trick, at the beginning of the loop.

@Patrik: do you confirm this?

Tomasz





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


Re: [PATCH] dhcp: Fixed Crash on Switching Network

2014-08-04 Thread Tomasz Bursztyka

Hi,

Thanks, patch looks ok to me. But that does not fix the root cause yet 
since basically,

connman should never start dhcp client if the device is not up.
Though I think your patch should come in anyway, it's indeed necessary 
to know if the

initialization went fine before proceeding further.

We are investigating this on our side since we've got the proper steps 
to reproduce it.


Tomasz


Sometimes while switching network dhcp_initialize() fails because
interface is not up and hence dhcp-dhcp_client remains NULL. Here we
don't check return type of dhcp_initialize() and go on to call function
g_dhcp_client_start() and crash occurs.
Below trace is obtained when connman crashes:
connmand[19034]: Aborting (signal 11) [/usr/local/sbin/connmand]
connmand[19034]:  backtrace 
connmand[19034]: #0  0xb7630f38 in /lib/i386-linux-gnu/libpthread.so.0
connmand[19034]: #1  0x8055a22 in debug() at client.c:0
connmand[19034]: #2  0x8058837 in g_dhcp_client_start() at polkit.c:0
connmand[19034]: #3  0x80a4772 in __connman_dhcp_start() at polkit.c:0
connmand[19034]: #4  0x8082a80 in set_connected.part.8() at network.c:0
connmand[19034]: #5  0x8082f7f in connman_network_set_connected() at
??:0
connmand[19034]: #6  0x805f921 in eth_network_connect() at ethernet.c:0
connmand[19034]: #7  0x8082dc3 in __connman_network_connect() at
polkit.c:0
connmand[19034]: #8  0x808e7e4 in __connman_service_connect() at
polkit.c:0
connmand[19034]: #9  0x808eef0 in auto_connect_service() at service.c:0
connmand[19034]: #10 0x808efde in run_auto_connect() at service.c:0
connmand[19034]: #11 0xb76cea3f in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #12 0xb76cdd46 in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #13 0xb76ce0e5 in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #14 0xb76ce52b in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #15 0x80544cd in main() at polkit.c:0
connmand[19034]: #16 0xb739b4d3 in /lib/i386-linux-gnu/libc.so.6
connmand[19034]: +++
---
 src/dhcp.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 132b787..a3dd3c4 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -587,6 +587,7 @@ int __connman_dhcp_start(struct connman_ipconfig 
*ipconfig,

 {
  const char *last_addr = NULL;
  struct connman_dhcp *dhcp;
+ int err;

  DBG();

@@ -615,9 +616,12 @@ int __connman_dhcp_start(struct connman_ipconfig 
*ipconfig,

connman_network_ref(network);
   }

-  g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
+  err = dhcp_initialize(dhcp);

-  dhcp_initialize(dhcp);
+  if(err != 0)
+   return err;
+
+  g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
  }

  dhcp-callback = callback;



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


[PATCH 2/2] dhcpv6: Use proper default values fot T1 and T2

2014-08-04 Thread Patrik Flykt
If T1 or T2 are not set by the server, use the recommended default
DHCPv6 server values 0.5 and 0.8. See RFC 3315, section 22.4.

Thanks to Dan Williams for reporting this issue.
---
 src/dhcpv6.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 461b0a6..dee2d81 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1422,11 +1422,13 @@ int __connman_dhcpv6_start_renew(struct connman_network 
*network,
/* RFC 3315, 22.4 */
return 0;
 
-   if (T1 == 0)
+   if (T1 == 0) {
/* RFC 3315, 22.4
 * Client can choose the timeout.
 */
-   T1 = 1800;
+   T1 = (expired - started) / 2;
+   T2 = (expired - started) / 10 * 8;
+   }
 
dhcp-callback = callback;
 
-- 
1.9.1

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


[PATCH 1/2] dhcpv6: Fix timer calculation

2014-08-04 Thread Patrik Flykt
Take into account the current and starting time when computing the
next timeout. When T2 has elapsed, rebind should start immediately.

Thanks to Dan Williams for reporting this.
---
 src/dhcpv6.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 72fe33f..461b0a6 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1399,7 +1399,7 @@ int __connman_dhcpv6_start_renew(struct connman_network 
*network,
dhcpv6_cb callback)
 {
struct connman_dhcpv6 *dhcp;
-   uint32_t T1, T2;
+   uint32_t T1, T2, delta;
time_t started, current, expired;
 
dhcp = g_hash_table_lookup(network_table, network);
@@ -1437,22 +1437,23 @@ int __connman_dhcpv6_start_renew(struct connman_network 
*network,
if (T2 != 0x  T2  0) {
if ((unsigned)current = (unsigned)started + T2) {
/* RFC 3315, chapter 18.1.3, start rebind */
-   DBG(rebind after %d secs, T2);
+   DBG(start rebind immediately);
 
-   dhcp-timeout = g_timeout_add_seconds(T2, start_rebind,
+   dhcp-timeout = g_timeout_add_seconds(0, start_rebind,
dhcp);
 
} else if ((unsigned)current  (unsigned)started + T1) {
-   DBG(renew after %d secs, T1);
+   delta = started + T1 - current;
+   DBG(renew after %d secs, delta);
 
-   dhcp-timeout = g_timeout_add_seconds(T1, start_renew,
-   dhcp);
+   dhcp-timeout = g_timeout_add_seconds(delta,
+   start_renew, dhcp);
} else {
-   DBG(rebind after %d secs, T2 - T1);
+   delta = started + T2 - current;
+   DBG(rebind after %d secs, delta);
 
-   dhcp-timeout = g_timeout_add_seconds(T2 - T1,
-   start_rebind,
-   dhcp);
+   dhcp-timeout = g_timeout_add_seconds(delta,
+   start_rebind, dhcp);
}
}
 
-- 
1.9.1

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


[PATCH 0/2] Two DHCPv6 fixes

2014-08-04 Thread Patrik Flykt

Hi,

Here are two patches fixing DHCPv6 T1 and T2 timer calculations.
With this default timer values should be used and proper timeouts
calculated.

Cheers,

Patrik


Patrik Flykt (2):
  dhcpv6: Fix timer calculation
  dhcpv6: Use proper default values fot T1 and T2

 src/dhcpv6.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

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