OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_NET_UTIL_H_ | 5 #ifndef NET_BASE_NET_UTIL_H_ |
6 #define NET_BASE_NET_UTIL_H_ | 6 #define NET_BASE_NET_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 // Canonicalizes |host| and returns it. Also fills |host_info| with | 200 // Canonicalizes |host| and returns it. Also fills |host_info| with |
201 // IP address information. |host_info| must not be NULL. | 201 // IP address information. |host_info| must not be NULL. |
202 NET_API std::string CanonicalizeHost(const std::string& host, | 202 NET_API std::string CanonicalizeHost(const std::string& host, |
203 url_canon::CanonHostInfo* host_info); | 203 url_canon::CanonHostInfo* host_info); |
204 | 204 |
205 // Returns true if |host| is not an IP address and is compliant with a set of | 205 // Returns true if |host| is not an IP address and is compliant with a set of |
206 // rules based on RFC 1738 and tweaked to be compatible with the real world. | 206 // rules based on RFC 1738 and tweaked to be compatible with the real world. |
207 // The rules are: | 207 // The rules are: |
208 // * One or more components separated by '.' | 208 // * One or more components separated by '.' |
209 // * Each component begins and ends with an alphanumeric character | 209 // * Each component begins with an alphanumeric character or '-' |
210 // * Each component contains only alphanumeric characters and '-' or '_' | 210 // * Each component contains only alphanumeric characters and '-' or '_' |
211 // * The last component does not begin with a digit | 211 // * Each component ends with an alphanumeric character |
| 212 // * The last component begins with an alphabetic character |
212 // * Optional trailing dot after last component (means "treat as FQDN") | 213 // * Optional trailing dot after last component (means "treat as FQDN") |
213 // If |desired_tld| is non-NULL, the host will only be considered invalid if | 214 // If |desired_tld| is non-NULL, the host will only be considered invalid if |
214 // appending it as a trailing component still results in an invalid host. This | 215 // appending it as a trailing component still results in an invalid host. This |
215 // helps us avoid marking as "invalid" user attempts to open "www.401k.com" by | 216 // helps us avoid marking as "invalid" user attempts to open "www.401k.com" by |
216 // typing 4-0-1-k-<ctrl>+<enter>. | 217 // typing 4-0-1-k-<ctrl>+<enter>. |
217 // | 218 // |
218 // NOTE: You should only pass in hosts that have been returned from | 219 // NOTE: You should only pass in hosts that have been returned from |
219 // CanonicalizeHost(), or you may not get accurate results. | 220 // CanonicalizeHost(), or you may not get accurate results. |
220 NET_API bool IsCanonicalizedHostCompliant(const std::string& host, | 221 NET_API bool IsCanonicalizedHostCompliant(const std::string& host, |
221 const std::string& desired_tld); | 222 const std::string& desired_tld); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 | 458 |
458 // Returns list of network interfaces except loopback interface. If an | 459 // Returns list of network interfaces except loopback interface. If an |
459 // interface has more than one address, a separate entry is added to | 460 // interface has more than one address, a separate entry is added to |
460 // the list for each address. | 461 // the list for each address. |
461 // Can be called only on a thread that allows IO. | 462 // Can be called only on a thread that allows IO. |
462 NET_API bool GetNetworkList(NetworkInterfaceList* networks); | 463 NET_API bool GetNetworkList(NetworkInterfaceList* networks); |
463 | 464 |
464 } // namespace net | 465 } // namespace net |
465 | 466 |
466 #endif // NET_BASE_NET_UTIL_H_ | 467 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |