| 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 "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/sys_byteorder.h" | 8 #include "base/sys_byteorder.h" |
| 9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
| 10 #include "net/base/big_endian.h" | 10 #include "net/base/big_endian.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 uint8 DnsResponse::rcode() const { | 224 uint8 DnsResponse::rcode() const { |
| 225 DCHECK(parser_.IsValid()); | 225 DCHECK(parser_.IsValid()); |
| 226 return base::NetToHost16(header()->flags) & dns_protocol::kRcodeMask; | 226 return base::NetToHost16(header()->flags) & dns_protocol::kRcodeMask; |
| 227 } | 227 } |
| 228 | 228 |
| 229 unsigned DnsResponse::answer_count() const { | 229 unsigned DnsResponse::answer_count() const { |
| 230 DCHECK(parser_.IsValid()); | 230 DCHECK(parser_.IsValid()); |
| 231 return base::NetToHost16(header()->ancount); | 231 return base::NetToHost16(header()->ancount); |
| 232 } | 232 } |
| 233 | 233 |
| 234 unsigned DnsResponse::additional_answer_count() const { |
| 235 DCHECK(parser_.IsValid()); |
| 236 return base::NetToHost16(header()->arcount); |
| 237 } |
| 238 |
| 234 base::StringPiece DnsResponse::qname() const { | 239 base::StringPiece DnsResponse::qname() const { |
| 235 DCHECK(parser_.IsValid()); | 240 DCHECK(parser_.IsValid()); |
| 236 // The response is HEADER QNAME QTYPE QCLASS ANSWER. | 241 // The response is HEADER QNAME QTYPE QCLASS ANSWER. |
| 237 // |parser_| is positioned at the beginning of ANSWER, so the end of QNAME is | 242 // |parser_| is positioned at the beginning of ANSWER, so the end of QNAME is |
| 238 // two uint16s before it. | 243 // two uint16s before it. |
| 239 const size_t hdr_size = sizeof(dns_protocol::Header); | 244 const size_t hdr_size = sizeof(dns_protocol::Header); |
| 240 const size_t qname_size = parser_.GetOffset() - 2 * sizeof(uint16) - hdr_size; | 245 const size_t qname_size = parser_.GetOffset() - 2 * sizeof(uint16) - hdr_size; |
| 241 return base::StringPiece(io_buffer_->data() + hdr_size, qname_size); | 246 return base::StringPiece(io_buffer_->data() + hdr_size, qname_size); |
| 242 } | 247 } |
| 243 | 248 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 328 |
| 324 // getcanonname in eglibc returns the first owner name of an A or AAAA RR. | 329 // getcanonname in eglibc returns the first owner name of an A or AAAA RR. |
| 325 // If the response passed all the checks so far, then |expected_name| is it. | 330 // If the response passed all the checks so far, then |expected_name| is it. |
| 326 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses, | 331 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses, |
| 327 expected_name); | 332 expected_name); |
| 328 *ttl = base::TimeDelta::FromSeconds(ttl_sec); | 333 *ttl = base::TimeDelta::FromSeconds(ttl_sec); |
| 329 return DNS_PARSE_OK; | 334 return DNS_PARSE_OK; |
| 330 } | 335 } |
| 331 | 336 |
| 332 } // namespace net | 337 } // namespace net |
| OLD | NEW |