Lines Matching defs:s

76 static int dtls1_listen(SSL *s, struct sockaddr *client);
79 dtls1_new(SSL *s)
81 if (!ssl3_new(s))
84 if ((s->d1 = calloc(1, sizeof(*s->d1))) == NULL)
87 if ((s->d1->unprocessed_rcds.q = pqueue_new()) == NULL)
89 if ((s->d1->buffered_messages = pqueue_new()) == NULL)
91 if ((s->d1->sent_messages = pqueue_new()) == NULL)
93 if ((s->d1->buffered_app_data.q = pqueue_new()) == NULL)
96 if (s->server)
97 s->d1->cookie_len = sizeof(s->d1->cookie);
99 s->method->ssl_clear(s);
103 dtls1_free(s);
156 dtls1_clear_queues(SSL *s)
158 dtls1_drain_records(s->d1->unprocessed_rcds.q);
159 dtls1_drain_fragments(s->d1->buffered_messages);
160 dtls1_drain_fragments(s->d1->sent_messages);
161 dtls1_drain_rcontents(s->d1->buffered_app_data.q);
165 dtls1_free(SSL *s)
167 if (s == NULL)
170 ssl3_free(s);
172 if (s->d1 == NULL)
175 dtls1_clear_queues(s);
177 pqueue_free(s->d1->unprocessed_rcds.q);
178 pqueue_free(s->d1->buffered_messages);
179 pqueue_free(s->d1->sent_messages);
180 pqueue_free(s->d1->buffered_app_data.q);
182 freezero(s->d1, sizeof(*s->d1));
183 s->d1 = NULL;
187 dtls1_clear(SSL *s)
195 if (s->d1) {
196 unprocessed_rcds = s->d1->unprocessed_rcds.q;
197 buffered_messages = s->d1->buffered_messages;
198 sent_messages = s->d1->sent_messages;
199 buffered_app_data = s->d1->buffered_app_data.q;
200 mtu = s->d1->mtu;
202 dtls1_clear_queues(s);
204 memset(s->d1, 0, sizeof(*s->d1));
206 s->d1->unprocessed_rcds.epoch =
207 tls12_record_layer_read_epoch(s->rl) + 1;
209 if (s->server) {
210 s->d1->cookie_len = sizeof(s->d1->cookie);
213 if (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU) {
214 s->d1->mtu = mtu;
217 s->d1->unprocessed_rcds.q = unprocessed_rcds;
218 s->d1->buffered_messages = buffered_messages;
219 s->d1->sent_messages = sent_messages;
220 s->d1->buffered_app_data.q = buffered_app_data;
223 ssl3_clear(s);
225 s->version = DTLS1_VERSION;
229 dtls1_ctrl(SSL *s, int cmd, long larg, void *parg)
235 if (dtls1_get_timeout(s, (struct timeval*) parg) != NULL) {
240 ret = dtls1_handle_timeout(s);
243 ret = dtls1_listen(s, parg);
247 ret = ssl3_ctrl(s, cmd, larg, parg);
254 dtls1_start_timer(SSL *s)
258 if (s->d1->next_timeout.tv_sec == 0 && s->d1->next_timeout.tv_usec == 0) {
259 s->d1->timeout_duration = 1;
263 gettimeofday(&(s->d1->next_timeout), NULL);
266 s->d1->next_timeout.tv_sec += s->d1->timeout_duration;
267 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0,
268 &s->d1->next_timeout);
272 dtls1_get_timeout(SSL *s, struct timeval* timeleft)
277 if (s->d1->next_timeout.tv_sec == 0 && s->d1->next_timeout.tv_usec == 0) {
285 if (s->d1->next_timeout.tv_sec < timenow.tv_sec ||
286 (s->d1->next_timeout.tv_sec == timenow.tv_sec &&
287 s->d1->next_timeout.tv_usec <= timenow.tv_usec)) {
293 memcpy(timeleft, &(s->d1->next_timeout), sizeof(struct timeval));
314 dtls1_is_timer_expired(SSL *s)
319 if (dtls1_get_timeout(s, &timeleft) == NULL) {
333 dtls1_double_timeout(SSL *s)
335 s->d1->timeout_duration *= 2;
336 if (s->d1->timeout_duration > 60)
337 s->d1->timeout_duration = 60;
338 dtls1_start_timer(s);
342 dtls1_stop_timer(SSL *s)
345 memset(&(s->d1->timeout), 0, sizeof(struct dtls1_timeout_st));
346 memset(&(s->d1->next_timeout), 0, sizeof(struct timeval));
347 s->d1->timeout_duration = 1;
348 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0,
349 &(s->d1->next_timeout));
351 dtls1_clear_record_buffer(s);
355 dtls1_check_timeout_num(SSL *s)
357 s->d1->timeout.num_alerts++;
360 if (s->d1->timeout.num_alerts > 2) {
361 s->d1->mtu = BIO_ctrl(SSL_get_wbio(s),
366 if (s->d1->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT) {
368 SSLerror(s, SSL_R_READ_TIMEOUT_EXPIRED);
376 dtls1_handle_timeout(SSL *s)
379 if (!dtls1_is_timer_expired(s)) {
383 dtls1_double_timeout(s);
385 if (dtls1_check_timeout_num(s) < 0)
388 s->d1->timeout.read_timeouts++;
389 if (s->d1->timeout.read_timeouts > DTLS1_TMO_READ_COUNT) {
390 s->d1->timeout.read_timeouts = 1;
393 dtls1_start_timer(s);
394 return dtls1_retransmit_buffered_messages(s);
398 dtls1_listen(SSL *s, struct sockaddr *client)
403 SSL_clear(s);
405 SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE);
406 s->d1->listen = 1;
408 ret = SSL_accept(s);
412 (void)BIO_dgram_get_peer(SSL_get_rbio(s), client);