aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/config/netaddr.h
diff options
context:
space:
mode:
authorstanly <stanly@yandex-team.ru>2022-02-10 16:46:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:49 +0300
commitcde218e65dfef5ce03a48d641fd8f7913cf17b2d (patch)
treed3349caea4095825a55b5ba24fe758067b29ce6f /library/cpp/messagebus/config/netaddr.h
parent9f813499b4ef585cb3c2bb93de93ef003daf4fc4 (diff)
downloadydb-cde218e65dfef5ce03a48d641fd8f7913cf17b2d.tar.gz
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/config/netaddr.h')
-rw-r--r--library/cpp/messagebus/config/netaddr.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/library/cpp/messagebus/config/netaddr.h b/library/cpp/messagebus/config/netaddr.h
index b79c0cc355..2e40f1464b 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));