Lines Matching defs:net_addr

104 size_t GetAddressSize(const NetAddress* net_addr) {
105 return net_addr->is_ipv6 ? kIPv6AddressSize : kIPv4AddressSize;
120 // Zeroes the memory, so net_addr->is_valid == false.
123 NetAddress* net_addr = ToNetAddress(addr);
124 DCHECK(net_addr);
125 memset(net_addr, 0, sizeof(NetAddress));
126 return net_addr;
129 bool IsValid(const NetAddress* net_addr) {
130 return net_addr && net_addr->is_valid;
134 const NetAddress* net_addr = ToNetAddress(addr);
135 if (!IsValid(net_addr))
137 return net_addr->is_ipv6 ?
142 const NetAddress* net_addr = ToNetAddress(addr);
143 if (!IsValid(net_addr))
145 return net_addr->port;
151 const NetAddress* net_addr = ToNetAddress(addr);
152 if (!IsValid(net_addr))
154 size_t net_addr_size = GetAddressSize(net_addr);
158 memcpy(address, net_addr->address, net_addr_size);
163 const NetAddress* net_addr = ToNetAddress(addr);
164 if (!IsValid(net_addr))
166 return net_addr->scope_id;
203 std::string ConvertIPv4AddressToString(const NetAddress* net_addr,
207 net_addr->address[0], net_addr->address[1],
208 net_addr->address[2], net_addr->address[3]);
210 base::StringAppendF(&description, ":%u", net_addr->port);
225 std::string ConvertIPv6AddressToString(const NetAddress* net_addr,
230 reinterpret_cast<const uint16_t*>(net_addr->address);
239 net_addr->address[12],
240 net_addr->address[13],
241 net_addr->address[14],
242 net_addr->address[15]);
281 if (net_addr->scope_id != 0)
282 base::StringAppendF(&description, "%%%u", net_addr->scope_id);
285 base::StringAppendF(&description, "]:%u", net_addr->port);
318 NetAddress* net_addr = InitNetAddress(addr);
319 net_addr->is_valid = true;
320 net_addr->is_ipv6 = (is_ipv6 == PP_TRUE);
328 NetAddress* net_addr = InitNetAddress(addr);
329 net_addr->is_valid = true;
330 net_addr->is_ipv6 = false;
331 net_addr->port = port;
332 memcpy(net_addr->address, ip, kIPv4AddressSize);
341 NetAddress* net_addr = InitNetAddress(addr);
342 net_addr->is_valid = true;
343 net_addr->is_ipv6 = true;
344 net_addr->port = port;
345 net_addr->scope_id = scope_id;
346 memcpy(net_addr->address, ip, kIPv6AddressSize);
423 NetAddress* net_addr = InitNetAddress(addr);
428 net_addr->is_valid = true;
429 net_addr->is_ipv6 = false;
430 net_addr->port = ConvertFromNetEndian16(addr4->sin_port);
431 memcpy(net_addr->address, &addr4->sin_addr.s_addr, kIPv4AddressSize);
437 net_addr->is_valid = true;
438 net_addr->is_ipv6 = true;
439 net_addr->port = ConvertFromNetEndian16(addr6->sin6_port);
440 net_addr->flow_info = addr6->sin6_flowinfo;
441 net_addr->scope_id = addr6->sin6_scope_id;
442 memcpy(net_addr->address, addr6->sin6_addr.s6_addr, kIPv6AddressSize);
446 // InitNetAddress sets net_addr->is_valid to false.
459 NetAddress* net_addr = InitNetAddress(addr);
462 net_addr->is_valid = true;
463 net_addr->is_ipv6 = false;
464 net_addr->port = static_cast<uint16_t>(port);
465 std::copy(address.begin(), address.end(), net_addr->address);
469 net_addr->is_valid = true;
470 net_addr->is_ipv6 = true;
471 net_addr->port = static_cast<uint16_t>(port);
472 std::copy(address.begin(), address.end(), net_addr->address);
476 // InitNetAddress sets net_addr->is_valid to false.
491 const NetAddress* net_addr = ToNetAddress(&addr);
492 if (!IsValid(net_addr))
495 *port = net_addr->port;
496 size_t address_size = GetAddressSize(net_addr);
497 address->assign(&net_addr->address[0], &net_addr->address[address_size]);
507 const NetAddress* net_addr = ToNetAddress(&addr);
508 if (!IsValid(net_addr))
515 if (net_addr->is_ipv6)
516 return ConvertIPv6AddressToString(net_addr, include_port);
517 return ConvertIPv4AddressToString(net_addr, include_port);
539 const NetAddress* net_addr = ToNetAddress(&addr);
540 if (!IsValid(net_addr))
542 return net_addr->is_ipv6 ? PP_NETADDRESS_FAMILY_IPV6 :
553 const NetAddress* net_addr = ToNetAddress(&addr);
554 if (!IsValid(net_addr) || net_addr->is_ipv6)
557 ipv4_addr->port = ConvertToNetEndian16(net_addr->port);
561 memcpy(ipv4_addr->addr, net_addr->address, kIPv4AddressSize);
573 const NetAddress* net_addr = ToNetAddress(&addr);
574 if (!IsValid(net_addr) || !net_addr->is_ipv6)
577 ipv6_addr->port = ConvertToNetEndian16(net_addr->port);
581 memcpy(ipv6_addr->addr, net_addr->address, kIPv6AddressSize);