Re: [PATCH 0/3] Misc dnsproxy fixes

2012-11-19 Thread Kalle Valo
Patrik Flykt  writes:

> On Mon, 2012-11-19 at 10:48 +0200, patrik.fl...@linux.intel.com wrote:
>
>> Here are a few dnsproxy related fixes, updating the ones I sent end of last
>> week. It seems that g_io_channel_* is pretty unforgiving when fed a NULL
>> channel, thus the extra checks.
>> 
>> Hope this fixes Kalle Valo's crash.
>
> I applied these three. Let's see if the crash also got fixed.

Just updated to 86f21518. No crash in an hour, earlier it crashes within
five minutes or so. I think the crash is fixed.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


dnsproxy crash

2012-11-17 Thread Kalle Valo
Hi,

I updated connman to latest commit from git (a3c241e74) and I saw this
crash twice in the first 10 mins:

connmand[30146]: src/dnsproxy.c:server_create_socket() sk 14
connmand[30146]: src/dnsproxy.c:create_server() Adding DNS server
2001:b18:0:1000:2e0:81ff:fe61:ae0d
connmand[30146]: src/dnsproxy.c:__connman_dnsproxy_remove() interface
wlan0 server 2001:16d8::3::2
connmand[30146]: src/dnsproxy.c:find_server() interface wlan0 server
2001:16d8::3::2 proto 17
connmand[30146]: Aborting (signal 11) [src/connmand]
connmand[30146]:  backtrace 
connmand[30146]: #0  0x7f78a046ecb0 in
/lib/x86_64-linux-gnu/libpthread.so.0
connmand[30146]: #1  0x7f78a0944790 in
/lib/x86_64-linux-gnu/libglib-2.0.so.0
connmand[30146]: #2  0x46b299 in destroy_server() at src/dnsproxy.c:1779
connmand[30146]: #3  0x46e6b0 in remove_server() at src/dnsproxy.c:2313
connmand[30146]: #4  0x44b9e1 in __connman_resolver_redo_servers() at
src/resolver.c:566
connmand[30146]: #5  0x459004 in process_newaddr() at src/rtnl.c:618
connmand[30146]: #6  0x7f78a0907d53 in
/lib/x86_64-linux-gnu/libglib-2.0.so.0
connmand[30146]: #7  0x7f78a09080a0 in
/lib/x86_64-linux-gnu/libglib-2.0.so.0
connmand[30146]: #8  0x7f78a090849a in
/lib/x86_64-linux-gnu/libglib-2.0.so.0
connmand[30146]: #9  0x40e58d in main() at src/main.c:605
connmand[30146]: #10 0x7f789f5d176d in /lib/x86_64-linux-gnu/libc.so.6
connmand[30146]: +++

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v0 0/6] cppcheck fixes

2011-03-18 Thread Kalle Valo
Daniel Wagner  writes:

>> for me connman still starts fine and loads the correct modules takes
>> control of the card etc. assigns an ipv6 mac but it will not see my old
>> wireless g router that knows nothing of ipv6 (is ipv4 only) Linksys
>> wrt54g ver 2 ( I have two of these and am considering flashing the
>> second one with a linux router like openwrt
>
> Make sure you are have a wpa_supplicant (>= v0.8.x) which has the new
> D-Bus interface enabled.  Older version of wpa_supplicant wont work.

Actually wpa_supplicant 0.7.x also has the new dbus interface.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: connman in server environment

2011-02-25 Thread Kalle Valo
Samuel Ortiz  writes:

>> 3) Where i can find full featured command line utilite to controlling
>> conmmand?
> Look at the python scripts under the test/ connman directory.

Alternatively you might want to check cmcc from ubuntu's
indicator-network package.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: Duplicate nameservers

2011-02-25 Thread Kalle Valo
On 02/22/2011 02:14 AM, Samuel Ortiz wrote:
> Hi Kalle,

Hi Samuel,

> On Thu, Feb 17, 2011 at 01:24:54PM +0200, Kalle Valo wrote:
>> Hi,
>>
>> this week I started seeing duplicate nameservers on the service
>> properties. For example, after some time I can see my 192.168.1.1
>> nameserver 10 times. It seems to happen after a dhcp lease renewal.
> So that one should be fixed now. Please let me know if it's not.

Just tested this. I don't see duplicate entries anymore.

Thank you for fixing this.

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 2/2] tethering: Using /proc/sys/net/bridge to detect the support of bridge

2011-02-18 Thread Kalle Valo
martin...@intel.com writes:

> From: Martin Xu 
>
> If bridge is built in knerl, /sys/module/bridge can not be used to detect
> the support of bridge in kernel.
> ---
>  src/tethering.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/tethering.c b/src/tethering.c
> index 705f5ee..15e1ed9 100644
> --- a/src/tethering.c
> +++ b/src/tethering.c
> @@ -35,7 +35,7 @@
>  
>  #include 
>  
> -#define BRIDGE_SYSFS_DIR "/sys/module/bridge"
> +#define BRIDGE_SYSFS_DIR "/proc/sys/net/bridge"

SYSFS_DIR is misleading now.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] doc: ipv6 prefix length is a string

2011-02-16 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Kalle,

Hi Marcel,
>> But code wants it as string:
>> 
>>  } else if (g_str_equal(key, "PrefixLength") == TRUE) {
>>  if (type != DBUS_TYPE_STRING)
>>  return -EINVAL;
>> 
>>  dbus_message_iter_get_basic(&entry,
>>  &prefix_length_string);
>> 
>>  prefix_length = atoi(prefix_length_string);
>>  if (prefix_length < 0 || prefix_length > 128)
>>  return -EINVAL;
>> 
>> Or am I missing something?
>
> that is a bug. It was clearly intended as uint8.

Ok. I assume the a{ss} dict is a bug as well.

But fixing this breaks service api, which happens way too often already :/

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


crash in connman_ipaddress_free()

2011-02-15 Thread Kalle Valo
.c:209
#30 0x00428ba3 in main (argc=1, argv=0x7fffe638) at src/main.c:250

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] doc: ipv6 prefix length is a string

2011-02-15 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Kalle,

Hi Marcel,

>> --- a/doc/service-api.txt
>> +++ b/doc/service-api.txt
>> @@ -367,7 +367,7 @@ Properties   string State [readonly]
>>  
>>  The current configured IPv6 address.
>>  
>> -uint8 PrefixLength [readonly]
>> +string PrefixLength [readonly]
>>  
>>  The prefix length of the IPv6 address.
>
> actually the documentation is correct here. This should be a uint8.

But code wants it as string:

} else if (g_str_equal(key, "PrefixLength") == TRUE) {
if (type != DBUS_TYPE_STRING)
return -EINVAL;

dbus_message_iter_get_basic(&entry,
&prefix_length_string);

prefix_length = atoi(prefix_length_string);
if (prefix_length < 0 || prefix_length > 128)
return -EINVAL;

Or am I missing something?

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [RFC 0/3] Fix handling of provisioned APN

2011-02-15 Thread Kalle Valo
Samuel Ortiz  writes:

> After reviewing your patch, and looking at the oFono GPRS provisioning, we
> decided to actually remove the ConnMan APN service property.
> APNs, Username and Password should be provisioned or set through oFono.
>
>  What we're now missing from ConnMan is an agent interface when such
> settings are missing.

Shouldn't the agent interface be in ofono? If connman shouldn't know
anything about apn, adding an agent interface to connman sounds a bit
odd.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH] doc: ipv6 prefix length is a string

2011-02-15 Thread Kalle Valo
Also the dict type is a{ss}, not a{sv} as I expected, but don't know
how I should mark that.
---
 doc/service-api.txt |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/doc/service-api.txt b/doc/service-api.txt
index b3e758e..ff6b044 100644
--- a/doc/service-api.txt
+++ b/doc/service-api.txt
@@ -367,7 +367,7 @@ Properties  string State [readonly]
 
The current configured IPv6 address.
 
-   uint8 PrefixLength [readonly]
+   string PrefixLength [readonly]
 
The prefix length of the IPv6 address.
 

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: connman git works somewhat, kills /etc/resolv.conf

2011-02-09 Thread Kalle Valo
DJ Cozatt  writes:

>> ConnMan has a build in dnsproxy which is used by default. That's why
>> you have a 127.0.0.1 entry in resolv.conf.  You can use the '-r'
>> option to disable the dnsproxy and get the old behavior back. Though
>> this is only a workaround.
>> 
>> The question is why dnsproxy doesn't work for you.
>
> this I do not know. I have a name service cache daemon that is initiated
> already at startup. should it be removed? 

If port 53 is already taken, connman should automatically fallback to
not using dnsproxy. Daniel promptly fixed this few weeks ago and the fix
is in 0.69. Here's the commit:

http://git.kernel.org/?p=network/connman/connman.git;a=commitdiff;h=cde0b261b8976d168af0cfa05f68f0d2543c501e

Make sure that you have that patch in your build.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v2] rtnl: fix some uninitalised warnings

2011-02-08 Thread Kalle Valo
src/rtnl.c:578:8: error: 'src' may be used uninitialized in this function
src/rtnl.c:610:8: error: 'src' may be used uninitialized in this function
src/rtnl.c:1108:19: error: 'servers' may be used uninitialized in this function
---
 src/rtnl.c |   12 +---
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/rtnl.c b/src/rtnl.c
index 3d42043..07b570a 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -578,9 +578,6 @@ static void process_newaddr(unsigned char family, unsigned 
char prefixlen,
void *src;
char ip_string[INET6_ADDRSTRLEN];
 
-   if (family != AF_INET && family != AF_INET6)
-   return;
-
if (family == AF_INET) {
struct in_addr ipv4_addr = { INADDR_ANY };
 
@@ -594,6 +591,8 @@ static void process_newaddr(unsigned char family, unsigned 
char prefixlen,
return;
 
src = &ipv6_address;
+   } else {
+   return;
}
 
if (inet_ntop(family, src, ip_string, INET6_ADDRSTRLEN) == NULL)
@@ -610,9 +609,6 @@ static void process_deladdr(unsigned char family, unsigned 
char prefixlen,
void *src;
char ip_string[INET6_ADDRSTRLEN];
 
-   if (family != AF_INET && family != AF_INET6)
-   return;
-
if (family == AF_INET) {
struct in_addr ipv4_addr = { INADDR_ANY };
 
@@ -626,6 +622,8 @@ static void process_deladdr(unsigned char family, unsigned 
char prefixlen,
return;
 
src = &ipv6_address;
+   } else {
+   return;
}
 
if (inet_ntop(family, src, ip_string, INET6_ADDRSTRLEN) == NULL)
@@ -1105,7 +1103,7 @@ static void rtnl_newnduseropt(struct nlmsghdr *hdr)
struct nd_opt_hdr *opt = (void *)&msg[1];
guint32 lifetime = -1;
const char **domains = NULL;
-   struct in6_addr *servers;
+   struct in6_addr *servers = NULL;
int nr_servers = 0;
int msglen = msg->nduseropt_opts_len;
char *interface;

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [RFC PATCH] dhcp: call dhcp_bound() only when something has changed

2011-02-08 Thread Kalle Valo
Samuel Ortiz  writes:

> Hi Kalle,
>
> On Mon, Feb 07, 2011 at 04:04:33PM +0200, Kalle Valo wrote:
>> A user reported that his konversation (a kde irc client) is disconnecting
>> periodically every 30 minutes. After some investigation the culprit was
>> dhcp renewal handling in connman. connman removes and adds again ip settings
>> during every dhcp renewal and that confused konversation.
>> 
>> Even when ignoring the konversation problem it's not very robust to remove
>> settings removed from dhcp and then again set the exactly same settings.
>> 
>> Here's a patch which adds checks if the dhcp settings have really changed
>> and only then dhcp_bound() is called.
>
> That makes sense to me, thanks for catching that. I think we can even
> be smarter and check if the actual IPv4 settings need to be changed or
> if it's only e.g. the namservers or the PAC file that changed (all of
> those being quite unlikely on a DHCP renewal, but still).

That's a good idea.

> I propose we wait until Daniel's patchset (DHCP element removal) gets in, and
> then you can rebase your patch on top of it. Is that ok with you ?

That sounds very good to me. I'll revisit this patch later and send v2
then.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 2/4] rtnl: fix some uninitalised warnings

2011-02-08 Thread Kalle Valo
Samuel Ortiz  writes:

>> -}
>> +} else
>> +return;
> I'm fine with this fix, but then please remove the
>
>   if (family != AF_INET && family != AF_INET6)
>   return;
>
> check, as you noticed on IRC. This is quite dumb, but if we're going to hit
> that problem when moving to 4.5, then let's fix it now.

I'll send v2 of this patch soon.

> As for the {} after the else, either way is fine with me.

I'll go with Daniel's recommendation.

Thanks for the review.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: crash in append_domain()

2011-02-07 Thread Kalle Valo
Kalle Valo  writes:

> Hi,
>
> today I started seeing very frequent connman crashes. I updated my
> openwrt access point yesterday and enabled rdnss, maybe that's somehow
> related?
>
> Below is the stacktrace. It's with my gcc 4.5 warning fixes (which I'm
> about to send), but I can see the crashes with the vanilla master
> branch.

And below are the last debug messages I saw. Note that domain is null.

I'm now using rndss and very low dhcp lease time. Most probably that
causes it.

> #0  __strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:107
> #1  0x77b52f89 in g_str_equal (v1=, 
> v2=)
> at /build/buildd/glib2.0-2.27.93/glib/gstring.c:116
> #2  0x00449eee in append_domain (interface=0x725f00 "wlan0", 
> domain=0x0) at src/dnsproxy.c:855
> #3  0x0044b97d in __connman_dnsproxy_append (
> interface=0x725f00 "wlan0", domain=0x0, 
> server=0x7fffe290 "2001:b18:0:1000:2e0:81ff:fe61:ae0d")
> at src/dnsproxy.c:889
> #4  0x00437a8b in append_resolver (interface=0x725f00 "wlan0", 
> domain=0x0, server=0x7fffe290 "2001:b18:0:1000:2e0:81ff:fe61:ae0d", 
> lifetime=600, flags=0) at src/resolver.c:272
> #5  0x00440429 in rtnl_newnduseropt (chan=, 
> cond=, data=) at src/rtnl.c:1153
> #6  rtnl_message (chan=, cond=, 
> data=) at src/rtnl.c:1322
> #7  netlink_event (chan=, cond=, 
> data=) at src/rtnl.c:1355
> #8  0x77b30cfd in g_main_dispatch (context=0x671100)
> at /build/buildd/glib2.0-2.27.93/glib/gmain.c:2440
> #9  g_main_context_dispatch (context=0x671100)
> at /build/buildd/glib2.0-2.27.93/glib/gmain.c:3013
> #10 0x77b314e8 in g_main_context_iterate (context=0x671100, 
> block=, dispatch=1, self=)
> at /build/buildd/glib2.0-2.27.93/glib/gmain.c:3091
> #11 0x77b31b2a in g_main_loop_run (loop=0x6711e0)
> at /build/buildd/glib2.0-2.27.93/glib/gmain.c:3299
> #12 0x00422087 in main (argc=1, argv=0x7fffe658) at src/main.c:246

connmand[17462]: src/ipconfig.c:__connman_ipconfig_append_ipv4() 
connmand[17462]: src/ipconfig.c:__connman_ipconfig_append_ipv6() 
connmand[17462]: wlan0 ip bound
connmand[17462]: src/ipconfig.c:__connman_ipconfig_append_ipv4() 
connmand[17462]: src/ipconfig.c:__connman_ipconfig_append_ipv6() 
connmand[17462]: src/rtnl.c:rtnl_message() buf 0x7fffd310 len 92
connmand[17462]: src/rtnl.c:rtnl_message() NEWNDUSEROPT len 92 type 68 flags 
0x seq 0
connmand[17462]: src/rtnl.c:rtnl_newnduseropt() family 0a index 3 len 0028 type 
86 code 00
connmand[17462]: src/rtnl.c:rtnl_newnduseropt() nd opt type 25 len 5
connmand[17462]: src/resolver.c:connman_resolver_append_lifetime() interface 
wlan0 domain (null) server 2001:b18:0:1000:2e0:81ff:fe61:ae0d lifetime 600
connmand[17462]: src/resolver.c:append_resolver() interface wlan0 domain (null) 
server 2001:b18:0:1000:2e0:81ff:fe61:ae0d lifetime 600 flags 0
connmand[17462]: src/dnsproxy.c:__connman_dnsproxy_append() interface wlan0 
server 2001:b18:0:1000:2e0:81ff:fe61:ae0d
connmand[17462]: src/dnsproxy.c:find_server() interface wlan0 server 
2001:b18:0:1000:2e0:81ff:fe61:ae0d
connmand[17462]: src/dnsproxy.c:append_domain() interface wlan0 domain (null)

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 2/4] rtnl: fix some uninitalised warnings

2011-02-07 Thread Kalle Valo
Daniel Wagner  writes:

> Hi Kalle,

Hi Daniel,

>> --- a/src/rtnl.c
>> +++ b/src/rtnl.c
>> @@ -594,7 +594,8 @@ static void process_newaddr(unsigned char family, 
>> unsigned char prefixlen,
>>  return;
>>  
>>  src = &ipv6_address;
>> -}
>> +} else
>> +return;
>
> IIRC, we are started to use always brakets for the else case too when
> the if case has brakets. Though there is quite a lot of code which
> doesn't do that. Maybe this is something with a cool perl magic hack
> can be fixed ;)

Thanks, I'll keep this in mind and will fix it in v2. But actually this
patch is a bit ugly and I'm not sure if Samuel want's this.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[RFC PATCH] dhcp: call dhcp_bound() only when something has changed

2011-02-07 Thread Kalle Valo
A user reported that his konversation (a kde irc client) is disconnecting
periodically every 30 minutes. After some investigation the culprit was
dhcp renewal handling in connman. connman removes and adds again ip settings
during every dhcp renewal and that confused konversation.

