Lines Matching +full:header +full:- +full:payload

4  * SPDX-License-Identifier: Apache-2.0
52 * If an entire payload (e.g., IPv6) datagram fits within a single 802.15.4
54 * a fragmentation header. If the datagram does not fit within a single
61 * Functionality is comprised of link-local IPv6 addresses and stateless
62 * IPv6 address autoconfiguration, Neighbor Discovery, and header compression
64 * LE's link-layer fragmentation support.
70 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 * +-+-+-+-+-+-+-+-+
100 uint8_t pos = frag->len; in set_up_frag_hdr()
105 frag->data[pos] = NET_6LO_DISPATCH_FRAG1; in set_up_frag_hdr()
108 frag->data[pos] = NET_6LO_DISPATCH_FRAGN; in set_up_frag_hdr()
111 set_datagram_size(frag->data + pos, size); in set_up_frag_hdr()
114 set_datagram_tag(frag->data + pos, datagram_tag); in set_up_frag_hdr()
118 frag->data[pos] = offset; in set_up_frag_hdr()
124 uint8_t capacity = frag->size - frag->len; in calc_payload_capacity()
132 uint8_t remainder = ctx->buf->len - (ctx->pos - ctx->buf->data); in copy_data()
135 memcpy(frame_buf->data + frame_buf->len, ctx->pos, move); in copy_data()
143 uint8_t remainder = (ctx->buf->len - (ctx->pos - ctx->buf->data)); in update_fragment_ctx()
147 ctx->buf = ctx->buf->frags; in update_fragment_ctx()
148 if (ctx->buf) { in update_fragment_ctx()
149 ctx->pos = ctx->buf->data; in update_fragment_ctx()
152 ctx->pos += moved; in update_fragment_ctx()
157 * ch : compressed (IPv6) header(s)
158 * fh : fragment header (dispatch + size + tag + [offset])
159 * p : payload (first fragment holds IPv6 hdr as payload)
173 * Space in every fragment is because fragment payload should be multiple
185 set_up_frag_hdr(frame_buf, ctx->pkt_size, ctx->offset); in ieee802154_6lo_fragment()
188 ctx->processed += capacity; in ieee802154_6lo_fragment()
190 bool is_first_frag = !ctx->offset; in ieee802154_6lo_fragment()
195 capacity -= ctx->hdr_diff; in ieee802154_6lo_fragment()
197 /* Adding IPv6 dispatch header */ in ieee802154_6lo_fragment()
202 while (capacity && ctx->buf) { in ieee802154_6lo_fragment()
206 capacity -= moved; in ieee802154_6lo_fragment()
209 ctx->offset = ctx->processed >> 3; in ieee802154_6lo_fragment()
211 return ctx->buf; in ieee802154_6lo_fragment()
236 NET_ERR("Could not get IPv6 header"); in update_protocol_header_lengths()
241 ipv6->len = htons(size - NET_IPV6H_LEN); in update_protocol_header_lengths()
245 if (ipv6->nexthdr == IPPROTO_UDP) { in update_protocol_header_lengths()
251 udp->len = htons(size - NET_IPV6H_LEN); in update_protocol_header_lengths()
254 NET_ERR("Could not get UDP header"); in update_protocol_header_lengths()
289 if (fcache->pkt) { in reass_timeout()
290 net_pkt_unref(fcache->pkt); in reass_timeout()
293 fcache->pkt = NULL; in reass_timeout()
294 fcache->size = 0U; in reass_timeout()
295 fcache->tag = 0U; in reass_timeout()
296 fcache->used = false; in reass_timeout()
347 if (get_datagram_type(frag->data) == NET_6LO_DISPATCH_FRAG1) { in fragment_append()
351 frag->frags = pkt->buffer; in fragment_append()
352 pkt->buffer = frag; in fragment_append()
365 frag = pkt->buffer; in fragment_cached_pkt_len()
369 if (get_datagram_type(frag->data) == NET_6LO_DISPATCH_FRAG1) { in fragment_cached_pkt_len()
373 len += frag->len - frag_hdr_len; in fragment_cached_pkt_len()
375 frag = frag->frags; in fragment_cached_pkt_len()
378 /* 6lo assumes that fragment header has been removed, in fragment_cached_pkt_len()
381 data = pkt->buffer->data; in fragment_cached_pkt_len()
382 pkt->buffer->data += NET_6LO_FRAG1_HDR_LEN; in fragment_cached_pkt_len()
386 pkt->buffer->data = data; in fragment_cached_pkt_len()
397 if (get_datagram_type(frag->data) == NET_6LO_DISPATCH_FRAG1) { in fragment_offset()
401 return ((uint16_t)frag->data[NET_FRAG_OFFSET_POS] << 3); in fragment_offset()
409 current = pkt->buffer; in fragment_move_back()
414 prev->frags = frag; in fragment_move_back()
417 frag->frags = current; in fragment_move_back()
422 current = current->frags; in fragment_move_back()
430 frag = pkt->buffer; in fragment_remove_headers()
434 if (get_datagram_type(frag->data) == NET_6LO_DISPATCH_FRAG1) { in fragment_remove_headers()
438 memmove(frag->data, frag->data + frag_hdr_len, frag->len - frag_hdr_len); in fragment_remove_headers()
439 frag->len -= frag_hdr_len; in fragment_remove_headers()
441 frag = frag->frags; in fragment_remove_headers()
450 current = pkt->buffer; in fragment_reconstruct_packet()
453 next = current->frags; in fragment_reconstruct_packet()
470 return (get_datagram_type(pkt->buffer->data) == NET_6LO_DISPATCH_FRAG1); in fragment_packet_valid()
476 * Remove the fragmentation header and uncompress IPv6 and related headers.
490 frag = pkt->buffer; in fragment_add_to_cache()
491 type = get_datagram_type(frag->data); in fragment_add_to_cache()
493 if ((type == NET_6LO_DISPATCH_FRAG1 && frag->len < NET_6LO_FRAG1_HDR_LEN) || in fragment_add_to_cache()
494 (type == NET_6LO_DISPATCH_FRAGN && frag->len < NET_6LO_FRAGN_HDR_LEN)) { in fragment_add_to_cache()
495 NET_ERR("Fragment too short (%u): fragment dropped", frag->len); in fragment_add_to_cache()
500 size = get_datagram_size(frag->data); in fragment_add_to_cache()
503 tag = get_datagram_tag(frag->data + NET_6LO_FRAG_DATAGRAM_SIZE_LEN); in fragment_add_to_cache()
508 pkt->buffer = NULL; in fragment_add_to_cache()
517 pkt->buffer = frag; in fragment_add_to_cache()
524 fragment_append(fcache->pkt, frag); in fragment_add_to_cache()
526 if (fragment_cached_pkt_len(fcache->pkt) == fcache->size) { in fragment_add_to_cache()
527 /* All fragments received - reassemble packet. */ in fragment_add_to_cache()
531 pkt->buffer = fcache->pkt->buffer; in fragment_add_to_cache()
532 fcache->pkt->buffer = NULL; in fragment_add_to_cache()
534 /* In case pkt == fcache->pkt, we don't want in fragment_add_to_cache()
537 fcache->pkt = NULL; in fragment_add_to_cache()
550 NET_ERR("Invalid 6LoWPAN header: packet dropped"); in fragment_add_to_cache()
575 if (!pkt || !pkt->buffer) { in ieee802154_6lo_reassemble()
576 NET_WARN("Empty payload: packet dropped"); in ieee802154_6lo_reassemble()
580 if (get_datagram_type(pkt->buffer->data) >= NET_6LO_DISPATCH_FRAG1) { in ieee802154_6lo_reassemble()
583 NET_DBG("No frag dispatch (%02x)", pkt->buffer->data[0]); in ieee802154_6lo_reassemble()
589 NET_ERR("Invalid header: packet dropped"); in ieee802154_6lo_reassemble()