Re: [PATCH] Allow service to get the related network

2009-07-09 Thread Jukka Rissanen
On Thu, Jul 9, 2009 at 8:45 PM, Marcel Holtmannmar...@holtmann.org wrote:
 Hi Jukka,

 the following patch allows service element to get information about
 the related network. I created a custom storage plugin that updates
 the wifi information (like passphrase) in plugins service_load()
 method. This cannot be done if the service element cannot access the
 network data.

 I prefer not to do this and better fix it a different way. What kind of
 information do you need from struct network? If we can fix this in a
 better way, I prefer to do that. If not then we have to opt for your
 patch and work on something.

I would need SSID information so that I can fetch passphrase from
gconf (where it is stored in maemo) and put passphrase info to
network.wifi struct.
First I tried to use the storage plugins network_load func but at that
stage the SSID information is not yet known. The optimal solution
would be that SSID is available when network_load is called.

 With the passphrase we do set it when actually trying to connect to the
 network. No need to set it any earlier.

But it should not harm if the passphrase is pre-set to those networks
that are known.


 And your mailer introduced line-breaks into your patch. So it won't even
 apply cleanly.

Ok, I have to figure it out.


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


Connman 0.40 regression from 0.19

2009-09-02 Thread Jukka Rissanen
Hi,

I just noticed a regression in 0.40 (compared to 0.19).

I have two network interfaces (wlan0 and usb0) in host and want to
only enable wlan0 interface so I use
   /usr/sbin/connmand -n -i wlan*
to start connmand.
In 0.19 this worked ok, my usb0 interface was left intact and I could
use it normally (ssh connection continued worked ok). In 0.40 the usb0
interface is still up but its address and route is lost.

In syslog I can see following:

Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: Connection Manager version 0.40
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: The loopback interface
is already up
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: System hostname is Nokia-NXX-32-2
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: Failed to bind listener socket
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: Adding profile default
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: Failed to open RFKILL
control device
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: wlan0 {create} index 3
type 1 ETHER
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: wlan0 {update} flags 4098 DOWN
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: usb0 {create} index 6
type 1 ETHER
Jan  1 11:02:53 Nokia-NXX-32-2 connmand[5033]: usb0 {update} flags
69699 UP,RUNNING,LOWER_UP
Jan  1 11:02:54 Nokia-NXX-32-2 connmand[5033]: wlan0 {update} flags 4099 UP
Jan  1 11:02:55 Nokia-NXX-32-2 connmand[5033]: wlan0 SCANNING
Jan  1 11:02:55 Nokia-NXX-32-2 connmand[5033]: wlan0 scanning started
Jan  1 11:02:56 Nokia-NXX-32-2 connmand[5033]: wlan0 scanning finished
Jan  1 11:03:01 Nokia-NXX-32-2 connmand[5033]: wlan0 INACTIVE
Jan  1 11:03:25 Nokia-NXX-32-2 connmand[5033]: usb0 {update} flags 4098 DOWN
Jan  1 11:03:26 Nokia-NXX-32-2 connmand[5033]: usb0 {update} flags
69699 UP,RUNNING,LOWER_UP
Jan  1 11:03:26 Nokia-NXX-32-2 connmand[5033]: usb0 {add} address
192.168.2.15/24 label usb0
Jan  1 11:03:27 Nokia-NXX-32-2 connmand[5033]: usb0 {add} route
0.0.0.0 gw 192.168.2.14 scope 0 UNIVERSE
Jan  1 11:03:57 Nokia-NXX-32-2 connmand[5033]: Terminating
Jan  1 11:03:57 Nokia-NXX-32-2 connmand[5033]: wlan0 {remove} index 3
Jan  1 11:03:57 Nokia-NXX-32-2 connmand[5033]: usb0 {remove} index 6
Jan  1 11:03:57 Nokia-NXX-32-2 connmand[5033]: Removing profile default
Jan  1 11:03:57 Nokia-NXX-32-2 connmand[5033]: Exit


I also enabled debugging via -d option which shows that filtering is
enabled for usb0

Jan  1 11:12:44 Nokia-NXX-32-2 connmand[5312]:
src/element.c:connman_element_register() ignoring 1220818493b3 [usb0]
device

although usb0 will still become useless.

Any ideas what goes wrong?

I also noticed that -I cmd line option is not used anywhere so perhaps
it could be removed alltogether from the code.


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


Re: Connman 0.40 regression from 0.19

2009-09-02 Thread Jukka Rissanen
Hi Marcel,

2009/9/2 Marcel Holtmann mar...@holtmann.org:
 I also noticed that -I cmd line option is not used anywhere so perhaps
 it could be removed alltogether from the code.

 The -I should do the exact opposite. Allow all interfaces except that
 one. Kinda nice if you wanna exclude eth0 for example.

 Regards

 Marcel

Yes, the -I option should do that but the

__connman_element_init(const char *device, const char *nodevice);

does not use the nodevice variable for anything so the -I option does
nothing. Perhaps this is also a regression from earlier version where
it worked, I have not tried to use this option earlier.


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


[PATCH proxy-manual 1/5] Add manual proxy description

2010-08-26 Thread Jukka Rissanen
---
 doc/service-api.txt |   69 +-
 1 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/doc/service-api.txt b/doc/service-api.txt
index c1dd541..b8b694b 100644
--- a/doc/service-api.txt
+++ b/doc/service-api.txt
@@ -410,13 +410,78 @@ Propertiesstring State [readonly]
If no automatic configuration is available,
then direct is set.
 
-   The values auto and manual are not yet
-   supported.
+   The value auto is not yet supported.
 
string URL [readonly]
 
Automatic proxy configuration URL.
 
+   string Http [readonly]
+
+   Address/hostname for HTTP proxy. Used when
+   Method is manual
+
+   uint16 HttpPort [readonly]
+
+   Port number for HTTP proxy. Used if Http has
+   a value.
+
+   string Https [readonly]
+
+   Address/hostname for HTTPS proxy. Used when
+   Method is manual
+
+   uint16 HttpsPort [readonly]
+
+   Port number for HTTPS proxy. Used if Https has
+   a value.
+
+   string Ftp [readonly]
+
+   Address/hostname for FTP proxy. Used when
+   Method is manual
+
+   uint16 FtpPort [readonly]
+
+   Port number for FTP proxy. Used if Ftp has
+   a value.
+
+   string Socks [readonly]
+
+   Address/hostname for socks proxy. Used when
+   Method is manual
+
+   uint16 SocksPort [readonly]
+
+   Port number for socks proxy. Used if Socks has
+   a value.
+
+   string Rtsp [readonly]
+
+   Address/hostname for RTSP proxy. Used when
+   Method is manual
+
+   uint16 RtspPort [readonly]
+
+   Port number for RTSP proxy. Used if Rtsp has
+   a value.
+
+   array{string} Ignore [readonly]
+
+   List of networks or hostnames that do not
+   have a proxy.
+
+   dict Proxy.Configuration [readwrite]
+
+   Same values as Proxy property. The Proxy represents
+   the actual system configuration while this allows
+   user configuration.
+
+   The proxy port must be set the same time as proxy host
+   when saving initial entry. It is possible to update
+   the port and host individually of an existing proxy
+   setting.
+
dict Provider [readonly]
 
string Host [readonly]
-- 
1.7.0.4

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


[PATCH proxy-manual 3/5] Add test script for setting up proxy

2010-08-26 Thread Jukka Rissanen
---
 Makefile.am|3 +-
 test/set-proxy |   74 
 2 files changed, 76 insertions(+), 1 deletions(-)
 create mode 100755 test/set-proxy

diff --git a/Makefile.am b/Makefile.am
index 1bf7207..128d4b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,7 +179,8 @@ test_scripts = test/get-state test/list-profiles 
test/list-services \
test/monitor-manager test/test-counter test/set-ip-method \
test/set-nameservers test/set-domains test/find-service \
test/get-services test/get-proxy-autoconfig \
-   test/enable-tethering test/disable-tethering test/backtrace
+   test/enable-tethering test/disable-tethering test/backtrace \
+   test/set-proxy
 
 if TEST
 testdir = $(pkglibdir)/test
diff --git a/test/set-proxy b/test/set-proxy
new file mode 100755
index 000..35a4bf1
--- /dev/null
+++ b/test/set-proxy
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv)  2):
+   print Usage: %s service [direct|auto|manual|auto-config] 
[url=pac-url] [http=host:port] [https=host:port] [ftp=host:port] 
[socks=host:port] [rtsp=host:port] [ignore=host1,host2,...] % (sys.argv[0])
+   print Example: %s service0 manual http=http.proxy.example.com:8080 
rtsp= % sys.argv[0]
+   print  This would set the http proxy and clear the rtsp proxy 
values
+   sys.exit(1)
+
+bus = dbus.SystemBus()
+path = /profile/default/ + sys.argv[1]
+service = dbus.Interface(bus.get_object('org.moblin.connman', path),
+   'org.moblin.connman.Service')
+values = {}
+values[Method] = sys.argv[2]
+
+properties = service.GetProperties()
+
+for arg in sys.argv[3:]:
+   if arg.startswith(url=):
+   url = arg.replace(url=, , 1)
+   #print url: %s % url
+   values[URL] = url
+   if arg.startswith(http=):
+   try:
+   (host, port) = arg.replace(http=,,1).split(:)
+   except:
+   (host, port) = (, 0)
+   #print http: %s:%s % (host, port)
+   values[Http] = host
+   values[HttpPort] = dbus.UInt16(port)
+   if arg.startswith(https=):
+   try:
+   (host, port) = arg.replace(https=,,1).split(:)
+   except:
+   (host, port) = (, 0)
+   #print https: %s:%s % (host, port)
+   values[Https] = host
+   values[HttpsPort] = dbus.UInt16(port)
+   if arg.startswith(ftp=):
+   try:
+   (host, port) = arg.replace(ftp=,,1).split(:)
+   except:
+   (host, port) = (, 0)
+   #print ftp: %s:%s % (host, port)
+   values[Ftp] = host
+   values[FtpPort] = dbus.UInt16(port)
+   if arg.startswith(socks=):
+   try:
+   (host, port) = arg.replace(socks=,,1).split(:)
+   except:
+   (host, port) = (, 0)
+   #print socks: %s:%s % (host, port)
+   values[Socks] = host
+   values[SocksPort] = dbus.UInt16(port)
+   if arg.startswith(rtsp=):
+   try:
+   (host, port) = arg.replace(rtsp=,,1).split(:)
+   except:
+   (host, port) = (, 0)
+   #print rtsp: %s:%s % (host, port)
+   values[Rtsp] = host
+   values[RtspPort] = dbus.UInt16(port)
+   if arg.startswith(ignore=):
+   try:
+   ignore_hosts = arg.replace(ignore=,,1).split(,)
+   except:
+   ignore_hosts = []
+   #print ignore: %s % ignore_hosts
+   values[Ignore] = ignore_hosts
+
+service.SetProperty(Proxy.Configuration, dbus.Dictionary(values, signature = 
sv))
-- 
1.7.0.4

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


[PATCH proxy-manual 4/5] Pretty print proxy data

2010-08-26 Thread Jukka Rissanen
---
 test/get-services |9 ++---
 test/list-providers   |8 ++--
 test/list-services|8 ++--
 test/monitor-services |   10 +++---
 test/test-manager |8 ++--
 5 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/test/get-services b/test/get-services
index d337e0c..b4b849a 100755
--- a/test/get-services
+++ b/test/get-services
@@ -6,7 +6,10 @@ def extract_values(values):
val = {
for key in values.keys():
val +=   + key + =
-   val += str(values[key])
+   if key in [Ignore]:
+   val += extract_list(values[key])
+   else:
+   val += str(values[key])
val +=  }
return val
 
@@ -33,8 +36,8 @@ for entry in services:
for key in properties.keys():
if key in [IPv4, IPv4.Configuration,
IPv6, IPv6.Configuration,
-   Proxy, Ethernet,
-   Provider]:
+   Proxy, Ethernet, Provider,
+   Proxy.Configuration]:
val = extract_values(properties[key])
elif key in [Nameservers, Nameservers.Configuration,
Domains, Domains.Configuration]:
diff --git a/test/list-providers b/test/list-providers
index 94375d5..6c74a1d 100755
--- a/test/list-providers
+++ b/test/list-providers
@@ -9,7 +9,10 @@ def extract_values(values):
if key in [PrefixLength]:
val += %s % (int(values[key]))
else:
-   val += str(values[key])
+   if key in [Ignore]:
+   val += extract_list(values[key])
+   else:
+   val += str(values[key])
val +=  }
return val
 
@@ -38,7 +41,8 @@ for path in properties[Providers]:
for key in properties.keys():
if key in [IPv4, IPv4.Configuration,
IPv6, IPv6.Configuration,
-   Proxy, Ethernet, Provider]:
+   Proxy, Proxy.Configuration,
+   Ethernet, Provider]:
val = extract_values(properties[key])
elif key in [Nameservers, Nameservers.Configuration,
Domains, Domains.Configuration]:
diff --git a/test/list-services b/test/list-services
index a894092..bf225de 100755
--- a/test/list-services
+++ b/test/list-services
@@ -9,7 +9,10 @@ def extract_values(values):
if key in [PrefixLength]:
val += %s % (int(values[key]))
else:
-   val += str(values[key])
+   if key in [Ignore]:
+   val += extract_list(values[key])
+   else:
+   val += str(values[key])
val +=  }
return val
 
@@ -38,7 +41,8 @@ for path in properties[Services]:
for key in properties.keys():
if key in [IPv4, IPv4.Configuration,
IPv6, IPv6.Configuration,
-   Proxy, Ethernet, Provider]:
+   Proxy, Proxy.Configuration,
+   Ethernet, Provider]:
val = extract_values(properties[key])
elif key in [Nameservers, Nameservers.Configuration,
Domains, Domains.Configuration]:
diff --git a/test/monitor-services b/test/monitor-services
index 05d1e1d..ead9d36 100755
--- a/test/monitor-services
+++ b/test/monitor-services
@@ -9,7 +9,10 @@ def extract_values(values):
val = {
for key in values.keys():
val +=   + key + =
-   val += str(values[key])
+   if key in [Ignore]:
+   val += extract_list(values[key])
+   else:
+   val += str(values[key])
val +=  }
return val
 
@@ -29,8 +32,9 @@ def property_changed(name, value, path):
val = val +   + i[i.rfind(/) + 1:]
val = val +  ]
elif name in [IPv4, IPv4.Configuration,
-   IPv6, IPv6.Configuration,
-   Proxy, Ethernet]:
+   IPv6, IPv6.Configuration,
+   Proxy, Proxy.Configuration,
+   Ethernet]:
val = extract_values(value)
elif name in [Nameservers, Nameservers.Configuration,
Domains, Domains.Configuration]:
diff --git a/test/test-manager b/test/test-manager
index b5a2530..da23e8d 

[PATCH proxy-manual 5/5] Add plugin for setting up proxy data in gconf

2010-08-26 Thread Jukka Rissanen
---
 Makefile.plugins |7 ++
 configure.ac |   10 +++
 plugins/proxygconf.c |  183 ++
 3 files changed, 200 insertions(+), 0 deletions(-)
 create mode 100644 plugins/proxygconf.c

diff --git a/Makefile.plugins b/Makefile.plugins
index 4ca78d3..2f15d85 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -230,6 +230,13 @@ plugins_ntpd_la_LDFLAGS = $(plugin_ldflags)
 endif
 endif
 
+if PROXYGCONF
+plugin_LTLIBRARIES += plugins/proxygconf.la
+plugin_objects += $(plugins_proxygconf_la_OBJECTS)
+plugins_proxygconf_la_CFLAGS = $(plugin_cflags) @GCONF_CFLAGS@
+plugins_proxygconf_la_LDFLAGS = $(plugin_ldflags) @GCONF_LIBS@
+endif
+
 EXTRA_DIST += plugins/polkit.policy scripts/dhclient.conf
 
 plugins/connman.policy: plugins/polkit.policy
