Add IPv6 support to getifaddrs() on Windows - #1433
Conversation
We now ask both IPv4 and IPv6 addresses to GetAdaptersAddresses Ipv6 address flags fill up is left as a todo because I'm not sure how to get the same information as of Linux I've tested on a x86_64 Windows machine and I get the same informations as of ipconfig.exe
|
I'm asking copilot to take a deeper look. With IPv6 and IPv4 addresses, I would assume what you'd probably want to do is get the family of the socket, and filter results so that interfaces consistent with the socket's family are returned. This way you won't have an issue where code that only expects to iterate over ipv4 interfaces will get surprised. Is that how the BSDs do this? Also review the brace movement at line 234-241. Name clash detection must work for IPv6. |
There was a problem hiding this comment.
Pull request overview
This pull request adds IPv6 support to the getifaddrs() implementation on Windows by modifying the Windows-specific ioctl handling code. The implementation now queries both IPv4 and IPv6 addresses from GetAdaptersAddresses and stores IPv6-specific information in the host adapter information structure.
Changes:
- Modified
GetAdaptersAddressescalls to useAF_UNSPECinstead ofAF_INETto retrieve both IPv4 and IPv6 addresses - Extended
HostAdapterInfoNodestructure with IPv6-specific fields (interface index, scope, prefix length, flags, and IPv6 address) - Updated
appendHostInfoto handle IPv6 addresses separately with scope detection logic - Modified
ioctl_siocgifconf_ntto populate IPv6 fields in theifreqstructure
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The filtering would be done on the linked-list returned by linux getifaddrs man says this
BSDs
I think this is the intended behavior, contrary to ipv4, ipv6 ifaces can have multiples addresses on the same iface |
We now ask both IPv4 and IPv6 addresses to GetAdaptersAddresses
Ipv6 address flags fill up is left as a todo because I'm not sure how to get the same information as of Linux
I've tested on a x86_64 Windows machine and I get the same informations as of ipconfig.exe