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 |
526 // | 532 // |
527 // StreamInterface Implementation | 533 // StreamInterface Implementation |
528 // | 534 // |
529 | 535 |
530 StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len, | 536 StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len, |
531 size_t* written, int* error) { | 537 size_t* written, int* error) { |
532 LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Write(" << data_len << ")"; | 538 LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Write(" << data_len << ")"; |
533 | 539 |
534 switch (state_) { | 540 switch (state_) { |
535 case SSL_NONE: | 541 case SSL_NONE: |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 if (!ssl_) { | 799 if (!ssl_) { |
794 BIO_free(bio); | 800 BIO_free(bio); |
795 return -1; | 801 return -1; |
796 } | 802 } |
797 | 803 |
798 SSL_set_app_data(ssl_, this); | 804 SSL_set_app_data(ssl_, this); |
799 | 805 |
800 SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now. | 806 SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now. |
801 if (ssl_mode_ == SSL_MODE_DTLS) { | 807 if (ssl_mode_ == SSL_MODE_DTLS) { |
802 #ifdef OPENSSL_IS_BORINGSSL | 808 #ifdef OPENSSL_IS_BORINGSSL |
803 // Change the initial retransmission timer from 1 second to 50ms. | 809 DTLSv1_set_initial_timeout_duration(ssl_, dtls_handshake_timeout_ms_); |
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); | |
808 #else | 810 #else |
809 // Enable read-ahead for DTLS so whole packets are read from internal BIO | 811 // Enable read-ahead for DTLS so whole packets are read from internal BIO |
810 // before parsing. This is done internally by BoringSSL for DTLS. | 812 // before parsing. This is done internally by BoringSSL for DTLS. |
811 SSL_set_read_ahead(ssl_, 1); | 813 SSL_set_read_ahead(ssl_, 1); |
812 #endif | 814 #endif |
813 } | 815 } |
814 | 816 |
815 SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | | 817 SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | |
816 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); | 818 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); |
817 | 819 |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 } | 1229 } |
1228 | 1230 |
1229 return false; | 1231 return false; |
1230 } | 1232 } |
1231 | 1233 |
1232 void OpenSSLStreamAdapter::enable_time_callback_for_testing() { | 1234 void OpenSSLStreamAdapter::enable_time_callback_for_testing() { |
1233 g_use_time_callback_for_testing = true; | 1235 g_use_time_callback_for_testing = true; |
1234 } | 1236 } |
1235 | 1237 |
1236 } // namespace rtc | 1238 } // namespace rtc |
OLD | NEW |