Morse Micro IoT SDK  2.11.2
Morse Micro Packet List (mmpkt_list) API

Detailed Description

Data Structures

struct  mmpkt_list
 Structure that can be used as the head of a linked list of mmpkts that counts its length. More...
 

Macros

#define MMPKT_LIST_INIT   { NULL, NULL, 0 }
 Static initializer for mmpkt_list. More...
 
#define MMPKT_LIST_WALK(_lst, _wlk, _nxt)
 Safely walk the mmpkt list. More...
 

Functions

static void mmpkt_list_init (struct mmpkt_list *list)
 Initialization function for mmpkt_list, for cases where MMPKT_LIST_INIT cannot be used. More...
 
static uint32_t mmpkt_list_length (struct mmpkt_list *list)
 Gets the current length of the given mmpkt list. More...
 
void mmpkt_list_prepend (struct mmpkt_list *list, struct mmpkt *mmpkt)
 Add an mmpkt to the start of an mmpkt list. More...
 
void mmpkt_list_append (struct mmpkt_list *list, struct mmpkt *mmpkt)
 Add an mmpkt to the end of an mmpkt list. More...
 
void mmpkt_list_insert_after (struct mmpkt_list *list, struct mmpkt *ref, struct mmpkt *mmpkt)
 Insert an mmpkt into an mmpkt list after a specified list entry. More...
 
void mmpkt_list_remove (struct mmpkt_list *list, struct mmpkt *mmpkt)
 Remove an mmpkt from an mmpkt list. More...
 
struct mmpktmmpkt_list_dequeue (struct mmpkt_list *list)
 Remove the mmpkt at the head of the list and return it. More...
 
uint32_t mmpkt_list_dequeue_multiple (struct mmpkt_list *src, struct mmpkt_list *dst, uint32_t count)
 Remove up to count mmpkts from the head of src and append them to dst. More...
 
struct mmpktmmpkt_list_dequeue_tail (struct mmpkt_list *list)
 Remove the mmpkt at the tail of the list and return it. More...
 
static struct mmpktmmpkt_list_dequeue_all (struct mmpkt_list *list)
 Remove all mmpkts from the list and return as a linked list. More...
 
static bool mmpkt_list_is_empty (struct mmpkt_list *list)
 Checks whether the given mmpkt list is empty. More...
 
static struct mmpktmmpkt_list_peek (struct mmpkt_list *list)
 Returns the head of the mmpkt list. More...
 
static struct mmpktmmpkt_list_peek_tail (struct mmpkt_list *list)
 Returns the tail of the mmpkt list. More...
 
uint32_t mmpkt_list_clear (struct mmpkt_list *list)
 Free all the packets in the given list and reset the list to empty state. More...
 
void mmpkt_list_append_list (struct mmpkt_list *list, struct mmpkt_list *other)
 Insert mmpkts to the end of an mmpkt list, from another mmpkt list. More...
 

Macro Definition Documentation

◆ MMPKT_LIST_INIT

#define MMPKT_LIST_INIT   { NULL, NULL, 0 }

Static initializer for mmpkt_list.

Definition at line 37 of file mmpkt_list.h.

◆ MMPKT_LIST_WALK

#define MMPKT_LIST_WALK (   _lst,
  _wlk,
  _nxt 
)
Value:
if ((_lst)->head != NULL) /* NOLINT(readability/braces) */ \
for (_wlk = (_lst)->head, _nxt = mmpkt_get_next(_wlk); _wlk != NULL; \
_wlk = _nxt, _nxt = _wlk ? mmpkt_get_next(_wlk) : NULL)
static struct mmpkt * mmpkt_get_next(struct mmpkt *mmpkt)
Get the next pointer embedded in the mmpkt.
Definition: mmpkt.h:573

Safely walk the mmpkt list.

Warning
This macro cannot be used following an if statement with no parentheses if there is an else clause. For example, do not do: if (x) MMPKT_LIST_WALK(a,b,c) else foo(); – instead: if (x) { MMPKT_LIST_WALK(a,b,c) } else foo();

Definition at line 210 of file mmpkt_list.h.

Function Documentation

◆ mmpkt_list_append()

void mmpkt_list_append ( struct mmpkt_list list,
struct mmpkt mmpkt 
)

Add an mmpkt to the end of an mmpkt list.

Parameters
listThe list to append to.
mmpktThe mmpkt to append.

◆ mmpkt_list_append_list()

