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

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

Issue 1471203002: GetDefaultLocalAddress should return false when the address is invalid (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@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 | « no previous file | webrtc/base/network_unittest.cc » ('j') | 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (ipv4.family() == AF_INET) { 338 if (ipv4.family() == AF_INET) {
339 default_local_ipv4_address_ = ipv4; 339 default_local_ipv4_address_ = ipv4;
340 } 340 }
341 if (ipv6.family() == AF_INET6) { 341 if (ipv6.family() == AF_INET6) {
342 default_local_ipv6_address_ = ipv6; 342 default_local_ipv6_address_ = ipv6;
343 } 343 }
344 } 344 }
345 345
346 bool NetworkManagerBase::GetDefaultLocalAddress(int family, 346 bool NetworkManagerBase::GetDefaultLocalAddress(int family,
347 IPAddress* ipaddr) const { 347 IPAddress* ipaddr) const {
348 if (family == AF_INET) { 348 if (family == AF_INET && !default_local_ipv4_address_.IsNil()) {
349 *ipaddr = default_local_ipv4_address_; 349 *ipaddr = default_local_ipv4_address_;
350 return true; 350 return true;
351 } else if (family == AF_INET6) { 351 } else if (family == AF_INET6 && !default_local_ipv6_address_.IsNil()) {
352 *ipaddr = default_local_ipv6_address_; 352 *ipaddr = default_local_ipv6_address_;
353 return true; 353 return true;
354 } 354 }
355 return false; 355 return false;
356 } 356 }
357 357
358 BasicNetworkManager::BasicNetworkManager() 358 BasicNetworkManager::BasicNetworkManager()
359 : thread_(NULL), sent_first_update_(false), start_count_(0), 359 : thread_(NULL), sent_first_update_(false), start_count_(0),
360 network_ignore_mask_(kDefaultNetworkIgnoreMask), 360 network_ignore_mask_(kDefaultNetworkIgnoreMask),
361 ignore_non_default_routes_(false) { 361 ignore_non_default_routes_(false) {
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 std::stringstream ss; 911 std::stringstream ss;
912 // Print out the first space-terminated token of the network desc, plus 912 // Print out the first space-terminated token of the network desc, plus
913 // the IP address. 913 // the IP address.
914 ss << "Net[" << description_.substr(0, description_.find(' ')) 914 ss << "Net[" << description_.substr(0, description_.find(' '))
915 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ 915 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_
916 << ":" << AdapterTypeToString(type_) << "]"; 916 << ":" << AdapterTypeToString(type_) << "]";
917 return ss.str(); 917 return ss.str();
918 } 918 }
919 919
920 } // namespace rtc 920 } // namespace rtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/network_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698