Even when ignoring the konversation problem it's not very robust to remove
settings removed from dhcp and then again set the exactly same settings.

Here's a patch which adds checks if the dhcp settings have really changed
and only then dhcp_bound() is called.

Please comment.
---
 src/dhcp.c |   62 ++--
 1 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 163b0b7..376c145 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -50,24 +50,29 @@ struct connman_dhcp {
struct connman_element *element;
 };
 
-static void dhcp_set_value(struct connman_dhcp *dhcp,
+static gboolean dhcp_set_value(struct connman_dhcp *dhcp,
const char *key, const char *value)
 {
char **nameservers;
 
-   if (g_strcmp0(key, "Address") == 0) {
+   if (g_strcmp0(key, "Address") == 0 &&
+   g_strcmp0(dhcp->element->ipv4.address, value) != 0) {
g_free(dhcp->element->ipv4.address);
dhcp->element->ipv4.address = g_strdup(value);
-   } else if (g_strcmp0(key, "Netmask") == 0) {
+   } else if (g_strcmp0(key, "Netmask") == 0 &&
+   g_strcmp0(dhcp->element->ipv4.netmask, value) != 0) {
g_free(dhcp->element->ipv4.netmask);
dhcp->element->ipv4.netmask = g_strdup(value);
-   } else if (g_strcmp0(key, "Gateway") == 0) {
+   } else if (g_strcmp0(key, "Gateway") == 0 &&
+   g_strcmp0(dhcp->element->ipv4.gateway, value) != 0) {
g_free(dhcp->element->ipv4.gateway);
dhcp->element->ipv4.gateway = g_strdup(value);
-   } else if (g_strcmp0(key, "Network") == 0) {
+   } else if (g_strcmp0(key, "Network") == 0 &&
+   g_strcmp0(dhcp->element->ipv4.network, value) != 0) {
g_free(dhcp->element->ipv4.network);
dhcp->element->ipv4.network = g_strdup(value);
-   } else if (g_strcmp0(key, "Broadcast") == 0) {
+   } else if (g_strcmp0(key, "Broadcast") == 0 &&
+   g_strcmp0(dhcp->element->ipv4.broadcast, value) != 0) {
g_free(dhcp->element->ipv4.broadcast);
dhcp->element->ipv4.broadcast = g_strdup(value);
} else if (g_strcmp0(key, "Nameserver") == 0) {
@@ -80,28 +85,41 @@ static void dhcp_set_value(struct connman_dhcp *dhcp,
 */
dhcp->element->ipv4.nameserver = g_strdup(nameservers[0]);
g_strfreev(nameservers);
-   } else if (g_strcmp0(key, "Domainname") == 0) {
+
+   /*
+* FIXME: compare values and don't do anything if they are
+* the same
+*/
+   return FALSE;
+   } else if (g_strcmp0(key, "Domainname") == 0 &&
+   g_strcmp0(dhcp->element->domainname, value) != 0) {
g_free(dhcp->element->domainname);
dhcp->element->domainname = g_strdup(value);
 
__connman_utsname_set_domainname(value);
-   } else if (g_strcmp0(key, "Hostname") == 0) {
+   } else if (g_strcmp0(key, "Hostname") == 0 &&
+   g_strcmp0(dhcp->element->hostname, value) != 0) {
g_free(dhcp->element->hostname);
dhcp->element->hostname = g_strdup(value);
 
__connman_utsname_set_hostname(value);
-   } else if (g_strcmp0(key, "Timeserver") == 0) {
+   } else if (g_strcmp0(key, "Timeserver") == 0 &&
+   g_strcmp0(dhcp->element->ipv4.timeserver, value) != 0) {
connman_info("Timeserver %s", value);
 
g_free(dhcp->element->ipv4.timeserver);
dhcp->element->ipv4.timeserver = g_strdup(value);
} else if (g_strcmp0(key, "MTU") == 0) {
-   } else if (g_strcmp0(key, "PAC") == 0) {
+   } else if (g_strcmp0(key, "PAC") == 0 &&
+   g_strcmp0(dhcp->element->ipv4.pac, value) != 0) {
connman_info("PAC configuration %s", value);
 
g_free(dhcp->element->ipv4.pac);
dhcp->element->ipv4.pac = g_strdup(value);
-   }
+   } else
+   return FALSE;
+
+   return TRUE;
 }
 
 static void dhcp_bound(struct connman_dhcp *dhcp)
@@ -153,17 +171,18 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
GList *list, *option = NULL;
char *address, *nameservers;
size_t ns_strlen = 0;
+   gboolean changed = FALSE;
 
DBG("Lease available");
 
address = g_dhcp_client_get_address(dhcp_client);
if (address != NULL)
-   dhcp_set_value(dhcp, "Address", address);
+  

[PATCH 4/4] pacrunner: remove unitialised use of host_ret variable

2011-02-07 Thread Kalle Valo
For some reason there's a null check for host_ret in parse_url(), which
is at that point is an uninitialised local variable. Just remove the check.

plugins/pacrunner.c:316:5: error: 'host_ret' may be used uninitialized in
this function
---
 plugins/pacrunner.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/plugins/pacrunner.c b/plugins/pacrunner.c
index 44ac3c1..f914eeb 100644
--- a/plugins/pacrunner.c
+++ b/plugins/pacrunner.c
@@ -313,9 +313,6 @@ static char * parse_url(const char *url)
if (scheme == NULL)
return NULL;
 
-   if (host_ret == NULL)
-   return NULL;
-
host = strstr(scheme, "://");
if (host != NULL) {
*host = '\0';

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 1/4] iptables-test: fix uninitialised use of entry_head

2011-02-07 Thread Kalle Valo
tools/iptables-test.c:455:20: error: ‘entry_return’ may be used uninitialized 
in this function
---
 tools/iptables-test.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/iptables-test.c b/tools/iptables-test.c
index e316cc9..298f23d 100644
--- a/tools/iptables-test.c
+++ b/tools/iptables-test.c
@@ -473,7 +473,7 @@ static int connman_iptables_add_chain(struct 
connman_iptables *table,
sizeof(struct error_target);
entry_head = g_try_malloc0(entry_head_size);
if (entry_head == NULL)
-   goto err;
+   goto err_head;
 
memset(entry_head, 0, entry_head_size);
 
@@ -486,7 +486,7 @@ static int connman_iptables_add_chain(struct 
connman_iptables *table,
strcpy(error->error, name);
 
if (connman_add_entry(table, entry_head, last, -1) < 0)
-   goto err;
+   goto err_head;
 
/* tail entry */
entry_return_size = sizeof(struct ipt_entry) +
@@ -511,8 +511,9 @@ static int connman_iptables_add_chain(struct 
connman_iptables *table,
return 0;
 
 err:
-   g_free(entry_head);
g_free(entry_return);
+err_head:
+   g_free(entry_head);
 
return -ENOMEM;
 }

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

[PATCH 3/4] iptables: fix uninitialised use of entry_return

2011-02-07 Thread Kalle Valo
src/iptables.c:432:20: error: ‘entry_return’ may be used uninitialized in this 
function
---
 src/iptables.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/iptables.c b/src/iptables.c
index 9e7f717..8f8ab53 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -450,7 +450,7 @@ static int iptables_add_chain(struct connman_iptables 
*table,
sizeof(struct error_target);
entry_head = g_try_malloc0(entry_head_size);
if (entry_head == NULL)
-   goto err;
+   goto err_head;
 
memset(entry_head, 0, entry_head_size);
 
@@ -463,7 +463,7 @@ static int iptables_add_chain(struct connman_iptables 
*table,
strcpy(error->error, name);
 
if (iptables_add_entry(table, entry_head, last, -1) < 0)
-   goto err;
+   goto err_head;
 
/* tail entry */
entry_return_size = sizeof(struct ipt_entry) +
@@ -488,8 +488,9 @@ static int iptables_add_chain(struct connman_iptables 
*table,
return 0;
 
 err:
-   g_free(entry_head);
g_free(entry_return);
+err_head:
+   g_free(entry_head);
 
return -ENOMEM;
 }

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

[PATCH 2/4] rtnl: fix some uninitalised warnings

2011-02-07 Thread Kalle Valo
src/rtnl.c:578:8: error: ‘src’ may be used uninitialized in this function
src/rtnl.c:610:8: error: ‘src’ may be used uninitialized in this function
src/rtnl.c:1108:19: error: ‘servers’ may be used uninitialized in this function
---
 src/rtnl.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/rtnl.c b/src/rtnl.c
index 3d42043..d5d502c 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -594,7 +594,8 @@ static void process_newaddr(unsigned char family, unsigned 
char prefixlen,
return;
 
src = &ipv6_address;
-   }
+   } else
+   return;
 
if (inet_ntop(family, src, ip_string, INET6_ADDRSTRLEN) == NULL)
return;
@@ -626,7 +627,8 @@ static void process_deladdr(unsigned char family, unsigned 
char prefixlen,
return;
 
src = &ipv6_address;
-   }
+   } else
+   return;
 
if (inet_ntop(family, src, ip_string, INET6_ADDRSTRLEN) == NULL)
return;
@@ -1105,7 +1107,7 @@ static void rtnl_newnduseropt(struct nlmsghdr *hdr)
struct nd_opt_hdr *opt = (void *)&msg[1];
guint32 lifetime = -1;
const char **domains = NULL;
-   struct in6_addr *servers;
+   struct in6_addr *servers = NULL;
int nr_servers = 0;
int msglen = msg->nduseropt_opts_len;
char *interface;

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

[PATCH 0/4] gcc 4.5 warning fixes

2011-02-07 Thread Kalle Valo
Ubuntu 11.04 alpha has gcc 4.5 and it some warnings I didn't see earlier. Some
of the warnings seem to be false, though.

---

Kalle Valo (4):
  iptables-test: fix uninitialised use of entry_head
  rtnl: fix some uninitalised warnings
  iptables: fix uninitialised use of entry_return
  pacrunner: remove unitialised use of host_ret variable


 plugins/pacrunner.c   |3 ---
 src/iptables.c|7 ---
 src/rtnl.c|8 +---
 tools/iptables-test.c |7 ---
 4 files changed, 13 insertions(+), 12 deletions(-)

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


crash in append_domain()

2011-02-07 Thread Kalle Valo
Hi,

today I started seeing very frequent connman crashes. I updated my
openwrt access point yesterday and enabled rdnss, maybe that's somehow
related?

Below is the stacktrace. It's with my gcc 4.5 warning fixes (which I'm
about to send), but I can see the crashes with the vanilla master
branch.

#0  __strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:107
#1  0x77b52f89 in g_str_equal (v1=, 
v2=)
at /build/buildd/glib2.0-2.27.93/glib/gstring.c:116
#2  0x00449eee in append_domain (interface=0x725f00 "wlan0", 
domain=0x0) at src/dnsproxy.c:855
#3  0x0044b97d in __connman_dnsproxy_append (
interface=0x725f00 "wlan0", domain=0x0, 
server=0x7fffe290 "2001:b18:0:1000:2e0:81ff:fe61:ae0d")
at src/dnsproxy.c:889
#4  0x00437a8b in append_resolver (interface=0x725f00 "wlan0", 
domain=0x0, server=0x7fffe290 "2001:b18:0:1000:2e0:81ff:fe61:ae0d", 
lifetime=600, flags=0) at src/resolver.c:272
#5  0x00440429 in rtnl_newnduseropt (chan=, 
cond=, data=) at src/rtnl.c:1153
#6  rtnl_message (chan=, cond=, 
data=) at src/rtnl.c:1322
#7  netlink_event (chan=, cond=, 
data=) at src/rtnl.c:1355
#8  0x77b30cfd in g_main_dispatch (context=0x671100)
at /build/buildd/glib2.0-2.27.93/glib/gmain.c:2440
#9  g_main_context_dispatch (context=0x671100)
at /build/buildd/glib2.0-2.27.93/glib/gmain.c:3013
#10 0x77b314e8 in g_main_context_iterate (context=0x671100, 
block=, dispatch=1, self=)
at /build/buildd/glib2.0-2.27.93/glib/gmain.c:3091
#11 0x77b31b2a in g_main_loop_run (loop=0x6711e0)
at /build/buildd/glib2.0-2.27.93/glib/gmain.c:3299
#12 0x00422087 in main (argc=1, argv=0x7fffe658) at src/main.c:246

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: ConnMan relicensing

2011-02-04 Thread Kalle Valo
Russell Dill  writes:

> Has ConnMan every been relicensed (eg, distributed under a license
> other than the GPL) and/or does Intel have any plans to relicense
> ConnMan?

Relicensing connman would be difficult because there are so many
contributors and you would need approval from all of them.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [RFC] doc: Add EAP login support in Agent API

2011-02-04 Thread Kalle Valo
Bragge Henri  writes:

> Hi Samuel,
>
> On Thu, 2011-02-03 at 17:13 +0100, Samuel Ortiz wrote: 
>> Hi Henri,
>
>> > @@ -97,6 +102,18 @@ Arguments  string Type
>> >Contains the list of alternate field names this
>> >field can be represented by.
>> >  
>> > +  string Phase2
>> > +
>> > +  EAP Phase2 authentication method. For example "gtc",
>> > +  "mschapv2", or "md5". Used to supplement Passphrase
>> > +  field when requesting credentials for 802.1X networks.
>> This is something I don't want to present to the user. Typically, the user
>> knows its identity and a passphrase associated to it. So asking for an EAP
>> passphrase is good enough. 
>> 
>
> I agree that we don't want to show Phase2 method to the user as such.
> Instead the reason for it is to enable customization of UI further by
> having a different dialog for, say, MSCHAPV2 username/password dialog
> and GTC challenge dialog.
>
> I've seen such customizations for example in Nokia N900, where user is
> asked for "Username" & "Password" in the former case and "Response" in
> the latter.

I agree with Henri. Providing the authentication method makes it easier
for the UI application to help the user.

> Maybe instead of the literal phase2 method, additional Passphrase types
> could be introduced, like "eap-password" and "eap-response"?

To me that sounds a bit artificial and I don't see any benefit compared
to using real method names. And besides there's no harm providing the
method to the UI, and it's extremely simple to implement.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v2] dnsproxy: Fallback to resolv.conf if dnsproxy fails

2011-01-31 Thread Kalle Valo
Samuel Ortiz  writes:

> Hi Kalle,
>
> On Mon, Jan 31, 2011 at 04:28:19PM +0200, Kalle Valo wrote:
>> Kalle Valo  writes:
>> 
>> > Daniel Wagner  writes:
>> >
>> >> In case dnsproxy can't create the socket listener we
>> >> should fall back to resolv.conf.
>> >>
>> >> Reported by Kalle Valo 
>> >
>> > dnsproxy now works as it did earlier and dns works even if I had dnsmasq
>> > accidentally running. Thanks a lot for fixing this.
>> 
>> Just noticed that this is not yet applied and, to my dismay, it also
>> missed 0.68 release :( 
>>
>> Is there anything wrong with the patch or is just in the queue? Is there
>> anything I can do to help?
>
> It's been pushed now, it just got lost on my patch queue somehow.
> Sorry for the glitch.

No problem. Thank you for taking it now.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v2] dnsproxy: Fallback to resolv.conf if dnsproxy fails

2011-01-31 Thread Kalle Valo
Kalle Valo  writes:

> Daniel Wagner  writes:
>
>> In case dnsproxy can't create the socket listener we
>> should fall back to resolv.conf.
>>
>> Reported by Kalle Valo 
>
> dnsproxy now works as it did earlier and dns works even if I had dnsmasq
> accidentally running. Thanks a lot for fixing this.

Just noticed that this is not yet applied and, to my dismay, it also
missed 0.68 release :( 

Is there anything wrong with the patch or is just in the queue? Is there
anything I can do to help?

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: Connman-0.67 Crashes and/or Hangs on Start-up

2011-01-30 Thread Kalle Valo
Hi Grant,

Grant Erickson  writes:

> Between you and Samuel, it's good to hear that both the Atheros AR242x and
> Intel IWLAGN work well with 0.68/b1db3cb under wireless extensions with the
> non-legacy Wi-Fi plug-in. Would I be correct in assuming that both you and
> Samuel are using a Core iX or Atom platform? Against what kernel version are
> you running?
>
> In my case, it's linux-2.6.32, armv7l and TI WLAN 127x, their TIWLAN WiLink
> 6.1.0.2.144 driver and firmware 6.1.0.0.335.

TI's WiLink driver might behave oddly and simply have bugs in it's wext
interface. I strongly recommend to use the proper upstream driver
wl12xx:

http://linuxwireless.org/en/users/Drivers/wl12xx

In the long run you will save a lot of trouble. For example, it will
work with wpasupplicant and connman out of box, thanks to mac80211
stack. Out-of-tree drivers are always pain, avoid them like the plague.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v3 0/4] nmcompat plugin

2011-01-28 Thread Kalle Valo
Kalle Valo  writes:

> Based on discussion on IRC, here are patches to move all nm code to 
> a plugin. This way it doesn't affect core code but still applications get
> network state events.
>
> Tested with pidgin and empathy from Ubuntu 10.10.
>
> v3: 
>  o fix nm_state() to use correct variable
>  o separate dbus configuration file
>
> v2: more error checking in init() and fixed one too long line

[...]

>  plugins/connman-nmcompat.conf |   14 ++
>  plugins/nmcompat.c|  282 
> +
>  2 files changed, 296 insertions(+), 0 deletions(-)

It seems stgit is playing tricks on me and diffstats are wrong
in almost of the patches I sent.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v3 4/4] nmcompat: dbus configuration file

2011-01-28 Thread Kalle Valo
Add separate dbus configuration file for nmcompat plugin. It will
installed only when the plugin is enabled.
---
 plugins/connman-nmcompat.conf |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)
 create mode 100644 plugins/connman-nmcompat.conf