void mmpkt_list_append_list ( struct mmpkt_list list,
struct mmpkt_list other 
)

Insert mmpkts to the end of an mmpkt list, from another mmpkt list.

The mmpkts will be removed from the other list, and the other list will be marked as empty.

Parameters
listThe list to append to.
otherThe list to remove mmpkts from for appending.

◆ mmpkt_list_clear()

uint32_t mmpkt_list_clear ( struct mmpkt_list list)

Free all the packets in the given list and reset the list to empty state.

Parameters
listThe list to clear.
Returns
the number of mmpkts cleared from the list

◆ mmpkt_list_dequeue()

struct mmpkt * mmpkt_list_dequeue ( struct mmpkt_list list)

Remove the mmpkt at the head of the list and return it.

Parameters
listThe list to dequeue from.
Returns
the dequeued mmpkt, or NULL if the list is empty.

◆ mmpkt_list_dequeue_all()

static struct mmpkt * mmpkt_list_dequeue_all ( struct mmpkt_list list)
inlinestatic

Remove all mmpkts from the list and return as a linked list.

Parameters
listThe list to dequeue from.
Returns
the dequeued mmpkts, or NULL if the list is empty.

Definition at line 138 of file mmpkt_list.h.

◆ mmpkt_list_dequeue_multiple()

uint32_t mmpkt_list_dequeue_multiple ( struct mmpkt_list src,
struct mmpkt_list dst,
uint32_t  count 
)

Remove up to count mmpkts from the head of src and append them to dst.

The relative packet order is preserved. If count exceeds the list length, all packets are moved.

Parameters
srcThe list to dequeue from.
dstThe list to append to.
countThe maximum number of packets to dequeue.
Returns
the number of mmpkts dequeued from the list.

◆ mmpkt_list_dequeue_tail()

struct mmpkt * mmpkt_list_dequeue_tail ( struct mmpkt_list list)

Remove the mmpkt at the tail of the list and return it.

Parameters
listThe list to dequeue from.
Returns
the dequeued mmpkt, or NULL if the list is empty.

◆ mmpkt_list_init()

static void mmpkt_list_init ( struct mmpkt_list list)
inlinestatic

Initialization function for mmpkt_list, for cases where MMPKT_LIST_INIT cannot be used.

Parameters
listThe mmpkt_list to init.

Definition at line 45 of file mmpkt_list.h.

◆ mmpkt_list_insert_after()

void mmpkt_list_insert_after ( struct mmpkt_list list,
struct mmpkt ref,
struct mmpkt mmpkt 
)

Insert an mmpkt into an mmpkt list after a specified list entry.

Parameters
listThe list to insert into.
refThe packet to insert after.
mmpktThe mmpkt to insert.

◆ mmpkt_list_is_empty()

static bool mmpkt_list_is_empty ( struct mmpkt_list list)
inlinestatic

Checks whether the given mmpkt list is empty.

Parameters
listThe list to check.
Returns
true if the list is empty, else false.

Definition at line 154 of file mmpkt_list.h.

◆ mmpkt_list_length()

static uint32_t mmpkt_list_length ( struct mmpkt_list list)
inlinestatic

Gets the current length of the given mmpkt list.

Parameters
listThe list to get the length of.
Returns
the current length of list.

Definition at line 59 of file mmpkt_list.h.

◆ mmpkt_list_peek()

static struct mmpkt * mmpkt_list_peek ( struct mmpkt_list list)
inlinestatic

Returns the head of the mmpkt list.

Parameters
listThe list to peek into.
Returns
the mmpkt at the head of the list.

Definition at line 166 of file mmpkt_list.h.

◆ mmpkt_list_peek_tail()

static struct mmpkt * mmpkt_list_peek_tail ( struct mmpkt_list list)
inlinestatic

Returns the tail of the mmpkt list.

Parameters
listThe list to peek into.
Returns
the mmpkt at the tail of the list.

Definition at line 178 of file mmpkt_list.h.

◆ mmpkt_list_prepend()

void mmpkt_list_prepend ( struct mmpkt_list list,
struct mmpkt mmpkt 
)

Add an mmpkt to the start of an mmpkt list.

Parameters
listThe list to prepend to.
mmpktThe mmpkt to prepend.

◆ mmpkt_list_remove()

void mmpkt_list_remove ( struct mmpkt_list list,
struct mmpkt mmpkt 
)

Remove an mmpkt from an mmpkt list.

Parameters
listThe list to remove from.
mmpktThe mmpkt to remove.