Index: net/base/dns_query.h |
diff --git a/net/base/dns_query.h b/net/base/dns_query.h |
index bc25997e9e881c2bd235f13ec9bfb11efc899d7d..71b260c13db10bd2a99f48d45b74d9ca2d85ab39 100644 |
--- a/net/base/dns_query.h |
+++ b/net/base/dns_query.h |
@@ -8,63 +8,59 @@ |
#include <string> |
-#include "net/base/address_family.h" |
#include "net/base/io_buffer.h" |
#include "net/base/net_util.h" |
namespace net{ |
-// A class that encapsulates bits and pieces related to DNS request processing. |
+// Represents on-the-wire DNS query message as an object. |
class DnsQuery { |
public: |
- // Constructs an object containing an IOBuffer with raw DNS query string |
- // for |hostname| with the given |address_family|; |port| is here due to |
- // legacy -- getaddrinfo() takes service name, which is mapped to some |
- // port and returns sockaddr_in structures with ports filled in, so do we |
- // -- look at DnsResponse::Parse() to see where it is used. |
+ // Constructs a query message from |dns_name| which *MUST* be in a valid |
+ // DNS name format, and |qtype| which must be either kDNS_A or kDNS_AAA. |
// Every generated object has a random ID, hence two objects generated |
// with the same set of constructor arguments are generally not equal; |
// there is a 1/2^16 chance of them being equal due to size of |id_|. |
- DnsQuery(const std::string& hostname, AddressFamily address_family, int port); |
+ DnsQuery(const std::string& dns_name, uint16 qtype); |
~DnsQuery(); |
- // Returns true if the constructed object was valid. |
- bool IsValid() const { return io_buffer_.get() != NULL; } |
+ // Clones |this| verbatim with ID field of the header regenerated. |
+ DnsQuery* CloneWithNewId() const; |
- // DnsQuery field accessors. These should only be called on an object |
- // for whom |IsValid| is true. |
- int port() const; |
+ // DnsQuery field accessors. |
uint16 id() const; |
uint16 qtype() const; |
- AddressFamily address_family() const; |
- const std::string& hostname() const; |
+ |
+ // Returns the size of the Question section of the query. Used when |
+ // matching the response. |
+ size_t question_size() const; |
+ |
+ // Returns pointer to the Question section of the query. Used when |
+ // matching the response. |
+ const char* question_data() const; |
// IOBuffer accessor to be used for writing out the query. |
- IOBufferWithSize* io_buffer() const; |
+ IOBufferWithSize* io_buffer() const { return io_buffer_; } |
private: |
- // Port to be used by corresponding DnsResponse when filling sockaddr_ins |
- // to be returned. |
- int port_; |
+ // Copy constructor to be used only by CloneWithNewId; it's not public |
+ // since there is a semantic difference -- this does not construct an |
+ // exact copy! |
+ DnsQuery(const DnsQuery& rhs); |
- // ID of the query. |
- uint16 id_; |
+ // Not implemented; just to prevent the assignment. |
+ void operator=(const DnsQuery&); |
- // Type of query, currently, either A or AAAA. |
- uint16 qtype_; |
+ // Randomizes ID field of the query message. |
+ void RandomizeId(); |
- // Address family of the query; used when constructing new object from |
- // this one. |
- AddressFamily address_family_; |
- |
- // Hostname that we are trying to resolve. |
- std::string hostname_; |
+ // Size of the DNS name (*NOT* hostname) we are trying to resolve; used |
+ // to calculate offsets. |
+ size_t dns_name_size_; |
// Contains query bytes to be consumed by higher level Write() call. |
scoped_refptr<IOBufferWithSize> io_buffer_; |
- |
- DISALLOW_COPY_AND_ASSIGN(DnsQuery); |
}; |
} // namespace net |