diff options
Diffstat (limited to 'src/network/core/address.cpp')
-rw-r--r-- | src/network/core/address.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp index 0498c793f..aa18418f9 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -27,9 +27,13 @@ const char *NetworkAddress::GetHostname() uint16 NetworkAddress::GetPort() const { switch (this->address.ss_family) { + case AF_UNSPEC: case AF_INET: return ntohs(((struct sockaddr_in *)&this->address)->sin_port); + case AF_INET6: + return ntohs(((struct sockaddr_in6 *)&this->address)->sin6_port); + default: NOT_REACHED(); } @@ -38,10 +42,15 @@ uint16 NetworkAddress::GetPort() const void NetworkAddress::SetPort(uint16 port) { switch (this->address.ss_family) { + case AF_UNSPEC: case AF_INET: ((struct sockaddr_in*)&this->address)->sin_port = htons(port); break; + case AF_INET6: + ((struct sockaddr_in6*)&this->address)->sin6_port = htons(port); + break; + default: NOT_REACHED(); } |