From 2ed87c2e0ca2dc937f561f643b4b24267353b825 Mon Sep 17 00:00:00 2001 From: skarg Date: Wed, 16 Apr 2008 23:05:00 +0000 Subject: [PATCH] Corrected AdapterInfo subnet mask which was not correctly determined for IpAddresses that were assigned to second or one of the follow up network interfaces. Thank you Thomas! --- bacnet-stack/ports/win32/bip-init.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bacnet-stack/ports/win32/bip-init.c b/bacnet-stack/ports/win32/bip-init.c index 76649c5c..b06d6231 100644 --- a/bacnet-stack/ports/win32/bip-init.c +++ b/bacnet-stack/ports/win32/bip-init.c @@ -94,7 +94,8 @@ static uint32_t getIpMaskForIpAddress( /* Save memory size of buffer */ DWORD dwBufLen = sizeof(AdapterInfo); uint32_t ipMask = INADDR_BROADCAST; - + bool found = false; + PIP_ADAPTER_INFO pAdapterInfo; /* GetAdapterInfo: @@ -116,18 +117,14 @@ static uint32_t getIpMaskForIpAddress( inet_addr(pIpAddressInfo->IpMask.String); if (adapterAddress == ipAddress) { ipMask = adapterMask; - break; + found = true; } pIpAddressInfo = pIpAddressInfo->Next; - } - while (pIpAddressInfo); - if (ipMask != 0L) { - break; - } + } while (pIpAddressInfo && !found); /* Progress through linked list */ pAdapterInfo = pAdapterInfo->Next; /* Terminate on last adapter */ - } while (pAdapterInfo); + } while (pAdapterInfo && !found); } return ipMask;