OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 local_cert_ = certificate; | 235 local_cert_ = certificate; |
236 return true; | 236 return true; |
237 } | 237 } |
238 | 238 |
239 void SetRemoteSSLCertificate(rtc::FakeSSLCertificate* cert) { | 239 void SetRemoteSSLCertificate(rtc::FakeSSLCertificate* cert) { |
240 remote_cert_ = cert; | 240 remote_cert_ = cert; |
241 } | 241 } |
242 | 242 |
243 bool IsDtlsActive() const override { return do_dtls_; } | 243 bool IsDtlsActive() const override { return do_dtls_; } |
244 | 244 |
245 bool SetSrtpCryptoSuites(const std::vector<int>& ciphers) override { | 245 bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override { |
246 srtp_ciphers_ = ciphers; | 246 srtp_ciphers_ = ciphers; |
247 return true; | 247 return true; |
248 } | 248 } |
249 | 249 |
250 bool GetSrtpCryptoSuite(int* crypto_suite) override { | 250 bool GetSrtpCryptoSuite(std::string* cipher) override { |
251 if (chosen_crypto_suite_ != rtc::SRTP_INVALID_CRYPTO_SUITE) { | 251 if (!chosen_srtp_cipher_.empty()) { |
252 *crypto_suite = chosen_crypto_suite_; | 252 *cipher = chosen_srtp_cipher_; |
253 return true; | 253 return true; |
254 } | 254 } |
255 return false; | 255 return false; |
256 } | 256 } |
257 | 257 |
258 bool GetSslCipherSuite(int* cipher_suite) override { return false; } | 258 bool GetSslCipherSuite(int* cipher) override { return false; } |
259 | 259 |
260 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const { | 260 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const { |
261 return local_cert_; | 261 return local_cert_; |
262 } | 262 } |
263 | 263 |
264 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override { | 264 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override { |
265 if (!remote_cert_) | 265 if (!remote_cert_) |
266 return false; | 266 return false; |
267 | 267 |
268 *cert = remote_cert_->GetReference(); | 268 *cert = remote_cert_->GetReference(); |
269 return true; | 269 return true; |
270 } | 270 } |
271 | 271 |
272 bool ExportKeyingMaterial(const std::string& label, | 272 bool ExportKeyingMaterial(const std::string& label, |
273 const uint8_t* context, | 273 const uint8_t* context, |
274 size_t context_len, | 274 size_t context_len, |
275 bool use_context, | 275 bool use_context, |
276 uint8_t* result, | 276 uint8_t* result, |
277 size_t result_len) override { | 277 size_t result_len) override { |
278 if (chosen_crypto_suite_ != rtc::SRTP_INVALID_CRYPTO_SUITE) { | 278 if (!chosen_srtp_cipher_.empty()) { |
279 memset(result, 0xff, result_len); | 279 memset(result, 0xff, result_len); |
280 return true; | 280 return true; |
281 } | 281 } |
282 | 282 |
283 return false; | 283 return false; |
284 } | 284 } |
285 | 285 |
286 void NegotiateSrtpCiphers() { | 286 void NegotiateSrtpCiphers() { |
287 for (std::vector<int>::const_iterator it1 = srtp_ciphers_.begin(); | 287 for (std::vector<std::string>::const_iterator it1 = srtp_ciphers_.begin(); |
288 it1 != srtp_ciphers_.end(); ++it1) { | 288 it1 != srtp_ciphers_.end(); ++it1) { |
289 for (std::vector<int>::const_iterator it2 = dest_->srtp_ciphers_.begin(); | 289 for (std::vector<std::string>::const_iterator it2 = |
| 290 dest_->srtp_ciphers_.begin(); |
290 it2 != dest_->srtp_ciphers_.end(); ++it2) { | 291 it2 != dest_->srtp_ciphers_.end(); ++it2) { |
291 if (*it1 == *it2) { | 292 if (*it1 == *it2) { |
292 chosen_crypto_suite_ = *it1; | 293 chosen_srtp_cipher_ = *it1; |
293 dest_->chosen_crypto_suite_ = *it2; | 294 dest_->chosen_srtp_cipher_ = *it2; |
294 return; | 295 return; |
295 } | 296 } |
296 } | 297 } |
297 } | 298 } |
298 } | 299 } |
299 | 300 |
300 bool GetStats(ConnectionInfos* infos) override { | 301 bool GetStats(ConnectionInfos* infos) override { |
301 ConnectionInfo info; | 302 ConnectionInfo info; |
302 infos->clear(); | 303 infos->clear(); |
303 infos->push_back(info); | 304 infos->push_back(info); |
(...skipping 10 matching lines...) Expand all Loading... |
314 private: | 315 private: |
315 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; | 316 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; |
316 Transport* transport_; | 317 Transport* transport_; |
317 FakeTransportChannel* dest_ = nullptr; | 318 FakeTransportChannel* dest_ = nullptr; |
318 State state_ = STATE_INIT; | 319 State state_ = STATE_INIT; |
319 bool async_ = false; | 320 bool async_ = false; |
320 Candidates remote_candidates_; | 321 Candidates remote_candidates_; |
321 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_; | 322 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_; |
322 rtc::FakeSSLCertificate* remote_cert_ = nullptr; | 323 rtc::FakeSSLCertificate* remote_cert_ = nullptr; |
323 bool do_dtls_ = false; | 324 bool do_dtls_ = false; |
324 std::vector<int> srtp_ciphers_; | 325 std::vector<std::string> srtp_ciphers_; |
325 int chosen_crypto_suite_ = rtc::SRTP_INVALID_CRYPTO_SUITE; | 326 std::string chosen_srtp_cipher_; |
326 int receiving_timeout_ = -1; | 327 int receiving_timeout_ = -1; |
327 bool gather_continually_ = false; | 328 bool gather_continually_ = false; |
328 IceRole role_ = ICEROLE_UNKNOWN; | 329 IceRole role_ = ICEROLE_UNKNOWN; |
329 uint64_t tiebreaker_ = 0; | 330 uint64_t tiebreaker_ = 0; |
330 std::string ice_ufrag_; | 331 std::string ice_ufrag_; |
331 std::string ice_pwd_; | 332 std::string ice_pwd_; |
332 std::string remote_ice_ufrag_; | 333 std::string remote_ice_ufrag_; |
333 std::string remote_ice_pwd_; | 334 std::string remote_ice_pwd_; |
334 IceMode remote_ice_mode_ = ICEMODE_FULL; | 335 IceMode remote_ice_mode_ = ICEMODE_FULL; |
335 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10; | 336 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 } | 535 } |
535 } | 536 } |
536 | 537 |
537 private: | 538 private: |
538 bool fail_create_channel_; | 539 bool fail_create_channel_; |
539 }; | 540 }; |
540 | 541 |
541 } // namespace cricket | 542 } // namespace cricket |
542 | 543 |
543 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 544 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
OLD | NEW |