Lines Matching refs:frag
149 hm_fragment *frag = OPENSSL_malloc(sizeof(hm_fragment)); in dtls1_hm_fragment_new() local
150 if (frag == NULL) { in dtls1_hm_fragment_new()
154 memset(frag, 0, sizeof(hm_fragment)); in dtls1_hm_fragment_new()
159 frag->fragment = OPENSSL_malloc(frag_len); in dtls1_hm_fragment_new()
160 if (frag->fragment == NULL) { in dtls1_hm_fragment_new()
172 frag->reassembly = OPENSSL_malloc(bitmask_len); in dtls1_hm_fragment_new()
173 if (frag->reassembly == NULL) { in dtls1_hm_fragment_new()
177 memset(frag->reassembly, 0, bitmask_len); in dtls1_hm_fragment_new()
181 return frag; in dtls1_hm_fragment_new()
184 dtls1_hm_fragment_free(frag); in dtls1_hm_fragment_new()
188 void dtls1_hm_fragment_free(hm_fragment *frag) { in dtls1_hm_fragment_free() argument
189 if (frag == NULL) { in dtls1_hm_fragment_free()
192 OPENSSL_free(frag->fragment); in dtls1_hm_fragment_free()
193 OPENSSL_free(frag->reassembly); in dtls1_hm_fragment_free()
194 OPENSSL_free(frag); in dtls1_hm_fragment_free()
211 static void dtls1_hm_fragment_mark(hm_fragment *frag, size_t start, in dtls1_hm_fragment_mark() argument
214 size_t msg_len = frag->msg_header.msg_len; in dtls1_hm_fragment_mark()
216 if (frag->reassembly == NULL || start > end || end > msg_len) { in dtls1_hm_fragment_mark()
224 frag->reassembly[start >> 3] |= bit_range(start & 7, end & 7); in dtls1_hm_fragment_mark()
226 frag->reassembly[start >> 3] |= bit_range(start & 7, 8); in dtls1_hm_fragment_mark()
228 frag->reassembly[i] = 0xff; in dtls1_hm_fragment_mark()
231 frag->reassembly[end >> 3] |= bit_range(0, end & 7); in dtls1_hm_fragment_mark()
237 if (frag->reassembly[i] != 0xff) { in dtls1_hm_fragment_mark()
242 frag->reassembly[msg_len >> 3] != bit_range(0, msg_len & 7)) { in dtls1_hm_fragment_mark()
246 OPENSSL_free(frag->reassembly); in dtls1_hm_fragment_mark()
247 frag->reassembly = NULL; in dtls1_hm_fragment_mark()
420 hm_fragment *frag = (hm_fragment *)item->data; in dtls1_is_next_message_complete() local
421 assert(ssl->d1->handshake_read_seq <= frag->msg_header.seq); in dtls1_is_next_message_complete()
423 return ssl->d1->handshake_read_seq == frag->msg_header.seq && in dtls1_is_next_message_complete()
424 frag->reassembly == NULL; in dtls1_is_next_message_complete()
457 hm_fragment *frag; in dtls1_get_buffered_message() local
460 frag = dtls1_hm_fragment_new(msg_hdr->msg_len, in dtls1_get_buffered_message()
462 if (frag == NULL) { in dtls1_get_buffered_message()
465 memcpy(&frag->msg_header, msg_hdr, sizeof(*msg_hdr)); in dtls1_get_buffered_message()
466 item = pitem_new(seq64be, frag); in dtls1_get_buffered_message()
468 dtls1_hm_fragment_free(frag); in dtls1_get_buffered_message()
476 frag = item->data; in dtls1_get_buffered_message()
477 assert(frag->msg_header.seq == msg_hdr->seq); in dtls1_get_buffered_message()
478 if (frag->msg_header.type != msg_hdr->type || in dtls1_get_buffered_message()
479 frag->msg_header.msg_len != msg_hdr->msg_len) { in dtls1_get_buffered_message()
487 return frag; in dtls1_get_buffered_message()
545 hm_fragment *frag = dtls1_get_buffered_message(ssl, &msg_hdr); in dtls1_process_fragment() local
546 if (frag == NULL) { in dtls1_process_fragment()
549 assert(frag->msg_header.msg_len == msg_len); in dtls1_process_fragment()
551 if (frag->reassembly == NULL) { in dtls1_process_fragment()
561 ret = dtls1_read_bytes(ssl, SSL3_RT_HANDSHAKE, frag->fragment + frag_off, in dtls1_process_fragment()
568 dtls1_hm_fragment_mark(frag, frag_off, frag_off + frag_len); in dtls1_process_fragment()
579 hm_fragment *frag = NULL; in dtls1_get_message() local
613 frag = (hm_fragment *)item->data; in dtls1_get_message()
614 assert(ssl->d1->handshake_read_seq == frag->msg_header.seq); in dtls1_get_message()
615 assert(frag->reassembly == NULL); in dtls1_get_message()
617 if (frag->msg_header.msg_len > (size_t)max) { in dtls1_get_message()
626 if (!BUF_MEM_grow(ssl->init_buf, (size_t)frag->msg_header.msg_len + in dtls1_get_message()
630 !CBB_add_u8(&cbb, frag->msg_header.type) || in dtls1_get_message()
631 !CBB_add_u24(&cbb, frag->msg_header.msg_len) || in dtls1_get_message()
632 !CBB_add_u16(&cbb, frag->msg_header.seq) || in dtls1_get_message()
634 !CBB_add_u24(&cbb, frag->msg_header.msg_len) || in dtls1_get_message()
635 !CBB_add_bytes(&cbb, frag->fragment, frag->msg_header.msg_len) || in dtls1_get_message()
641 assert(len == (size_t)frag->msg_header.msg_len + DTLS1_HM_HEADER_LENGTH); in dtls1_get_message()
647 ssl->s3->tmp.message_type = frag->msg_header.type; in dtls1_get_message()
648 ssl->s3->tmp.message_size = frag->msg_header.msg_len; in dtls1_get_message()
650 ssl->init_num = frag->msg_header.msg_len; in dtls1_get_message()
667 dtls1_hm_fragment_free(frag); in dtls1_get_message()
677 dtls1_hm_fragment_free(frag); in dtls1_get_message()
717 static int dtls1_retransmit_message(SSL *ssl, hm_fragment *frag) { in dtls1_retransmit_message() argument
721 assert(frag->msg_header.epoch <= ssl->d1->w_epoch); in dtls1_retransmit_message()
723 if (ssl->d1->w_epoch == 1 && frag->msg_header.epoch == 0) { in dtls1_retransmit_message()
729 if (frag->msg_header.is_ccs) { in dtls1_retransmit_message()
734 memcpy(ssl->init_buf->data, frag->fragment, in dtls1_retransmit_message()
735 frag->msg_header.msg_len + DTLS1_HM_HEADER_LENGTH); in dtls1_retransmit_message()
736 ssl->init_num = frag->msg_header.msg_len + DTLS1_HM_HEADER_LENGTH; in dtls1_retransmit_message()
738 dtls1_set_message_header(ssl, frag->msg_header.type, in dtls1_retransmit_message()
739 frag->msg_header.msg_len, frag->msg_header.seq, in dtls1_retransmit_message()
740 0, frag->msg_header.frag_len); in dtls1_retransmit_message()
756 hm_fragment *frag = (hm_fragment *)item->data; in dtls1_retransmit_buffered_messages() local
757 if (dtls1_retransmit_message(ssl, frag) <= 0) { in dtls1_retransmit_buffered_messages()
769 hm_fragment *frag = dtls1_hm_fragment_new(0 /* frag_len */, in dtls1_buffer_change_cipher_spec() local
771 if (frag == NULL) { in dtls1_buffer_change_cipher_spec()
774 frag->msg_header.is_ccs = 1; in dtls1_buffer_change_cipher_spec()
775 frag->msg_header.epoch = ssl->d1->w_epoch; in dtls1_buffer_change_cipher_spec()
783 pitem *item = pitem_new(seq64be, frag); in dtls1_buffer_change_cipher_spec()
785 dtls1_hm_fragment_free(frag); in dtls1_buffer_change_cipher_spec()
798 hm_fragment *frag = dtls1_hm_fragment_new(ssl->init_num, 0); in dtls1_buffer_message() local
799 if (!frag) { in dtls1_buffer_message()
803 memcpy(frag->fragment, ssl->init_buf->data, ssl->init_num); in dtls1_buffer_message()
808 frag->msg_header.msg_len = ssl->d1->w_msg_hdr.msg_len; in dtls1_buffer_message()
809 frag->msg_header.seq = ssl->d1->w_msg_hdr.seq; in dtls1_buffer_message()
810 frag->msg_header.type = ssl->d1->w_msg_hdr.type; in dtls1_buffer_message()
811 frag->msg_header.frag_off = 0; in dtls1_buffer_message()
812 frag->msg_header.frag_len = ssl->d1->w_msg_hdr.msg_len; in dtls1_buffer_message()
813 frag->msg_header.is_ccs = 0; in dtls1_buffer_message()
814 frag->msg_header.epoch = ssl->d1->w_epoch; in dtls1_buffer_message()
816 uint16_t priority = dtls1_get_queue_priority(frag->msg_header.seq, in dtls1_buffer_message()
823 pitem *item = pitem_new(seq64be, frag); in dtls1_buffer_message()
825 dtls1_hm_fragment_free(frag); in dtls1_buffer_message()