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

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

Issue 6394004: Log source ip and port in NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK. Created 9 years, 11 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') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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
11 #ifdef OS_WIN 11 #if defined(OS_WIN)
12 #include <windows.h> 12 #include <windows.h>
13 #include <ws2tcpip.h>
14 #elif defined(OS_POSIX)
15 #include <sys/socket.h>
13 #endif 16 #endif
14 17
15 #include <string> 18 #include <string>
16 #include <set> 19 #include <set>
17 #include <vector> 20 #include <vector>
18 21
19 #include "base/basictypes.h" 22 #include "base/basictypes.h"
20 #include "base/string16.h" 23 #include "base/string16.h"
21 #include "net/base/escape.h" 24 #include "net/base/escape.h"
22 25
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Returns a host:port string for the given URL. 103 // Returns a host:port string for the given URL.
101 std::string GetHostAndPort(const GURL& url); 104 std::string GetHostAndPort(const GURL& url);
102 105
103 // Returns a host[:port] string for the given URL, where the port is omitted 106 // Returns a host[:port] string for the given URL, where the port is omitted
104 // if it is the default for the URL's scheme. 107 // if it is the default for the URL's scheme.
105 std::string GetHostAndOptionalPort(const GURL& url); 108 std::string GetHostAndOptionalPort(const GURL& url);
106 109
107 // Returns the string representation of an address, like "192.168.0.1". 110 // Returns the string representation of an address, like "192.168.0.1".
108 // Returns empty string on failure. 111 // Returns empty string on failure.
109 std::string NetAddressToString(const struct addrinfo* net_address); 112 std::string NetAddressToString(const struct addrinfo* net_address);
113 std::string NetAddressToString(const struct sockaddr* net_address,
114 socklen_t address_len);
110 115
111 // Same as NetAddressToString, but additionally includes the port number. For 116 // Same as NetAddressToString, but additionally includes the port number. For
112 // example: "192.168.0.1:99" or "[::1]:80". 117 // example: "192.168.0.1:99" or "[::1]:80".
113 std::string NetAddressToStringWithPort(const struct addrinfo* net_address); 118 std::string NetAddressToStringWithPort(const struct addrinfo* net_address);
119 std::string NetAddressToStringWithPort(const struct sockaddr* net_address,
120 socklen_t address_len);
114 121
115 // Returns the hostname of the current system. Returns empty string on failure. 122 // Returns the hostname of the current system. Returns empty string on failure.
116 std::string GetHostName(); 123 std::string GetHostName();
117 124
118 // Extracts the unescaped username/password from |url|, saving the results 125 // Extracts the unescaped username/password from |url|, saving the results
119 // into |*username| and |*password|. 126 // into |*username| and |*password|.
120 void GetIdentityFromURL(const GURL& url, 127 void GetIdentityFromURL(const GURL& url,
121 string16* username, 128 string16* username,
122 string16* password); 129 string16* password);
123 130
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // |ip_prefix| will be matched. 404 // |ip_prefix| will be matched.
398 // 405 //
399 // In cases when an IPv4 address is being compared to an IPv6 address prefix 406 // In cases when an IPv4 address is being compared to an IPv6 address prefix
400 // and vice versa, the IPv4 addresses will be converted to IPv4-mapped 407 // and vice versa, the IPv4 addresses will be converted to IPv4-mapped
401 // (IPv6) addresses. 408 // (IPv6) addresses.
402 bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number, 409 bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number,
403 const IPAddressNumber& ip_prefix, 410 const IPAddressNumber& ip_prefix,
404 size_t prefix_length_in_bits); 411 size_t prefix_length_in_bits);
405 412
406 // Returns the port field of the sockaddr in |info|. 413 // Returns the port field of the sockaddr in |info|.
407 uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); 414 const uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info);
415 uint16* GetPortFieldFromAddrinfo(struct addrinfo* info);
408 416
409 // Returns the value of |info's| port (in host byte ordering). 417 // Returns the value of |info's| port (in host byte ordering).
410 int GetPortFromAddrinfo(const struct addrinfo* info); 418 int GetPortFromAddrinfo(const struct addrinfo* info);
411 419
420 // Same except for struct sockaddr.
421 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address,
422 socklen_t address_len);
423 int GetPortFromSockaddr(const struct sockaddr* address,
424 socklen_t address_len);
425
412 } // namespace net 426 } // namespace net
413 427
414 #endif // NET_BASE_NET_UTIL_H_ 428 #endif // NET_BASE_NET_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698