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