Re: [PATCH dhcp 1/4] service: Remember last DHCP IP address.

2011-07-27 Thread Jukka Rissanen

Hi Daniel,

On 07/26/2011 06:44 PM, Daniel Wagner wrote:

Hi Jukka

On 07/26/2011 01:29 PM, Jukka Rissanen wrote:

---
  src/connman.h |3 +++
  src/service.c |   36 
  2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 408b809..e687502 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -552,6 +552,9 @@ void __connman_service_notify(struct connman_service 
*service,

  int __connman_service_counter_register(const char *counter);
  void __connman_service_counter_unregister(const char *counter);
+void __connman_service_set_dhcp_address(struct connman_service *service,
+   const char *address);
+char *__connman_service_get_dhcp_address(struct connman_service *service);


This looks like the wrong place to me storing the last IP address.
Wouldn't it make more sense to add this kind of thing to ipconfig? We
might even want to do this for IPv6, no?

cheers,
daniel



Yes, that is certainly possible. I can send a new version where the last 
address is in ipconfig.



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


[PATCH dhcp v2 2/2] dhcp: Try to reuse the IP address we had last time.

2011-07-27 Thread Jukka Rissanen
This fix sends the DHCP_REQUESTED_IP option to server.

Fixes BMC #21068
---
 gdhcp/client.c|   22 ++
 gdhcp/gdhcp.h |2 +-
 src/dhcp.c|   23 ++-
 tools/dhcp-test.c |2 +-
 4 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/gdhcp/client.c b/gdhcp/client.c
index 0cf39cd..9ac7752 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -109,6 +109,7 @@ struct _GDHCPClient {
gpointer address_conflict_data;
GDHCPDebugFunc debug_func;
gpointer debug_data;
+   char *last_address;
 };
 
 static inline void debug(GDHCPClient *client, const char *format, ...)
@@ -879,7 +880,7 @@ static void restart_dhcp(GDHCPClient *dhcp_client, int 
retry_times)
dhcp_client->requested_ip = 0;
switch_listening_mode(dhcp_client, L2);
 
-   g_dhcp_client_start(dhcp_client);
+   g_dhcp_client_start(dhcp_client, dhcp_client->last_address);
 }
 
 static gboolean start_rebound_timeout(gpointer user_data)
@@ -1240,7 +1241,7 @@ static gboolean discover_timeout(gpointer user_data)
 
dhcp_client->retry_times++;
 
-   g_dhcp_client_start(dhcp_client);
+   g_dhcp_client_start(dhcp_client, dhcp_client->last_address);
 
return FALSE;
 }
@@ -1306,9 +1307,10 @@ static gboolean ipv4ll_probe_timeout(gpointer dhcp_data)
return FALSE;
 }
 
