| 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_response.h" | 5 #include "net/dns/dns_response.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/big_endian.h" | 9 #include "base/big_endian.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/sys_byteorder.h" | 11 #include "base/sys_byteorder.h" |
| 12 #include "base/trace_event/trace_event.h" |
| 12 #include "net/base/address_list.h" | 13 #include "net/base/address_list.h" |
| 13 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 14 #include "net/base/ip_address.h" | 15 #include "net/base/ip_address.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "net/dns/dns_protocol.h" | 17 #include "net/dns/dns_protocol.h" |
| 17 #include "net/dns/dns_query.h" | 18 #include "net/dns/dns_query.h" |
| 18 #include "net/dns/dns_util.h" | 19 #include "net/dns/dns_util.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 return parser_; | 272 return parser_; |
| 272 } | 273 } |
| 273 | 274 |
| 274 const dns_protocol::Header* DnsResponse::header() const { | 275 const dns_protocol::Header* DnsResponse::header() const { |
| 275 return reinterpret_cast<const dns_protocol::Header*>(io_buffer_->data()); | 276 return reinterpret_cast<const dns_protocol::Header*>(io_buffer_->data()); |
| 276 } | 277 } |
| 277 | 278 |
| 278 DnsResponse::Result DnsResponse::ParseToAddressList( | 279 DnsResponse::Result DnsResponse::ParseToAddressList( |
| 279 AddressList* addr_list, | 280 AddressList* addr_list, |
| 280 base::TimeDelta* ttl) const { | 281 base::TimeDelta* ttl) const { |
| 282 TRACE_EVENT0("net", "DnsResponse::ParseToAddressList"); |
| 281 DCHECK(IsValid()); | 283 DCHECK(IsValid()); |
| 282 // DnsTransaction already verified that |response| matches the issued query. | 284 // DnsTransaction already verified that |response| matches the issued query. |
| 283 // We still need to determine if there is a valid chain of CNAMEs from the | 285 // We still need to determine if there is a valid chain of CNAMEs from the |
| 284 // query name to the RR owner name. | 286 // query name to the RR owner name. |
| 285 // We err on the side of caution with the assumption that if we are too picky, | 287 // We err on the side of caution with the assumption that if we are too picky, |
| 286 // we can always fall back to the system getaddrinfo. | 288 // we can always fall back to the system getaddrinfo. |
| 287 | 289 |
| 288 // Expected owner of record. No trailing dot. | 290 // Expected owner of record. No trailing dot. |
| 289 std::string expected_name = GetDottedName(); | 291 std::string expected_name = GetDottedName(); |
| 290 | 292 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 338 |
| 337 // getcanonname in eglibc returns the first owner name of an A or AAAA RR. | 339 // getcanonname in eglibc returns the first owner name of an A or AAAA RR. |
| 338 // If the response passed all the checks so far, then |expected_name| is it. | 340 // If the response passed all the checks so far, then |expected_name| is it. |
| 339 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses, | 341 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses, |
| 340 expected_name); | 342 expected_name); |
| 341 *ttl = base::TimeDelta::FromSeconds(ttl_sec); | 343 *ttl = base::TimeDelta::FromSeconds(ttl_sec); |
| 342 return DNS_PARSE_OK; | 344 return DNS_PARSE_OK; |
| 343 } | 345 } |
| 344 | 346 |
| 345 } // namespace net | 347 } // namespace net |
| OLD | NEW |