| OLD | NEW |
| 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_win.h" | 5 #include "net/dns/dns_config_service_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 adapter->FirstUnicastAddress; | 274 adapter->FirstUnicastAddress; |
| 275 address != NULL; | 275 address != NULL; |
| 276 address = address->Next) { | 276 address = address->Next) { |
| 277 IPEndPoint ipe; | 277 IPEndPoint ipe; |
| 278 if (!ipe.FromSockAddr(address->Address.lpSockaddr, | 278 if (!ipe.FromSockAddr(address->Address.lpSockaddr, |
| 279 address->Address.iSockaddrLength)) { | 279 address->Address.iSockaddrLength)) { |
| 280 return HOSTS_PARSE_WIN_BAD_ADDRESS; | 280 return HOSTS_PARSE_WIN_BAD_ADDRESS; |
| 281 } | 281 } |
| 282 if (!have_ipv4 && (ipe.GetFamily() == ADDRESS_FAMILY_IPV4)) { | 282 if (!have_ipv4 && (ipe.GetFamily() == ADDRESS_FAMILY_IPV4)) { |
| 283 have_ipv4 = true; | 283 have_ipv4 = true; |
| 284 (*hosts)[DnsHostsKey(localname, ADDRESS_FAMILY_IPV4)] = ipe.address(); | 284 (*hosts)[DnsHostsKey(localname, ADDRESS_FAMILY_IPV4)] = |
| 285 ipe.address_number(); |
| 285 } else if (!have_ipv6 && (ipe.GetFamily() == ADDRESS_FAMILY_IPV6)) { | 286 } else if (!have_ipv6 && (ipe.GetFamily() == ADDRESS_FAMILY_IPV6)) { |
| 286 have_ipv6 = true; | 287 have_ipv6 = true; |
| 287 (*hosts)[DnsHostsKey(localname, ADDRESS_FAMILY_IPV6)] = ipe.address(); | 288 (*hosts)[DnsHostsKey(localname, ADDRESS_FAMILY_IPV6)] = |
| 289 ipe.address_number(); |
| 288 } | 290 } |
| 289 } | 291 } |
| 290 } | 292 } |
| 291 return HOSTS_PARSE_WIN_OK; | 293 return HOSTS_PARSE_WIN_OK; |
| 292 } | 294 } |
| 293 | 295 |
| 294 // Watches a single registry key for changes. | 296 // Watches a single registry key for changes. |
| 295 class RegistryWatcher : public base::NonThreadSafe { | 297 class RegistryWatcher : public base::NonThreadSafe { |
| 296 public: | 298 public: |
| 297 typedef base::Callback<void(bool succeeded)> CallbackType; | 299 typedef base::Callback<void(bool succeeded)> CallbackType; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 if (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK) | 508 if (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK) |
| 507 continue; | 509 continue; |
| 508 | 510 |
| 509 for (const IP_ADAPTER_DNS_SERVER_ADDRESS* address = | 511 for (const IP_ADAPTER_DNS_SERVER_ADDRESS* address = |
| 510 adapter->FirstDnsServerAddress; | 512 adapter->FirstDnsServerAddress; |
| 511 address != NULL; | 513 address != NULL; |
| 512 address = address->Next) { | 514 address = address->Next) { |
| 513 IPEndPoint ipe; | 515 IPEndPoint ipe; |
| 514 if (ipe.FromSockAddr(address->Address.lpSockaddr, | 516 if (ipe.FromSockAddr(address->Address.lpSockaddr, |
| 515 address->Address.iSockaddrLength)) { | 517 address->Address.iSockaddrLength)) { |
| 516 if (IsStatelessDiscoveryAddress(ipe.address())) | 518 if (IsStatelessDiscoveryAddress(ipe.address_number())) |
| 517 continue; | 519 continue; |
| 518 // Override unset port. | 520 // Override unset port. |
| 519 if (!ipe.port()) | 521 if (!ipe.port()) |
| 520 ipe = IPEndPoint(ipe.address(), dns_protocol::kDefaultPort); | 522 ipe = IPEndPoint(ipe.address_number(), dns_protocol::kDefaultPort); |
| 521 config->nameservers.push_back(ipe); | 523 config->nameservers.push_back(ipe); |
| 522 } else { | 524 } else { |
| 523 return CONFIG_PARSE_WIN_BAD_ADDRESS; | 525 return CONFIG_PARSE_WIN_BAD_ADDRESS; |
| 524 } | 526 } |
| 525 } | 527 } |
| 526 | 528 |
| 527 // IP_ADAPTER_ADDRESSES in Vista+ has a search list at |FirstDnsSuffix|, | 529 // IP_ADAPTER_ADDRESSES in Vista+ has a search list at |FirstDnsSuffix|, |
| 528 // but it came up empty in all trials. | 530 // but it came up empty in all trials. |
| 529 // |DnsSuffix| stores the effective connection-specific suffix, which is | 531 // |DnsSuffix| stores the effective connection-specific suffix, which is |
| 530 // obtained via DHCP (regkey: Tcpip\Parameters\Interfaces\{XXX}\DhcpDomain) | 532 // obtained via DHCP (regkey: Tcpip\Parameters\Interfaces\{XXX}\DhcpDomain) |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 } | 780 } |
| 779 | 781 |
| 780 } // namespace internal | 782 } // namespace internal |
| 781 | 783 |
| 782 // static | 784 // static |
| 783 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { | 785 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { |
| 784 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin()); | 786 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin()); |
| 785 } | 787 } |
| 786 | 788 |
| 787 } // namespace net | 789 } // namespace net |
| OLD | NEW |