Skip to content

Commit

Permalink
fixed issue 128383 - replace GetPeerAddress(AddressList* address) wit…
Browse files Browse the repository at this point in the history
…h GetPeerAddress(IPEndPoint* address)

R=szym@chromium.org
BUG=128383
TEST=try bot


Review URL: https://chromiumcodereview.appspot.com/10491007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141125 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
zhaoqin@chromium.org committed Jun 8, 2012
1 parent dc67e1c commit a352869
Show file tree
Hide file tree
Showing 58 changed files with 107 additions and 114 deletions.
5 changes: 2 additions & 3 deletions content/browser/renderer_host/p2p/socket_host_tcp_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,12 @@ void P2PSocketHostTcpServer::HandleAcceptResult(int result) {
return;
}

net::AddressList addr_list;
if (accept_socket_->GetPeerAddress(&addr_list) != net::OK) {
net::IPEndPoint address;
if (accept_socket_->GetPeerAddress(&address) != net::OK) {
LOG(ERROR) << "Failed to get address of an accepted socket.";
accept_socket_.reset();
return;
}
const net::IPEndPoint& address = addr_list.front();
AcceptedSocketsMap::iterator it = accepted_sockets_.find(address);
if (it != accepted_sockets_.end())
delete it->second;
Expand Down
7 changes: 3 additions & 4 deletions content/browser/renderer_host/p2p/socket_host_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FakeSocket : public net::StreamSocket {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(net::IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE;
virtual const net::BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE;
Expand Down Expand Up @@ -180,9 +180,8 @@ bool FakeSocket::IsConnectedAndIdle() const {
return false;
}

int FakeSocket::GetPeerAddress(net::AddressList* address) const {
*address = net::AddressList::CreateFromIPAddress(peer_address_.address(),
peer_address_.port());
int FakeSocket::GetPeerAddress(net::IPEndPoint* address) const {
*address = peer_address_;
return net::OK;
}

Expand Down
14 changes: 7 additions & 7 deletions content/browser/renderer_host/pepper_tcp_server_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ void PepperTCPServerSocket::OnAcceptCompleted(
} else {
scoped_ptr<net::StreamSocket> socket(socket_buffer_.release());

net::IPEndPoint ip_end_point;
net::AddressList address_list;
net::IPEndPoint ip_end_point_local;
net::IPEndPoint ip_end_point_remote;
PP_NetAddress_Private local_addr =
NetAddressPrivateImpl::kInvalidNetAddress;
PP_NetAddress_Private remote_addr =
NetAddressPrivateImpl::kInvalidNetAddress;

if (socket->GetLocalAddress(&ip_end_point) != net::OK ||
!NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point,
if (socket->GetLocalAddress(&ip_end_point_local) != net::OK ||
!NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_local,
&local_addr) ||
socket->GetPeerAddress(&address_list) != net::OK ||
!NetAddressPrivateImpl::AddressListToNetAddress(address_list,
&remote_addr)) {
socket->GetPeerAddress(&ip_end_point_remote) != net::OK ||
!NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_remote,
&remote_addr)) {
SendAcceptACKError();
} else {
uint32 accepted_socket_id =
Expand Down
14 changes: 7 additions & 7 deletions content/browser/renderer_host/pepper_tcp_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,19 @@ void PepperTCPSocket::OnConnectCompleted(int result) {
SendConnectACKError();
connection_state_ = BEFORE_CONNECT;
} else {
net::IPEndPoint ip_end_point;
net::AddressList address_list;
net::IPEndPoint ip_end_point_local;
net::IPEndPoint ip_end_point_remote;
PP_NetAddress_Private local_addr =
NetAddressPrivateImpl::kInvalidNetAddress;
PP_NetAddress_Private remote_addr =
NetAddressPrivateImpl::kInvalidNetAddress;

if (socket_->GetLocalAddress(&ip_end_point) != net::OK ||
!NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point,
if (socket_->GetLocalAddress(&ip_end_point_local) != net::OK ||
!NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_local,
&local_addr) ||
socket_->GetPeerAddress(&address_list) != net::OK ||
!NetAddressPrivateImpl::AddressListToNetAddress(address_list,
&remote_addr)) {
socket_->GetPeerAddress(&ip_end_point_remote) != net::OK ||
!NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_remote,
&remote_addr)) {
SendConnectACKError();
connection_state_ = BEFORE_CONNECT;
} else {
Expand Down
6 changes: 3 additions & 3 deletions jingle/glue/pseudotcp_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,13 @@ bool PseudoTcpAdapter::IsConnectedAndIdle() const {
return false;
}

int PseudoTcpAdapter::GetPeerAddress(net::AddressList* address) const {
int PseudoTcpAdapter::GetPeerAddress(net::IPEndPoint* address) const {
DCHECK(CalledOnValidThread());

// We don't have a meaningful peer address, but we can't return an
// error, so we return a INADDR_ANY instead.
net::IPAddressNumber ip_address(4);
*address = net::AddressList::CreateFromIPAddress(ip_address, 0);
net::IPAddressNumber ip_address(net::kIPv4AddressSize);
*address = net::IPEndPoint(ip_address, 0);
return net::OK;
}

Expand Down
2 changes: 1 addition & 1 deletion jingle/glue/pseudotcp_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(net::IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE;
virtual const net::BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion jingle/notifier/base/fake_ssl_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ bool FakeSSLClientSocket::IsConnectedAndIdle() const {
return handshake_completed_ && transport_socket_->IsConnectedAndIdle();
}

int FakeSSLClientSocket::GetPeerAddress(net::AddressList* address) const {
int FakeSSLClientSocket::GetPeerAddress(net::IPEndPoint* address) const {
return transport_socket_->GetPeerAddress(address);
}

Expand Down
2 changes: 1 addition & 1 deletion jingle/notifier/base/fake_ssl_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FakeSSLClientSocket : public net::StreamSocket {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(net::IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE;
virtual const net::BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE;
Expand Down
8 changes: 4 additions & 4 deletions jingle/notifier/base/fake_ssl_client_socket_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MockClientSocket : public net::StreamSocket {
MOCK_METHOD0(Disconnect, void());
MOCK_CONST_METHOD0(IsConnected, bool());
MOCK_CONST_METHOD0(IsConnectedAndIdle, bool());
MOCK_CONST_METHOD1(GetPeerAddress, int(net::AddressList*));
MOCK_CONST_METHOD1(GetPeerAddress, int(net::IPEndPoint*));
MOCK_CONST_METHOD1(GetLocalAddress, int(net::IPEndPoint*));
MOCK_CONST_METHOD0(NetLog, const net::BoundNetLog&());
MOCK_METHOD0(SetSubresourceSpeculation, void());
Expand Down Expand Up @@ -270,12 +270,12 @@ TEST_F(FakeSSLClientSocketTest, PassThroughMethods) {
MockClientSocket* mock_client_socket = new MockClientSocket();
const int kReceiveBufferSize = 10;
const int kSendBufferSize = 20;
net::AddressList address_list;
net::IPEndPoint ip_endpoint(net::IPAddressNumber(net::kIPv4AddressSize), 80);
const int kPeerAddress = 30;
net::BoundNetLog net_log;
EXPECT_CALL(*mock_client_socket, SetReceiveBufferSize(kReceiveBufferSize));
EXPECT_CALL(*mock_client_socket, SetSendBufferSize(kSendBufferSize));
EXPECT_CALL(*mock_client_socket, GetPeerAddress(&address_list)).
EXPECT_CALL(*mock_client_socket, GetPeerAddress(&ip_endpoint)).
WillOnce(Return(kPeerAddress));
EXPECT_CALL(*mock_client_socket, NetLog()).WillOnce(ReturnRef(net_log));
EXPECT_CALL(*mock_client_socket, SetSubresourceSpeculation());
Expand All @@ -286,7 +286,7 @@ TEST_F(FakeSSLClientSocketTest, PassThroughMethods) {
fake_ssl_client_socket.SetReceiveBufferSize(kReceiveBufferSize);
fake_ssl_client_socket.SetSendBufferSize(kSendBufferSize);
EXPECT_EQ(kPeerAddress,
fake_ssl_client_socket.GetPeerAddress(&address_list));
fake_ssl_client_socket.GetPeerAddress(&ip_endpoint));
EXPECT_EQ(&net_log, &fake_ssl_client_socket.NetLog());
fake_ssl_client_socket.SetSubresourceSpeculation();
fake_ssl_client_socket.SetOmniboxSpeculation();
Expand Down
2 changes: 1 addition & 1 deletion jingle/notifier/base/proxy_resolving_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ bool ProxyResolvingClientSocket::IsConnectedAndIdle() const {
}

int ProxyResolvingClientSocket::GetPeerAddress(
net::AddressList* address) const {
net::IPEndPoint* address) const {
if (transport_.get() && transport_->socket())
return transport_->socket()->GetPeerAddress(address);
NOTREACHED();
Expand Down
2 changes: 1 addition & 1 deletion jingle/notifier/base/proxy_resolving_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ProxyResolvingClientSocket : public net::StreamSocket {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(net::IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE;
virtual const net::BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE;
Expand Down
4 changes: 2 additions & 2 deletions net/curvecp/curvecp_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ bool CurveCPClientSocket::IsConnectedAndIdle() const {
return false;
}

int CurveCPClientSocket::GetPeerAddress(AddressList* address) const {
int CurveCPClientSocket::GetPeerAddress(IPEndPoint* address) const {
IPEndPoint endpoint;
int rv = packetizer_.GetPeerAddress(&endpoint);
if (rv < 0)
return rv;
*address = AddressList(endpoint);
*address = endpoint;
return OK;
}

Expand Down
2 changes: 1 addition & 1 deletion net/curvecp/curvecp_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CurveCPClientSocket : public StreamSocket {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
virtual const BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE;
Expand Down
11 changes: 6 additions & 5 deletions net/ftp/ftp_network_transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,10 @@ int FtpNetworkTransaction::DoCtrlConnect() {
int FtpNetworkTransaction::DoCtrlConnectComplete(int result) {
if (result == OK) {
// Put the peer's IP address and port into the response.
AddressList address;
result = ctrl_socket_->GetPeerAddress(&address);
IPEndPoint ip_endpoint;
result = ctrl_socket_->GetPeerAddress(&ip_endpoint);
if (result == OK) {
response_.socket_address = HostPortPair::FromIPEndPoint(address.front());
response_.socket_address = HostPortPair::FromIPEndPoint(ip_endpoint);
next_state_ = STATE_CTRL_READ;
}
}
Expand Down Expand Up @@ -1188,14 +1188,15 @@ int FtpNetworkTransaction::ProcessResponseQUIT(

int FtpNetworkTransaction::DoDataConnect() {
next_state_ = STATE_DATA_CONNECT_COMPLETE;
IPEndPoint ip_endpoint;
AddressList data_address;
// Connect to the same host as the control socket to prevent PASV port
// scanning attacks.
int rv = ctrl_socket_->GetPeerAddress(&data_address);
int rv = ctrl_socket_->GetPeerAddress(&ip_endpoint);
if (rv != OK)
return Stop(rv);
data_address = AddressList::CreateFromIPAddress(
data_address.front().address(), data_connection_port_);
ip_endpoint.address(), data_connection_port_);
data_socket_.reset(socket_factory_->CreateTransportClientSocket(
data_address, net_log_.net_log(), net_log_.source()));
return data_socket_->Connect(io_callback_);
Expand Down
2 changes: 1 addition & 1 deletion net/http/http_proxy_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ bool HttpProxyClientSocket::SetSendBufferSize(int32 size) {
return transport_->socket()->SetSendBufferSize(size);
}

int HttpProxyClientSocket::GetPeerAddress(AddressList* address) const {
int HttpProxyClientSocket::GetPeerAddress(IPEndPoint* address) const {
return transport_->socket()->GetPeerAddress(address);
}

Expand Down
2 changes: 1 addition & 1 deletion net/http/http_proxy_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class HttpProxyClientSocket : public ProxyClientSocket {
const CompletionCallback& callback) OVERRIDE;
virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
virtual bool SetSendBufferSize(int32 size) OVERRIDE;
virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;

private:
Expand Down
6 changes: 3 additions & 3 deletions net/http/http_stream_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ int HttpStreamParser::SendRequest(const std::string& request_line,
response_ = response;

// Put the peer's IP address and port into the response.
AddressList address;
int result = connection_->socket()->GetPeerAddress(&address);
IPEndPoint ip_endpoint;
int result = connection_->socket()->GetPeerAddress(&ip_endpoint);
if (result != OK)
return result;
response_->socket_address = HostPortPair::FromIPEndPoint(address.front());
response_->socket_address = HostPortPair::FromIPEndPoint(ip_endpoint);

std::string request = request_line + headers.ToString();
request_body_.reset(request_body);
Expand Down
2 changes: 1 addition & 1 deletion net/socket/buffered_write_stream_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool BufferedWriteStreamSocket::IsConnectedAndIdle() const {
return wrapped_socket_->IsConnectedAndIdle();
}

int BufferedWriteStreamSocket::GetPeerAddress(AddressList* address) const {
int BufferedWriteStreamSocket::GetPeerAddress(IPEndPoint* address) const {
return wrapped_socket_->GetPeerAddress(address);
}

Expand Down
2 changes: 1 addition & 1 deletion net/socket/buffered_write_stream_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NET_EXPORT_PRIVATE BufferedWriteStreamSocket : public StreamSocket {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
virtual const BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion net/socket/client_socket_pool_base_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class MockClientSocket : public StreamSocket {
virtual bool IsConnected() const { return connected_; }
virtual bool IsConnectedAndIdle() const { return connected_; }

virtual int GetPeerAddress(AddressList* /* address */) const {
virtual int GetPeerAddress(IPEndPoint* /* address */) const {
return ERR_UNEXPECTED;
}

Expand Down
6 changes: 3 additions & 3 deletions net/socket/socket_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,11 @@ bool MockClientSocket::IsConnectedAndIdle() const {
return connected_;
}

int MockClientSocket::GetPeerAddress(AddressList* address) const {
int MockClientSocket::GetPeerAddress(IPEndPoint* address) const {
IPAddressNumber ip;
bool rv = ParseIPLiteralToNumber("192.0.2.33", &ip);
CHECK(rv);
*address = AddressList::CreateFromIPAddress(ip, 0);
*address = IPEndPoint(ip, 0);
return OK;
}

Expand Down Expand Up @@ -824,7 +824,7 @@ bool MockTCPClientSocket::IsConnectedAndIdle() const {
return IsConnected();
}

int MockTCPClientSocket::GetPeerAddress(AddressList* address) const {
int MockTCPClientSocket::GetPeerAddress(IPEndPoint* address) const {
if (!IsConnected())
return ERR_SOCKET_NOT_CONNECTED;
return MockClientSocket::GetPeerAddress(address);
Expand Down
4 changes: 2 additions & 2 deletions net/socket/socket_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ class MockClientSocket : public SSLClientSocket {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
virtual const BoundNetLog& NetLog() const OVERRIDE;
virtual void SetSubresourceSpeculation() OVERRIDE {}
Expand Down Expand Up @@ -640,7 +640,7 @@ class MockTCPClientSocket : public MockClientSocket, public AsyncSocket {
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
virtual bool IsConnectedAndIdle() const OVERRIDE;
virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual bool WasEverUsed() const OVERRIDE;
virtual bool UsingTCPFastOpen() const OVERRIDE;
virtual int64 NumBytesRead() const OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion net/socket/socks5_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ int SOCKS5ClientSocket::DoHandshakeReadComplete(int result) {
return OK;
}

int SOCKS5ClientSocket::GetPeerAddress(AddressList* address) const {
int SOCKS5ClientSocket::GetPeerAddress(IPEndPoint* address) const {
return transport_->socket()->GetPeerAddress(address);
}

Expand Down
2 changes: 1 addition & 1 deletion net/socket/socks5_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NET_EXPORT_PRIVATE SOCKS5ClientSocket : public StreamSocket {
virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
virtual bool SetSendBufferSize(int32 size) OVERRIDE;

virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;

private:
Expand Down
2 changes: 1 addition & 1 deletion net/socket/socks_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ int SOCKSClientSocket::DoHandshakeReadComplete(int result) {
// Note: we ignore the last 6 bytes as specified by the SOCKS protocol
}

int SOCKSClientSocket::GetPeerAddress(AddressList* address) const {
int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const {
return transport_->socket()->GetPeerAddress(address);
}

Expand Down
2 changes: 1 addition & 1 deletion net/socket/socks_client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket {
virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
virtual bool SetSendBufferSize(int32 size) OVERRIDE;

virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;

private:
Expand Down
Loading

0 comments on commit a352869

Please sign in to comment.