diff --git a/configure.ac b/configure.ac
index 6923aa1..ddba330 100644
--- a/configure.ac
+++ b/configure.ac
@@ -368,5 +368,15 @@ AC_ARG_ENABLE(datafiles, 
AC_HELP_STRING([--disable-datafiles],
[enable_datafiles=${enableval}])
 AM_CONDITIONAL(DATAFILES, test ${enable_datafiles} != no)
 
+AC_ARG_ENABLE(proxygconf, AC_HELP_STRING([--enable-proxygconf],
+   [enable proxy GConf support]), [enable_proxygconf=${enableval}])
+AM_CONDITIONAL(PROXYGCONF, test ${enable_proxygconf} = yes)
+if (test ${enable_proxygconf} = yes); then
+   PKG_CHECK_MODULES(GCONF, gconf-2.0, dummy=yes,
+   AC_MSG_ERROR(gconf library is required))
+   AC_SUBST(GCONF_CFLAGS)
+   AC_SUBST(GCONF_LIBS)
+fi
+
 AC_OUTPUT(Makefile include/version.h src/connman.service
scripts/connman doc/version.xml connman.pc)
diff --git a/plugins/proxygconf.c b/plugins/proxygconf.c
new file mode 100644
index 000..2987567
--- /dev/null
+++ b/plugins/proxygconf.c
@@ -0,0 +1,183 @@
+/*
+ *  Save proxy settings to gconf.
+ *
+ *  Copyright (C) 2010 Nokia 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 config.h
+#endif
+
+#include stdio.h
+
+#define CONNMAN_API_SUBJECT_TO_CHANGE
+#include connman/plugin.h
+#include connman/storage.h
+#include connman/log.h
+
+#include gconf/gconf-client.h
+
+#define CONF_PROXY /system/proxy
+#define HTTP_PROXY /system/http_proxy
+
+
+static void set(GConfClient *gconf,
+   const char *host_path, const char *host,
+   const char *port_path, uint16_t port)
+{
+   if (host  host[0]) {
+   gconf_client_set_string(gconf, host_path, host, NULL);
+   if (port_path)
+   gconf_client_set_int(gconf, port_path, port, NULL);
+   } else {
+   gconf_client_unset(gconf, host_path, NULL);
+   if (port_path)
+   gconf_client_unset(gconf, port_path, NULL);
+   }
+}
+
+static void clear_entries(GConfClient *gconf)
+{
+   gconf_client_unset(gconf, CONF_PROXY /mode, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /secure_host, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /secure_port, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /ftp_host, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /ftp_port, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /socks_host, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /socks_port, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /rtsp_host, NULL);
+   gconf_client_unset(gconf, CONF_PROXY /rtsp_port, NULL);
+
+   gconf_client_unset(gconf, HTTP_PROXY /host, NULL);
+   gconf_client_unset(gconf, HTTP_PROXY /port, NULL);
+   gconf_client_unset(gconf, HTTP_PROXY /ignore_hosts, NULL);
+   gconf_client_unset(gconf, HTTP_PROXY /use_http_proxy, NULL);
+}
+
+static int proxy_save(struct connman_service *service)
+{
+   GConfClient *gconf;
+   struct connman_manual_proxy *proxy;
+   enum connman_service_proxy_method method;
+
+   DBG();
+
+   gconf = gconf_client_get_default();
+
+   proxy = connman_service_get_default_proxy(service, method);
+   if (!proxy) {
+   clear_entries(gconf);
+   goto out;
+   }
+
+   if (method != CONNMAN_SERVICE_PROXY_METHOD_MANUAL) {
+   clear_entries(gconf);
+   goto out;
+   }
+
+   set(gconf, CONF_PROXY /mode, manual, 

[PATCH IPv6] Separate IPv4 and IPv6 in struct connman_ipconfig so that connman can work with IPv6 only networks.

2010-11-22 Thread Jukka Rissanen
---
 include/ipconfig.h |3 +-
 include/network.h  |4 +-
 plugins/ofono.c|4 +-
 src/connman.h  |   13 ++-
 src/ipconfig.c |  381 +---
 src/ipv4.c |2 +-
 src/network.c  |  150 +
 src/provider.c |6 +-
 src/service.c  |  320 ++--
 9 files changed, 609 insertions(+), 274 deletions(-)

diff --git a/include/ipconfig.h b/include/ipconfig.h
index 28a3d6a..92110e0 100644
--- a/include/ipconfig.h
+++ b/include/ipconfig.h
@@ -74,7 +74,8 @@ struct connman_ipconfig_ops {
void (*ip_release) (struct connman_ipconfig *ipconfig);
 };
 
-struct connman_ipconfig *connman_ipconfig_create(int index);
+struct connman_ipconfig *connman_ipconfig_create(int index,
+   enum connman_ipconfig_type type);
 struct connman_ipconfig *connman_ipconfig_clone(struct connman_ipconfig 
*ipconfig);
 struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig 
*ipconfig);
 void connman_ipconfig_unref(struct connman_ipconfig *ipconfig);
diff --git a/include/network.h b/include/network.h
index f6ebc3a..0b538a4 100644
--- a/include/network.h
+++ b/include/network.h
@@ -89,7 +89,9 @@ connman_bool_t connman_network_get_connected(struct 
connman_network *network);
 
 connman_bool_t connman_network_get_associating(struct connman_network 
*network);
 
-void connman_network_set_method(struct connman_network *network,
+void connman_network_set_ipv4_method(struct connman_network *network,
+   enum connman_ipconfig_method method);
+void connman_network_set_ipv6_method(struct connman_network *network,
enum connman_ipconfig_method method);
 
 int connman_network_set_address(struct connman_network *network,
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 691037d..e9c5e71 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1484,7 +1484,7 @@ static void set_connected(struct connman_network *network,
return;
 
case CONNMAN_IPCONFIG_METHOD_FIXED:
-   connman_network_set_method(network, method);
+   connman_network_set_ipv4_method(network, method);
 
if (connected == FALSE)
cleanup_ipconfig(network);
@@ -1493,7 +1493,7 @@ static void set_connected(struct connman_network *network,
break;
 
case CONNMAN_IPCONFIG_METHOD_DHCP:
-   connman_network_set_method(network, method);
+   connman_network_set_ipv4_method(network, method);
 
connman_network_set_connected(network, connected);
break;
diff --git a/src/connman.h b/src/connman.h
index 8cb4754..1a781ce 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -263,6 +263,8 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix);
 int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix);
+int __connman_ipconfig_get_configs(int index, struct connman_ipconfig **ipv4,
+   struct connman_ipconfig **ipv6);
 
 #include connman/utsname.h
 
@@ -374,7 +376,8 @@ int __connman_network_disconnect(struct connman_network 
*network);
 int __connman_network_clear_ipconfig(struct connman_network *network,
struct connman_ipconfig *ipconfig);
 int __connman_network_set_ipconfig(struct connman_network *network,
-   struct connman_ipconfig *ipconfig);
+   struct connman_ipconfig *ipconfig_ipv4,
+   struct connman_ipconfig *ipconfig_ipv6);
 
 connman_bool_t __connman_network_has_driver(struct connman_network *network);
 
@@ -455,9 +458,13 @@ struct connman_service 
*__connman_service_create_from_provider(struct connman_pr
 void __connman_service_update_from_network(struct connman_network *network);
 void __connman_service_remove_from_network(struct connman_network *network);
 
-void __connman_service_create_ipconfig(struct connman_service *service,
+void __connman_service_create_ip4config(struct connman_service *service,
+   int index);
+void __connman_service_create_ip6config(struct connman_service *service,
int index);
-struct connman_ipconfig *__connman_service_get_ipconfig(
+struct connman_ipconfig *__connman_service_get_ip4config(
+   struct connman_service *service);
+struct connman_ipconfig *__connman_service_get_ip6config(
struct connman_service *service);
 const char *__connman_service_get_ident(struct connman_service *service);
 const char 

[PATCH] Update TODO list about IPv6 enhancements

2010-11-24 Thread Jukka Rissanen
---
 TODO |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/TODO b/TODO
index 62baae4..43838fd 100644
--- a/TODO
+++ b/TODO
@@ -126,6 +126,19 @@ Core
resolver.c code for editing resolv.conf.
 
 
+- IPv6 enhancements
+
+   Priority: High
+   Complexity: C8
+   Owner: Jukka Rissanen jukka.rissa...@nokia.com
+
+   Support IPv6 only networks so that system can go online even if
+   there is no IPv4 address. Also support more than one IPv6 address
+   in one device so that the addresses are reported correctly via
+   dbus interface. The autoconf IPv6 addresses need also some tweaking
+   so that system will go online properly.
+
+
 WiFi
 
 
-- 
1.7.0.4

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


[PATCH IPv6 v2 00/10] Separate IPv4 and IPv6 data

2010-12-09 Thread Jukka Rissanen
Hi all,

this is second version of the IPv6 and IPv4 separation in connman_ipconfig 
struct.
The v1 patch was a big one and now it is split to smaller chunks as instructed 
by Samuel.

The patches are necessary so that connman can be used in an environment where 
might not be IPv4 addresses available (like in many LTE networks). Everything 
should be working as is after the patch i.e., the patch does not change any 
fundamental things but the patch is needed for future work.

Regards,

Jukka


Jukka Rissanen (10):
  Make sure ipconfig is not null before accessing members
  Removed ipconfig from connman_network struct as it is not used.
  Do not add duplicate IP address to address list.
  Allow more than one IP address in the address list.
  Changing __connman_service_notify() to use the service directly
instead of ipconfig. This is done to make the code more readable.
  Separate IPv4 and IPv6 in connman_ipconfig struct so that connman can
work with IPv6 only networks.
  Return only a valid IPv6 configuration
  Set the IPv6 gateway address only if using IPv6 config
  Check that ipconfig is valid IPv4 config before returning data
  Check that ipconfig is valid IPv6 config before returning data

 include/ipconfig.h |3 +-
 include/network.h  |4 +-
 plugins/ofono.c|4 +-
 src/connman.h  |   13 ++-
 src/ipconfig.c |  357 +---
 src/ipv4.c |2 +-
 src/network.c  |  150 ++-
 src/provider.c |   21 +++-
 src/service.c  |  318 +++---
 9 files changed, 596 insertions(+), 276 deletions(-)

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


[PATCH IPv6 v2 03/10] Do not add duplicate IP address to address list.

2010-12-09 Thread Jukka Rissanen
---
 src/ipconfig.c |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 133db61..62323c7 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -594,6 +594,17 @@ void __connman_ipconfig_dellink(int index, struct 
rtnl_link_stats *stats)
g_hash_table_remove(ipdevice_hash, GINT_TO_POINTER(index));
 }
 
+static inline gint check_duplicate_address(gconstpointer a, gconstpointer b)
+{
+   const struct connman_ipaddress *addr1 = a;
+   const struct connman_ipaddress *addr2 = b;
+
+   if (addr1-prefixlen != addr2-prefixlen)
+   return addr2-prefixlen - addr1-prefixlen;
+
+   return g_strcmp0(addr1-local, addr2-local);
+}
+
 void __connman_ipconfig_newaddr(int index, int family, const char *label,
unsigned char prefixlen, const char *address)
 {
@@ -614,6 +625,12 @@ void __connman_ipconfig_newaddr(int index, int family, 
const char *label,
ipaddress-prefixlen = prefixlen;
ipaddress-local = g_strdup(address);
 
+   if (g_slist_find_custom(ipdevice-address_list, ipaddress,
+   check_duplicate_address)) {
+   connman_ipaddress_free(ipaddress);
+   return;
+   }
+
ipdevice-address_list = g_slist_append(ipdevice-address_list,
ipaddress);
 
-- 
1.7.0.4

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


[PATCH IPv6 v2 02/10] Removed ipconfig from connman_network struct as it is not used.

2010-12-09 Thread Jukka Rissanen
---
 src/network.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/src/network.c b/src/network.c
index 0e22522..e5fd7ab 100644
--- a/src/network.c
+++ b/src/network.c
@@ -44,7 +44,6 @@ struct connman_network {
char *name;
char *node;
char *group;
-   struct connman_ipconfig *ipconfig;
 
struct connman_network_driver *driver;
void *driver_data;
@@ -169,11 +168,6 @@ static void network_destruct(struct connman_element 
*element)
g_free(network-address);
g_free(network-identifier);
 
-   if (network-ipconfig) {
-   connman_ipconfig_unref(network-ipconfig);
-   network-ipconfig = NULL;
-   }
-
network-device = NULL;
 }
 
-- 
1.7.0.4

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


[PATCH IPv6 v2 04/10] Allow more than one IP address in the address list.

2010-12-09 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 62323c7..fe99b81 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -649,9 +649,6 @@ void __connman_ipconfig_newaddr(int index, int family, 
const char *label,
if ((ipdevice-flags  (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | 
IFF_LOWER_UP))
return;
 
-   if (g_slist_length(ipdevice-address_list)  1)
-   return;
-
for (list = g_list_first(ipconfig_list); list;
list = g_list_next(list)) {
struct connman_ipconfig *ipconfig = list-data;
-- 
1.7.0.4

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


[PATCH IPv6 v2 06/10] Separate IPv4 and IPv6 in connman_ipconfig struct so that connman can work with IPv6 only networks.

2010-12-09 Thread Jukka Rissanen
This patch does not yet enable IPv6 only network support but it is
required for later work.
---
 include/ipconfig.h |3 +-
 include/network.h  |4 +-
 plugins/ofono.c|4 +-
 src/connman.h  |   11 ++-
 src/ipconfig.c |  321 
 src/ipv4.c |2 +-
 src/network.c  |  146 +++-
 src/provider.c |   21 +++-
 src/service.c  |  314 +++
 9 files changed, 563 insertions(+), 263 deletions(-)

diff --git a/include/ipconfig.h b/include/ipconfig.h
index 28a3d6a..92110e0 100644
--- a/include/ipconfig.h
+++ b/include/ipconfig.h
@@ -74,7 +74,8 @@ struct connman_ipconfig_ops {
void (*ip_release) (struct connman_ipconfig *ipconfig);
 };
 
-struct connman_ipconfig *connman_ipconfig_create(int index);
+struct connman_ipconfig *connman_ipconfig_create(int index,
+   enum connman_ipconfig_type type);
 struct connman_ipconfig *connman_ipconfig_clone(struct connman_ipconfig 
*ipconfig);
 struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig 
*ipconfig);
 void connman_ipconfig_unref(struct connman_ipconfig *ipconfig);
diff --git a/include/network.h b/include/network.h
index f6ebc3a..0b538a4 100644
--- a/include/network.h
+++ b/include/network.h
@@ -89,7 +89,9 @@ connman_bool_t connman_network_get_connected(struct 
connman_network *network);
 
 connman_bool_t connman_network_get_associating(struct connman_network 
*network);
 
-void connman_network_set_method(struct connman_network *network,
+void connman_network_set_ipv4_method(struct connman_network *network,
+   enum connman_ipconfig_method method);
+void connman_network_set_ipv6_method(struct connman_network *network,
enum connman_ipconfig_method method);
 
 int connman_network_set_address(struct connman_network *network,
diff --git a/plugins/ofono.c b/plugins/ofono.c
index ee47406..1cb0961 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1497,7 +1497,7 @@ static void set_connected(struct connman_network *network,
return;
 
case CONNMAN_IPCONFIG_METHOD_FIXED:
-   connman_network_set_method(network, method);
+   connman_network_set_ipv4_method(network, method);
 
if (connected == FALSE)
cleanup_ipconfig(network);
@@ -1506,7 +1506,7 @@ static void set_connected(struct connman_network *network,
break;
 
case CONNMAN_IPCONFIG_METHOD_DHCP:
-   connman_network_set_method(network, method);
+   connman_network_set_ipv4_method(network, method);
 
connman_network_set_connected(network, connected);
break;
diff --git a/src/connman.h b/src/connman.h
index 9b8fcc7..03eda92 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -376,7 +376,8 @@ int __connman_network_disconnect(struct connman_network 
*network);
 int __connman_network_clear_ipconfig(struct connman_network *network,
struct connman_ipconfig *ipconfig);
 int __connman_network_set_ipconfig(struct connman_network *network,
-   struct connman_ipconfig *ipconfig);
+   struct connman_ipconfig *ipconfig_ipv4,
+   struct connman_ipconfig *ipconfig_ipv6);
 
 connman_bool_t __connman_network_has_driver(struct connman_network *network);
 
@@ -459,9 +460,13 @@ struct connman_service 
*__connman_service_create_from_provider(struct connman_pr
 void __connman_service_update_from_network(struct connman_network *network);
 void __connman_service_remove_from_network(struct connman_network *network);
 
-void __connman_service_create_ipconfig(struct connman_service *service,
+void __connman_service_create_ip4config(struct connman_service *service,
+   int index);
+void __connman_service_create_ip6config(struct connman_service *service,
int index);
-struct connman_ipconfig *__connman_service_get_ipconfig(
+struct connman_ipconfig *__connman_service_get_ip4config(
+   struct connman_service *service);
+struct connman_ipconfig *__connman_service_get_ip6config(
struct connman_service *service);
 const char *__connman_service_get_ident(struct connman_service *service);
 const char *__connman_service_get_path(struct connman_service *service);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index c6e33ec..a2a7bf2 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -50,8 +50,6 @@ struct connman_ipconfig {
enum connman_ipconfig_method method;
struct connman_ipaddress *address;
struct connman_ipaddress *system;
-
-   struct connman_ipconfig *ipv6;
 };
 
 struct 

[PATCH IPv6 v2 07/10] Return only a valid IPv6 configuration

2010-12-09 Thread Jukka Rissanen
---
 src/ipconfig.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index a2a7bf2..9ba8486 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1202,7 +1202,7 @@ void connman_ipconfig_set_ops(struct connman_ipconfig 
*ipconfig,
 struct connman_ipconfig *connman_ipconfig_get_ipv6config(
struct connman_ipconfig *ipconfig)
 {
-   if (ipconfig == NULL)
+   if (ipconfig == NULL || ipconfig-type != CONNMAN_IPCONFIG_TYPE_IPV6)
return NULL;
 
return ipconfig;
-- 
1.7.0.4

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


[PATCH IPv6 v2 08/10] Set the IPv6 gateway address only if using IPv6 config

2010-12-09 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 9ba8486..cf164c0 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1254,7 +1254,8 @@ void __connman_ipconfig_set_element_ipv6_gateway(
struct connman_ipconfig *ipconfig,
struct connman_element *element)
 {
-   element-ipv6.gateway = ipconfig-address-gateway;
+   if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV6)
+   element-ipv6.gateway = ipconfig-address-gateway;
 }
 
 /*
-- 
1.7.0.4

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


[PATCH IPv6 v2 09/10] Check that ipconfig is valid IPv4 config before returning data

2010-12-09 Thread Jukka Rissanen
---
 src/ipconfig.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index cf164c0..fef98cc 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1528,6 +1528,9 @@ void __connman_ipconfig_append_ipv4(struct 
connman_ipconfig *ipconfig,
 
DBG();
 
+   if (ipconfig-type != CONNMAN_IPCONFIG_TYPE_IPV4)
+   return;
+
str = __connman_ipconfig_method2string(ipconfig-method);
if (str == NULL)
return;
-- 
1.7.0.4

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


[PATCH IPv6 v2 10/10] Check that ipconfig is valid IPv6 config before returning data

2010-12-09 Thread Jukka Rissanen
---
 src/ipconfig.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index fef98cc..17ac5d3 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1567,6 +1567,9 @@ void __connman_ipconfig_append_ipv6(struct 
connman_ipconfig *ipconfig,
 
DBG();
 
+   if (ipconfig-type != CONNMAN_IPCONFIG_TYPE_IPV6)
+   return;
+
str = __connman_ipconfig_method2string(ipconfig-method);
if (str == NULL)
return;
-- 
1.7.0.4

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


[PATCH IPv6 v2 01/10] Make sure ipconfig is not null before accessing members

2010-12-09 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index a872dff..133db61 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -998,7 +998,8 @@ static void  free_ipv6config(struct connman_ipconfig 
*ipconfig)
  */
 void connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
 {
-   if (g_atomic_int_dec_and_test(ipconfig-refcount) == TRUE) {
+   if (ipconfig 
+   g_atomic_int_dec_and_test(ipconfig-refcount) == TRUE) {
__connman_ipconfig_disable(ipconfig);
 
connman_ipconfig_set_ops(ipconfig, NULL);
-- 
1.7.0.4

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


[PATCH autoconf 0/3] Add support for autoconfigured IPv6 addresses

2010-12-15 Thread Jukka Rissanen
Hi,

this patch set adds support for autoconfigured IPv6 addresses.
I introduced a new CONNMAN_IPCONFIG_METHOD_AUTOCONF method that is only
valid in IPv6 networks.

Please review.

Regards,

Jukka



Jukka Rissanen (3):
  ipv6: Added autoconf IP configuration method which is used in IPv6
networks
  ipv6: Add support for auto configured IPv6 addresses
  ipv6: Added description of IPv6 autoconf method

 doc/service-api.txt |5 -
 include/ipconfig.h  |   12 +++-
 plugins/ofono.c |1 +
 src/connman.h   |3 ++-
 src/ipconfig.c  |   51 ---
 src/network.c   |5 +
 src/rtnl.c  |   15 ---
 7 files changed, 75 insertions(+), 17 deletions(-)

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


[PATCH autoconf 1/3] ipv6: Added autoconf IP configuration method which is used in IPv6 networks

2010-12-15 Thread Jukka Rissanen
---
 include/ipconfig.h |   11 ++-
 plugins/ofono.c|1 +
 src/ipconfig.c |9 +
 src/network.c  |5 +
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/include/ipconfig.h b/include/ipconfig.h
index 01b8aaf..ed03081 100644
--- a/include/ipconfig.h
+++ b/include/ipconfig.h
@@ -56,11 +56,12 @@ enum connman_ipconfig_type {
 };
 
 enum connman_ipconfig_method {
-   CONNMAN_IPCONFIG_METHOD_UNKNOWN = 0,
-   CONNMAN_IPCONFIG_METHOD_OFF = 1,
-   CONNMAN_IPCONFIG_METHOD_FIXED   = 2,
-   CONNMAN_IPCONFIG_METHOD_MANUAL  = 3,
-   CONNMAN_IPCONFIG_METHOD_DHCP= 4,
+   CONNMAN_IPCONFIG_METHOD_UNKNOWN  = 0,
+   CONNMAN_IPCONFIG_METHOD_OFF  = 1,
+   CONNMAN_IPCONFIG_METHOD_FIXED= 2,
+   CONNMAN_IPCONFIG_METHOD_MANUAL   = 3,
+   CONNMAN_IPCONFIG_METHOD_DHCP = 4,
+   CONNMAN_IPCONFIG_METHOD_AUTOCONF = 5,
 };
 
 struct connman_ipconfig;
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 1cb0961..fc02508 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1494,6 +1494,7 @@ static void set_connected(struct connman_network *network,
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
return;
 
case CONNMAN_IPCONFIG_METHOD_FIXED:
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 3c0579d..3ba83d4 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1131,6 +1131,7 @@ int __connman_ipconfig_set_address(struct 
connman_ipconfig *ipconfig)
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_DHCP:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
break;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV4)
@@ -1158,6 +1159,7 @@ int __connman_ipconfig_clear_address(struct 
connman_ipconfig *ipconfig)
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_DHCP:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
break;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV4)
@@ -1339,6 +1341,8 @@ const char *__connman_ipconfig_method2string(enum 
connman_ipconfig_method method
return manual;
case CONNMAN_IPCONFIG_METHOD_DHCP:
return dhcp;
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
+   return autoconf;
}
 
return NULL;
@@ -1354,6 +1358,8 @@ enum connman_ipconfig_method 
__connman_ipconfig_string2method(const char *method
return CONNMAN_IPCONFIG_METHOD_MANUAL;
else if (g_strcmp0(method, dhcp) == 0)
return CONNMAN_IPCONFIG_METHOD_DHCP;
+   else if (g_strcmp0(method, autoconf) == 0)
+   return CONNMAN_IPCONFIG_METHOD_AUTOCONF;
else
return CONNMAN_IPCONFIG_METHOD_UNKNOWN;
 }
@@ -1449,6 +1455,7 @@ void __connman_ipconfig_append_ipv6config(struct 
connman_ipconfig *ipconfig,
return;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
break;
}
 
@@ -1486,6 +1493,7 @@ void __connman_ipconfig_append_ipv4config(struct 
connman_ipconfig *ipconfig,
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_DHCP:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
return;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
break;
@@ -1594,6 +1602,7 @@ int __connman_ipconfig_set_config(struct connman_ipconfig 
*ipconfig,
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
return -EINVAL;
 
case CONNMAN_IPCONFIG_METHOD_MANUAL:
diff --git a/src/network.c b/src/network.c
index 57d873a..8083c7b 100644
--- a/src/network.c
+++ b/src/network.c
@@ -760,6 +760,7 @@ static gboolean set_connected(gpointer user_data)
break;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
ret = manual_ipv6_set(network, ipconfig_ipv6);
if (ret != 0) {
connman_network_set_error(network,
@@ -774,6 +775,7 @@ static gboolean set_connected(gpointer user_data)
switch (ipv4_method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
+   case CONNMAN_IPCONFIG_METHOD_AUTOCONF:
return FALSE;
case 

[PATCH autoconf 3/3] ipv6: Added description of IPv6 autoconf method

2010-12-15 Thread Jukka Rissanen
---
 doc/service-api.txt |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/doc/service-api.txt b/doc/service-api.txt
index d309736..485c3de 100644
--- a/doc/service-api.txt
+++ b/doc/service-api.txt
@@ -365,12 +365,15 @@ Propertiesstring State [readonly]
string Method [readonly]
 
Possible values are dhcp, manual
-   and off.
+   autoconf and off.
 
The value fixed indicates an IP address
that can not be modified. For example
cellular networks return fixed information.
 
+   The value autoconf indicates an IP address
+   that is auto configured by the system.
+
dhcp is not supported currently.
 
string Address [readonly]
-- 
1.7.0.4

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


[PATCH autoconf 2/3] ipv6: Add support for auto configured IPv6 addresses

2010-12-15 Thread Jukka Rissanen
---
 include/ipconfig.h |1 +
 src/connman.h  |3 ++-
 src/ipconfig.c |   42 +++---
 src/rtnl.c |   15 ---
 4 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/include/ipconfig.h b/include/ipconfig.h
index ed03081..c80d9d6 100644
--- a/include/ipconfig.h
+++ b/include/ipconfig.h
@@ -39,6 +39,7 @@ struct connman_ipaddress {
char *peer;
char *broadcast;
char *gateway;
+   void *address; /* either in_addr or in6_addr */
 };
 
 struct connman_ipaddress *connman_ipaddress_alloc(int family);
diff --git a/src/connman.h b/src/connman.h
index 03eda92..03d8c51 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -210,7 +210,8 @@ void __connman_ipconfig_newlink(int index, unsigned short 
type,
struct rtnl_link_stats *stats);
 void __connman_ipconfig_dellink(int index, struct rtnl_link_stats *stats);
 void __connman_ipconfig_newaddr(int index, int family, const char *label,
-   unsigned char prefixlen, const char *address);
+   unsigned char prefixlen, const char *address,
+   void *ipaddress);
 void __connman_ipconfig_deladdr(int index, int family, const char *label,
unsigned char prefixlen, const char *address);
 void __connman_ipconfig_newroute(int index, int family, unsigned char scope,
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 3ba83d4..77911df 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -71,6 +71,7 @@ struct connman_ipdevice {
GSList *address_list;
char *ipv4_gateway;
char *ipv6_gateway;
+   struct connman_ipaddress *ipv6_ll;
 
char *pac;
 
@@ -95,6 +96,7 @@ struct connman_ipaddress *connman_ipaddress_alloc(int family)
ipaddress-peer = NULL;
ipaddress-broadcast = NULL;
ipaddress-gateway = NULL;
+   ipaddress-address = NULL;
 
return ipaddress;
 }
@@ -108,6 +110,7 @@ void connman_ipaddress_free(struct connman_ipaddress 
*ipaddress)
g_free(ipaddress-peer);
g_free(ipaddress-local);
g_free(ipaddress-gateway);
+   g_free(ipaddress-address);
g_free(ipaddress);
 }
 
@@ -315,6 +318,7 @@ static void free_ipdevice(gpointer data)
 
g_free(ipdevice-address);
g_free(ipdevice-ifname);
+   connman_ipaddress_free(ipdevice-ipv6_ll);
g_free(ipdevice);
 }
 
@@ -525,6 +529,21 @@ void __connman_ipconfig_dellink(int index, struct 
rtnl_link_stats *stats)
g_hash_table_remove(ipdevice_hash, GINT_TO_POINTER(index));
 }
 
+static inline gboolean is_autoconf_address(struct connman_ipaddress *ipaddress,
+   struct connman_ipaddress *linklocal_address)
+{
+   if (!linklocal_address)
+   return FALSE;
+
+   if (((__const uint32_t *)(linklocal_address-address))[2] ==
+   ((__const uint32_t *)(ipaddress-address))[2] 
+   ((__const uint32_t *)(linklocal_address-address))[3] ==
+   ((__const uint32_t *)(ipaddress-address))[3])
+   return TRUE;
+   else
+   return FALSE;
+}
+
 static inline gint check_duplicate_address(gconstpointer a, gconstpointer b)
 {
const struct connman_ipaddress *addr1 = a;
@@ -537,7 +556,8 @@ static inline gint check_duplicate_address(gconstpointer a, 
gconstpointer b)
 }
 
 void __connman_ipconfig_newaddr(int index, int family, const char *label,
-   unsigned char prefixlen, const char *address)
+   unsigned char prefixlen, const char *address,
+   void *in_address)
 {
struct connman_ipdevice *ipdevice;
struct connman_ipaddress *ipaddress;
@@ -555,6 +575,17 @@ void __connman_ipconfig_newaddr(int index, int family, 
const char *label,
 
ipaddress-prefixlen = prefixlen;
ipaddress-local = g_strdup(address);
+   ipaddress-address = in_address;
+
+   if (family == AF_INET6  IN6_IS_ADDR_LINKLOCAL(in_address)) {
+
+   DBG(ipv6 ll %s, address);
+   if (ipdevice-ipv6_ll)
+   connman_ipaddress_free(ipdevice-ipv6_ll);
+
+   ipdevice-ipv6_ll = ipaddress;
+   return;
+   }
 
if (g_slist_find_custom(ipdevice-address_list, ipaddress,
check_duplicate_address)) {
@@ -572,10 +603,15 @@ void __connman_ipconfig_newaddr(int index, int family, 
const char *label,
connman_ipaddress_copy(ipdevice-config_ipv4-system,
ipaddress);
 
-   else if (ipdevice-config_ipv6 != NULL  family == AF_INET6)
+   else if (ipdevice-config_ipv6 != NULL  family == AF_INET6) {
connman_ipaddress_copy(ipdevice-config_ipv6-system,
ipaddress);
-   else
+
+

[PATCH autoconf v2 1/8] ipconfig: Remove unnecessary null checks

2010-12-21 Thread Jukka Rissanen
---
 src/network.c |   11 ++-
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/network.c b/src/network.c
index 57d873a..1bc5a6c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -738,15 +738,8 @@ static gboolean set_connected(gpointer user_data)
DBG(service %p ipv4 %p ipv6 %p, service, ipconfig_ipv4,
ipconfig_ipv6);
 
-   if (ipconfig_ipv4)
-   ipv4_method = __connman_ipconfig_get_method(ipconfig_ipv4);
-   else
-   ipv4_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
-
-   if (ipconfig_ipv6)
-   ipv6_method = __connman_ipconfig_get_method(ipconfig_ipv6);
-   else
-   ipv6_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   ipv4_method = __connman_ipconfig_get_method(ipconfig_ipv4);
+   ipv6_method = __connman_ipconfig_get_method(ipconfig_ipv6);
 
DBG(method ipv4 %d ipv6 %d, ipv4_method, ipv6_method);
DBG(network connected %d, network-connected);
-- 
1.7.0.4

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


[PATCH autoconf v2 2/8] ipconfig: Added auto method that is used for IPv6 auto configured addresses

2010-12-21 Thread Jukka Rissanen
---
 include/ipconfig.h |1 +
 plugins/ofono.c|1 +
 src/ipconfig.c |9 +
 src/network.c  |5 +
 4 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/ipconfig.h b/include/ipconfig.h
index e8f6de1..9bc97d5 100644
--- a/include/ipconfig.h
+++ b/include/ipconfig.h
@@ -61,6 +61,7 @@ enum connman_ipconfig_method {
CONNMAN_IPCONFIG_METHOD_FIXED   = 2,
CONNMAN_IPCONFIG_METHOD_MANUAL  = 3,
CONNMAN_IPCONFIG_METHOD_DHCP= 4,
+   CONNMAN_IPCONFIG_METHOD_AUTO= 5,
 };
 
 struct connman_ipconfig;
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 0a13b7b..9385f39 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1511,6 +1511,7 @@ static void set_connected(struct connman_network *network,
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
return;
 
case CONNMAN_IPCONFIG_METHOD_FIXED:
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 90b4f16..6ab7025 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1108,6 +1108,7 @@ int __connman_ipconfig_set_address(struct 
connman_ipconfig *ipconfig)
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_DHCP:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
break;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV4)
@@ -1135,6 +1136,7 @@ int __connman_ipconfig_clear_address(struct 
connman_ipconfig *ipconfig)
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_DHCP:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
break;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV4)
@@ -1316,6 +1318,8 @@ const char *__connman_ipconfig_method2string(enum 
connman_ipconfig_method method
return manual;
case CONNMAN_IPCONFIG_METHOD_DHCP:
return dhcp;
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
+   return auto;
}
 
return NULL;
@@ -1331,6 +1335,8 @@ enum connman_ipconfig_method 
__connman_ipconfig_string2method(const char *method
return CONNMAN_IPCONFIG_METHOD_MANUAL;
else if (g_strcmp0(method, dhcp) == 0)
return CONNMAN_IPCONFIG_METHOD_DHCP;
+   else if (g_strcmp0(method, auto) == 0)
+   return CONNMAN_IPCONFIG_METHOD_AUTO;
else
return CONNMAN_IPCONFIG_METHOD_UNKNOWN;
 }
@@ -1426,6 +1432,7 @@ void __connman_ipconfig_append_ipv6config(struct 
connman_ipconfig *ipconfig,
return;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
break;
}
 
@@ -1463,6 +1470,7 @@ void __connman_ipconfig_append_ipv4config(struct 
connman_ipconfig *ipconfig,
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_DHCP:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
return;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
break;
@@ -1571,6 +1579,7 @@ int __connman_ipconfig_set_config(struct connman_ipconfig 
*ipconfig,
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
return -EINVAL;
 
case CONNMAN_IPCONFIG_METHOD_MANUAL:
diff --git a/src/network.c b/src/network.c
index 1bc5a6c..73b1a45 100644
--- a/src/network.c
+++ b/src/network.c
@@ -750,6 +750,7 @@ static gboolean set_connected(gpointer user_data)
switch (ipv6_method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
break;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
@@ -767,6 +768,7 @@ static gboolean set_connected(gpointer user_data)
switch (ipv4_method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
return FALSE;
case CONNMAN_IPCONFIG_METHOD_FIXED:
if (set_connected_fixed(network)  0) {
@@ -1019,6 +1021,7 @@ int __connman_network_clear_ipconfig(struct 
connman_network *network,
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
return -EINVAL;
case CONNMAN_IPCONFIG_METHOD_MANUAL:

[PATCH autoconf v2 4/8] ipv6: Test script for setting IPv6 Method

2010-12-21 Thread Jukka Rissanen
---
 test/set-ipv6-method |   33 +
 1 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100755 test/set-ipv6-method

diff --git a/test/set-ipv6-method b/test/set-ipv6-method
new file mode 100755
index 000..569e887
--- /dev/null
+++ b/test/set-ipv6-method
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+def print_usage():
+   print Usage: %s service off|manual|auto [address [netmask]] % 
(sys.argv[0])
+
+if (len(sys.argv)  3):
+   print_usage()
+   sys.exit(1)
+
+bus = dbus.SystemBus()
+path = /profile/default/ + sys.argv[1]
+service = dbus.Interface(bus.get_object('net.connman', path),
+   'net.connman.Service')
+
+properties = service.GetProperties()
+
+print Setting method %s for %s % (sys.argv[2], sys.argv[1])
+
+ipv6_configuration = { Method: sys.argv[2] }
+if (len(sys.argv)  3):
+   ipv6_configuration[Address] = sys.argv[3]
+if (len(sys.argv)  4):
+   ipv6_configuration[Netmask] = sys.argv[4]
+if (len(sys.argv)  5):
+   ipv6_configuration[Gateway] = sys.argv[5]
+
+service.SetProperty(IPv6.Configuration, ipv6_configuration)
+print New IPv6.Configuration: , ipv6_configuration
+
+print
-- 
1.7.0.4

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


[PATCH autoconf v2 0/8] IPv6 auto configuration

2010-12-21 Thread Jukka Rissanen
Hi all,

following patches add new AUTO ipconfig method type. It is only used
in IPv6 ipconfig. The default method for IPv6 config will be AUTO.
If user sets the IPv6 ipconfig method to OFF, then IPv6 is disabled
for that interface. Setting IPv6 ipconfig method back to AUTO will
enable IPv6 for that interface.

Regards,

Jukka



Jukka Rissanen (8):
  ipconfig: Remove unnecessary null checks
  ipconfig: Added auto method that is used for IPv6 auto configured
addresses
  ipconfig: Default method is auto for IPv6
  ipv6: Test script for setting IPv6 Method
  ipv6: Do not set the method as it is set when ipconfig is created
  ipv6: Clear the IPv6 address if that address is removed from system
  ipv6: Allow user to disable or enable IPv6 at will
  ipv6: Do not disconnect IPv4 if IPv6 method changes

 include/ipconfig.h   |1 +
 plugins/ofono.c  |1 +
 src/ipconfig.c   |  117 +-
 src/network.c|   16 +++
 src/service.c|   49 +++--
 test/set-ipv6-method |   33 ++
 6 files changed, 183 insertions(+), 34 deletions(-)
 create mode 100755 test/set-ipv6-method

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


[PATCH autoconf v2 3/8] ipconfig: Default method is auto for IPv6

2010-12-21 Thread Jukka Rissanen
---
 src/ipconfig.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 6ab7025..7a53689 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -852,7 +852,7 @@ static struct connman_ipconfig *create_ipv6config(int index)
 
ipv6config-index = index;
ipv6config-type = CONNMAN_IPCONFIG_TYPE_IPV6;
-   ipv6config-method = CONNMAN_IPCONFIG_METHOD_OFF;
+   ipv6config-method = CONNMAN_IPCONFIG_METHOD_AUTO;
 
ipv6config-address = connman_ipaddress_alloc(AF_INET6);
if (ipv6config-address == NULL) {
-- 
1.7.0.4

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


[PATCH autoconf v2 5/8] ipv6: Do not set the method as it is set when ipconfig is created

2010-12-21 Thread Jukka Rissanen
---
 src/service.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/service.c b/src/service.c
index 6ca80cd..14de1d0 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3818,9 +3818,6 @@ static void setup_ip6config(struct connman_service 
*service, int index)
if (service-ipconfig_ipv6 == NULL)
return;
 
-   connman_ipconfig_set_method(service-ipconfig_ipv6,
-   CONNMAN_IPCONFIG_METHOD_OFF);
-
connman_ipconfig_set_data(service-ipconfig_ipv6, service);
 
connman_ipconfig_set_ops(service-ipconfig_ipv6, service_ops);
-- 
1.7.0.4

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


[PATCH autoconf v2 6/8] ipv6: Clear the IPv6 address if that address is removed from system

2010-12-21 Thread Jukka Rissanen
---
 src/ipconfig.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 7a53689..6196a03 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -616,6 +616,14 @@ void __connman_ipconfig_deladdr(int index, int family, 
const char *label,
ipdevice-address_list = g_slist_remove(ipdevice-address_list,
ipaddress);
 
+   if (family == AF_INET6  ipdevice-config_ipv6-system 
+   ipdevice-config_ipv6-system-prefixlen ==
+   ipaddress-prefixlen 
+   g_strcmp0(ipdevice-config_ipv6-system-local,
+   ipaddress-local) == 0) {
+   connman_ipaddress_clear(ipdevice-config_ipv6-system);
+   }
+
connman_ipaddress_free(ipaddress);
 
connman_info(%s {del} address %s/%u label %s, ipdevice-ifname,
-- 
1.7.0.4

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


[PATCH autoconf v2 8/8] ipv6: Do not disconnect IPv4 if IPv6 method changes

2010-12-21 Thread Jukka Rissanen
---
 src/service.c |   46 ++
 1 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/src/service.c b/src/service.c
index 14de1d0..994eaa6 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2039,6 +2039,7 @@ static DBusMessage *set_property(DBusConnection *conn,
g_str_equal(name, IPv6.Configuration)) {
 
enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
+   struct connman_ipconfig *ipv4 = NULL, *ipv6 = NULL;
int err = 0;
 
DBG(%s, name);
@@ -2047,31 +2048,37 @@ static DBusMessage *set_property(DBusConnection *conn,
service-ipconfig_ipv6 == NULL)
return __connman_error_invalid_property(msg);
 
-   if (is_connecting(service) ||
-   is_connected(service)) {
-   __connman_network_clear_ipconfig(service-network,
-   service-ipconfig_ipv4);
-   __connman_network_clear_ipconfig(service-network,
-   service-ipconfig_ipv6);
-   }
-
if (g_str_equal(name, IPv4.Configuration) == TRUE) {
+
+   if (is_connecting(service) || is_connected(service))
+   __connman_network_clear_ipconfig(
+   service-network,
+   service-ipconfig_ipv4);
+
+   ipv4 = service-ipconfig_ipv4;
type = CONNMAN_IPCONFIG_TYPE_IPV4;
-   err = __connman_ipconfig_set_config(
-   service-ipconfig_ipv4, type, value);
+   err = __connman_ipconfig_set_config(ipv4, type,
+   value);
+
} else if (g_str_equal(name, IPv6.Configuration) == TRUE) {
+
+   if (is_connecting(service) || is_connected(service))
+   __connman_network_clear_ipconfig(
+   service-network,
+   service-ipconfig_ipv6);
+
+   ipv6 = service-ipconfig_ipv6;
type = CONNMAN_IPCONFIG_TYPE_IPV6;
-   err = __connman_ipconfig_set_config(
-   service-ipconfig_ipv6, type, value);
+   err = __connman_ipconfig_set_config(ipv6, type,
+   value);
}
 
if (err  0) {
-   if (is_connected(service) ||
-   is_connecting(service))
+   if (is_connected(service) || is_connecting(service))
__connman_network_set_ipconfig(
service-network,
-   service-ipconfig_ipv4,
-   service-ipconfig_ipv6);
+   ipv4,
+   ipv6);
return __connman_error_failed(msg, -err);
}
 
@@ -2080,11 +2087,10 @@ static DBusMessage *set_property(DBusConnection *conn,
else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
ipv6_configuration_changed(service);
 
-   if (is_connecting(service) ||
-   is_connected(service))
+   if (is_connecting(service) || is_connected(service))
__connman_network_set_ipconfig(service-network,
-   service-ipconfig_ipv4,
-   service-ipconfig_ipv6);
+   ipv4,
+   ipv6);
 
__connman_storage_save_service(service);
} else
-- 
1.7.0.4

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


[PATCH memleak 02/10] memoryleak: SSID was not freed

2010-12-22 Thread Jukka Rissanen
---
 plugins/supplicant.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/plugins/supplicant.c b/plugins/supplicant.c
index 5f2d204..df181d8 100644
--- a/plugins/supplicant.c
+++ b/plugins/supplicant.c
@@ -635,8 +635,12 @@ static void add_interface_reply(DBusPendingCall *call, 
void *user_data)
ssid[k++] = hex;
}
 
-   if (add_hidden_network(task, ssid, hex_ssid_len / 2)  0)
+   if (add_hidden_network(task, ssid, hex_ssid_len / 2)  0) {
+   g_free(ssid);
break;
+   }
+
+   g_free(ssid);
}
 
g_strfreev(hex_ssids);
-- 
1.7.0.4

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


[PATCH memleak 01/10] memoryleak: network interface string was not freed

2010-12-22 Thread Jukka Rissanen
---
 plugins/portal.c |   18 --
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/plugins/portal.c b/plugins/portal.c
index d4456f5..cad2998 100644
--- a/plugins/portal.c
+++ b/plugins/portal.c
@@ -105,7 +105,7 @@ static int location_detect(struct connman_location 
*location)
 {
struct server_data *data;
enum connman_service_type service_type;
-   const char *interface;
+   char *interface;
int err;
 
DBG(location %p, location);
@@ -134,15 +134,18 @@ static int location_detect(struct connman_location 
*location)
DBG(interface %s, interface);
 
data = g_try_new0(struct server_data, 1);
-   if (data == NULL)
-   return -ENOMEM;
+   if (data == NULL) {
+   err = -ENOMEM;
+   goto done;
+   }
 
connman_location_set_data(location, data);
 
data-web = g_web_new(0);
if (data-web == NULL) {
g_free(data);
-   return -ENOMEM;
+   err = -ENOMEM;
+   goto done;
}
 
if (getenv(CONNMAN_WEB_DEBUG))
@@ -155,11 +158,14 @@ static int location_detect(struct connman_location 
*location)
err = connman_proxy_lookup(interface, STATUS_URL,
proxy_callback, location);
if (err  0)
-   return err;
+   goto done;
 
connman_location_ref(location);
+   err = 0;
 
-   return 0;
+done:
+   g_free(interface);
+   return err;
 }
 
 static int location_finish(struct connman_location *location)
-- 
1.7.0.4

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


[PATCH memleak 09/10] Possible memory leak when creating ipconfig

2010-12-22 Thread Jukka Rissanen
---
 src/service.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/service.c b/src/service.c
index c6d3d36..2e5974f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4324,7 +4324,8 @@ __connman_service_create_from_provider(struct 
connman_provider *provider)
 
service-strength = 0;
 
-   service-ipconfig_ipv4 = connman_ipconfig_create(index,
+   if (service-ipconfig_ipv4 == NULL)
+   service-ipconfig_ipv4 = connman_ipconfig_create(index,
CONNMAN_IPCONFIG_TYPE_IPV4);
if (service-ipconfig_ipv4 == NULL)
return service;
@@ -4334,7 +4335,8 @@ __connman_service_create_from_provider(struct 
connman_provider *provider)
connman_ipconfig_set_data(service-ipconfig_ipv4, service);
connman_ipconfig_set_ops(service-ipconfig_ipv4, service_ops);
 
-   service-ipconfig_ipv6 = connman_ipconfig_create(index,
+   if (service-ipconfig_ipv6 == NULL)
+   service-ipconfig_ipv6 = connman_ipconfig_create(index,
CONNMAN_IPCONFIG_TYPE_IPV6);
if (service-ipconfig_ipv6 == NULL)
return service;
-- 
1.7.0.4

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


[PATCH memleak 06/10] memoryleak: method was not freed

2010-12-22 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 3e6f738..db350d3 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1742,7 +1742,7 @@ void __connman_ipconfig_append_ethernet(struct 
connman_ipconfig *ipconfig,
 int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix)
 {
-   const char *method;
+   char *method;
char *key;
 
DBG(ipconfig %p identifier %s, ipconfig, identifier);
@@ -1760,6 +1760,7 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
ipconfig-method = CONNMAN_IPCONFIG_METHOD_OFF;
 
+   g_free(method);
g_free(key);
 
key = g_strdup_printf(%snetmask_prefixlen, prefix);
-- 
1.7.0.4

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


[PATCH memleak v2 1/4] memoryleak: remove the element for real

2010-12-22 Thread Jukka Rissanen
---
 src/connection.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index bac700f..1a386ae 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -405,6 +405,8 @@ static void connection_remove(struct connman_element 
*element)
if (data != NULL)
set_default_gateway(data);
}
+
+   connman_element_unref(element);
 }
 
 static struct connman_driver connection_driver = {
-- 
1.7.0.4

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


[PATCH memleak v2 2/4] memoryleak: dhcp_client is already referenced when created

2010-12-22 Thread Jukka Rissanen
---
 plugins/dhcp.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/plugins/dhcp.c b/plugins/dhcp.c
index e3d1957..aaac96d 100644
--- a/plugins/dhcp.c
+++ b/plugins/dhcp.c
@@ -154,8 +154,6 @@ static int dhcp_request(struct connman_dhcp *dhcp)
 
connman_dhcp_set_data(dhcp, dhcp_client);
 
-   g_dhcp_client_ref(dhcp_client);
-
return g_dhcp_client_start(dhcp_client);
 }
 
-- 
1.7.0.4

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


[PATCH memleak v2 0/4] More memory leaks

2010-12-22 Thread Jukka Rissanen
Hi again,

more memory leaks, these were a bit trickier to find.

Regards,
Jukka


Jukka Rissanen (4):
  memoryleak: remove the element for real
  memoryleak: dhcp_client is already referenced when created
  memoryleak: remove the element when not needed
  memoryleak: remove element when not needed any more

 plugins/dhcp.c   |2 --
 src/connection.c |2 ++
 src/dhcp.c   |1 +
 src/ipv4.c   |2 ++
 4 files changed, 5 insertions(+), 2 deletions(-)

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


[PATCH memleak resend 05/15] memoryleak: block was not freed

2010-12-31 Thread Jukka Rissanen
---
 plugins/supplicant.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/plugins/supplicant.c b/plugins/supplicant.c
index df181d8..6e29911 100644
--- a/plugins/supplicant.c
+++ b/plugins/supplicant.c
@@ -224,6 +224,7 @@ static void remove_block(gpointer user_data)
 
g_free(block-ssid);
g_free(block-netpath);
+   g_free(block);
 }
 
 static struct supplicant_task *find_task_by_index(int index)
-- 
1.7.0.4

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


[PATCH memleak resend 06/15] memoryleak: method was not freed

2010-12-31 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 57e3218..690b51e 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1634,7 +1634,7 @@ void __connman_ipconfig_append_ethernet(struct 
connman_ipconfig *ipconfig,
 int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix)
 {
-   const char *method;
+   char *method;
char *key;
 
DBG(ipconfig %p identifier %s, ipconfig, identifier);
@@ -1652,6 +1652,7 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
ipconfig-method = CONNMAN_IPCONFIG_METHOD_OFF;
 
+   g_free(method);
g_free(key);
 
key = g_strdup_printf(%snetmask_prefixlen, prefix);
-- 
1.7.0.4

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



[PATCH memleak resend 04/15] memoryleak: address was not freed

2010-12-31 Thread Jukka Rissanen
---
 plugins/dhcp.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/plugins/dhcp.c b/plugins/dhcp.c
index 07fed38..5fe99d7 100644
--- a/plugins/dhcp.c
+++ b/plugins/dhcp.c
@@ -76,6 +76,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
address = g_dhcp_client_get_address(dhcp_client);
if (address != NULL)
connman_dhcp_set_value(dhcp, Address, address);
+   g_free(address);
 
option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET);
if (option != NULL)
-- 
1.7.0.4

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


[PATCH memleak resend 12/15] memoryleak: dhcp_client is already referenced when created

2010-12-31 Thread Jukka Rissanen
---
 plugins/dhcp.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/plugins/dhcp.c b/plugins/dhcp.c
index 5fe99d7..54306ed 100644
--- a/plugins/dhcp.c
+++ b/plugins/dhcp.c
@@ -191,8 +191,6 @@ static int dhcp_request(struct connman_dhcp *dhcp)
 
connman_dhcp_set_data(dhcp, dhcp_client);
 
-   g_dhcp_client_ref(dhcp_client);
-
return g_dhcp_client_start(dhcp_client);
 }
 
-- 
1.7.0.4

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


[PATCH memleak resend 15/15] memoryleak: root element was not freed

2010-12-31 Thread Jukka Rissanen
---
 src/element.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/element.c b/src/element.c
index a4230b7..1dcc695 100644
--- a/src/element.c
+++ b/src/element.c
@@ -1463,6 +1463,8 @@ void __connman_element_cleanup(void)
g_node_traverse(element_root, G_POST_ORDER, G_TRAVERSE_ALL, -1,
free_node, NULL);
 
+   connman_element_unref(element_root-data);
+
g_node_destroy(element_root);
element_root = NULL;
 
-- 
1.7.0.4

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


[PATCH memleak resend v2 1/2] memoryleak: check return value correctly before clearing pointer

2011-01-03 Thread Jukka Rissanen
---
 src/service.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/service.c b/src/service.c
index 61e065b..e58c08f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3406,10 +3406,10 @@ int __connman_service_disconnect(struct connman_service 
*service)
__connman_ipconfig_clear_address(service-ipconfig_ipv4);
__connman_ipconfig_clear_address(service-ipconfig_ipv6);
 
-   if (!__connman_ipconfig_disable(service-ipconfig_ipv4))
+   if (__connman_ipconfig_disable(service-ipconfig_ipv4) == 0)
service-ipconfig_ipv4 = NULL;
 
-   if (!__connman_ipconfig_disable(service-ipconfig_ipv6))
+   if (__connman_ipconfig_disable(service-ipconfig_ipv6) == 0)
service-ipconfig_ipv6 = NULL;
 
__connman_stats_service_unregister(service);
-- 
1.7.0.4

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


[PATCH memleak resend v3 2/2] Make calls to __connman_ipconfig_disable() consistent.

2011-01-03 Thread Jukka Rissanen
---
 src/service.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index 18b0340..09cc4eb 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2233,11 +2233,11 @@ static gboolean connect_timeout(gpointer user_data)
__connman_network_disconnect(service-network);
 
if (service-ipconfig_ipv4)
-   if (!__connman_ipconfig_disable(service-ipconfig_ipv4))
+   if (__connman_ipconfig_disable(service-ipconfig_ipv4) == 0)
service-ipconfig_ipv4 = NULL;
 
if (service-ipconfig_ipv6)
-   if (!__connman_ipconfig_disable(service-ipconfig_ipv6))
+   if (__connman_ipconfig_disable(service-ipconfig_ipv6) == 0)
service-ipconfig_ipv6 = NULL;
 
__connman_stats_service_unregister(service);
@@ -3352,13 +3352,13 @@ int __connman_service_connect(struct connman_service 
*service)
if (err  0) {
if (err != -EINPROGRESS) {
if (service-ipconfig_ipv4)
-   if (!__connman_ipconfig_disable(
-   service-ipconfig_ipv4))
+   if (__connman_ipconfig_disable(
+   service-ipconfig_ipv4) == 0)
service-ipconfig_ipv4 = NULL;
 
if (service-ipconfig_ipv6)
-   if (!__connman_ipconfig_disable(
-   service-ipconfig_ipv6))
+   if (__connman_ipconfig_disable(
+   service-ipconfig_ipv6) == 0)
service-ipconfig_ipv6 = NULL;
 
__connman_stats_service_unregister(service);
-- 
1.7.0.4

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


[PATCH memleak service 0/3] Memory leak fixes in service

2011-01-05 Thread Jukka Rissanen
Hi again,

while doing IPv6 work I found some more memory leak problems.

The patch 1 is optional as it just adds some more debug output
in ipconfig ref/unref functions but I needed it to find the
problem described in second patch.

The patch 2 fixes reference counting issue in service.c file.
The IPv4 and IPv6 ipconfig structs are created in service.c and
the reference count is set to 1 at the beginning. The service.c
also calls __connman_ipconfig_enable() which increments ref count
to 2. At some point the __connman_ipconfig_disable() is called which
then decrements the ref count to 1 and then incorrectly clears ipconfig.
The patch unrefs the ipconfig correctly before setting ipconfig to NULL.

The patch 3 frees the IPv6 gateway address as it was never done.


Regards,

Jukka


Jukka Rissanen (3):
  ipconfig: add debugging to ref counting functions
  memoryleak: ipconfig was not unreferenced properly
  memoryleak: IPv6 gateway was not freed

 src/connection.c |1 +
 src/ipconfig.c   |   12 ++--
 src/service.c|   34 ++
 3 files changed, 33 insertions(+), 14 deletions(-)

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


[PATCH memleak service 1/3] ipconfig: add debugging to ref counting functions

2011-01-05 Thread Jukka Rissanen
---
 src/ipconfig.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 690b51e..b5dc98f 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -915,6 +915,9 @@ struct connman_ipconfig *connman_ipconfig_create(int index,
  */
 struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig 
*ipconfig)
 {
+   DBG(ipconfig %p refcount %d, ipconfig,
+   g_atomic_int_get(ipconfig-refcount) + 1);
+
g_atomic_int_inc(ipconfig-refcount);
 
return ipconfig;
@@ -928,8 +931,13 @@ struct connman_ipconfig *connman_ipconfig_ref(struct 
connman_ipconfig *ipconfig)
  */
 void connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
 {
-   if (ipconfig 
-   g_atomic_int_dec_and_test(ipconfig-refcount) == TRUE) {
+   if (ipconfig == NULL)
+   return;
+
+   DBG(ipconfig %p refcount %d, ipconfig,
+   g_atomic_int_get(ipconfig-refcount) - 1);
+
+   if (g_atomic_int_dec_and_test(ipconfig-refcount) == TRUE) {
__connman_ipconfig_disable(ipconfig);
 
connman_ipconfig_set_ops(ipconfig, NULL);
-- 
1.7.0.4

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


[PATCH memleak service 2/3] memoryleak: ipconfig was not unreferenced properly

2011-01-05 Thread Jukka Rissanen
The service creates ipconfig and then enables it which means that
ref count goes to 2. At some point it then disables ipconfig but
does not do unref which means there is a memory leak as ref count
never goes to 0.
---
 src/service.c |   40 
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/service.c b/src/service.c
index 09cc4eb..0002609 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2232,13 +2232,15 @@ static gboolean connect_timeout(gpointer user_data)
if (service-network != NULL)
__connman_network_disconnect(service-network);
 
-   if (service-ipconfig_ipv4)
-   if (__connman_ipconfig_disable(service-ipconfig_ipv4) == 0)
-   service-ipconfig_ipv4 = NULL;
+   if (__connman_ipconfig_disable(service-ipconfig_ipv4) == 0) {
+   connman_ipconfig_unref(service-ipconfig_ipv4);
+   service-ipconfig_ipv4 = NULL;
+   }
 
-   if (service-ipconfig_ipv6)
-   if (__connman_ipconfig_disable(service-ipconfig_ipv6) == 0)
-   service-ipconfig_ipv6 = NULL;
+   if (__connman_ipconfig_disable(service-ipconfig_ipv6) == 0) {
+   connman_ipconfig_unref(service-ipconfig_ipv6);
+   service-ipconfig_ipv6 = NULL;
+   }
 
__connman_stats_service_unregister(service);
 
@@ -3351,15 +3353,17 @@ int __connman_service_connect(struct connman_service 
*service)
 
if (err  0) {
if (err != -EINPROGRESS) {
-   if (service-ipconfig_ipv4)
-   if (__connman_ipconfig_disable(
-   service-ipconfig_ipv4) == 0)
-   service-ipconfig_ipv4 = NULL;
+   if (__connman_ipconfig_disable(
+   service-ipconfig_ipv4) == 0) {
+   connman_ipconfig_unref(service-ipconfig_ipv4);
+   service-ipconfig_ipv4 = NULL;
+   }
 
-   if (service-ipconfig_ipv6)
-   if (__connman_ipconfig_disable(
-   service-ipconfig_ipv6) == 0)
-   service-ipconfig_ipv6 = NULL;
+   if (__connman_ipconfig_disable(
+   service-ipconfig_ipv6) == 0) {
+   connman_ipconfig_unref(service-ipconfig_ipv6);
+   service-ipconfig_ipv6 = NULL;
+   }
 
__connman_stats_service_unregister(service);
if (service-userconnect == TRUE)
@@ -3406,11 +3410,15 @@ int __connman_service_disconnect(struct connman_service 
*service)
__connman_ipconfig_clear_address(service-ipconfig_ipv4);
__connman_ipconfig_clear_address(service-ipconfig_ipv6);
 
-   if (__connman_ipconfig_disable(service-ipconfig_ipv4) == 0)
+   if (__connman_ipconfig_disable(service-ipconfig_ipv4) == 0) {
+   connman_ipconfig_unref(service-ipconfig_ipv4);
service-ipconfig_ipv4 = NULL;
+   }
 
-   if (__connman_ipconfig_disable(service-ipconfig_ipv6) == 0)
+   if (__connman_ipconfig_disable(service-ipconfig_ipv6) == 0) {
+   connman_ipconfig_unref(service-ipconfig_ipv6);
service-ipconfig_ipv6 = NULL;
+   }
 
__connman_stats_service_unregister(service);
 
-- 
1.7.0.4

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


[PATCH memleak service 3/3] memoryleak: IPv6 gateway was not freed

2011-01-05 Thread Jukka Rissanen
---
 src/connection.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index bfd19b5..789a242 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -221,6 +221,7 @@ static int remove_gateway(struct gateway_data *data)
err = 0;
 
g_free(data-ipv4_gateway);
+   g_free(data-ipv6_gateway);
g_free(data-vpn_ip);
g_free(data);
 
-- 
1.7.0.4

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


[PATCH autoconf v3 01/12] ipconfig: Remove unnecessary null checks.

2011-01-07 Thread Jukka Rissanen
---
 src/network.c |   11 ++-
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/network.c b/src/network.c
index 3130f7c..18e3099 100644
--- a/src/network.c
+++ b/src/network.c
@@ -745,15 +745,8 @@ static gboolean set_connected(gpointer user_data)
DBG(service %p ipv4 %p ipv6 %p, service, ipconfig_ipv4,
ipconfig_ipv6);
 
-   if (ipconfig_ipv4)
-   ipv4_method = __connman_ipconfig_get_method(ipconfig_ipv4);
-   else
-   ipv4_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
-
-   if (ipconfig_ipv6)
-   ipv6_method = __connman_ipconfig_get_method(ipconfig_ipv6);
-   else
-   ipv6_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   ipv4_method = __connman_ipconfig_get_method(ipconfig_ipv4);
+   ipv6_method = __connman_ipconfig_get_method(ipconfig_ipv6);
 
DBG(method ipv4 %d ipv6 %d, ipv4_method, ipv6_method);
DBG(network connected %d, network-connected);
-- 
1.7.0.4

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


[PATCH autoconf v3 03/12] ipconfig: Default method is auto for IPv6

2011-01-07 Thread Jukka Rissanen
---
 src/ipconfig.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 3610d46..7a14c42 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -852,7 +852,7 @@ static struct connman_ipconfig *create_ipv6config(int index)
 
ipv6config-index = index;
ipv6config-type = CONNMAN_IPCONFIG_TYPE_IPV6;
-   ipv6config-method = CONNMAN_IPCONFIG_METHOD_OFF;
+   ipv6config-method = CONNMAN_IPCONFIG_METHOD_AUTO;
 
ipv6config-address = connman_ipaddress_alloc(AF_INET6);
if (ipv6config-address == NULL) {
-- 
1.7.0.4

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


[PATCH autoconf v3 05/12] ipv6: Do not set the method as it is set when ipconfig is created

2011-01-07 Thread Jukka Rissanen
---
 src/service.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/service.c b/src/service.c
index 0002609..9338ca1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3830,9 +3830,6 @@ static void setup_ip6config(struct connman_service 
*service, int index)
if (service-ipconfig_ipv6 == NULL)
return;
 
-   connman_ipconfig_set_method(service-ipconfig_ipv6,
-   CONNMAN_IPCONFIG_METHOD_OFF);
-
connman_ipconfig_set_data(service-ipconfig_ipv6, service);
 
connman_ipconfig_set_ops(service-ipconfig_ipv6, service_ops);
-- 
1.7.0.4

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


[PATCH autoconf v3 06/12] ipv6: Clear the IPv6 address if that address is removed from system

2011-01-07 Thread Jukka Rissanen
---
 src/ipconfig.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 7a14c42..2c0ede6 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -616,6 +616,15 @@ void __connman_ipconfig_deladdr(int index, int family, 
const char *label,
ipdevice-address_list = g_slist_remove(ipdevice-address_list,
ipaddress);
 
+   if (family == AF_INET6  ipdevice-config_ipv6 
+   ipdevice-config_ipv6-system 
+   ipdevice-config_ipv6-system-prefixlen ==
+   ipaddress-prefixlen 
+   g_strcmp0(ipdevice-config_ipv6-system-local,
+   ipaddress-local) == 0) {
+   connman_ipaddress_clear(ipdevice-config_ipv6-system);
+   }
+
connman_ipaddress_free(ipaddress);
 
connman_info(%s {del} address %s/%u label %s, ipdevice-ifname,
-- 
1.7.0.4

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


[PATCH autoconf v3 04/12] ipv6: Test script for setting IPv6 Method

2011-01-07 Thread Jukka Rissanen
---
 test/set-ipv6-method |   33 +
 1 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100755 test/set-ipv6-method

diff --git a/test/set-ipv6-method b/test/set-ipv6-method
new file mode 100755
index 000..569e887
--- /dev/null
+++ b/test/set-ipv6-method
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+def print_usage():
+   print Usage: %s service off|manual|auto [address [netmask]] % 
(sys.argv[0])
+
+if (len(sys.argv)  3):
+   print_usage()
+   sys.exit(1)
+
+bus = dbus.SystemBus()
+path = /profile/default/ + sys.argv[1]
+service = dbus.Interface(bus.get_object('net.connman', path),
+   'net.connman.Service')
+
+properties = service.GetProperties()
+
+print Setting method %s for %s % (sys.argv[2], sys.argv[1])
+
+ipv6_configuration = { Method: sys.argv[2] }
+if (len(sys.argv)  3):
+   ipv6_configuration[Address] = sys.argv[3]
+if (len(sys.argv)  4):
+   ipv6_configuration[Netmask] = sys.argv[4]
+if (len(sys.argv)  5):
+   ipv6_configuration[Gateway] = sys.argv[5]
+
+service.SetProperty(IPv6.Configuration, ipv6_configuration)
+print New IPv6.Configuration: , ipv6_configuration
+
+print
-- 
1.7.0.4

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


[PATCH autoconf v3 08/12] ipconfig: Removed obsolete code.

2011-01-07 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 9781d52..38de5f0 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1616,9 +1616,6 @@ int __connman_ipconfig_set_config(struct connman_ipconfig 
*ipconfig,
break;
 
case CONNMAN_IPCONFIG_METHOD_DHCP:
-   if (ipconfig-method == method)
-   return 0;
-
ipconfig-method = method;
break;
}
-- 
1.7.0.4

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


[PATCH autoconf v3 12/12] ipv6: Fix possible values for Method in service API

2011-01-07 Thread Jukka Rissanen
---
 doc/service-api.txt |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/doc/service-api.txt b/doc/service-api.txt
index aaddbfb..4a8a490 100644
--- a/doc/service-api.txt
+++ b/doc/service-api.txt
@@ -364,15 +364,13 @@ Propertiesstring State [readonly]
 
string Method [readonly]
 
-   Possible values are dhcp, manual
+   Possible values are auto, manual
and off.
 
The value fixed indicates an IP address
that can not be modified. For example
cellular networks return fixed information.
 
-   dhcp is not supported currently.
-
string Address [readonly]
 
The current configured IPv6 address.
-- 
1.7.0.4

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


[PATCH autoconf v3 11/12] ipv6: Do not disconnect IPv4 if IPv6 method changes.

2011-01-07 Thread Jukka Rissanen
---
 src/service.c |   49 -
 1 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/src/service.c b/src/service.c
index 01e52f2..db7f85e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2041,7 +2041,7 @@ static DBusMessage *set_property(DBusConnection *conn,
} else if (g_str_equal(name, IPv4.Configuration) == TRUE ||
g_str_equal(name, IPv6.Configuration)) {
 
-   enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
+   struct connman_ipconfig *ipv4 = NULL, *ipv6 = NULL;
int err = 0;
 
DBG(%s, name);
@@ -2050,44 +2050,43 @@ static DBusMessage *set_property(DBusConnection *conn,
service-ipconfig_ipv6 == NULL)
return __connman_error_invalid_property(msg);
 
-   if (is_connecting(service) ||
-   is_connected(service)) {
-   __connman_network_clear_ipconfig(service-network,
-   service-ipconfig_ipv4);
-   __connman_network_clear_ipconfig(service-network,
-   service-ipconfig_ipv6);
-   }
-
if (g_str_equal(name, IPv4.Configuration) == TRUE) {
-   type = CONNMAN_IPCONFIG_TYPE_IPV4;
-   err = __connman_ipconfig_set_config(
-   service-ipconfig_ipv4, value);
+   if (is_connecting(service) || is_connected(service))
+   __connman_network_clear_ipconfig(
+   service-network,
+   service-ipconfig_ipv4);
+
+   ipv4 = service-ipconfig_ipv4;
+   err = __connman_ipconfig_set_config(ipv4, value);
+
} else if (g_str_equal(name, IPv6.Configuration) == TRUE) {
-   type = CONNMAN_IPCONFIG_TYPE_IPV6;
-   err = __connman_ipconfig_set_config(
-   service-ipconfig_ipv6, value);
+   if (is_connecting(service) || is_connected(service))
+   __connman_network_clear_ipconfig(
+   service-network,
+   service-ipconfig_ipv6);
+
+   ipv6 = service-ipconfig_ipv6;
+   err = __connman_ipconfig_set_config(ipv6, value);
}
 
if (err  0) {
-   if (is_connected(service) ||
-   is_connecting(service))
+   if (is_connected(service) || is_connecting(service))
__connman_network_set_ipconfig(
service-network,
-   service-ipconfig_ipv4,
-   service-ipconfig_ipv6);
+   ipv4,
+   ipv6);
return __connman_error_failed(msg, -err);
}
 
-   if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+   if (ipv4)
ipv4_configuration_changed(service);
-   else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
+   else if (ipv6)
ipv6_configuration_changed(service);
 
-   if (is_connecting(service) ||
-   is_connected(service))
+   if (is_connecting(service) || is_connected(service))
__connman_network_set_ipconfig(service-network,
-   service-ipconfig_ipv4,
-   service-ipconfig_ipv6);
+   ipv4,
+   ipv6);
 
__connman_storage_save_service(service);
} else
-- 
1.7.0.4

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


[PATCH autoconf v4 4/5] ipv6: Set ipconfig method correctly for IPv4 and IPv6 config

2011-01-10 Thread Jukka Rissanen
---
 src/ipconfig.c |   77 ++-
 1 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index f1533e0..49bc349 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -23,6 +23,7 @@
 #include config.h
 #endif
 
+#include stdio.h
 #include net/if.h
 #include net/if_arp.h
 #include linux/if_link.h
@@ -291,6 +292,35 @@ static const char *scope2str(unsigned char scope)
return ;
 }
 
+static void set_ipv6_state(gchar *ifname, gboolean enable)
+{
+   gchar *path;
+   FILE *f;
+
+   if (ifname == NULL)
+   path = g_strdup(/proc/sys/net/ipv6/conf/all/disable_ipv6);
+   else
+   path = g_strdup_printf(
+   /proc/sys/net/ipv6/conf/%s/disable_ipv6, ifname);
+
+   if (path == NULL)
+   return;
+
+   f = fopen(path, r+);
+
+   g_free(path);
+
+   if (f == NULL)
+   return;
+
+   if (enable == FALSE)
+   fprintf(f, 1);
+   else
+   fprintf(f, 0);
+
+   fclose(f);
+}
+
 static void free_ipdevice(gpointer data)
 {
struct connman_ipdevice *ipdevice = data;
@@ -1512,6 +1542,34 @@ void __connman_ipconfig_append_ipv4config(struct 
connman_ipconfig *ipconfig,
DBUS_TYPE_STRING, ipconfig-address-gateway);
 }
 
+static void disable_ipv6(struct connman_ipconfig *ipconfig)
+{
+   struct connman_ipdevice *ipdevice;
+
+   DBG();
+
+   ipdevice = g_hash_table_lookup(ipdevice_hash,
+   GINT_TO_POINTER(ipconfig-index));
+   if (ipdevice == NULL)
+   return;
+
+   set_ipv6_state(ipdevice-ifname, FALSE);
+}
+
+static void enable_ipv6(struct connman_ipconfig *ipconfig)
+{
+   struct connman_ipdevice *ipdevice;
+
+   DBG();
+
+   ipdevice = g_hash_table_lookup(ipdevice_hash,
+   GINT_TO_POINTER(ipconfig-index));
+   if (ipdevice == NULL)
+   return;
+
+   set_ipv6_state(ipdevice-ifname, TRUE);
+}
+
 int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig,
DBusMessageIter *array)
 {
@@ -1586,11 +1644,23 @@ int __connman_ipconfig_set_config(struct 
connman_ipconfig *ipconfig,
 
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
-   case CONNMAN_IPCONFIG_METHOD_OFF:
case CONNMAN_IPCONFIG_METHOD_FIXED:
-   case CONNMAN_IPCONFIG_METHOD_AUTO:
return -EINVAL;
 
+   case CONNMAN_IPCONFIG_METHOD_OFF:
+   ipconfig-method = method;
+   if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV6)
+   disable_ipv6(ipconfig);
+   break;
+
+   case CONNMAN_IPCONFIG_METHOD_AUTO:
+   if (ipconfig-type != CONNMAN_IPCONFIG_TYPE_IPV6)
+   return -EINVAL;
+
+   ipconfig-method = method;
+   enable_ipv6(ipconfig);
+   break;
+
case CONNMAN_IPCONFIG_METHOD_MANUAL:
if (address == NULL)
return -EINVAL;
@@ -1607,6 +1677,9 @@ int __connman_ipconfig_set_config(struct connman_ipconfig 
*ipconfig,
break;
 
case CONNMAN_IPCONFIG_METHOD_DHCP:
+   if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV6)
+   return -ENOTSUP;
+
ipconfig-method = method;
break;
}
-- 
1.7.0.4

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


[PATCH autoconf v4 1/5] ipv6: Test script for setting IPv6 Method

2011-01-10 Thread Jukka Rissanen
---
 test/set-ipv6-method |   33 +
 1 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100755 test/set-ipv6-method

diff --git a/test/set-ipv6-method b/test/set-ipv6-method
new file mode 100755
index 000..274e89b
--- /dev/null
+++ b/test/set-ipv6-method
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+def print_usage():
+   print Usage: %s service off|manual|auto [address [prefixlen] 
[gateway]] % (sys.argv[0])
+
+if (len(sys.argv)  3):
+   print_usage()
+   sys.exit(1)
+
+bus = dbus.SystemBus()
+path = /profile/default/ + sys.argv[1]
+service = dbus.Interface(bus.get_object('net.connman', path),
+   'net.connman.Service')
+
+properties = service.GetProperties()
+
+print Setting method %s for %s % (sys.argv[2], sys.argv[1])
+
+ipv6_configuration = { Method: sys.argv[2] }
+if (len(sys.argv)  3):
+   ipv6_configuration[Address] = sys.argv[3]
+if (len(sys.argv)  4):
+   ipv6_configuration[PrefixLength] = sys.argv[4]
+if (len(sys.argv)  5):
+   ipv6_configuration[Gateway] = sys.argv[5]
+
+service.SetProperty(IPv6.Configuration, ipv6_configuration)
+print New IPv6.Configuration: , ipv6_configuration
+
+print
-- 
1.7.0.4

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


[PATCH autoconf v4 5/5] ipconfig: Restore original IPv6 interface status when connman quits.

2011-01-10 Thread Jukka Rissanen
---
 src/ipconfig.c |   36 
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 49bc349..7ecd7e7 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -77,6 +77,8 @@ struct connman_ipdevice {
 
struct connman_ipconfig *config_ipv4;
struct connman_ipconfig *config_ipv6;
+
+   gboolean ipv6_enabled;
 };
 
 static GHashTable *ipdevice_hash = NULL;
@@ -292,6 +294,35 @@ static const char *scope2str(unsigned char scope)
return ;
 }
 
+static gboolean get_ipv6_state(gchar *ifname)
+{
+   int disabled;
+   gchar *path;
+   FILE *f;
+   gboolean enabled = FALSE;
+
+   if (ifname == NULL)
+   path = g_strdup(/proc/sys/net/ipv6/conf/all/disable_ipv6);
+   else
+   path = g_strdup_printf(
+   /proc/sys/net/ipv6/conf/%s/disable_ipv6, ifname);
+
+   if (path == NULL)
+   return enabled;
+
+   f = fopen(path, r);
+
+   g_free(path);
+
+   if (f != NULL) {
+   if (fscanf(f, %d, disabled)  0)
+   enabled = !disabled;
+   fclose(f);
+   }
+
+   return enabled;
+}
+
 static void set_ipv6_state(gchar *ifname, gboolean enable)
 {
gchar *path;
@@ -344,6 +375,9 @@ static void free_ipdevice(gpointer data)
g_free(ipdevice-pac);
 
g_free(ipdevice-address);
+
+   set_ipv6_state(ipdevice-ifname, ipdevice-ipv6_enabled);
+
g_free(ipdevice-ifname);
g_free(ipdevice);
 }
@@ -439,6 +473,8 @@ void __connman_ipconfig_newlink(int index, unsigned short 
type,
ipdevice-ifname = connman_inet_ifname(index);
ipdevice-type = type;
 
+   ipdevice-ipv6_enabled = get_ipv6_state(ipdevice-ifname);
+
ipdevice-address = g_strdup(address);
 
g_hash_table_insert(ipdevice_hash, GINT_TO_POINTER(index), ipdevice);
-- 
1.7.0.4

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


[PATCH autoconf v4 2/5] ipv4: Renamed set-ip-method to be consistent with IPv6 script

2011-01-10 Thread Jukka Rissanen
---
 test/set-ip-method   |   34 --
 test/set-ipv4-method |   34 ++
 2 files changed, 34 insertions(+), 34 deletions(-)
 delete mode 100755 test/set-ip-method
 create mode 100755 test/set-ipv4-method

diff --git a/test/set-ip-method b/test/set-ip-method
deleted file mode 100755
index 576c803..000
--- a/test/set-ip-method
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus
-
-def print_usage():
-   print Usage: %s service [off|dhcp|manual address [netmask]] % 
(sys.argv[0])
-
-
-if (len(sys.argv)  3):
-   print_usage()
-   sys.exit(1)
-
-bus = dbus.SystemBus()
-path = /profile/default/ + sys.argv[1]
-service = dbus.Interface(bus.get_object('net.connman', path),
-   'net.connman.Service')
-
-properties = service.GetProperties()
-
-print Setting method %s for %s % (sys.argv[2], sys.argv[1])
-
-ipv4_configuration = { Method: sys.argv[2] }
-if (len(sys.argv)  3):
-   ipv4_configuration[Address] = sys.argv[3]
-if (len(sys.argv)  4):
-   ipv4_configuration[Netmask] = sys.argv[4]
-if (len(sys.argv)  5):
-ipv4_configuration[Gateway] = sys.argv[5]
-
-service.SetProperty(IPv4.Configuration, ipv4_configuration)
-print New IPv4.Configuration: , ipv4_configuration
-
-print
diff --git a/test/set-ipv4-method b/test/set-ipv4-method
new file mode 100755
index 000..576c803
--- /dev/null
+++ b/test/set-ipv4-method
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+def print_usage():
+   print Usage: %s service [off|dhcp|manual address [netmask]] % 
(sys.argv[0])
+
+
+if (len(sys.argv)  3):
+   print_usage()
+   sys.exit(1)
+
+bus = dbus.SystemBus()
+path = /profile/default/ + sys.argv[1]
+service = dbus.Interface(bus.get_object('net.connman', path),
+   'net.connman.Service')
+
+properties = service.GetProperties()
+
+print Setting method %s for %s % (sys.argv[2], sys.argv[1])
+
+ipv4_configuration = { Method: sys.argv[2] }
+if (len(sys.argv)  3):
+   ipv4_configuration[Address] = sys.argv[3]
+if (len(sys.argv)  4):
+   ipv4_configuration[Netmask] = sys.argv[4]
+if (len(sys.argv)  5):
+ipv4_configuration[Gateway] = sys.argv[5]
+
+service.SetProperty(IPv4.Configuration, ipv4_configuration)
+print New IPv4.Configuration: , ipv4_configuration
+
+print
-- 
1.7.0.4

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


[PATCH ipv6 v1 01/14] ipconfig: Clear the ipaddress pointers when address is deleted.

2011-01-24 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 6ef39c5..bd664f3 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -682,7 +682,8 @@ void __connman_ipconfig_deladdr(int index, int family, 
const char *label,
ipdevice-address_list = g_slist_remove(ipdevice-address_list,
ipaddress);
 
-   connman_ipaddress_free(ipaddress);
+   connman_ipaddress_clear(ipaddress);
+   g_free(ipaddress);
 
connman_info(%s {del} address %s/%u label %s, ipdevice-ifname,
address, prefixlen, label);
-- 
1.7.0.4

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


[PATCH ipv6 v1 00/14] Support IPv6 only networks

2011-01-24 Thread Jukka Rissanen
Hi Samuel,

following patches allow connman to support IPv6 only networks.
This means that if IPv4 is turned off (ipconfig method is OFF) or
dhcp does not return any IPv4 address and IPv6 is set to auto,
then service can be connected if interface has IPv6 address.
The user can set the IPv6 to OFF if the IPv6 addressing should not
make the service ready.

In practice this means that following is possible:

$ ./list-services
[ /profile/default/ethernet_0050dacfd855_cable ]
IPv6.Configuration = { Method=auto }
IPv6 = { PrefixLength=64 Method=auto 
Address=2001:db8:200:2:250:daff:fecf:d855 }
IPv4.Configuration = { Method=dhcp }
IPv4 = { Netmask=255.255.255.0 Gateway=192.168.1.1 Method=dhcp 
Address=192.168.1.100 }
$ ./get-state
System is online
$ ./set-ipv4-method ethernet_0050dacfd855_cable off
Setting method off for ethernet_0050dacfd855_cable
New IPv4.Configuration:  {'Method': 'off'}

$ ./get-state
System is online
$ ./list-services
[ /profile/default/ethernet_0050dacfd855_cable ]
IPv6.Configuration = { Method=auto }
IPv6 = { PrefixLength=64 Method=auto 
Address=2001:db8:200:2:250:daff:fecf:d855 }
IPv4.Configuration = { Method=off }
IPv4 = { }
$ ./set-ipv6-method ethernet_0050dacfd855_cable off
Setting method off for ethernet_0050dacfd855_cable
New IPv6.Configuration:  {'Method': 'off'}

$ ./get-state
System is offline
$ ./list-services
[ /profile/default/ethernet_0050dacfd855_cable ]
IPv6.Configuration = { Method=off }
IPv6 = { }
IPv4.Configuration = { Method=off }
IPv4 = { }
$ ./set-ipv6-method ethernet_0050dacfd855_cable auto
Setting method auto for ethernet_0050dacfd855_cable
New IPv6.Configuration:  {'Method': 'auto'}

$ ./list-services
[ /profile/default/ethernet_0050dacfd855_cable ]
IPv6.Configuration = { Method=auto }
IPv6 = { PrefixLength=64 Method=auto 
Address=2001:db8:200:2:250:daff:fecf:d855 }
IPv4.Configuration = { Method=off }
IPv4 = { }
$ ./get-state
System is online
$ ./set-ipv4-method ethernet_0050dacfd855_cable dhcp
Setting method dhcp for ethernet_0050dacfd855_cable
New IPv4.Configuration:  {'Method': 'dhcp'}

$ ./list-services
[ /profile/default/ethernet_0050dacfd855_cable ]
IPv6.Configuration = { Method=auto }
IPv6 = { PrefixLength=64 Method=auto 
Address=2001:db8:200:2:250:daff:fecf:d855 }
IPv4.Configuration = { Method=dhcp }
IPv4 = { Netmask=255.255.255.0 Gateway=192.168.1.1 Method=dhcp 
Address=192.168.1.100 }
$ ./get-state
System is online
$ ./set-ipv6-method ethernet_0050dacfd855_cable off
Setting method off for ethernet_0050dacfd855_cable
New IPv6.Configuration:  {'Method': 'off'}

$ ./get-state
System is online
$ ./set-ipv4-method ethernet_0050dacfd855_cable off
Setting method off for ethernet_0050dacfd855_cable
New IPv4.Configuration:  {'Method': 'off'}

$ ./get-state
System is offline


Then the patches:

01: This is the patch that we talked in the mailing list earlier,
it just clears the pointers in ipaddress struct instead of
just freeing the pointers. This should not make much difference
and I did not see any problems with the original version.

02: Nameserver property for IPv6, this is needed by patch #07

03: Helper function for getting the ipconfig type, needed by
patches #09 and #10

04: Split the service state for two parts, the other one is
handling IPv4 state and the other IPv6 state. The states
are combined by combine_state(). The system should still
behave the same way after this patch i.e., IPv4 state is
the master state.

05: Enable or disable IPv6 when the loading the config from
file.

06: Determine the service state from IPv4 and IPv6 states.

07: Enable IPv6 autoconf to change the state. This is the network
part.

08: Set the service state correctly when network is disconnected.

09: Set the service state correctly when ipconfig is cleared.

10: IPv6 autoconf will change the service state. The autoconf
address creation/deletion is received via netlink which then
calls service bound and release functions. Note that in
bound case, the ipconfig is not enabled because that call
is done already. The ipconfig disable needs to be done in
release case as it would not be done otherwise.

11: Check and change the state properly if the user changes
ipconfig method.

12: Disable IPv4 when address is released and IPv4 is marked OFF.

13: If loading IPv6 which is autoconfigurable, then update the
service state.

14: Remove the IPv6 from todo list as the most important stuff
is now implemented.

From these patches the #01, #02 and #03 and also perhaps #04 are
independent. The other ones should be commited in one go.


Regards,
Jukka



Jukka Rissanen (14):
  ipconfig: Clear the ipaddress pointers when address is deleted.
  ipv6: Add property for IPv6 nameserver
  ipconfig: Added helper function that returns the config type.
  service: Split service state to IPv4 and IPv6 parts.
  ipconfig: Enable or disable IPv6 when

[PATCH ipv6 v1 04/14] service: Split service state to IPv4 and IPv6 parts.

2011-01-24 Thread Jukka Rissanen
---
 src/connection.c |6 +-
 src/connman.h|3 +-
 src/location.c   |3 +-
 src/network.c|   24 +++--
 src/provider.c   |   27 +++--
 src/service.c|  335 +++--
 6 files changed, 313 insertions(+), 85 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 789a242..844c279 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -332,7 +332,8 @@ static int connection_probe(struct connman_element *element)
new_gateway-ipv4_gateway);
__connman_service_set_domainname(service, domainname);
 
-   __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY);
+   __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
 
if (service == NULL) {
new_gateway-vpn = TRUE;
@@ -376,7 +377,8 @@ static void connection_remove(struct connman_element 
*element)
service = __connman_element_get_service(element);
__connman_service_nameserver_del_routes(service);
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_DISCONNECT);
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
 
connman_element_set_enabled(element, FALSE);
 
diff --git a/src/connman.h b/src/connman.h
index 12566aa..45f600f 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -484,7 +484,8 @@ int __connman_service_set_immutable(struct connman_service 
*service,
 void __connman_service_set_string(struct connman_service *service,
const char *key, const char *value);
 int __connman_service_indicate_state(struct connman_service *service,
-   enum connman_service_state state);
+   enum connman_service_state state_ipv4,
+   enum connman_service_state state_ipv6);
 int __connman_service_indicate_error(struct connman_service *service,
enum connman_service_error error);
 int __connman_service_indicate_default(struct connman_service *service);
diff --git a/src/location.c b/src/location.c
index e7bfdc0..46928b5 100644
--- a/src/location.c
+++ b/src/location.c
@@ -186,7 +186,8 @@ void connman_location_report_result(struct connman_location 
*location,
break;
case CONNMAN_LOCATION_RESULT_ONLINE:
__connman_service_indicate_state(location-service,
-   CONNMAN_SERVICE_STATE_ONLINE);
+   CONNMAN_SERVICE_STATE_ONLINE,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
break;
}
 }
diff --git a/src/network.c b/src/network.c
index 612e923..05ee0c1 100644
--- a/src/network.c
+++ b/src/network.c
@@ -497,7 +497,8 @@ int connman_network_set_associating(struct connman_network 
*network,
 
service = __connman_service_lookup_from_network(network);
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_ASSOCIATION);
+   CONNMAN_SERVICE_STATE_ASSOCIATION,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
}
 
return 0;
@@ -515,7 +516,8 @@ static void set_associate_error(struct connman_network 
*network)
service = __connman_service_lookup_from_network(network);
 
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_FAILURE);
+   CONNMAN_SERVICE_STATE_FAILURE,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
 }
 
 static void set_configure_error(struct connman_network *network)
@@ -527,7 +529,8 @@ static void set_configure_error(struct connman_network 
*network)
service = __connman_service_lookup_from_network(network);
 
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_FAILURE);
+   CONNMAN_SERVICE_STATE_FAILURE,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
 }
 
 void connman_network_set_ipv4_method(struct connman_network *network,
@@ -601,7 +604,8 @@ static void set_configuration(struct connman_network 
*network)
 
service = __connman_service_lookup_from_network(network);
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_CONFIGURATION);
+   CONNMAN_SERVICE_STATE_CONFIGURATION,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
 }
 
 static int 

[PATCH ipv6 v1 05/14] ipconfig: Enable or disable IPv6 when loading the saved service.

2011-01-24 Thread Jukka Rissanen
---
 src/ipconfig.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 4d9b30f..0627b5b 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1778,6 +1778,14 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
ipconfig-method = CONNMAN_IPCONFIG_METHOD_OFF;
 
+   if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV6) {
+   if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_OFF)
+   disable_ipv6(ipconfig);
+   else if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_AUTO ||
+   ipconfig-method == CONNMAN_IPCONFIG_METHOD_MANUAL)
+   enable_ipv6(ipconfig);
+   }
+
g_free(method);
g_free(key);
 
-- 
1.7.0.4

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


[PATCH ipv6 v1 06/14] service: Only disconnect the service if both IPv4 and IPv6 states agree.

2011-01-24 Thread Jukka Rissanen
---
 src/service.c |   17 +
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/service.c b/src/service.c
index 98f824b..09c6913 100644
--- a/src/service.c
+++ b/src/service.c
@@ -107,6 +107,7 @@ struct connman_service {
char **proxies;
char **excludes;
char *pac;
+   int connect_count;
 };
 
 static void append_path(gpointer value, gpointer user_data)
@@ -2886,6 +2887,7 @@ static void service_initialize(struct connman_service 
*service)
stats_init(service);
 
service-provider = NULL;
+   service-connect_count = 0;
 }
 
 /**
@@ -3298,6 +3300,8 @@ int __connman_service_indicate_state(struct 
connman_service *service,
if (state == CONNMAN_SERVICE_STATE_READY) {
enum connman_service_proxy_method proxy_config;
 
+   g_atomic_int_inc(service-connect_count);
+
set_reconnect_state(service, TRUE);
 
__connman_service_set_favorite(service, TRUE);
@@ -3336,11 +3340,15 @@ int __connman_service_indicate_state(struct 
connman_service *service,
 
default_changed();
} else if (state == CONNMAN_SERVICE_STATE_DISCONNECT) {
-   __connman_location_finish(service);
 
-   default_changed();
+   if (g_atomic_int_dec_and_test(service-connect_count) ==
+   TRUE) {
+   __connman_location_finish(service);
+
+   default_changed();
 
-   __connman_wpad_stop(service);
+   __connman_wpad_stop(service);
+   }
 
update_nameservers(service);
dns_changed(service);
@@ -3363,7 +3371,8 @@ int __connman_service_indicate_state(struct 
connman_service *service,
if (iter != NULL)
g_sequence_sort_changed(iter, service_compare, NULL);
 
-   __connman_profile_changed(FALSE);
+   if (service-connect_count == 0)
+   __connman_profile_changed(FALSE);
 
service_state = combine_state(service-state_ipv4,
service-state_ipv6);
-- 
1.7.0.4

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


[PATCH ipv6 v1 09/14] service: Set service state correctly when ipconfig is cleared.

2011-01-24 Thread Jukka Rissanen
---
 src/network.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/network.c b/src/network.c
index d21f7b6..f1a6e38 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1057,12 +1057,14 @@ int __connman_network_clear_ipconfig(struct 
connman_network *network,
 {
struct connman_service *service;
enum connman_ipconfig_method method;
+   enum connman_ipconfig_type type;
 
service = __connman_service_lookup_from_network(network);
if (service == NULL)
return -EINVAL;
 
method = __connman_ipconfig_get_method(ipconfig);
+   type = __connman_ipconfig_get_config_type(ipconfig);
 
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
@@ -1080,8 +1082,13 @@ int __connman_network_clear_ipconfig(struct 
connman_network *network,
break;
}
 
-   __connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_CONFIGURATION,
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_UNKNOWN,
+   CONNMAN_SERVICE_STATE_DISCONNECT);
+   else if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
CONNMAN_SERVICE_STATE_UNKNOWN);
 
return 0;
-- 
1.7.0.4

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


[PATCH ipv6 v1 11/14] service: Check service state properly if user changes method.

2011-01-24 Thread Jukka Rissanen
---
 src/service.c |   30 --
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/service.c b/src/service.c
index b775d44..38f8f2f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2203,6 +2203,9 @@ static DBusMessage *set_property(DBusConnection *conn,
g_str_equal(name, IPv6.Configuration)) {
 
struct connman_ipconfig *ipv4 = NULL, *ipv6 = NULL;
+   enum connman_ipconfig_method old_method;
+   enum connman_ipconfig_method method =
+   CONNMAN_IPCONFIG_METHOD_UNKNOWN;
enum connman_service_state state =
CONNMAN_SERVICE_STATE_UNKNOWN;
int err = 0;
@@ -2214,26 +2217,49 @@ static DBusMessage *set_property(DBusConnection *conn,
return __connman_error_invalid_property(msg);
 
if (g_str_equal(name, IPv4.Configuration) == TRUE) {
+   ipv4 = service-ipconfig_ipv4;
+   old_method = __connman_ipconfig_get_method(ipv4);
state = service-state_ipv4;
+
if (is_connecting(service, state) ||
is_connected(service, state))
__connman_network_clear_ipconfig(
service-network,
service-ipconfig_ipv4);
 
-   ipv4 = service-ipconfig_ipv4;
err = __connman_ipconfig_set_config(ipv4, value);
+   method = __connman_ipconfig_get_method(ipv4);
+   if (err == 0 
+   old_method == CONNMAN_IPCONFIG_METHOD_OFF 
+   method == CONNMAN_IPCONFIG_METHOD_DHCP) {
+   state = service-state_ipv4 =
+   CONNMAN_SERVICE_STATE_CONFIGURATION;
+   __connman_ipconfig_enable(ipv4);
+   }
+
+   DBG(err %d ipv4 %p method %d state %s, err, ipv4,
+   method, state2string(state));
 
} else if (g_str_equal(name, IPv6.Configuration) == TRUE) {
+   ipv6 = service-ipconfig_ipv6;
+   old_method = __connman_ipconfig_get_method(ipv6);
state = service-state_ipv6;
+
if (is_connecting(service, state) ||
is_connected(service, state))
__connman_network_clear_ipconfig(
service-network,
service-ipconfig_ipv6);
 
-   ipv6 = service-ipconfig_ipv6;
err = __connman_ipconfig_set_config(ipv6, value);
+   method = __connman_ipconfig_get_method(ipv6);
+   if (err == 0  old_method ==
+   CONNMAN_IPCONFIG_METHOD_OFF 
+   method == CONNMAN_IPCONFIG_METHOD_AUTO)
+   __connman_ipconfig_enable(ipv6);
+
+   DBG(err %d ipv6 %p method %d state %s, err, ipv6,
+   method, state2string(state));
}
 
if (err  0) {
-- 
1.7.0.4

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


[PATCH ipv6 v1 12/14] service: Disable IPv4 when address is released.

2011-01-24 Thread Jukka Rissanen
---
 src/service.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index 38f8f2f..0d38e66 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4076,6 +4076,14 @@ static void service_ip_release(struct connman_ipconfig 
*ipconfig)
__connman_ipconfig_disable(ipconfig);
}
 
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV4 
+   method == CONNMAN_IPCONFIG_METHOD_OFF) {
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_SERVICE_STATE_UNKNOWN);
+   __connman_ipconfig_disable(ipconfig);
+   }
+
settings_changed(service);
 }
 
-- 
1.7.0.4

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


[PATCH ipv6 v1 10/14] service: IPv6 autoconf will change the service state.

2011-01-24 Thread Jukka Rissanen
---
 src/service.c |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index 09c6913..b775d44 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4014,18 +4014,42 @@ static void service_lower_down(struct connman_ipconfig 
*ipconfig)
 static void service_ip_bound(struct connman_ipconfig *ipconfig)
 {
struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
 
connman_info(%s ip bound, connman_ipconfig_get_ifname(ipconfig));
 
+   type = __connman_ipconfig_get_config_type(ipconfig);
+   method = __connman_ipconfig_get_method(ipconfig);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6 
+   method == CONNMAN_IPCONFIG_METHOD_AUTO)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_UNKNOWN,
+   CONNMAN_SERVICE_STATE_READY);
+
settings_changed(service);
 }
 
 static void service_ip_release(struct connman_ipconfig *ipconfig)
 {
struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
 
connman_info(%s ip release, connman_ipconfig_get_ifname(ipconfig));
 
+   type = __connman_ipconfig_get_config_type(ipconfig);
+   method = __connman_ipconfig_get_method(ipconfig);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6 
+   method == CONNMAN_IPCONFIG_METHOD_OFF) {
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_UNKNOWN,
+   CONNMAN_SERVICE_STATE_DISCONNECT);
+   __connman_ipconfig_disable(ipconfig);
+   }
+
settings_changed(service);
 }
 
-- 
1.7.0.4

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


[PATCH ipv6 v1 02/14] ipv6: Add property for IPv6 nameserver

2011-01-24 Thread Jukka Rissanen
---
 include/property.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/property.h b/include/property.h
index e18e1e9..487a170 100644
--- a/include/property.h
+++ b/include/property.h
@@ -57,6 +57,7 @@ enum connman_property_id {
CONNMAN_PROPERTY_ID_IPV6_ADDRESS,
CONNMAN_PROPERTY_ID_IPV6_PREFIXLEN,
CONNMAN_PROPERTY_ID_IPV6_GATEWAY,
+   CONNMAN_PROPERTY_ID_IPV6_NAMESERVER,
 };
 
 enum connman_property_type {
-- 
1.7.0.4

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


[PATCH ipv6 v1 14/14] todo: Remove IPv6 enhancements as they are implemented.

2011-01-24 Thread Jukka Rissanen
---
 TODO |   13 -
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/TODO b/TODO
index 73aeb03..d58c10d 100644
--- a/TODO
+++ b/TODO
@@ -79,19 +79,6 @@ Core
credentials, ConnMan should be able to initiate a WiSPR authentication.
 
 
-- IPv6 enhancements
-
-   Priority: High
-   Complexity: C8
-   Owner: Jukka Rissanen jukka.rissa...@nokia.com
-
-   Support IPv6 only networks so that system can go online even if
-   there is no IPv4 address. Also support more than one IPv6 address
-   in one device so that the addresses are reported correctly via
-   dbus interface. The autoconf IPv6 addresses need also some tweaking
-   so that system will go online properly.
-
-
 WiFi
 
 
-- 
1.7.0.4

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


[PATCH ipv6 v1 08/14] service: Set service state correctly when network is disconnected.

2011-01-24 Thread Jukka Rissanen
---
 src/network.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/network.c b/src/network.c
index 0d620a2..d21f7b6 100644
--- a/src/network.c
+++ b/src/network.c
@@ -844,8 +844,8 @@ static gboolean set_connected(gpointer user_data)
service = __connman_service_lookup_from_network(network);
 
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_IDLE,
-   CONNMAN_SERVICE_STATE_UNKNOWN);
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_SERVICE_STATE_DISCONNECT);
}
 
network-connecting = FALSE;
-- 
1.7.0.4

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


[PATCH] service: Added a script for toggling AutoConnect flag.

2011-01-25 Thread Jukka Rissanen
---
A simple script for setting and getting the service auto connect
flag.

 test/set-autoconnect |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100755 test/set-autoconnect

diff --git a/test/set-autoconnect b/test/set-autoconnect
new file mode 100755
index 000..decc7de
--- /dev/null
+++ b/test/set-autoconnect
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv)  2):
+   print Usage: %s service [0 | 1] % (sys.argv[0])
+   sys.exit(1)
+
+bus = dbus.SystemBus()
+path = /profile/default/ + sys.argv[1]
+service = dbus.Interface(bus.get_object('net.connman', path),
+   'net.connman.Service')
+
+properties = service.GetProperties()
+
+if (len(sys.argv)  3):
+   print Current AutoConnect value is %s % properties[AutoConnect]
+else:
+   print Setting autoconnect to %s % (sys.argv[2])
+   service.SetProperty(AutoConnect, dbus.Boolean(int(sys.argv[2])))
-- 
1.7.0.4

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


[PATCH ipv6 v2 00/15] Support IPv6 only networks

2011-02-08 Thread Jukka Rissanen
Hi Samuel,

thanks for the comments to v1 patchset. This second version
fixes the issues you found out:

Patch #4:
- connman_service_indicate_state() prototype changed so that
  only one state can be changed at a time
- is_connected() and is_connecting() function prototypes changed
  back to what they were before
- unnecessary checks in service_compare() removed
- extra debugging removed

Patch #6:
- simplified the combined state checking (removed the counter that
  was present in v1 patch)

Patch #9:
- fixed the incorrect state

Patch #11:
- reworked the patch, hope it looks more sane now

Patch #7:
- The IPv6 default gateway issue is still open, so far I have not
  seen any problems with it (=not setting any routes in connman).
  As you noticed the kernel automagically creates a default route
  but that route is using link local address (at least in my test
  system with 2.6.32 kernel). Also kernel creates routes to all
  autoconfigured networks to specific interface.
  I have a patch pending that clears the routes if user turns the
  IPv6 off but I am not sure if that patch is really the correct way
  to do it. I will send it to mailing list for comments after some
  more testing. Anyway, this route problem should not affect this
  patchset.

The v2 patchset adds additional patch #14 which was needed because
of reworking of patches #4 and #9.

Regards,

Jukka


Jukka Rissanen (15):
  ipconfig: Clear the ipaddress pointers when address is deleted.
  ipv6: Add property for IPv6 nameserver
  ipconfig: Added helper function that returns the config type.
  service: Split service state to IPv4 and IPv6 parts.
  ipconfig: Enable or disable IPv6 when loading the saved service.
  service: Only disconnect the service if both IPv4 and IPv6 states
agree.
  network: Enable IPv6 autoconf to change the service state to ready.
  network: Set service state correctly when network is disconnected.
  network: Set service state correctly when ipconfig is cleared.
  service: IPv6 autoconf will change the service state.
  service: Check service state properly if user changes method.
  service: Change IPv4 state when address is released.
  ipconfig: Enable ipconfig if loading autoconfigurable IPv6 config.
  service: Do not change state if combined state does not change.
  todo: Remove IPv6 enhancements as they are implemented.

 TODO   |   13 --
 include/property.h |1 +
 src/connection.c   |6 +-
 src/connman.h  |5 +-
 src/ipconfig.c |   30 -
 src/location.c |3 +-
 src/network.c  |   72 -
 src/provider.c |   27 +++-
 src/service.c  |  416 
 9 files changed, 472 insertions(+), 101 deletions(-)

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


[PATCH ipv6 v2 01/15] ipconfig: Clear the ipaddress pointers when address is deleted.

2011-02-08 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 6ef39c5..bd664f3 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -682,7 +682,8 @@ void __connman_ipconfig_deladdr(int index, int family, 
const char *label,
ipdevice-address_list = g_slist_remove(ipdevice-address_list,
ipaddress);
 
-   connman_ipaddress_free(ipaddress);
+   connman_ipaddress_clear(ipaddress);
+   g_free(ipaddress);
 
connman_info(%s {del} address %s/%u label %s, ipdevice-ifname,
address, prefixlen, label);
-- 
1.7.0.4

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


[PATCH ipv6 v2 05/15] ipconfig: Enable or disable IPv6 when loading the saved service.

2011-02-08 Thread Jukka Rissanen
---
 src/ipconfig.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 4d9b30f..0627b5b 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1778,6 +1778,14 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
ipconfig-method = CONNMAN_IPCONFIG_METHOD_OFF;
 
+   if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV6) {
+   if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_OFF)
+   disable_ipv6(ipconfig);
+   else if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_AUTO ||
+   ipconfig-method == CONNMAN_IPCONFIG_METHOD_MANUAL)
+   enable_ipv6(ipconfig);
+   }
+
g_free(method);
g_free(key);
 
-- 
1.7.0.4

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


[PATCH ipv6 v2 03/15] ipconfig: Added helper function that returns the config type.

2011-02-08 Thread Jukka Rissanen
---
 src/connman.h  |2 ++
 src/ipconfig.c |6 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 992d533..7f18ff4 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -218,6 +218,8 @@ void __connman_ipconfig_delroute(int index, int family, 
unsigned char scope,
 
 void __connman_ipconfig_foreach(void (*function) (int index, void *user_data),
void *user_data);
+enum connman_ipconfig_type __connman_ipconfig_get_config_type(
+   struct connman_ipconfig *ipconfig);
 unsigned short __connman_ipconfig_get_type(int index);
 unsigned int __connman_ipconfig_get_flags(int index);
 const char *__connman_ipconfig_get_gateway(int index);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index bd664f3..4d9b30f 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -853,6 +853,12 @@ void __connman_ipconfig_foreach(void (*function) (int 
index, void *user_data),
g_list_free(keys);
 }
 
+enum connman_ipconfig_type __connman_ipconfig_get_config_type(
+   struct connman_ipconfig *ipconfig)
+{
+   return ipconfig ? ipconfig-type : CONNMAN_IPCONFIG_TYPE_UNKNOWN;
+}
+
 unsigned short __connman_ipconfig_get_type(int index)
 {
struct connman_ipdevice *ipdevice;
-- 
1.7.0.4

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


[PATCH ipv6 v2 02/15] ipv6: Add property for IPv6 nameserver

2011-02-08 Thread Jukka Rissanen
---
 include/property.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/property.h b/include/property.h
index e18e1e9..487a170 100644
--- a/include/property.h
+++ b/include/property.h
@@ -57,6 +57,7 @@ enum connman_property_id {
CONNMAN_PROPERTY_ID_IPV6_ADDRESS,
CONNMAN_PROPERTY_ID_IPV6_PREFIXLEN,
CONNMAN_PROPERTY_ID_IPV6_GATEWAY,
+   CONNMAN_PROPERTY_ID_IPV6_NAMESERVER,
 };
 
 enum connman_property_type {
-- 
1.7.0.4

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


[PATCH ipv6 v2 07/15] network: Enable IPv6 autoconf to change the service state to ready.

2011-02-08 Thread Jukka Rissanen
---
 src/network.c |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/network.c b/src/network.c
index c3febd3..a338a58 100644
--- a/src/network.c
+++ b/src/network.c
@@ -768,6 +768,37 @@ static int manual_ipv6_set(struct connman_network *network,
return 0;
 }
 
+static void autoconf_ipv6_set(struct connman_network *network,
+   struct connman_ipconfig *ipconfig_ipv6)
+{
+   struct connman_service *service;
+   struct connman_ipconfig *ipconfig;
+   const char *nameserver = NULL;
+
+   DBG(network %p, network);
+
+   service = __connman_service_lookup_from_network(network);
+
+   ipconfig = __connman_service_get_ip6config(service);
+
+   __connman_device_increase_connections(network-device);
+
+   __connman_device_set_network(network-device, network);
+
+   connman_device_set_disconnected(network-device, FALSE);
+
+   connman_element_get_value(network-element,
+   CONNMAN_PROPERTY_ID_IPV6_NAMESERVER, nameserver);
+   if (nameserver != NULL)
+   __connman_service_append_nameserver(service, nameserver);
+
+   network-connecting = FALSE;
+
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_READY,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+}
+
 static gboolean set_connected(gpointer user_data)
 {
struct connman_network *network = user_data;
@@ -795,7 +826,9 @@ static gboolean set_connected(gpointer user_data)
switch (ipv6_method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
+   break;
case CONNMAN_IPCONFIG_METHOD_AUTO:
+   autoconf_ipv6_set(network, ipconfig_ipv6);
break;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
@@ -1100,7 +1133,9 @@ int __connman_network_set_ipconfig(struct connman_network 
*network,
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
+   break;
case CONNMAN_IPCONFIG_METHOD_AUTO:
+   autoconf_ipv6_set(network, ipconfig_ipv6);
break;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
-- 
1.7.0.4

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


[PATCH ipv6 v2 06/15] service: Only disconnect the service if both IPv4 and IPv6 states agree.

2011-02-08 Thread Jukka Rissanen
---
 src/service.c |   17 +
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/service.c b/src/service.c
index c27431c..89f7b4d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3245,6 +3245,7 @@ int __connman_service_indicate_state(struct 
connman_service *service,
enum connman_service_state service_state,
state = CONNMAN_SERVICE_STATE_IDLE;
GSequenceIter *iter;
+   connman_bool_t disconnected = FALSE;
 
if (service == NULL)
return -EINVAL;
@@ -3384,11 +3385,18 @@ int __connman_service_indicate_state(struct 
connman_service *service,
 
default_changed();
} else if (state == CONNMAN_SERVICE_STATE_DISCONNECT) {
-   __connman_location_finish(service);
 
-   default_changed();
+   if (service-state_ipv4 == CONNMAN_SERVICE_STATE_DISCONNECT ||
+   service-state_ipv6 ==
+   CONNMAN_SERVICE_STATE_DISCONNECT) {
+   __connman_location_finish(service);
+
+   default_changed();
+
+   __connman_wpad_stop(service);
 
-   __connman_wpad_stop(service);
+   disconnected = TRUE;
+   }
 
update_nameservers(service);
dns_changed(service);
@@ -3411,7 +3419,8 @@ int __connman_service_indicate_state(struct 
connman_service *service,
if (iter != NULL)
g_sequence_sort_changed(iter, service_compare, NULL);
 
-   __connman_profile_changed(FALSE);
+   if (disconnected == TRUE)
+   __connman_profile_changed(FALSE);
 
service_state = combine_state(service-state_ipv4,
service-state_ipv6);
-- 
1.7.0.4

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


[PATCH ipv6 v2 04/15] service: Split service state to IPv4 and IPv6 parts.

2011-02-08 Thread Jukka Rissanen
---
 src/connection.c |6 +-
 src/connman.h|3 +-
 src/location.c   |3 +-
 src/network.c|   24 +++--
 src/provider.c   |   27 +++--
 src/service.c|  309 +-
 6 files changed, 300 insertions(+), 72 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 789a242..7e517fa 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -332,7 +332,8 @@ static int connection_probe(struct connman_element *element)
new_gateway-ipv4_gateway);
__connman_service_set_domainname(service, domainname);
 
-   __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY);
+   __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
 
if (service == NULL) {
new_gateway-vpn = TRUE;
@@ -376,7 +377,8 @@ static void connection_remove(struct connman_element 
*element)
service = __connman_element_get_service(element);
__connman_service_nameserver_del_routes(service);
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_DISCONNECT);
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
 
connman_element_set_enabled(element, FALSE);
 
diff --git a/src/connman.h b/src/connman.h
index 7f18ff4..6202db3 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -478,7 +478,8 @@ int __connman_service_set_immutable(struct connman_service 
*service,
 void __connman_service_set_string(struct connman_service *service,
const char *key, const char *value);
 int __connman_service_indicate_state(struct connman_service *service,
-   enum connman_service_state state);
+   enum connman_service_state new_state,
+   enum connman_ipconfig_type type);
 int __connman_service_indicate_error(struct connman_service *service,
enum connman_service_error error);
 int __connman_service_clear_error(struct connman_service *service);
diff --git a/src/location.c b/src/location.c
index 820011f..ccfb2ed 100644
--- a/src/location.c
+++ b/src/location.c
@@ -191,7 +191,8 @@ void connman_location_report_result(struct connman_location 
*location,
break;
case CONNMAN_LOCATION_RESULT_ONLINE:
__connman_service_indicate_state(location-service,
-   CONNMAN_SERVICE_STATE_ONLINE);
+   CONNMAN_SERVICE_STATE_ONLINE,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
break;
}
 }
diff --git a/src/network.c b/src/network.c
index 09d4d2b..c3febd3 100644
--- a/src/network.c
+++ b/src/network.c
@@ -501,7 +501,8 @@ int connman_network_set_associating(struct connman_network 
*network,
 
service = __connman_service_lookup_from_network(network);
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_ASSOCIATION);
+   CONNMAN_SERVICE_STATE_ASSOCIATION,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
}
 
return 0;
@@ -519,7 +520,8 @@ static void set_associate_error(struct connman_network 
*network)
service = __connman_service_lookup_from_network(network);
 
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_FAILURE);
+   CONNMAN_SERVICE_STATE_FAILURE,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
 }
 
 static void set_configure_error(struct connman_network *network)
@@ -531,7 +533,8 @@ static void set_configure_error(struct connman_network 
*network)
service = __connman_service_lookup_from_network(network);
 
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_FAILURE);
+   CONNMAN_SERVICE_STATE_FAILURE,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
 }
 
 static void set_invalid_key_error(struct connman_network *network)
@@ -634,7 +637,8 @@ static void set_configuration(struct connman_network 
*network)
 
service = __connman_service_lookup_from_network(network);
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_CONFIGURATION);
+   CONNMAN_SERVICE_STATE_CONFIGURATION,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
 }
 
 static int set_connected_fixed(struct connman_network *network)

[PATCH ipv6 v2 09/15] network: Set service state correctly when ipconfig is cleared.

2011-02-08 Thread Jukka Rissanen
---
 src/network.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/network.c b/src/network.c
index c59a091..ec7666f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1094,12 +1094,14 @@ int __connman_network_clear_ipconfig(struct 
connman_network *network,
 {
struct connman_service *service;
enum connman_ipconfig_method method;
+   enum connman_ipconfig_type type;
 
service = __connman_service_lookup_from_network(network);
if (service == NULL)
return -EINVAL;
 
method = __connman_ipconfig_get_method(ipconfig);
+   type = __connman_ipconfig_get_config_type(ipconfig);
 
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
@@ -1117,7 +1119,12 @@ int __connman_network_clear_ipconfig(struct 
connman_network *network,
break;
}
 
-   __connman_service_indicate_state(service,
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_CONFIGURATION,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+   else if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+   __connman_service_indicate_state(service,
CONNMAN_SERVICE_STATE_CONFIGURATION,
CONNMAN_IPCONFIG_TYPE_IPV4);
 
-- 
1.7.0.4

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


[PATCH ipv6 v2 10/15] service: IPv6 autoconf will change the service state.

2011-02-08 Thread Jukka Rissanen
---
 src/service.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index 89f7b4d..28a8f6a 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4129,18 +4129,46 @@ static void service_lower_down(struct connman_ipconfig 
*ipconfig)
 static void service_ip_bound(struct connman_ipconfig *ipconfig)
 {
struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
 
connman_info(%s ip bound, connman_ipconfig_get_ifname(ipconfig));
 
+   type = __connman_ipconfig_get_config_type(ipconfig);
+   method = __connman_ipconfig_get_method(ipconfig);
+
+   DBG(service %p ipconfig %p type %d method %d, service, ipconfig,
+   type, method);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6 
+   method == CONNMAN_IPCONFIG_METHOD_AUTO)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_READY,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+
settings_changed(service);
 }
 
 static void service_ip_release(struct connman_ipconfig *ipconfig)
 {
struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
 
connman_info(%s ip release, connman_ipconfig_get_ifname(ipconfig));
 
+   type = __connman_ipconfig_get_config_type(ipconfig);
+   method = __connman_ipconfig_get_method(ipconfig);
+
+   DBG(service %p ipconfig %p type %d method %d, service, ipconfig,
+   type, method);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6 
+   method == CONNMAN_IPCONFIG_METHOD_OFF)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+
settings_changed(service);
 }
 
-- 
1.7.0.4

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


[PATCH ipv6 v2 11/15] service: Check service state properly if user changes method.

2011-02-08 Thread Jukka Rissanen
---
 src/service.c |   65 +++--
 1 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/src/service.c b/src/service.c
index 28a8f6a..2dff83a 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2012,6 +2012,49 @@ error:
return -EINVAL;
 }
 
+static int change_ipconfig_method(struct connman_service *service,
+   struct connman_ipconfig *ipconfig,
+   DBusMessageIter *array,
+   enum connman_service_state state,
+   enum connman_service_state *new_state)
+{
+   enum connman_ipconfig_method old_method;
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type;
+   int err;
+
+   old_method = __connman_ipconfig_get_method(ipconfig);
+
+   if (is_connecting_state(service, state) ||
+   is_connected_state(service, state))
+   __connman_network_clear_ipconfig(service-network, ipconfig);
+
+   err = __connman_ipconfig_set_config(ipconfig, array);
+   method = __connman_ipconfig_get_method(ipconfig);
+   type = __connman_ipconfig_get_config_type(ipconfig);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
+   if (err == 0  old_method == CONNMAN_IPCONFIG_METHOD_OFF 
+   method == CONNMAN_IPCONFIG_METHOD_DHCP) {
+   *new_state = service-state_ipv4 =
+   CONNMAN_SERVICE_STATE_CONFIGURATION;
+   __connman_ipconfig_enable(ipconfig);
+   }
+
+   } else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) {
+   if (err == 0  old_method == CONNMAN_IPCONFIG_METHOD_OFF 
+   method == CONNMAN_IPCONFIG_METHOD_AUTO) {
+   *new_state = service-state_ipv6;
+   __connman_ipconfig_enable(ipconfig);
+   }
+   }
+
+   DBG(err %d ipconfig %p type %d method %d state %s, err, ipconfig,
+   type, method, state2string(*new_state));
+
+   return err;
+}
+
 static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg, void *user_data)
 {
@@ -2242,26 +2285,16 @@ static DBusMessage *set_property(DBusConnection *conn,
return __connman_error_invalid_property(msg);
 
if (g_str_equal(name, IPv4.Configuration) == TRUE) {
-   state = service-state_ipv4;
-   if (is_connecting_state(service, state) ||
-   is_connected_state(service, state))
-   __connman_network_clear_ipconfig(
-   service-network,
-   service-ipconfig_ipv4);
-
ipv4 = service-ipconfig_ipv4;
-   err = __connman_ipconfig_set_config(ipv4, value);
+   err = change_ipconfig_method(service, ipv4, value,
+   service-state_ipv4,
+   state);
 
} else if (g_str_equal(name, IPv6.Configuration) == TRUE) {
-   state = service-state_ipv6;
-   if (is_connecting_state(service, state) ||
-   is_connected_state(service, state))
-   __connman_network_clear_ipconfig(
-   service-network,
-   service-ipconfig_ipv6);
-
ipv6 = service-ipconfig_ipv6;
-   err = __connman_ipconfig_set_config(ipv6, value);
+   err = change_ipconfig_method(service, ipv6, value,
+   service-state_ipv6,
+   state);
}
 
if (err  0) {
-- 
1.7.0.4

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


[PATCH ipv6 v2 13/15] ipconfig: Enable ipconfig if loading autoconfigurable IPv6 config.

2011-02-08 Thread Jukka Rissanen
---
 src/ipconfig.c |   15 ++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 0627b5b..1fb8281 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1782,8 +1782,21 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_OFF)
disable_ipv6(ipconfig);
else if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_AUTO ||
-   ipconfig-method == CONNMAN_IPCONFIG_METHOD_MANUAL)
+   ipconfig-method == CONNMAN_IPCONFIG_METHOD_MANUAL) {
enable_ipv6(ipconfig);
+   __connman_ipconfig_enable(ipconfig);
+
+   if (ipconfig-ops_data) {
+   struct connman_service *service =
+   ipconfig-ops_data;
+   struct connman_network *network;
+   network = __connman_service_get_network(
+   service);
+   if (network)
+   __connman_network_set_ipconfig(network,
+   NULL, ipconfig);
+   }
+   }
}
 
g_free(method);
-- 
1.7.0.4

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


[PATCH ipv6 v2 12/15] service: Change IPv4 state when address is released.

2011-02-08 Thread Jukka Rissanen
---
 src/service.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index 2dff83a..ff20e42 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4202,6 +4202,12 @@ static void service_ip_release(struct connman_ipconfig 
*ipconfig)
CONNMAN_SERVICE_STATE_DISCONNECT,
CONNMAN_IPCONFIG_TYPE_IPV6);
 
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV4 
+   method == CONNMAN_IPCONFIG_METHOD_OFF)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
+
settings_changed(service);
 }
 
-- 
1.7.0.4

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


[PATCH ipv6 v2 14/15] service: Do not change state if combined state does not change.

2011-02-08 Thread Jukka Rissanen
---
 src/service.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index ff20e42..a5ade8d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3344,6 +3344,9 @@ int __connman_service_indicate_state(struct 
connman_service *service,
else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
service-state_ipv6 = new_state;
 
+   if (state == service_state)
+   return -EALREADY;
+
state_changed(service);
 
if (state == CONNMAN_SERVICE_STATE_ONLINE) {
-- 
1.7.0.4

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


[PATCH ipv6 v3 00/12] Support IPv6 only networks

2011-02-10 Thread Jukka Rissanen
Hi Samuel,

here is the v3 of the IPv6 only patchset.
Following changes were done compared to v2:

#4: merged patch #14 from v2
#6: removed this patch as it was useless
#7: patch #8 from v2 merged, fixed also line len
#11: changed the func name


Regards,
Jukka



Jukka Rissanen (12):
  ipconfig: Clear the ipaddress pointers when address is deleted.
  ipv6: Add property for IPv6 nameserver
  ipconfig: Added helper function that returns the config type.
  service: Split service state to IPv4 and IPv6 parts.
  ipconfig: Enable or disable IPv6 when loading the saved service.
  network: Enable IPv6 autoconf to change the service state to ready.
  network: Set service state correctly when ipconfig is cleared.
  service: IPv6 autoconf will change the service state.
  service: Check service state properly if user changes method.
  service: Change IPv4 state when address is released.
  ipconfig: Enable ipconfig if loading autoconfigurable IPv6 config.
  todo: Remove IPv6 enhancements as they are implemented.

 TODO   |   13 --
 include/property.h |1 +
 src/connection.c   |6 +-
 src/connman.h  |5 +-
 src/ipconfig.c |   30 -
 src/location.c |3 +-
 src/network.c  |   72 --
 src/provider.c |   27 +++--
 src/service.c  |  397 
 9 files changed, 457 insertions(+), 97 deletions(-)

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


[PATCH ipv6 v3 03/12] ipconfig: Added helper function that returns the config type.

2011-02-10 Thread Jukka Rissanen
---
 src/connman.h  |2 ++
 src/ipconfig.c |6 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 992d533..7f18ff4 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -218,6 +218,8 @@ void __connman_ipconfig_delroute(int index, int family, 
unsigned char scope,
 
 void __connman_ipconfig_foreach(void (*function) (int index, void *user_data),
void *user_data);
+enum connman_ipconfig_type __connman_ipconfig_get_config_type(
+   struct connman_ipconfig *ipconfig);
 unsigned short __connman_ipconfig_get_type(int index);
 unsigned int __connman_ipconfig_get_flags(int index);
 const char *__connman_ipconfig_get_gateway(int index);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index bd664f3..4d9b30f 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -853,6 +853,12 @@ void __connman_ipconfig_foreach(void (*function) (int 
index, void *user_data),
g_list_free(keys);
 }
 
+enum connman_ipconfig_type __connman_ipconfig_get_config_type(
+   struct connman_ipconfig *ipconfig)
+{
+   return ipconfig ? ipconfig-type : CONNMAN_IPCONFIG_TYPE_UNKNOWN;
+}
+
 unsigned short __connman_ipconfig_get_type(int index)
 {
struct connman_ipdevice *ipdevice;
-- 
1.7.0.4

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


[PATCH ipv6 v3 01/12] ipconfig: Clear the ipaddress pointers when address is deleted.

2011-02-10 Thread Jukka Rissanen
---
 src/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 6ef39c5..bd664f3 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -682,7 +682,8 @@ void __connman_ipconfig_deladdr(int index, int family, 
const char *label,
ipdevice-address_list = g_slist_remove(ipdevice-address_list,
ipaddress);
 
-   connman_ipaddress_free(ipaddress);
+   connman_ipaddress_clear(ipaddress);
+   g_free(ipaddress);
 
connman_info(%s {del} address %s/%u label %s, ipdevice-ifname,
address, prefixlen, label);
-- 
1.7.0.4

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


[PATCH ipv6 v3 02/12] ipv6: Add property for IPv6 nameserver

2011-02-10 Thread Jukka Rissanen
---
 include/property.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/property.h b/include/property.h
index e18e1e9..487a170 100644
--- a/include/property.h
+++ b/include/property.h
@@ -57,6 +57,7 @@ enum connman_property_id {
CONNMAN_PROPERTY_ID_IPV6_ADDRESS,
CONNMAN_PROPERTY_ID_IPV6_PREFIXLEN,
CONNMAN_PROPERTY_ID_IPV6_GATEWAY,
+   CONNMAN_PROPERTY_ID_IPV6_NAMESERVER,
 };
 
 enum connman_property_type {
-- 
1.7.0.4

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


[PATCH ipv6 v3 05/12] ipconfig: Enable or disable IPv6 when loading the saved service.

2011-02-10 Thread Jukka Rissanen
---
 src/ipconfig.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 4d9b30f..0627b5b 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1778,6 +1778,14 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
ipconfig-method = CONNMAN_IPCONFIG_METHOD_OFF;
 
+   if (ipconfig-type == CONNMAN_IPCONFIG_TYPE_IPV6) {
+   if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_OFF)
+   disable_ipv6(ipconfig);
+   else if (ipconfig-method == CONNMAN_IPCONFIG_METHOD_AUTO ||
+   ipconfig-method == CONNMAN_IPCONFIG_METHOD_MANUAL)
+   enable_ipv6(ipconfig);
+   }
+
g_free(method);
g_free(key);
 
-- 
1.7.0.4

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


[PATCH ipv6 v3 06/12] network: Enable IPv6 autoconf to change the service state to ready.

2011-02-10 Thread Jukka Rissanen
---
 src/network.c |   43 +--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/network.c b/src/network.c
index c3febd3..7a4d931 100644
--- a/src/network.c
+++ b/src/network.c
@@ -768,6 +768,37 @@ static int manual_ipv6_set(struct connman_network *network,
return 0;
 }
 
+static void autoconf_ipv6_set(struct connman_network *network,
+   struct connman_ipconfig *ipconfig_ipv6)
+{
+   struct connman_service *service;
+   struct connman_ipconfig *ipconfig;
+   const char *nameserver = NULL;
+
+   DBG(network %p, network);
+
+   service = __connman_service_lookup_from_network(network);
+
+   ipconfig = __connman_service_get_ip6config(service);
+
+   __connman_device_increase_connections(network-device);
+
+   __connman_device_set_network(network-device, network);
+
+   connman_device_set_disconnected(network-device, FALSE);
+
+   connman_element_get_value(network-element,
+   CONNMAN_PROPERTY_ID_IPV6_NAMESERVER, nameserver);
+   if (nameserver != NULL)
+   __connman_service_append_nameserver(service, nameserver);
+
+   network-connecting = FALSE;
+
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_READY,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+}
+
 static gboolean set_connected(gpointer user_data)
 {
struct connman_network *network = user_data;
@@ -795,7 +826,9 @@ static gboolean set_connected(gpointer user_data)
switch (ipv6_method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
+   break;
case CONNMAN_IPCONFIG_METHOD_AUTO:
+   autoconf_ipv6_set(network, ipconfig_ipv6);
break;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
@@ -844,8 +877,12 @@ static gboolean set_connected(gpointer user_data)
service = __connman_service_lookup_from_network(network);
 
__connman_service_indicate_state(service,
-   CONNMAN_SERVICE_STATE_IDLE,
-   CONNMAN_IPCONFIG_TYPE_IPV4);
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
+
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
}
 
network-connecting = FALSE;
@@ -1100,7 +1137,9 @@ int __connman_network_set_ipconfig(struct connman_network 
*network,
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
+   break;
case CONNMAN_IPCONFIG_METHOD_AUTO:
+   autoconf_ipv6_set(network, ipconfig_ipv6);
break;
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
-- 
1.7.0.4

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


[PATCH ipv6 v3 07/12] network: Set service state correctly when ipconfig is cleared.

2011-02-10 Thread Jukka Rissanen
---
 src/network.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/network.c b/src/network.c
index 7a4d931..240da89 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1094,12 +1094,14 @@ int __connman_network_clear_ipconfig(struct 
connman_network *network,
 {
struct connman_service *service;
enum connman_ipconfig_method method;
+   enum connman_ipconfig_type type;
 
service = __connman_service_lookup_from_network(network);
if (service == NULL)
return -EINVAL;
 
method = __connman_ipconfig_get_method(ipconfig);
+   type = __connman_ipconfig_get_config_type(ipconfig);
 
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
@@ -1117,7 +1119,12 @@ int __connman_network_clear_ipconfig(struct 
connman_network *network,
break;
}
 
-   __connman_service_indicate_state(service,
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_CONFIGURATION,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+   else if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+   __connman_service_indicate_state(service,
CONNMAN_SERVICE_STATE_CONFIGURATION,
CONNMAN_IPCONFIG_TYPE_IPV4);
 
-- 
1.7.0.4

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


[PATCH ipv6 v3 08/12] service: IPv6 autoconf will change the service state.

2011-02-10 Thread Jukka Rissanen
---
 src/service.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index 5db3bae..1b8e42a 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4123,18 +4123,46 @@ static void service_lower_down(struct connman_ipconfig 
*ipconfig)
 static void service_ip_bound(struct connman_ipconfig *ipconfig)
 {
struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
 
connman_info(%s ip bound, connman_ipconfig_get_ifname(ipconfig));
 
+   type = __connman_ipconfig_get_config_type(ipconfig);
+   method = __connman_ipconfig_get_method(ipconfig);
+
+   DBG(service %p ipconfig %p type %d method %d, service, ipconfig,
+   type, method);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6 
+   method == CONNMAN_IPCONFIG_METHOD_AUTO)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_READY,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+
settings_changed(service);
 }
 
 static void service_ip_release(struct connman_ipconfig *ipconfig)
 {
struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
 
connman_info(%s ip release, connman_ipconfig_get_ifname(ipconfig));
 
+   type = __connman_ipconfig_get_config_type(ipconfig);
+   method = __connman_ipconfig_get_method(ipconfig);
+
+   DBG(service %p ipconfig %p type %d method %d, service, ipconfig,
+   type, method);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6 
+   method == CONNMAN_IPCONFIG_METHOD_OFF)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+
settings_changed(service);
 }
 
-- 
1.7.0.4

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


[PATCH ipv6 v3 09/12] service: Check service state properly if user changes method.

2011-02-10 Thread Jukka Rissanen
---
 src/service.c |   63 ++--
 1 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/src/service.c b/src/service.c
index 1b8e42a..07fa7f6 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2012,6 +2012,49 @@ error:
return -EINVAL;
 }
 
+static int set_ipconfig(struct connman_service *service,
+   struct connman_ipconfig *ipconfig,
+   DBusMessageIter *array,
+   enum connman_service_state state,
+   enum connman_service_state *new_state)
+{
+   enum connman_ipconfig_method old_method;
+   enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+   enum connman_ipconfig_type type;
+   int err;
+
+   old_method = __connman_ipconfig_get_method(ipconfig);
+
+   if (is_connecting_state(service, state) ||
+   is_connected_state(service, state))
+   __connman_network_clear_ipconfig(service-network, ipconfig);
+
+   err = __connman_ipconfig_set_config(ipconfig, array);
+   method = __connman_ipconfig_get_method(ipconfig);
+   type = __connman_ipconfig_get_config_type(ipconfig);
+
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
+   if (err == 0  old_method == CONNMAN_IPCONFIG_METHOD_OFF 
+   method == CONNMAN_IPCONFIG_METHOD_DHCP) {
+   *new_state = service-state_ipv4 =
+   CONNMAN_SERVICE_STATE_CONFIGURATION;
+   __connman_ipconfig_enable(ipconfig);
+   }
+
+   } else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) {
+   if (err == 0  old_method == CONNMAN_IPCONFIG_METHOD_OFF 
+   method == CONNMAN_IPCONFIG_METHOD_AUTO) {
+   *new_state = service-state_ipv6;
+   __connman_ipconfig_enable(ipconfig);
+   }
+   }
+
+   DBG(err %d ipconfig %p type %d method %d state %s, err, ipconfig,
+   type, method, state2string(*new_state));
+
+   return err;
+}
+
 static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg, void *user_data)
 {
@@ -2242,26 +2285,14 @@ static DBusMessage *set_property(DBusConnection *conn,
return __connman_error_invalid_property(msg);
 
if (g_str_equal(name, IPv4.Configuration) == TRUE) {
-   state = service-state_ipv4;
-   if (is_connecting_state(service, state) ||
-   is_connected_state(service, state))
-   __connman_network_clear_ipconfig(
-   service-network,
-   service-ipconfig_ipv4);
-
ipv4 = service-ipconfig_ipv4;
-   err = __connman_ipconfig_set_config(ipv4, value);
+   err = set_ipconfig(service, ipv4, value,
+   service-state_ipv4, state);
 
} else if (g_str_equal(name, IPv6.Configuration) == TRUE) {
-   state = service-state_ipv6;
-   if (is_connecting_state(service, state) ||
-   is_connected_state(service, state))
-   __connman_network_clear_ipconfig(
-   service-network,
-   service-ipconfig_ipv6);
-
ipv6 = service-ipconfig_ipv6;
-   err = __connman_ipconfig_set_config(ipv6, value);
+   err = set_ipconfig(service, ipv6, value,
+   service-state_ipv6, state);
}
 
if (err  0) {
-- 
1.7.0.4

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


[PATCH ipv6 v3 10/12] service: Change IPv4 state when address is released.

2011-02-10 Thread Jukka Rissanen
---
 src/service.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index 07fa7f6..7751dc0 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4194,6 +4194,12 @@ static void service_ip_release(struct connman_ipconfig 
*ipconfig)
CONNMAN_SERVICE_STATE_DISCONNECT,
CONNMAN_IPCONFIG_TYPE_IPV6);
 
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV4 
+   method == CONNMAN_IPCONFIG_METHOD_OFF)
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV4);
+
settings_changed(service);
 }
 
-- 
1.7.0.4

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


[PATCH ipv6 v3 12/12] todo: Remove IPv6 enhancements as they are implemented.

2011-02-10 Thread Jukka Rissanen
---
 TODO |   13 -
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/TODO b/TODO
index 7ae6974..371eb07 100644
--- a/TODO
+++ b/TODO
@@ -67,19 +67,6 @@ Core
credentials, ConnMan should be able to initiate a WiSPR authentication.
 
 
-- IPv6 enhancements
-
-   Priority: High
-   Complexity: C8
-   Owner: Jukka Rissanen jukka.rissa...@nokia.com
-
-   Support IPv6 only networks so that system can go online even if
-   there is no IPv4 address. Also support more than one IPv6 address
-   in one device so that the addresses are reported correctly via
-   dbus interface. The autoconf IPv6 addresses need also some tweaking
-   so that system will go online properly.
-
-
 WiFi
 
 
-- 
1.7.0.4

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


[PATCH] network: IPv6 must go through disconnect state before idle.

2011-02-11 Thread Jukka Rissanen
---
Hi Samuel,

please apply this patch as without it the system will not go offline.
The patch adds DISCONNECT state for IPv6 that should be entered before
IDLE state. Eventually the IPv6 disconnection should be handled in
connection.c as you pointed out in IRC but that probably needs to
wait until Daniel's element removal patches are commited.

Regards,
Jukka


 src/network.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/network.c b/src/network.c
index 5bba620..be2cae5 100644
--- a/src/network.c
+++ b/src/network.c
@@ -880,6 +880,13 @@ static gboolean set_connected(gpointer user_data)
CONNMAN_SERVICE_STATE_IDLE,
CONNMAN_IPCONFIG_TYPE_IPV4);
 
+   /* TODO: eventually the IPv6 disconnect state should be handled
+* in connection.c
+*/
+   __connman_service_indicate_state(service,
+   CONNMAN_SERVICE_STATE_DISCONNECT,
+   CONNMAN_IPCONFIG_TYPE_IPV6);
+
__connman_service_indicate_state(service,
CONNMAN_SERVICE_STATE_IDLE,
CONNMAN_IPCONFIG_TYPE_IPV6);
-- 
1.7.0.4

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


  1   2   3   4   5   6   7   8   9   10   >