[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 | |||||
tfarina | 77021d6 | 2015-10-11 20:19:03 | [diff] [blame] | 5 | #ifndef NET_DNS_DNS_UTIL_H_ |
6 | #define NET_DNS_DNS_UTIL_H_ | ||||
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | |||||
[email protected] | d069c11a | 2013-04-13 00:01:55 | [diff] [blame] | 10 | #include "base/strings/string_piece.h" |
ttuttle | cf1158bf | 2016-03-18 16:37:44 | [diff] [blame] | 11 | #include "base/time/time.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 12 | #include "net/base/net_export.h" |
ttuttle | cf1158bf | 2016-03-18 16:37:44 | [diff] [blame] | 13 | #include "net/base/network_change_notifier.h" |
[email protected] | b3ccac8 | 2010-08-04 15:54:40 | [diff] [blame] | 14 | |
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 15 | namespace net { |
16 | |||||
juliatuttle | 317860e | 2016-05-12 14:47:22 | [diff] [blame] | 17 | class AddressList; |
18 | |||||
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 19 | // DNSDomainFromDot - convert a domain string to DNS format. From DJB's |
20 | // public domain DNS library. | ||||
21 | // | ||||
22 | // dotted: a string in dotted form: "www.google.com" | ||||
23 | // out: a result in DNS form: "\x03www\x06google\x03com\x00" | ||||
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 24 | NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted, |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 25 | std::string* out); |
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 26 | |
mmenke | d6e9161aff | 2016-09-09 21:55:44 | [diff] [blame^] | 27 | // Checks that a hostname is valid. Simple wrapper around DNSDomainFromDot. |
28 | NET_EXPORT_PRIVATE bool IsValidDNSDomain(const base::StringPiece& dotted); | ||||
29 | |||||
[email protected] | d0d49dd8 | 2012-01-26 00:03:59 | [diff] [blame] | 30 | // DNSDomainToString converts a domain in DNS format to a dotted string. |
31 | // Excludes the dot at the end. | ||||
[email protected] | 7556ea2 | 2011-12-08 19:29:15 | [diff] [blame] | 32 | NET_EXPORT_PRIVATE std::string DNSDomainToString( |
33 | const base::StringPiece& domain); | ||||
[email protected] | f060be3 | 2011-02-17 17:20:28 | [diff] [blame] | 34 | |
tfarina | ecc304ec | 2015-12-16 05:37:54 | [diff] [blame] | 35 | // Returns true if it can determine that only loopback addresses are configured. |
36 | // i.e. if only 127.0.0.1 and ::1 are routable. | ||||
37 | // Also returns false if it cannot determine this. | ||||
38 | NET_EXPORT_PRIVATE bool HaveOnlyLoopbackAddresses(); | ||||
39 | |||||
ttuttle | cf1158bf | 2016-03-18 16:37:44 | [diff] [blame] | 40 | #if !defined(OS_NACL) |
41 | NET_EXPORT_PRIVATE | ||||
42 | base::TimeDelta GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( | ||||
43 | const char* field_trial_name, | ||||
44 | base::TimeDelta default_delta, | ||||
45 | NetworkChangeNotifier::ConnectionType connection_type); | ||||
46 | #endif // !defined(OS_NACL) | ||||
47 | |||||
juliatuttle | 317860e | 2016-05-12 14:47:22 | [diff] [blame] | 48 | // How similar or different two AddressLists are (see values for details). |
49 | // Used in histograms; do not modify existing values. | ||||
50 | enum AddressListDeltaType { | ||||
51 | // Both lists contain the same addresses in the same order. | ||||
52 | DELTA_IDENTICAL = 0, | ||||
53 | // Both lists contain the same addresses in a different order. | ||||
54 | DELTA_REORDERED = 1, | ||||
55 | // The two lists have at least one address in common, but not all of them. | ||||
56 | DELTA_OVERLAP = 2, | ||||
57 | // The two lists have no addresses in common. | ||||
58 | DELTA_DISJOINT = 3, | ||||
59 | MAX_DELTA_TYPE | ||||
60 | }; | ||||
61 | |||||
62 | // Compares two AddressLists to see how similar or different their addresses | ||||
63 | // are. (See |AddressListDeltaType| for details of exactly what's checked.) | ||||
64 | AddressListDeltaType FindAddressListDeltaType(const AddressList& a, | ||||
65 | const AddressList& b); | ||||
66 | |||||
[email protected] | c36f064 | 2009-09-09 01:10:50 | [diff] [blame] | 67 | } // namespace net |
68 | |||||
tfarina | 77021d6 | 2015-10-11 20:19:03 | [diff] [blame] | 69 | #endif // NET_DNS_DNS_UTIL_H_ |