/* If it's the first fragment being created, fh will not own any offset (so it will be 1 byte smaller)  */
struct net_buf* ieee802154_6lo_fragment(struct ieee802154_6lo_fragment_ctx *ctx, struct net_buf *frame_buf, bool iphc)
/* If it's the first fragment being created, fh will not own any offset (so it will be 1 byte smaller)  */
struct net_buf* ieee802154_6lo_fragment(struct ieee802154_6lo_fragment_ctx *ctx, struct net_buf *frame_buf, bool iphc)
{
	uint8_t capacity;
	set_up_frag_hdr(frame_buf, ctx->pkt_size, ctx->offset);
	capacity = calc_payload_capacity(frame_buf);
	ctx->processed += capacity;
	bool is_first_frag = !ctx->offset;
	if (is_first_frag) {
		if (iphc) {
			capacity -= ctx->hdr_diff;
		} else {
			capacity += 1U;
		}
	}
	while (capacity && ctx->buf) {
		uint8_t moved = copy_data(ctx, frame_buf, capacity);
		update_fragment_ctx(ctx, moved);
		capacity -= moved;
	}
	ctx->offset = ctx->processed >> 3;
	return ctx->buf;
}