Skip to contentSkip to conversation

fix compilation on Windows

PATCH In review Heiko Hund 3 participants 8 messages Nov 15, 2014 – Nov 18, 2014

lore
Share & tools
lore

Heiko Hund

author
#0 lore raw

PATCH 1/2 fix compilation on Windows

The local member in struct lick_socket_address went away a while ago. Fixing the code to compile again under Windows. While there, also fix the code to deal with struct link_socket_info.af == AF_UNSPEC

---
 src/openvpn/socket.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
src/openvpn/socket.c +7 -8
index c649d62..9ed8a5a 100644
@@ -2916,6 +2916,7 @@ link_socket_read_udp_posix (struct link_socket *sock,
 #endif
     buf->len = recvfrom (sock->sd, BPTR (buf), maxsize, 0,
 			 &from->dest.addr.sa, &fromlen);
+  /* FIXME: won't do anything when sock->info.af == AF_UNSPEC */
   if (buf->len >= 0 && expectedlen && fromlen != expectedlen)
     bad_address_length (fromlen, expectedlen);
   return buf->len;
@@ -3060,10 +3061,7 @@ socket_recv_queue (struct link_socket *sock, int maxsize)
       if (proto_is_udp(sock->info.proto))
 	{
 	  sock->reads.addr_defined = true;
-	  if (sock->info.af == AF_INET)
-	    sock->reads.addrlen = sizeof (sock->reads.addr);
-	  else
-	    sock->reads.addrlen = sizeof (sock->reads.addr6);
+	  sock->reads.addrlen = sizeof (sock->reads.addr6);
 	  status = WSARecvFrom(
 			       sock->sd,
 			       wsabuf,
@@ -3095,9 +3093,10 @@ socket_recv_queue (struct link_socket *sock, int maxsize)
 
       if (!status) /* operation completed immediately? */
 	{
-	  int addrlen = af_addr_size(sock->info.lsa->local.addr.sa.sa_family);
-	  if (sock->reads.addr_defined && sock->reads.addrlen != addrlen)
-	    bad_address_length (sock->reads.addrlen, addrlen);
+	  /* FIXME: won't do anything when sock->info.af == AF_UNSPEC */
+	  int af_len = af_addr_size (sock->info.af);
+	  if (sock->reads.addr_defined && af_len && sock->reads.addrlen != af_len)
+	    bad_address_length (sock->reads.addrlen, af_len);
 	  sock->reads.iostate = IOSTATE_IMMEDIATE_RETURN;
 
 	  /* since we got an immediate return, we must signal the event object ourselves */
@@ -3159,7 +3158,7 @@ socket_send_queue (struct link_socket *sock, struct buffer *buf, const struct li
 	{
 	  /* set destination address for UDP writes */
 	  sock->writes.addr_defined = true;
-	  if (sock->info.af == AF_INET6)
+	  if (to->dest.addr.sa.sa_family == AF_INET6)
 	    {
 	      sock->writes.addr6 = to->dest.addr.in6;
 	      sock->writes.addrlen = sizeof (sock->writes.addr6);
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/2 fix warnings on Windows

Just add a few valid casts that shut up mingw gcc.

---
 src/openvpn/mtu.c    | 5 ++---
 src/openvpn/route.c  | 2 +-
 src/openvpn/socket.c | 4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)
src/openvpn/mtu.c +2 -3
index 13f3f6c..3665a34 100644
@@ -158,8 +158,7 @@ set_mtu_discover_type (int sd, int mtu_type)
   if (mtu_type >= 0)
     {
 #if defined(HAVE_SETSOCKOPT) && defined(SOL_IP) && defined(IP_MTU_DISCOVER)
-      if (setsockopt
-	  (sd, SOL_IP, IP_MTU_DISCOVER, &mtu_type, sizeof (mtu_type)))
+      if (setsockopt (sd, SOL_IP, IP_MTU_DISCOVER, (void *) &mtu_type, sizeof (mtu_type)))
 	msg (M_ERR, "Error setting IP_MTU_DISCOVER type=%d on TCP/UDP socket",
 	     mtu_type);
 #else
@@ -288,7 +287,7 @@ void
 set_sock_extended_error_passing (int sd)
 {
   int on = 1;
-  if (setsockopt (sd, SOL_IP, IP_RECVERR, &on, sizeof (on)))
+  if (setsockopt (sd, SOL_IP, IP_RECVERR, (void *) &on, sizeof (on)))
     msg (M_WARN | M_ERRNO,
 	 "Note: enable extended error passing on TCP/UDP socket failed (IP_RECVERR)");
 }
src/openvpn/route.c +1 -1
index e76c2bd..5d18213 100644
@@ -277,7 +277,7 @@ init_route (struct route_ipv4 *r,
   /* get_special_addr replaces specialaddr with a special ip addr
      like gw. getaddrinfo is called to convert a a addrinfo struct */
 
-  if(get_special_addr (rl, ro->network, &special.s_addr, &status))
+  if(get_special_addr (rl, ro->network, (in_addr_t *) &special.s_addr, &status))
     {
       special.s_addr = htonl(special.s_addr);
       ret = openvpn_getaddrinfo(0, inet_ntoa(special), NULL, 0, NULL,
src/openvpn/socket.c +2 -2
index 9ed8a5a..2499ab0 100644
@@ -729,7 +729,7 @@ static inline void
 socket_set_mark (int sd, int mark)
 {
 #if defined(TARGET_LINUX) && HAVE_DECL_SO_MARK
-  if (mark && setsockopt (sd, SOL_SOCKET, SO_MARK, &mark, sizeof (mark)) != 0)
+  if (mark && setsockopt (sd, SOL_SOCKET, SO_MARK, (void *) &mark, sizeof (mark)) != 0)
     msg (M_WARN, "NOTE: setsockopt SO_MARK=%d failed", mark);
 #endif
 }
@@ -1117,7 +1117,7 @@ socket_bind (socket_descriptor_t sd,
       int v6only = ipv6only ? 1: 0;	/* setsockopt must have an "int" */
 
       msg (M_INFO, "setsockopt(IPV6_V6ONLY=%d)", v6only);
-      if (setsockopt(sd, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only)))
+      if (setsockopt (sd, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &v6only, sizeof(v6only)))
 	{
 	  msg (M_NONFATAL|M_ERRNO, "Setting IPV6_V6ONLY=%d failed", v6only);
 	}
Signature · 1 line
1.9.1
#2 lore raw

[Openvpn-devel] [PATCH applied] Re: fix warnings on Windows

Your patch has been applied to the master branch.

commit a2466d9e6c78c57d579a1fa99c8554eabb9dbe44

Author: Heiko Hund
Date:   Sat Nov 15 17:25:08 2014 +0100
     fix warnings on Windows

     Signed-off-by: Heiko Hund <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/9229
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#3 lore raw
In reply to Heiko Hund

ACK. Tested in client and server mode on a Win7-VM.

Your patch has been applied to the master branch.

commit 78b8fc720b6e6c31a889e4efaa28dbbc31da65ea (master)

Author: Heiko Hund
Date:   Sat Nov 15 17:25:07 2014 +0100
     fix compilation on Windows

     Signed-off-by: Heiko Hund <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/9228
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#4 lore raw
In reply to Heiko Hund

ACK. Tested in client and server mode on a Win7-VM.

Your patch has been applied to the master branch.

commit 78b8fc720b6e6c31a889e4efaa28dbbc31da65ea (master)

Author: Heiko Hund
Date:   Sat Nov 15 17:25:07 2014 +0100
     fix compilation on Windows

     Signed-off-by: Heiko Hund <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/9228
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw

PATCH 1/1 Fix windows build on older mingw versions.

In reply to Heiko Hund

Add missing #define for IPV6_V6ONLY sockopt.

Fix last remaining fallout of dual-stack patch set in connect() call for "not CONNECT_NONBLOCK" case.

---
 src/openvpn/socket.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
src/openvpn/socket.c +9 -1
index 2499ab0..f3f6422 100644
@@ -1081,6 +1081,14 @@ socket_listen_accept (socket_descriptor_t sd,
   return new_sd;
 }
 
+/* older mingw versions and WinXP do not have this define, 
+ * but Vista and up support the functionality - just define it here
+ */
+#ifdef WIN32
+# ifndef IPV6_V6ONLY
+#  define IPV6_V6ONLY 27
+# endif
+#endif
 void
 socket_bind (socket_descriptor_t sd,
              struct addrinfo *local,
@@ -1211,7 +1219,7 @@ openvpn_connect (socket_descriptor_t sd,
 	}
     }
 #else
-  status = connect (sd, &remote->addr.sa, af_addr_size(remote->addr.sa.sa_family));
+  status = connect (sd, remote, af_addr_size(remote->sa_family));
   if (status)
     status = openvpn_errno ();
 #endif
Signature · 1 line
1.7.9.5
#6 lore raw

Re: [Openvpn-devel] [PATCH] Fix windows build on older mingw versions.

Am 17.11.14 21:58, schrieb Gert Doering:

Quoted 4 lines

Add missing #define for IPV6_V6ONLY sockopt.

Fix last remaining fallout of dual-stack patch set in connect() call for "not CONNECT_NONBLOCK" case.

I like your optimism.

Quoted 25 lines
---
 src/openvpn/socket.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
src/openvpn/socket.c +8 -0
index 2499ab0..f3f6422 100644
@@ -1081,6 +1081,14 @@ socket_listen_accept (socket_descriptor_t sd,
   return new_sd;
 }
 
+/* older mingw versions and WinXP do not have this define, 
+ * but Vista and up support the functionality - just define it here
+ */
+#ifdef WIN32
+# ifndef IPV6_V6ONLY
+#  define IPV6_V6ONLY 27
+# endif
+#endif
 void
 socket_bind (socket_descriptor_t sd,
              struct addrinfo *local,

src/openvpn/socket.c openvpn_connect (socket_descriptor_t sd, · line 1225

Quoted 8 lines
src/openvpn/socket.c +1 -1
@@ -1211,7 +1219,7 @@ openvpn_connect (socket_descriptor_t sd,
 	}
     }
 #else
-  status = connect (sd, &remote->addr.sa, af_addr_size(remote->addr.sa.sa_family));
+  status = connect (sd, remote, af_addr_size(remote->sa_family));
   if (status)
     status = openvpn_errno ();
 #endif

ACK

Arne

#7 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix windows build on older mingw versions.

In reply to Gert Doering

Your patch has been applied to the master branch.

commit 188a65153fb304db873694eaab21599e37ead908

Author: Gert Doering
Date:   Mon Nov 17 21:58:23 2014 +0100
     Fix windows build on older mingw versions.

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/9246

--
kind regards,

Gert Doering