From 6a66f19332b140a32d9944eed959344e4a041f5a Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Mon, 17 Oct 2011 17:35:42 +0000 Subject: [PATCH] Windows fixes for IPv6 and CIDR support. --- Shibboleth.sln | 1 - configs/console.logger | 1 + configs/native.logger.in | 1 + configs/shibd.logger.in | 1 + shibsp/remoting/impl/SocketListener.h | 2 +- shibsp/remoting/impl/TCPListener.cpp | 4 ++-- shibsp/shibsp-lite.vcxproj | 10 +++++----- shibsp/shibsp.vcxproj | 8 ++++---- shibsp/util/IPRange.cpp | 4 ++-- shibsp/util/IPRange.h | 2 +- 10 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Shibboleth.sln b/Shibboleth.sln index 83a50e5..7169046 100644 --- a/Shibboleth.sln +++ b/Shibboleth.sln @@ -72,7 +72,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{31B171C1-E ProjectSection(SolutionItems) = preProject m4\acinclude.m4 = m4\acinclude.m4 m4\acx_pthread.m4 = m4\acx_pthread.m4 - config_win32.h = config_win32.h configure.ac = configure.ac doxygen.am = doxygen.am doxygen.cfg = doxygen.cfg diff --git a/configs/console.logger b/configs/console.logger index 06fadfd..08f5128 100644 --- a/configs/console.logger +++ b/configs/console.logger @@ -3,6 +3,7 @@ log4j.rootCategory=WARN, console # fairly verbose for DEBUG, so generally leave at INFO log4j.category.XMLTooling.XMLObject=INFO log4j.category.XMLTooling.KeyInfoResolver=INFO +log4j.category.Shibboleth.IPRange=INFO log4j.category.Shibboleth.PropertySet=INFO # raise for low-level tracing of SOAP client HTTP/SSL behavior diff --git a/configs/native.logger.in b/configs/native.logger.in index 8c17632..52a90ae 100644 --- a/configs/native.logger.in +++ b/configs/native.logger.in @@ -4,6 +4,7 @@ log4j.rootCategory=INFO, native_log, warn_log # fairly verbose for DEBUG, so generally leave at INFO log4j.category.XMLTooling.XMLObject=INFO log4j.category.XMLTooling.KeyInfoResolver=INFO +log4j.category.Shibboleth.IPRange=INFO log4j.category.Shibboleth.PropertySet=INFO # raise for low-level tracing of SOAP client HTTP/SSL behavior diff --git a/configs/shibd.logger.in b/configs/shibd.logger.in index 4ce707d..d2e8473 100644 --- a/configs/shibd.logger.in +++ b/configs/shibd.logger.in @@ -4,6 +4,7 @@ log4j.rootCategory=INFO, shibd_log, warn_log # fairly verbose for DEBUG, so generally leave at INFO log4j.category.XMLTooling.XMLObject=INFO log4j.category.XMLTooling.KeyInfoResolver=INFO +log4j.category.Shibboleth.IPRange=INFO log4j.category.Shibboleth.PropertySet=INFO # raise for low-level tracing of SOAP client HTTP/SSL behavior diff --git a/shibsp/remoting/impl/SocketListener.h b/shibsp/remoting/impl/SocketListener.h index bbcde89..e6b4fed 100644 --- a/shibsp/remoting/impl/SocketListener.h +++ b/shibsp/remoting/impl/SocketListener.h @@ -38,7 +38,7 @@ #include #ifdef WIN32 -# include +# include #endif namespace shibsp { diff --git a/shibsp/remoting/impl/TCPListener.cpp b/shibsp/remoting/impl/TCPListener.cpp index ff49126..fe8884f 100644 --- a/shibsp/remoting/impl/TCPListener.cpp +++ b/shibsp/remoting/impl/TCPListener.cpp @@ -205,7 +205,7 @@ bool TCPListener::bind(ShibSocket& s, bool force) const ::setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt, sizeof(opt)); #ifdef WIN32 - if (SOCKET_ERROR==::bind(s, (const struct sockaddr*)&m_sockaddr, m_sockaddr.ss_len) || SOCKET_ERROR==::listen(s, 3)) { + if (SOCKET_ERROR==::bind(s, (const struct sockaddr*)&m_sockaddr, sizeof(m_sockaddr)) || SOCKET_ERROR==::listen(s, 3)) { log_error("bind"); close(s); return false; @@ -229,7 +229,7 @@ bool TCPListener::bind(ShibSocket& s, bool force) const bool TCPListener::connect(ShibSocket& s) const { #ifdef WIN32 - if(SOCKET_ERROR==::connect(s, (const struct sockaddr*)&m_sockaddr, m_sockaddr.ss_len)) + if(SOCKET_ERROR==::connect(s, (const struct sockaddr*)&m_sockaddr, sizeof(m_sockaddr))) return log_error("connect"); #else # ifdef HAVE_STRUCT_SOCKADDR_STORAGE diff --git a/shibsp/shibsp-lite.vcxproj b/shibsp/shibsp-lite.vcxproj index 7802ee7..0dcdf35 100644 --- a/shibsp/shibsp-lite.vcxproj +++ b/shibsp/shibsp-lite.vcxproj @@ -101,7 +101,7 @@ _UNICODE;UNICODE;SHIBSP_LITE;_DEBUG;%(PreprocessorDefinitions) - log4shib1D.lib;xerces-c_3D.lib;xmltooling-lite1D.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1D.lib;xerces-c_3D.lib;xmltooling-lite1D.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-xmltooling\$(Configuration);%(AdditionalLibraryDirectories) true Windows @@ -127,7 +127,7 @@ _UNICODE;UNICODE;SHIBSP_LITE;_DEBUG;%(PreprocessorDefinitions) - log4shib1D.lib;xerces-c_3D.lib;xmltooling-lite1D.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1D.lib;xerces-c_3D.lib;xmltooling-lite1D.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-xmltooling\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) true Windows @@ -146,7 +146,7 @@ _UNICODE;UNICODE;SHIBSP_LITE;%(PreprocessorDefinitions) - log4shib1.lib;xerces-c_3.lib;xmltooling-lite1.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1.lib;xerces-c_3.lib;xmltooling-lite1.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-xmltooling\$(Configuration);%(AdditionalLibraryDirectories) Windows true @@ -170,7 +170,7 @@ _UNICODE;UNICODE;SHIBSP_LITE;%(PreprocessorDefinitions) - log4shib1.lib;xerces-c_3.lib;xmltooling-lite1.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1.lib;xerces-c_3.lib;xmltooling-lite1.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-xmltooling\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) true Windows @@ -294,4 +294,4 @@ - + \ No newline at end of file diff --git a/shibsp/shibsp.vcxproj b/shibsp/shibsp.vcxproj index 93eb4bf..0912a36 100644 --- a/shibsp/shibsp.vcxproj +++ b/shibsp/shibsp.vcxproj @@ -99,7 +99,7 @@ _UNICODE;UNICODE;_DEBUG;%(PreprocessorDefinitions) - log4shib1D.lib;xerces-c_3D.lib;xsec_1D.lib;saml2D.lib;xmltooling1D.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1D.lib;xerces-c_3D.lib;xsec_1D.lib;saml2D.lib;xmltooling1D.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-opensaml\$(Configuration);..\..\cpp-xmltooling\$(Configuration);%(AdditionalLibraryDirectories) true Windows @@ -125,7 +125,7 @@ _UNICODE;UNICODE;_DEBUG;%(PreprocessorDefinitions) - log4shib1D.lib;xerces-c_3D.lib;xsec_1D.lib;saml2D.lib;xmltooling1D.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1D.lib;xerces-c_3D.lib;xsec_1D.lib;saml2D.lib;xmltooling1D.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-opensaml\$(Platform)\$(Configuration);..\..\cpp-xmltooling\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) true Windows @@ -141,7 +141,7 @@ Level3 - log4shib1.lib;xerces-c_3.lib;xsec_1.lib;saml2.lib;xmltooling1.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1.lib;xerces-c_3.lib;xsec_1.lib;saml2.lib;xmltooling1.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-opensaml\$(Configuration);..\..\cpp-xmltooling\$(Configuration);%(AdditionalLibraryDirectories) Windows true @@ -162,7 +162,7 @@ Level3 - log4shib1.lib;xerces-c_3.lib;xsec_1.lib;saml2.lib;xmltooling1.lib;wsock32.lib;%(AdditionalDependencies) + log4shib1.lib;xerces-c_3.lib;xsec_1.lib;saml2.lib;xmltooling1.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies) ..\..\cpp-opensaml\$(Platform)\$(Configuration);..\..\cpp-xmltooling\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) true Windows diff --git a/shibsp/util/IPRange.cpp b/shibsp/util/IPRange.cpp index 72dd8fc..6ff85d6 100644 --- a/shibsp/util/IPRange.cpp +++ b/shibsp/util/IPRange.cpp @@ -115,7 +115,7 @@ bool IPRange::contains(const struct sockaddr* address) const return false; unsigned long raw = 0; memcpy(&raw, &((struct sockaddr_in*)address)->sin_addr, 4); - bitset<32> rawbits(ntohl(raw)); // the bitset loads from a host-order variable + bitset<32> rawbits((int)ntohl(raw)); // the bitset loads from a host-order variable if (log.isDebugEnabled()) { log.debug( "comparing address (%s) to network (%s) with mask (%s)", @@ -172,7 +172,7 @@ IPRange IPRange::parseCIDRBlock(const char* cidrBlock) unsigned long raw = 0; memcpy(&raw, &((struct sockaddr_in*)address->ai_addr)->sin_addr, 4); freeaddrinfo(address); - bitset<32> rawbits(ntohl(raw)); // the bitset loads from a host-order variable + bitset<32> rawbits((int)ntohl(raw)); // the bitset loads from a host-order variable return IPRange(rawbits, maskSize); } #ifdef AF_INET6 diff --git a/shibsp/util/IPRange.h b/shibsp/util/IPRange.h index d4198bc..84c0f19 100644 --- a/shibsp/util/IPRange.h +++ b/shibsp/util/IPRange.h @@ -32,7 +32,7 @@ #include #ifdef WIN32 -# include +# include #elif defined(SHIBSP_HAVE_SYS_SOCKET_H) # include #endif -- 2.1.4