#include <sys/socket.h>
#endif
-// WinSock2.h defines these for Windows
+// mswsock.h defines WSA_CMSG definitions
+#if HAVE_MSWSOCK_H
+#include <mswsock.h>
+#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#endif
/* lifted off https://metacpan.org/source/SAMPO/Socket-PassAccessRights-0.03/passfd.c */
-#ifndef CMSG_DATA
-# define CMSG_DATA(cmsg) ((cmsg)->cmsg_data)
+// check for WSA_CMSG first because Windows defines CMSG_DATA for other uses
+#if defined(WSA_CMSG_DATA)
+# define SQUID_CMSG_DATA(cmsg) WSA_CMSG_DATA(cmsg)
+#elif defined(CMSG_DATA)
+# define SQUID_CMSG_DATA(cmsg) CMSG_DATA(cmsg)
+#else
+# define SQUID_CMSG_DATA(cmsg) ((cmsg)->cmsg_data)
#endif
#ifndef CMSG_NXTHDR
-# define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
+# define CMSG_NXTHDR(mhdr, X) __cmsg_nxthdr (mhdr, X)
#endif
#ifndef CMSG_FIRSTHDR
windows.h \
ws2tcpip.h \
iphlpapi.h ,,,[
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
#if HAVE_WINDOWS_H
#include <windows.h>
#endif
-#if HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif])
+#if HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+])
fi
# check that we have unix sockets
AC_DEFINE(HAVE_SETRESUID,1,[Yay! Another Linux brokenness. Knowing that setresuid() exists is not enough, because RedHat 5.0 declares setresuid() but does not implement it.])
fi
+AC_CHECK_HEADERS(mswsock.h)
AC_MSG_CHECKING([for constant CMSG_SPACE])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+ #if HAVE_MSWSOCK_H
+ #include <mswsock.h>
+ #endif
int a[CMSG_SPACE(int)];
]])], [
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+ #if HAVE_MSWSOCK_H
+ #include <mswsock.h>
+ #endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+ #if HAVE_MSWSOCK_H
+ #include <mswsock.h>
+ #endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
break;
if (o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS) {
- int *tmp = (int*)CMSG_DATA(o);
+ int *tmp = (int*)SQUID_CMSG_DATA(o);
clientFde->tosFromServer = (tos_t)*tmp;
break;
}
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fdCount);
- int *fdStore = reinterpret_cast<int*>(CMSG_DATA(cmsg));
+ int *fdStore = reinterpret_cast<int*>(SQUID_CMSG_DATA(cmsg));
memcpy(fdStore, &fd, fdCount * sizeof(int));
msg_controllen = cmsg->cmsg_len;
Must(cmsg->cmsg_type == SCM_RIGHTS);
const int fdCount = 1;
- const int *fdStore = reinterpret_cast<const int*>(CMSG_DATA(cmsg));
+ const int *fdStore = reinterpret_cast<const int*>(SQUID_CMSG_DATA(cmsg));
int fd = -1;
memcpy(&fd, fdStore, fdCount * sizeof(int));
return fd;