41 ASSERT((addr.sa_family == AF_INET) || (addr.sa_family==AF_INET6));
43 if (addr.sa_family == AF_INET6)
47 else if (addr.sa_family == AF_INET)
59 ASSERT(addr6.sin6_family==AF_INET6);
65 ASSERT(addr4.sin_family == AF_INET);
71 sockaddr_in addr = {};
72 addr.sin_family = AF_INET;
73 addr.sin_port = htons(port);
74 addr.sin_addr.s_addr = htonl(ipHostByteOrder);
129 size_t bytescopied = 0;
144 memcpy(pAddr, &ip,
sizeof(ip));
145 bytescopied =
sizeof(ip);
202 pPort[0] = pPort[0] ^ transid.
id[0];
203 pPort[1] = pPort[1] ^ transid.
id[1];
205 for (
size_t i = 0; i < iplen; i++)
207 pIP[i] = pIP[i] ^ transid.
id[i];
263 const static uint8_t ZERO_ARRAY[16] = {};
286 char sz[INET6_ADDRSTRLEN + 6];
294 const void *pAddrBytes = NULL;
295 const char* pszResult = NULL;
296 const size_t portLength = 6;
297 char szPort[portLength+1];
298 char delimiter = (family == AF_INET) ?
':' :
'.';
305 if (family == AF_INET)
310 else if (family == AF_INET6)
320 pszResult = ::inet_ntop(family, pAddrBytes, pszAddrBytes, length);
324 sprintf(szPort,
"%c%d", delimiter,
GetPort());
329 strcat(pszAddrBytes, szPort);
340 if ( ((family != AF_INET) && (family != AF_INET6)) ||
347 if (family == AF_INET)
349 uint32_t ip = 0x7f000001;
354 sockaddr_in6 addr6 = {};
358 uint8_t ip6[16] = {};
361 addr6.sin6_family = AF_INET6;
362 memcpy(&addr6.sin6_addr, ip6, 16);
size_t GetIPImpl(void *pAddr, size_t length, bool fNetworkByteOrder) const
socklen_t GetSockAddrLength() const
uint16_t GetIPLength() const
const uint16_t STUN_IPV6_LENGTH
bool IsSameIP_and_Port(const CSocketAddress &other) const
void ApplyStunXorMap(const StunTransactionId &id)
static HRESULT GetLocalHost(uint16_t family, CSocketAddress *pAddr)
#define ChkIf(expr, hrerror)
size_t GetIP_NBO(void *pAddr, size_t length) const
const uint16_t STUN_IPV4_LENGTH
bool IsSameIP(const CSocketAddress &other) const
#define COMPILE_TIME_ASSERT(x)
const sockaddr * GetSockAddr() const
size_t GetIP(void *pAddr, size_t length) const
void ToString(std::string *pStr) const
HRESULT ToStringBuffer(char *pszAddrBytes, size_t length) const
uint8_t id[STUN_TRANSACTION_ID_LENGTH]
uint16_t GetPort_NBO() const
uint16_t GetFamily() const
bool IsIPAddressZero() const
#define ChkIfA(expr, hrerror)
void CommonConstructor(const sockaddr &addr)