OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_BASE_DNSRR_RESOLVER_H_ |
| 6 #define NET_BASE_DNSRR_RESOLVER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "build/build_config.h" |
| 14 #include "net/base/completion_callback.h" |
| 15 |
| 16 namespace net { |
| 17 |
| 18 // DnsRRResolver resolves arbitary DNS resource record types. It should not be |
| 19 // confused with HostResolver and should not be used to resolve A/AAAA records. |
| 20 // |
| 21 // HostResolver exists to lookup addresses and there are many details about |
| 22 // address resolution over and above DNS (i.e. Bonjour, VPNs etc). |
| 23 // |
| 24 // DnsRRResolver should only be used when the data is specifically DNS data and |
| 25 // the name is a fully qualified DNS domain. |
| 26 class DnsRRResolver { |
| 27 public: |
| 28 // Response contains the details of a successful request. |
| 29 struct Response { |
| 30 // name contains the canonical name of the resulting domain. If the queried |
| 31 // name was a CNAME then this can differ. |
| 32 std::string name; |
| 33 // ttl contains the TTL of the resource records. |
| 34 uint32 ttl; |
| 35 // dnssec is true if the response was DNSSEC validated. |
| 36 bool dnssec; |
| 37 std::vector<std::string> rrdatas; |
| 38 // sigs contains the RRSIG records returned. |
| 39 std::vector<std::string> signatures; |
| 40 |
| 41 // For testing only |
| 42 bool ParseFromResponse(const uint8* data, unsigned len, |
| 43 uint16 rrtype_requested); |
| 44 }; |
| 45 |
| 46 enum { |
| 47 // Try harder to get a DNSSEC signed response. This doesn't mean that the |
| 48 // Response will always have the dnssec bit set. |
| 49 FLAG_WANT_DNSSEC = 1, |
| 50 }; |
| 51 |
| 52 // Resolve starts the resolution process. When complete, |callback| is called |
| 53 // with a result. If the result is |OK| then |response| is filled with the |
| 54 // result of the resolution. Note the |callback| is called from a random |
| 55 // worker thread. |
| 56 static bool Resolve(const std::string& name, uint16 rrtype, |
| 57 uint16 flags, CompletionCallback* callback, |
| 58 Response* response); |
| 59 |
| 60 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(DnsRRResolver); |
| 62 }; |
| 63 |
| 64 } // namespace net |
| 65 |
| 66 #endif // NET_BASE_DNSRR_RESOLVER_H_ |
OLD | NEW |