SF#3560776: Fix byte-ordering issues with INADDR_* literals

This commit is contained in:
Aleksandar Fabijanic
2012-09-07 03:34:08 +00:00
parent 03b7dcd3e1
commit 2a6c041422
2 changed files with 226 additions and 224 deletions

View File

@@ -41,279 +41,278 @@
#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(POCO_OS_FAMILY_WINDOWS)
#include "Poco/UnWindows.h" #include "Poco/UnWindows.h"
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#define POCO_INVALID_SOCKET INVALID_SOCKET #define POCO_INVALID_SOCKET INVALID_SOCKET
#define poco_socket_t SOCKET #define poco_socket_t SOCKET
#define poco_socklen_t int #define poco_socklen_t int
#define poco_ioctl_request_t int #define poco_ioctl_request_t int
#define poco_closesocket(s) closesocket(s) #define poco_closesocket(s) closesocket(s)
#define POCO_EINTR WSAEINTR #define POCO_EINTR WSAEINTR
#define POCO_EACCES WSAEACCES #define POCO_EACCES WSAEACCES
#define POCO_EFAULT WSAEFAULT #define POCO_EFAULT WSAEFAULT
#define POCO_EINVAL WSAEINVAL #define POCO_EINVAL WSAEINVAL
#define POCO_EMFILE WSAEMFILE #define POCO_EMFILE WSAEMFILE
#define POCO_EAGAIN WSAEWOULDBLOCK #define POCO_EAGAIN WSAEWOULDBLOCK
#define POCO_EWOULDBLOCK WSAEWOULDBLOCK #define POCO_EWOULDBLOCK WSAEWOULDBLOCK
#define POCO_EINPROGRESS WSAEINPROGRESS #define POCO_EINPROGRESS WSAEINPROGRESS
#define POCO_EALREADY WSAEALREADY #define POCO_EALREADY WSAEALREADY
#define POCO_ENOTSOCK WSAENOTSOCK #define POCO_ENOTSOCK WSAENOTSOCK
#define POCO_EDESTADDRREQ WSAEDESTADDRREQ #define POCO_EDESTADDRREQ WSAEDESTADDRREQ
#define POCO_EMSGSIZE WSAEMSGSIZE #define POCO_EMSGSIZE WSAEMSGSIZE
#define POCO_EPROTOTYPE WSAEPROTOTYPE #define POCO_EPROTOTYPE WSAEPROTOTYPE
#define POCO_ENOPROTOOPT WSAENOPROTOOPT #define POCO_ENOPROTOOPT WSAENOPROTOOPT
#define POCO_EPROTONOSUPPORT WSAEPROTONOSUPPORT #define POCO_EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define POCO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT #define POCO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#define POCO_ENOTSUP WSAEOPNOTSUPP #define POCO_ENOTSUP WSAEOPNOTSUPP
#define POCO_EPFNOSUPPORT WSAEPFNOSUPPORT #define POCO_EPFNOSUPPORT WSAEPFNOSUPPORT
#define POCO_EAFNOSUPPORT WSAEAFNOSUPPORT #define POCO_EAFNOSUPPORT WSAEAFNOSUPPORT
#define POCO_EADDRINUSE WSAEADDRINUSE #define POCO_EADDRINUSE WSAEADDRINUSE
#define POCO_EADDRNOTAVAIL WSAEADDRNOTAVAIL #define POCO_EADDRNOTAVAIL WSAEADDRNOTAVAIL
#define POCO_ENETDOWN WSAENETDOWN #define POCO_ENETDOWN WSAENETDOWN
#define POCO_ENETUNREACH WSAENETUNREACH #define POCO_ENETUNREACH WSAENETUNREACH
#define POCO_ENETRESET WSAENETRESET #define POCO_ENETRESET WSAENETRESET
#define POCO_ECONNABORTED WSAECONNABORTED #define POCO_ECONNABORTED WSAECONNABORTED
#define POCO_ECONNRESET WSAECONNRESET #define POCO_ECONNRESET WSAECONNRESET
#define POCO_ENOBUFS WSAENOBUFS #define POCO_ENOBUFS WSAENOBUFS
#define POCO_EISCONN WSAEISCONN #define POCO_EISCONN WSAEISCONN
#define POCO_ENOTCONN WSAENOTCONN #define POCO_ENOTCONN WSAENOTCONN
#define POCO_ESHUTDOWN WSAESHUTDOWN #define POCO_ESHUTDOWN WSAESHUTDOWN
#define POCO_ETIMEDOUT WSAETIMEDOUT #define POCO_ETIMEDOUT WSAETIMEDOUT
#define POCO_ECONNREFUSED WSAECONNREFUSED #define POCO_ECONNREFUSED WSAECONNREFUSED
#define POCO_EHOSTDOWN WSAEHOSTDOWN #define POCO_EHOSTDOWN WSAEHOSTDOWN
#define POCO_EHOSTUNREACH WSAEHOSTUNREACH #define POCO_EHOSTUNREACH WSAEHOSTUNREACH
#define POCO_ESYSNOTREADY WSASYSNOTREADY #define POCO_ESYSNOTREADY WSASYSNOTREADY
#define POCO_ENOTINIT WSANOTINITIALISED #define POCO_ENOTINIT WSANOTINITIALISED
#define POCO_HOST_NOT_FOUND WSAHOST_NOT_FOUND #define POCO_HOST_NOT_FOUND WSAHOST_NOT_FOUND
#define POCO_TRY_AGAIN WSATRY_AGAIN #define POCO_TRY_AGAIN WSATRY_AGAIN
#define POCO_NO_RECOVERY WSANO_RECOVERY #define POCO_NO_RECOVERY WSANO_RECOVERY
#define POCO_NO_DATA WSANO_DATA #define POCO_NO_DATA WSANO_DATA
#elif defined(POCO_VXWORKS) #elif defined(POCO_VXWORKS)
#include <hostLib.h> #include <hostLib.h>
#include <ifLib.h> #include <ifLib.h>
#include <inetLib.h> #include <inetLib.h>
#include <ioLib.h> #include <ioLib.h>
#include <resolvLib.h> #include <resolvLib.h>
#include <types.h> #include <types.h>
#include <socket.h> #include <socket.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#define POCO_INVALID_SOCKET -1 #define POCO_INVALID_SOCKET -1
#define poco_socket_t int #define poco_socket_t int
#define poco_socklen_t int #define poco_socklen_t int
#define poco_ioctl_request_t int #define poco_ioctl_request_t int
#define poco_closesocket(s) ::close(s) #define poco_closesocket(s) ::close(s)
#define POCO_EINTR EINTR #define POCO_EINTR EINTR
#define POCO_EACCES EACCES #define POCO_EACCES EACCES
#define POCO_EFAULT EFAULT #define POCO_EFAULT EFAULT
#define POCO_EINVAL EINVAL #define POCO_EINVAL EINVAL
#define POCO_EMFILE EMFILE #define POCO_EMFILE EMFILE
#define POCO_EAGAIN EAGAIN #define POCO_EAGAIN EAGAIN
#define POCO_EWOULDBLOCK EWOULDBLOCK #define POCO_EWOULDBLOCK EWOULDBLOCK
#define POCO_EINPROGRESS EINPROGRESS #define POCO_EINPROGRESS EINPROGRESS
#define POCO_EALREADY EALREADY #define POCO_EALREADY EALREADY
#define POCO_ENOTSOCK ENOTSOCK #define POCO_ENOTSOCK ENOTSOCK
#define POCO_EDESTADDRREQ EDESTADDRREQ #define POCO_EDESTADDRREQ EDESTADDRREQ
#define POCO_EMSGSIZE EMSGSIZE #define POCO_EMSGSIZE EMSGSIZE
#define POCO_EPROTOTYPE EPROTOTYPE #define POCO_EPROTOTYPE EPROTOTYPE
#define POCO_ENOPROTOOPT ENOPROTOOPT #define POCO_ENOPROTOOPT ENOPROTOOPT
#define POCO_EPROTONOSUPPORT EPROTONOSUPPORT #define POCO_EPROTONOSUPPORT EPROTONOSUPPORT
#define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT #define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT
#define POCO_ENOTSUP ENOTSUP #define POCO_ENOTSUP ENOTSUP
#define POCO_EPFNOSUPPORT EPFNOSUPPORT #define POCO_EPFNOSUPPORT EPFNOSUPPORT
#define POCO_EAFNOSUPPORT EAFNOSUPPORT #define POCO_EAFNOSUPPORT EAFNOSUPPORT
#define POCO_EADDRINUSE EADDRINUSE #define POCO_EADDRINUSE EADDRINUSE
#define POCO_EADDRNOTAVAIL EADDRNOTAVAIL #define POCO_EADDRNOTAVAIL EADDRNOTAVAIL
#define POCO_ENETDOWN ENETDOWN #define POCO_ENETDOWN ENETDOWN
#define POCO_ENETUNREACH ENETUNREACH #define POCO_ENETUNREACH ENETUNREACH
#define POCO_ENETRESET ENETRESET #define POCO_ENETRESET ENETRESET
#define POCO_ECONNABORTED ECONNABORTED #define POCO_ECONNABORTED ECONNABORTED
#define POCO_ECONNRESET ECONNRESET #define POCO_ECONNRESET ECONNRESET
#define POCO_ENOBUFS ENOBUFS #define POCO_ENOBUFS ENOBUFS
#define POCO_EISCONN EISCONN #define POCO_EISCONN EISCONN
#define POCO_ENOTCONN ENOTCONN #define POCO_ENOTCONN ENOTCONN
#define POCO_ESHUTDOWN ESHUTDOWN #define POCO_ESHUTDOWN ESHUTDOWN
#define POCO_ETIMEDOUT ETIMEDOUT #define POCO_ETIMEDOUT ETIMEDOUT
#define POCO_ECONNREFUSED ECONNREFUSED #define POCO_ECONNREFUSED ECONNREFUSED
#define POCO_EHOSTDOWN EHOSTDOWN #define POCO_EHOSTDOWN EHOSTDOWN
#define POCO_EHOSTUNREACH EHOSTUNREACH #define POCO_EHOSTUNREACH EHOSTUNREACH
#define POCO_ESYSNOTREADY -4 #define POCO_ESYSNOTREADY -4
#define POCO_ENOTINIT -5 #define POCO_ENOTINIT -5
#define POCO_HOST_NOT_FOUND HOST_NOT_FOUND #define POCO_HOST_NOT_FOUND HOST_NOT_FOUND
#define POCO_TRY_AGAIN TRY_AGAIN #define POCO_TRY_AGAIN TRY_AGAIN
#define POCO_NO_RECOVERY NO_RECOVERY #define POCO_NO_RECOVERY NO_RECOVERY
#define POCO_NO_DATA NO_DATA #define POCO_NO_DATA NO_DATA
#elif defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_VMS) #elif defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_VMS)
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <fcntl.h> #include <fcntl.h>
#if POCO_OS != POCO_OS_HPUX #if POCO_OS != POCO_OS_HPUX
#include <sys/select.h> #include <sys/select.h>
#endif #endif
#include <sys/ioctl.h> #include <sys/ioctl.h>
#if defined(POCO_OS_FAMILY_VMS) #if defined(POCO_OS_FAMILY_VMS)
#include <inet.h> #include <inet.h>
#else #else
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
#if (POCO_OS == POCO_OS_LINUX) #if (POCO_OS == POCO_OS_LINUX)
// <linux/if.h> is needed by NetworkInterface for ifmap, ifreq and ifconf definitions // <linux/if.h> is needed by NetworkInterface for ifmap, ifreq and ifconf definitions
#include <linux/if.h> #include <linux/if.h>
// if_nametoindex and if_indextoname are needed by IPAddress and NetworkInterface // if_nametoindex and if_indextoname are needed by IPAddress and NetworkInterface
// we can't get them from <net/if.h> because of a conflict with <linux/if.h>, so // we can't get them from <net/if.h> because of a conflict with <linux/if.h>, so
// we declare them here // we declare them here
extern "C" extern "C"
{ {
extern unsigned int if_nametoindex (__const char *__ifname) __THROW; extern unsigned int if_nametoindex (__const char *__ifname) __THROW;
extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW; extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
} }
#else // (POCO_OS != POCO_OS_LINUX) #else
#include <net/if.h> #include <net/if.h>
#endif // (POCO_OS != POCO_OS_LINUX) #endif
#endif #endif
#if defined(sun) || defined(__APPLE__) #if (POCO_OS == POCO_OS_SOLARIS) || (POCO_OS == POCO_OS_MAC_OS_X)
#include <sys/sockio.h> #include <sys/sockio.h>
#include <sys/filio.h> #include <sys/filio.h>
#endif #endif
#define POCO_INVALID_SOCKET -1 #define POCO_INVALID_SOCKET -1
#define poco_socket_t int #define poco_socket_t int
#define poco_socklen_t socklen_t #define poco_socklen_t socklen_t
#define poco_fcntl_request_t int #define poco_fcntl_request_t int
#if defined(POCO_OS_FAMILY_BSD) #if defined(POCO_OS_FAMILY_BSD)
#define poco_ioctl_request_t unsigned long #define poco_ioctl_request_t unsigned long
#else #else
#define poco_ioctl_request_t int #define poco_ioctl_request_t int
#endif #endif
#define poco_closesocket(s) ::close(s) #define poco_closesocket(s) ::close(s)
#define POCO_EINTR EINTR #define POCO_EINTR EINTR
#define POCO_EACCES EACCES #define POCO_EACCES EACCES
#define POCO_EFAULT EFAULT #define POCO_EFAULT EFAULT
#define POCO_EINVAL EINVAL #define POCO_EINVAL EINVAL
#define POCO_EMFILE EMFILE #define POCO_EMFILE EMFILE
#define POCO_EAGAIN EAGAIN #define POCO_EAGAIN EAGAIN
#define POCO_EWOULDBLOCK EWOULDBLOCK #define POCO_EWOULDBLOCK EWOULDBLOCK
#define POCO_EINPROGRESS EINPROGRESS #define POCO_EINPROGRESS EINPROGRESS
#define POCO_EALREADY EALREADY #define POCO_EALREADY EALREADY
#define POCO_ENOTSOCK ENOTSOCK #define POCO_ENOTSOCK ENOTSOCK
#define POCO_EDESTADDRREQ EDESTADDRREQ #define POCO_EDESTADDRREQ EDESTADDRREQ
#define POCO_EMSGSIZE EMSGSIZE #define POCO_EMSGSIZE EMSGSIZE
#define POCO_EPROTOTYPE EPROTOTYPE #define POCO_EPROTOTYPE EPROTOTYPE
#define POCO_ENOPROTOOPT ENOPROTOOPT #define POCO_ENOPROTOOPT ENOPROTOOPT
#define POCO_EPROTONOSUPPORT EPROTONOSUPPORT #define POCO_EPROTONOSUPPORT EPROTONOSUPPORT
#if defined(ESOCKTNOSUPPORT) #if defined(ESOCKTNOSUPPORT)
#define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT #define POCO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT
#else #else
#define POCO_ESOCKTNOSUPPORT -1 #define POCO_ESOCKTNOSUPPORT -1
#endif #endif
#define POCO_ENOTSUP ENOTSUP #define POCO_ENOTSUP ENOTSUP
#define POCO_EPFNOSUPPORT EPFNOSUPPORT #define POCO_EPFNOSUPPORT EPFNOSUPPORT
#define POCO_EAFNOSUPPORT EAFNOSUPPORT #define POCO_EAFNOSUPPORT EAFNOSUPPORT
#define POCO_EADDRINUSE EADDRINUSE #define POCO_EADDRINUSE EADDRINUSE
#define POCO_EADDRNOTAVAIL EADDRNOTAVAIL #define POCO_EADDRNOTAVAIL EADDRNOTAVAIL
#define POCO_ENETDOWN ENETDOWN #define POCO_ENETDOWN ENETDOWN
#define POCO_ENETUNREACH ENETUNREACH #define POCO_ENETUNREACH ENETUNREACH
#define POCO_ENETRESET ENETRESET #define POCO_ENETRESET ENETRESET
#define POCO_ECONNABORTED ECONNABORTED #define POCO_ECONNABORTED ECONNABORTED
#define POCO_ECONNRESET ECONNRESET #define POCO_ECONNRESET ECONNRESET
#define POCO_ENOBUFS ENOBUFS #define POCO_ENOBUFS ENOBUFS
#define POCO_EISCONN EISCONN #define POCO_EISCONN EISCONN
#define POCO_ENOTCONN ENOTCONN #define POCO_ENOTCONN ENOTCONN
#if defined(ESHUTDOWN) #if defined(ESHUTDOWN)
#define POCO_ESHUTDOWN ESHUTDOWN #define POCO_ESHUTDOWN ESHUTDOWN
#else #else
#define POCO_ESHUTDOWN -2 #define POCO_ESHUTDOWN -2
#endif #endif
#define POCO_ETIMEDOUT ETIMEDOUT #define POCO_ETIMEDOUT ETIMEDOUT
#define POCO_ECONNREFUSED ECONNREFUSED #define POCO_ECONNREFUSED ECONNREFUSED
#if defined(EHOSTDOWN) #if defined(EHOSTDOWN)
#define POCO_EHOSTDOWN EHOSTDOWN #define POCO_EHOSTDOWN EHOSTDOWN
#else #else
#define POCO_EHOSTDOWN -3 #define POCO_EHOSTDOWN -3
#endif #endif
#define POCO_EHOSTUNREACH EHOSTUNREACH #define POCO_EHOSTUNREACH EHOSTUNREACH
#define POCO_ESYSNOTREADY -4 #define POCO_ESYSNOTREADY -4
#define POCO_ENOTINIT -5 #define POCO_ENOTINIT -5
#define POCO_HOST_NOT_FOUND HOST_NOT_FOUND #define POCO_HOST_NOT_FOUND HOST_NOT_FOUND
#define POCO_TRY_AGAIN TRY_AGAIN #define POCO_TRY_AGAIN TRY_AGAIN
#define POCO_NO_RECOVERY NO_RECOVERY #define POCO_NO_RECOVERY NO_RECOVERY
#define POCO_NO_DATA NO_DATA #define POCO_NO_DATA NO_DATA
#endif #endif
#if defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_TRU64) || (POCO_OS == POCO_OS_AIX) || (POCO_OS == POCO_OS_IRIX) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_VXWORKS) #if defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_TRU64) || (POCO_OS == POCO_OS_AIX) || (POCO_OS == POCO_OS_IRIX) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_VXWORKS)
#define POCO_HAVE_SALEN 1 #define POCO_HAVE_SALEN 1
#endif #endif
#if POCO_OS != POCO_OS_VXWORKS && !defined(POCO_NET_NO_ADDRINFO) #if POCO_OS != POCO_OS_VXWORKS && !defined(POCO_NET_NO_ADDRINFO)
#define POCO_HAVE_ADDRINFO 1 #define POCO_HAVE_ADDRINFO 1
#endif #endif
#if (POCO_OS == POCO_OS_HPUX) || (POCO_OS == POCO_OS_SOLARIS) || (POCO_OS == POCO_OS_WINDOWS_CE) #if (POCO_OS == POCO_OS_HPUX) || (POCO_OS == POCO_OS_SOLARIS) || (POCO_OS == POCO_OS_WINDOWS_CE)
#define POCO_BROKEN_TIMEOUTS 1 #define POCO_BROKEN_TIMEOUTS 1
#endif #endif
#if defined(POCO_HAVE_ADDRINFO) #if defined(POCO_HAVE_ADDRINFO)
#if !defined(AI_ADDRCONFIG) #if !defined(AI_ADDRCONFIG)
#define AI_ADDRCONFIG 0 #define AI_ADDRCONFIG 0
#endif #endif
#endif #endif
#if defined(POCO_HAVE_SALEN) #if defined(POCO_HAVE_SALEN)
#define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len) #define poco_set_sa_len(pSA, len) (pSA)->sa_len = (len)
#define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in) #define poco_set_sin_len(pSA) (pSA)->sin_len = sizeof(struct sockaddr_in)
#if defined(POCO_HAVE_IPv6) #if defined(POCO_HAVE_IPv6)
#define poco_set_sin6_len(pSA) (pSA)->sin6_len = sizeof(struct sockaddr_in6) #define poco_set_sin6_len(pSA) (pSA)->sin6_len = sizeof(struct sockaddr_in6)
#endif #endif
#else #else
#define poco_set_sa_len(pSA, len) (void) 0 #define poco_set_sa_len(pSA, len) (void) 0
#define poco_set_sin_len(pSA) (void) 0 #define poco_set_sin_len(pSA) (void) 0
#define poco_set_sin6_len(pSA) (void) 0 #define poco_set_sin6_len(pSA) (void) 0
#endif #endif
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE 0xFFFFFFFF #define INADDR_NONE 0xffffffff
#endif #endif
#ifndef INADDR_ANY #ifndef INADDR_ANY
#define INADDR_ANY 0x00000000 #define INADDR_ANY 0x00000000
#endif #endif
#ifndef INADDR_BROADCAST #ifndef INADDR_BROADCAST
#define INADDR_BROADCAST 0xffffffff #define INADDR_BROADCAST 0xffffffff
#endif #endif
#ifndef INADDR_LOOPBACK #ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001 #define INADDR_LOOPBACK 0x7f000001
#endif #endif
#ifndef INADDR_UNSPEC_GROUP #ifndef INADDR_UNSPEC_GROUP
#define INADDR_UNSPEC_GROUP 0xe0000000 #define INADDR_UNSPEC_GROUP 0xe0000000
#endif #endif
#ifndef INADDR_ALLHOSTS_GROUP #ifndef INADDR_ALLHOSTS_GROUP
#define INADDR_ALLHOSTS_GROUP 0xe0000001 #define INADDR_ALLHOSTS_GROUP 0xe0000001
#endif #endif
#ifndef INADDR_ALLRTRS_GROUP #ifndef INADDR_ALLRTRS_GROUP
#define INADDR_ALLRTRS_GROUP 0xe0000002 #define INADDR_ALLRTRS_GROUP 0xe0000002
#endif #endif
#ifndef INADDR_MAX_LOCAL_GROUP #ifndef INADDR_MAX_LOCAL_GROUP
#define INADDR_MAX_LOCAL_GROUP 0xe00000ff #define INADDR_MAX_LOCAL_GROUP 0xe00000ff
#endif #endif
#if defined(POCO_ARCH_BIG_ENDIAN) #if defined(POCO_ARCH_BIG_ENDIAN)
#define poco_ntoh_16(x) (x) #define poco_ntoh_16(x) (x)
#define poco_ntoh_32(x) (x) #define poco_ntoh_32(x) (x)
@@ -323,6 +322,7 @@ extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
#define poco_ntoh_32(x) \ #define poco_ntoh_32(x) \
((((x) >> 24) & 0x000000ff) | (((x) >> 8) & 0x0000ff00) | (((x) << 8) & 0x00ff0000) | (((x) << 24) & 0xff000000)) ((((x) >> 24) & 0x000000ff) | (((x) >> 8) & 0x0000ff00) | (((x) << 8) & 0x00ff0000) | (((x) << 24) & 0xff000000))
#endif #endif
#define poco_hton_16(x) poco_ntoh_16(x)
#define poco_hton_32(x) poco_ntoh_32(x)
#endif // Net_SocketDefs_INCLUDED #endif // Net_SocketDefs_INCLUDED

View File

@@ -634,8 +634,10 @@ void IPAddressTest::testByteOrderMacros()
{ {
Poco::UInt16 a16 = 0xDEAD; Poco::UInt16 a16 = 0xDEAD;
assert (poco_ntoh_16(a16) == ntohs(a16)); assert (poco_ntoh_16(a16) == ntohs(a16));
assert (poco_hton_16(a16) == htons(a16));
Poco::UInt32 a32 = 0xDEADBEEF; Poco::UInt32 a32 = 0xDEADBEEF;
assert (poco_ntoh_32(a32) == ntohl(a32)); assert (poco_ntoh_32(a32) == ntohl(a32));
assert (poco_hton_32(a32) == htonl(a32));
} }