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.cpp | |
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.cpp')
-rw-r--r-- | library/cpp/messagebus/config/netaddr.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/library/cpp/messagebus/config/netaddr.cpp b/library/cpp/messagebus/config/netaddr.cpp index f82378c345..962ac538e2 100644 --- a/library/cpp/messagebus/config/netaddr.cpp +++ b/library/cpp/messagebus/config/netaddr.cpp @@ -4,7 +4,7 @@ #include <cstdlib> -namespace NBus { +namespace NBus { const char* ToCString(EIpVersion ipVersion) { switch (ipVersion) { case EIP_VERSION_ANY: @@ -37,12 +37,12 @@ namespace NBus { { } }; - + static bool Compare(const IRemoteAddr& l, const IRemoteAddr& r) noexcept { if (l.Addr()->sa_family != r.Addr()->sa_family) { return false; } - + switch (l.Addr()->sa_family) { case AF_INET: { return memcmp(&(((const sockaddr_in*)l.Addr())->sin_addr), &(((const sockaddr_in*)r.Addr())->sin_addr), sizeof(in_addr)) == 0 && @@ -53,25 +53,25 @@ namespace NBus { return memcmp(&(((const sockaddr_in6*)l.Addr())->sin6_addr), &(((const sockaddr_in6*)r.Addr())->sin6_addr), sizeof(in6_addr)) == 0 && ((const sockaddr_in6*)l.Addr())->sin6_port == ((const sockaddr_in6*)r.Addr())->sin6_port; } - } - + } + return memcmp(l.Addr(), r.Addr(), Min<size_t>(l.Len(), r.Len())) == 0; - } - + } + TNetAddr::TNetAddr() : Ptr(new TOpaqueAddr) { } - + TNetAddr::TNetAddr(TAutoPtr<IRemoteAddr> addr) : Ptr(addr) { Y_VERIFY(!!Ptr); } - + namespace { using namespace NAddr; - + const char* Describe(EIpVersion version) { switch (version) { case EIP_VERSION_4: @@ -150,7 +150,7 @@ namespace NBus { socklen_t TNetAddr::Len() const { return Ptr->Len(); } - + int TNetAddr::GetPort() const { switch (Ptr->Addr()->sa_family) { case AF_INET: @@ -162,11 +162,11 @@ namespace NBus { throw 1; } } - + bool TNetAddr::IsIpv4() const { return Ptr->Addr()->sa_family == AF_INET; } - + bool TNetAddr::IsIpv6() const { return Ptr->Addr()->sa_family == AF_INET6; } @@ -177,7 +177,7 @@ namespace NBus { } -template <> +template <> void Out<NBus::TNetAddr>(IOutputStream& out, const NBus::TNetAddr& addr) { - Out<NAddr::IRemoteAddr>(out, addr); -} + Out<NAddr::IRemoteAddr>(out, addr); +} |