33#ifndef MM_FAST_ROUND_UP
34#define MM_FAST_ROUND_UP(x, m) ((((x)-1) | ((m)-1)) + 1)
37struct mmdrv_cmd_metadata;
38struct mmdrv_tx_metadata;
39struct mmdrv_rx_metadata;
52 struct mmdrv_tx_metadata *
tx;
54 struct mmdrv_rx_metadata *
rx;
56 struct mmdrv_cmd_metadata *
cmd;
126 uint32_t data_start_offset,
const struct mmpkt_ops *ops)
153 uint32_t space_at_start, uint32_t space_at_end,
163 if (space_at_end != UINT32_MAX)
175 if ((int32_t)
data_len < (int32_t)space_at_start)
186 data_start = ((uint8_t *)
mmpkt) + header_size;
190 if (metadata_size != 0)
213 uint32_t metadata_size);
238 return (
struct mmpktview *)
mmpkt;
261 return (
struct mmpkt *)view;
379 memcpy(dest, data, len);
395static inline uint8_t *
mmpkt_append(
struct mmpktview *view, uint32_t len)
416 memcpy(dest, data, len);
551 return ((
const uint8_t *)ptr >= &
mmpkt->
buf[0]
#define MMOSAL_ASSERT(expr)
Assert that the given expression evaluates to true and abort execution if not.
struct mmpkt * mmpkt_alloc_on_heap(uint32_t space_at_start, uint32_t space_at_end, uint32_t metadata_size)
Allocate a new mmpkt on the heap (using mmosal_malloc()).
static void mmpkt_append_data(struct mmpktview *view, const uint8_t *data, uint32_t len)
Appends the given data to the data already in the mmpkt.
static struct mmpkt * mmpkt_init_buf(uint8_t *buf, uint32_t buf_len, uint32_t space_at_start, uint32_t space_at_end, uint32_t metadata_size, const struct mmpkt_ops *ops)
Initialize an mmpkt in a single buffer using the given values.
static struct mmpkt * mmpkt_from_view(struct mmpktview *view)
Get the underlying mmpkt from an opened view.
static void mmpkt_close(struct mmpktview **view)
Close the given view.
void mmpkt_release(struct mmpkt *mmpkt)
Release a reference to the given mmpkt.
static void mmpkt_init(struct mmpkt *mmpkt, uint8_t *buf, uint32_t buf_len, uint32_t data_start_offset, const struct mmpkt_ops *ops)
Initialize an mmpkt header with the given values.
static union mmpkt_metadata_ptr mmpkt_get_metadata(struct mmpkt *mmpkt)
Retrieve a reference to the metadata associated with the given mmpkt.
static struct mmpkt * mmpkt_get_next(struct mmpkt *mmpkt)
Get the next pointer embedded in the mmpkt.
static void mmpkt_adjust_start_offset(struct mmpkt *mmpkt, int32_t delta)
Adjust the start offset of an mmpkt.
static uint32_t mmpkt_available_space_at_start(struct mmpktview *view)
Returns the amount of space available for prepending to the data in the buffer.
static uint32_t mmpkt_peek_data_length(struct mmpkt *mmpkt)
Peek the length of the data currently from an unopened mmpkt.
#define MM_FAST_ROUND_UP(x, m)
Round x up to the next multiple of m (where m is a power of 2).
static uint8_t * mmpkt_get_data_end(struct mmpktview *view)
Gets a pointer to the end of the data in the mmpkt.
static uint8_t * mmpkt_prepend(struct mmpktview *view, uint32_t len)
Reserves space immediately before the data currently in the given mmpkt and returns a pointer to this...
static void mmpkt_truncate(struct mmpkt *mmpkt, uint32_t len)
Truncate the mmpkt data to the given length.
static uint32_t mmpkt_get_data_length(struct mmpktview *view)
Gets the length of the data currently in the mmpkt.
static uint32_t mmpkt_available_space_at_end(struct mmpktview *view)
Returns the amount of space available for appending to the data in the buffer.
static void mmpkt_prepend_data(struct mmpktview *view, const uint8_t *data, uint32_t len)
Prepends the given data to the data already in the mmpkt.
static uint8_t * mmpkt_remove_from_end(struct mmpktview *view, uint32_t len)
Remove data from the end of the mmpkt.
static struct mmpktview * mmpkt_open(struct mmpkt *mmpkt)
Open a view of the given mmpkt.
static uint8_t * mmpkt_append(struct mmpktview *view, uint32_t len)
Reserves space immediately after the data currently in the given mmpkt and returns a pointer to this ...
static uint8_t * mmpkt_get_data_start(struct mmpktview *view)
Gets a pointer to the start of the data in the mmpkt.
static bool mmpkt_contains_ptr(struct mmpktview *view, const void *ptr)
Check whether the given pointer is pointing inside the mmpkt's buffer.
static uint8_t * mmpkt_remove_from_start(struct mmpktview *view, uint32_t len)
Remove data from the start of the mmpkt.
static void mmpkt_set_next(struct mmpkt *mmpkt, struct mmpkt *next)
Set the next pointer embedded in the mmpkt.
char buf[1408]
Statically allocated buffer for HTTP GET request, just under 1 packet size.
Operations data structure for mmpkt.
void(* free_mmpkt)(void *mmpkt)
Free the given mmpkt.
Core mmpkt data structure.
uint32_t buf_len
Length of the buffer.
uint32_t data_len
Length of actual data in the buffer.
uint32_t start_offset
Offset where actual data starts in the buffer.
const struct mmpkt_ops * ops
Reference to operations data structure for this mmpkt.
uint8_t * buf
The buffer where data is stored.
union mmpkt_metadata_ptr metadata
Packet metadata used by driver (context dependent).
struct mmpkt *volatile next
Pointer that can be used to construct linked lists.