From ef0752391c40c63a5cf510b9b464658071a9e798 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 3 Nov 2006 19:28:51 +0000 Subject: [PATCH] make sure primary ip is used for net_interface_config --- src/os/win32/win32_sigar.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 19c7b3b6..f57e50eb 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -2264,22 +2264,18 @@ sigar_net_interface_config_get(sigar_t *sigar, if (status == SIGAR_OK) { char *addr; - if (adapter->CurrentIpAddress) { - addr = adapter->CurrentIpAddress->IpAddress.String; - sigar_net_address_set(ifconfig->address, - inet_addr(addr)); - addr = adapter->CurrentIpAddress->IpMask.String; - sigar_net_address_set(ifconfig->netmask, - inet_addr(addr)); - } - else { - addr = adapter->IpAddressList.IpAddress.String; - sigar_net_address_set(ifconfig->address, - inet_addr(addr)); - addr = adapter->IpAddressList.IpMask.String; - sigar_net_address_set(ifconfig->netmask, - inet_addr(addr)); + IP_ADDR_STRING *ip = &adapter->IpAddressList; + + /* last address in the list is the primary */ + while (ip->Next) { + ip = ip->Next; } + addr = ip->IpAddress.String; + sigar_net_address_set(ifconfig->address, + inet_addr(addr)); + addr = ip->IpMask.String; + sigar_net_address_set(ifconfig->netmask, + inet_addr(addr)); } /* hack for MS_LOOPBACK_ADAPTER */