summaryrefslogtreecommitdiffstats
path: root/source/OSSupport
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-05 21:46:40 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-05 21:46:40 +0100
commit469d08ec42e3454e8fe711c4c12a5fca499c9d29 (patch)
tree615fb8b0b106eef882b5505faac7bc3253fc4f03 /source/OSSupport
parentIPv6 support: fixed IP string getting on accept() (diff)
downloadcuberite-469d08ec42e3454e8fe711c4c12a5fca499c9d29.tar
cuberite-469d08ec42e3454e8fe711c4c12a5fca499c9d29.tar.gz
cuberite-469d08ec42e3454e8fe711c4c12a5fca499c9d29.tar.bz2
cuberite-469d08ec42e3454e8fe711c4c12a5fca499c9d29.tar.lz
cuberite-469d08ec42e3454e8fe711c4c12a5fca499c9d29.tar.xz
cuberite-469d08ec42e3454e8fe711c4c12a5fca499c9d29.tar.zst
cuberite-469d08ec42e3454e8fe711c4c12a5fca499c9d29.zip
Diffstat (limited to '')
-rw-r--r--source/OSSupport/Socket.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/source/OSSupport/Socket.cpp b/source/OSSupport/Socket.cpp
index efc20284f..b4ac62993 100644
--- a/source/OSSupport/Socket.cpp
+++ b/source/OSSupport/Socket.cpp
@@ -293,9 +293,23 @@ cSocket cSocket::AcceptIPv6(void)
// Get IP in string form:
if (SClient.IsValid())
{
- char buffer[INET6_ADDRSTRLEN];
- inet_ntop(AF_INET6, &(from.sin6_addr), buffer, sizeof(buffer));
- SClient.m_IPString.assign(buffer);
+ #if defined(_WIN32)
+ // Windows XP doesn't have inet_ntop, so we need to improvise:
+ Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x",
+ from.sin6_addr.u.Word[0],
+ from.sin6_addr.u.Word[1],
+ from.sin6_addr.u.Word[2],
+ from.sin6_addr.u.Word[3],
+ from.sin6_addr.u.Word[4],
+ from.sin6_addr.u.Word[5],
+ from.sin6_addr.u.Word[6],
+ from.sin6_addr.u.Word[7]
+ );
+ #else
+ char buffer[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &(from.sin6_addr), buffer, sizeof(buffer));
+ SClient.m_IPString.assign(buffer);
+ #endif // _WIN32
}
return SClient;
}