Try to fix the build on Windows.

Still untested on the OS, but Grok pointed me to the alternative
function to use.  Hope it works.
This commit is contained in:
Mike Swanson
2026-02-06 17:49:02 -08:00
parent eaa4c7063f
commit 85e4122f9f
2 changed files with 10 additions and 1 deletions

View File

@@ -28,7 +28,7 @@
*/
#ifdef _WIN32
# include <winsock.h>
# include <ws2tcpip.h>
#else
# include <arpa/inet.h>
#endif
@@ -896,7 +896,11 @@ load_network(void)
p = ini_section_get_string(cat, temp, "");
if (p && *p) {
struct in_addr addr;
#ifdef _WIN32
if (inet_aton(p, &addr)) {
#else
if (inet_pton(AF_INET, p, &addr)) {
#endif
uint8_t *bytes = (uint8_t *)&addr.s_addr;
bytes[3] = 0;
sprintf(nc->slirp_net, "%d.%d.%d.0", bytes[0], bytes[1], bytes[2]);

View File

@@ -43,6 +43,7 @@
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <ws2tcpip.h>
#else
# include <poll.h>
#endif
@@ -503,7 +504,11 @@ net_slirp_init(const netcard_t *card, const uint8_t *mac_addr, UNUSED(void *priv
const char *slirp_net = net_cards_conf[card->card_num].slirp_net;
if (slirp_net[0] != '\0') {
struct in_addr addr;
#ifdef _WIN32
inet_pton(AF_INET, slirp_net, &addr);
#else
inet_aton(slirp_net, &addr);
#endif
net.s_addr = htonl(ntohl(addr.s_addr) & 0xffffff00);
host.s_addr = htonl(ntohl(addr.s_addr) + 2);
dhcp.s_addr = htonl(ntohl(addr.s_addr) + 15);