OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_DNS_DNS_QUERY_H_ | 5 #ifndef NET_DNS_DNS_QUERY_H_ |
6 #define NET_DNS_DNS_QUERY_H_ | 6 #define NET_DNS_DNS_QUERY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
12 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
13 | 16 |
14 namespace net { | 17 namespace net { |
15 | 18 |
16 class IOBufferWithSize; | 19 class IOBufferWithSize; |
17 | 20 |
18 // Represents on-the-wire DNS query message as an object. | 21 // Represents on-the-wire DNS query message as an object. |
19 // TODO(szym): add support for the OPT pseudo-RR (EDNS0/DNSSEC). | 22 // TODO(szym): add support for the OPT pseudo-RR (EDNS0/DNSSEC). |
20 class NET_EXPORT_PRIVATE DnsQuery { | 23 class NET_EXPORT_PRIVATE DnsQuery { |
21 public: | 24 public: |
22 // Constructs a query message from |qname| which *MUST* be in a valid | 25 // Constructs a query message from |qname| which *MUST* be in a valid |
23 // DNS name format, and |qtype|. The qclass is set to IN. | 26 // DNS name format, and |qtype|. The qclass is set to IN. |
24 DnsQuery(uint16 id, const base::StringPiece& qname, uint16 qtype); | 27 DnsQuery(uint16_t id, const base::StringPiece& qname, uint16_t qtype); |
25 ~DnsQuery(); | 28 ~DnsQuery(); |
26 | 29 |
27 // Clones |this| verbatim, with ID field of the header set to |id|. | 30 // Clones |this| verbatim, with ID field of the header set to |id|. |
28 scoped_ptr<DnsQuery> CloneWithNewId(uint16 id) const; | 31 scoped_ptr<DnsQuery> CloneWithNewId(uint16_t id) const; |
29 | 32 |
30 // DnsQuery field accessors. | 33 // DnsQuery field accessors. |
31 uint16 id() const; | 34 uint16_t id() const; |
32 base::StringPiece qname() const; | 35 base::StringPiece qname() const; |
33 uint16 qtype() const; | 36 uint16_t qtype() const; |
34 | 37 |
35 // Returns the Question section of the query. Used when matching the | 38 // Returns the Question section of the query. Used when matching the |
36 // response. | 39 // response. |
37 base::StringPiece question() const; | 40 base::StringPiece question() const; |
38 | 41 |
39 // IOBuffer accessor to be used for writing out the query. | 42 // IOBuffer accessor to be used for writing out the query. |
40 IOBufferWithSize* io_buffer() const { return io_buffer_.get(); } | 43 IOBufferWithSize* io_buffer() const { return io_buffer_.get(); } |
41 | 44 |
42 void set_flags(uint16 flags); | 45 void set_flags(uint16_t flags); |
43 | 46 |
44 private: | 47 private: |
45 DnsQuery(const DnsQuery& orig, uint16 id); | 48 DnsQuery(const DnsQuery& orig, uint16_t id); |
46 | 49 |
47 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used | 50 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used |
48 // to calculate offsets. | 51 // to calculate offsets. |
49 size_t qname_size_; | 52 size_t qname_size_; |
50 | 53 |
51 // Contains query bytes to be consumed by higher level Write() call. | 54 // Contains query bytes to be consumed by higher level Write() call. |
52 scoped_refptr<IOBufferWithSize> io_buffer_; | 55 scoped_refptr<IOBufferWithSize> io_buffer_; |
53 | 56 |
54 DISALLOW_COPY_AND_ASSIGN(DnsQuery); | 57 DISALLOW_COPY_AND_ASSIGN(DnsQuery); |
55 }; | 58 }; |
56 | 59 |
57 } // namespace net | 60 } // namespace net |
58 | 61 |
59 #endif // NET_DNS_DNS_QUERY_H_ | 62 #endif // NET_DNS_DNS_QUERY_H_ |
OLD | NEW |