OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_DNS_DNS_UTIL_H_ | 5 #ifndef NET_DNS_DNS_UTIL_H_ |
6 #define NET_DNS_DNS_UTIL_H_ | 6 #define NET_DNS_DNS_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 #include "net/base/network_change_notifier.h" | 13 #include "net/base/network_change_notifier.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class AddressList; | 17 class AddressList; |
18 | 18 |
19 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's | 19 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's |
20 // public domain DNS library. | 20 // public domain DNS library. |
21 // | 21 // |
22 // dotted: a string in dotted form: "www.google.com" | 22 // dotted: a string in dotted form: "www.google.com" |
23 // out: a result in DNS form: "\x03www\x06google\x03com\x00" | 23 // out: a result in DNS form: "\x03www\x06google\x03com\x00" |
24 NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted, | 24 NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted, |
25 std::string* out); | 25 std::string* out); |
26 | 26 |
| 27 // dotted: a string in dotted form: "www.google.com" |
| 28 // out: a result in DNS form: "\x03www\x06google\x03com\x00" |
| 29 // valid_name: whether or not |IsValidHostLabelCharacter| returned true for |
| 30 // all characters in all labels in the name. |
| 31 bool DNSDomainFromDotWithValidityCheck(const base::StringPiece& dotted, |
| 32 std::string* out, |
| 33 bool* valid_name); |
| 34 |
27 // Checks that a hostname is valid. Simple wrapper around DNSDomainFromDot. | 35 // Checks that a hostname is valid. Simple wrapper around DNSDomainFromDot. |
28 NET_EXPORT_PRIVATE bool IsValidDNSDomain(const base::StringPiece& dotted); | 36 NET_EXPORT_PRIVATE bool IsValidDNSDomain(const base::StringPiece& dotted); |
29 | 37 |
30 // Returns true if the character is valid in a DNS hostname label, whether in | 38 // Returns true if the character is valid in a DNS hostname label, whether in |
31 // the first position or later in the label. | 39 // the first position or later in the label. |
32 // | 40 // |
33 // This function asserts a looser form of the restrictions in RFC 7719 (section | 41 // This function asserts a looser form of the restrictions in RFC 7719 (section |
34 // 2; https://tools.ietf.org/html/rfc7719#section-2): hostnames can include | 42 // 2; https://tools.ietf.org/html/rfc7719#section-2): hostnames can include |
35 // characters a-z, A-Z, 0-9, -, and _, and any of those characters (except -) | 43 // characters a-z, A-Z, 0-9, -, and _, and any of those characters (except -) |
36 // are legal in the first position. The looser rules are necessary to support | 44 // are legal in the first position. The looser rules are necessary to support |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 }; | 78 }; |
71 | 79 |
72 // Compares two AddressLists to see how similar or different their addresses | 80 // Compares two AddressLists to see how similar or different their addresses |
73 // are. (See |AddressListDeltaType| for details of exactly what's checked.) | 81 // are. (See |AddressListDeltaType| for details of exactly what's checked.) |
74 AddressListDeltaType FindAddressListDeltaType(const AddressList& a, | 82 AddressListDeltaType FindAddressListDeltaType(const AddressList& a, |
75 const AddressList& b); | 83 const AddressList& b); |
76 | 84 |
77 } // namespace net | 85 } // namespace net |
78 | 86 |
79 #endif // NET_DNS_DNS_UTIL_H_ | 87 #endif // NET_DNS_DNS_UTIL_H_ |
OLD | NEW |