Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: net/base/net_util.h

Issue 22538003: Add IP address handling to net::IsHostnameNonUnique (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made arrays const Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/net_util.cc » ('j') | net/base/net_util.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_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 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 int* port); 105 int* port);
106 106
107 // Returns a host:port string for the given URL. 107 // Returns a host:port string for the given URL.
108 NET_EXPORT std::string GetHostAndPort(const GURL& url); 108 NET_EXPORT std::string GetHostAndPort(const GURL& url);
109 109
110 // Returns a host[:port] string for the given URL, where the port is omitted 110 // Returns a host[:port] string for the given URL, where the port is omitted
111 // if it is the default for the URL's scheme. 111 // if it is the default for the URL's scheme.
112 NET_EXPORT_PRIVATE std::string GetHostAndOptionalPort(const GURL& url); 112 NET_EXPORT_PRIVATE std::string GetHostAndOptionalPort(const GURL& url);
113 113
114 // Returns true if |hostname| contains a non-registerable or non-assignable 114 // Returns true if |hostname| contains a non-registerable or non-assignable
115 // domain name (eg: a gTLD that has not been assigned by IANA) 115 // domain name (eg: a gTLD that has not been assigned by IANA) or an IP address
116 // 116 // that falls in an IANA-reserved range.
117 // TODO(rsleevi): http://crbug.com/119212 - Also match internal IP
118 // address ranges.
119 NET_EXPORT bool IsHostnameNonUnique(const std::string& hostname); 117 NET_EXPORT bool IsHostnameNonUnique(const std::string& hostname);
120 118
119 // Returns true if an IP address hostname is in a range reserved by the IANA.
120 // Works with both IPv4 and IPv6 addresses, but you must specify which type
121 // you're checking. It's the caller's responsibility to make sure that the
122 // host_addr is actually the type that's indicated by |ipv4|.
123 NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address, bool ipv4);
Ryan Sleevi 2013/08/08 19:49:31 If using |IPAddressNumber|, then we just use kIPv4
felt 2013/08/09 04:53:20 Done.
124
121 // Convenience struct for when you need a |struct sockaddr|. 125 // Convenience struct for when you need a |struct sockaddr|.
122 struct SockaddrStorage { 126 struct SockaddrStorage {
123 SockaddrStorage() : addr_len(sizeof(addr_storage)), 127 SockaddrStorage() : addr_len(sizeof(addr_storage)),
124 addr(reinterpret_cast<struct sockaddr*>(&addr_storage)) {} 128 addr(reinterpret_cast<struct sockaddr*>(&addr_storage)) {}
125 struct sockaddr_storage addr_storage; 129 struct sockaddr_storage addr_storage;
126 socklen_t addr_len; 130 socklen_t addr_len;
127 struct sockaddr* const addr; 131 struct sockaddr* const addr;
128 }; 132 };
129 133
130 // Extracts the IP address and port portions of a sockaddr. |port| is optional, 134 // Extracts the IP address and port portions of a sockaddr. |port| is optional,
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 WIFI_PHY_LAYER_PROTOCOL_UNKNOWN 537 WIFI_PHY_LAYER_PROTOCOL_UNKNOWN
534 }; 538 };
535 539
536 // Characterize the PHY mode of the currently associated access point. 540 // Characterize the PHY mode of the currently associated access point.
537 // Currently only available on OS_WIN. 541 // Currently only available on OS_WIN.
538 NET_EXPORT WifiPHYLayerProtocol GetWifiPHYLayerProtocol(); 542 NET_EXPORT WifiPHYLayerProtocol GetWifiPHYLayerProtocol();
539 543
540 } // namespace net 544 } // namespace net
541 545
542 #endif // NET_BASE_NET_UTIL_H_ 546 #endif // NET_BASE_NET_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/net_util.cc » ('j') | net/base/net_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698