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_test_util.h" | 5 #include "net/dns/dns_test_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/big_endian.h" | 9 #include "base/big_endian.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 reinterpret_cast<dns_protocol::Header*>(buffer); | 101 reinterpret_cast<dns_protocol::Header*>(buffer); |
102 header->flags |= dns_protocol::kFlagResponse; | 102 header->flags |= dns_protocol::kFlagResponse; |
103 | 103 |
104 if (MockDnsClientRule::OK == result_) { | 104 if (MockDnsClientRule::OK == result_) { |
105 const uint16_t kPointerToQueryName = | 105 const uint16_t kPointerToQueryName = |
106 static_cast<uint16_t>(0xc000 | sizeof(*header)); | 106 static_cast<uint16_t>(0xc000 | sizeof(*header)); |
107 | 107 |
108 const uint32_t kTTL = 86400; // One day. | 108 const uint32_t kTTL = 86400; // One day. |
109 | 109 |
110 // Size of RDATA which is a IPv4 or IPv6 address. | 110 // Size of RDATA which is a IPv4 or IPv6 address. |
111 size_t rdata_size = qtype_ == dns_protocol::kTypeA ? kIPv4AddressSize | 111 size_t rdata_size = qtype_ == dns_protocol::kTypeA |
112 : kIPv6AddressSize; | 112 ? IPAddress::kIPv4AddressSize |
| 113 : IPAddress::kIPv6AddressSize; |
113 | 114 |
114 // 12 is the sum of sizes of the compressed name reference, TYPE, | 115 // 12 is the sum of sizes of the compressed name reference, TYPE, |
115 // CLASS, TTL and RDLENGTH. | 116 // CLASS, TTL and RDLENGTH. |
116 size_t answer_size = 12 + rdata_size; | 117 size_t answer_size = 12 + rdata_size; |
117 | 118 |
118 // Write answer with loopback IP address. | 119 // Write answer with loopback IP address. |
119 header->ancount = base::HostToNet16(1); | 120 header->ancount = base::HostToNet16(1); |
120 base::BigEndianWriter writer(buffer + nbytes, answer_size); | 121 base::BigEndianWriter writer(buffer + nbytes, answer_size); |
121 writer.WriteU16(kPointerToQueryName); | 122 writer.WriteU16(kPointerToQueryName); |
122 writer.WriteU16(qtype_); | 123 writer.WriteU16(qtype_); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 219 |
219 AddressSorter* MockDnsClient::GetAddressSorter() { | 220 AddressSorter* MockDnsClient::GetAddressSorter() { |
220 return address_sorter_.get(); | 221 return address_sorter_.get(); |
221 } | 222 } |
222 | 223 |
223 void MockDnsClient::CompleteDelayedTransactions() { | 224 void MockDnsClient::CompleteDelayedTransactions() { |
224 factory_->CompleteDelayedTransactions(); | 225 factory_->CompleteDelayedTransactions(); |
225 } | 226 } |
226 | 227 |
227 } // namespace net | 228 } // namespace net |
OLD | NEW |