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

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

Issue 2545163002: net: move kRcodeMask into dns_response.cc (Closed)
Patch Set: Created 4 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
« no previous file with comments | « net/dns/dns_protocol.h ('k') | no next file » | 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 <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 "net/base/address_list.h" 12 #include "net/base/address_list.h"
13 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
14 #include "net/base/ip_address.h" 14 #include "net/base/ip_address.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/dns/dns_protocol.h" 16 #include "net/dns/dns_protocol.h"
17 #include "net/dns/dns_query.h" 17 #include "net/dns/dns_query.h"
18 #include "net/dns/dns_util.h" 18 #include "net/dns/dns_util.h"
19 19
20 namespace net { 20 namespace net {
21 21
22 namespace {
23
24 const uint8_t kRcodeMask = 0xf;
25
26 } // namespace
27
22 DnsResourceRecord::DnsResourceRecord() { 28 DnsResourceRecord::DnsResourceRecord() {
23 } 29 }
24 30
25 DnsResourceRecord::~DnsResourceRecord() { 31 DnsResourceRecord::~DnsResourceRecord() {
26 } 32 }
27 33
28 DnsRecordParser::DnsRecordParser() : packet_(NULL), length_(0), cur_(0) { 34 DnsRecordParser::DnsRecordParser() : packet_(NULL), length_(0), cur_(0) {
29 } 35 }
30 36
31 DnsRecordParser::DnsRecordParser(const void* packet, 37 DnsRecordParser::DnsRecordParser(const void* packet,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 220
215 return true; 221 return true;
216 } 222 }
217 223
218 bool DnsResponse::IsValid() const { 224 bool DnsResponse::IsValid() const {
219 return parser_.IsValid(); 225 return parser_.IsValid();
220 } 226 }
221 227
222 uint16_t DnsResponse::flags() const { 228 uint16_t DnsResponse::flags() const {
223 DCHECK(parser_.IsValid()); 229 DCHECK(parser_.IsValid());
224 return base::NetToHost16(header()->flags) & ~(dns_protocol::kRcodeMask); 230 return base::NetToHost16(header()->flags) & ~(kRcodeMask);
225 } 231 }
226 232
227 uint8_t DnsResponse::rcode() const { 233 uint8_t DnsResponse::rcode() const {
228 DCHECK(parser_.IsValid()); 234 DCHECK(parser_.IsValid());
229 return base::NetToHost16(header()->flags) & dns_protocol::kRcodeMask; 235 return base::NetToHost16(header()->flags) & kRcodeMask;
230 } 236 }
231 237
232 unsigned DnsResponse::answer_count() const { 238 unsigned DnsResponse::answer_count() const {
233 DCHECK(parser_.IsValid()); 239 DCHECK(parser_.IsValid());
234 return base::NetToHost16(header()->ancount); 240 return base::NetToHost16(header()->ancount);
235 } 241 }
236 242
237 unsigned DnsResponse::additional_answer_count() const { 243 unsigned DnsResponse::additional_answer_count() const {
238 DCHECK(parser_.IsValid()); 244 DCHECK(parser_.IsValid());
239 return base::NetToHost16(header()->arcount); 245 return base::NetToHost16(header()->arcount);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 340
335 // getcanonname in eglibc returns the first owner name of an A or AAAA RR. 341 // getcanonname in eglibc returns the first owner name of an A or AAAA RR.
336 // If the response passed all the checks so far, then |expected_name| is it. 342 // If the response passed all the checks so far, then |expected_name| is it.
337 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses, 343 *addr_list = AddressList::CreateFromIPAddressList(ip_addresses,
338 expected_name); 344 expected_name);
339 *ttl = base::TimeDelta::FromSeconds(ttl_sec); 345 *ttl = base::TimeDelta::FromSeconds(ttl_sec);
340 return DNS_PARSE_OK; 346 return DNS_PARSE_OK;
341 } 347 }
342 348
343 } // namespace net 349 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_protocol.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698