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

Side by Side Diff: net/socket/socks_client_socket.cc

Issue 9716020: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/socks5_client_socket_unittest.cc ('k') | net/socket/web_socket_server_socket.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) 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 #include "net/socket/socks_client_socket.h" 5 #include "net/socket/socks_client_socket.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/sys_byteorder.h"
10 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
11 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 #include "net/base/sys_addrinfo.h" 14 #include "net/base/sys_addrinfo.h"
14 #include "net/socket/client_socket_handle.h" 15 #include "net/socket/client_socket_handle.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 // Every SOCKS server requests a user-id from the client. It is optional 19 // Every SOCKS server requests a user-id from the client. It is optional
19 // and we send an empty string. 20 // and we send an empty string.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 next_state_ = STATE_HANDSHAKE_WRITE; 292 next_state_ = STATE_HANDSHAKE_WRITE;
292 return OK; 293 return OK;
293 } 294 }
294 295
295 // Builds the buffer that is to be sent to the server. 296 // Builds the buffer that is to be sent to the server.
296 const std::string SOCKSClientSocket::BuildHandshakeWriteBuffer() const { 297 const std::string SOCKSClientSocket::BuildHandshakeWriteBuffer() const {
297 SOCKS4ServerRequest request; 298 SOCKS4ServerRequest request;
298 request.version = kSOCKSVersion4; 299 request.version = kSOCKSVersion4;
299 request.command = kSOCKSStreamRequest; 300 request.command = kSOCKSStreamRequest;
300 request.nw_port = htons(host_request_info_.port()); 301 request.nw_port = base::HostToNet16(host_request_info_.port());
301 302
302 const struct addrinfo* ai = addresses_.head(); 303 const struct addrinfo* ai = addresses_.head();
303 DCHECK(ai); 304 DCHECK(ai);
304 305
305 // We disabled IPv6 results when resolving the hostname, so none of the 306 // We disabled IPv6 results when resolving the hostname, so none of the
306 // results in the list will be IPv6. 307 // results in the list will be IPv6.
307 // TODO(eroman): we only ever use the first address in the list. It would be 308 // TODO(eroman): we only ever use the first address in the list. It would be
308 // more robust to try all the IP addresses we have before 309 // more robust to try all the IP addresses we have before
309 // failing the connect attempt. 310 // failing the connect attempt.
310 CHECK_EQ(AF_INET, ai->ai_addr->sa_family); 311 CHECK_EQ(AF_INET, ai->ai_addr->sa_family);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 428
428 int SOCKSClientSocket::GetPeerAddress(AddressList* address) const { 429 int SOCKSClientSocket::GetPeerAddress(AddressList* address) const {
429 return transport_->socket()->GetPeerAddress(address); 430 return transport_->socket()->GetPeerAddress(address);
430 } 431 }
431 432
432 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { 433 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const {
433 return transport_->socket()->GetLocalAddress(address); 434 return transport_->socket()->GetLocalAddress(address);
434 } 435 }
435 436
436 } // namespace net 437 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socks5_client_socket_unittest.cc ('k') | net/socket/web_socket_server_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698