OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 | 301 |
302 size_t SocketAddress::ToDualStackSockAddrStorage(sockaddr_storage *addr) const { | 302 size_t SocketAddress::ToDualStackSockAddrStorage(sockaddr_storage *addr) const { |
303 return ToSockAddrStorageHelper(addr, ip_.AsIPv6Address(), port_, scope_id_); | 303 return ToSockAddrStorageHelper(addr, ip_.AsIPv6Address(), port_, scope_id_); |
304 } | 304 } |
305 | 305 |
306 size_t SocketAddress::ToSockAddrStorage(sockaddr_storage* addr) const { | 306 size_t SocketAddress::ToSockAddrStorage(sockaddr_storage* addr) const { |
307 return ToSockAddrStorageHelper(addr, ip_, port_, scope_id_); | 307 return ToSockAddrStorageHelper(addr, ip_, port_, scope_id_); |
308 } | 308 } |
309 | 309 |
310 std::string SocketAddress::IPToString(uint32_t ip_as_host_order_integer) { | |
311 return IPAddress(ip_as_host_order_integer).ToString(); | |
312 } | |
313 | |
314 std::string IPToSensitiveString(uint32_t ip_as_host_order_integer) { | |
315 return IPAddress(ip_as_host_order_integer).ToSensitiveString(); | |
316 } | |
317 | |
318 bool SocketAddress::StringToIP(const std::string& hostname, uint32_t* ip) { | 310 bool SocketAddress::StringToIP(const std::string& hostname, uint32_t* ip) { |
319 in_addr addr; | 311 in_addr addr; |
320 if (rtc::inet_pton(AF_INET, hostname.c_str(), &addr) == 0) | 312 if (rtc::inet_pton(AF_INET, hostname.c_str(), &addr) == 0) |
321 return false; | 313 return false; |
322 *ip = NetworkToHost32(addr.s_addr); | 314 *ip = NetworkToHost32(addr.s_addr); |
323 return true; | 315 return true; |
324 } | 316 } |
325 | 317 |
326 bool SocketAddress::StringToIP(const std::string& hostname, IPAddress* ip) { | 318 bool SocketAddress::StringToIP(const std::string& hostname, IPAddress* ip) { |
327 in_addr addr4; | 319 in_addr addr4; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 SocketAddress EmptySocketAddressWithFamily(int family) { | 363 SocketAddress EmptySocketAddressWithFamily(int family) { |
372 if (family == AF_INET) { | 364 if (family == AF_INET) { |
373 return SocketAddress(IPAddress(INADDR_ANY), 0); | 365 return SocketAddress(IPAddress(INADDR_ANY), 0); |
374 } else if (family == AF_INET6) { | 366 } else if (family == AF_INET6) { |
375 return SocketAddress(IPAddress(in6addr_any), 0); | 367 return SocketAddress(IPAddress(in6addr_any), 0); |
376 } | 368 } |
377 return SocketAddress(); | 369 return SocketAddress(); |
378 } | 370 } |
379 | 371 |
380 } // namespace rtc | 372 } // namespace rtc |
OLD | NEW |