Skip to content

Commit

Permalink
net/IPv4Address: add method GetPortBE()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Nov 26, 2021
1 parent 9d5d19f commit cb4dc4b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/net/IPv4Address.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down

0 comments on commit cb4dc4b

Please sign in to comment.