-int g_dhcp_client_start(GDHCPClient *dhcp_client)
+int g_dhcp_client_start(GDHCPClient *dhcp_client, const char *last_address)
 {
int re;
+   uint32_t addr;
 
if (dhcp_client->retry_times == DISCOVER_RETRIES) {
ipv4ll_start(dhcp_client);
@@ -1327,7 +1329,18 @@ int g_dhcp_client_start(GDHCPClient *dhcp_client)
dhcp_client->xid = rand();
}
 
-   send_discover(dhcp_client, 0);
+   if (last_address == NULL)
+   addr = 0;
+   else {
+   addr = inet_addr(last_address);
+   if (addr == 0x)
+   addr = 0;
+   else {
+   g_free(dhcp_client->last_address);
+   dhcp_client->last_address = g_strdup(last_address);
+   }
+   }
+   send_discover(dhcp_client, addr);
 
dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
DISCOVER_TIMEOUT,
@@ -1505,6 +1518,7 @@ void g_dhcp_client_unref(GDHCPClient *dhcp_client)
 
g_free(dhcp_client->interface);
g_free(dhcp_client->assigned_ip);
+   g_free(dhcp_client->last_address);
 
g_list_free(dhcp_client->request_list);
g_list_free(dhcp_client->require_list);
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index 4f583ff..d89446e 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -73,7 +73,7 @@ typedef void (*GDHCPDebugFunc)(const char *str, gpointer 
user_data);
 GDHCPClient *g_dhcp_client_new(GDHCPType type, int index,
GDHCPClientError *error);
 
-int g_dhcp_client_start(GDHCPClient *client);
+int g_dhcp_client_start(GDHCPClient *client, const char *last_address);
 void g_dhcp_client_stop(GDHCPClient *client);
 
 GDHCPClient *g_dhcp_client_ref(GDHCPClient *client);
diff --git a/src/dhcp.c b/src/dhcp.c
index 20fc599..63edfe9 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -42,6 +42,7 @@ struct connman_dhcp {
char **nameservers;
char *timeserver;
char *pac;
+   char *last_address;
 
GDHCPClient *dhcp_client;
 };
@@ -53,10 +54,12 @@ static void dhcp_free(struct connman_dhcp *dhcp)
g_strfreev(dhcp->nameservers);
g_free(dhcp->timeserver);
g_free(dhcp->pac);
+   g_free(dhcp->last_address);
 
dhcp->nameservers = NULL;
dhcp->timeserver = NULL;
dhcp->pac = NULL;
+   dhcp->last_address = NULL;
 }
 
 /**
@@ -103,6 +106,10 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, 
connman_bool_t callback)
}
}
 
+   __connman_ipconfig_set_dhcp_address(ipconfig, dhcp->last_address);
+
+   DBG("last address %s", dhcp->last_address);
+
__connman_ipconfig_address_remove(ipconfig);
 
__connman_ipconfig_set_local(ipconfig, NULL);
@@ -204,6 +211,12 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
 
address = g_dhcp_client_get_address(dhcp_client);
 
+   g_free(dhcp->last_address);
+   dhcp->last_address = g_strdup(address);
+   __connman_ipconfig_set_dhcp_address(ipconfig, dhcp->last_address);
+
+   DBG("last address %s", address);
+
option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET);
if (option != NULL)
netmask = g_strdup(option->data);
@@ -409,7 +422,7 @@ static int dhcp_request(struct connman_dhcp *dhcp)
 
dhcp->dhcp_client = dhcp_client;
 
-   return g_dhcp_client_start(dhcp_client);
+   return g_dhcp_client_start(dhcp_client, dhcp->last_address);
 }
 
 sta

[PATCH dhcp v2 0/2] Reuse last IP address.

2011-07-27 Thread Jukka Rissanen
Hi,

changes in this v2 patch:
- The IP address is saved in ipconfig instead of service
- I also merged three patches to one so that they do not
  break the build.

The following patchset fixes the problem in bug #21068
https://bugs.meego.com/show_bug.cgi?id=21068

We suggest the DHCP server to give us the IP address we had
last time. This is done by sending the DHCP REQUESTED IP option
to server.

Regards,
Jukka


Jukka Rissanen (2):
  ipconfig: Remember last DHCP IP address.
  dhcp: Try to reuse the IP address we had last time.

 gdhcp/client.c|   22 ++
 gdhcp/gdhcp.h |2 +-
 src/connman.h |3 +++
 src/dhcp.c|   23 ++-
 src/ipconfig.c|   40 +++-
 tools/dhcp-test.c |2 +-
 6 files changed, 84 insertions(+), 8 deletions(-)

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


[PATCH dhcp v2 1/2] ipconfig: Remember last DHCP IP address.

2011-07-27 Thread Jukka Rissanen
---
 src/connman.h  |3 +++
 src/ipconfig.c |   40 +++-
 2 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 408b809..d6acae4 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -257,6 +257,9 @@ unsigned char __connman_ipconfig_netmask_prefix_len(const 
char *netmask);
 int __connman_ipconfig_set_proxy_autoconfig(struct connman_ipconfig *ipconfig,
const char *url);
 const char *__connman_ipconfig_get_proxy_autoconfig(struct connman_ipconfig 
*ipconfig);
+void __connman_ipconfig_set_dhcp_address(struct connman_ipconfig *ipconfig,
+   const char *address);
+char *__connman_ipconfig_get_dhcp_address(struct connman_ipconfig *ipconfig);
 
 int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 9f73b65..7fb56a4 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -54,6 +54,7 @@ struct connman_ipconfig {
struct connman_ipaddress *system;
 
int ipv6_privacy_config;
+   char *last_dynamic_ip_address;
 };
 
 struct connman_ipdevice {
@@ -1286,6 +1287,7 @@ void connman_ipconfig_unref(struct connman_ipconfig 
*ipconfig)
 
connman_ipaddress_free(ipconfig->system);
connman_ipaddress_free(ipconfig->address);
+   g_free(ipconfig->last_dynamic_ip_address);
g_free(ipconfig);
}
 }
@@ -1518,6 +1520,24 @@ const char 
*__connman_ipconfig_get_proxy_autoconfig(struct connman_ipconfig *ipc
return ipdevice->pac;
 }
 
+void __connman_ipconfig_set_dhcp_address(struct connman_ipconfig *ipconfig,
+   const char *address)
+{
+   if (ipconfig == NULL)
+   return;
+
+   g_free(ipconfig->last_dynamic_ip_address);
+   ipconfig->last_dynamic_ip_address = g_strdup(address);
+}
+
+char *__connman_ipconfig_get_dhcp_address(struct connman_ipconfig *ipconfig)
+{
+   if (ipconfig == NULL)
+   return NULL;
+
+   return g_strdup(ipconfig->last_dynamic_ip_address);
+}
+
 static void disable_ipv6(struct connman_ipconfig *ipconfig)
 {
struct connman_ipdevice *ipdevice;
@@ -2080,6 +2100,7 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
 {
char *method;
char *key;
+   char *str;
 
DBG("ipconfig %p identifier %s", ipconfig, identifier);
 
@@ -2140,6 +2161,14 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
keyfile, identifier, key, NULL);
g_free(key);
 
+   key = g_strdup_printf("%sDHCP.LastAddress", prefix);
+   str = g_key_file_get_string(keyfile, identifier, key, NULL);
+   if (str != NULL) {
+   g_free(ipconfig->last_dynamic_ip_address);
+   ipconfig->last_dynamic_ip_address = str;
+   }
+   g_free(key);
+
return 0;
 }
 
@@ -2169,9 +2198,18 @@ int __connman_ipconfig_save(struct connman_ipconfig 
*ipconfig,
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
break;
+   case CONNMAN_IPCONFIG_METHOD_DHCP:
+   key = g_strdup_printf("%sDHCP.LastAddress", prefix);
+   if (ipconfig->last_dynamic_ip_address != NULL &&
+   strlen(ipconfig->last_dynamic_ip_address) > 0)
+   g_key_file_set_string(keyfile, identifier, key,
+   ipconfig->last_dynamic_ip_address);
+   else
+   g_key_file_remove_key(keyfile, identifier, key, NULL);
+   g_free(key);
+   /* fall through */
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
-   case CONNMAN_IPCONFIG_METHOD_DHCP:
case CONNMAN_IPCONFIG_METHOD_AUTO:
return 0;
}
-- 
1.7.1

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


