Skip to content

Commit

Permalink
broadcast addr can be NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
th-otto authored and OmniBlade committed Jun 12, 2024
1 parent 33b76ad commit 11ae34e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions common/wspudp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,20 @@ bool UDPInterfaceClass::Open_Socket(SOCKET)
struct in_addr* tmp_addr = &((struct sockaddr_in*)ifa->ifa_addr)->sin_addr;
char buf[INET_ADDRSTRLEN];
inet_ntop(AF_INET, tmp_addr, buf, INET_ADDRSTRLEN);
char temp[128];
sprintf(temp, "RA95: Found local address: %s\n", buf);
fprintf(stderr, temp);
fprintf(stderr, "RA95: Found local address: %s\n", buf);

unsigned char* a = new unsigned char[4];
*((uint32_t*)a) = tmp_addr->s_addr;
LocalAddresses.Add(a);

tmp_addr = &((struct sockaddr_in*)ifa->ifa_broadaddr)->sin_addr;
inet_ntop(AF_INET, tmp_addr, buf, INET_ADDRSTRLEN);
sprintf(temp, "RA95: Using broadcast address of: %s\n", buf);
fprintf(stderr, temp);
Set_Broadcast_Address(buf);
if ((struct sockaddr_in*)ifa->ifa_broadaddr == 0) {
fprintf(stderr, "RA95: No broadcast address\n");
} else {
tmp_addr = &((struct sockaddr_in*)ifa->ifa_broadaddr)->sin_addr;
inet_ntop(AF_INET, tmp_addr, buf, INET_ADDRSTRLEN);
fprintf(stderr, "RA95: Using broadcast address of: %s\n", buf);
Set_Broadcast_Address(buf);
}
}
}

Expand Down

0 comments on commit 11ae34e

Please sign in to comment.