Lines Matching +full:one +full:- +full:wire
2 * Copyright 2005-2022 The OpenSSL Project Authors. All Rights Reserved.
24 if ((end) - (start) <= 8) { \
30 … for (ii = (((start) >> 3) + 1); ii < ((((end) - 1)) >> 3); ii++) bitmask[ii] = 0xff; \
31 bitmask[(((end) - 1) >> 3)] |= bitmask_end_values[((end) & 7)]; \
37 … if (bitmask[(((msg_len) - 1) >> 3)] != bitmask_end_values[((msg_len) & 7)]) is_complete = 0; \
38 if (is_complete) for (ii = (((msg_len) - 1) >> 3) - 1; ii >= 0 ; ii--) \
75 /* zero length fragment gets zero frag->fragment */ in dtls1_hm_fragment_new()
76 frag->fragment = buf; in dtls1_hm_fragment_new()
89 frag->reassembly = bitmask; in dtls1_hm_fragment_new()
99 OPENSSL_free(frag->fragment); in dtls1_hm_fragment_free()
100 OPENSSL_free(frag->reassembly); in dtls1_hm_fragment_free()
105 * send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or
117 return -1; in dtls1_do_write()
119 if (s->d1->mtu < dtls1_min_mtu(s)) in dtls1_do_write()
121 return -1; in dtls1_do_write()
123 if (s->init_off == 0 && type == SSL3_RT_HANDSHAKE) { in dtls1_do_write()
124 if (!ossl_assert(s->init_num == in dtls1_do_write()
125 s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH)) in dtls1_do_write()
126 return -1; in dtls1_do_write()
129 if (s->write_hash) { in dtls1_do_write()
130 if (s->enc_write_ctx in dtls1_do_write()
131 && (EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(s->enc_write_ctx)) & in dtls1_do_write()
135 mac_size = EVP_MD_CTX_get_size(s->write_hash); in dtls1_do_write()
139 if (s->enc_write_ctx && in dtls1_do_write()
140 (EVP_CIPHER_CTX_get_mode(s->enc_write_ctx) == EVP_CIPH_CBC_MODE)) in dtls1_do_write()
141 blocksize = 2 * EVP_CIPHER_CTX_get_block_size(s->enc_write_ctx); in dtls1_do_write()
146 s->rwstate = SSL_NOTHING; in dtls1_do_write()
148 /* s->init_num shouldn't ever be < 0...but just in case */ in dtls1_do_write()
149 while (s->init_num > 0) { in dtls1_do_write()
150 if (type == SSL3_RT_HANDSHAKE && s->init_off != 0) { in dtls1_do_write()
151 /* We must be writing a fragment other than the first one */ in dtls1_do_write()
156 if (s->init_off <= DTLS1_HM_HEADER_LENGTH) { in dtls1_do_write()
159 * contained the message header plus one other byte. in dtls1_do_write()
164 return -1; in dtls1_do_write()
171 s->init_off -= DTLS1_HM_HEADER_LENGTH; in dtls1_do_write()
172 s->init_num += DTLS1_HM_HEADER_LENGTH; in dtls1_do_write()
180 frag_off = s->d1->w_msg_hdr.frag_off; in dtls1_do_write()
184 used_len = BIO_wpending(s->wbio) + DTLS1_RT_HEADER_LENGTH in dtls1_do_write()
186 if (s->d1->mtu > used_len) in dtls1_do_write()
187 curr_mtu = s->d1->mtu - used_len; in dtls1_do_write()
195 ret = BIO_flush(s->wbio); in dtls1_do_write()
197 s->rwstate = SSL_WRITING; in dtls1_do_write()
201 if (s->d1->mtu > used_len + DTLS1_HM_HEADER_LENGTH) { in dtls1_do_write()
202 curr_mtu = s->d1->mtu - used_len; in dtls1_do_write()
205 return -1; in dtls1_do_write()
210 * We just checked that s->init_num > 0 so this cast should be safe in dtls1_do_write()
212 if (((unsigned int)s->init_num) > curr_mtu) in dtls1_do_write()
215 len = s->init_num; in dtls1_do_write()
229 return -1; in dtls1_do_write()
231 dtls1_fix_message_header(s, frag_off, len - DTLS1_HM_HEADER_LENGTH); in dtls1_do_write()
234 (unsigned char *)&s->init_buf-> in dtls1_do_write()
235 data[s->init_off]); in dtls1_do_write()
238 ret = dtls1_write_bytes(s, type, &s->init_buf->data[s->init_off], len, in dtls1_do_write()
243 * previous packet caused the failure -- so can't really in dtls1_do_write()
251 return -1; in dtls1_do_write()
252 /* Have one more go */ in dtls1_do_write()
255 return -1; in dtls1_do_write()
257 return -1; in dtls1_do_write()
266 return -1; in dtls1_do_write()
268 if (type == SSL3_RT_HANDSHAKE && !s->d1->retransmitting) { in dtls1_do_write()
274 (unsigned char *)&s->init_buf->data[s->init_off]; in dtls1_do_write()
275 const struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; in dtls1_do_write()
278 if (frag_off == 0 && s->version != DTLS1_BAD_VER) { in dtls1_do_write()
283 *p++ = msg_hdr->type; in dtls1_do_write()
284 l2n3(msg_hdr->msg_len, p); in dtls1_do_write()
285 s2n(msg_hdr->seq, p); in dtls1_do_write()
287 l2n3(msg_hdr->msg_len, p); in dtls1_do_write()
288 p -= DTLS1_HM_HEADER_LENGTH; in dtls1_do_write()
292 xlen = written - DTLS1_HM_HEADER_LENGTH; in dtls1_do_write()
296 return -1; in dtls1_do_write()
299 if (written == s->init_num) { in dtls1_do_write()
300 if (s->msg_callback) in dtls1_do_write()
301 s->msg_callback(1, s->version, type, s->init_buf->data, in dtls1_do_write()
302 (size_t)(s->init_off + s->init_num), s, in dtls1_do_write()
303 s->msg_callback_arg); in dtls1_do_write()
305 s->init_off = 0; /* done writing this message */ in dtls1_do_write()
306 s->init_num = 0; in dtls1_do_write()
310 s->init_off += written; in dtls1_do_write()
311 s->init_num -= written; in dtls1_do_write()
312 written -= DTLS1_HM_HEADER_LENGTH; in dtls1_do_write()
335 msg_hdr = &s->d1->r_msg_hdr; in dtls_get_message()
348 *mt = s->s3.tmp.message_type; in dtls_get_message()
350 p = (unsigned char *)s->init_buf->data; in dtls_get_message()
353 if (s->msg_callback) { in dtls_get_message()
354 s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, in dtls_get_message()
355 p, 1, s, s->msg_callback_arg); in dtls_get_message()
363 msg_len = msg_hdr->msg_len; in dtls_get_message()
366 *(p++) = msg_hdr->type; in dtls_get_message()
368 s2n(msg_hdr->seq, p); in dtls_get_message()
374 s->d1->handshake_read_seq++; in dtls_get_message()
376 s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; in dtls_get_message()
382 * Actually we already have the message body - but this is an opportunity for
388 unsigned char *msg = (unsigned char *)s->init_buf->data; in dtls_get_message_body()
389 size_t msg_len = s->init_num + DTLS1_HM_HEADER_LENGTH; in dtls_get_message_body()
391 if (s->s3.tmp.message_type == SSL3_MT_CHANGE_CIPHER_SPEC) { in dtls_get_message_body()
399 if (*(s->init_buf->data) == SSL3_MT_FINISHED && !ssl3_take_mac(s)) { in dtls_get_message_body()
404 if (s->version == DTLS1_BAD_VER) { in dtls_get_message_body()
406 msg_len -= DTLS1_HM_HEADER_LENGTH; in dtls_get_message_body()
412 if (s->msg_callback) in dtls_get_message_body()
413 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, in dtls_get_message_body()
414 s->init_buf->data, s->init_num + DTLS1_HM_HEADER_LENGTH, in dtls_get_message_body()
415 s, s->msg_callback_arg); in dtls_get_message_body()
418 *len = s->init_num; in dtls_get_message_body()
430 if (max_len < s->max_cert_list) in dtls1_max_handshake_message_len()
431 return s->max_cert_list; in dtls1_max_handshake_message_len()
439 msg_len = msg_hdr->msg_len; in dtls1_preprocess_fragment()
440 frag_off = msg_hdr->frag_off; in dtls1_preprocess_fragment()
441 frag_len = msg_hdr->frag_len; in dtls1_preprocess_fragment()
450 if (s->d1->r_msg_hdr.frag_off == 0) { /* first fragment */ in dtls1_preprocess_fragment()
455 if (!BUF_MEM_grow_clean(s->init_buf, msg_len + DTLS1_HM_HEADER_LENGTH)) { in dtls1_preprocess_fragment()
460 s->s3.tmp.message_size = msg_len; in dtls1_preprocess_fragment()
461 s->d1->r_msg_hdr.msg_len = msg_len; in dtls1_preprocess_fragment()
462 s->s3.tmp.message_type = msg_hdr->type; in dtls1_preprocess_fragment()
463 s->d1->r_msg_hdr.type = msg_hdr->type; in dtls1_preprocess_fragment()
464 s->d1->r_msg_hdr.seq = msg_hdr->seq; in dtls1_preprocess_fragment()
465 } else if (msg_len != s->d1->r_msg_hdr.msg_len) { in dtls1_preprocess_fragment()
478 * Returns 1 if there is a buffered fragment available, 0 if not, or -1 on a
483 /*- in dtls1_retrieve_buffered_fragment()
486 * (1) copy over the fragment to s->init_buf->data[] in dtls1_retrieve_buffered_fragment()
487 * (2) update s->init_num in dtls1_retrieve_buffered_fragment()
495 iter = pqueue_iterator(s->d1->buffered_messages); in dtls1_retrieve_buffered_fragment()
501 frag = (hm_fragment *)item->data; in dtls1_retrieve_buffered_fragment()
503 if (frag->msg_header.seq < s->d1->handshake_read_seq) { in dtls1_retrieve_buffered_fragment()
507 if (!s->server in dtls1_retrieve_buffered_fragment()
508 || frag->msg_header.seq != 0 in dtls1_retrieve_buffered_fragment()
509 || s->d1->handshake_read_seq != 1 in dtls1_retrieve_buffered_fragment()
510 || s->statem.hand_state != DTLS_ST_SW_HELLO_VERIFY_REQUEST) { in dtls1_retrieve_buffered_fragment()
516 pqueue_pop(s->d1->buffered_messages); in dtls1_retrieve_buffered_fragment()
530 nextfrag = (hm_fragment *)next->data; in dtls1_retrieve_buffered_fragment()
531 if (nextfrag->msg_header.seq == s->d1->handshake_read_seq) { in dtls1_retrieve_buffered_fragment()
534 * cookie and one with. Ditch the one without. in dtls1_retrieve_buffered_fragment()
536 pqueue_pop(s->d1->buffered_messages); in dtls1_retrieve_buffered_fragment()
552 if (frag->reassembly != NULL) in dtls1_retrieve_buffered_fragment()
555 if (s->d1->handshake_read_seq == frag->msg_header.seq || chretran) { in dtls1_retrieve_buffered_fragment()
556 size_t frag_len = frag->msg_header.frag_len; in dtls1_retrieve_buffered_fragment()
557 pqueue_pop(s->d1->buffered_messages); in dtls1_retrieve_buffered_fragment()
560 ret = dtls1_preprocess_fragment(s, &frag->msg_header); in dtls1_retrieve_buffered_fragment()
562 if (ret && frag->msg_header.frag_len > 0) { in dtls1_retrieve_buffered_fragment()
564 (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH; in dtls1_retrieve_buffered_fragment()
565 memcpy(&p[frag->msg_header.frag_off], frag->fragment, in dtls1_retrieve_buffered_fragment()
566 frag->msg_header.frag_len); in dtls1_retrieve_buffered_fragment()
580 s->d1->handshake_read_seq = 0; in dtls1_retrieve_buffered_fragment()
581 s->d1->next_handshake_write_seq = 0; in dtls1_retrieve_buffered_fragment()
588 s->init_num = 0; in dtls1_retrieve_buffered_fragment()
589 return -1; in dtls1_retrieve_buffered_fragment()
600 int i = -1, is_complete; in dtls1_reassemble_fragment()
602 size_t frag_len = msg_hdr->frag_len; in dtls1_reassemble_fragment()
605 if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len || in dtls1_reassemble_fragment()
606 msg_hdr->msg_len > dtls1_max_handshake_message_len(s)) in dtls1_reassemble_fragment()
615 seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); in dtls1_reassemble_fragment()
616 seq64be[7] = (unsigned char)msg_hdr->seq; in dtls1_reassemble_fragment()
617 item = pqueue_find(s->d1->buffered_messages, seq64be); in dtls1_reassemble_fragment()
620 frag = dtls1_hm_fragment_new(msg_hdr->msg_len, 1); in dtls1_reassemble_fragment()
623 memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); in dtls1_reassemble_fragment()
624 frag->msg_header.frag_len = frag->msg_header.msg_len; in dtls1_reassemble_fragment()
625 frag->msg_header.frag_off = 0; in dtls1_reassemble_fragment()
627 frag = (hm_fragment *)item->data; in dtls1_reassemble_fragment()
628 if (frag->msg_header.msg_len != msg_hdr->msg_len) { in dtls1_reassemble_fragment()
640 if (frag->reassembly == NULL) { in dtls1_reassemble_fragment()
644 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, in dtls1_reassemble_fragment()
651 frag_len -= readbytes; in dtls1_reassemble_fragment()
657 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, in dtls1_reassemble_fragment()
658 frag->fragment + msg_hdr->frag_off, in dtls1_reassemble_fragment()
661 i = -1; in dtls1_reassemble_fragment()
665 RSMBLY_BITMASK_MARK(frag->reassembly, (long)msg_hdr->frag_off, in dtls1_reassemble_fragment()
666 (long)(msg_hdr->frag_off + frag_len)); in dtls1_reassemble_fragment()
668 if (!ossl_assert(msg_hdr->msg_len > 0)) in dtls1_reassemble_fragment()
670 RSMBLY_BITMASK_IS_COMPLETE(frag->reassembly, (long)msg_hdr->msg_len, in dtls1_reassemble_fragment()
674 OPENSSL_free(frag->reassembly); in dtls1_reassemble_fragment()
675 frag->reassembly = NULL; in dtls1_reassemble_fragment()
681 i = -1; in dtls1_reassemble_fragment()
685 item = pqueue_insert(s->d1->buffered_messages, item); in dtls1_reassemble_fragment()
701 return -1; in dtls1_reassemble_fragment()
707 int i = -1; in dtls1_process_out_of_seq_message()
711 size_t frag_len = msg_hdr->frag_len; in dtls1_process_out_of_seq_message()
714 if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len) in dtls1_process_out_of_seq_message()
719 seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); in dtls1_process_out_of_seq_message()
720 seq64be[7] = (unsigned char)msg_hdr->seq; in dtls1_process_out_of_seq_message()
721 item = pqueue_find(s->d1->buffered_messages, seq64be); in dtls1_process_out_of_seq_message()
724 * If we already have an entry and this one is a fragment, don't discard in dtls1_process_out_of_seq_message()
727 if (item != NULL && frag_len != msg_hdr->msg_len) in dtls1_process_out_of_seq_message()
735 if (msg_hdr->seq <= s->d1->handshake_read_seq || in dtls1_process_out_of_seq_message()
736 msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL || in dtls1_process_out_of_seq_message()
737 (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED)) { in dtls1_process_out_of_seq_message()
741 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, in dtls1_process_out_of_seq_message()
748 frag_len -= readbytes; in dtls1_process_out_of_seq_message()
751 if (frag_len != msg_hdr->msg_len) { in dtls1_process_out_of_seq_message()
762 memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); in dtls1_process_out_of_seq_message()
768 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, in dtls1_process_out_of_seq_message()
769 frag->fragment, frag_len, 0, in dtls1_process_out_of_seq_message()
772 i = -1; in dtls1_process_out_of_seq_message()
781 item = pqueue_insert(s->d1->buffered_messages, item); in dtls1_process_out_of_seq_message()
786 * |msg_hdr->msg_len| in which case |item| is set to NULL and it will in dtls1_process_out_of_seq_message()
804 unsigned char wire[DTLS1_HM_HEADER_LENGTH]; in dtls_get_reassembled_message() local
821 s->init_num = frag_len; in dtls_get_reassembled_message()
827 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &recvd_type, wire, in dtls_get_reassembled_message()
830 s->rwstate = SSL_READING; in dtls_get_reassembled_message()
835 if (wire[0] != SSL3_MT_CCS) { in dtls_get_reassembled_message()
841 memcpy(s->init_buf->data, wire, readbytes); in dtls_get_reassembled_message()
842 s->init_num = readbytes - 1; in dtls_get_reassembled_message()
843 s->init_msg = s->init_buf->data + 1; in dtls_get_reassembled_message()
844 s->s3.tmp.message_type = SSL3_MT_CHANGE_CIPHER_SPEC; in dtls_get_reassembled_message()
845 s->s3.tmp.message_size = readbytes - 1; in dtls_get_reassembled_message()
846 *len = readbytes - 1; in dtls_get_reassembled_message()
857 dtls1_get_message_header(wire, &msg_hdr); in dtls_get_reassembled_message()
867 if (frag_len > RECORD_LAYER_get_rrec_length(&s->rlayer)) { in dtls_get_reassembled_message()
874 * (or dropped)--no further processing at this time in dtls_get_reassembled_message()
878 if (msg_hdr.seq != s->d1->handshake_read_seq) { in dtls_get_reassembled_message()
879 if (!s->server in dtls_get_reassembled_message()
881 || s->d1->handshake_read_seq != 1 in dtls_get_reassembled_message()
882 || wire[0] != SSL3_MT_CLIENT_HELLO in dtls_get_reassembled_message()
883 || s->statem.hand_state != DTLS_ST_SW_HELLO_VERIFY_REQUEST) { in dtls_get_reassembled_message()
900 if (!s->server in dtls_get_reassembled_message()
901 && s->d1->r_msg_hdr.frag_off == 0 in dtls_get_reassembled_message()
902 && s->statem.hand_state != TLS_ST_OK in dtls_get_reassembled_message()
903 && wire[0] == SSL3_MT_HELLO_REQUEST) { in dtls_get_reassembled_message()
905 * The server may always send 'Hello Request' messages -- we are in dtls_get_reassembled_message()
909 if (wire[1] == 0 && wire[2] == 0 && wire[3] == 0) { in dtls_get_reassembled_message()
910 if (s->msg_callback) in dtls_get_reassembled_message()
911 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, in dtls_get_reassembled_message()
912 wire, DTLS1_HM_HEADER_LENGTH, s, in dtls_get_reassembled_message()
913 s->msg_callback_arg); in dtls_get_reassembled_message()
915 s->init_num = 0; in dtls_get_reassembled_message()
931 (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH; in dtls_get_reassembled_message()
933 i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, in dtls_get_reassembled_message()
941 s->rwstate = SSL_READING; in dtls_get_reassembled_message()
965 s->d1->handshake_read_seq = 0; in dtls_get_reassembled_message()
966 s->d1->next_handshake_write_seq = 0; in dtls_get_reassembled_message()
970 * Note that s->init_num is *not* used as current offset in in dtls_get_reassembled_message()
971 * s->init_buf->data, but as a counter summing up fragments' lengths: as in dtls_get_reassembled_message()
975 *len = s->init_num = frag_len; in dtls_get_reassembled_message()
979 s->init_num = 0; in dtls_get_reassembled_message()
984 /*-
986 * ssl->enc_read_ctx re-init
987 * ssl->rlayer.read_sequence zero
988 * ssl->s3.read_mac_secret re-init
989 * ssl->session->read_sym_enc assign
990 * ssl->session->read_compression assign
991 * ssl->session->read_hash assign
995 if (s->version == DTLS1_BAD_VER) { in dtls_construct_change_cipher_spec()
996 s->d1->next_handshake_write_seq++; in dtls_construct_change_cipher_spec()
998 if (!WPACKET_put_bytes_u16(pkt, s->d1->handshake_write_seq)) { in dtls_construct_change_cipher_spec()
1026 * We're not expecting any more messages from the peer at this point - in dtls_wait_for_dry()
1037 s->s3.in_read_app_data = 2; in dtls_wait_for_dry()
1038 s->rwstate = SSL_READING; in dtls_wait_for_dry()
1083 return seq * 2 - is_ccs; in dtls1_get_queue_priority()
1088 pqueue *sent = s->d1->sent_messages; in dtls1_retransmit_buffered_messages()
1097 frag = (hm_fragment *)item->data; in dtls1_retransmit_buffered_messages()
1100 (frag->msg_header.seq, in dtls1_retransmit_buffered_messages()
1101 frag->msg_header.is_ccs), &found) <= 0) in dtls1_retransmit_buffered_messages()
1102 return -1; in dtls1_retransmit_buffered_messages()
1118 if (!ossl_assert(s->init_off == 0)) in dtls1_buffer_message()
1121 frag = dtls1_hm_fragment_new(s->init_num, 0); in dtls1_buffer_message()
1125 memcpy(frag->fragment, s->init_buf->data, s->init_num); in dtls1_buffer_message()
1128 /* For DTLS1_BAD_VER the header length is non-standard */ in dtls1_buffer_message()
1129 if (!ossl_assert(s->d1->w_msg_hdr.msg_len + in dtls1_buffer_message()
1130 ((s->version == in dtls1_buffer_message()
1132 == (unsigned int)s->init_num)) { in dtls1_buffer_message()
1137 if (!ossl_assert(s->d1->w_msg_hdr.msg_len + in dtls1_buffer_message()
1138 DTLS1_HM_HEADER_LENGTH == (unsigned int)s->init_num)) { in dtls1_buffer_message()
1144 frag->msg_header.msg_len = s->d1->w_msg_hdr.msg_len; in dtls1_buffer_message()
1145 frag->msg_header.seq = s->d1->w_msg_hdr.seq; in dtls1_buffer_message()
1146 frag->msg_header.type = s->d1->w_msg_hdr.type; in dtls1_buffer_message()
1147 frag->msg_header.frag_off = 0; in dtls1_buffer_message()
1148 frag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len; in dtls1_buffer_message()
1149 frag->msg_header.is_ccs = is_ccs; in dtls1_buffer_message()
1152 frag->msg_header.saved_retransmit_state.enc_write_ctx = s->enc_write_ctx; in dtls1_buffer_message()
1153 frag->msg_header.saved_retransmit_state.write_hash = s->write_hash; in dtls1_buffer_message()
1154 frag->msg_header.saved_retransmit_state.compress = s->compress; in dtls1_buffer_message()
1155 frag->msg_header.saved_retransmit_state.session = s->session; in dtls1_buffer_message()
1156 frag->msg_header.saved_retransmit_state.epoch = in dtls1_buffer_message()
1157 DTLS_RECORD_LAYER_get_w_epoch(&s->rlayer); in dtls1_buffer_message()
1162 char)(dtls1_get_queue_priority(frag->msg_header.seq, in dtls1_buffer_message()
1163 frag->msg_header.is_ccs) >> 8); in dtls1_buffer_message()
1166 char)(dtls1_get_queue_priority(frag->msg_header.seq, in dtls1_buffer_message()
1167 frag->msg_header.is_ccs)); in dtls1_buffer_message()
1175 pqueue_insert(s->d1->sent_messages, item); in dtls1_buffer_message()
1194 item = pqueue_find(s->d1->sent_messages, seq64be); in dtls1_retransmit_message()
1202 frag = (hm_fragment *)item->data; in dtls1_retransmit_message()
1204 if (frag->msg_header.is_ccs) in dtls1_retransmit_message()
1209 memcpy(s->init_buf->data, frag->fragment, in dtls1_retransmit_message()
1210 frag->msg_header.msg_len + header_length); in dtls1_retransmit_message()
1211 s->init_num = frag->msg_header.msg_len + header_length; in dtls1_retransmit_message()
1213 dtls1_set_message_header_int(s, frag->msg_header.type, in dtls1_retransmit_message()
1214 frag->msg_header.msg_len, in dtls1_retransmit_message()
1215 frag->msg_header.seq, 0, in dtls1_retransmit_message()
1216 frag->msg_header.frag_len); in dtls1_retransmit_message()
1219 saved_state.enc_write_ctx = s->enc_write_ctx; in dtls1_retransmit_message()
1220 saved_state.write_hash = s->write_hash; in dtls1_retransmit_message()
1221 saved_state.compress = s->compress; in dtls1_retransmit_message()
1222 saved_state.session = s->session; in dtls1_retransmit_message()
1223 saved_state.epoch = DTLS_RECORD_LAYER_get_w_epoch(&s->rlayer); in dtls1_retransmit_message()
1225 s->d1->retransmitting = 1; in dtls1_retransmit_message()
1228 s->enc_write_ctx = frag->msg_header.saved_retransmit_state.enc_write_ctx; in dtls1_retransmit_message()
1229 s->write_hash = frag->msg_header.saved_retransmit_state.write_hash; in dtls1_retransmit_message()
1230 s->compress = frag->msg_header.saved_retransmit_state.compress; in dtls1_retransmit_message()
1231 s->session = frag->msg_header.saved_retransmit_state.session; in dtls1_retransmit_message()
1232 DTLS_RECORD_LAYER_set_saved_w_epoch(&s->rlayer, in dtls1_retransmit_message()
1233 frag->msg_header. in dtls1_retransmit_message()
1236 ret = dtls1_do_write(s, frag->msg_header.is_ccs ? in dtls1_retransmit_message()
1240 s->enc_write_ctx = saved_state.enc_write_ctx; in dtls1_retransmit_message()
1241 s->write_hash = saved_state.write_hash; in dtls1_retransmit_message()
1242 s->compress = saved_state.compress; in dtls1_retransmit_message()
1243 s->session = saved_state.session; in dtls1_retransmit_message()
1244 DTLS_RECORD_LAYER_set_saved_w_epoch(&s->rlayer, saved_state.epoch); in dtls1_retransmit_message()
1246 s->d1->retransmitting = 0; in dtls1_retransmit_message()
1248 (void)BIO_flush(s->wbio); in dtls1_retransmit_message()
1257 s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; in dtls1_set_message_header()
1258 s->d1->next_handshake_write_seq++; in dtls1_set_message_header()
1261 dtls1_set_message_header_int(s, mt, len, s->d1->handshake_write_seq, in dtls1_set_message_header()
1271 struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; in dtls1_set_message_header_int()
1273 msg_hdr->type = mt; in dtls1_set_message_header_int()
1274 msg_hdr->msg_len = len; in dtls1_set_message_header_int()
1275 msg_hdr->seq = seq_num; in dtls1_set_message_header_int()
1276 msg_hdr->frag_off = frag_off; in dtls1_set_message_header_int()
1277 msg_hdr->frag_len = frag_len; in dtls1_set_message_header_int()
1283 struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; in dtls1_fix_message_header()
1285 msg_hdr->frag_off = frag_off; in dtls1_fix_message_header()
1286 msg_hdr->frag_len = frag_len; in dtls1_fix_message_header()
1291 struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; in dtls1_write_message_header()
1293 *p++ = msg_hdr->type; in dtls1_write_message_header()
1294 l2n3(msg_hdr->msg_len, p); in dtls1_write_message_header()
1296 s2n(msg_hdr->seq, p); in dtls1_write_message_header()
1297 l2n3(msg_hdr->frag_off, p); in dtls1_write_message_header()
1298 l2n3(msg_hdr->frag_len, p); in dtls1_write_message_header()
1306 msg_hdr->type = *(data++); in dtls1_get_message_header()
1307 n2l3(data, msg_hdr->msg_len); in dtls1_get_message_header()
1309 n2s(data, msg_hdr->seq); in dtls1_get_message_header()
1310 n2l3(data, msg_hdr->frag_off); in dtls1_get_message_header()
1311 n2l3(data, msg_hdr->frag_len); in dtls1_get_message_header()
1319 s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; in dtls1_set_handshake_header()
1321 s->d1->handshake_write_seq, 0, 0); in dtls1_set_handshake_header()
1348 s->d1->w_msg_hdr.msg_len = msglen - DTLS1_HM_HEADER_LENGTH; in dtls1_close_construct_packet()
1349 s->d1->w_msg_hdr.frag_len = msglen - DTLS1_HM_HEADER_LENGTH; in dtls1_close_construct_packet()
1351 s->init_num = (int)msglen; in dtls1_close_construct_packet()
1352 s->init_off = 0; in dtls1_close_construct_packet()
1355 /* Buffer the message to handle re-xmits */ in dtls1_close_construct_packet()