Skip to content

Commit bfbaddb

Browse files
committed
CI Win: unpin libpcpnatpmp
but the code still needs to be patched this roughly reverts the commit 382f2fc
1 parent 89c3ed6 commit bfbaddb

File tree

2 files changed

+84
-6
lines changed

2 files changed

+84
-6
lines changed

.github/scripts/install-common-deps.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,8 @@ install_pcp() {
124124
cd libpcpnatpmp
125125
# TODO TOREMOVE when not needed
126126
if is_win; then
127-
git checkout 46341d6
128-
sed "/int gettimeofday/i\\
129-
struct timezone;\\
130-
struct timeval;\\
131-
" libpcp/src/windows/pcp_gettimeofday.h > fixed
132-
mv fixed libpcp/src/windows/pcp_gettimeofday.h
127+
git am "$curdir"/patches/\
128+
libpcpnatpmp-0001-win32-build-fixes.patch
133129
fi
134130
sed 's/AC_PREREQ(.*)/AC_PREREQ(\[2.69\])/' configure.ac \
135131
> configure.ac.fixed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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

Comments
 (0)