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