diff options
Diffstat (limited to 'toxcore/LAN_discovery.c')
-rw-r--r-- | toxcore/LAN_discovery.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index c3d06014..e23550df 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -70,14 +70,16 @@ static void fetch_broadcast_info(uint16_t port) | |||
70 | IP_ADAPTER_INFO *pAdapter = pAdapterInfo; | 70 | IP_ADAPTER_INFO *pAdapter = pAdapterInfo; |
71 | 71 | ||
72 | while (pAdapter) { | 72 | while (pAdapter) { |
73 | IP gateway = {0}, subnet_mask = {0}; | 73 | IP gateway = {0}; |
74 | IP subnet_mask = {0}; | ||
74 | 75 | ||
75 | if (addr_parse_ip(pAdapter->IpAddressList.IpMask.String, &subnet_mask) | 76 | if (addr_parse_ip(pAdapter->IpAddressList.IpMask.String, &subnet_mask) |
76 | && addr_parse_ip(pAdapter->GatewayList.IpAddress.String, &gateway)) { | 77 | && addr_parse_ip(pAdapter->GatewayList.IpAddress.String, &gateway)) { |
77 | if (net_family_is_ipv4(gateway.family) && net_family_is_ipv4(subnet_mask.family)) { | 78 | if (net_family_is_ipv4(gateway.family) && net_family_is_ipv4(subnet_mask.family)) { |
78 | IP_Port *ip_port = &ip_ports[count]; | 79 | IP_Port *ip_port = &ip_ports[count]; |
79 | ip_port->ip.family = net_family_ipv4; | 80 | ip_port->ip.family = net_family_ipv4; |
80 | uint32_t gateway_ip = net_ntohl(gateway.ip.v4.uint32), subnet_ip = net_ntohl(subnet_mask.ip.v4.uint32); | 81 | uint32_t gateway_ip = net_ntohl(gateway.ip.v4.uint32); |
82 | uint32_t subnet_ip = net_ntohl(subnet_mask.ip.v4.uint32); | ||
81 | uint32_t broadcast_ip = gateway_ip + ~subnet_ip - 1; | 83 | uint32_t broadcast_ip = gateway_ip + ~subnet_ip - 1; |
82 | ip_port->ip.ip.v4.uint32 = net_htonl(broadcast_ip); | 84 | ip_port->ip.ip.v4.uint32 = net_htonl(broadcast_ip); |
83 | ip_port->port = port; | 85 | ip_port->port = port; |