OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 void TCPPort::PrepareAddress() { | 164 void TCPPort::PrepareAddress() { |
165 if (socket_) { | 165 if (socket_) { |
166 // If socket isn't bound yet the address will be added in | 166 // If socket isn't bound yet the address will be added in |
167 // OnAddressReady(). Socket may be in the CLOSED state if Listen() | 167 // OnAddressReady(). Socket may be in the CLOSED state if Listen() |
168 // failed, we still want to add the socket address. | 168 // failed, we still want to add the socket address. |
169 LOG(LS_VERBOSE) << "Preparing TCP address, current state: " | 169 LOG(LS_VERBOSE) << "Preparing TCP address, current state: " |
170 << socket_->GetState(); | 170 << socket_->GetState(); |
171 if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND || | 171 if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND || |
172 socket_->GetState() == rtc::AsyncPacketSocket::STATE_CLOSED) | 172 socket_->GetState() == rtc::AsyncPacketSocket::STATE_CLOSED) |
173 AddAddress(socket_->GetLocalAddress(), socket_->GetLocalAddress(), | 173 AddAddress(socket_->GetLocalAddress(), socket_->GetLocalAddress(), |
174 rtc::SocketAddress(), | 174 rtc::SocketAddress(), TCP_PROTOCOL_NAME, TCP_PROTOCOL_NAME, |
175 TCP_PROTOCOL_NAME, TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, | 175 TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, |
176 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); | 176 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); |
177 } else { | 177 } else { |
178 LOG_J(LS_INFO, this) << "Not listening due to firewall restrictions."; | 178 LOG_J(LS_INFO, this) << "Not listening due to firewall restrictions."; |
179 // Note: We still add the address, since otherwise the remote side won't | 179 // Note: We still add the address, since otherwise the remote side won't |
180 // recognize our incoming TCP connections. | 180 // recognize our incoming TCP connections. |
181 AddAddress(rtc::SocketAddress(ip(), 0), | 181 AddAddress(rtc::SocketAddress(ip(), 0), rtc::SocketAddress(ip(), 0), |
182 rtc::SocketAddress(ip(), 0), rtc::SocketAddress(), | 182 rtc::SocketAddress(), TCP_PROTOCOL_NAME, TCP_PROTOCOL_NAME, |
183 TCP_PROTOCOL_NAME, TCPTYPE_ACTIVE_STR, LOCAL_PORT_TYPE, | 183 TCPTYPE_ACTIVE_STR, LOCAL_PORT_TYPE, |
184 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); | 184 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 int TCPPort::SendTo(const void* data, size_t size, | 188 int TCPPort::SendTo(const void* data, size_t size, |
189 const rtc::SocketAddress& addr, | 189 const rtc::SocketAddress& addr, |
190 const rtc::PacketOptions& options, | 190 const rtc::PacketOptions& options, |
191 bool payload) { | 191 bool payload) { |
192 rtc::AsyncPacketSocket * socket = NULL; | 192 rtc::AsyncPacketSocket * socket = NULL; |
193 TCPConnection* conn = static_cast<TCPConnection*>(GetConnection(addr)); | 193 TCPConnection* conn = static_cast<TCPConnection*>(GetConnection(addr)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 const rtc::PacketTime& packet_time) { | 278 const rtc::PacketTime& packet_time) { |
279 Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); | 279 Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); |
280 } | 280 } |
281 | 281 |
282 void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { | 282 void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { |
283 Port::OnReadyToSend(); | 283 Port::OnReadyToSend(); |
284 } | 284 } |
285 | 285 |
286 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, | 286 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, |
287 const rtc::SocketAddress& address) { | 287 const rtc::SocketAddress& address) { |
288 AddAddress(address, address, rtc::SocketAddress(), | 288 AddAddress(address, address, rtc::SocketAddress(), TCP_PROTOCOL_NAME, |
289 TCP_PROTOCOL_NAME, TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, | 289 TCP_PROTOCOL_NAME, TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, |
290 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); | 290 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); |
291 } | 291 } |
292 | 292 |
293 TCPConnection::TCPConnection(TCPPort* port, | 293 TCPConnection::TCPConnection(TCPPort* port, |
294 const Candidate& candidate, | 294 const Candidate& candidate, |
295 rtc::AsyncPacketSocket* socket) | 295 rtc::AsyncPacketSocket* socket) |
296 : Connection(port, 0, candidate), | 296 : Connection(port, 0, candidate), |
297 socket_(socket), | 297 socket_(socket), |
298 error_(0), | 298 error_(0), |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { | 468 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { |
469 if (outgoing_) { | 469 if (outgoing_) { |
470 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); | 470 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); |
471 } | 471 } |
472 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); | 472 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); |
473 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); | 473 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); |
474 socket->SignalClose.connect(this, &TCPConnection::OnClose); | 474 socket->SignalClose.connect(this, &TCPConnection::OnClose); |
475 } | 475 } |
476 | 476 |
477 } // namespace cricket | 477 } // namespace cricket |
OLD | NEW |