version 1.53, 2007/07/10 19:59:55
|
version 1.58.2.1, 2007/09/11 16:32:43
|
|
|
| |
#if defined(PEGASUS_OS_TYPE_WINDOWS) | #if defined(PEGASUS_OS_TYPE_WINDOWS) |
# include "SystemWindows.cpp" | # include "SystemWindows.cpp" |
#elif defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS) |
#elif defined(PEGASUS_OS_TYPE_UNIX) || \ |
|
defined(PEGASUS_OS_VMS) || \ |
|
defined(PEGASUS_OS_VXWORKS) |
# include "SystemPOSIX.cpp" | # include "SystemPOSIX.cpp" |
#else | #else |
# error "Unsupported platform" | # error "Unsupported platform" |
|
|
{ | { |
char ipAddress[PEGASUS_INET_ADDRSTR_LEN]; | char ipAddress[PEGASUS_INET_ADDRSTR_LEN]; |
HostAddress::convertBinaryToText(info->ai_family, | HostAddress::convertBinaryToText(info->ai_family, |
&((struct sockaddr_in*)(info->ai_addr))->sin_addr, ipAddress, |
&(reinterpret_cast<struct sockaddr_in*>(info->ai_addr))->sin_addr, |
|
ipAddress, |
PEGASUS_INET_ADDRSTR_LEN); | PEGASUS_INET_ADDRSTR_LEN); |
hostIP = ipAddress; | hostIP = ipAddress; |
freeaddrinfo(info); | freeaddrinfo(info); |
|
|
{ | { |
char ipAddress[PEGASUS_INET6_ADDRSTR_LEN]; | char ipAddress[PEGASUS_INET6_ADDRSTR_LEN]; |
HostAddress::convertBinaryToText(info->ai_family, | HostAddress::convertBinaryToText(info->ai_family, |
&((struct sockaddr_in6*)(info->ai_addr))->sin6_addr, ipAddress, |
&(reinterpret_cast<struct sockaddr_in6*>(info->ai_addr))->sin6_addr, |
|
ipAddress, |
PEGASUS_INET6_ADDRSTR_LEN); | PEGASUS_INET6_ADDRSTR_LEN); |
hostIP = ipAddress; | hostIP = ipAddress; |
freeaddrinfo(info); | freeaddrinfo(info); |
|
|
#endif | #endif |
} | } |
| |
|
|
|
#ifdef PEGASUS_ENABLE_IPV6 |
|
Boolean System::isIPv6StackActive() |
|
{ |
|
SocketHandle ip6Socket; |
|
if ((ip6Socket = Socket::createSocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) |
|
== PEGASUS_INVALID_SOCKET) |
|
{ |
|
if (getSocketError() == PEGASUS_INVALID_ADDRESS_FAMILY) |
|
{ |
|
return false; |
|
} |
|
} |
|
else |
|
{ |
|
Socket::close(ip6Socket); |
|
} |
|
|
|
return true; |
|
} |
|
#endif |
|
|
// ------------------------------------------------------------------------ | // ------------------------------------------------------------------------ |
// Convert a hostname into a a single host unique integer representation | // Convert a hostname into a a single host unique integer representation |
// ------------------------------------------------------------------------ | // ------------------------------------------------------------------------ |
|
|
while (res1 && !isLocal) | while (res1 && !isLocal) |
{ | { |
if (isLoopBack(AF_INET, | if (isLoopBack(AF_INET, |
&((struct sockaddr_in*)res1->ai_addr)->sin_addr)) |
&(reinterpret_cast<struct sockaddr_in*>(res1->ai_addr))->sin_addr)) |
{ | { |
isLocal = true; | isLocal = true; |
break; | break; |
|
|
res2 = res2root; | res2 = res2root; |
while (res2) | while (res2) |
{ | { |
if (!memcmp(&((struct sockaddr_in*)res1->ai_addr)->sin_addr, |
if (!memcmp( |
&((struct sockaddr_in*)res2->ai_addr)->sin_addr, |
&(reinterpret_cast<struct sockaddr_in*>(res1->ai_addr))-> |
|
sin_addr, |
|
&(reinterpret_cast<struct sockaddr_in*>(res2->ai_addr))-> |
|
sin_addr, |
sizeof (struct in_addr))) | sizeof (struct in_addr))) |
{ | { |
isLocal = true; | isLocal = true; |
|
|
res1 = res1root; | res1 = res1root; |
while (res1 && !isLocal) | while (res1 && !isLocal) |
{ | { |
if (isLoopBack(AF_INET6, |
if (isLoopBack( |
&((struct sockaddr_in6*)res1->ai_addr)->sin6_addr)) |
AF_INET6, |
|
&(reinterpret_cast<struct sockaddr_in6*>(res1->ai_addr))-> |
|
sin6_addr)) |
{ | { |
isLocal = true; | isLocal = true; |
break; | break; |
|
|
res2 = res2root; | res2 = res2root; |
while (res2) | while (res2) |
{ | { |
if (!memcmp(&((struct sockaddr_in6*)res1->ai_addr)->sin6_addr, |
if (!memcmp( |
&((struct sockaddr_in6*)res2->ai_addr)->sin6_addr, |
&(reinterpret_cast<struct sockaddr_in6*>(res1->ai_addr))-> |
|
sin6_addr, |
|
&(reinterpret_cast<struct sockaddr_in6*>(res2->ai_addr))-> |
|
sin6_addr, |
sizeof (struct in6_addr))) | sizeof (struct in6_addr))) |
{ | { |
isLocal = true; | isLocal = true; |
|
|
// Note: Platforms already supporting the inet_aton() | // Note: Platforms already supporting the inet_aton() |
// should define their platform here, | // should define their platform here, |
// as this is the superior way to work | // as this is the superior way to work |
#if defined(PEGASUS_OS_LINUX) || defined(PEGASUS_OS_AIX) |
#if defined(PEGASUS_OS_LINUX) || \ |
|
defined(PEGASUS_OS_AIX) || \ |
|
defined(PEGASUS_OS_HPUX) || \ |
|
defined(PEGASUS_OS_PASE) |
| |
struct in_addr inaddr; | struct in_addr inaddr; |
// if inet_aton failed(return=0), | // if inet_aton failed(return=0), |