Hi Jukka,

>  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..aa8274c 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_dhcp_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_dhcp_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_dhcp_address);
> +     ipconfig->last_dhcp_address = g_strdup(address);
> +}
> +
> +char *__connman_ipconfig_get_dhcp_address(struct connman_ipconfig *ipconfig)
> +{
> +     if (ipconfig == NULL)
> +             return NULL;
> +
> +     return ipconfig->last_dhcp_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_dhcp_address);
> +             ipconfig->last_dhcp_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_dhcp_address != NULL &&
> +                             strlen(ipconfig->last_dhcp_address) > 0)
> +                     g_key_file_set_string(keyfile, identifier, key,
> +                                     ipconfig->last_dhcp_address);
> +             else
> +                     g_key_file_remove_key(keyfile, identifier, key, NULL);
> +             g_free(key);
> +             /* fall through */

I am against storing the last IP address from DHCP on disk. What is this
good for?

When you leave the current network to switch to a different one or when
you shutdown your laptop, why bother with trying to keep the same
address. I rather not actually.

When connected to the same network and roaming between access points,
then yes, you should keep the same address, but that is only valid as
long as ConnMan is actually running.

Regards

Marcel


_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to