OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ASSERT(!transport_); | 68 ASSERT(!transport_); |
69 ssl_max_version_ = version; | 69 ssl_max_version_ = version; |
70 } | 70 } |
71 void SetupChannels(int count, cricket::IceRole role) { | 71 void SetupChannels(int count, cricket::IceRole role) { |
72 transport_.reset(new cricket::DtlsTransport<cricket::FakeTransport>( | 72 transport_.reset(new cricket::DtlsTransport<cricket::FakeTransport>( |
73 "dtls content name", nullptr, certificate_)); | 73 "dtls content name", nullptr, certificate_)); |
74 transport_->SetAsync(true); | 74 transport_->SetAsync(true); |
75 transport_->SetIceRole(role); | 75 transport_->SetIceRole(role); |
76 transport_->SetIceTiebreaker( | 76 transport_->SetIceTiebreaker( |
77 (role == cricket::ICEROLE_CONTROLLING) ? 1 : 2); | 77 (role == cricket::ICEROLE_CONTROLLING) ? 1 : 2); |
78 transport_->SignalWritableState.connect(this, | |
79 &DtlsTestClient::OnTransportWritableState); | |
80 | 78 |
81 for (int i = 0; i < count; ++i) { | 79 for (int i = 0; i < count; ++i) { |
82 cricket::DtlsTransportChannelWrapper* channel = | 80 cricket::DtlsTransportChannelWrapper* channel = |
83 static_cast<cricket::DtlsTransportChannelWrapper*>( | 81 static_cast<cricket::DtlsTransportChannelWrapper*>( |
84 transport_->CreateChannel(i)); | 82 transport_->CreateChannel(i)); |
85 ASSERT_TRUE(channel != NULL); | 83 ASSERT_TRUE(channel != NULL); |
86 channel->SetSslMaxProtocolVersion(ssl_max_version_); | 84 channel->SetSslMaxProtocolVersion(ssl_max_version_); |
87 channel->SignalWritableState.connect(this, | 85 channel->SignalWritableState.connect(this, |
88 &DtlsTestClient::OnTransportChannelWritableState); | 86 &DtlsTestClient::OnTransportChannelWritableState); |
89 channel->SignalReadPacket.connect(this, | 87 channel->SignalReadPacket.connect(this, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 negotiated_dtls_ = (local_cert && remote_cert); | 184 negotiated_dtls_ = (local_cert && remote_cert); |
187 } | 185 } |
188 | 186 |
189 bool Connect(DtlsTestClient* peer) { | 187 bool Connect(DtlsTestClient* peer) { |
190 transport_->ConnectChannels(); | 188 transport_->ConnectChannels(); |
191 transport_->SetDestination(peer->transport_.get()); | 189 transport_->SetDestination(peer->transport_.get()); |
192 return true; | 190 return true; |
193 } | 191 } |
194 | 192 |
195 bool all_channels_writable() const { | 193 bool all_channels_writable() const { |
196 return transport_->all_channels_writable(); | 194 if (channels_.empty()) { |
| 195 return false; |
| 196 } |
| 197 for (cricket::DtlsTransportChannelWrapper* channel : channels_) { |
| 198 if (!channel->writable()) { |
| 199 return false; |
| 200 } |
| 201 } |
| 202 return true; |
197 } | 203 } |
198 | 204 |
199 void CheckRole(rtc::SSLRole role) { | 205 void CheckRole(rtc::SSLRole role) { |
200 if (role == rtc::SSL_CLIENT) { | 206 if (role == rtc::SSL_CLIENT) { |
201 ASSERT_FALSE(received_dtls_client_hello_); | 207 ASSERT_FALSE(received_dtls_client_hello_); |
202 ASSERT_TRUE(received_dtls_server_hello_); | 208 ASSERT_TRUE(received_dtls_server_hello_); |
203 } else { | 209 } else { |
204 ASSERT_TRUE(received_dtls_client_hello_); | 210 ASSERT_TRUE(received_dtls_client_hello_); |
205 ASSERT_FALSE(received_dtls_server_hello_); | 211 ASSERT_FALSE(received_dtls_server_hello_); |
206 } | 212 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 uint32 packet_num = rtc::GetBE32(data + kPacketNumOffset); | 312 uint32 packet_num = rtc::GetBE32(data + kPacketNumOffset); |
307 int num_matches = 0; | 313 int num_matches = 0; |
308 for (size_t i = kPacketNumOffset; i < size; ++i) { | 314 for (size_t i = kPacketNumOffset; i < size; ++i) { |
309 if (static_cast<uint8>(data[i]) == (packet_num & 0xff)) { | 315 if (static_cast<uint8>(data[i]) == (packet_num & 0xff)) { |
310 ++num_matches; | 316 ++num_matches; |
311 } | 317 } |
312 } | 318 } |
313 return (num_matches < ((static_cast<int>(size) - 5) / 10)); | 319 return (num_matches < ((static_cast<int>(size) - 5) / 10)); |
314 } | 320 } |
315 | 321 |
316 // Transport callbacks | |
317 void OnTransportWritableState(cricket::Transport* transport) { | |
318 LOG(LS_INFO) << name_ << ": is writable"; | |
319 } | |
320 | |
321 // Transport channel callbacks | 322 // Transport channel callbacks |
322 void OnTransportChannelWritableState(cricket::TransportChannel* channel) { | 323 void OnTransportChannelWritableState(cricket::TransportChannel* channel) { |
323 LOG(LS_INFO) << name_ << ": Channel '" << channel->component() | 324 LOG(LS_INFO) << name_ << ": Channel '" << channel->component() |
324 << "' is writable"; | 325 << "' is writable"; |
325 } | 326 } |
326 | 327 |
327 void OnTransportChannelReadPacket(cricket::TransportChannel* channel, | 328 void OnTransportChannelReadPacket(cricket::TransportChannel* channel, |
328 const char* data, size_t size, | 329 const char* data, size_t size, |
329 const rtc::PacketTime& packet_time, | 330 const rtc::PacketTime& packet_time, |
330 int flags) { | 331 int flags) { |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 // Each side's remote certificate is the other side's local certificate. | 864 // Each side's remote certificate is the other side's local certificate. |
864 ASSERT_TRUE( | 865 ASSERT_TRUE( |
865 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept())); | 866 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept())); |
866 ASSERT_EQ(remote_cert1->ToPEMString(), | 867 ASSERT_EQ(remote_cert1->ToPEMString(), |
867 certificate2->ssl_certificate().ToPEMString()); | 868 certificate2->ssl_certificate().ToPEMString()); |
868 ASSERT_TRUE( | 869 ASSERT_TRUE( |
869 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept())); | 870 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept())); |
870 ASSERT_EQ(remote_cert2->ToPEMString(), | 871 ASSERT_EQ(remote_cert2->ToPEMString(), |
871 certificate1->ssl_certificate().ToPEMString()); | 872 certificate1->ssl_certificate().ToPEMString()); |
872 } | 873 } |
OLD | NEW |