diff --git a/Makefile.am b/Makefile.am
index 67b2c29..144fcc5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,9 +32,14 @@ gweb_sources = gweb/gweb.h gweb/gweb.c gweb/gresolv.h 
gweb/gresolv.c \
gweb/giognutls.h gweb/giognutls.c
 
 if DATAFILES
+
+if NMCOMPAT
+nmcompat_conf = plugins/connman-nmcompat.conf
+endif
+
 dbusconfdir = @DBUS_CONFDIR@
 
-dbusconf_DATA = src/connman.conf
+dbusconf_DATA = src/connman.conf $(nmcompat_conf)
 
 if SYSTEMD
 systemdunitdir = @SYSTEMD_UNITDIR@
@@ -109,7 +114,8 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPNG_CFLAGS@ 
@XTABLES_CFLAGS@ \
 
 INCLUDES = -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus
 
-EXTRA_DIST = src/genbuiltin src/connman-dbus.conf src/connman-polkit.conf
+EXTRA_DIST = src/genbuiltin src/connman-dbus.conf src/connman-polkit.conf \
+   plugins/connman-nmcompat.conf
 
 
 script_DATA =
diff --git a/plugins/connman-nmcompat.conf b/plugins/connman-nmcompat.conf
new file mode 100644
index 000..5887a34
--- /dev/null
+++ b/plugins/connman-nmcompat.conf
@@ -0,0 +1,14 @@
+http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd";>
+
+
+
+
+
+
+
+
+
+
+
+

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v3 3/4] nmcompat: support nm dbus properties

2011-01-28 Thread Kalle Valo
After some investigation I found that network-manager also provides
the network state through properties and libnm-glib library uses this
instead of the GetState() method.

Add Get() method call retrieve the property and a PropertyChanged signal
to notify state changes. Now empathy, which uses libnm-glib, properly
detects network state changes.

I deliberately omitted GetAll() method because libnm-glib doesn't seem
to need it.
---
 plugins/nmcompat.c |   94 
 1 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c
index 876c00f..2b74a40 100644
--- a/plugins/nmcompat.c
+++ b/plugins/nmcompat.c
@@ -43,6 +43,8 @@ enum {
 #define NM_PATH   "/org/freedesktop/NetworkManager"
 #define NM_INTERFACE  NM_SERVICE
 
+#define DBUS_PROPERTIES_INTERFACE  "org.freedesktop.DBus.Properties"
+
 static DBusConnection *connection = NULL;
 static dbus_uint32_t state = NM_STATE_UNKNOWN;
 
@@ -61,6 +63,45 @@ static void nm_send_signal(const char *name, dbus_uint32_t 
state)
g_dbus_send_message(connection, signal);
 }
 
+static void nm_send_prop_signal(dbus_uint32_t state)
+{
+   const char *key = "State";
+   DBusMessageIter iter, dict, dict_entry, dict_val;
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE,
+   "PropertiesChanged");
+   if (signal == NULL)
+   return;
+
+   dbus_message_iter_init_append(signal, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+   DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_STRING_AS_STRING
+   DBUS_TYPE_VARIANT_AS_STRING
+   DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+   &dict);
+
+   dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
+   NULL, &dict_entry);
+
+   dbus_message_iter_append_basic(&dict_entry, DBUS_TYPE_STRING,
+   &key);
+
+   dbus_message_iter_open_container(&dict_entry,
+   DBUS_TYPE_VARIANT,
+   DBUS_TYPE_UINT32_AS_STRING, &dict_val);
+
+   dbus_message_iter_append_basic(&dict_val, DBUS_TYPE_UINT32, &state);
+
+   dbus_message_iter_close_container(&dict_entry, &dict_val);
+   dbus_message_iter_close_container(&dict, &dict_entry);
+   dbus_message_iter_close_container(&iter, &dict);
+
+   g_dbus_send_message(connection, signal);
+}
+
 static void default_changed(struct connman_service *service)
 {
if (service != NULL)
@@ -75,6 +116,8 @@ static void default_changed(struct connman_service *service)
 
/* the preferred current signal */
nm_send_signal("StateChanged", state);
+
+   nm_send_prop_signal(state);
 }
 
 static struct connman_notifier notifier = {
@@ -139,6 +182,47 @@ static GDBusMethodTable nm_methods[] = {
{ },
 };
 
+static DBusMessage *nm_prop_get(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessageIter iter, value;
+   const char *interface, *key;
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_get_args(msg, NULL,
+   DBUS_TYPE_STRING, &interface,
+   DBUS_TYPE_STRING, &key,
+   DBUS_TYPE_INVALID);
+
+   if (g_strcmp0(key, "State") == 0) {
+   dbus_message_iter_init_append(reply, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
+   DBUS_TYPE_UINT32_AS_STRING,
+   &value);
+   dbus_message_iter_append_basic(&value, DBUS_TYPE_UINT32,
+   &state);
+   dbus_message_iter_close_container(&iter, &value);
+   } else {
+   dbus_message_unref(reply);
+   return dbus_message_new_error(msg, DBUS_ERROR_FAILED,
+   "Unsupported property");
+   }
+
+   return reply;
+}
+
+static GDBusMethodTable nm_prop_methods[] = {
+   { "Get", "ss",  "v",   nm_prop_get  },
+   { },
+};
+
 static int nmcompat_init(void)
 {
gboolean ret;
@@ -166,6 +250,16 @@ static int nmcompat_init(void)
return -1;
}
 
+   ret = g_dbus_register_interface(connection, NM_PATH,
+   DBUS_PROPERTIES_INTERFACE,
+   nm_prop_methods, NULL, NULL,
+   NULL, NULL);
+   i

[PATCH v3 2/4] nmcompat: add plugin

2011-01-28 Thread Kalle Valo
Add plugin which provides network-manager state interface to applications.
This is a direct copy of what was in src/manager.c, just copied all into
a plugin.
---
 plugins/nmcompat.c |  188 
 1 files changed, 188 insertions(+), 0 deletions(-)
 create mode 100644 plugins/nmcompat.c

diff --git a/Makefile.plugins b/Makefile.plugins
index 1841697..af3cfa0 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -269,6 +269,18 @@ plugins_ntpd_la_LDFLAGS = $(plugin_ldflags)
 endif
 endif
 
+if NMCOMPAT
+if NMCOMPAT_BUILTIN
+builtin_modules += nmcompat
+builtin_sources += plugins/nmcompat.c
+else
+plugin_LTLIBRARIES += plugins/nmcompat.la
+plugin_objects += $(plugins_nmcompat_la_OBJECTS)
+plugins_nmcompat_la_CFLAGS = $(plugin_cflags)
+plugins_nmcompat_la_LDFLAGS = $(plugin_ldflags)
+endif
+endif
+
 EXTRA_DIST += plugins/polkit.policy
 
 plugins/net.connman.policy: plugins/polkit.policy
diff --git a/configure.ac b/configure.ac
index 66bee66..38aa4b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,6 +274,12 @@ fi
 AM_CONDITIONAL(NTPD, test "${enable_ntpd}" != "no")
 AM_CONDITIONAL(NTPD_BUILTIN, test "${enable_ntpd}" = "builtin")
 
+AC_ARG_ENABLE(nmcompat,
+   AC_HELP_STRING([--enable-nmcompat], [enable nmcompat support]),
+   [enable_nmcompat=${enableval}], [enable_nmcompat="no"])
+AM_CONDITIONAL(NMCOMPAT, test "${enable_nmcompat}" != "no")
+AM_CONDITIONAL(NMCOMPAT_BUILTIN, test "${enable_nmcompat}" = "builtin")
+
 AC_ARG_WITH(stats-max-file-size, 
AC_HELP_STRING([--with-stats-max-file-size=SIZE],
[Maximal size of a statistics round robin file]),
[stats_max_file_size=${withval}])
diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c
new file mode 100644
index 000..876c00f
--- /dev/null
+++ b/plugins/nmcompat.c
@@ -0,0 +1,188 @@
+/*
+ *
+ *  Connection Manager
+ *
+ *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
+
+#define CONNMAN_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+
+enum {
+   NM_STATE_UNKNOWN = 0,
+   NM_STATE_ASLEEP,
+   NM_STATE_CONNECTING,
+   NM_STATE_CONNECTED,
+   NM_STATE_DISCONNECTED
+};
+
+#define NM_SERVICE"org.freedesktop.NetworkManager"
+#define NM_PATH   "/org/freedesktop/NetworkManager"
+#define NM_INTERFACE  NM_SERVICE
+
+static DBusConnection *connection = NULL;
+static dbus_uint32_t state = NM_STATE_UNKNOWN;
+
+
+static void nm_send_signal(const char *name, dbus_uint32_t state)
+{
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
+   if (signal == NULL)
+   return;
+
+   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
+   DBUS_TYPE_INVALID);
+
+   g_dbus_send_message(connection, signal);
+}
+
+static void default_changed(struct connman_service *service)
+{
+   if (service != NULL)
+   state = NM_STATE_CONNECTED;
+   else
+   state = NM_STATE_DISCONNECTED;
+
+   DBG("%p %d", service, state);
+
+   /* older deprecated signal, in case applications still use this */
+   nm_send_signal("StateChange", state);
+
+   /* the preferred current signal */
+   nm_send_signal("StateChanged", state);
+}
+
+static struct connman_notifier notifier = {
+   .name   = "nmcompat",
+   .priority   = CONNMAN_NOTIFIER_PRIORITY_DEFAULT,
+   .default_changed= default_changed,
+};
+
+static DBusMessage *nm_sleep(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_append_args(reply, DBUS_TYPE_INVALID);
+
+   return reply;
+}
+
+static DBusMessage *nm_wake(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_append_args(reply, DBUS_TYPE_

[PATCH v3 1/4] manager: remove network-manager compatibility code

2011-01-28 Thread Kalle Valo
Remove the network-manager compatibility code from src/manager.c so that all
this can be implemented as a plugin.

-c command line switch is still left but marked as obsole to avoid breaking
current start scripts. By removing the switch connman would not start at
all if -c is used.
---
 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 972c435..979c564 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -25,10 +25,6 @@
 
 #include 
 
-#define NM_SERVICE"org.freedesktop.NetworkManager"
-#define NM_PATH   "/org/freedesktop/NetworkManager"
-#define NM_INTERFACE  NM_SERVICE
-
 int __connman_dbus_init(DBusConnection *conn);
 void __connman_dbus_cleanup(void);
 
@@ -55,7 +51,7 @@ DBusMessage *__connman_error_invalid_property(DBusMessage 
*msg);
 
 #include 
 
-int __connman_manager_init(gboolean compat);
+int __connman_manager_init(void);
 void __connman_manager_cleanup(void);
 
 int __connman_agent_init(void);
diff --git a/src/main.c b/src/main.c
index 08f2555..d8cc8ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -99,7 +99,7 @@ static GOptionEntry options[] = {
G_OPTION_ARG_NONE, &option_dnsproxy,
"Don't enable DNS Proxy" },
{ "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat,
-   "Enable Network Manager compatibility" },
+   "(obsolete)" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Show version information and exit" },
{ NULL },
@@ -204,13 +204,6 @@ int main(int argc, char *argv[])
 
g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL);
 
-   if (option_compat == TRUE) {
-   if (g_dbus_request_name(conn, NM_SERVICE, NULL) == FALSE) {
-   fprintf(stderr, "Can't register compat service\n");
-   option_compat = FALSE;
-   }
-   }
-
__connman_log_init(option_debug, option_detach);
 
__connman_dbus_init(conn);
@@ -222,7 +215,7 @@ int main(int argc, char *argv[])
__connman_iptables_init();
__connman_tethering_init();
__connman_counter_init();
-   __connman_manager_init(option_compat);
+   __connman_manager_init();
__connman_profile_init();
__connman_config_init();
__connman_stats_init();
diff --git a/src/manager.c b/src/manager.c
index 6fb54e1..9705b05 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -27,16 +27,6 @@
 
 #include "connman.h"
 
-enum {
-   NM_STATE_UNKNOWN = 0,
-   NM_STATE_ASLEEP,
-   NM_STATE_CONNECTING,
-   NM_STATE_CONNECTED,
-   NM_STATE_DISCONNECTED
-};
-
-static gboolean nm_compat = FALSE;
-
 static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -313,46 +303,10 @@ static void technology_notify(enum connman_service_type 
type,
technology_reply(0);
 }
 
-static void nm_send_signal(const char *name, dbus_uint32_t state)
-{
-   DBusMessage *signal;
-
-   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
-   if (signal == NULL)
-   return;
-
-   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
-   DBUS_TYPE_INVALID);
-
-   g_dbus_send_message(connection, signal);
-}
-
-static void default_changed(struct connman_service *service)
-{
-   dbus_uint32_t state;
-
-   if (!nm_compat)
-   return;
-
-   if (service != NULL)
-   state = NM_STATE_CONNECTED;
-   else
-   state = NM_STATE_DISCONNECTED;
-
-   DBG("%p %d", service, state);
-
-   /* older deprecated signal, in case applications still use this */
-   nm_send_signal("StateChange", state);
-
-   /* the preferred current signal */
-   nm_send_signal("StateChanged", state);
-}
-
 static struct connman_notifier technology_notifier = {
.name   = "manager",
.priority   = CONNMAN_NOTIFIER_PRIORITY_HIGH,
.service_enabled= technology_notify,
-   .default_changed= default_changed,
 };
 
 static DBusMessage *enable_technology(DBusConnection *conn,
@@ -698,69 +652,7 @@ static GDBusSignalTable manager_signals[] = {
{ },
 };
 
-static DBusMessage *nm_sleep(DBusConnection *conn,
-   DBusMessage *msg, void *data)
-{
-   DBusMessage *reply;
-
-   DBG("conn %p", conn);
-
-   reply = dbus_message_new_method_return(msg);
-   if (reply == NULL)
-   return NULL;
-
-   dbus_message_append_args(reply, DBUS_TYPE_INVALID);
-
-   return reply;
-}
-
-static DBusMessage *nm_wake(DBusConnection *conn,
-   DBusMessage *msg, void *data)
-{
-   DBusMessage *reply;
-
-   DBG("conn %p", conn);
-
-   reply = dbus_message_new_method_return(msg);
-

[PATCH v3 0/4] nmcompat plugin

2011-01-28 Thread Kalle Valo
Based on discussion on IRC, here are patches to move all nm code to 
a plugin. This way it doesn't affect core code but still applications get
network state events.

Tested with pidgin and empathy from Ubuntu 10.10.

v3: 
 o fix nm_state() to use correct variable
 o separate dbus configuration file

v2: more error checking in init() and fixed one too long line


---

Kalle Valo (4):
  manager: remove network-manager compatibility code
  nmcompat: add plugin
  nmcompat: support nm dbus properties
  nmcompat: dbus configuration file


 plugins/connman-nmcompat.conf |   14 ++
 plugins/nmcompat.c|  282 +
 2 files changed, 296 insertions(+), 0 deletions(-)
 create mode 100644 plugins/connman-nmcompat.conf
 create mode 100644 plugins/nmcompat.c

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v2 4/4] dbus: allow owning org.freedesktop.NetworkManager

2011-01-28 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Kalle,

Hi Marcel,

>> The network-manager compatibility interface doesn't start unless
>> we allow connman to own the interface in the dbus configuration.
>> ---
>>  src/connman-dbus.conf |1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> you need to create a separate one that belongs to the plugin. Only when
> the plugin is compiled in or selected we should punch this whole in the
> policy.

Ok, will do.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v2 4/4] dbus: allow owning org.freedesktop.NetworkManager

2011-01-28 Thread Kalle Valo
The network-manager compatibility interface doesn't start unless
we allow connman to own the interface in the dbus configuration.
---
 src/connman-dbus.conf |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/connman-dbus.conf b/src/connman-dbus.conf
index 311f28c..fa70297 100644
--- a/src/connman-dbus.conf
+++ b/src/connman-dbus.conf
@@ -3,6 +3,7 @@
 
 
 
+
 
 
 

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v2 3/4] nmcompat: support nm dbus properties

2011-01-28 Thread Kalle Valo
After some investigation I found that network-manager also provides
the network state through properties and libnm-glib library uses this
instead of the GetState() method.

Add Get() method call retrieve the property and a PropertyChanged signal
to notify state changes. Now empathy, which uses libnm-glib, properly
detects network state changes.

I deliberately omitted GetAll() method because libnm-glib doesn't seem
to need it.
---
 plugins/nmcompat.c |   94 
 1 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c
index 0135d03..2aec1d8 100644
--- a/plugins/nmcompat.c
+++ b/plugins/nmcompat.c
@@ -43,6 +43,8 @@ enum {
 #define NM_PATH   "/org/freedesktop/NetworkManager"
 #define NM_INTERFACE  NM_SERVICE
 
+#define DBUS_PROPERTIES_INTERFACE  "org.freedesktop.DBus.Properties"
+
 static DBusConnection *connection = NULL;
 static dbus_uint32_t state = NM_STATE_UNKNOWN;
 
@@ -61,6 +63,45 @@ static void nm_send_signal(const char *name, dbus_uint32_t 
state)
g_dbus_send_message(connection, signal);
 }
 
