]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Windows: fix getaddrinfo, getnameinfo, inet_ntop and inet_pton detection
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 21 Dec 2014 16:28:17 +0000 (08:28 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 21 Dec 2014 16:28:17 +0000 (08:28 -0800)
These API symbols are not always defined as functions, and in varying
locations. AC_REPLACE_FUNCS cannot handle that kind of complexity so we
must use AC_CHECK_DECL instead and provide the sequence of #include
necessary to identify their existence.

18 files changed:
compat/Makefile.am
compat/compat.h
compat/getaddrinfo.cc [moved from compat/getaddrinfo.c with 98% similarity]
compat/getaddrinfo.h
compat/getnameinfo.cc [moved from compat/getnameinfo.c with 99% similarity]
compat/getnameinfo.h
compat/inet_ntop.cc [moved from compat/inet_ntop.c with 99% similarity]
compat/inet_ntop.h
compat/inet_pton.cc [moved from compat/inet_pton.c with 99% similarity]
compat/inet_pton.h
compat/os/mswindows.h
configure.ac
helpers/negotiate_auth/kerberos/negotiate_kerberos_auth.cc
helpers/negotiate_auth/kerberos/negotiate_kerberos_pac.cc
lib/rfc3596.c
src/client_side_request.cc
src/ip/Address.cc
test-suite/pconn-banger.c

index 80669a21eb46e2a15af6e3107f937932916977d4..805ccb91171c51a1f99a2089b8b26c49982e7d62 100644 (file)
@@ -31,11 +31,15 @@ libcompat_squid_la_SOURCES = \
        eui64_aton.h \
        eui64_aton.c \
        fdsetsize.h \
+       getaddrinfo.cc \
        getaddrinfo.h \
+       getnameinfo.cc \
        getnameinfo.h \
        GnuRegex.c \
        GnuRegex.h \
+       inet_ntop.cc \
        inet_ntop.h \
+       inet_pton.cc \
        inet_pton.h \
        initgroups.h \
        memrchr.cc \
index 03dd7f64cd59463ead7c5d4a24913564fa009775..dee3253320142c7d5d7cabde31c84740d2b4c775 100644 (file)
 
 #include "compat/assert.h"
 #include "compat/compat_shared.h"
+#include "compat/getaddrinfo.h"
+#include "compat/getnameinfo.h"
+#include "compat/inet_ntop.h"
+#include "compat/inet_pton.h"
 #include "compat/stdvarargs.h"
 
 /* cstdio has a bunch of problems with 64-bit definitions */
similarity index 98%
rename from compat/getaddrinfo.c
rename to compat/getaddrinfo.cc
index 4d46ffc5dd394e3157a54929b2a14269e648283c..7f030f90f228ccf754a3fa064725f2aaa31c396c 100644 (file)
 /* An emulation of the RFC 2553 / Posix getaddrinfo resolver interface.
  */
 
-#if !HAVE_GETADDRINFO
+#if !HAVE_DECL_GETADDRINFO
 
 /* Need to turn off Posix features in glibc to build this */
 #undef _POSIX_C_SOURCE
 #undef _XOPEN_SOURCE
 
-#include "compat/getaddrinfo.h"
-#include "compat/inet_pton.h"
-
 #if HAVE_STRING_H
 #include <string.h>
 #endif
@@ -332,5 +329,5 @@ xgai_strerror (int ecode)
     return eai_descr[ecode];
 }
 
-#endif /* HAVE_GETADDRINFO */
+#endif /* HAVE_DECL_GETADDRINFO */
 
index 0b5af56bbc10690c6b5880ba0af9df7e618f6f41..2e17d48b32a775b42852e4889a3b6293ec04bfbb 100644 (file)
@@ -49,7 +49,7 @@
 /* Structure and prototypes taken from RFC 2553 */
 
 /* These functions are provided by the OS */
-#if !HAVE_GETADDRINFO
+#if !HAVE_DECL_GETADDRINFO
 
 /* SG 23/09/2007:
 On Windows the following definitions are already available, may be that
@@ -112,6 +112,6 @@ SQUIDCEXTERN const char *xgai_strerror (int code);
 #define gai_strerror    xgai_strerror
 #endif
 
-#endif /* HAVE_GETADDRINFO */
+#endif /* HAVE_DECL_GETADDRINFO */
 #endif /* _getaddrinfo_h */
 
