aboutsummaryrefslogtreecommitdiffstats
path: root/util/network/address.cpp
diff options
context:
space:
mode:
authorkulikov <kulikov@yandex-team.ru>2022-02-10 16:49:34 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:34 +0300
commitc707901605d7b7c6cba0998cd52e1ae619c97762 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/network/address.cpp
parent65e5266709e7ff94b14ae128309e229de714b0df (diff)
downloadydb-c707901605d7b7c6cba0998cd52e1ae619c97762.tar.gz
Restoring authorship annotation for <kulikov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/network/address.cpp')
-rw-r--r--util/network/address.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/util/network/address.cpp b/util/network/address.cpp
index 267c2f9092..a81a9e6994 100644
--- a/util/network/address.cpp
+++ b/util/network/address.cpp
@@ -139,7 +139,7 @@ IRemoteAddrPtr NAddr::GetSockAddr(SOCKET s) {
return addr;
}
-
+
IRemoteAddrPtr NAddr::GetPeerAddr(SOCKET s) {
auto addr = MakeHolder<TOpaqueAddr>();
@@ -150,41 +150,41 @@ IRemoteAddrPtr NAddr::GetPeerAddr(SOCKET s) {
return addr;
}
-static const in_addr& InAddr(const IRemoteAddr& addr) {
- return ((const sockaddr_in*)addr.Addr())->sin_addr;
-}
-
-static const in6_addr& In6Addr(const IRemoteAddr& addr) {
- return ((const sockaddr_in6*)addr.Addr())->sin6_addr;
-}
-
-bool NAddr::IsLoopback(const IRemoteAddr& addr) {
- if (addr.Addr()->sa_family == AF_INET) {
+static const in_addr& InAddr(const IRemoteAddr& addr) {
+ return ((const sockaddr_in*)addr.Addr())->sin_addr;
+}
+
+static const in6_addr& In6Addr(const IRemoteAddr& addr) {
+ return ((const sockaddr_in6*)addr.Addr())->sin6_addr;
+}
+
+bool NAddr::IsLoopback(const IRemoteAddr& addr) {
+ if (addr.Addr()->sa_family == AF_INET) {
return ((ntohl(InAddr(addr).s_addr) >> 24) & 0xff) == 127;
}
if (addr.Addr()->sa_family == AF_INET6) {
- return 0 == memcmp(&In6Addr(addr), &in6addr_loopback, sizeof(in6_addr));
- }
+ return 0 == memcmp(&In6Addr(addr), &in6addr_loopback, sizeof(in6_addr));
+ }
return false;
-}
-
-bool NAddr::IsSame(const IRemoteAddr& lhs, const IRemoteAddr& rhs) {
- if (lhs.Addr()->sa_family != rhs.Addr()->sa_family) {
- return false;
+}
+
+bool NAddr::IsSame(const IRemoteAddr& lhs, const IRemoteAddr& rhs) {
+ if (lhs.Addr()->sa_family != rhs.Addr()->sa_family) {
+ return false;
}
if (lhs.Addr()->sa_family == AF_INET) {
- return InAddr(lhs).s_addr == InAddr(rhs).s_addr;
+ return InAddr(lhs).s_addr == InAddr(rhs).s_addr;
}
if (lhs.Addr()->sa_family == AF_INET6) {
- return 0 == memcmp(&In6Addr(lhs), &In6Addr(rhs), sizeof(in6_addr));
- }
-
- ythrow yexception() << "unsupported addr family: " << lhs.Addr()->sa_family;
-}
+ return 0 == memcmp(&In6Addr(lhs), &In6Addr(rhs), sizeof(in6_addr));
+ }
+
+ ythrow yexception() << "unsupported addr family: " << lhs.Addr()->sa_family;
+}
socklen_t NAddr::SockAddrLength(const sockaddr* addr) {
switch (addr->sa_family) {