Hi Jukka,

> 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 */
Let's call this one inet_addr to be more explicit.


>  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;
> +     }
I think the ll IPv6 address should just be treated as other addresses, except
that we don't want to copy it to config_ipv6->address.
It should be added to the address_list list once we checked it's not a
duplicate.




>  
>       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
> +
> +             if (prefixlen == 64 && is_autoconf_address(ipaddress,
> +                                     ipdevice->ipv6_ll))
Then your is_autoconf_address() should just take an ipdevice and an ipadress
as arguments, and then go through the address_list list to find the ll one.


> +                     ipdevice->config_ipv6->method =
> +                                     CONNMAN_IPCONFIG_METHOD_AUTOCONF;
> +     } else
>               return;
>  
>       if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | 
> IFF_LOWER_UP))
> diff --git a/src/rtnl.c b/src/rtnl.c
> index b10d835..cf11148 100644
> --- a/src/rtnl.c
> +++ b/src/rtnl.c
> @@ -585,22 +585,23 @@ static void process_newaddr(unsigned char family, 
> unsigned char prefixlen,
>               struct in_addr ipv4_addr = { INADDR_ANY };
>  
>               extract_ipv4_addr(msg, bytes, &label, &ipv4_addr, NULL, NULL);
> -             src = &ipv4_addr;
> +             src = g_try_new0(struct in_addr, 1);
> +             memcpy(src, &ipv4_addr, sizeof(struct in_addr));
I'd rather see the allocation and memcpy being done in ipconfig.c
The allocation should be done by connman_ipaddress_alloc() and the memcpy by
__connman_ipconfig_newaddr(). This way the allocation and the release of this
pointer are done by the same code layer.

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

Reply via email to