similarity index 99%
rename from compat/getnameinfo.c
rename to compat/getnameinfo.cc
index 100354a57d1c8be6bab12c41a436d85c07308d53..dd17c5f521a354529752a9ac1d13e8f48a05cf1e 100644 (file)
  *     - gethostbyaddr() is usually not thread safe.
  */
 
-#if !HAVE_GETNAMEINFO
-
-#include "compat/getaddrinfo.h"
-#include "compat/inet_ntop.h"
+#if !HAVE_DECL_GETNAMEINFO
 
 #if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
@@ -424,5 +421,5 @@ int flags;
         return n;
 }
 #endif /* INET6 */
-#endif
+#endif /* HAVE_DECL_GETNAMEINFO */
 
index 605f6ca112ab8aa9a1f511521b583c0efbbe8d09..f09df8c6bf1b6badbff7ca61a4ca6a3931b5a523 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef _getnameinfo_h
 #define _getnameinfo_h
 
-#if !HAVE_GETNAMEINFO
+#if !HAVE_DECL_GETNAMEINFO
 
 // RFC 2553 / Posix resolver
 // Reconstructed from KAME getnameinfo.c
@@ -22,6 +22,6 @@ SQUIDCEXTERN int xgetnameinfo(const struct sockaddr *sa,
                               int flags );
 #define getnameinfo xgetnameinfo
 
-#endif /* HAVE_GETNAMEINFO */
+#endif /* HAVE_DECL_GETNAMEINFO */
 #endif /* _getnameinfo_h */
 
similarity index 99%
rename from compat/inet_ntop.c
rename to compat/inet_ntop.cc
index a99ae61ec298fbf3f893f801725066af62bea291..1ea6580362bb8015a0c62fa95c73932cc6ebcb0a 100644 (file)
@@ -29,8 +29,7 @@
 
 #include "squid.h"
 
-#if !HAVE_INET_NTOP
-#include "inet_ntop.h"
+#if !HAVE_DECL_INET_NTOP
 
 /*
  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -253,5 +252,5 @@ size_t size;
     return (dst);
 }
 
-#endif /* HAVE_INET_NTOP */
+#endif /* HAVE_DECL_INET_NTOP */
 
index 454a8a8bd9fe603fb2e7eaabd5e842d6beee6691..7ae80a9691d73bdb09bd6c055def43135e0d5da9 100644 (file)
@@ -10,7 +10,7 @@
 #define _INC_INET_NTOP_H
 
 /* Use the system provided version where possible */
-#if !HAVE_INET_NTOP
+#if !HAVE_DECL_INET_NTOP
 
 /* char *
 * inet_ntop(af, src, dst, size)
@@ -23,6 +23,6 @@
 SQUIDCEXTERN const char * xinet_ntop(int af, const void *src, char *dst, size_t size);
 #define inet_ntop xinet_ntop
 
-#endif
+#endif /* HAVE_DECL_INET_NTOP */
 #endif /* _INC_INET_NTOP_H */
 
similarity index 99%
rename from compat/inet_pton.c
rename to compat/inet_pton.cc
index 7e158b805c428c01093b907113d32a0bc9ae6052..8090903b0b7266c7484af6dee4f5dda67c3f4f1b 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "squid.h"
 
-#if !HAVE_INET_PTON
+#if !HAVE_DECL_INET_PTON
 
 /*
  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -274,5 +274,5 @@ u_char *dst;
     return (1);
 }
 
-#endif /* HAVE_INET_PTON */
+#endif /* HAVE_DECL_INET_PTON */
 
index d0d46c49c681fafef6412fd024126ad5fc502b1e..30f563ecc1d0d8cbbbd083adb00bc1644635bc3c 100644 (file)
@@ -10,7 +10,7 @@
 #define _INC_INET_PTON_H
 
 /* Use the system provided version where possible */
-#if !HAVE_INET_PTON
+#if !HAVE_DECL_INET_PTON
 
 /* int
 * inet_pton(af, src, dst)
@@ -26,6 +26,6 @@
 SQUIDCEXTERN int xinet_pton(int af, const char *src, void *dst);
 #define inet_pton xinet_pton
 
-#endif
+#endif /* HAVE_DECL_INET_PTON */
 #endif /* _INC_INET_NTOP_H */
 
