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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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/dns_config_service_posix.h" 5 #include "net/dns/dns_config_service_posix.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 for (int i = 0; i < nscount; ++i) { 404 for (int i = 0; i < nscount; ++i) {
405 IPEndPoint ipe; 405 IPEndPoint ipe;
406 if (!ipe.FromSockAddr( 406 if (!ipe.FromSockAddr(
407 reinterpret_cast<const struct sockaddr*>(&addresses[i]), 407 reinterpret_cast<const struct sockaddr*>(&addresses[i]),
408 sizeof addresses[i])) { 408 sizeof addresses[i])) {
409 return CONFIG_PARSE_POSIX_BAD_ADDRESS; 409 return CONFIG_PARSE_POSIX_BAD_ADDRESS;
410 } 410 }
411 dns_config->nameservers.push_back(ipe); 411 dns_config->nameservers.push_back(ipe);
412 } 412 }
413 #elif defined(OS_LINUX) 413 #elif defined(OS_LINUX)
414 COMPILE_ASSERT(arraysize(res.nsaddr_list) >= MAXNS && 414 static_assert(arraysize(res.nsaddr_list) >= MAXNS &&
415 arraysize(res._u._ext.nsaddrs) >= MAXNS, 415 arraysize(res._u._ext.nsaddrs) >= MAXNS,
416 incompatible_libresolv_res_state); 416 "incompatible libresolv res_state");
417 DCHECK_LE(res.nscount, MAXNS); 417 DCHECK_LE(res.nscount, MAXNS);
418 // Initially, glibc stores IPv6 in |_ext.nsaddrs| and IPv4 in |nsaddr_list|. 418 // Initially, glibc stores IPv6 in |_ext.nsaddrs| and IPv4 in |nsaddr_list|.
419 // In res_send.c:res_nsend, it merges |nsaddr_list| into |nsaddrs|, 419 // In res_send.c:res_nsend, it merges |nsaddr_list| into |nsaddrs|,
420 // but we have to combine the two arrays ourselves. 420 // but we have to combine the two arrays ourselves.
421 for (int i = 0; i < res.nscount; ++i) { 421 for (int i = 0; i < res.nscount; ++i) {
422 IPEndPoint ipe; 422 IPEndPoint ipe;
423 const struct sockaddr* addr = NULL; 423 const struct sockaddr* addr = NULL;
424 size_t addr_len = 0; 424 size_t addr_len = 0;
425 if (res.nsaddr_list[i].sin_family) { // The indicator used by res_nsend. 425 if (res.nsaddr_list[i].sin_family) { // The indicator used by res_nsend.
426 addr = reinterpret_cast<const struct sockaddr*>(&res.nsaddr_list[i]); 426 addr = reinterpret_cast<const struct sockaddr*>(&res.nsaddr_list[i]);
(...skipping 25 matching lines...) Expand all
452 for (int i = 0; (i < MAXDNSRCH) && res.dnsrch[i]; ++i) { 452 for (int i = 0; (i < MAXDNSRCH) && res.dnsrch[i]; ++i) {
453 dns_config->search.push_back(std::string(res.dnsrch[i])); 453 dns_config->search.push_back(std::string(res.dnsrch[i]));
454 } 454 }
455 455
456 dns_config->ndots = res.ndots; 456 dns_config->ndots = res.ndots;
457 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans); 457 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans);
458 dns_config->attempts = res.retry; 458 dns_config->attempts = res.retry;
459 #if defined(RES_ROTATE) 459 #if defined(RES_ROTATE)
460 dns_config->rotate = res.options & RES_ROTATE; 460 dns_config->rotate = res.options & RES_ROTATE;
461 #endif 461 #endif
462 #if defined(RES_USE_EDNS0)
462 dns_config->edns0 = res.options & RES_USE_EDNS0; 463 dns_config->edns0 = res.options & RES_USE_EDNS0;
464 #endif
465 #if !defined(RES_USE_DNSSEC)
466 // Some versions of libresolv don't have support for the DO bit. In this
467 // case, we proceed without it.
468 static const int RES_USE_DNSSEC = 0;
469 #endif
463 470
464 // The current implementation assumes these options are set. They normally 471 // The current implementation assumes these options are set. They normally
465 // cannot be overwritten by /etc/resolv.conf 472 // cannot be overwritten by /etc/resolv.conf
466 unsigned kRequiredOptions = RES_RECURSE | RES_DEFNAMES | RES_DNSRCH; 473 unsigned kRequiredOptions = RES_RECURSE | RES_DEFNAMES | RES_DNSRCH;
467 if ((res.options & kRequiredOptions) != kRequiredOptions) { 474 if ((res.options & kRequiredOptions) != kRequiredOptions) {
468 dns_config->unhandled_options = true; 475 dns_config->unhandled_options = true;
469 return CONFIG_PARSE_POSIX_MISSING_OPTIONS; 476 return CONFIG_PARSE_POSIX_MISSING_OPTIONS;
470 } 477 }
471 478
472 unsigned kUnhandledOptions = RES_USEVC | RES_IGNTC | RES_USE_DNSSEC; 479 unsigned kUnhandledOptions = RES_USEVC | RES_IGNTC | RES_USE_DNSSEC;
(...skipping 17 matching lines...) Expand all
490 #endif // !defined(OS_ANDROID) 497 #endif // !defined(OS_ANDROID)
491 498
492 } // namespace internal 499 } // namespace internal
493 500
494 // static 501 // static
495 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { 502 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() {
496 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServicePosix()); 503 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServicePosix());
497 } 504 }
498 505
499 } // namespace net 506 } // namespace net
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_test_util.h ('k') | net/dns/dns_session.cc » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698