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_query.h" | 5 #include "net/dns/dns_query.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/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 base::BigEndianWriter writer(reinterpret_cast<char*>(header + 1), | 36 base::BigEndianWriter writer(reinterpret_cast<char*>(header + 1), |
37 question_size); | 37 question_size); |
38 writer.WriteBytes(qname.data(), qname.size()); | 38 writer.WriteBytes(qname.data(), qname.size()); |
39 writer.WriteU16(qtype); | 39 writer.WriteU16(qtype); |
40 writer.WriteU16(dns_protocol::kClassIN); | 40 writer.WriteU16(dns_protocol::kClassIN); |
41 } | 41 } |
42 | 42 |
43 DnsQuery::~DnsQuery() { | 43 DnsQuery::~DnsQuery() { |
44 } | 44 } |
45 | 45 |
46 DnsQuery* DnsQuery::CloneWithNewId(uint16 id) const { | 46 scoped_ptr<DnsQuery> DnsQuery::CloneWithNewId(uint16 id) const { |
47 return new DnsQuery(*this, id); | 47 return scoped_ptr<DnsQuery>(new DnsQuery(*this, id)); |
eroman
2015/09/18 17:39:56
make_scoped_ptr(new DnsQuery(*this, id));
Paritosh Kumar
2015/09/21 09:38:43
Thanks. Done.
| |
48 } | 48 } |
49 | 49 |
50 uint16 DnsQuery::id() const { | 50 uint16 DnsQuery::id() const { |
51 const dns_protocol::Header* header = | 51 const dns_protocol::Header* header = |
52 reinterpret_cast<const dns_protocol::Header*>(io_buffer_->data()); | 52 reinterpret_cast<const dns_protocol::Header*>(io_buffer_->data()); |
53 return base::NetToHost16(header->id); | 53 return base::NetToHost16(header->id); |
54 } | 54 } |
55 | 55 |
56 base::StringPiece DnsQuery::qname() const { | 56 base::StringPiece DnsQuery::qname() const { |
57 return base::StringPiece(io_buffer_->data() + sizeof(dns_protocol::Header), | 57 return base::StringPiece(io_buffer_->data() + sizeof(dns_protocol::Header), |
(...skipping 22 matching lines...) Expand all Loading... | |
80 header->id = base::HostToNet16(id); | 80 header->id = base::HostToNet16(id); |
81 } | 81 } |
82 | 82 |
83 void DnsQuery::set_flags(uint16 flags) { | 83 void DnsQuery::set_flags(uint16 flags) { |
84 dns_protocol::Header* header = | 84 dns_protocol::Header* header = |
85 reinterpret_cast<dns_protocol::Header*>(io_buffer_->data()); | 85 reinterpret_cast<dns_protocol::Header*>(io_buffer_->data()); |
86 header->flags = flags; | 86 header->flags = flags; |
87 } | 87 } |
88 | 88 |
89 } // namespace net | 89 } // namespace net |
OLD | NEW |