+static void nm_send_prop_signal(dbus_uint32_t state)
+{
+   const char *key = "State";
+   DBusMessageIter iter, dict, dict_entry, dict_val;
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE,
+   "PropertiesChanged");
+   if (signal == NULL)
+   return;
+
+   dbus_message_iter_init_append(signal, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+   DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_STRING_AS_STRING
+   DBUS_TYPE_VARIANT_AS_STRING
+   DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+   &dict);
+
+   dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
+   NULL, &dict_entry);
+
+   dbus_message_iter_append_basic(&dict_entry, DBUS_TYPE_STRING,
+   &key);
+
+   dbus_message_iter_open_container(&dict_entry,
+   DBUS_TYPE_VARIANT,
+   DBUS_TYPE_UINT32_AS_STRING, &dict_val);
+
+   dbus_message_iter_append_basic(&dict_val, DBUS_TYPE_UINT32, &state);
+
+   dbus_message_iter_close_container(&dict_entry, &dict_val);
+   dbus_message_iter_close_container(&dict, &dict_entry);
+   dbus_message_iter_close_container(&iter, &dict);
+
+   g_dbus_send_message(connection, signal);
+}
+
 static void default_changed(struct connman_service *service)
 {
if (service != NULL)
@@ -75,6 +116,8 @@ static void default_changed(struct connman_service *service)
 
/* the preferred current signal */
nm_send_signal("StateChanged", state);
+
+   nm_send_prop_signal(state);
 }
 
 static struct connman_notifier notifier = {
@@ -140,6 +183,47 @@ static GDBusMethodTable nm_methods[] = {
{ },
 };
 
+static DBusMessage *nm_prop_get(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessageIter iter, value;
+   const char *interface, *key;
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_get_args(msg, NULL,
+   DBUS_TYPE_STRING, &interface,
+   DBUS_TYPE_STRING, &key,
+   DBUS_TYPE_INVALID);
+
+   if (g_strcmp0(key, "State") == 0) {
+   dbus_message_iter_init_append(reply, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
+   DBUS_TYPE_UINT32_AS_STRING,
+   &value);
+   dbus_message_iter_append_basic(&value, DBUS_TYPE_UINT32,
+   &state);
+   dbus_message_iter_close_container(&iter, &value);
+   } else {
+   dbus_message_unref(reply);
+   return dbus_message_new_error(msg, DBUS_ERROR_FAILED,
+   "Unsupported property");
+   }
+
+   return reply;
+}
+
+static GDBusMethodTable nm_prop_methods[] = {
+   { "Get", "ss",  "v",   nm_prop_get  },
+   { },
+};
+
 static int nmcompat_init(void)
 {
gboolean ret;
@@ -167,6 +251,16 @@ static int nmcompat_init(void)
return -1;
}
 
+   ret = g_dbus_register_interface(connection, NM_PATH,
+   DBUS_PROPERTIES_INTERFACE,
+   nm_prop_methods, NULL, NULL,
+   NULL, NULL);
+   i

[PATCH v2 2/4] nmcompat: add plugin

2011-01-28 Thread Kalle Valo
Add plugin which provides network-manager state interface to applications.
This is a direct copy of what was in src/manager.c, just copied all into
a plugin.
---
 Makefile.plugins   |   12 +++
 configure.ac   |6 ++
 plugins/nmcompat.c |  189 
 3 files changed, 207 insertions(+), 0 deletions(-)
 create mode 100644 plugins/nmcompat.c

diff --git a/Makefile.plugins b/Makefile.plugins
index e87f10b..eb317f3 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -272,6 +272,18 @@ plugins_ntpd_la_LDFLAGS = $(plugin_ldflags)
 endif
 endif
 
+if NMCOMPAT
+if NMCOMPAT_BUILTIN
+builtin_modules += nmcompat
+builtin_sources += plugins/nmcompat.c
+else
+plugin_LTLIBRARIES += plugins/nmcompat.la
+plugin_objects += $(plugins_nmcompat_la_OBJECTS)
+plugins_nmcompat_la_CFLAGS = $(plugin_cflags)
+plugins_nmcompat_la_LDFLAGS = $(plugin_ldflags)
+endif
+endif
+
 EXTRA_DIST += plugins/polkit.policy
 
 plugins/net.connman.policy: plugins/polkit.policy
diff --git a/configure.ac b/configure.ac
index 951b7a3..f2d401f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,6 +274,12 @@ fi
 AM_CONDITIONAL(NTPD, test "${enable_ntpd}" != "no")
 AM_CONDITIONAL(NTPD_BUILTIN, test "${enable_ntpd}" = "builtin")
 
+AC_ARG_ENABLE(nmcompat,
+   AC_HELP_STRING([--enable-nmcompat], [enable nmcompat support]),
+   [enable_nmcompat=${enableval}], [enable_nmcompat="no"])
+AM_CONDITIONAL(NMCOMPAT, test "${enable_nmcompat}" != "no")
+AM_CONDITIONAL(NMCOMPAT_BUILTIN, test "${enable_nmcompat}" = "builtin")
+
 AC_ARG_WITH(stats-max-file-size, 
AC_HELP_STRING([--with-stats-max-file-size=SIZE],
[Maximal size of a statistics round robin file]),
[stats_max_file_size=${withval}])
diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c
new file mode 100644
index 000..0135d03
--- /dev/null
+++ b/plugins/nmcompat.c
@@ -0,0 +1,189 @@
+/*
+ *
+ *  Connection Manager
+ *
+ *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
+
+#define CONNMAN_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+
+enum {
+   NM_STATE_UNKNOWN = 0,
+   NM_STATE_ASLEEP,
+   NM_STATE_CONNECTING,
+   NM_STATE_CONNECTED,
+   NM_STATE_DISCONNECTED
+};
+
+#define NM_SERVICE"org.freedesktop.NetworkManager"
+#define NM_PATH   "/org/freedesktop/NetworkManager"
+#define NM_INTERFACE  NM_SERVICE
+
+static DBusConnection *connection = NULL;
+static dbus_uint32_t state = NM_STATE_UNKNOWN;
+
+
+static void nm_send_signal(const char *name, dbus_uint32_t state)
+{
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
+   if (signal == NULL)
+   return;
+
+   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
+   DBUS_TYPE_INVALID);
+
+   g_dbus_send_message(connection, signal);
+}
+
+static void default_changed(struct connman_service *service)
+{
+   if (service != NULL)
+   state = NM_STATE_CONNECTED;
+   else
+   state = NM_STATE_DISCONNECTED;
+
+   DBG("%p %d", service, state);
+
+   /* older deprecated signal, in case applications still use this */
+   nm_send_signal("StateChange", state);
+
+   /* the preferred current signal */
+   nm_send_signal("StateChanged", state);
+}
+
+static struct connman_notifier notifier = {
+   .name   = "nmcompat",
+   .priority   = CONNMAN_NOTIFIER_PRIORITY_DEFAULT,
+   .default_changed= default_changed,
+};
+
+static DBusMessage *nm_sleep(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_append_args(reply, DBUS_TYPE_INVALID);
+
+   return reply;
+}
+
+static DBusMessage *nm_wake(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   retu

[PATCH v2 1/4] manager: remove network-manager compatibility code

2011-01-28 Thread Kalle Valo
Remove the network-manager compatibility code from src/manager.c so that all
this can be implemented as a plugin.

-c command line switch is still left but marked as obsole to avoid breaking
current start scripts. By removing the switch connman would not start at
all if -c is used.
---
 src/connman.h |6 ---
 src/main.c|   11 +
 src/manager.c |  121 -
 3 files changed, 4 insertions(+), 134 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 5bcda43..6e3b3ba 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -25,10 +25,6 @@
 
 #include 
 
-#define NM_SERVICE"org.freedesktop.NetworkManager"
-#define NM_PATH   "/org/freedesktop/NetworkManager"
-#define NM_INTERFACE  NM_SERVICE
-
 int __connman_dbus_init(DBusConnection *conn);
 void __connman_dbus_cleanup(void);
 
@@ -55,7 +51,7 @@ DBusMessage *__connman_error_invalid_property(DBusMessage 
*msg);
 
 #include 
 
-int __connman_manager_init(gboolean compat);
+int __connman_manager_init(void);
 void __connman_manager_cleanup(void);
 
 int __connman_agent_init(void);
diff --git a/src/main.c b/src/main.c
index 08f2555..d8cc8ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -99,7 +99,7 @@ static GOptionEntry options[] = {
G_OPTION_ARG_NONE, &option_dnsproxy,
"Don't enable DNS Proxy" },
{ "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat,
-   "Enable Network Manager compatibility" },
+   "(obsolete)" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Show version information and exit" },
{ NULL },
@@ -204,13 +204,6 @@ int main(int argc, char *argv[])
 
g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL);
 
-   if (option_compat == TRUE) {
-   if (g_dbus_request_name(conn, NM_SERVICE, NULL) == FALSE) {
-   fprintf(stderr, "Can't register compat service\n");
-   option_compat = FALSE;
-   }
-   }
-
__connman_log_init(option_debug, option_detach);
 
__connman_dbus_init(conn);
@@ -222,7 +215,7 @@ int main(int argc, char *argv[])
__connman_iptables_init();
__connman_tethering_init();
__connman_counter_init();
-   __connman_manager_init(option_compat);
+   __connman_manager_init();
__connman_profile_init();
__connman_config_init();
__connman_stats_init();
diff --git a/src/manager.c b/src/manager.c
index 6fb54e1..9705b05 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -27,16 +27,6 @@
 
 #include "connman.h"
 
-enum {
-   NM_STATE_UNKNOWN = 0,
-   NM_STATE_ASLEEP,
-   NM_STATE_CONNECTING,
-   NM_STATE_CONNECTED,
-   NM_STATE_DISCONNECTED
-};
-
-static gboolean nm_compat = FALSE;
-
 static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -313,46 +303,10 @@ static void technology_notify(enum connman_service_type 
type,
technology_reply(0);
 }
 
-static void nm_send_signal(const char *name, dbus_uint32_t state)
-{
-   DBusMessage *signal;
-
-   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
-   if (signal == NULL)
-   return;
-
-   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
-   DBUS_TYPE_INVALID);
-
-   g_dbus_send_message(connection, signal);
-}
-
-static void default_changed(struct connman_service *service)
-{
-   dbus_uint32_t state;
-
-   if (!nm_compat)
-   return;
-
-   if (service != NULL)
-   state = NM_STATE_CONNECTED;
-   else
-   state = NM_STATE_DISCONNECTED;
-
-   DBG("%p %d", service, state);
-
-   /* older deprecated signal, in case applications still use this */
-   nm_send_signal("StateChange", state);
-
-   /* the preferred current signal */
-   nm_send_signal("StateChanged", state);
-}
-
 static struct connman_notifier technology_notifier = {
.name   = "manager",
.priority   = CONNMAN_NOTIFIER_PRIORITY_HIGH,
.service_enabled= technology_notify,
-   .default_changed= default_changed,
 };
 
 static DBusMessage *enable_technology(DBusConnection *conn,
@@ -698,69 +652,7 @@ static GDBusSignalTable manager_signals[] = {
{ },
 };
 
-static DBusMessage *nm_sleep(DBusConnection *conn,
-   DBusMessage *msg, void *data)
-{
-   DBusMessage *reply;
-
-   DBG("conn %p", conn);
-
-   reply = dbus_message_new_method_return(msg);
-   if (reply == NULL)
-   return NULL;
-
-   dbus_message_append_args(reply, DBUS_TYPE_INVALID);
-
-   return reply;
-}
-
-static DBusMessage *nm_wake(DBusConnection *conn,
-   DBusMessage *

[PATCH v2 0/4] nmcompat plugin

2011-01-28 Thread Kalle Valo
Based on discussion on IRC, here are patches to move all nm code to 
a plugin. This way it doesn't affect core code but still applications get
network state events.

Tested with pidgin and empathy from Ubuntu 10.10.

v2: more error checking in init() and fixed one too long line

---

Kalle Valo (4):
  manager: remove network-manager compatibility code
  nmcompat: add plugin
  nmcompat: support nm dbus properties
  dbus: allow owning org.freedesktop.NetworkManager


 Makefile.plugins  |   12 ++
 configure.ac  |6 +
 plugins/nmcompat.c|  283 +
 src/connman-dbus.conf |1 
 src/connman.h |6 -
 src/main.c|   11 --
 src/manager.c |  121 -
 7 files changed, 306 insertions(+), 134 deletions(-)
 create mode 100644 plugins/nmcompat.c

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 2/4] nmcompat: add plugin

2011-01-27 Thread Kalle Valo
Samuel Ortiz  writes:

> Hi Kalle,

Hi Samuel,

> The patch looks pretty good, I just have one nitpick:

Thank you for the review. I'll fix the issues you found and send v2 shortly.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v2] dnsproxy: Fallback to resolv.conf if dnsproxy fails

2011-01-27 Thread Kalle Valo
Hi Daniel,

Daniel Wagner  writes:

> In case dnsproxy can't create the socket listener we
> should fall back to resolv.conf.
>
> Reported by Kalle Valo 

dnsproxy now works as it did earlier and dns works even if I had dnsmasq
accidentally running. Thanks a lot for fixing this.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: regression: resolv.conf empty

2011-01-27 Thread Kalle Valo
Kalle Valo  writes:

>>> I noticed this evening that my resolv.conf is empty:
>>
>> Could you post the log?
>
> Sure thing. And I found the culprit already, when I finally looked at the
> logs:
>
> Jan 27 10:22:39 tukki connmand[13859]: Failed to bind UDP listener socket
>
> I had dnsmasq running and that's why the port was already taken.

Just to be clear, this is still a regression. Earlier connman was able
to fallback to updating resolv.conf if dnsproxy didn't start for some
reason. Now DNS will be broken if dnsproxy fails for some reason.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


regression: resolv.conf empty

2011-01-26 Thread Kalle Valo
Hi,

I noticed this evening that my resolv.conf is empty:

tukki:~$ cat /etc/resolv.conf 
# Generated by Connection Manager
tukki:~$ 

Even though I have nameservers configured:

tukki:~$ cmcc show valo | grep Nameservers
  Nameservers = [ 192.168.1.1 2001:b18:0:1000:2e0:81ff:fe61:ae0d 
2001:16d8::3::2 ]
  Nameservers.Configuration = [ 192.168.1.1 2001:b18:0:1000:2e0:81ff:fe61:ae0d 
2001:16d8::3::2 ]
tukki:~$ 

If I start connman with -r switch, I see the nameservers again in
resolv.conf. But without -r switch resolv.conf stays empty.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 4/4] dbus: allow owning org.freedesktop.NetworkManager

2011-01-26 Thread Kalle Valo
The network-manager compatibility interface doesn't start unless
we allow connman to own the interface in the dbus configuration.
---
 src/connman-dbus.conf |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/connman-dbus.conf b/src/connman-dbus.conf
index 311f28c..fa70297 100644
--- a/src/connman-dbus.conf
+++ b/src/connman-dbus.conf
@@ -3,6 +3,7 @@
 
 
 
+
 
 
 

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 3/4] nmcompat: support nm dbus properties

2011-01-26 Thread Kalle Valo
After some investigation I found that network-manager also provides
the network state through properties and libnm-glib library uses this
instead of the GetState() method.

Add Get() method call retrieve the property and a PropertyChanged signal
to notify state changes. Now empathy, which uses libnm-glib, properly
detects network state changes.

I deliberately omitted GetAll() method because libnm-glib doesn't seem
to need it.
---
 plugins/nmcompat.c |   88 
 1 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c
index aea2250..a7d12cc 100644
--- a/plugins/nmcompat.c
+++ b/plugins/nmcompat.c
@@ -43,6 +43,8 @@ enum {
 #define NM_PATH   "/org/freedesktop/NetworkManager"
 #define NM_INTERFACE  NM_SERVICE
 
+#define DBUS_PROPERTIES_INTERFACE  "org.freedesktop.DBus.Properties"
+
 static DBusConnection *connection = NULL;
 static dbus_uint32_t state = NM_STATE_UNKNOWN;
 
@@ -61,6 +63,44 @@ static void nm_send_signal(const char *name, dbus_uint32_t 
state)
g_dbus_send_message(connection, signal);
 }
 
