Lines Matching refs:SSL
57 #include <openssl/ssl.h>
80 int dtls1_new(SSL *ssl) {
81 if (!ssl3_new(ssl)) {
86 ssl3_free(ssl);
91 ssl->d1 = d1;
98 ssl->version = DTLS1_2_VERSION;
102 void dtls1_free(SSL *ssl) {
103 ssl3_free(ssl);
105 if (ssl == NULL || ssl->d1 == NULL) {
109 dtls_clear_incoming_messages(ssl);
110 dtls_clear_outgoing_messages(ssl);
112 OPENSSL_free(ssl->d1);
113 ssl->d1 = NULL;
116 void DTLSv1_set_initial_timeout_duration(SSL *ssl, unsigned int duration_ms) {
117 ssl->initial_timeout_duration_ms = duration_ms;
120 void dtls1_start_timer(SSL *ssl) {
122 if (ssl->d1->next_timeout.tv_sec == 0 && ssl->d1->next_timeout.tv_usec == 0) {
123 ssl->d1->timeout_duration_ms = ssl->initial_timeout_duration_ms;
127 ssl_get_current_time(ssl, &ssl->d1->next_timeout);
130 ssl->d1->next_timeout.tv_sec += ssl->d1->timeout_duration_ms / 1000;
131 ssl->d1->next_timeout.tv_usec += (ssl->d1->timeout_duration_ms % 1000) * 1000;
132 if (ssl->d1->next_timeout.tv_usec >= 1000000) {
133 ssl->d1->next_timeout.tv_sec++;
134 ssl->d1->next_timeout.tv_usec -= 1000000;
138 int DTLSv1_get_timeout(const SSL *ssl, struct timeval *out) {
139 if (!SSL_is_dtls(ssl)) {
144 if (ssl->d1->next_timeout.tv_sec == 0 && ssl->d1->next_timeout.tv_usec == 0) {
149 ssl_get_current_time(ssl, &timenow);
152 if (ssl->d1->next_timeout.tv_sec < timenow.tv_sec ||
153 (ssl->d1->next_timeout.tv_sec == timenow.tv_sec &&
154 ssl->d1->next_timeout.tv_usec <= timenow.tv_usec)) {
161 OPENSSL_memcpy(&ret, &ssl->d1->next_timeout, sizeof(ret));
188 int dtls1_is_timer_expired(SSL *ssl) {
192 if (!DTLSv1_get_timeout(ssl, &timeleft)) {
205 void dtls1_double_timeout(SSL *ssl) {
206 ssl->d1->timeout_duration_ms *= 2;
207 if (ssl->d1->timeout_duration_ms > 60000) {
208 ssl->d1->timeout_duration_ms = 60000;
210 dtls1_start_timer(ssl);
213 void dtls1_stop_timer(SSL *ssl) {
215 ssl->d1->num_timeouts = 0;
216 OPENSSL_memset(&ssl->d1->next_timeout, 0, sizeof(ssl->d1->next_timeout));
217 ssl->d1->timeout_duration_ms = ssl->initial_timeout_duration_ms;
220 dtls_clear_outgoing_messages(ssl);
223 int dtls1_check_timeout_num(SSL *ssl) {
224 ssl->d1->num_timeouts++;
227 if (ssl->d1->num_timeouts > DTLS1_MTU_TIMEOUTS &&
228 !(SSL_get_options(ssl) & SSL_OP_NO_QUERY_MTU)) {
229 long mtu = BIO_ctrl(ssl->wbio, BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, NULL);
231 ssl->d1->mtu = (unsigned)mtu;
235 if (ssl->d1->num_timeouts > DTLS1_MAX_TIMEOUTS) {
237 OPENSSL_PUT_ERROR(SSL, SSL_R_READ_TIMEOUT_EXPIRED);
244 int DTLSv1_handle_timeout(SSL *ssl) {
245 ssl_reset_error_state(ssl);
247 if (!SSL_is_dtls(ssl)) {
252 if (!dtls1_is_timer_expired(ssl)) {
256 dtls1_double_timeout(ssl);
258 if (dtls1_check_timeout_num(ssl) < 0) {
262 dtls1_start_timer(ssl);
263 return dtls1_retransmit_outgoing_messages(ssl);