Home | History | Annotate | Download | only in base
      1 // Copyright (c) 2009 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_DNS_UTIL_H_
      6 #define NET_BASE_DNS_UTIL_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 
     13 namespace net {
     14 
     15 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's
     16 // public domain DNS library.
     17 //
     18 //   dotted: a string in dotted form: "www.google.com"
     19 //   out: a result in DNS form: "\x03www\x06google\x03com\x00"
     20 bool DNSDomainFromDot(const std::string& dotted, std::string* out);
     21 
     22 // DNSDomainToString coverts a domain in DNS format to a dotted string.
     23 std::string DNSDomainToString(const std::string& domain);
     24 
     25 // Returns true iff the given character is in the set of valid DNS label
     26 // characters as given in RFC 3490, 4.1, 3(a)
     27 bool IsSTD3ASCIIValidCharacter(char c);
     28 
     29 // Returns the hostname by trimming the ending dot, if one exists.
     30 std::string TrimEndingDot(const std::string& host);
     31 
     32 // DNS resource record types. See
     33 // http://www.iana.org/assignments/dns-parameters
     34 // WARNING: if you're adding any new values here you may need to add them to
     35 // dnsrr_resolver.cc:DnsRRIsParsedByWindows.
     36 
     37 static const uint16 kDNS_CNAME = 5;
     38 static const uint16 kDNS_TXT = 16;
     39 static const uint16 kDNS_CERT = 37;
     40 static const uint16 kDNS_DS = 43;
     41 static const uint16 kDNS_RRSIG = 46;
     42 static const uint16 kDNS_DNSKEY = 48;
     43 static const uint16 kDNS_ANY = 0xff;
     44 static const uint16 kDNS_CAA = 13172;  // temporary, not IANA
     45 static const uint16 kDNS_TESTING = 0xfffe;  // in private use area.
     46 
     47 // http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
     48 static const uint8 kDNSSEC_RSA_SHA1 = 5;
     49 static const uint8 kDNSSEC_RSA_SHA1_NSEC3 = 7;
     50 static const uint8 kDNSSEC_RSA_SHA256 = 8;
     51 
     52 // RFC 4509
     53 static const uint8 kDNSSEC_SHA1 = 1;
     54 static const uint8 kDNSSEC_SHA256 = 2;
     55 
     56 }  // namespace net
     57 
     58 #endif  // NET_BASE_DNS_UTIL_H_
     59