1
0
Fork 0
mirror of https://gitlab.com/Mr_Goldberg/goldberg_emulator.git synced 2024-11-14 10:50:13 +01:00

Fix wrong broadcast addr on windows

This commit is contained in:
Nemirtingas 2019-09-20 12:52:56 +02:00
parent b77b4e2ef5
commit 1545e375a2

View file

@ -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++;