Porting getifaddrs to Win XP

The closest functions on Windows are GetAdaptersInfo and GetAdaptersAddresses. The MSDN documentation is pretty comprehensive, so you should find everything you need.


getifaddrs() is not a portable solution, so if you need to support multiple platforms, you should consider using getaddrinfo, which is POSIX- and Windows-friendly. It is a little more complicated at first glance, but it really isn't that bad. This SO question has some good answers and links on the topic. (In particular, the showip.c example on Beej's page is quite helpful, and here is a Windows example; note that it is missing an #include <stdio.h> at the top, and be sure to link against Ws2_32.lib.)


I've done it here, including a separate version for Wine as the IP version agnostic routines don't current work as expected,

http://code.google.com/p/openpgm/source/browse/trunk/openpgm/pgm/getifaddrs.c

LGPL 2.1 license

edit: Wine 1.3 fixes the issues encountered with the IPv4 & IPv6 friendly API.