]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
work around inet_ntop/inet_pton problems for MSVC builds on WinXP
authorGert Doering <gert@greenie.muc.de>
Thu, 24 Nov 2011 20:09:36 +0000 (21:09 +0100)
committerDavid Sommerseth <davids@redhat.com>
Fri, 25 Nov 2011 16:21:35 +0000 (17:21 +0100)
always use our built-in replacement functions now, even if building
on Win7 (which has inet_ntop/inet_pton in the system libraries) because
the resulting binary will then fail on WinXP.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
socket.c
win32.h

index 5302eca2bba56ee02b7feddef85823de28b29eb7..c8a86ea6fb1073e0e98738189c4d05ebac7b0f8c 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -3083,11 +3083,12 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
 /*
  * inet_ntop() and inet_pton() wrap-implementations using
  * WSAAddressToString() and WSAStringToAddress() functions
+ *
+ * this is needed as long as we support running OpenVPN on WinXP
  */
 
-#ifndef _MSC_VER
 const char *
-inet_ntop(int af, const void *src, char *dst, socklen_t size)
+openvpn_inet_ntop(int af, const void *src, char *dst, socklen_t size)
 {
   struct sockaddr_storage ss;
   unsigned long s = size;
@@ -3111,7 +3112,7 @@ inet_ntop(int af, const void *src, char *dst, socklen_t size)
 }
 
 int
-inet_pton(int af, const char *src, void *dst)
+openvpn_inet_pton(int af, const char *src, void *dst)
 {
   struct sockaddr_storage ss;
   int size = sizeof(ss);
@@ -3134,8 +3135,6 @@ inet_pton(int af, const char *src, void *dst)
   return 0;
 }
 
-#endif
-
 int
 socket_recv_queue (struct link_socket *sock, int maxsize)
 {
diff --git a/win32.h b/win32.h
index 9ee95ef4485ec6133e3ace83e476da207f716b58..23c04bedefb2af192d84d0932821e73e7b1a3f1b 100644 (file)
--- a/win32.h
+++ b/win32.h
@@ -276,10 +276,12 @@ char *get_win_sys_path (void);
 
 /* call self in a subprocess */
 void fork_to_self (const char *cmdline);
-#ifndef _MSC_VER
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
-int inet_pton(int af, const char *src, void *st);
-#endif
+
+const char *openvpn_inet_ntop(int af, const void *src,
+                              char *dst, socklen_t size);
+int openvpn_inet_pton(int af, const char *src, void *dst);
+#define inet_ntop(af,src,dst,size) openvpn_inet_ntop(af,src,dst,size)
+#define inet_pton(af,src,dst)      openvpn_inet_pton(af,src,dst)
 
 /* Find temporary directory */
 const char *win_get_tempdir();