index 1d3e6eb2fe08e362d7cf760f866136775973fa5b..0f31a2d52a7215982361b790b485d105fd535a92 100644 (file)
@@ -621,6 +621,13 @@ getsockopt(int s, int l, int o, void * v, socklen_t * n)
 }
 #define getsockopt(s,l,o,v,n) Squid::getsockopt(s,l,o,v,n)
 
+inline char *
+inet_ntop(int af, const void *src, char *dst, size_t size)
+{
+    return (char*)InetNtopA(af, const_cast<void*>(src), dst, size);
+}
+#define inet_ntop(a,s,d,l) Squid::inet_ntop(a,s,d,l)
+
 /* Simple ioctl() emulation */
 inline int
 ioctl(int s, int c, void * a)
index bc586c6b9977d3363b7d7734680a8af4c86b4615..bcf67bbf68817cbca7696a1cbed7d54573dedfc8 100644 (file)
@@ -3346,17 +3346,42 @@ AC_CHECK_FUNCS(\
 dnl ... and some we provide local replacements for
 AC_REPLACE_FUNCS(\
        drand48 \
-       inet_ntop \
-       inet_pton \
        initgroups \
-       getaddrinfo \
-       getnameinfo \
        psignal \
        strerror \
        strtoll \
        tempnam \
 )
 
+AC_CHECK_DECLS([getaddrinfo,getnameinfo,inet_ntop,inet_pton],,,[
+/*
+ * BSD requires sys/types.h, sys/socket.h, netinet/in.h, netdb.h, arpa/inet.h
+ * Linux requires sys/types.h, sys/socket.h, arpa/inet.h
+ * Windows requires sys/socket.h, winsock2.h, ws2tcpip.h
+ */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#if HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+])
+
 # Magic which checks whether we are forcing a type of comm loop we
 # are actually going to (ab)use.
 # Mostly ripped from squid-commloops, thanks to adrian and benno
index 58bd591cd382d08531b185a211d22783e05a85e2..bf209decf621fbe63e8d0ddf87a32b39068618f1 100644 (file)
@@ -36,8 +36,6 @@
  */
 
 #include "squid.h"
-#include "compat/getaddrinfo.h"
-#include "compat/getnameinfo.h"
 #include "rfc1738.h"
 
 #if HAVE_GSSAPI
index d084ee4a18ea5e1679f33926d28ec644444a5023..d5078b78ebe5b8ab875c6f7c8c88826962ac028d 100644 (file)
@@ -36,8 +36,6 @@
  */
 
 #include "squid.h"
-#include "compat/getaddrinfo.h"
-#include "compat/getnameinfo.h"
 #include "rfc1738.h"
 
 #include "negotiate_kerberos.h"
index 6cae278680c023ccdd2426944834b7efe5452494..5544ea3b59a6d0dcf8252f2574f78d0741aa41ac 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include "squid.h"
-#include "compat/inet_pton.h"
 #include "util.h"
 
 #if HAVE_UNISTD_H
index 999e2db20f18c57e882afb6c67cafa0d97cec671..9ce8f51d23e41e5778722fc444036c48c95318dc 100644 (file)
@@ -28,7 +28,6 @@
 #include "clientStream.h"
 #include "comm/Connection.h"
 #include "comm/Write.h"
-#include "compat/inet_pton.h"
 #include "err_detail_type.h"
 #include "errorpage.h"
 #include "fd.h"
index e4bb1b2d206edfd86edffd953164505dab3a6516..1cf2d1e8929f8a47ceb1c14911f6b00a54660a54 100644 (file)
@@ -9,8 +9,6 @@
 /* DEBUG: section 14    IP Storage and Handling */
 
 #include "squid.h"
-#include "compat/getaddrinfo.h"
-#include "compat/inet_ntop.h"
 #include "Debug.h"
 #include "ip/Address.h"
 #include "ip/tools.h"
index e0e49f1115bd97229181b645e85c030e99911a3e..d3224bf7f717e8b904aee5ec317c94154c9556f4 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include "squid.h"
-#include "compat/getaddrinfo.h"
 
 #if HAVE_UNISTD_H
 #include <unistd.h>