diff --git a/src/net/AddressInfo.hxx b/src/net/AddressInfo.hxx index 73857eac5..7796571a0 100644 --- a/src/net/AddressInfo.hxx +++ b/src/net/AddressInfo.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef NET_ADDRESS_INFO_HXX -#define NET_ADDRESS_INFO_HXX +#pragma once #include "SocketAddress.hxx" @@ -45,6 +44,14 @@ public: return ai_protocol; } + constexpr bool IsInet() const noexcept { + return ai_family == AF_INET || ai_family == AF_INET6; + } + + constexpr bool IsTCP() const noexcept { + return IsInet() && GetType() == SOCK_STREAM; + } + constexpr operator SocketAddress() const noexcept { return {ai_addr, (SocketAddress::size_type)ai_addrlen}; } @@ -130,5 +137,3 @@ public: return const_iterator(nullptr); } }; - -#endif