From c30466b84ad8fa91640fc09e08b2d25cdb54f895 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 24 Nov 2021 17:47:39 +0100 Subject: [PATCH] net/IPv4Address: add method GetPortBE() --- src/net/IPv4Address.hxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/net/IPv4Address.hxx b/src/net/IPv4Address.hxx index 58fa89897..07fb892ee 100644 --- a/src/net/IPv4Address.hxx +++ b/src/net/IPv4Address.hxx @@ -187,11 +187,18 @@ public: return address.sin_family != AF_UNSPEC; } + /** + * @return the port number in network byte order + */ + constexpr uint16_t GetPortBE() const noexcept { + return address.sin_port; + } + /** * @return the port number in host byte order */ constexpr uint16_t GetPort() const noexcept { - return FromBE16(address.sin_port); + return FromBE16(GetPortBE()); } /**