On 1 June 2016 at 17:46, Patrick Wildt <[email protected]> wrote: > On Wed, Jun 01, 2016 at 03:47:45PM +0200, Mike Belopuhov wrote: >> On 1 June 2016 at 13:33, Patrick Wildt <[email protected]> wrote: >> > Hi, >> > >> > The IPv6 address assignment was basically copied from the IPv4 >> > code. Instead of working on the last 32-bits, it actually worked >> > on the fourth byte. Thus it modified the network bits instead of >> > the host bits. >> > >> > This diff fixes the code so that we can have at least a 32-bit >> > address pool space by using the current IPv4 code. In the future >> > it might be nice to be able to leverage all host bits. >> > >> > Is there a saner way to access the last 32-bits of an IPv6 address? >> > Another possibility would be >> > >> > *((uint32_t *)&in6->sin6_addr.s6_addr[12]) = ...; >> > >> > but I'm not sure that's any better. >> > >> >> The best way to do it is via memcpy. Save htonl(host) in a uint32_t >> on the stack and memcpy it into the (char *)&...s6_addr[12]. >> >> I think __u6_addr.__u6_addr32 is an implementation detail. >> >> > Patrick >> > >> > > Ok, how is this? >
Looks good to me. OK mikeb