+static void nm_send_prop_signal(dbus_uint32_t state)
+{
+   const char *key = "State";
+   DBusMessageIter iter, dict, dict_entry, dict_val;
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE,
+   "PropertiesChanged");
+   if (signal == NULL)
+   return;
+
+   dbus_message_iter_init_append(signal, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+   DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_STRING_AS_STRING 
DBUS_TYPE_VARIANT_AS_STRING
+   DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+   &dict);
+
+   dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
+   NULL, &dict_entry);
+
+   dbus_message_iter_append_basic(&dict_entry, DBUS_TYPE_STRING,
+   &key);
+
+   dbus_message_iter_open_container(&dict_entry,
+   DBUS_TYPE_VARIANT,
+   DBUS_TYPE_UINT32_AS_STRING, &dict_val);
+
+   dbus_message_iter_append_basic(&dict_val, DBUS_TYPE_UINT32, &state);
+
+   dbus_message_iter_close_container(&dict_entry, &dict_val);
+   dbus_message_iter_close_container(&dict, &dict_entry);
+   dbus_message_iter_close_container(&iter, &dict);
+
+   g_dbus_send_message(connection, signal);
+}
+
 static void default_changed(struct connman_service *service)
 {
if (service != NULL)
@@ -75,6 +115,8 @@ static void default_changed(struct connman_service *service)
 
/* the preferred current signal */
nm_send_signal("StateChanged", state);
+
+   nm_send_prop_signal(state);
 }
 
 static struct connman_notifier notifier = {
@@ -140,6 +182,47 @@ static GDBusMethodTable nm_methods[] = {
{ },
 };
 
+static DBusMessage *nm_prop_get(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessageIter iter, value;
+   const char *interface, *key;
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_get_args(msg, NULL,
+   DBUS_TYPE_STRING, &interface,
+   DBUS_TYPE_STRING, &key,
+   DBUS_TYPE_INVALID);
+
+   if (g_strcmp0(key, "State") == 0) {
+   dbus_message_iter_init_append(reply, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
+   DBUS_TYPE_UINT32_AS_STRING,
+   &value);
+   dbus_message_iter_append_basic(&value, DBUS_TYPE_UINT32,
+   &state);
+   dbus_message_iter_close_container(&iter, &value);
+   } else {
+   dbus_message_unref(reply);
+   return dbus_message_new_error(msg, DBUS_ERROR_FAILED,
+   "Unsupported property");
+   }
+
+   return reply;
+}
+
+static GDBusMethodTable nm_prop_methods[] = {
+   { "Get", "ss",  "v",   nm_prop_get  },
+   { },
+};
+
 static int nmcompat_init(void)
 {
DBG("");
@@ -161,6 +244,11 @@ static int nmcompat_init(void)
g_dbus_register_interface(connection, NM_PATH, NM_INTERFACE,
nm_methods, NULL, NULL, NULL, NULL);
 
+   g_dbus_register_interface(connection, NM_PATH,
+   DBUS_PROPERTIES_INTERFACE,
+   nm_prop_methods, NULL, NULL,
+  

[PATCH 2/4] nmcompat: add plugin

2011-01-26 Thread Kalle Valo
Add plugin which provides network-manager state interface to applications.
This is a direct copy of what was in src/manager.c, just copied all into
a plugin.
---
 Makefile.plugins   |   12 +++
 configure.ac   |6 ++
 plugins/nmcompat.c |  183 
 3 files changed, 201 insertions(+), 0 deletions(-)
 create mode 100644 plugins/nmcompat.c

diff --git a/Makefile.plugins b/Makefile.plugins
index d8ca1b1..9310ff5 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -252,6 +252,18 @@ plugins_ntpd_la_LDFLAGS = $(plugin_ldflags)
 endif
 endif
 
+if NMCOMPAT
+if NMCOMPAT_BUILTIN
+builtin_modules += nmcompat
+builtin_sources += plugins/nmcompat.c
+else
+plugin_LTLIBRARIES += plugins/nmcompat.la
+plugin_objects += $(plugins_nmcompat_la_OBJECTS)
+plugins_nmcompat_la_CFLAGS = $(plugin_cflags)
+plugins_nmcompat_la_LDFLAGS = $(plugin_ldflags)
+endif
+endif
+
 EXTRA_DIST += plugins/polkit.policy
 
 plugins/net.connman.policy: plugins/polkit.policy
diff --git a/configure.ac b/configure.ac
index 1d95c6d..52422f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -257,6 +257,12 @@ fi
 AM_CONDITIONAL(NTPD, test "${enable_ntpd}" != "no")
 AM_CONDITIONAL(NTPD_BUILTIN, test "${enable_ntpd}" = "builtin")
 
+AC_ARG_ENABLE(nmcompat,
+   AC_HELP_STRING([--enable-nmcompat], [enable nmcompat support]),
+   [enable_nmcompat=${enableval}], [enable_nmcompat="no"])
+AM_CONDITIONAL(NMCOMPAT, test "${enable_nmcompat}" != "no")
+AM_CONDITIONAL(NMCOMPAT_BUILTIN, test "${enable_nmcompat}" = "builtin")
+
 AC_ARG_WITH(stats-max-file-size, 
AC_HELP_STRING([--with-stats-max-file-size=SIZE],
[Maximal size of a statistics round robin file]),
[stats_max_file_size=${withval}])
diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c
new file mode 100644
index 000..aea2250
--- /dev/null
+++ b/plugins/nmcompat.c
@@ -0,0 +1,183 @@
+/*
+ *
+ *  Connection Manager
+ *
+ *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
+
+#define CONNMAN_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+
+enum {
+   NM_STATE_UNKNOWN = 0,
+   NM_STATE_ASLEEP,
+   NM_STATE_CONNECTING,
+   NM_STATE_CONNECTED,
+   NM_STATE_DISCONNECTED
+};
+
+#define NM_SERVICE"org.freedesktop.NetworkManager"
+#define NM_PATH   "/org/freedesktop/NetworkManager"
+#define NM_INTERFACE  NM_SERVICE
+
+static DBusConnection *connection = NULL;
+static dbus_uint32_t state = NM_STATE_UNKNOWN;
+
+
+static void nm_send_signal(const char *name, dbus_uint32_t state)
+{
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
+   if (signal == NULL)
+   return;
+
+   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
+   DBUS_TYPE_INVALID);
+
+   g_dbus_send_message(connection, signal);
+}
+
+static void default_changed(struct connman_service *service)
+{
+   if (service != NULL)
+   state = NM_STATE_CONNECTED;
+   else
+   state = NM_STATE_DISCONNECTED;
+
+   DBG("%p %d", service, state);
+
+   /* older deprecated signal, in case applications still use this */
+   nm_send_signal("StateChange", state);
+
+   /* the preferred current signal */
+   nm_send_signal("StateChanged", state);
+}
+
+static struct connman_notifier notifier = {
+   .name   = "nmcompat",
+   .priority   = CONNMAN_NOTIFIER_PRIORITY_DEFAULT,
+   .default_changed= default_changed,
+};
+
+static DBusMessage *nm_sleep(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_append_args(reply, DBUS_TYPE_INVALID);
+
+   return reply;
+}
+
+static DBusMessage *nm_wake(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   retu

[PATCH 1/4] manager: remove network-manager compatibility code

2011-01-26 Thread Kalle Valo
Remove the network-manager compatibility code from src/manager.c so that all
this can be implemented as a plugin.

-c command line switch is still left but marked as obsole to avoid breaking
current start scripts. By removing the switch connman would not start at
all if -c is used.
---
 src/connman.h |6 ---
 src/main.c|   11 +
 src/manager.c |  121 -
 3 files changed, 4 insertions(+), 134 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 24d5d2c..50f72e5 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -25,10 +25,6 @@
 
 #include 
 
-#define NM_SERVICE"org.freedesktop.NetworkManager"
-#define NM_PATH   "/org/freedesktop/NetworkManager"
-#define NM_INTERFACE  NM_SERVICE
-
 int __connman_dbus_init(DBusConnection *conn);
 void __connman_dbus_cleanup(void);
 
@@ -55,7 +51,7 @@ DBusMessage *__connman_error_invalid_property(DBusMessage 
*msg);
 
 #include 
 
-int __connman_manager_init(gboolean compat);
+int __connman_manager_init(void);
 void __connman_manager_cleanup(void);
 
 int __connman_agent_init(void);
diff --git a/src/main.c b/src/main.c
index 08f2555..d8cc8ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -99,7 +99,7 @@ static GOptionEntry options[] = {
G_OPTION_ARG_NONE, &option_dnsproxy,
"Don't enable DNS Proxy" },
{ "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat,
-   "Enable Network Manager compatibility" },
+   "(obsolete)" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Show version information and exit" },
{ NULL },
@@ -204,13 +204,6 @@ int main(int argc, char *argv[])
 
g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL);
 
-   if (option_compat == TRUE) {
-   if (g_dbus_request_name(conn, NM_SERVICE, NULL) == FALSE) {
-   fprintf(stderr, "Can't register compat service\n");
-   option_compat = FALSE;
-   }
-   }
-
__connman_log_init(option_debug, option_detach);
 
__connman_dbus_init(conn);
@@ -222,7 +215,7 @@ int main(int argc, char *argv[])
__connman_iptables_init();
__connman_tethering_init();
__connman_counter_init();
-   __connman_manager_init(option_compat);
+   __connman_manager_init();
__connman_profile_init();
__connman_config_init();
__connman_stats_init();
diff --git a/src/manager.c b/src/manager.c
index 6fb54e1..9705b05 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -27,16 +27,6 @@
 
 #include "connman.h"
 
-enum {
-   NM_STATE_UNKNOWN = 0,
-   NM_STATE_ASLEEP,
-   NM_STATE_CONNECTING,
-   NM_STATE_CONNECTED,
-   NM_STATE_DISCONNECTED
-};
-
-static gboolean nm_compat = FALSE;
-
 static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -313,46 +303,10 @@ static void technology_notify(enum connman_service_type 
type,
technology_reply(0);
 }
 
-static void nm_send_signal(const char *name, dbus_uint32_t state)
-{
-   DBusMessage *signal;
-
-   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
-   if (signal == NULL)
-   return;
-
-   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
-   DBUS_TYPE_INVALID);
-
-   g_dbus_send_message(connection, signal);
-}
-
-static void default_changed(struct connman_service *service)
-{
-   dbus_uint32_t state;
-
-   if (!nm_compat)
-   return;
-
-   if (service != NULL)
-   state = NM_STATE_CONNECTED;
-   else
-   state = NM_STATE_DISCONNECTED;
-
-   DBG("%p %d", service, state);
-
-   /* older deprecated signal, in case applications still use this */
-   nm_send_signal("StateChange", state);
-
-   /* the preferred current signal */
-   nm_send_signal("StateChanged", state);
-}
-
 static struct connman_notifier technology_notifier = {
.name   = "manager",
.priority   = CONNMAN_NOTIFIER_PRIORITY_HIGH,
.service_enabled= technology_notify,
-   .default_changed= default_changed,
 };
 
 static DBusMessage *enable_technology(DBusConnection *conn,
@@ -698,69 +652,7 @@ static GDBusSignalTable manager_signals[] = {
{ },
 };
 
-static DBusMessage *nm_sleep(DBusConnection *conn,
-   DBusMessage *msg, void *data)
-{
-   DBusMessage *reply;
-
-   DBG("conn %p", conn);
-
-   reply = dbus_message_new_method_return(msg);
-   if (reply == NULL)
-   return NULL;
-
-   dbus_message_append_args(reply, DBUS_TYPE_INVALID);
-
-   return reply;
-}
-
-static DBusMessage *nm_wake(DBusConnection *conn,
-   DBusMessage *

[PATCH 0/4] nmcompat plugin

2011-01-26 Thread Kalle Valo
Based on discussion on IRC, here are patches to move all nm code to 
a plugin. This way it doesn't affect core code but still applications get
network state events.

Tested with pidgin and empathy from Ubuntu 10.10.

---

Kalle Valo (4):
  manager: remove network-manager compatibility code
  nmcompat: add plugin
  nmcompat: support nm dbus properties
  dbus: allow owning org.freedesktop.NetworkManager


 Makefile.plugins  |   12 ++
 configure.ac  |6 +
 plugins/nmcompat.c|  271 +
 src/connman-dbus.conf |1 
 src/connman.h |6 -
 src/main.c|   11 --
 src/manager.c |  121 --
 7 files changed, 294 insertions(+), 134 deletions(-)
 create mode 100644 plugins/nmcompat.c

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH] Add TAGS and openvpn-script to gitignore

2011-01-26 Thread Kalle Valo
To clean up git status output.

TAGS is created with 'make tags'.
---
 .gitignore |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 835ee2a..28a679a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ ltmain.sh
 missing
 stamp-h1
 autom4te.cache
+TAGS
 
 connman.pc
 include/connman
@@ -35,6 +36,7 @@ src/*-connman.rules
 plugins/connman.policy
 scripts/connman
 scripts/openconnect-script
+scripts/openvpn-script
 client/cm
 tools/wispr
 tools/wifi-scan

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 0/2] Support for libnm-glib

2011-01-26 Thread Kalle Valo
Marcel Holtmann  writes:

>> > Or put it in an extra daemon on top of ConnMan.
>> 
>> That's a lot of extra infrastructure work. Creating a new package etc
>> just for a simple dbus interface wrapper.
>
> you could do it as tools/network-manager.c inside the ConnMan code if
> you prefer.

Yes, that would be a good solution. Easy to install for all connman
users/packagers and development would be easier.

The only downside is that I really don't have time work on it right now.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 0/2] Support for libnm-glib

2011-01-26 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Kalle,

Hi Marcel,

>> > I investigated more about network-manager compat support and here is
>> > what I found. Please take a look.
>> >
>> > ---
>> >
>> > Kalle Valo (2):
>> >   dbus: allow owning org.freedesktop.NetworkManager
>> >   manager: support nm dbus properties
>> 
>> Any comments?
>
> I think we are going over board with this. I don't like the idea and we
> might better remove the NM compat support altogether.

I think it's a good idea to have the nm compat interface in connman.
That way connman users benefit from the nm support already implemented
in applications. I would hate to lose it from connman.

But the only good options are either take all my patches or remove all
of the nm compat code. The current state of having a broken interface
just creates problems for the applications.

If you decide to remove it, just let me know and I can send a patch to
do that. (Even when I don't like the patch, but I just want to fix this
mess.)

> Or put it in an extra daemon on top of ConnMan.

That's a lot of extra infrastructure work. Creating a new package etc
just for a simple dbus interface wrapper.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 0/2] Support for libnm-glib

2011-01-26 Thread Kalle Valo
Kalle Valo  writes:

> I investigated more about network-manager compat support and here is
> what I found. Please take a look.
>
> ---
>
> Kalle Valo (2):
>   dbus: allow owning org.freedesktop.NetworkManager
>   manager: support nm dbus properties

Any comments?

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Crash during suspend with manual IP

2011-01-24 Thread Kalle Valo
Hi,

I just filed this bug:

Crash during suspend with manual IP
http://bugs.meego.com/show_bug.cgi?id=12795

Stacktrace:

#0 0x0079e5bb in ?? ()
#1 0x0041cfba in method_call_reply (call=0x6f0a00,
user_data=) at gsupplicant/dbus.c:386
#2 0x778c553a in complete_pending_call_and_unlock (
connection=0x674620, pending=0x6f0a00, message=)
at dbus-connection.c:2311
#3 0x778c81af in dbus_connection_dispatch (connection=0x674620)
at dbus-connection.c:4596
#4 0x0040cd08 in message_dispatch (data=)
at gdbus/mainloop.c:80
#5 0x77b3ab1b in g_timeout_dispatch (source=0x754200,
callback=0x7fffe1d0, user_data=0x76e69298)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:3585
#6 0x77b3a342 in g_main_dispatch (context=0x673120)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2149
#7 g_main_context_dispatch (context=0x673120)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2702
#8 0x77b3e2a8 in g_main_context_iterate (context=0x673120,
block=, dispatch=,
self=)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2780
#9 0x77b3e7b5 in g_main_loop_run (loop=0x6722e0)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2988

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 2/2] manager: support nm dbus properties

2011-01-24 Thread Kalle Valo
After some investigation I found that network-manager also provides
the network state through properties and libnm-glib library uses this
instead of the GetState() method.

Add Get() method call retrieve the property and a PropertyChanged signal
to notify state changes. Now empathy, which uses libnm-glib, properly
detects network state changes.

I deliberately omitted GetAll() method because libnm-glib doesn't seem
to need it.
---
 src/connman.h |2 +
 src/manager.c |  102 +++--
 2 files changed, 100 insertions(+), 4 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 37946f6..cf5f142 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -29,6 +29,8 @@
 #define NM_PATH   "/org/freedesktop/NetworkManager"
 #define NM_INTERFACE  NM_SERVICE
 
+#define DBUS_PROPERTIES_INTERFACE  "org.freedesktop.DBus.Properties"
+
 int __connman_dbus_init(DBusConnection *conn);
 void __connman_dbus_cleanup(void);
 
diff --git a/src/manager.c b/src/manager.c
index 6fb54e1..190136f 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -327,6 +327,44 @@ static void nm_send_signal(const char *name, dbus_uint32_t 
state)
g_dbus_send_message(connection, signal);
 }
 
+static void nm_send_prop_signal(dbus_uint32_t state)
+{
+   const char *key = "State";
+   DBusMessageIter iter, dict, dict_entry, dict_val;
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE,
+   "PropertiesChanged");
+   if (signal == NULL)
+   return;
+
+   dbus_message_iter_init_append(signal, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+   DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_STRING_AS_STRING 
DBUS_TYPE_VARIANT_AS_STRING
+   DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+   &dict);
+
+   dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
+   NULL, &dict_entry);
+
+   dbus_message_iter_append_basic(&dict_entry, DBUS_TYPE_STRING,
+   &key);
+
+   dbus_message_iter_open_container(&dict_entry,
+   DBUS_TYPE_VARIANT,
+   DBUS_TYPE_UINT32_AS_STRING, &dict_val);
+
+   dbus_message_iter_append_basic(&dict_val, DBUS_TYPE_UINT32, &state);
+
+   dbus_message_iter_close_container(&dict_entry, &dict_val);
+   dbus_message_iter_close_container(&dict, &dict_entry);
+   dbus_message_iter_close_container(&iter, &dict);
+
+   g_dbus_send_message(connection, signal);
+}
+
 static void default_changed(struct connman_service *service)
 {
dbus_uint32_t state;
@@ -346,6 +384,8 @@ static void default_changed(struct connman_service *service)
 
/* the preferred current signal */
nm_send_signal("StateChanged", state);
+
+   nm_send_prop_signal(state);
 }
 
 static struct connman_notifier technology_notifier = {
@@ -730,6 +770,14 @@ static DBusMessage *nm_wake(DBusConnection *conn,
return reply;
 }
 
+static dbus_uint32_t get_nm_state(void)
+{
+   if (__connman_notifier_count_connected() > 0)
+   return NM_STATE_CONNECTED;
+   else
+   return NM_STATE_DISCONNECTED;
+}
+
 static DBusMessage *nm_state(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -742,10 +790,7 @@ static DBusMessage *nm_state(DBusConnection *conn,
if (reply == NULL)
return NULL;
 
-   if (__connman_notifier_count_connected() > 0)
-   state = NM_STATE_CONNECTED;
-   else
-   state = NM_STATE_DISCONNECTED;
+   state = get_nm_state();
 
dbus_message_append_args(reply, DBUS_TYPE_UINT32, &state,
DBUS_TYPE_INVALID);
@@ -753,6 +798,45 @@ static DBusMessage *nm_state(DBusConnection *conn,
return reply;
 }
 
+static DBusMessage *nm_prop_get(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessageIter iter, value;
+   const char *interface, *key;
+   dbus_uint32_t state;
+   DBusMessage *reply;
+
+   DBG("conn %p", conn);
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_get_args(msg, NULL,
+   DBUS_TYPE_STRING, &interface,
+   DBUS_TYPE_STRING, &key,
+   DBUS_TYPE_INVALID);
+
+   if (g_strcmp0(key, "State") == 0) {
+   state = get_nm_state();
+
+   dbus_message_iter_init_append(reply, &iter);
+
+   dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
+  

[PATCH 1/2] dbus: allow owning org.freedesktop.NetworkManager

2011-01-24 Thread Kalle Valo
The network-manager compatibility interface doesn't start unless
we allow connman to own the interface in the dbus configuration.
---
 src/connman-dbus.conf |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/connman-dbus.conf b/src/connman-dbus.conf
index 311f28c..fa70297 100644
--- a/src/connman-dbus.conf
+++ b/src/connman-dbus.conf
@@ -3,6 +3,7 @@
 
 
 
+
 
 
 

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 0/2] Support for libnm-glib

2011-01-24 Thread Kalle Valo
I investigated more about network-manager compat support and here is
what I found. Please take a look.

---

Kalle Valo (2):
  dbus: allow owning org.freedesktop.NetworkManager
  manager: support nm dbus properties


 src/connman-dbus.conf |1 
 src/connman.h |2 +
 src/manager.c |  102 +++--
 3 files changed, 101 insertions(+), 4 deletions(-)

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v2] manager: send network-manager state change signals

2011-01-18 Thread Kalle Valo
Kalle Valo  writes:

> When using network-manager compatibility mode in connman applications,
> for example pidgin and firefox, didn't notice when connman changed states
> from offline to online (and vice versa) and applications would notice the
> new state only after restarting them.
>
> The problem was that connman wasn't sending StateChanged signals. After
> adding them pidgin and firefox will notice the new states immeadiately.

In v2 I added a check for nm_compat.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH v2] manager: send network-manager state change signals

2011-01-18 Thread Kalle Valo
When using network-manager compatibility mode in connman applications,
for example pidgin and firefox, didn't notice when connman changed states
from offline to online (and vice versa) and applications would notice the
new state only after restarting them.

The problem was that connman wasn't sending StateChanged signals. After
adding them pidgin and firefox will notice the new states immeadiately.
---
 src/manager.c |   56 ++--
 1 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index 0f66560..6fb54e1 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -27,6 +27,16 @@
 
 #include "connman.h"
 
+enum {
+   NM_STATE_UNKNOWN = 0,
+   NM_STATE_ASLEEP,
+   NM_STATE_CONNECTING,
+   NM_STATE_CONNECTED,
+   NM_STATE_DISCONNECTED
+};
+
+static gboolean nm_compat = FALSE;
+
 static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -303,10 +313,46 @@ static void technology_notify(enum connman_service_type 
type,
technology_reply(0);
 }
 
+static void nm_send_signal(const char *name, dbus_uint32_t state)
+{
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
+   if (signal == NULL)
+   return;
+
+   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
+   DBUS_TYPE_INVALID);
+
+   g_dbus_send_message(connection, signal);
+}
+
+static void default_changed(struct connman_service *service)
+{
+   dbus_uint32_t state;
+
+   if (!nm_compat)
+   return;
+
+   if (service != NULL)
+   state = NM_STATE_CONNECTED;
+   else
+   state = NM_STATE_DISCONNECTED;
+
+   DBG("%p %d", service, state);
+
+   /* older deprecated signal, in case applications still use this */
+   nm_send_signal("StateChange", state);
+
+   /* the preferred current signal */
+   nm_send_signal("StateChanged", state);
+}
+
 static struct connman_notifier technology_notifier = {
.name   = "manager",
.priority   = CONNMAN_NOTIFIER_PRIORITY_HIGH,
.service_enabled= technology_notify,
+   .default_changed= default_changed,
 };
 
 static DBusMessage *enable_technology(DBusConnection *conn,
@@ -684,14 +730,6 @@ static DBusMessage *nm_wake(DBusConnection *conn,
return reply;
 }
 
-enum {
-   NM_STATE_UNKNOWN = 0,
-   NM_STATE_ASLEEP,
-   NM_STATE_CONNECTING,
-   NM_STATE_CONNECTED,
-   NM_STATE_DISCONNECTED
-};
-
 static DBusMessage *nm_state(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -722,8 +760,6 @@ static GDBusMethodTable nm_methods[] = {
{ },
 };
 
-static gboolean nm_compat = FALSE;
-
 int __connman_manager_init(gboolean compat)
 {
DBG("");

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH] manager: send network-manager state change signals

2011-01-18 Thread Kalle Valo
When using network-manager compatibility mode in connman applications,
for example pidgin and firefox, didn't notice when connman changed states
from offline to online (and vice versa) and applications would notice the
new state only after restarting them.

The problem was that connman wasn't sending StateChanged signals. After
adding them pidgin and firefox will notice the new states immeadiately.
---
 src/manager.c |   49 +
 1 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index 0f66560..728a828 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -27,6 +27,14 @@
 
 #include "connman.h"
 
+enum {
+   NM_STATE_UNKNOWN = 0,
+   NM_STATE_ASLEEP,
+   NM_STATE_CONNECTING,
+   NM_STATE_CONNECTED,
+   NM_STATE_DISCONNECTED
+};
+
 static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -303,10 +311,43 @@ static void technology_notify(enum connman_service_type 
type,
technology_reply(0);
 }
 
+static void nm_send_signal(const char *name, dbus_uint32_t state)
+{
+   DBusMessage *signal;
+
+   signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name);
+   if (signal == NULL)
+   return;
+
+   dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state,
+   DBUS_TYPE_INVALID);
+
+   g_dbus_send_message(connection, signal);
+}
+
+static void default_changed(struct connman_service *service)
+{
+   dbus_uint32_t state;
+
+   if (service != NULL)
+   state = NM_STATE_CONNECTED;
+   else
+   state = NM_STATE_DISCONNECTED;
+
+   DBG("%p %d", service, state);
+
+   /* older deprecated signal, in case applications still use this */
+   nm_send_signal("StateChange", state);
+
+   /* the preferred current signal */
+   nm_send_signal("StateChanged", state);
+}
+
 static struct connman_notifier technology_notifier = {
.name   = "manager",
.priority   = CONNMAN_NOTIFIER_PRIORITY_HIGH,
.service_enabled= technology_notify,
+   .default_changed= default_changed,
 };
 
 static DBusMessage *enable_technology(DBusConnection *conn,
@@ -684,14 +725,6 @@ static DBusMessage *nm_wake(DBusConnection *conn,
return reply;
 }
 
-enum {
-   NM_STATE_UNKNOWN = 0,
-   NM_STATE_ASLEEP,
-   NM_STATE_CONNECTING,
-   NM_STATE_CONNECTED,
-   NM_STATE_DISCONNECTED
-};
-
 static DBusMessage *nm_state(DBusConnection *conn,
DBusMessage *msg, void *data)
 {

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: g_key_file_set_string: assertion `string != NULL' failed

2010-12-17 Thread Kalle Valo
On 12/17/2010 06:18 PM, Kalle Valo wrote:
> I noticed this critical message while testing latest git:
> 
> (connmand:2146): GLib-CRITICAL **: g_key_file_set_string: assertion
> `string != NULL' failed

And backtrace:

#0  0x76b1fba5 in raise (sig=)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x76b236b0 in abort () at abort.c:92
#2  0x77b44f0a in g_logv (log_domain=,
log_level=, format=,
args1=0x7fffcd30) at
/build/buildd/glib2.0-2.26.0/glib/gmessages.c:557
#3  0x77b44fa3 in g_log (
log_domain=0x8cc , log_level=2252,
format=0x6 )
at /build/buildd/glib2.0-2.26.0/glib/gmessages.c:577
#4  0x0043d493 in __connman_ipconfig_save (ipconfig=0x807ca0,
keyfile=0x69f850,
identifier=0x7dea70 "wifi_0026b6675606_76616c6f_managed_psk",
prefix=0x45548a "IPv6.") at src/ipconfig.c:1712
#5  0x00432a4c in service_save (service=0x6b3600) at
src/service.c:4673
#6  0x0044653b in __connman_storage_save_service (service=0x6b3600)
at src/storage.c:265
#7  0x0043f0ee in __connman_ipconfig_newlink (index=3,
type=, flags=,
address=, mtu=,
stats=) at src/ipconfig.c:481
#8  0x00444574 in process_newlink (type=2252, index=3, flags=4099,
change=0, msg=, bytes=)
at src/rtnl.c:439
#9  0x00445260 in rtnl_newlink (chan=,
cond=, data=) at
src/rtnl.c:862
#10 rtnl_message (chan=, cond=,
data=) at src/rtnl.c:1220
#11 netlink_event (chan=, cond=,
data=) at src/rtnl.c:1266
#12 0x77b3a342 in g_main_dispatch (context=0x6700e0)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2149
#13 g_main_context_dispatch (context=0x6700e0)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2702
#14 0x77b3e2a8 in g_main_context_iterate (context=0x6700e0,
block=, dispatch=,
self=)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2780
#15 0x77b3e7b5 in g_main_loop_run (loop=0x671090)
at /build/buildd/glib2.0-2.26.0/glib/gmain.c:2988
#16 0x00427837 in main (argc=1, argv=0x7fffe648) at
src/main.c:250

