[email protected] | d0d49dd8 | 2012-01-26 00:03:59 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 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_ | ||||
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | |||||
[email protected] | b3ccac8 | 2010-08-04 15:54:40 | [diff] [blame] | 10 | #include "base/basictypes.h" |
[email protected] | d069c11a | 2013-04-13 00:01:55 | [diff] [blame^] | 11 | #include "base/strings/string_piece.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 12 | #include "net/base/net_export.h" |
[email protected] | b3ccac8 | 2010-08-04 15:54:40 | [diff] [blame] | 13 | |
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 14 | namespace net { |
15 | |||||
16 | // DNSDomainFromDot - convert a domain string to DNS format. From DJB's | ||||
17 | // public domain DNS library. | ||||
18 | // | ||||
19 | // dotted: a string in dotted form: "www.google.com" | ||||
20 | // out: a result in DNS form: "\x03www\x06google\x03com\x00" | ||||
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 21 | NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted, |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 22 | std::string* out); |
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 23 | |
[email protected] | d0d49dd8 | 2012-01-26 00:03:59 | [diff] [blame] | 24 | // DNSDomainToString converts a domain in DNS format to a dotted string. |
25 | // Excludes the dot at the end. | ||||
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 26 | NET_EXPORT_PRIVATE std::string DNSDomainToString( |
27 | const base::StringPiece& domain); | ||||
[email protected] | f060be3 | 2011-02-17 17:20:28 | [diff] [blame] | 28 | |
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 29 | // Returns true iff the given character is in the set of valid DNS label |
30 | // characters as given in RFC 3490, 4.1, 3(a) | ||||
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 31 | NET_EXPORT_PRIVATE bool IsSTD3ASCIIValidCharacter(char c); |
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 32 | |
[email protected] | 13c340e1 | 2010-03-08 19:29:41 | [diff] [blame] | 33 | // Returns the hostname by trimming the ending dot, if one exists. |
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 34 | NET_EXPORT std::string TrimEndingDot(const base::StringPiece& host); |
35 | |||||
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 36 | } // namespace net |
37 | |||||
38 | #endif // NET_BASE_DNS_UTIL_H_ |