From dbb2b2927176b0014b36c183fe556fb149deb8c5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 19 Aug 2024 22:45:40 +0200 Subject: [PATCH] net/IPv6Address: add method GetPortBE() --- src/net/IPv6Address.hxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/net/IPv6Address.hxx b/src/net/IPv6Address.hxx index cd04c7a46..2c0006958 100644 --- a/src/net/IPv6Address.hxx +++ b/src/net/IPv6Address.hxx @@ -132,8 +132,18 @@ public: return address.sin6_family == AF_INET6; } + /** + * @return the port number in network byte order + */ + constexpr uint16_t GetPortBE() const noexcept { + return address.sin6_port; + } + + /** + * @return the port number in host byte order + */ constexpr uint16_t GetPort() const noexcept { - return FromBE16(address.sin6_port); + return FromBE16(GetPortBE()); } void SetPort(uint16_t port) noexcept {