Re: [PATCH dhcp v2 0/2] Reuse last IP address.

2011-07-27 Thread Jukka Rissanen
I just noticed that this patch is not yet ready. I missed the 
non-authoritative server case where the server ignores the request with 
REQUESTED IP option. I will send a new version soonish.


Jukka


On 07/27/2011 01:58 PM, Jukka Rissanen wrote:

Hi,

changes in this v2 patch:
- The IP address is saved in ipconfig instead of service
- I also merged three patches to one so that they do not
   break the build.

The following patchset fixes the problem in bug #21068
https://bugs.meego.com/show_bug.cgi?id=21068

We suggest the DHCP server to give us the IP address we had
last time. This is done by sending the DHCP REQUESTED IP option
to server.

Regards,
Jukka


Jukka Rissanen (2):
   ipconfig: Remember last DHCP IP address.
   dhcp: Try to reuse the IP address we had last time.

  gdhcp/client.c|   22 ++
  gdhcp/gdhcp.h |2 +-
  src/connman.h |3 +++
  src/dhcp.c|   23 ++-
  src/ipconfig.c|   40 +++-
  tools/dhcp-test.c |2 +-
  6 files changed, 84 insertions(+), 8 deletions(-)




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


[PATCH dhcp v3 1/2] ipconfig: Remember last DHCP IP address.

2011-07-27 Thread Jukka Rissanen
---
 src/connman.h  |3 +++
 src/ipconfig.c |   40 +++-
 2 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 681b29f..3fc5a8a 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -257,6 +257,9 @@ unsigned char __connman_ipconfig_netmask_prefix_len(const 
char *netmask);
 int __connman_ipconfig_set_proxy_autoconfig(struct connman_ipconfig *ipconfig,
const char *url);
 const char *__connman_ipconfig_get_proxy_autoconfig(struct connman_ipconfig 
*ipconfig);
+void __connman_ipconfig_set_dhcp_address(struct connman_ipconfig *ipconfig,
+   const char *address);
+char *__connman_ipconfig_get_dhcp_address(struct connman_ipconfig *ipconfig);
 
 int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 9f73b65..7fb56a4 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -54,6 +54,7 @@ struct connman_ipconfig {
struct connman_ipaddress *system;
 
int ipv6_privacy_config;
+   char *last_dynamic_ip_address;
 };
 
 struct connman_ipdevice {
@@ -1286,6 +1287,7 @@ void connman_ipconfig_unref(struct connman_ipconfig 
*ipconfig)
 
connman_ipaddress_free(ipconfig->system);
connman_ipaddress_free(ipconfig->address);
+   g_free(ipconfig->last_dynamic_ip_address);
g_free(ipconfig);
}
 }
@@ -1518,6 +1520,24 @@ const char 
*__connman_ipconfig_get_proxy_autoconfig(struct connman_ipconfig *ipc
return ipdevice->pac;
 }
 
