diff options
author | Nader Morshed <morshed.nader@gmail.com> | 2011-11-30 15:36:51 -0500 |
---|---|---|
committer | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2011-11-30 15:36:51 -0500 |
commit | 1fe527bef1f52b96cbbd755db8bbcab93bed49f8 (patch) | |
tree | e6a14a4d48b0c4056e54ae9e9a8c921cc7ef882c /agent/interfaces.c | |
parent | 1b44dca9978bfded1c34e8c33d5bd242c070d80e (diff) | |
download | libnice-1fe527bef1f52b96cbbd755db8bbcab93bed49f8.tar.gz |
Add support for windows's compilation through MinGW
Diffstat (limited to 'agent/interfaces.c')
-rw-r--r-- | agent/interfaces.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/agent/interfaces.c b/agent/interfaces.c index 01046d1..d5d4f4d 100644 --- a/agent/interfaces.c +++ b/agent/interfaces.c @@ -350,6 +350,20 @@ nice_interfaces_get_ip_for_interface (gchar *interface_name) #include <winsock2.h> #include <Iphlpapi.h> +// Should be in Iphlpapi.h, but mingw doesn't seem to have these +// Values copied directly from: +// http://msdn.microsoft.com/en-us/library/aa366845(v=vs.85).aspx +// (Title: MIB_IPADDRROW structure) + +#ifndef MIB_IPADDR_DISCONNECTED +#define MIB_IPADDR_DISCONNECTED 0x0008 +#endif + +#ifndef MIB_IPADDR_DELETED +#define MIB_IPADDR_DELETED 0x0040 +#endif + +#if 0 static gboolean started_wsa_engine = FALSE; /* @@ -383,6 +397,7 @@ SOCKET nice_interfaces_get_WSA_socket () return sock; } +#endif GList * nice_interfaces_get_local_interfaces () { @@ -450,7 +465,7 @@ GList * nice_interfaces_get_local_ips (gboolean include_loopback) continue; } - ipstr = g_strdup_printf ("%d.%d.%d.%d", + ipstr = g_strdup_printf ("%lu.%lu.%lu.%lu", (ipaddr->dwAddr ) & 0xFF, (ipaddr->dwAddr >> 8) & 0xFF, (ipaddr->dwAddr >> 16) & 0xFF, @@ -471,8 +486,11 @@ GList * nice_interfaces_get_local_ips (gboolean include_loopback) /* * returns ip address as an utf8 string */ +// Source for idx's type (Was IF_INDEX): +// http://msdn.microsoft.com/en-us/library/aa366836(v=VS.85).aspx +// (Title: MIB_IFROW structure) static gchar * -win32_get_ip_for_interface (IF_INDEX idx) +win32_get_ip_for_interface (DWORD idx) { ULONG size = 0; PMIB_IPADDRTABLE ip_table; @@ -491,7 +509,7 @@ win32_get_ip_for_interface (IF_INDEX idx) PMIB_IPADDRROW ipaddr = &ip_table->table[i]; if (ipaddr->dwIndex == idx && !(ipaddr->wType & (MIB_IPADDR_DISCONNECTED | MIB_IPADDR_DELETED))) { - ret = g_strdup_printf ("%d.%d.%d.%d", + ret = g_strdup_printf ("%lu.%lu.%lu.%lu", (ipaddr->dwAddr ) & 0xFF, (ipaddr->dwAddr >> 8) & 0xFF, (ipaddr->dwAddr >> 16) & 0xFF, |