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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 TCPPort::~TCPPort() { | 118 TCPPort::~TCPPort() { |
119 delete socket_; | 119 delete socket_; |
120 std::list<Incoming>::iterator it; | 120 std::list<Incoming>::iterator it; |
121 for (it = incoming_.begin(); it != incoming_.end(); ++it) | 121 for (it = incoming_.begin(); it != incoming_.end(); ++it) |
122 delete it->socket; | 122 delete it->socket; |
123 incoming_.clear(); | 123 incoming_.clear(); |
124 } | 124 } |
125 | 125 |
126 Connection* TCPPort::CreateConnection(const Candidate& address, | 126 Connection* TCPPort::CreateConnection(const Candidate& address, |
127 CandidateOrigin origin) { | 127 CandidateOrigin origin, |
| 128 const IceConfig& config) { |
128 if (!SupportsProtocol(address.protocol())) { | 129 if (!SupportsProtocol(address.protocol())) { |
129 return NULL; | 130 return NULL; |
130 } | 131 } |
131 | 132 |
132 if (address.tcptype() == TCPTYPE_ACTIVE_STR || | 133 if (address.tcptype() == TCPTYPE_ACTIVE_STR || |
133 (address.tcptype().empty() && address.address().port() == 0)) { | 134 (address.tcptype().empty() && address.address().port() == 0)) { |
134 // It's active only candidate, we should not try to create connections | 135 // It's active only candidate, we should not try to create connections |
135 // for these candidates. | 136 // for these candidates. |
136 return NULL; | 137 return NULL; |
137 } | 138 } |
(...skipping 13 matching lines...) Expand all Loading... |
151 } | 152 } |
152 | 153 |
153 if (!IsCompatibleAddress(address.address())) { | 154 if (!IsCompatibleAddress(address.address())) { |
154 return NULL; | 155 return NULL; |
155 } | 156 } |
156 | 157 |
157 TCPConnection* conn = NULL; | 158 TCPConnection* conn = NULL; |
158 if (rtc::AsyncPacketSocket* socket = | 159 if (rtc::AsyncPacketSocket* socket = |
159 GetIncoming(address.address(), true)) { | 160 GetIncoming(address.address(), true)) { |
160 socket->SignalReadPacket.disconnect(this); | 161 socket->SignalReadPacket.disconnect(this); |
161 conn = new TCPConnection(this, address, socket); | 162 conn = new TCPConnection(this, address, config, socket); |
162 } else { | 163 } else { |
163 conn = new TCPConnection(this, address); | 164 conn = new TCPConnection(this, address, config); |
164 } | 165 } |
165 AddOrReplaceConnection(conn); | 166 AddOrReplaceConnection(conn); |
166 return conn; | 167 return conn; |
167 } | 168 } |
168 | 169 |
169 void TCPPort::PrepareAddress() { | 170 void TCPPort::PrepareAddress() { |
170 if (socket_) { | 171 if (socket_) { |
171 // If socket isn't bound yet the address will be added in | 172 // If socket isn't bound yet the address will be added in |
172 // OnAddressReady(). Socket may be in the CLOSED state if Listen() | 173 // OnAddressReady(). Socket may be in the CLOSED state if Listen() |
173 // failed, we still want to add the socket address. | 174 // failed, we still want to add the socket address. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 299 |
299 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, | 300 void TCPPort::OnAddressReady(rtc::AsyncPacketSocket* socket, |
300 const rtc::SocketAddress& address) { | 301 const rtc::SocketAddress& address) { |
301 AddAddress(address, address, rtc::SocketAddress(), TCP_PROTOCOL_NAME, "", | 302 AddAddress(address, address, rtc::SocketAddress(), TCP_PROTOCOL_NAME, "", |
302 TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST_TCP, | 303 TCPTYPE_PASSIVE_STR, LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST_TCP, |
303 0, true); | 304 0, true); |
304 } | 305 } |
305 | 306 |
306 TCPConnection::TCPConnection(TCPPort* port, | 307 TCPConnection::TCPConnection(TCPPort* port, |
307 const Candidate& candidate, | 308 const Candidate& candidate, |
| 309 const IceConfig& config, |
308 rtc::AsyncPacketSocket* socket) | 310 rtc::AsyncPacketSocket* socket) |
309 : Connection(port, 0, candidate), | 311 : Connection(port, 0, candidate, config), |
310 socket_(socket), | 312 socket_(socket), |
311 error_(0), | 313 error_(0), |
312 outgoing_(socket == NULL), | 314 outgoing_(socket == NULL), |
313 connection_pending_(false), | 315 connection_pending_(false), |
314 pretending_to_be_writable_(false), | 316 pretending_to_be_writable_(false), |
315 reconnection_timeout_(cricket::CONNECTION_WRITE_CONNECT_TIMEOUT) { | 317 reconnection_timeout_(cricket::CONNECTION_WRITE_CONNECT_TIMEOUT) { |
316 if (outgoing_) { | 318 if (outgoing_) { |
317 CreateOutgoingTcpSocket(); | 319 CreateOutgoingTcpSocket(); |
318 } else { | 320 } else { |
319 // Incoming connections should match the network address. | 321 // Incoming connections should match the network address. |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { | 514 void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) { |
513 if (outgoing_) { | 515 if (outgoing_) { |
514 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); | 516 socket->SignalConnect.connect(this, &TCPConnection::OnConnect); |
515 } | 517 } |
516 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); | 518 socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket); |
517 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); | 519 socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend); |
518 socket->SignalClose.connect(this, &TCPConnection::OnClose); | 520 socket->SignalClose.connect(this, &TCPConnection::OnClose); |
519 } | 521 } |
520 | 522 |
521 } // namespace cricket | 523 } // namespace cricket |
OLD | NEW |