+void __connman_ipconfig_set_dhcp_address(struct connman_ipconfig *ipconfig,
+   const char *address)
+{
+   if (ipconfig == NULL)
+   return;
+
+   g_free(ipconfig->last_dynamic_ip_address);
+   ipconfig->last_dynamic_ip_address = g_strdup(address);
+}
+
+char *__connman_ipconfig_get_dhcp_address(struct connman_ipconfig *ipconfig)
+{
+   if (ipconfig == NULL)
+   return NULL;
+
+   return g_strdup(ipconfig->last_dynamic_ip_address);
+}
+
 static void disable_ipv6(struct connman_ipconfig *ipconfig)
 {
struct connman_ipdevice *ipdevice;
@@ -2080,6 +2100,7 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
 {
char *method;
char *key;
+   char *str;
 
DBG("ipconfig %p identifier %s", ipconfig, identifier);
 
@@ -2140,6 +2161,14 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
keyfile, identifier, key, NULL);
g_free(key);
 
+   key = g_strdup_printf("%sDHCP.LastAddress", prefix);
+   str = g_key_file_get_string(keyfile, identifier, key, NULL);
+   if (str != NULL) {
+   g_free(ipconfig->last_dynamic_ip_address);
+   ipconfig->last_dynamic_ip_address = str;
+   }
+   g_free(key);
+
return 0;
 }
 
@@ -2169,9 +2198,18 @@ int __connman_ipconfig_save(struct connman_ipconfig 
*ipconfig,
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
break;
+   case CONNMAN_IPCONFIG_METHOD_DHCP:
+   key = g_strdup_printf("%sDHCP.LastAddress", prefix);
+   if (ipconfig->last_dynamic_ip_address != NULL &&
+   strlen(ipconfig->last_dynamic_ip_address) > 0)
+   g_key_file_set_string(keyfile, identifier, key,
+   ipconfig->last_dynamic_ip_address);
+   else
+   g_key_file_remove_key(keyfile, identifier, key, NULL);
+   g_free(key);
+   /* fall through */
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
-   case CONNMAN_IPCONFIG_METHOD_DHCP:
case CONNMAN_IPCONFIG_METHOD_AUTO:
return 0;
}
-- 
1.7.1

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


[PATCH dhcp v3 0/2] Reuse last IP address.

2011-07-27 Thread Jukka Rissanen
Hi,

changes in v3:
- Do not send REQUESTED IP option in resend because
  the non-authoritative server case will drop those
  packets

changes in v2:
- The IP address is saved in ipconfig instead of service
- I also merged three patches to one so that they do not
  break the build.

The following patchset fixes the problem in bug #21068
https://bugs.meego.com/show_bug.cgi?id=21068

We suggest the DHCP server to give us the IP address we had
last time. This is done by sending the DHCP REQUESTED IP option
to server.

Regards,
Jukka


Jukka Rissanen (2):
  ipconfig: Remember last DHCP IP address.
  dhcp: Try to reuse the IP address we had last time.

 gdhcp/client.c|   27 +++
 gdhcp/gdhcp.h |2 +-
 src/connman.h |3 +++
 src/dhcp.c|   23 ++-
 src/ipconfig.c|   40 +++-
 tools/dhcp-test.c |2 +-
 6 files changed, 89 insertions(+), 8 deletions(-)

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


[PATCH dhcp v3 2/2] dhcp: Try to reuse the IP address we had last time.

2011-07-27 Thread Jukka Rissanen
This fix will cause the DHCP_REQUESTED_IP option to be sent to
the server.

Fixes BMC #21068
---
 gdhcp/client.c|   27 +++
 gdhcp/gdhcp.h |2 +-
 src/dhcp.c|   23 ++-
 tools/dhcp-test.c |2 +-
 4 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/gdhcp/client.c b/gdhcp/client.c
index 0cf39cd..f491f5c 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -109,6 +109,7 @@ struct _GDHCPClient {
gpointer address_conflict_data;
GDHCPDebugFunc debug_func;
gpointer debug_data;
+   char *last_address;
 };
 
 static inline void debug(GDHCPClient *client, const char *format, ...)
@@ -879,7 +880,7 @@ static void restart_dhcp(GDHCPClient *dhcp_client, int 
retry_times)
dhcp_client->requested_ip = 0;
switch_listening_mode(dhcp_client, L2);
 
-   g_dhcp_client_start(dhcp_client);
+   g_dhcp_client_start(dhcp_client, dhcp_client->last_address);
 }
 
 static gboolean start_rebound_timeout(gpointer user_data)
@@ -1240,7 +1241,12 @@ static gboolean discover_timeout(gpointer user_data)
 
dhcp_client->retry_times++;
 
-   g_dhcp_client_start(dhcp_client);
+   /*
+* We do not send the REQUESTED IP option if we are retrying because
+* if the server is non-authoritative it will ignore the request if the
+* option is present.
+*/
+   g_dhcp_client_start(dhcp_client, NULL);
 
return FALSE;
 }
