From a73e93ae912ef0eca0b619414c347cf9eb77e333 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 5 Nov 2006 20:18:11 +0000 Subject: [PATCH] dwBCastAddr is a flag, not an address --- src/os/win32/win32_sigar.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 6a0e0ffa..e752e1bd 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -2399,9 +2399,17 @@ sigar_net_interface_config_get(sigar_t *sigar, sigar_net_address_set(ifconfig->netmask, ipaddr->dwMask); - /* wtf is up w/ dwBCastAddr? */ - sigar_net_address_set(ifconfig->broadcast, - ipaddr->dwAddr|0xFF000000); + if (ifr->dwType != MIB_IF_TYPE_LOOPBACK) { + long bcast = ipaddr->dwAddr & ipaddr->dwMask; + + if (ipaddr->dwBCastAddr) { + bcast |= ~ipaddr->dwMask; + ifconfig->flags |= SIGAR_IFF_BROADCAST; + } + + sigar_net_address_set(ifconfig->broadcast, + bcast); + } } /* hack for MS_LOOPBACK_ADAPTER */ @@ -2417,8 +2425,7 @@ sigar_net_interface_config_get(sigar_t *sigar, } else { if (ipaddr) { - ifconfig->flags |= - SIGAR_IFF_BROADCAST|SIGAR_IFF_MULTICAST; + ifconfig->flags |= SIGAR_IFF_MULTICAST; } SIGAR_SSTRCPY(ifconfig->type,