And the code:

DBG("ipconfig %p identifier %s", ipconfig, identifier);

method = __connman_ipconfig_method2string(ipconfig->method);

key = g_strdup_printf("%smethod", prefix);
g_key_file_set_string(keyfile, identifier, key, method); <
g_free(key);

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


g_key_file_set_string: assertion `string != NULL' failed

2010-12-17 Thread Kalle Valo
Hi,

I noticed this critical message while testing latest git:

(connmand:2146): GLib-CRITICAL **: g_key_file_set_string: assertion
`string != NULL' failed

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 1/4] gdhcp: Add support for IPV4LL

2010-12-13 Thread Kalle Valo
Hi Samuel,

Samuel Ortiz  writes:

> On Fri, Dec 10, 2010 at 11:00:33AM +, Julien Massot wrote:
>> The IPV4LL protocol is highly integrated in gdhcp client, and
>> start IPV4LL negociation on dhcp failure.

[...]

> Thanks a lot, patch applied.

Nice. Can we now enable wifi adhoc?

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: How to add new files into connman and compiles

2010-12-13 Thread Kalle Valo
"Zhang, Wen (Sky)"  writes:

> Hi

Hi Wen,

> all I have writted a plugin for ofono cdma data connection

Cool. Can you share it? I'm very interested about cdma support.

But why do you need to have a separate ofono plugin for cdma?

> but I do not know how to add plugin and compile it like as ofono
> plugin, and can create like as ofono_cdma.so and ofono_cdma.la Who can
> tell me which files should modify, configure.ac? Makefile.am? Or other
> files? 

grep is usually your best friend, better to use it. But Makefile.plugin
is the file you are interested about:

if OFONO
if OFONO_BUILTIN
builtin_modules += ofono
builtin_sources += plugins/ofono.c
else
plugin_LTLIBRARIES += plugins/ofono.la
plugin_objects += $(plugins_ofono_la_OBJECTS)
plugins_ofono_la_CFLAGS = $(plugin_cflags)
plugins_ofono_la_LDFLAGS = $(plugin_ldflags)
endif
endif

If you want to add a new configure switch when you need to also edit
configure.ac.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: crash in udp_server_event()

2010-12-07 Thread Kalle Valo
Hi David,

sorry, I forgot to answer this last week. I guess I was too eager to go
the long weekend I had :)

David Woodhouse  writes:

> On Thu, 2010-12-02 at 15:09 +0200, Kalle Valo wrote:
>> The code in question is:
>> 
>> if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
>> struct server_data *data = user_data;
>> 
>> connman_error("Error with UDP server %s", data->server);
>> data->watch = 0;  < here
>> return FALSE;
>> }
>
> I think it's the line above the one you marked, *in* connman_error(). 

Yeah, I think you are correct.

> I wonder what data->server is set to?

Sorry, I have no idea.

> Confused, though; I can't see *any* way that can go wrong. Running in
> valgrind here and taking the nameserver down deliberately to trigger the
> error, I don't see any sign of it.
>
> Can you reproduce it?

No. But normally I have dnsproxy disabled, I was just trying it for the
first time last friday. I tried to reproduce the crash this morning, but
didn't see it.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH v4 2/2] Add support for multiple search domains

2010-12-07 Thread Kalle Valo
Samuel Ortiz  writes:

> Hi Henri,

Moi Samuel and Henri,

> On Tue, Dec 07, 2010 at 10:49:38AM +0200, Henri Bragge wrote:
>> Domains are appended to entry list just like nameservers, and finally 
>> exported
>> to /etc/resolv.conf. Domains are written to resolv.conf in reverse order so
>> that the most recently appended domain will have the highest priority.
>> 
>> Search domains should only be useful for resolvfile_resolver and should be
>> ignored by dnsproxy_resolver.
>
> Both patches applied, thanks a lot.

I just tested this with our daily builds and it's working great for me.
Thanks a lot for implementing this, I have received requests about this
feature.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: connman make issue

2010-12-07 Thread Kalle Valo
小霖  writes:

> Hi all,

Hi,

> In the ubuntu operating system, when you execute a command
>'make' the following issue occurred.

[...]

> src/technology.c: In function ‘__connman_technology_enable_device’:
> src/technology.c:538: error: ‘ERFKILL’ undeclared (first use in this function)

What version of Ubuntu and especially what version of linux-libc-dev?
I'm using Ubuntu 10.04 and I have ERFKILL defined here:

/usr/include/asm-generic/errno.h:#define ERFKILL
132 /* Operation not possible due to RF-kill */

Here's my version:

ii  linux-libc-dev 2.6.32-26.47   Linux Kernel Headers for development

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Re: DUN Support

2010-12-02 Thread Kalle Valo
Claudio Degioanni  writes:

> Hi all,

Hi Claudio,

> I have a question about connman current release (0.64). It supports the
> DUN profile ?
>
> What does it use ? ofono or bluez ?

Do you mean DUN client? I know Gustavo F. Padovan has been working on
getting DUN client support to ofono, but I haven't tested his patches
yet. A bit more info here:

http://lists.ofono.org/pipermail/ofono/2010-April/002005.html

Most probably you get better answers from ofono mailing list.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


crash in udp_server_event()

2010-12-02 Thread Kalle Valo
Hi,

I was playing with dnsproxy and got this crash:

connmand[14243]: wlan0 {add} address 192.168.1.232/24 label wlan0
connmand[14243]: Aborting (signal 11)
connmand[14243]:  backtrace 
connmand[14243]: [0]: /lib/libpthread.so.0(+0xfb40) [0x7f66dd865b40]
connmand[14243]: [1]: /lib/libc.so.6(_IO_vfprintf+0x416a) [0x7f66dccf07aa]
connmand[14243]: [2]: /lib/libc.so.6(__vfprintf_chk+0x77) [0x7f66dcda50d7]
connmand[14243]: [3]: /lib/libc.so.6(__vsyslog_chk+0x191) [0x7f66dcd89511]
connmand[14243]: [4]: src/connmand(connman_error+0x98) [0x426b68]
connmand[14243]: [5]: src/connmand() [0x4244ce]
connmand[14243]: [6]:
/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1f2) [0x7f66ddcf5342]
connmand[14243]: [7]: /lib/libglib-2.0.so.0(+0x442a8) [0x7f66ddcf92a8]
connmand[14243]: [8]: /lib/libglib-2.0.so.0(g_main_loop_run+0x195)
[0x7f66ddcf97b5]
connmand[14243]: [9]: src/connmand() [0x426417]
connmand[14243]: [10]: /lib/libc.so.6(__libc_start_main+0xfe)
[0x7f66dccc5d8e]
connmand[14243]: [11]: src/connmand() [0x40be79]
connmand[14243]: +++

 backtrace 
[0]: connman_error() [log.c:87]
[1]: udp_server_event() [dnsproxy.c:468]
[2]: main() [main.c:262]
[3]: _start() [iptables.c:0]
---

The code in question is:

if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
struct server_data *data = user_data;

connman_error("Error with UDP server %s", data->server);
data->watch = 0;  < here
return FALSE;
}

Using latest git, commit 543a9964f9.

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: API to use to connect with fixed network settings to a hidden network

2010-12-02 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Kalle,

Hi Marcel,

>> Can't we pass the IP settings through ConnectService()? I think that's
>> the best solution.
>
> we could, but this is actually pretty much complicated to handle
> internally. Be my guest in trying this.

That's the second challenge, the first challenge is to get you agree
with the API ;)

> In the long term, we need to remove ConnectService and create one
> service (per security setting) for hidden networks if they are around.
> Then use the agent callback to ask for the SSID.
>
> At that point this would become a real service with SSID assigned and
> could potentially be used to set static IP etc.

The problem with this is that not all drivers add hidden SSIDs to the
scan results, at least I have seen this with broadcom's infamous wl
driver. So removing ConnectService might not be an option. Otherwise I
like the idea.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: API to use to connect with fixed network settings to a hidden network

2010-12-02 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Pierre-Rudolf,

Hello Marcel and Pierre-Rudolf,

>> using connman, I would like to connect to a hidden wifi network, but
>> using fixed network settings (ip, gateway, ...).
>> 
>> The only way I knkow to connect to a hidden wifi network is via the
>> ConnectService api of the manager. However, it does not allow me to
>> specify ip settings, like when I configure a service. How should I do ? 
>> 
>> I think I should create a service for this hidden wifi network,
>> configure it, and then ask to connect, but how do I create such a
>> service ?
>
> problem really is that you don't know anything about that service until
> you actually found it. And ConnMan can not find it until the user tells
> us about its SSID.

Can't we pass the IP settings through ConnectService()? I think that's
the best solution.

> Hidden WiFi networks are just a broken concept on so many levels.

I can't deny that, it's a horrible hack and creates so much problems
everywhere without any benefits.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Update TODO list regarding Agent API

2010-11-24 Thread Kalle Valo
Patrik Flykt  writes:

> On Wed, 2010-11-24 at 12:50 +0200, ext Kalle Valo wrote:
>> So what's missing still? I guess ReportError() at least. Also, are there
>> going to be any API breaks in the near future?
>
> Yes, ReportError is missing from upstream. I have an implementation that
> works on my machine. Is it ok if I send the patch latest on Friday?

No rush, I was just curious what you were planning to implement.

