Skip to contentSkip to conversation

constructing IPv6 in6_addr structure from ipv6

DISCUSSION Steve French 1 participant 1 message Dec 6, 2004

lore
Share & tools
lore
#0 lore raw

Is there a recommended way to construct a struct sockaddr_in6 in kernel which is the format the connect function on a socket requires for ipv6 addresses?

Basically this boils down to how to best construct a struct in6_addr starting with a IPv6 network address represented as a familiar dotted
address character string. I would prefer to convert this in kernel via
something like inet_pton(AF_INET6,original_address_string, converted_to_in6_add_form) but I could convert in userspace and pass the 16 byte array down to the kernel mangled as a string, via a mount option.

Is it better to mangle the address and pass it down, or do something
similar to inet_pton? This can't be the first time that someone has
wanted to deal with an ipv6 address coming from userspace ...