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

Function GetAddressAsString

library/cpp/netliba/v12/udp_address.cpp:241–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239 }
240
241 TString GetAddressAsString(const TUdpAddress& addr) {
242 char buf[1000];
243 if (addr.IsIPv4()) {
244 int ip = addr.GetIPv4();
245 snprintf(buf, sizeof(buf), "%d.%d.%d.%d:%d",
246 (ip >> 0) & 0xff, (ip >> 8) & 0xff,
247 (ip >> 16) & 0xff, (ip >> 24) & 0xff,
248 addr.Port);
249 } else {
250 ui16 ipv6[8];
251 *BreakAliasing<ui64>(ipv6) = addr.Network;
252 *BreakAliasing<ui64>(ipv6 + 4) = addr.Interface;
253 char suffix[100] = "";
254 if (addr.Scope != 0) {
255 snprintf(suffix, sizeof(suffix), "%%%d", addr.Scope);
256 }
257 snprintf(buf, sizeof(buf), "[%x:%x:%x:%x:%x:%x:%x:%x%s]:%d",
258 ntohs(ipv6[0]), ntohs(ipv6[1]), ntohs(ipv6[2]), ntohs(ipv6[3]),
259 ntohs(ipv6[4]), ntohs(ipv6[5]), ntohs(ipv6[6]), ntohs(ipv6[7]),
260 suffix, addr.Port);
261 }
262 return buf;
263 }
264}

Callers 6

RequestMethod · 0.70
CheckPacketIntegrityMethod · 0.70
GetDebugInfoLockedMethod · 0.70
AbortOnFailedRequestFunction · 0.70
GetDebugInfoMethod · 0.70

Calls 3

snprintfFunction · 0.50
IsIPv4Method · 0.45
GetIPv4Method · 0.45

Tested by 1

RequestMethod · 0.56