> Hidden SSID requesting is not in RequestInput, for that one to work
> ConnMan needs to know of services without SSIDs. I'm not sure what the
> scenario is where SSID needs to be requested, though.

Yeah, hidden SSID is always tricky.

> EAP passphrases are not asked, need some looking into. 

Please do :)

> And also some mechanism detecting invalid WPA passphrases and
> unsetting them in order to re-request them would be nice.

Oh yes, this would be really nice.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Update TODO list regarding Agent API

2010-11-24 Thread Kalle Valo
Hi Patrik,

patrik.fl...@nokia.com writes:

> Priority: Medium
> Complexity: C2
> +   Owner: Patrik Flykt 
> +
> +   Implement Agent API according to doc/agent-api.txt

So what's missing still? I guess ReportError() at least. Also, are there
going to be any API breaks in the near future?

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH IPv6] Separate IPv4 and IPv6 data

2010-11-22 Thread Kalle Valo
 writes:

> - autoconf IPv6 support (it is almost supported in connman already but
> system should also go to online state when the interface has autoconf
> address)

Yeah, this is already working somewhat (I'm using it daily), but there
are few issues. A major issue is that connman currently doesn't clear
the route table when disconnecting from a service and there will stale
entries in the route table. Also it would be nice to show the ipv6
autoconf settings (address, gateway etc) through the service api.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: Switching over to net.connman D-Bus service name

2010-11-09 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi everyone,

Hi Marcel,

> so I think it is time now to get rid of org.moblin.connman D-Bus service
> name and finally replace it with net.connman.

I agree.

> So this is a heads up for all UI developers that they need to change
> their code to adjust to this new service name.

Thank you for the warning, much appreciated.

But did you upload the changes already? I still see this in
include/dbus.h:

#define CONNMAN_SERVICE "org.moblin.connman"
#define CONNMAN_PATH"/org/moblin/connman"

If not, when are you planning to do push this? And any plans when a
release containing this change will come out? I'm just asking so that I
can synchronise my UI releases accordingly.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Save offlinemode when device enabled

2010-11-03 Thread Kalle Valo
Marcel Holtmann  writes:

> We could also send an agent request to ask for confirmation to take that
> one technology out off offline mode. The UI can then decide to always
> present that request or just use its own policy to reply to it.

Nice idea, I like this. I think this covers most of my worries, if not
all.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: API questions: scanning indication, hotspot branding and renaming services

2010-11-03 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Kalle,

Hi Marcel,

>> My plan is to use scanning indication to warn the user that the
>> available network list in a dialog will be updated soon. Showing some
>> scanning animation would do that.
>
> feel free to send a patch that adds this on the Technology interface. I
> will have a look at it.

I'll do that, but I can't do it right now. I first need to implement the
dialog I was talking about. I hope someone else is faster than me :)

> However be warned that this is really useless in case of WiFi. And it
> makes only sense if it is a user triggered transaction. For example
> wpa_supplicant has to scan in the background for you anyway.

Background scans are separate, I'm not interested about those at all and
do not want to expose them on UI. Here I'm talking about active, connman
triggered, scans.

>> Like Aapo said, a cryptic SSID is one good example. Also there's a case
>> if there are two networks with same SSID but different encryption
>> settings. I have this case already with my n900: one is open network,
>> the other one uses WPA-PSK and both have the same SSID. It would be
>> really nice to have different names for these two networks.
>
> That argument does not fly with me. You get the encryption details from
> ConnMan and you can just present that properly in the UI. That is an
> actual UI detail.

But the user might not want to differentiate them from settings, but
instead have a proper name.

> And I am still not convinced that aliasing services is a good idea. You
> guys have to come up with something better than just cryptic SSID that
> you only see once in your life. It is not that you can't do this in the
> UI itself if you really want to.

Of course we can do almost everything we want from UI, but they all will
be ugly and unreliable. Or we can even patch connman ourselves. But as
connman already has a nice interface for UI, it doesn't really make
sense creating ugly hacks. Better to do it right and implement these in
connman.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Save offlinemode when device enabled

2010-11-03 Thread Kalle Valo
Hi Marcel,

Marcel Holtmann  writes:

>> Sorry, but that sounds very confusing. In offline mode I would expect
>> that all transmitters are turned off until offline is disabled again.
>> But if a user can enable transmitters while in offline, I would not call
>> it offline mode anymore.
>
> we decided to call it OfflineMode compared to FlightMode. If you look
> back long enough you might even find FlightMode in the repository.
>
> Simple fact here is that we have to treat 3G as hard offline mode and
> some others like WiMAX and most likely also 5GHz WiFi because of
> regulatory rules. Mainly driven by airline regulations.
>
> However there are exceptions to it. And that is WiFi and Bluetooth and
> so it must be possible to re-enable this even while in offline mode.

I understand your reasoning, but I foresee that the solution will be
problematic for the user. Maybe a three state offline mode, for example
"hard", "soft" and "off", would be better? In hard state there's no way
to enable any of the technologies, but in soft that's possible. Or
handle the case you describe above from UI with enabling and disabling
technologies.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: API questions: scanning indication, hotspot branding and renaming services

2010-11-03 Thread Kalle Valo
Marcel Holtmann  writes:

> Hi Aapo,

Hi Marcel and Aapo,

>> We are working at Nokia on porting existing (MeeGo Touch based) Internet
>> connectivity UIs to support Connman. Previously our Internet UI has
>> supported Maemo specific connection daemon called ICd2.
>> 
>> Most parts of the Connman API look good and clear, but couple of
>> questions popped up today when going through our own worklist:
>> 
>>  * Is there indication when scanning starts or ends in Connman? I'm 
>>looking for something similar to Bluez Adapter API
>>"Discovering" property (but of course for e.g. WLAN scan instead of
>>BT discovery). I could not find anything similar when reading the 
>>API docs myself.
>
> there used to be an indication, but we removed that one.

I also would need support for showing scanning status.

> The question really is why do you want something like this for WiFi. In
> the future we will have wpa_supplicant doing proper background scanning
> for nice roaming capabilities. So essentially ConnMan should not ever
> trigger a scan again.

My plan is to use scanning indication to warn the user that the
available network list in a dialog will be updated soon. Showing some
scanning animation would do that.

>>  * Is there any possibility to rename a service? Currently Service 
>>"Name" property has been marked as [readonly] in the API 
>>documentation. In this case I would expect to find e.g. "Alias" 
>>property (like in Bluez Device API), but I was unable to find one. I 
>>know at least some cases when the end user can receive a WLAN AP 
>>from ISP having semi-random SSID. In this cases it IMHO would be 
>>nice to provide way for the user to rename or assign an alias for 
>>the WLAN service.
>
> There is no such feature right now. Do you really wanna expose that in
> the user interface.

I definitely see the use for this.

> It makes only sense to add such a thing if the UI and then in the end
> the user really wants to use this feature.
>
> Even with BlueZ I always question myself if it was a good idea. But then
> for BlueZ the device name is shown in a few more places, so I can argue
> for it. However with WiFi, why bother, that access point name should
> never really be presented to the user in any other application than the
> settings/selector UI.

Like Aapo said, a cryptic SSID is one good example. Also there's a case
if there are two networks with same SSID but different encryption
settings. I have this case already with my n900: one is open network,
the other one uses WPA-PSK and both have the same SSID. It would be
really nice to have different names for these two networks.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Save offlinemode when device enabled

2010-11-03 Thread Kalle Valo
Samuel Ortiz  writes:

> Offline mode can only be permanently switched when the user or an application
> explicitely set it (through Manager.SetProperty). When a technology is enabled
> while in offline mode, ConnMan only temporarily goes to online mode.

Sorry, but that sounds very confusing. In offline mode I would expect
that all transmitters are turned off until offline is disabled again.
But if a user can enable transmitters while in offline, I would not call
it offline mode anymore.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 1/1] Fix deadlock when disassociate while associating.

2010-10-27 Thread Kalle Valo
Hi Mohamed,

Mohamed Abbas  writes:

> while associating then the user disconnect the network this will
> cause the following:
> 1- __connman_service_disconnect() which will call
> 2-__connman_network_disconnect() which call
> 3 err = network->driver->disconnect(network); 
> 4-connman_network_set_connected(network, FALSE);

I noticed this patch breaks the first automatic connection to a wifi
network when connman is started. The wpa_s connects to the AP but dhcp
client is not run.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 2/2] gsupplicant: remove network from wpa_s when disconnecting

2010-10-27 Thread Kalle Valo
gsupplicant adds networks to wpasupplicant but never removes them. So
after a time wpasupplicant will contain a lot of disabled networks. This
doesn't seem to create any problems, but it's still better to make sure
that wpasupplicant configuration is clean.
---
 gsupplicant/supplicant.c |   38 +-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 0954e27..db8dc34 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2338,7 +2338,7 @@ int g_supplicant_interface_connect(GSupplicantInterface 
*interface,
return -EINPROGRESS;
 }
 
-static void interface_disconnect_result(const char *error,
+static void network_remove_result(const char *error,
DBusMessageIter *iter, void *user_data)
 {
struct interface_data *data = user_data;
@@ -2355,6 +2355,42 @@ static void interface_disconnect_result(const char 
*error,
dbus_free(data);
 }
 
+static void network_remove_params(DBusMessageIter *iter, void *user_data)
+{
+   struct interface_data *data = user_data;
+   const char *path = data->interface->network_path;
+
+   SUPPLICANT_DBG("path %s", path);
+
+   dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
+}
+
+static int network_remove(struct interface_data *data)
+{
+   GSupplicantInterface *interface = data->interface;
+
+   SUPPLICANT_DBG("");
+
+   return supplicant_dbus_method_call(interface->path,
+   SUPPLICANT_INTERFACE ".Interface", "RemoveNetwork",
+   network_remove_params, network_remove_result, data);
+}
+
+static void interface_disconnect_result(const char *error,
+   DBusMessageIter *iter, void *user_data)
+{
+   struct interface_data *data = user_data;
+
+   SUPPLICANT_DBG("");
+
+   if (error != NULL && data->callback != NULL) {
+   data->callback(-EIO, data->interface, data->user_data);
+   return;
+   }
+
+   network_remove(data);
+}
+
 int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
GSupplicantInterfaceCallback callback,
void *user_data)
-- 
1.7.1

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 0/2] gsupplicant: remove disconnected networks from wpa_s

2010-10-27 Thread Kalle Valo
Here are two simple patches to remove disconnected networks from
wpasupplicant. I had few patches on top of master branch, but rebasing to
master should be easy.

Please comment.

Kalle Valo (2):
  gsupplicant: store network path
  gsupplicant: remove network from wpa_s when disconnecting

 gsupplicant/supplicant.c |   69 --
 1 files changed, 60 insertions(+), 9 deletions(-)

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 1/2] gsupplicant: store network path

2010-10-27 Thread Kalle Valo
Store wpasupplicant network path so that it can be removed later.
---
 gsupplicant/supplicant.c |   31 +++
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 4b62ad3..0954e27 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -138,6 +138,7 @@ static GHashTable *bss_mapping;
 
 struct _GSupplicantInterface {
char *path;
+   char *network_path;
unsigned int keymgmt_capa;
unsigned int authalg_capa;
unsigned int proto_capa;
@@ -2022,39 +2023,53 @@ int g_supplicant_interface_scan(GSupplicantInterface 
*interface,
 static void interface_select_network_result(const char *error,
DBusMessageIter *iter, void *user_data)
 {
+   struct interface_connect_data *data = user_data;
+
SUPPLICANT_DBG("");
+
+   dbus_free(data);
 }
 
 static void interface_select_network_params(DBusMessageIter *iter,
void *user_data)
 {
-   char *path = user_data;
+   struct interface_connect_data *data = user_data;
+   GSupplicantInterface *interface = data->interface;
 
-   dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
+   dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
+   &interface->network_path);
 }
 
 static void interface_add_network_result(const char *error,
DBusMessageIter *iter, void *user_data)
 {
struct interface_connect_data *data = user_data;
-   char *path = NULL;
+   GSupplicantInterface *interface = data->interface;
+   const char *path;
 
if (error != NULL)
-   goto done;
+   goto error;
 
dbus_message_iter_get_basic(iter, &path);
if (path == NULL)
-   goto done;
+   goto error;
 
SUPPLICANT_DBG("PATH: %s", path);
 
+   g_free(interface->network_path);
+   interface->network_path = g_strdup(path);
+
supplicant_dbus_method_call(data->interface->path,
SUPPLICANT_INTERFACE ".Interface", "SelectNetwork",
interface_select_network_params,
-   interface_select_network_result, path);
+   interface_select_network_result, data);
 
-done:
-   dbus_free(data);
+   return;
+
+error:
+   g_free(interface->network_path);
+   interface->network_path = NULL;
+   g_free(data);
 }
 
 static void add_network_security_wep(DBusMessageIter *dict,
-- 
1.7.1

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 1/2] wifi: add a disconnected timer

2010-10-27 Thread Kalle Valo
Samuel Ortiz  writes:

> Hi Kalle,

Hi Samuel,

> On Tue, Oct 26, 2010 at 07:30:53PM +0300, Kalle Valo wrote:
>> In a big network, for example at Ubuntu Developer Summit which has >10 APs,
>> connman and wpasupplicant got out of sync very easily. connman claimed it
>> was connected even though wpasupplicant (and the kernel driver) was actually
>> connected to the AP.
>
> Did you mean connman claimed it was _disconnected_ ?

Yes, that's what I mean. Sorry for the confusion.

Just to be clear: connman claimed that wifi connection was disconnected,
but 'iw wlan0 link' showed that I was connected to Ubuntu network.

>> The problem is that while roaming between APs inside ESS
>> wpasupplicant states go like this:
>> 
>> COMPLETED -> DISCONNECTED -> SCANNING -> AUTHENTICATING ... -> COMPLETED
>> 
>> So what happens is that connman unnecessarily marks the network disconnected
>> even though wpasupplicant is just roaming to a different AP within ESS.
>
> Well it really got disconnected from the AP, so ConnMan should just track
> that.

Well, it depends how we want to handle intra-ESS roaming. I see two
choises:

1) wpasupplicant manages roaming, connman just provides SSID and other settings
2) connman manages roaming

We should definitely go with option 1, it's faster and wpasupplicant has
the best information to choose which AP to connect to. So roaming between
APs on an ESS would be transparent from connman point of view.

> I'm really not a big fan of trying to be smarter than wpa_supplicant. In my
> experience, it's the shortest paths to new bugs

The problem here is that when wpasupplicant is roaming between APs it
goes to the disconnected state and then immediately to the scanning
state. The connman wifi plugin doesn't handle this properly.

>> To fix this add a timer which waits 10 seconds after a disconnected state.
>> If wpasupplicant hasn't connected to a network at time only then set the
>> network disconnected.
>
> It looks a bit like a hack to me, the fundamental issue (ConnMan not tracking
> the wpa_supplicant states properly, it seems) is not fixed.

I agree my patch is a bit hackish, but it makes a huge difference here
at UDS. Without these two patches (and Mohamed's busy loop fix) connman
is unusable with a large wifi network.

Currently wifi plugin makes wrong assumptions how wpasupplicant works
and what the different wpasupplicant states mean. The proper fix would
be to change wpasupplicant to not use disconnected state when roaming.
The disconnected state should be used only when wpasupplicant is certain
that it cannot connect to the ESS anymore, for example after scanning
two times and not finding any suitable APs.

I think I can work on changing wpasupplicant at some point, but it will
take few months before I can find the time. My short term goal is to
make connman wifi reliable enough for the users.

Thank you for the comments.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Start wpa_supplican is service not running.

2010-10-27 Thread Kalle Valo
 writes:

> Hi Kalle,
>
>>> + reply = dbus_connection_send_with_reply_and_block(connection,
>>> + message, -1, &error);
>
>> connman must never block, instead we need to use async interfaces.
>
> I intentionally made the call blocking since the system_available will
> be set to TRUE only if we get a reply from Introspect method. This
> also indicates that wpa_supplicant was indeed started in case it was
> not already running.

Still it's wrong, connman should not block anywhere. When it's blocking
on something no other events are handled and that's bound to create
problems.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 0/2] wifi disconnect timer

2010-10-26 Thread Kalle Valo
Kalle Valo  writes:

> I'm at UDS right now and I have been debugging gsupplicant extensively and
> I have had quite a lot of problems. I noticed a problem how the wifi 
> plugin handles the wpasupplicant disconnect state. Here are two patches
> how I propose to fix the issues. At least in my case the patches
> helped a lot.

Sorry, I forgot to mention that these patches are on top of pile of
other patches. For example, Mohamed's " Fix deadlock when disassociate
while associating." patch. But please take a look and comment.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 0/2] *** SUBJECT HERE ***

2010-10-26 Thread Kalle Valo
Kalle Valo  writes:

> *** BLURB HERE ***

Heh, sorry about this. git send-email also sent an emacs backup file :)

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 1/2] wifi: add a disconnected timer

2010-10-26 Thread Kalle Valo
In a big network, for example at Ubuntu Developer Summit which has >10 APs,
connman and wpasupplicant got out of sync very easily. connman claimed it
was connected even though wpasupplicant (and the kernel driver) was actually
connected to the AP.

The problem is that while roaming between APs inside ESS wpasupplicant states
go like this:

COMPLETED -> DISCONNECTED -> SCANNING -> AUTHENTICATING ... -> COMPLETED

So what happens is that connman unnecessarily marks the network disconnected
even though wpasupplicant is just roaming to a different AP within ESS.

To fix this add a timer which waits 10 seconds after a disconnected state.
If wpasupplicant hasn't connected to a network at time only then set the
network disconnected.
---
 plugins/wifi.c |   71 ++-
 1 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 37f6e32..d036a92 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -61,6 +61,7 @@ struct wifi_data {
int index;
unsigned flags;
unsigned int watch;
+   guint disconnect_timer;
 };
 
 static int get_bssid(struct connman_device *device,
@@ -309,6 +310,61 @@ static const gchar *state2str(GSupplicantState state)
return "UNKNOWN";
 }
 