@@ -1306,9 +1312,10 @@ static gboolean ipv4ll_probe_timeout(gpointer dhcp_data)
return FALSE;
 }
 
-int g_dhcp_client_start(GDHCPClient *dhcp_client)
+int g_dhcp_client_start(GDHCPClient *dhcp_client, const char *last_address)
 {
int re;
+   uint32_t addr;
 
if (dhcp_client->retry_times == DISCOVER_RETRIES) {
ipv4ll_start(dhcp_client);
@@ -1327,7 +1334,18 @@ int g_dhcp_client_start(GDHCPClient *dhcp_client)
dhcp_client->xid = rand();
}
 
-   send_discover(dhcp_client, 0);
+   if (last_address == NULL)
+   addr = 0;
+   else {
+   addr = inet_addr(last_address);
+   if (addr == 0x)
+   addr = 0;
+   else {
+   g_free(dhcp_client->last_address);
+   dhcp_client->last_address = g_strdup(last_address);
+   }
+   }
+   send_discover(dhcp_client, addr);
 
dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
DISCOVER_TIMEOUT,
@@ -1505,6 +1523,7 @@ void g_dhcp_client_unref(GDHCPClient *dhcp_client)
 
g_free(dhcp_client->interface);
g_free(dhcp_client->assigned_ip);
+   g_free(dhcp_client->last_address);
 
g_list_free(dhcp_client->request_list);
g_list_free(dhcp_client->require_list);
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index 4f583ff..d89446e 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -73,7 +73,7 @@ typedef void (*GDHCPDebugFunc)(const char *str, gpointer 
user_data);
 GDHCPClient *g_dhcp_client_new(GDHCPType type, int index,
GDHCPClientError *error);
 
-int g_dhcp_client_start(GDHCPClient *client);
+int g_dhcp_client_start(GDHCPClient *client, const char *last_address);
 void g_dhcp_client_stop(GDHCPClient *client);
 
 GDHCPClient *g_dhcp_client_ref(GDHCPClient *client);
diff --git a/src/dhcp.c b/src/dhcp.c
index 39f4eeb..0e31e86 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -42,6 +42,7 @@ struct connman_dhcp {
char **nameservers;
char *timeserver;
char *pac;
+   char *last_address;
 
GDHCPClient *dhcp_client;
 };
@@ -53,10 +54,12 @@ static void dhcp_free(struct connman_dhcp *dhcp)
g_strfreev(dhcp->nameservers);
g_free(dhcp->timeserver);
g_free(dhcp->pac);
+   g_free(dhcp->last_address);
 
dhcp->nameservers = NULL;
dhcp->timeserver = NULL;
dhcp->pac = NULL;
+   dhcp->last_address = NULL;
 }
 
 /**
@@ -103,6 +106,10 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, 
connman_bool_t callback)
}
}
 
+   __connman_ipconfig_set_dhcp_address(ipconfig, dhcp->last_address);
+
+   DBG("last address %s", dhcp->last_address);
+
__connman_ipconfig_address_remove(ipconfig);
 
__connman_ipconfig_set_local(ipconfig, NULL);
@@ -205,6 +212,12 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
 
address = g_dhcp_client_get_address(dhcp_client);
 
+   g_free(dhcp->last_address);
+   dhcp->last_address = g_strdup(address);
+   __connman_ipconfig_set_dhcp_address(ipconfig, dhcp->last_address);
+
+   DBG("last address %s", address);
+
option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET);
if (option != NULL)
netmask = g_strdup(option->data);
@@ -412,7 +425,7 @@ static i

ANNOUNCE: ConnMan 0.76

2011-07-27 Thread Samuel Ortiz
Hi All,

ConnMan 0.76 was released on July 20th, 2011.

The main change for this release is the complete removal of the element
structure from the ConnMan code. ConnMan hackers can only thank Daniel Wagner
for this long term and tedious effort as the code is quite simpler to follow.
>From a user perspective, the element removal should not bring any visible
changes.

With 0.76, we also looked at the service state machine and separated the
ipconfig state handling from the actual service state one. The previous
service state machine was working fine, but with the introduction of a full
IPv6 support, we started to reach its limitations. 0.76 seems to fix that
issue.

>From a feature perspective, Jukka Rissanen implemented the final missing piece
to the IPv6 gateway handling. We should now be able to properly track IPv6
gateways. Guillaume Zajac also extended the private networks API in order for
it to properly support multiple private networks per caller. The missing piece
here is the IP pool code, and Guillaume volunteered to start working on it.

Finally, 0.76 brings many fixes from various people: Paolo Pellegrino fixed
our TTLS/PEAP support, Mohamed Abbas fixed our provision code to handle
*.config files additions at run time, Patrik Flykt cleaned our provider code,
Thierry Boureille fixed our IPv4v6 oFono plugin support, Grant Erickson
provided a partial fix for missing loopback addresses, and Tomasz Burtsztyka
fixed WPAD, service and gweb/gresolv related issues.

You can fetch signed tarballs for ConnMan 0.76 [1] [2], but you can also get
the latest code from our git tree [3]. Enjoy !

Cheers,
Samuel.

[1] http://www.kernel.org/pub/linux/network/connman/connman-0.76.tar.bz2
[2] http://www.kernel.org/pub/linux/network/connman/connman-0.76.tar.bz2.sign
[3] git://git.kernel.org/pub/scm/network/connman/connman.git
-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: Should Connman Receive All Supplicant State Changes?

2011-07-27 Thread Grant Erickson
On Jul 26, 2011, at 6:12 PM, Grant Erickson wrote:
> Is it expected that connman should receive and process all supplicant state 
> changes? If so, I am seeing cases where the supplicant fails to signal or 
> connman misses GROUP_HANDSHAKE always and occasionally ASSOCIATED, 
> 4WAY_HANDSHAKE, and DISCONNECTED as below:
> 
>   2011-07-26 21:34:22.00 daemon.debug wpa_supplicant[1530]: State: 
> COMPLETED -> ASSOCIATING
>   2011-07-26 21:34:22.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() received state 
> associating (5)
>   2011-07-26 21:34:22.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() state associating (5)
>   
>   ### OK
>   
>   2011-07-26 21:34:22.00 daemon.debug wpa_supplicant[1530]: State: 
> ASSOCIATING -> DISCONNECTED
>   2011-07-26 21:34:22.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() received state 
> disconnected (1)
>   2011-07-26 21:34:22.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() state disconnected (1)
>   
>   ### OK
>   
>   2011-07-26 21:34:22.00 daemon.debug wpa_supplicant[1530]: State: 
> DISCONNECTED -> DISCONNECTED
>   
>   ### OK: Already there.
>   
>   2011-07-26 21:34:23.00 daemon.debug wpa_supplicant[1530]: State: 
> DISCONNECTED -> ASSOCIATED
>   
>   ### FAILED
>   
>   2011-07-26 21:34:23.00 daemon.debug wpa_supplicant[1530]: State: 
> ASSOCIATED -> 4WAY_HANDSHAKE
>   2011-07-26 21:34:23.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() received state 
> 4way_handshake (7)
>   2011-07-26 21:34:23.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() state 4way_handshake (7)
>   
>   ### OK
>   
>   2011-07-26 21:34:23.00 daemon.debug wpa_supplicant[1530]: State: 
> 4WAY_HANDSHAKE -> 4WAY_HANDSHAKE
>   
>   ### OK: Already there.
>   
>   2011-07-26 21:34:23.00 daemon.debug wpa_supplicant[1530]: State: 
> 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
>   
>   ### FAILED
>   
>   2011-07-26 21:34:23.00 daemon.debug wpa_supplicant[1530]: State: 
> GROUP_HANDSHAKE -> COMPLETED
>   2011-07-26 21:34:23.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() received state 
> completed (9)
>   2011-07-26 21:34:23.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() state completed (9)
>   
>   ### OK
>   
>   2011-07-26 21:34:24.00 daemon.debug wpa_supplicant[1530]: State: 
> COMPLETED -> 4WAY_HANDSHAKE
>   
>   ### FAILED
>   
>   2011-07-26 21:34:24.00 daemon.debug wpa_supplicant[1530]: State: 
> 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
>   
>   ### FAILED
>   
>   2011-07-26 21:34:24.00 daemon.debug wpa_supplicant[1530]: State: 
> GROUP_HANDSHAKE -> COMPLETED
>   2011-07-26 21:34:24.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() received state 
> completed (9)
>   2011-07-26 21:34:24.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() state completed (9)
>   
>   ### OK
>   
>   2011-07-26 21:34:25.00 daemon.debug wpa_supplicant[1530]: State: 
> COMPLETED -> 4WAY_HANDSHAKE
>   
>   ### FAILED
>   
>   2011-07-26 21:34:25.00 daemon.debug wpa_supplicant[1530]: State: 
> 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
>   
>   ### FAILED
>   
>   2011-07-26 21:34:25.00 daemon.debug wpa_supplicant[1530]: State: 
> GROUP_HANDSHAKE -> COMPLETED
>   2011-07-26 21:34:25.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() received state 
> completed (9)
>   2011-07-26 21:34:25.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() state completed (9)
>   
>   ### OK
>   
>   2011-07-26 21:34:26.00 daemon.debug wpa_supplicant[1530]: State: 
> COMPLETED -> 4WAY_HANDSHAKE
>   
>   ### FAILED
>   
>   2011-07-26 21:34:26.00 daemon.debug wpa_supplicant[1530]: State: 
> 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
>   
>   ### FAILED
>   
>   2011-07-26 21:34:26.00 daemon.debug wpa_supplicant[1530]: State: 
> GROUP_HANDSHAKE -> COMPLETED
>   2011-07-26 21:34:26.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() received state 
> completed (9)
>   2011-07-26 21:34:26.00 daemon.debug connmand[1532]: 
> connman/gsupplicant/supplicant.c:interface_property() state completed (9)
>   
>   ### OK
>   
>   2011-07-26 21:34:27.00 daemon.debug wpa_supplicant[1530]: State: 
> COMPLETED -> ASSOCIATED

[PATCH] update ofono plugin for CDMA devices

2011-07-27 Thread Guillaume Zajac
Hi Marcel,

Here is a first version to make CDMA devices publishing an interface to manage 
data call.
It will require a cdma SIM atom into oFono to retrieve the IMSI.

Guillaume Zajac (1):
  ofono: manage CDMA device into plugin

 plugins/ofono.c |  246 ++-
 1 files changed, 245 insertions(+), 1 deletions(-)

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


[PATCH] ofono: manage CDMA device into plugin

2011-07-27 Thread Guillaume Zajac
---
 plugins/ofono.c |  246 ++-
 1 files changed, 245 insertions(+), 1 deletions(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index 1bd9a30..80555ce 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -50,6 +50,8 @@
 #define OFONO_CONTEXT_INTERFACEOFONO_SERVICE 
".ConnectionContext"
 #define OFONO_SIM_INTERFACEOFONO_SERVICE ".SimManager"
 #define OFONO_REGISTRATION_INTERFACE   OFONO_SERVICE ".NetworkRegistration"
+#define OFONO_CDMA_SIM_INTERFACE   OFONO_SERVICE ".cdma.SimManager"
+#define OFONO_CDMA_CONNECTION_MANAGER_INTERFACEOFONO_SERVICE 
".cdma.ConnectionManager"
 
 #define PROPERTY_CHANGED   "PropertyChanged"
 #define GET_PROPERTIES "GetProperties"
@@ -76,6 +78,8 @@ struct modem_data {
gboolean has_sim;
gboolean has_reg;
gboolean has_gprs;
+   gboolean is_cdma;
+   gboolean cdma_has_sim;
gboolean available;
gboolean pending_online;
dbus_bool_t requested_online;
@@ -551,6 +555,18 @@ static int set_network_active(struct connman_network 
*network)
set_active_reply, g_strdup(path), g_free);
 }
 
+static int set_cdma_network_active(struct connman_network *network)
+{
+   dbus_bool_t value = TRUE;
+   const char *path = connman_network_get_string(network, "Path");
+
+   DBG("network %p, path %s", network, path);
+
+   return set_property(path, OFONO_CDMA_CONNECTION_MANAGER_INTERFACE,
+   "Powered", DBUS_TYPE_BOOLEAN, &value,
+   set_active_reply, g_strdup(path), g_free);
+}
+
 static int set_network_inactive(struct connman_network *network)
 {
int err;
@@ -569,6 +585,24 @@ static int set_network_inactive(struct connman_network 
*network)
return err;
 }
 
+static int set_cdma_network_inactive(struct connman_network *network)
+{
+   int err;
+   dbus_bool_t value = FALSE;
+   const char *path = connman_network_get_string(network, "Path");
+
+   DBG("network %p, path %s", network, path);
+
+   err = set_property(path, OFONO_CDMA_CONNECTION_MANAGER_INTERFACE,
+   "Powered", DBUS_TYPE_BOOLEAN, &value,
+   NULL, NULL, NULL);
+
+   if (err == -EINPROGRESS)
+   err = 0;
+
+   return err;
+}
+
 static int network_connect(struct connman_network *network)
 {
struct connman_device *device;
@@ -584,6 +618,9 @@ static int network_connect(struct connman_network *network)
if (modem == NULL)
return -ENODEV;
 
+   if (modem->is_cdma)
+   return set_cdma_network_active(network);
+
if (modem->registered == FALSE)
return -ENOLINK;
 
@@ -598,13 +635,27 @@ static int network_connect(struct connman_network 
*network)
 
 static int network_disconnect(struct connman_network *network)
 {
+   struct connman_device *device;
+   struct modem_data *modem;
+
DBG("network %p", network);
 
+   device = connman_network_get_device(network);
+   if (device == NULL)
+   return -ENODEV;
+
+   modem = connman_device_get_data(device);
+   if (modem == NULL)
+   return -ENODEV;
+
if (connman_network_get_index(network) < 0)
return -ENOTCONN;
 
connman_network_set_associating(network, FALSE);
 
+   if (modem->is_cdma)
+   return set_cdma_network_inactive(network);
+
return set_network_inactive(network);
 }
 
@@ -936,6 +987,77 @@ static int add_network(struct connman_device *device,
return 0;
 }
 
+static int add_cdma_network(struct connman_device *device, const char *path)
+{
+   struct modem_data *modem = connman_device_get_data(device);
+   struct connman_network *network;
+   struct network_info *info;
+   char *ident;
+   const char *hash_path;
+
+   DBG("modem %p device %p path %s", modem, device, path);
+
+   ident = get_ident(path);
+
+   network = connman_device_get_network(device, ident);
+   if (network != NULL)
+   return -EALREADY;
+
+   info = g_hash_table_lookup(network_hash, path);
+   if (info != NULL) {
+   DBG("path %p already exists with device %p", path,
+   connman_network_get_device(info->network));
+   if (connman_network_get_device(info->network))
+   return -EALREADY;
+   g_hash_table_remove(network_hash, path);
+   }
+
+   network = connman_network_create(ident, CONNMAN_NETWORK_TYPE_CELLULAR);
+   if (network == NULL)
+   return -ENOMEM;
+
+   info = g_try_new0(struct network_info, 1);
+   if (info == NULL) {
+   connman_network_unref(network);
+   return -ENOMEM;
+   }
+
+   connman_ipaddress_clear(&info->ipv4_address);
+   connman_ipaddress_clea

Re: [PATCH dhcp v3 2/2] dhcp: Try to reuse the IP address we had last time.

2011-07-27 Thread Samuel Ortiz
Hi Jukka,

Some nitpicks:

On Wed, Jul 27, 2011 at 03:49:35PM +0300, Jukka Rissanen wrote:
> @@ -1327,7 +1334,18 @@ int g_dhcp_client_start(GDHCPClient *dhcp_client)
>   dhcp_client->xid = rand();
>   }
>  
> - send_discover(dhcp_client, 0);
> + if (last_address == NULL)
> + addr = 0;
For highly arguable aestethic reasons, I'd prefer to see a symetric bloc
opening with the if, even though it will contain only addr = 0.


> + else {
> + addr = inet_addr(last_address);
> + if (addr == 0x)
> + addr = 0;
Ditto.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH dhcp v3 1/2] ipconfig: Remember last DHCP IP address.

2011-07-27 Thread Samuel Ortiz
Hi Jukka,

On Wed, Jul 27, 2011 at 03:49:34PM +0300, Jukka Rissanen wrote:
> diff --git a/src/ipconfig.c b/src/ipconfig.c
> index 9f73b65..7fb56a4 100644
> --- a/src/ipconfig.c
> +++ b/src/ipconfig.c
> @@ -54,6 +54,7 @@ struct connman_ipconfig {
>   struct connman_ipaddress *system;
>  
>   int ipv6_privacy_config;
> + char *last_dynamic_ip_address;
We could even call this one last_dhcp_address.

> +char *__connman_ipconfig_get_dhcp_address(struct connman_ipconfig *ipconfig)
> +{
> + if (ipconfig == NULL)
> + return NULL;
> +
> + return g_strdup(ipconfig->last_dynamic_ip_address);
Do we really need to duplicate the string here ? Code calling this API will
not run when an ipconfig is not set anyway.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH] service : Fix put data on null pointer

2011-07-27 Thread Thierry Boureille
hi,
when using ConnectService of Manager interface a segfault arises due to a null 
pointer. 

in __connman_service_create_and_connect:

[...]
service = lookup_by_identifier(name);

if (service != NULL)
goto done;

network = create_hidden_wifi(device, ssid, mode, security);
if (network != NULL) {
connman_network_set_group(network, group);
service->network_created = TRUE;
}
[...]
in this part "service" is null

please find a fix below
regards

---
 src/service.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/service.c b/src/service.c
index d442c16..1939832 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4206,10 +4206,8 @@ int __connman_service_create_and_connect(DBusMessage 
*msg)
goto done;
 
network = create_hidden_wifi(device, ssid, mode, security);
-   if (network != NULL) {
+   if (network != NULL)
connman_network_set_group(network, group);
-   service->network_created = TRUE;
-   }
 
service = lookup_by_identifier(name);
 
@@ -4222,6 +4220,8 @@ done:
goto failed;
}
 
+   service->network_created = TRUE;
+
if (is_connected(service) == TRUE) {
err = -EISCONN;
goto failed;
-- 
1.7.3.4




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


Re: Query on ConnMan

2011-07-27 Thread Stephan Raue

Am 28.07.2011 06:57, schrieb M Prema:

After installing wpa_supplicant-0.7.2(in config file CONFIG_DRIVER_WEXT=y
is set,after this make and make install is done.wpa_supplicant installed
successfully) along with connman-0.75, I am not able to bringup the wifi
interface.
afaik connman-0.75 has a bug, i dont was able to bring the wlanX 
interfaces up. it works with 0.74 and 0.76 again


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