Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: webrtc/base/socketaddress.cc

Issue 1535993002: remove deprecated StringToIP() methods from SocketAddress API (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/socketaddress.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bool SocketAddress::StringToIP(const std::string& hostname, uint32_t* ip) {
311 in_addr addr;
312 if (rtc::inet_pton(AF_INET, hostname.c_str(), &addr) == 0)
313 return false;
314 *ip = NetworkToHost32(addr.s_addr);
315 return true;
316 }
317
318 bool SocketAddress::StringToIP(const std::string& hostname, IPAddress* ip) {
319 in_addr addr4;
320 if (rtc::inet_pton(AF_INET, hostname.c_str(), &addr4) > 0) {
321 if (ip) {
322 *ip = IPAddress(addr4);
323 }
324 return true;
325 }
326
327 in6_addr addr6;
328 if (rtc::inet_pton(AF_INET6, hostname.c_str(), &addr6) > 0) {
329 if (ip) {
330 *ip = IPAddress(addr6);
331 }
332 return true;
333 }
334 return false;
335 }
336
337 uint32_t SocketAddress::StringToIP(const std::string& hostname) {
338 uint32_t ip = 0;
339 StringToIP(hostname, &ip);
340 return ip;
341 }
342
343 bool SocketAddressFromSockAddrStorage(const sockaddr_storage& addr, 310 bool SocketAddressFromSockAddrStorage(const sockaddr_storage& addr,
344 SocketAddress* out) { 311 SocketAddress* out) {
345 if (!out) { 312 if (!out) {
346 return false; 313 return false;
347 } 314 }
348 if (addr.ss_family == AF_INET) { 315 if (addr.ss_family == AF_INET) {
349 const sockaddr_in* saddr = reinterpret_cast<const sockaddr_in*>(&addr); 316 const sockaddr_in* saddr = reinterpret_cast<const sockaddr_in*>(&addr);
350 *out = SocketAddress(IPAddress(saddr->sin_addr), 317 *out = SocketAddress(IPAddress(saddr->sin_addr),
351 NetworkToHost16(saddr->sin_port)); 318 NetworkToHost16(saddr->sin_port));
352 return true; 319 return true;
(...skipping 10 matching lines...) Expand all
363 SocketAddress EmptySocketAddressWithFamily(int family) { 330 SocketAddress EmptySocketAddressWithFamily(int family) {
364 if (family == AF_INET) { 331 if (family == AF_INET) {
365 return SocketAddress(IPAddress(INADDR_ANY), 0); 332 return SocketAddress(IPAddress(INADDR_ANY), 0);
366 } else if (family == AF_INET6) { 333 } else if (family == AF_INET6) {
367 return SocketAddress(IPAddress(in6addr_any), 0); 334 return SocketAddress(IPAddress(in6addr_any), 0);
368 } 335 }
369 return SocketAddress(); 336 return SocketAddress();
370 } 337 }
371 338
372 } // namespace rtc 339 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/socketaddress.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698