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

Side by Side Diff: net/dns/host_resolver_impl.cc

Issue 1565303002: Change IPEndpoint::address() to return a net::IPAddress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase for ChromeOS Created 4 years, 10 months 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 | « net/dns/dns_config_service_win.cc ('k') | net/dns/mdns_client.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/dns/host_resolver_impl.h" 5 #include "net/dns/host_resolver_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <Winsock2.h> 10 #include <Winsock2.h>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 net_log.net_log(), 208 net_log.net_log(),
209 net_log.source())); 209 net_log.source()));
210 int rv = socket->Connect(IPEndPoint(dest, 53)); 210 int rv = socket->Connect(IPEndPoint(dest, 53));
211 if (rv != OK) 211 if (rv != OK)
212 return false; 212 return false;
213 IPEndPoint endpoint; 213 IPEndPoint endpoint;
214 rv = socket->GetLocalAddress(&endpoint); 214 rv = socket->GetLocalAddress(&endpoint);
215 if (rv != OK) 215 if (rv != OK)
216 return false; 216 return false;
217 DCHECK_EQ(ADDRESS_FAMILY_IPV6, endpoint.GetFamily()); 217 DCHECK_EQ(ADDRESS_FAMILY_IPV6, endpoint.GetFamily());
218 const IPAddressNumber& address = endpoint.address(); 218 const IPAddressNumber& address = endpoint.address().bytes();
219 bool is_link_local = (address[0] == 0xFE) && ((address[1] & 0xC0) == 0x80); 219 bool is_link_local = (address[0] == 0xFE) && ((address[1] & 0xC0) == 0x80);
220 if (is_link_local) 220 if (is_link_local)
221 return false; 221 return false;
222 const uint8_t kTeredoPrefix[] = {0x20, 0x01, 0, 0}; 222 const uint8_t kTeredoPrefix[] = {0x20, 0x01, 0, 0};
223 bool is_teredo = std::equal(kTeredoPrefix, 223 bool is_teredo = std::equal(kTeredoPrefix,
224 kTeredoPrefix + arraysize(kTeredoPrefix), 224 kTeredoPrefix + arraysize(kTeredoPrefix),
225 address.begin()); 225 address.begin());
226 if (is_teredo) 226 if (is_teredo)
227 return false; 227 return false;
228 return true; 228 return true;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 AddressList EnsurePortOnAddressList(const AddressList& list, uint16_t port) { 293 AddressList EnsurePortOnAddressList(const AddressList& list, uint16_t port) {
294 if (list.empty() || list.front().port() == port) 294 if (list.empty() || list.front().port() == port)
295 return list; 295 return list;
296 return AddressList::CopyWithPort(list, port); 296 return AddressList::CopyWithPort(list, port);
297 } 297 }
298 298
299 // Returns true if |addresses| contains only IPv4 loopback addresses. 299 // Returns true if |addresses| contains only IPv4 loopback addresses.
300 bool IsAllIPv4Loopback(const AddressList& addresses) { 300 bool IsAllIPv4Loopback(const AddressList& addresses) {
301 for (unsigned i = 0; i < addresses.size(); ++i) { 301 for (unsigned i = 0; i < addresses.size(); ++i) {
302 const IPAddressNumber& address = addresses[i].address(); 302 const IPAddressNumber& address = addresses[i].address().bytes();
303 switch (addresses[i].GetFamily()) { 303 switch (addresses[i].GetFamily()) {
304 case ADDRESS_FAMILY_IPV4: 304 case ADDRESS_FAMILY_IPV4:
305 if (address[0] != 127) 305 if (address[0] != 127)
306 return false; 306 return false;
307 break; 307 break;
308 case ADDRESS_FAMILY_IPV6: 308 case ADDRESS_FAMILY_IPV6:
309 return false; 309 return false;
310 default: 310 default:
311 NOTREACHED(); 311 NOTREACHED();
312 return false; 312 return false;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 // Running on the worker thread 704 // Running on the worker thread
705 int error = params_.resolver_proc->Resolve(key_.hostname, 705 int error = params_.resolver_proc->Resolve(key_.hostname,
706 key_.address_family, 706 key_.address_family,
707 key_.host_resolver_flags, 707 key_.host_resolver_flags,
708 &results, 708 &results,
709 &os_error); 709 &os_error);
710 710
711 // Fail the resolution if the result contains 127.0.53.53. See the comment 711 // Fail the resolution if the result contains 127.0.53.53. See the comment
712 // block of kIcanNameCollisionIp for details on why. 712 // block of kIcanNameCollisionIp for details on why.
713 for (const auto& it : results) { 713 for (const auto& it : results) {
714 const IPAddressNumber& cur = it.address(); 714 const IPAddressNumber& cur = it.address().bytes();
715 if (cur.size() == arraysize(kIcanNameCollisionIp) && 715 if (cur.size() == arraysize(kIcanNameCollisionIp) &&
716 0 == memcmp(&cur.front(), kIcanNameCollisionIp, cur.size())) { 716 0 == memcmp(&cur.front(), kIcanNameCollisionIp, cur.size())) {
717 error = ERR_ICANN_NAME_COLLISION; 717 error = ERR_ICANN_NAME_COLLISION;
718 break; 718 break;
719 } 719 }
720 } 720 }
721 721
722 task_runner_->PostTask(FROM_HERE, 722 task_runner_->PostTask(FROM_HERE,
723 base::Bind(&ProcTask::OnLookupComplete, 723 base::Bind(&ProcTask::OnLookupComplete,
724 this, 724 this,
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 dns_client_->SetConfig(dns_config); 2428 dns_client_->SetConfig(dns_config);
2429 num_dns_failures_ = 0; 2429 num_dns_failures_ = 0;
2430 if (dns_client_->GetConfig()) 2430 if (dns_client_->GetConfig())
2431 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); 2431 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true);
2432 } 2432 }
2433 2433
2434 AbortDnsTasks(); 2434 AbortDnsTasks();
2435 } 2435 }
2436 2436
2437 } // namespace net 2437 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/dns/mdns_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698