From 1545e375a2109331a99de405b4dd92e70f541a84 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Fri, 20 Sep 2019 12:52:56 +0200 Subject: [PATCH] Fix wrong broadcast addr on windows --- dll/network.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dll/network.cpp b/dll/network.cpp index b85ce3f3..7b2628ab 100644 --- a/dll/network.cpp +++ b/dll/network.cpp @@ -71,16 +71,15 @@ static void get_broadcast_info(uint16 port) IP_ADAPTER_INFO *pAdapter = pAdapterInfo; while (pAdapter) { - unsigned long gateway = 0, subnet_mask = 0; + unsigned long iface_ip = 0, subnet_mask = 0; if (inet_pton(AF_INET, pAdapter->IpAddressList.IpMask.String, &subnet_mask) == 1 - && inet_pton(AF_INET, pAdapter->GatewayList.IpAddress.String, &gateway) == 1) { + && inet_pton(AF_INET, pAdapter->IpAddressList.IpAddress.String, &iface_ip) == 1) { IP_PORT *ip_port = &broadcasts[number_broadcasts]; //ip_port->ip.family = AF_INET; - uint32 gateway_ip = ntohl(gateway), subnet_ip = ntohl(subnet_mask); - uint32 broadcast_ip = gateway_ip + ~subnet_ip - 1; - ip_port->ip = htonl(broadcast_ip); + uint32 broadcast_ip = iface_ip | ~subnet_mask; + ip_port->ip = broadcast_ip; ip_port->port = port; number_broadcasts++;