Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: net/dns/dns_response.cc

Issue 11567031: [net/dns] Handle TC bit on DNS response in DnsTransaction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to 2nd review Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/dns/dns_response.h ('k') | net/dns/dns_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 cur_ = reader.ptr(); 124 cur_ = reader.ptr();
125 return true; 125 return true;
126 } 126 }
127 return false; 127 return false;
128 } 128 }
129 129
130 DnsResponse::DnsResponse() 130 DnsResponse::DnsResponse()
131 : io_buffer_(new IOBufferWithSize(dns_protocol::kMaxUDPSize + 1)) { 131 : io_buffer_(new IOBufferWithSize(dns_protocol::kMaxUDPSize + 1)) {
132 } 132 }
133 133
134 DnsResponse::DnsResponse(size_t length)
135 : io_buffer_(new IOBufferWithSize(length)) {
136 }
137
134 DnsResponse::DnsResponse(const void* data, 138 DnsResponse::DnsResponse(const void* data,
135 size_t length, 139 size_t length,
136 size_t answer_offset) 140 size_t answer_offset)
137 : io_buffer_(new IOBufferWithSize(length)), 141 : io_buffer_(new IOBufferWithSize(length)),
138 parser_(io_buffer_->data(), length, answer_offset) { 142 parser_(io_buffer_->data(), length, answer_offset) {
139 DCHECK(data); 143 DCHECK(data);
140 memcpy(io_buffer_->data(), data, length); 144 memcpy(io_buffer_->data(), data, length);
141 } 145 }
142 146
143 DnsResponse::~DnsResponse() { 147 DnsResponse::~DnsResponse() {
144 } 148 }
145 149
146 bool DnsResponse::InitParse(int nbytes, const DnsQuery& query) { 150 bool DnsResponse::InitParse(int nbytes, const DnsQuery& query) {
147 // Response includes query, it should be at least that size. 151 // Response includes query, it should be at least that size.
148 if (nbytes < query.io_buffer()->size() || nbytes > dns_protocol::kMaxUDPSize) 152 if (nbytes < query.io_buffer()->size() || nbytes >= io_buffer_->size())
149 return false; 153 return false;
150 154
151 // Match the query id. 155 // Match the query id.
152 if (base::NetToHost16(header()->id) != query.id()) 156 if (base::NetToHost16(header()->id) != query.id())
153 return false; 157 return false;
154 158
155 // Match question count. 159 // Match question count.
156 if (base::NetToHost16(header()->qdcount) != 1) 160 if (base::NetToHost16(header()->qdcount) != 1)
157 return false; 161 return false;
158 162
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 286
283 // getcanonname in eglibc returns the first owner name of an A or AAAA RR. 287 // getcanonname in eglibc returns the first owner name of an A or AAAA RR.
284 // If the response passed all the checks so far, then |expected_name| is it. 288 // If the response passed all the checks so far, then |expected_name| is it.
285 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses, 289 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses,
286 expected_name); 290 expected_name);
287 *ttl = base::TimeDelta::FromSeconds(ttl_sec); 291 *ttl = base::TimeDelta::FromSeconds(ttl_sec);
288 return DNS_PARSE_OK; 292 return DNS_PARSE_OK;
289 } 293 }
290 294
291 } // namespace net 295 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_response.h ('k') | net/dns/dns_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698