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

Unified Diff: net/dns/dns_response.h

Issue 9369045: [net] HostResolverImpl + DnsTransaction + DnsConfigService = Asynchronous DNS ready for experiments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Denitted. Created 8 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/dns/dns_response.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_response.h
diff --git a/net/dns/dns_response.h b/net/dns/dns_response.h
index 764517a37047354dd2fd9fbd8e6c57e4b0e41294..4866045d25e4c56acc247b1ab76b4d84d408f458 100644
--- a/net/dns/dns_response.h
+++ b/net/dns/dns_response.h
@@ -11,11 +11,13 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/string_piece.h"
+#include "base/time.h"
#include "net/base/net_export.h"
#include "net/base/net_util.h"
namespace net {
+class AddressList;
class DnsQuery;
class IOBufferWithSize;
@@ -61,10 +63,10 @@ class NET_EXPORT_PRIVATE DnsRecordParser {
// This is exposed to allow parsing compressed names within RRDATA for TYPEs
// such as NS, CNAME, PTR, MX, SOA.
// See RFC 1035 section 4.1.4.
- int ParseName(const void* pos, std::string* out) const;
+ unsigned ReadName(const void* pos, std::string* out) const;
- // Parses the next resource record. Returns true if succeeded.
- bool ParseRecord(DnsResourceRecord* record);
+ // Parses the next resource record into |record|. Returns true if succeeded.
+ bool ReadRecord(DnsResourceRecord* record);
private:
const char* packet_;
@@ -78,6 +80,20 @@ class NET_EXPORT_PRIVATE DnsRecordParser {
// position the RR parser.
class NET_EXPORT_PRIVATE DnsResponse {
public:
+ // Possible results from ParseToAddressList
+ enum Result {
+ DNS_SUCCESS = 0,
+ DNS_MALFORMED_RESPONSE, // DnsRecordParser failed before the end of
+ // packet.
+ DNS_MALFORMED_CNAME, // Could not parse CNAME out of RRDATA.
+ DNS_NAME_MISMATCH, // Got an address but no ordered chain of CNAMEs
+ // leads there.
+ DNS_SIZE_MISMATCH, // Got an address but size does not match.
+ DNS_CNAME_AFTER_ADDRESS, // Found CNAME after an address record.
+ DNS_ADDRESS_TTL_MISMATCH, // TTL of all address records are not identical.
+ DNS_NO_ADDRESSES, // No address records found.
+ };
+
// Constructs an object with an IOBuffer large enough to read
// one byte more than largest possible response, to detect malformed
// responses.
@@ -102,7 +118,7 @@ class NET_EXPORT_PRIVATE DnsResponse {
// Accessors for the header.
uint16 flags() const; // excluding rcode
uint8 rcode() const;
- int answer_count() const;
+ unsigned answer_count() const;
// Accessors to the question. The qname is unparsed.
base::StringPiece qname() const;
@@ -116,6 +132,10 @@ class NET_EXPORT_PRIVATE DnsResponse {
// This operation is idempotent.
DnsRecordParser Parser() const;
+ // Extracts an AddressList from this response. Returns SUCCESS if succeeded.
+ // Otherwise returns a detailed error number.
+ Result ParseToAddressList(AddressList* addr_list, base::TimeDelta* ttl) const;
+
private:
// Convenience for header access.
const dns_protocol::Header* header() const;
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/dns/dns_response.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698