aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/interconnect/interconnect_address.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/actors/interconnect/interconnect_address.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/actors/interconnect/interconnect_address.cpp')
-rw-r--r--library/cpp/actors/interconnect/interconnect_address.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/library/cpp/actors/interconnect/interconnect_address.cpp b/library/cpp/actors/interconnect/interconnect_address.cpp
index 8dff6ecb42..8f474f5a39 100644
--- a/library/cpp/actors/interconnect/interconnect_address.cpp
+++ b/library/cpp/actors/interconnect/interconnect_address.cpp
@@ -9,9 +9,9 @@
#endif
namespace NInterconnect {
- TAddress::TAddress() {
+ TAddress::TAddress() {
memset(&Addr, 0, sizeof(Addr));
- }
+ }
TAddress::TAddress(NAddr::IRemoteAddr& addr) {
socklen_t len = addr.Len();
@@ -19,42 +19,42 @@ namespace NInterconnect {
memcpy(&Addr.Generic, addr.Addr(), len);
}
- int TAddress::GetFamily() const {
+ int TAddress::GetFamily() const {
return Addr.Generic.sa_family;
- }
+ }
- socklen_t TAddress::Size() const {
+ socklen_t TAddress::Size() const {
switch (Addr.Generic.sa_family) {
- case AF_INET6:
+ case AF_INET6:
return sizeof(sockaddr_in6);
- case AF_INET:
+ case AF_INET:
return sizeof(sockaddr_in);
- default:
- return 0;
- }
- }
+ default:
+ return 0;
+ }
+ }
- sockaddr* TAddress::SockAddr() {
+ sockaddr* TAddress::SockAddr() {
return &Addr.Generic;
}
- const sockaddr* TAddress::SockAddr() const {
+ const sockaddr* TAddress::SockAddr() const {
return &Addr.Generic;
- }
+ }
- ui16 TAddress::GetPort() const {
+ ui16 TAddress::GetPort() const {
switch (Addr.Generic.sa_family) {
- case AF_INET6:
+ case AF_INET6:
return ntohs(Addr.Ipv6.sin6_port);
- case AF_INET:
+ case AF_INET:
return ntohs(Addr.Ipv4.sin_port);
- default:
- return 0;
- }
- }
+ default:
+ return 0;
+ }
+ }
- TString TAddress::ToString() const {
- return GetAddress() + ":" + ::ToString(GetPort());
+ TString TAddress::ToString() const {
+ return GetAddress() + ":" + ::ToString(GetPort());
}
TAddress::TAddress(const char* addr, ui16 port) {
@@ -63,8 +63,8 @@ namespace NInterconnect {
Addr.Ipv6.sin6_port = htons(port);
} else if (inet_pton(Addr.Ipv4.sin_family = AF_INET, addr, &Addr.Ipv4.sin_addr)) {
Addr.Ipv4.sin_port = htons(port);
- }
- }
+ }
+ }
TAddress::TAddress(const TString& addr, ui16 port)
: TAddress(addr.data(), port)
@@ -75,17 +75,17 @@ namespace NInterconnect {
socklen_t size;
switch (Addr.Generic.sa_family) {
- case AF_INET6:
+ case AF_INET6:
std::tie(src, size) = std::make_tuple(&Addr.Ipv6.sin6_addr, INET6_ADDRSTRLEN);
break;
- case AF_INET:
+ case AF_INET:
std::tie(src, size) = std::make_tuple(&Addr.Ipv4.sin_addr, INET_ADDRSTRLEN);
break;
- default:
- return TString();
- }
+ default:
+ return TString();
+ }
char *buffer = static_cast<char*>(alloca(size));
const char *p = inet_ntop(Addr.Generic.sa_family, const_cast<void*>(src), buffer, size);