net/SocketAddress: reimplement GetPort() using IPv4Address::GetPort()
This commit is contained in:
parent
dfc1f6342a
commit
1f3ce380ed
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "SocketAddress.hxx"
|
#include "SocketAddress.hxx"
|
||||||
|
#include "IPv4Address.hxx"
|
||||||
#include "IPv6Address.hxx"
|
#include "IPv6Address.hxx"
|
||||||
#include "util/StringView.hxx"
|
#include "util/StringView.hxx"
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ SocketAddress::GetPort() const noexcept
|
|||||||
|
|
||||||
switch (GetFamily()) {
|
switch (GetFamily()) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
return ntohs(((const struct sockaddr_in *)(const void *)address)->sin_port);
|
return IPv4Address(*this).GetPort();
|
||||||
|
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
return IPv6Address(*this).GetPort();
|
return IPv6Address(*this).GetPort();
|
||||||
|
Loading…
Reference in New Issue
Block a user