diff options
author | stanly <stanly@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
commit | 6170310e8721e225f64ddabf7a7358253d7a1249 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/messagebus/config/netaddr.h | |
parent | cde218e65dfef5ce03a48d641fd8f7913cf17b2d (diff) | |
download | ydb-6170310e8721e225f64ddabf7a7358253d7a1249.tar.gz |
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/config/netaddr.h')
-rw-r--r-- | library/cpp/messagebus/config/netaddr.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/library/cpp/messagebus/config/netaddr.h b/library/cpp/messagebus/config/netaddr.h index 2e40f1464b..b79c0cc355 100644 --- a/library/cpp/messagebus/config/netaddr.h +++ b/library/cpp/messagebus/config/netaddr.h @@ -1,22 +1,22 @@ -#pragma once - +#pragma once + #include <util/digest/numeric.h> #include <util/generic/hash.h> -#include <util/generic/ptr.h> +#include <util/generic/ptr.h> #include <util/generic/strbuf.h> -#include <util/generic/vector.h> -#include <util/network/address.h> - -namespace NBus { +#include <util/generic/vector.h> +#include <util/network/address.h> + +namespace NBus { using namespace NAddr; - + /// IP protocol version. enum EIpVersion { EIP_VERSION_4 = 1, EIP_VERSION_6 = 2, EIP_VERSION_ANY = EIP_VERSION_4 | EIP_VERSION_6, }; - + inline bool IsFamilyAllowed(ui16 sa_family, EIpVersion ipVersion) { if (ipVersion == EIP_VERSION_4 && sa_family != AF_INET) { return false; @@ -51,26 +51,26 @@ namespace NBus { inline explicit operator bool() const noexcept { return !!Ptr; } - + const sockaddr* Addr() const override; socklen_t Len() const override; - + bool IsIpv4() const; bool IsIpv6() const; int GetPort() const; - + private: TAtomicSharedPtr<IRemoteAddr> Ptr; }; using TSockAddrInVector = TVector<TNetAddr>; - + struct TNetAddrHostPortHash { inline size_t operator()(const TNetAddr& a) const { const sockaddr* s = a.Addr(); const sockaddr_in* const sa = reinterpret_cast<const sockaddr_in*>(s); const sockaddr_in6* const sa6 = reinterpret_cast<const sockaddr_in6*>(s); - + switch (s->sa_family) { case AF_INET: return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa->sin_addr), sizeof(sa->sin_addr))), IntHashImpl(sa->sin_port)); |