diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-03-10 23:25:53 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-03-10 23:25:53 +0100 |
commit | 4ffaace3849d9b084a8904aa6dbba50fa06bebd3 (patch) | |
tree | c65e1f89880a9640dcbc7888a64c59d988e967ba | |
parent | Potential Linux implementation (diff) | |
download | cuberite-4ffaace3849d9b084a8904aa6dbba50fa06bebd3.tar cuberite-4ffaace3849d9b084a8904aa6dbba50fa06bebd3.tar.gz cuberite-4ffaace3849d9b084a8904aa6dbba50fa06bebd3.tar.bz2 cuberite-4ffaace3849d9b084a8904aa6dbba50fa06bebd3.tar.lz cuberite-4ffaace3849d9b084a8904aa6dbba50fa06bebd3.tar.xz cuberite-4ffaace3849d9b084a8904aa6dbba50fa06bebd3.tar.zst cuberite-4ffaace3849d9b084a8904aa6dbba50fa06bebd3.zip |
Diffstat (limited to '')
-rw-r--r-- | src/OSSupport/NetworkInterfaceEnum.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/OSSupport/NetworkInterfaceEnum.cpp b/src/OSSupport/NetworkInterfaceEnum.cpp index 94edd3bfb..c4af1e93c 100644 --- a/src/OSSupport/NetworkInterfaceEnum.cpp +++ b/src/OSSupport/NetworkInterfaceEnum.cpp @@ -81,13 +81,19 @@ static AString PrintAddress(ifaddrs * InterfaceAddress) case AF_INET: { // IPv4 char AddressBuffer[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, &(reinterpret_cast<struct sockaddr_in *>(reinterpret_cast<void *>(InterfaceAddress->ifa_addr))->sin_addr), AddressBuffer, INET_ADDRSTRLEN); + sockaddr_in InternetSocket; + + std::memcpy(&InternetSocket, InterfaceAddress->ifa_addr, sizeof(InternetSocket)); + inet_ntop(AF_INET, &InternetSocket.sin_addr, AddressBuffer, INET_ADDRSTRLEN); return AddressBuffer; } case AF_INET6: { // IPv6 char AddressBuffer[INET6_ADDRSTRLEN]; - inet_ntop(AF_INET6, &(reinterpret_cast<struct sockaddr_in6 *>(reinterpret_cast<void *>(InterfaceAddress->ifa_addr))->sin6_addr), AddressBuffer, INET6_ADDRSTRLEN); + sockaddr_in6 InternetSocket; + + std::memcpy(&InternetSocket, InterfaceAddress->ifa_addr, sizeof(InternetSocket)); + inet_ntop(AF_INET6, &InternetSocket.sin6_addr, AddressBuffer, INET6_ADDRSTRLEN); return AddressBuffer; } default: |