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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 void OpenSSLStreamAdapter::SetMode(SSLMode mode) { | 516 void OpenSSLStreamAdapter::SetMode(SSLMode mode) { |
517 RTC_DCHECK(state_ == SSL_NONE); | 517 RTC_DCHECK(state_ == SSL_NONE); |
518 ssl_mode_ = mode; | 518 ssl_mode_ = mode; |
519 } | 519 } |
520 | 520 |
521 void OpenSSLStreamAdapter::SetMaxProtocolVersion(SSLProtocolVersion version) { | 521 void OpenSSLStreamAdapter::SetMaxProtocolVersion(SSLProtocolVersion version) { |
522 RTC_DCHECK(ssl_ctx_ == NULL); | 522 RTC_DCHECK(ssl_ctx_ == NULL); |
523 ssl_max_version_ = version; | 523 ssl_max_version_ = version; |
524 } | 524 } |
525 | 525 |
526 void OpenSSLStreamAdapter::SetInitialRetransmissionTimeout( | |
527 int timeout_ms) { | |
528 RTC_DCHECK(ssl_ctx_ == NULL); | |
529 dtls_handshake_timeout_ms_ = timeout_ms; | |
530 } | |
531 | |
532 // | 526 // |
533 // StreamInterface Implementation | 527 // StreamInterface Implementation |
534 // | 528 // |
535 | 529 |
536 StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len, | 530 StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len, |
537 size_t* written, int* error) { | 531 size_t* written, int* error) { |
538 LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Write(" << data_len << ")"; | 532 LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Write(" << data_len << ")"; |
539 | 533 |
540 switch (state_) { | 534 switch (state_) { |
541 case SSL_NONE: | 535 case SSL_NONE: |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 if (!ssl_) { | 793 if (!ssl_) { |
800 BIO_free(bio); | 794 BIO_free(bio); |
801 return -1; | 795 return -1; |
802 } | 796 } |
803 | 797 |
804 SSL_set_app_data(ssl_, this); | 798 SSL_set_app_data(ssl_, this); |
805 | 799 |
806 SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now. | 800 SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now. |
807 if (ssl_mode_ == SSL_MODE_DTLS) { | 801 if (ssl_mode_ == SSL_MODE_DTLS) { |
808 #ifdef OPENSSL_IS_BORINGSSL | 802 #ifdef OPENSSL_IS_BORINGSSL |
809 DTLSv1_set_initial_timeout_duration(ssl_, dtls_handshake_timeout_ms_); | 803 // Change the initial retransmission timer from 1 second to 50ms. |
| 804 // This will likely result in some spurious retransmissions, but |
| 805 // it's useful for ensuring a timely handshake when there's packet |
| 806 // loss. |
| 807 DTLSv1_set_initial_timeout_duration(ssl_, 50); |
810 #else | 808 #else |
811 // Enable read-ahead for DTLS so whole packets are read from internal BIO | 809 // Enable read-ahead for DTLS so whole packets are read from internal BIO |
812 // before parsing. This is done internally by BoringSSL for DTLS. | 810 // before parsing. This is done internally by BoringSSL for DTLS. |
813 SSL_set_read_ahead(ssl_, 1); | 811 SSL_set_read_ahead(ssl_, 1); |
814 #endif | 812 #endif |
815 } | 813 } |
816 | 814 |
817 SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | | 815 SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | |
818 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); | 816 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); |
819 | 817 |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 } | 1227 } |
1230 | 1228 |
1231 return false; | 1229 return false; |
1232 } | 1230 } |
1233 | 1231 |
1234 void OpenSSLStreamAdapter::enable_time_callback_for_testing() { | 1232 void OpenSSLStreamAdapter::enable_time_callback_for_testing() { |
1235 g_use_time_callback_for_testing = true; | 1233 g_use_time_callback_for_testing = true; |
1236 } | 1234 } |
1237 | 1235 |
1238 } // namespace rtc | 1236 } // namespace rtc |
OLD | NEW |