MCPcopy Create free account
hub / github.com/catboost/catboost / GetAddressAsString

Function GetAddressAsString

library/cpp/netliba/v6/udp_address.cpp:277–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275 }
276
277 TString GetAddressAsString(const TUdpAddress& addr) {
278 char buf[1000];
279 if (addr.IsIPv4()) {
280 int ip = addr.GetIPv4();
281 snprintf(buf, sizeof(buf), "%d.%d.%d.%d:%d",
282 (ip >> 0) & 0xff, (ip >> 8) & 0xff,
283 (ip >> 16) & 0xff, (ip >> 24) & 0xff,
284 addr.Port);
285 } else {
286 ui16 ipv6[8];
287 *BreakAliasing<ui64>(ipv6) = addr.Network;
288 *BreakAliasing<ui64>(ipv6 + 4) = addr.Interface;
289 char suffix[100] = "";
290 if (addr.Scope != 0) {
291 snprintf(suffix, sizeof(suffix), "%%%d", addr.Scope);
292 }
293 snprintf(buf, sizeof(buf), "[%x:%x:%x:%x:%x:%x:%x:%x%s]:%d",
294 ntohs(ipv6[0]), ntohs(ipv6[1]), ntohs(ipv6[2]), ntohs(ipv6[3]),
295 ntohs(ipv6[4]), ntohs(ipv6[5]), ntohs(ipv6[6]), ntohs(ipv6[7]),
296 suffix, addr.Port);
297 }
298 return buf;
299 }
300}

Callers 7

GetPeerLinkDebugMethod · 0.70
RequestMethod · 0.70
GetDebugInfoLockedMethod · 0.70
AbortOnFailedRequestFunction · 0.70
RemoteHostMethod · 0.50

Calls 3

snprintfFunction · 0.50
IsIPv4Method · 0.45
GetIPv4Method · 0.45

Tested by 1

RequestMethod · 0.56