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

Unified Diff: net/socket/socks_client_socket.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_EXPORT to *PortOnAddressList. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: net/socket/socks_client_socket.cc
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index 01983d916b67e018dc080e4a0c6905df1ba32624..66a2763367ab872622e8ccc5145b06b5d4e86b44 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -11,7 +11,6 @@
#include "net/base/io_buffer.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
-#include "net/base/sys_addrinfo.h"
#include "net/socket/client_socket_handle.h"
namespace net {
@@ -307,20 +306,18 @@ const std::string SOCKSClientSocket::BuildHandshakeWriteBuffer() const {
request.command = kSOCKSStreamRequest;
request.nw_port = base::HostToNet16(host_request_info_.port());
- const struct addrinfo* ai = addresses_.head();
- DCHECK(ai);
+ DCHECK(!addresses_.empty());
+ const IPEndPoint& ipe = addresses_.front();
// We disabled IPv6 results when resolving the hostname, so none of the
// results in the list will be IPv6.
// TODO(eroman): we only ever use the first address in the list. It would be
// more robust to try all the IP addresses we have before
// failing the connect attempt.
- CHECK_EQ(AF_INET, ai->ai_addr->sa_family);
- struct sockaddr_in* ipv4_host =
- reinterpret_cast<struct sockaddr_in*>(ai->ai_addr);
- memcpy(&request.ip, &ipv4_host->sin_addr, sizeof(ipv4_host->sin_addr));
+ CHECK_EQ(AF_INET, ipe.GetFamily());
+ memcpy(&request.ip, &ipe.address()[0], ipe.address().size());
eroman 2012/05/04 01:08:41 I'm not sure how I feel about this... The assumpti
szym 2012/05/04 02:38:29 Currently, IPAddressNumber stores data in same ord
eroman 2012/05/04 04:20:22 My paranoia stems from doing a memcpy() from a sou
- DVLOG(1) << "Resolved Host is : " << NetAddressToString(ai);
+ DVLOG(1) << "Resolved Host is : " << ipe.ToStringWithoutPort();
std::string handshake_data(reinterpret_cast<char*>(&request),
sizeof(request));

Powered by Google App Engine
This is Rietveld 408576698