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, "", |
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, "", TCPTYPE_ACTIVE_STR, |
183 TCP_PROTOCOL_NAME, TCPTYPE_ACTIVE_STR, LOCAL_PORT_TYPE, | 183 LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); |
184 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); | |
185 } | 184 } |
186 } | 185 } |
187 | 186 |
188 int TCPPort::SendTo(const void* data, size_t size, | 187 int TCPPort::SendTo(const void* data, size_t size, |
189 const rtc::SocketAddress& addr, | 188 const rtc::SocketAddress& addr, |
190 const rtc::PacketOptions& options, | 189 const rtc::PacketOptions& options, |
191 bool payload) { | 190 bool payload) { |
192 rtc::AsyncPacketSocket * socket = NULL; | 191 rtc::AsyncPacketSocket * socket = NULL; |
193 TCPConnection* conn = static_cast<TCPConnection*>(GetConnection(addr)); | 192 TCPConnection* conn = static_cast<TCPConnection*>(GetConnection(addr)); |
194 | 193 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 const rtc::PacketTime& packet_time) { | 277 const rtc::PacketTime& packet_time) { |
279 Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); | 278 Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); |
280 } | 279 } |
281 | 280 |
282 void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { | 281 void TCPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { |
283 Port::OnReadyToSend(); | 282 Port::OnReadyToSend(); |
284 } | 283 } |
285 | 284 |
286 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, | 285 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, |
287 const rtc::SocketAddress& address) { | 286 const rtc::SocketAddress& address) { |
288 AddAddress(address, address, rtc::SocketAddress(), | 287 AddAddress(address, address, rtc::SocketAddress(), TCP_PROTOCOL_NAME, "", |
289 TCP_PROTOCOL_NAME, TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, | 288 TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST_TCP, |
290 ICE_TYPE_PREFERENCE_HOST_TCP, 0, true); | 289 0, true); |
291 } | 290 } |
292 | 291 |
293 TCPConnection::TCPConnection(TCPPort* port, | 292 TCPConnection::TCPConnection(TCPPort* port, |
294 const Candidate& candidate, | 293 const Candidate& candidate, |
295 rtc::AsyncPacketSocket* socket) | 294 rtc::AsyncPacketSocket* socket) |
296 : Connection(port, 0, candidate), | 295 : Connection(port, 0, candidate), |
297 socket_(socket), | 296 socket_(socket), |
298 error_(0), | 297 error_(0), |
299 outgoing_(socket == NULL), | 298 outgoing_(socket == NULL), |
300 connection_pending_(false), | 299 connection_pending_(false), |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { | 467 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { |
469 if (outgoing_) { | 468 if (outgoing_) { |
470 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); | 469 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); |
471 } | 470 } |
472 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); | 471 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); |
473 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); | 472 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); |
474 socket->SignalClose.connect(this, &TCPConnection::OnClose); | 473 socket->SignalClose.connect(this, &TCPConnection::OnClose); |
475 } | 474 } |
476 | 475 |
477 } // namespace cricket | 476 } // namespace cricket |
OLD | NEW |