+static gboolean disconnected_timeout(gpointer user_data)
+{
+   GSupplicantInterface *interface;
+   struct connman_network *network;
+   struct wifi_data *wifi;
+
+   DBG("");
+
+   interface = user_data;
+
+   wifi = g_supplicant_interface_get_data(interface);
+
+   if (wifi == NULL)
+   return FALSE;
+
+   network = wifi->network;
+
+   connman_network_set_associating(network, FALSE);
+   connman_network_set_connected(network, FALSE);
+
+   connman_network_unref(wifi->network);
+   wifi->network = NULL;
+
+   return FALSE;
+}
+
+static void start_disconnected_timer(GSupplicantInterface *interface)
+{
+   struct wifi_data *wifi = g_supplicant_interface_get_data(interface);
+
+   if (wifi == NULL)
+   return;
+
+   if (wifi->disconnect_timer != 0)
+   return;
+
+   wifi->disconnect_timer = g_timeout_add(1, disconnected_timeout,
+   interface);
+}
+
+static void stop_disconnected_timer(GSupplicantInterface *interface)
+{
+   struct wifi_data *wifi = g_supplicant_interface_get_data(interface);
+
+   if (wifi == NULL)
+   return;
+
+   if (wifi->disconnect_timer == 0)
+   return;
+
+   g_source_remove(wifi->disconnect_timer);
+   wifi->disconnect_timer = 0;
+}
+
+
 static void interface_state(GSupplicantInterface *interface)
 {
struct connman_network *network;
@@ -328,8 +384,10 @@ static void interface_state(GSupplicantInterface 
*interface)
network = wifi->network;
device = wifi->device;
 
-   if (device == NULL || network == NULL)
+   if (device == NULL || network == NULL) {
+   stop_disconnected_timer(interface);
return;
+   }
 
switch (state) {
case G_SUPPLICANT_STATE_SCANNING:
@@ -345,6 +403,8 @@ static void interface_state(GSupplicantInterface *interface)
/* reset scan trigger and schedule background scan */
connman_device_schedule_scan(device);
 
+   stop_disconnected_timer(interface);
+
if (get_bssid(device, bssid, &bssid_len) == 0)
connman_network_set_address(network,
bssid, bssid_len);
@@ -352,12 +412,7 @@ static void interface_state(GSupplicantInterface 
*interface)
break;
 
case G_SUPPLICANT_STATE_DISCONNECTED:
-   connman_network_set_associating(network, FALSE);
-   connman_network_set_connected(network, FALSE);
-
-   connman_network_unref(wifi->network);
-   wifi->network = NULL;
-
+   start_disconnected_timer(interface);
break;
 
case G_SUPPLICANT_STATE_INACTIVE:
@@ -640,6 +695,8 @@ static int network_disconnect(struct connman_network 
*network)
 
connman_network_set_associating(network, FALSE);
 
+   stop_disconnected_timer(wifi->interface);
+
return g_supplicant_interface_disconnect(wifi->interface,
disconnect_callback, wifi);
 }
-- 
1.7.1

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 0/2] *** SUBJECT HERE ***

2010-10-26 Thread Kalle Valo
*** BLURB HERE ***

Kalle Valo (2):
  wifi: add a disconnected timer
  wifi: don't set associating state when roaming between APs

 plugins/wifi.c |   74 +--
 1 files changed, 66 insertions(+), 8 deletions(-)

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 2/2] wifi: don't set associating state when roaming between APs

2010-10-26 Thread Kalle Valo
When wpasupplicant is roaming between APs it exposes all states to connman.
After the wifi network is connected, we should not set associating state
anymore. Otherwise we just end up into weird states.
---
 plugins/wifi.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index d036a92..dc19b79 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -396,7 +396,8 @@ static void interface_state(GSupplicantInterface *interface)
 
case G_SUPPLICANT_STATE_AUTHENTICATING:
case G_SUPPLICANT_STATE_ASSOCIATING:
-   connman_network_set_associating(network, TRUE);
+   if (!connman_network_get_connected(network))
+   connman_network_set_associating(network, TRUE);
break;
 
case G_SUPPLICANT_STATE_COMPLETED:
-- 
1.7.1

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 0/2] wifi disconnect timer

2010-10-26 Thread Kalle Valo
I'm at UDS right now and I have been debugging gsupplicant extensively and
I have had quite a lot of problems. I noticed a problem how the wifi 
plugin handles the wpasupplicant disconnect state. Here are two patches
how I propose to fix the issues. At least in my case the patches
helped a lot.

Kalle Valo (2):
  wifi: add a disconnected timer
  wifi: don't set associating state when roaming between APs

 plugins/wifi.c |   74 +--
 1 files changed, 66 insertions(+), 8 deletions(-)

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Start wpa_supplican is service not running.

2010-10-26 Thread Kalle Valo
 writes:

> I have created a patch for this issue. The patch invokes the
> Introspect method to autostart wpa_supplicant if it is not already
> running.

Thanks a lot for working on this. I didn't read the patch that carefully
yet, but I noticed something:

> + reply = dbus_connection_send_with_reply_and_block(connection,
> + message, -1, &error);

connman must never block, instead we need to use async interfaces.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Start wpa_supplican is service not running.

2010-10-24 Thread Kalle Valo
On 10/24/2010 05:08 PM, Marcel Holtmann wrote:
> Hi Kalle,

Hi Marcel,

>> -dbus_message_set_auto_start(message, FALSE);
>> -
>>  dbus_message_append_args(message, DBUS_TYPE_STRING, &interface, NULL);
> 
> this patch is wrong. The non-autostart stuff is there on purpose. We do
> want control when the daemon is started. And more important in case of
> crash situation to be able to clean this properly.

I was thinking that there's likely a reason like that.

>> +supplicant_dbus_property_get_all(SUPPLICANT_PATH,
>>  SUPPLICANT_INTERFACE,
>>  service_property, NULL);
>> -
> 
> I actually prefer to autostart a daemon by asking for the introspection
> data and not via an actual method call. Just a quick hint here.

That sounds good to me. Thank you for the review.

Mohamed, do you want to create a patch or should I do it?

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Start wpa_supplican is service not running.

2010-10-24 Thread Kalle Valo
Hi Mohamed,

On 10/22/2010 06:12 AM, Mohamed Abbas wrote:
> This patch will fix a bug regarding ConnMan not starting
> wpa_supplican when using new supplican interface.

I noticed the same issue. I created a bit different patch for this and
was supposed to send it to the list, but I can't find it from the
archives anymore. I'll send it now anyway.

(git-send is not working for me right now, so I need to copy-paste this.
Sorry about that.)

gsupplicant: enable dbus auto start

From: Kalle Valo 

In Ubuntu wpasupplicant is started with dbus auto activation, but
gsupplicant
disables this feature and hence wifi didn't work at all. Enable this feature
to make it possible to start wpasupplicant when needed.

I don't know how other distros start wpasupplicant, but at least with
wifi-legacy wpasupplicant was automatically started by dbus.
---
 gsupplicant/dbus.c   |2 --
 gsupplicant/supplicant.c |6 +++---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/gsupplicant/dbus.c b/gsupplicant/dbus.c
index 53c56ae..2301807 100644
--- a/gsupplicant/dbus.c
+++ b/gsupplicant/dbus.c
@@ -154,8 +154,6 @@ int supplicant_dbus_property_get_all(const char
*path, const char *interface,
return -ENOMEM;
}

-   dbus_message_set_auto_start(message, FALSE);
-
dbus_message_append_args(message, DBUS_TYPE_STRING, &interface, NULL);

if (dbus_connection_send_with_reply(connection, message,
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 322b63d..4b62ad3 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2421,12 +2421,12 @@ int g_supplicant_register(const
GSupplicantCallbacks *callbacks)
dbus_connection_flush(connection);

if (dbus_bus_name_has_owner(connection,
-   SUPPLICANT_SERVICE, NULL) == TRUE) {
+   SUPPLICANT_SERVICE, NULL) == TRUE)
system_available = TRUE;
-   supplicant_dbus_property_get_all(SUPPLICANT_PATH,
+
+   supplicant_dbus_property_get_all(SUPPLICANT_PATH,
SUPPLICANT_INTERFACE,
service_property, NULL);
-   }

return 0;
 }
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


gsupplicant: resume regression

2010-10-22 Thread Kalle Valo
Hello,

I updated to latest git this morning and now connman doesn't reconnect
to a wifi network in resume. I need to keep the laptop suspended for few
minutes to reproduce this.

I noticed that driver is connected but connman doesn't see the network
at all:

tukki:~$ cmcc list
  Convention Center Foyer Only {
wifi_0026b6675606_436f6e76656e74696f6e2043656e74657220466f796572204f6e6c79_managed_none
}
tukki:~$ iw wlan0 link
Connected to 00:27:0d:b0:17:20 (on wlan0)
SSID: Ubuntu
freq: 2462
RX: 73440 bytes (552 packets)
TX: 174 bytes (3 packets)
signal: -63 dBm
tx bitrate: 1.0 MBit/s
tukki:~$

I'll do a bisect later today and get back on this.

ath9k, nl80211
connmand -c -d -P wifi_legacy
wpasupplicant 0.7.3

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: gsupplicant disconnect busyloop

2010-10-21 Thread Kalle Valo
Hi Mohamed,

On 10/21/2010 03:26 PM, Abbas, Mohamed wrote:
> Yes I am currently looking into the fix for this one. These two functions 
> __connman_network_disconnect and connman_network_set_connected keep calling 
> eatch other and create this deadlock.

I saw this two times now within two hours. If you have any patches, I'm
happy to test them.

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


gsupplicant: disconnect needed after a failure

2010-10-21 Thread Kalle Valo
Hello,

I noticed that if a wifi connection fails in configuration state (ie.
dhcp fails), I need to do an extra disconnect call to be able to use
wifi again. I was using gsupplicant and ath9k with wext.

Below is an example how it failed. I don't have any logs right now, but
if needed, I can provide them later.

The "Already connected" is the error I'm talking about.

tukki:~$ cmcc connect tower3
/usr/bin/cmcc:352: DeprecationWarning: BaseException.message has been
deprecated as of Python 2.6
  print "%s: %s" % (error._dbus_error_name, error.message)
org.moblin.connman.Error.Failed: Input/output error
tukki:~$ cmcc show tower3
[ /profile/default/wifi_0026b6675606_546f77657233_managed_none ]
  Name = Tower3
  Type = wifi
  State = failure
  Strength = 40
  Mode = managed
  Security = none
  IPv4 = {  }
  IPv4.Configuration = {  Method=dhcp }
  IPv6 = {  }
  IPv6.Configuration = {  Method=off }
  Ethernet = {  Interface=wlan0 Method=auto Address=00:26:B6:67:56:06 }
  Nameservers = [  ]
  Nameservers.Configuration = [  ]
  Domains = [  ]
  Domains.Configuration = [  ]
  Proxy = {  }
  PassphraseRequired = false
  Immutable = false
  Favorite = false
  AutoConnect = false
  LoginRequired = false
  Provider = {  }
  Proxy.Configuration = {  Method=auto }
tukki:~$ cmcc connect tower3
/usr/bin/cmcc:352: DeprecationWarning: BaseException.message has been
deprecated as of Python 2.6
  print "%s: %s" % (error._dbus_error_name, error.message)
org.moblin.connman.Error.AlreadyConnected: Already connected
tukki:~$ cmcc disconnect tower3
tukki:~$ cmcc connect tower3
/usr/bin/cmcc:352: DeprecationWarning: BaseException.message has been
deprecated as of Python 2.6
  print "%s: %s" % (error._dbus_error_name, error.message)
org.moblin.connman.Error.Failed: Input/output error
tukki:~$

Kalle
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


gsupplicant disconnect busyloop

2010-10-21 Thread Kalle Valo
Hi,

I was testing gsupplicant and I managed to get connman busyloop again.

connmand -c -d -P wifi_legacy
ath9k, nl80211
linux 2.6.35-22-generic (ubuntu maverick)
wpasupplicant 0.7.3

Kalle

Oct 21 21:19:30 tukki connmand[28253]: src/rtnl.c:rtnl_message() buf
0x7fff9affc510 len 156
Oct 21 21:19:30 tukki connmand[28253]: src/rtnl.c:rtnl_message()
NEWROUTE len 156 type 24 flags 0x seq 0
Oct 21 21:19:38 tukki connmand[28253]: src/rtnl.c:rtnl_message() buf
0x7fff9affc510 len 156
Oct 21 21:19:38 tukki connmand[28253]: src/rtnl.c:rtnl_message()
DELROUTE len 156 type 25 flags 0x seq 0
Oct 21 21:19:47 tukki connmand[28253]:
src/service.c:disconnect_service() service 0x7fed86f1c100
Oct 21 21:19:47 tukki connmand[28253]:
src/service.c:__connman_service_disconnect() service 0x7fed86f1c100
Oct 21 21:19:47 tukki connmand[28253]:
src/network.c:__connman_network_disconnect() network 0x7fed86f2a600
Oct 21 21:19:47 tukki connmand[28253]:
plugins/wifi.c:network_disconnect() network 0x7fed86f2a600
Oct 21 21:19:47 tukki connmand[28253]:
gsupplicant/supplicant.c:g_supplicant_interface_disconnect()
Oct 21 21:19:47 tukki connmand[28253]:
src/network.c:connman_network_set_connected() network 0x7fed86f2a600
connected 0
Oct 21 21:19:47 tukki connmand[28253]:
src/element.c:connman_element_set_error() element 0x7fed86f2a600 error 3
Oct 21 21:19:47 tukki connmand[28253]: src/network.c:network_change()
element 0x7fed86f2a600 name 5562756e7475_managed_none
Oct 21 21:19:47 tukki connmand[28253]:
src/service.c:__connman_service_lookup_from_network() network 0x7fed86f2a600
Oct 21 21:19:47 tukki connmand[28253]:
src/service.c:__connman_service_indicate_error() service 0x7fed86f1c100
error 4
Oct 21 21:19:47 tukki connmand[28253]:
src/service.c:__connman_service_indicate_state() service 0x7fed86f1c100
state 7
Oct 21 21:19:47 tukki connmand[28253]:
src/service.c:__connman_service_auto_connect()
Oct 21 21:19:47 tukki connmand[28253]:
src/storage.c:__connman_storage_save_service() service 0x7fed86f1c100
Oct 21 21:19:47 tukki connmand[28253]: src/service.c:service_save()
service 0x7fed86f1c100
Oct 21 21:19:47 tukki wpa_supplicant[5444]: dbus:
fi.w1.wpa_supplicant1.Interface.Disconnect
(/fi/w1/wpa_supplicant1/Interfaces/21)
Oct 21 21:19:47 tukki wpa_supplicant[5444]:
wpa_driver_nl80211_deauthenticate
Oct 21 21:19:47 tukki connmand[28253]:
src/network.c:connman_network_get_blob() network 0x7fed86f2a600 key
WiFi.SSID
Oct 21 21:19:47 tukki connmand[28253]:
src/ipconfig.c:__connman_ipconfig_save() ipconfig 0x7fed86edf700
identifier wifi_0026b6675606_5562756e7475_managed_none
Oct 21 21:19:47 tukki connmand[28253]:
src/ipconfig.c:__connman_ipconfig_save() ipconfig 0x7fed86eed200
identifier wifi_0026b6675606_5562756e7475_managed_none
Oct 21 21:19:47 tukki wpa_supplicant[5444]: No keys have been configured
- skip key clearing
Oct 21 21:19:47 tukki wpa_supplicant[5444]: State: COMPLETED -> DISCONNECTED
Oct 21 21:19:47 tukki wpa_supplicant[5444]:
wpa_driver_nl80211_set_operstate: operstate 1->0 (DORMANT)
Oct 21 21:19:47 tukki wpa_supplicant[5444]: netlink: Operstate:
linkmode=-1, operstate=5
Oct 21 21:19:47 tukki kernel: [52129.672600] wlan0: deauthenticating
from 00:27:0d:b0:17:20 by local choice (reason=3)
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: External notification
- portEnabled=0
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: SUPP_PAE entering
state DISCONNECTED
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: Supplicant port
status: Unauthorized
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: SUPP_BE entering
state INITIALIZE
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: Supplicant port
status: Unauthorized
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: External notification
- portValid=0
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: Supplicant port
status: Unauthorized
Oct 21 21:19:47 tukki wpa_supplicant[5444]: nl80211: Event message available
Oct 21 21:19:47 tukki wpa_supplicant[5444]: nl80211: MLME event 39
Oct 21 21:19:47 tukki wpa_supplicant[5444]: Deauthentication notification
Oct 21 21:19:47 tukki wpa_supplicant[5444]: Added BSSID
00:00:00:00:00:00 into blacklist
Oct 21 21:19:47 tukki wpa_supplicant[5444]: CTRL-EVENT-DISCONNECTED
bssid=00:00:00:00:00:00 reason=3
Oct 21 21:19:47 tukki wpa_supplicant[5444]: State: DISCONNECTED ->
DISCONNECTED
Oct 21 21:19:47 tukki wpa_supplicant[5444]:
wpa_driver_nl80211_set_operstate: operstate 0->0 (DORMANT)
Oct 21 21:19:47 tukki wpa_supplicant[5444]: netlink: Operstate:
linkmode=-1, operstate=5
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: External notification
- portEnabled=0
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: Supplicant port
status: Unauthorized
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: External notification
- portValid=0
Oct 21 21:19:47 tukki wpa_supplicant[5444]: EAPOL: Supplicant port
status: Unauthorized
Oct 21 21:19:47 tukki wpa_supplicant[5444]: RTM_NEWLINK: operstate=0
ifi_flags=0x1003 ([UP])
Oct 21 21:19:47 tukki wpa_supplicant

  1   2   >