|
| 1 | +From ecedae2d978922c5e25fb90d6b2e8d3cf21b325c Mon Sep 17 00:00:00 2001 |
| 2 | +From: Martin Pulec < [email protected]> |
| 3 | +Date: Tue, 11 Nov 2025 16:01:50 +0100 |
| 4 | +Subject: [PATCH] win32 build fixes |
| 5 | + |
| 6 | +--- |
| 7 | + lib/src/net/gateway.c | 2 +- |
| 8 | + lib/src/net/pcp_socket.c | 8 ++++---- |
| 9 | + lib/src/windows/pcp_gettimeofday.h | 2 ++ |
| 10 | + 3 files changed, 7 insertions(+), 5 deletions(-) |
| 11 | + |
| 12 | +diff --git a/lib/src/net/gateway.c b/lib/src/net/gateway.c |
| 13 | +index f314c2f..25d02bf 100644 |
| 14 | +--- a/lib/src/net/gateway.c |
| 15 | ++++ b/lib/src/net/gateway.c |
| 16 | +@@ -307,7 +307,7 @@ int getgateways(struct sockaddr_in6 **gws) { |
| 17 | + (IPV6_IS_ADDR_ANY(&row->NextHop.Ipv6.sin6_addr))) { |
| 18 | + continue; |
| 19 | + } else if ((row->NextHop.si_family == AF_INET) && |
| 20 | +- (&row->NextHop.Ipv6.sin6_addr == INADDR_ANY)) { |
| 21 | ++ (row->NextHop.Ipv4.sin_addr.s_addr == INADDR_ANY)) { |
| 22 | + continue; |
| 23 | + } else if (row->NextHop.si_family == AF_INET) { |
| 24 | + (*gws)[ret].sin6_family = AF_INET6; |
| 25 | +diff --git a/lib/src/net/pcp_socket.c b/lib/src/net/pcp_socket.c |
| 26 | +index 36cac6f..a61ad6d 100644 |
| 27 | +--- a/lib/src/net/pcp_socket.c |
| 28 | ++++ b/lib/src/net/pcp_socket.c |
| 29 | +@@ -460,9 +460,9 @@ static ssize_t pcp_socket_sendto_impl(PCP_SOCKET sock, const void *buf, |
| 30 | + |
| 31 | + #if defined(IPV6_PKTINFO) |
| 32 | + if (src_addr) { |
| 33 | ++#ifndef WIN32 |
| 34 | + struct in6_pktinfo ipi6 = {0}; |
| 35 | + |
| 36 | +-#ifndef WIN32 |
| 37 | + uint8_t c[CMSG_SPACE(sizeof(struct in6_pktinfo))] = {0}; |
| 38 | + struct iovec iov; |
| 39 | + struct msghdr msg; |
| 40 | +@@ -487,7 +487,7 @@ static ssize_t pcp_socket_sendto_impl(PCP_SOCKET sock, const void *buf, |
| 41 | + ret = sendmsg(sock, &msg, flags); |
| 42 | + #else // WIN32 |
| 43 | + WSABUF wsaBuf; |
| 44 | +- wsaBuf.buf = buf; |
| 45 | ++ wsaBuf.buf = (void *) buf; |
| 46 | + wsaBuf.len = len; |
| 47 | + uint8_t c[WSA_CMSG_SPACE(sizeof(struct in6_pktinfo))] = {0}; |
| 48 | + |
| 49 | +@@ -497,7 +497,7 @@ static ssize_t pcp_socket_sendto_impl(PCP_SOCKET sock, const void *buf, |
| 50 | + wsaMsg.namelen = addrlen; |
| 51 | + wsaMsg.lpBuffers = &wsaBuf; |
| 52 | + wsaMsg.dwBufferCount = 1; |
| 53 | +- wsaMsg.Control.buf = c; |
| 54 | ++ wsaMsg.Control.buf = (void *) c; |
| 55 | + |
| 56 | + // Set the source address inside the control message |
| 57 | + if (IN6_IS_ADDR_V4MAPPED(&src_addr->sin6_addr)) { |
| 58 | +@@ -528,7 +528,7 @@ static ssize_t pcp_socket_sendto_impl(PCP_SOCKET sock, const void *buf, |
| 59 | + if (WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &WSARecvMsg_GUID, |
| 60 | + sizeof(GUID), &WSARecvMsg, sizeof(WSARecvMsg), |
| 61 | + &dwBytesReturned, NULL, NULL) == SOCKET_ERROR) { |
| 62 | +- PCP_LOG(PCP_LOGLVL_PERR, ("WSAIoctl failed")); |
| 63 | ++ pcp_logger(PCP_LOGLVL_PERR, "WSAIoctl failed"); |
| 64 | + return 1; |
| 65 | + } |
| 66 | + |
| 67 | +diff --git a/lib/src/windows/pcp_gettimeofday.h b/lib/src/windows/pcp_gettimeofday.h |
| 68 | +index fb6f4fa..9249de2 100644 |
| 69 | +--- a/lib/src/windows/pcp_gettimeofday.h |
| 70 | ++++ b/lib/src/windows/pcp_gettimeofday.h |
| 71 | +@@ -26,6 +26,8 @@ |
| 72 | + #ifndef PCP_GETTIMEOFDAY |
| 73 | + #define PCP_GETTIMEOFDAY |
| 74 | + |
| 75 | ++struct timeval; |
| 76 | ++struct timezone; |
| 77 | + int gettimeofday(struct timeval *tv, struct timezone *tz); |
| 78 | + |
| 79 | + #endif /*PCP_GETTIMEOFDAY*/ |
| 80 | +-- |
| 81 | +2.51.1 |
| 82 | + |
0 commit comments