| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // CLASS, TTL and RDLENGTH. | 115 // CLASS, TTL and RDLENGTH. |
| 116 size_t answer_size = 12 + rdata_size; | 116 size_t answer_size = 12 + rdata_size; |
| 117 | 117 |
| 118 // Write answer with loopback IP address. | 118 // Write answer with loopback IP address. |
| 119 header->ancount = base::HostToNet16(1); | 119 header->ancount = base::HostToNet16(1); |
| 120 base::BigEndianWriter writer(buffer + nbytes, answer_size); | 120 base::BigEndianWriter writer(buffer + nbytes, answer_size); |
| 121 writer.WriteU16(kPointerToQueryName); | 121 writer.WriteU16(kPointerToQueryName); |
| 122 writer.WriteU16(qtype_); | 122 writer.WriteU16(qtype_); |
| 123 writer.WriteU16(dns_protocol::kClassIN); | 123 writer.WriteU16(dns_protocol::kClassIN); |
| 124 writer.WriteU32(kTTL); | 124 writer.WriteU32(kTTL); |
| 125 writer.WriteU16(rdata_size); | 125 writer.WriteU16(static_cast<uint16>(rdata_size)); |
| 126 if (qtype_ == dns_protocol::kTypeA) { | 126 if (qtype_ == dns_protocol::kTypeA) { |
| 127 char kIPv4Loopback[] = { 0x7f, 0, 0, 1 }; | 127 char kIPv4Loopback[] = { 0x7f, 0, 0, 1 }; |
| 128 writer.WriteBytes(kIPv4Loopback, sizeof(kIPv4Loopback)); | 128 writer.WriteBytes(kIPv4Loopback, sizeof(kIPv4Loopback)); |
| 129 } else { | 129 } else { |
| 130 char kIPv6Loopback[] = { 0, 0, 0, 0, 0, 0, 0, 0, | 130 char kIPv6Loopback[] = { 0, 0, 0, 0, 0, 0, 0, 0, |
| 131 0, 0, 0, 0, 0, 0, 0, 1 }; | 131 0, 0, 0, 0, 0, 0, 0, 1 }; |
| 132 writer.WriteBytes(kIPv6Loopback, sizeof(kIPv6Loopback)); | 132 writer.WriteBytes(kIPv6Loopback, sizeof(kIPv6Loopback)); |
| 133 } | 133 } |
| 134 nbytes += answer_size; | 134 nbytes += answer_size; |
| 135 } | 135 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 AddressSorter* MockDnsClient::GetAddressSorter() { | 219 AddressSorter* MockDnsClient::GetAddressSorter() { |
| 220 return address_sorter_.get(); | 220 return address_sorter_.get(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void MockDnsClient::CompleteDelayedTransactions() { | 223 void MockDnsClient::CompleteDelayedTransactions() { |
| 224 factory_->CompleteDelayedTransactions(); | 224 factory_->CompleteDelayedTransactions(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace net | 227 } // namespace net |
| OLD | NEW |