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_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 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 namespace url { | 39 namespace url { |
40 struct CanonHostInfo; | 40 struct CanonHostInfo; |
41 struct Parsed; | 41 struct Parsed; |
42 } | 42 } |
43 | 43 |
44 namespace net { | 44 namespace net { |
45 | 45 |
46 // Used by FormatUrl to specify handling of certain parts of the url. | 46 // Used by FormatUrl to specify handling of certain parts of the url. |
47 typedef uint32 FormatUrlType; | 47 typedef uint32_t FormatUrlType; |
48 typedef uint32 FormatUrlTypes; | 48 typedef uint32_t FormatUrlTypes; |
49 | 49 |
50 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
51 // Bluetooth address size. Windows Bluetooth is supported via winsock. | 51 // Bluetooth address size. Windows Bluetooth is supported via winsock. |
52 static const size_t kBluetoothAddressSize = 6; | 52 static const size_t kBluetoothAddressSize = 6; |
53 #endif | 53 #endif |
54 | 54 |
55 // Nothing is ommitted. | 55 // Nothing is ommitted. |
56 NET_EXPORT extern const FormatUrlType kFormatUrlOmitNothing; | 56 NET_EXPORT extern const FormatUrlType kFormatUrlOmitNothing; |
57 | 57 |
58 // If set, any username and password are removed. | 58 // If set, any username and password are removed. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 socklen_t addr_len; | 114 socklen_t addr_len; |
115 struct sockaddr* const addr; | 115 struct sockaddr* const addr; |
116 }; | 116 }; |
117 | 117 |
118 // Extracts the IP address and port portions of a sockaddr. |port| is optional, | 118 // Extracts the IP address and port portions of a sockaddr. |port| is optional, |
119 // and will not be filled in if NULL. | 119 // and will not be filled in if NULL. |
120 bool GetIPAddressFromSockAddr(const struct sockaddr* sock_addr, | 120 bool GetIPAddressFromSockAddr(const struct sockaddr* sock_addr, |
121 socklen_t sock_addr_len, | 121 socklen_t sock_addr_len, |
122 const unsigned char** address, | 122 const unsigned char** address, |
123 size_t* address_len, | 123 size_t* address_len, |
124 uint16* port); | 124 uint16_t* port); |
125 | 125 |
126 // Same as IPAddressToString() but for a sockaddr. This output will not include | 126 // Same as IPAddressToString() but for a sockaddr. This output will not include |
127 // the IPv6 scope ID. | 127 // the IPv6 scope ID. |
128 NET_EXPORT std::string NetAddressToString(const struct sockaddr* sa, | 128 NET_EXPORT std::string NetAddressToString(const struct sockaddr* sa, |
129 socklen_t sock_addr_len); | 129 socklen_t sock_addr_len); |
130 | 130 |
131 // Same as IPAddressToStringWithPort() but for a sockaddr. This output will not | 131 // Same as IPAddressToStringWithPort() but for a sockaddr. This output will not |
132 // include the IPv6 scope ID. | 132 // include the IPv6 scope ID. |
133 NET_EXPORT std::string NetAddressToStringWithPort(const struct sockaddr* sa, | 133 NET_EXPORT std::string NetAddressToStringWithPort(const struct sockaddr* sa, |
134 socklen_t sock_addr_len); | 134 socklen_t sock_addr_len); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // |addRow|. | 197 // |addRow|. |
198 // | 198 // |
199 // |name| is the file name to be displayed. |raw_bytes| will be used | 199 // |name| is the file name to be displayed. |raw_bytes| will be used |
200 // as the actual target of the link (so for example, ftp links should use | 200 // as the actual target of the link (so for example, ftp links should use |
201 // server's encoding). If |raw_bytes| is an empty string, UTF-8 encoded |name| | 201 // server's encoding). If |raw_bytes| is an empty string, UTF-8 encoded |name| |
202 // will be used. | 202 // will be used. |
203 // | 203 // |
204 // Both |name| and |raw_bytes| are escaped internally. | 204 // Both |name| and |raw_bytes| are escaped internally. |
205 NET_EXPORT std::string GetDirectoryListingEntry(const base::string16& name, | 205 NET_EXPORT std::string GetDirectoryListingEntry(const base::string16& name, |
206 const std::string& raw_bytes, | 206 const std::string& raw_bytes, |
207 bool is_dir, int64 size, | 207 bool is_dir, |
| 208 int64_t size, |
208 base::Time modified); | 209 base::Time modified); |
209 | 210 |
210 // If text starts with "www." it is removed, otherwise text is returned | 211 // If text starts with "www." it is removed, otherwise text is returned |
211 // unmodified. | 212 // unmodified. |
212 NET_EXPORT base::string16 StripWWW(const base::string16& text); | 213 NET_EXPORT base::string16 StripWWW(const base::string16& text); |
213 | 214 |
214 // Runs |url|'s host through StripWWW(). |url| must be valid. | 215 // Runs |url|'s host through StripWWW(). |url| must be valid. |
215 NET_EXPORT base::string16 StripWWWFromHost(const GURL& url); | 216 NET_EXPORT base::string16 StripWWWFromHost(const GURL& url); |
216 | 217 |
217 // Checks if |port| is in the valid range (0 to 65535, though 0 is technically | 218 // Checks if |port| is in the valid range (0 to 65535, though 0 is technically |
218 // reserved). Should be used before casting a port to a uint16. | 219 // reserved). Should be used before casting a port to a uint16_t. |
219 NET_EXPORT bool IsPortValid(int port); | 220 NET_EXPORT bool IsPortValid(int port); |
220 | 221 |
221 // Checks |port| against a list of ports which are restricted by default. | 222 // Checks |port| against a list of ports which are restricted by default. |
222 // Returns true if |port| is allowed, false if it is restricted. | 223 // Returns true if |port| is allowed, false if it is restricted. |
223 NET_EXPORT bool IsPortAllowedByDefault(int port); | 224 NET_EXPORT bool IsPortAllowedByDefault(int port); |
224 | 225 |
225 // Checks |port| against a list of ports which are restricted by the FTP | 226 // Checks |port| against a list of ports which are restricted by the FTP |
226 // protocol. Returns true if |port| is allowed, false if it is restricted. | 227 // protocol. Returns true if |port| is allowed, false if it is restricted. |
227 NET_EXPORT_PRIVATE bool IsPortAllowedByFtp(int port); | 228 NET_EXPORT_PRIVATE bool IsPortAllowedByFtp(int port); |
228 | 229 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 bool HaveOnlyLoopbackAddresses(); | 336 bool HaveOnlyLoopbackAddresses(); |
336 | 337 |
337 // Returns AddressFamily of the address. | 338 // Returns AddressFamily of the address. |
338 NET_EXPORT_PRIVATE AddressFamily GetAddressFamily( | 339 NET_EXPORT_PRIVATE AddressFamily GetAddressFamily( |
339 const IPAddressNumber& address); | 340 const IPAddressNumber& address); |
340 | 341 |
341 // Maps the given AddressFamily to either AF_INET, AF_INET6 or AF_UNSPEC. | 342 // Maps the given AddressFamily to either AF_INET, AF_INET6 or AF_UNSPEC. |
342 NET_EXPORT_PRIVATE int ConvertAddressFamily(AddressFamily address_family); | 343 NET_EXPORT_PRIVATE int ConvertAddressFamily(AddressFamily address_family); |
343 | 344 |
344 // Retuns the port field of the |sockaddr|. | 345 // Retuns the port field of the |sockaddr|. |
345 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, | 346 const uint16_t* GetPortFieldFromSockaddr(const struct sockaddr* address, |
346 socklen_t address_len); | 347 socklen_t address_len); |
347 // Returns the value of port in |sockaddr| (in host byte ordering). | 348 // Returns the value of port in |sockaddr| (in host byte ordering). |
348 NET_EXPORT_PRIVATE int GetPortFromSockaddr(const struct sockaddr* address, | 349 NET_EXPORT_PRIVATE int GetPortFromSockaddr(const struct sockaddr* address, |
349 socklen_t address_len); | 350 socklen_t address_len); |
350 | 351 |
351 // Returns true if |host| is one of the names (e.g. "localhost") or IP | 352 // Returns true if |host| is one of the names (e.g. "localhost") or IP |
352 // addresses (IPv4 127.0.0.0/8 or IPv6 ::1) that indicate a loopback. | 353 // addresses (IPv4 127.0.0.0/8 or IPv6 ::1) that indicate a loopback. |
353 // | 354 // |
354 // Note that this function does not check for IP addresses other than | 355 // Note that this function does not check for IP addresses other than |
355 // the above, although other IP addresses may point to the local | 356 // the above, although other IP addresses may point to the local |
356 // machine. | 357 // machine. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 DSCP_CS5 = 40, // Video | 407 DSCP_CS5 = 40, // Video |
407 DSCP_EF = 46, // Voice | 408 DSCP_EF = 46, // Voice |
408 DSCP_CS6 = 48, // Voice | 409 DSCP_CS6 = 48, // Voice |
409 DSCP_CS7 = 56, // Control messages | 410 DSCP_CS7 = 56, // Control messages |
410 DSCP_LAST = DSCP_CS7 | 411 DSCP_LAST = DSCP_CS7 |
411 }; | 412 }; |
412 | 413 |
413 } // namespace net | 414 } // namespace net |
414 | 415 |
415 #endif // NET_BASE_NET_UTIL_H_ | 416 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |