Archive for June 23rd, 2008
IPv6 readyness
Supporting IPv6 can be a little tricky for the average developer. I have stumbled on so many issues, mainly because I was hooked to IPv4 and I have little means to test IPv6. My Internet Router that’s attached to my ISP’s modem doesn’t support IPv6, even though the store where I bought my Cisco 851 said it did. So the only way to get in touch with the Internet cloud with IPv6 is to set up a 6to4 tunnel from within my network and connect to a fancy external provider.
I could still do that, but luckily I found a way to set up a mini-network between my main-development-pc and a server. First I had to assign v6 IP’s to the machines, and since I didn’t want to bother with DHCPv6 yet, I had to use static ones. I found a website where I just nicked the sample IP address from (since my router doesn’t support IPv6 anyway, it shouldn’t be a problem).
So I punched into my ssh-console; /sbin/ifconfig eth0 inet6 add 2001:0db8:0:f101::1/64
And on Vista I entered 2001:0db8:0:f101::2 mask 64 into the IPv6 protocol configuration screen.
And magically the pinging now works.
Next step was to add an AAAA record to the local DNS server I’m using, which wasn’t that hard.
Now, the first thing you’ll notice is that the posix function gethostbyname() doesn’t give you any results when you try to lookup your AAAA-record. At least, under Vista it doesn’t, I haven’t tested it anywhere else yet. You have to use the getaddrinfo() function (also posix).
The second problem, which is highly annoying, is about the ip-structure to ip-string conversion and vice-versa. Normally with IPv4 you can use the handy function inet_ntoa(), but ofcourse it doesn’t support IPv6. You have to start using inet_pton() / inet_ntop(). But it’s there where posix compliancy ended with Microsoft. You have to improvise the functions using getnameinfo() and getaddrinfo() using special flags.
Looking back at all the struggles concerning these functions, I don’t really get why I didn’t make a custom implementation. All it should be able to do is to translate an ascii patterned string to a structure with all the numbers mixed up. (seriously, the person who made up that network-byte-order-mechanism was insane)
Microsoft obviously got the message in a very late stage, and added a new Vista+ only function baked into ntdll.dll, named RtlIpv6StringToAddress(). I don’t get why no one else thought of that earlier.
Add comment June 23, 2008