Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Packet queue

The packetqueue module handles a list of queued packets.

Data Structures

struct  packetqueue
 Representation of a packet queue. More...
 
struct  packetqueue_item
 Representation of an item in a packet queue. More...
 

Files

file  packetqueue.c
 
    Packet queue management

 
file  packetqueue.h
 
    Header file for the packetqueue module

 

Macros

#define PACKETQUEUE(name, size)
 Define a packet queue. More...
 

Functions

static void remove_queued_packet (void *item)
 

Packet queue functions.

void packetqueue_init (struct packetqueue *q)
 Initialize a packet queue. More...
 
int packetqueue_enqueue_packetbuf (struct packetqueue *q, clock_time_t lifetime, void *ptr)
 Enqueue a packetbuf on a packet queue. More...
 
struct packetqueue_itempacketqueue_first (struct packetqueue *q)
 Access the first item on the packet buffer. More...
 
void packetqueue_dequeue (struct packetqueue *q)
 Remove the first item on the packet buffer. More...
 
int packetqueue_len (struct packetqueue *q)
 Get the length of the packet queue. More...
 

Packet queue item functions

struct queuebufpacketqueue_queuebuf (struct packetqueue_item *i)
 Access the queuebuf in a packet queue item. More...
 
void * packetqueue_ptr (struct packetqueue_item *i)
 Access the user-defined pointer in a packet queue item. More...
 

#define PACKETQUEUE (   name,
  size 
)
Value:
LIST(name##_list); \
MEMB(name##_memb, struct packetqueue_item, size); \
static struct packetqueue name = { &name##_list, \
&name##_memb }
#define LIST(name)
Declare a linked list.
Definition: wireless/SmartConnect_6LoWPAN/core/lib/list.h:88
Representation of a packet queue.
Definition: packetqueue.h:70
Representation of an item in a packet queue.
Definition: packetqueue.h:86
#define MEMB(name, structure, num)
Declare a memory block.
Definition: memb.h:89

Define a packet queue.

Parameters
nameThe variable name of the packet queue
sizeThe maximum size of the packet queue
        This statement defines a packet queue. A packet queue
        is defined on a per-module basis.

void packetqueue_dequeue ( struct packetqueue q)

Remove the first item on the packet buffer.

Parameters
qA pointer to a struct packetqueue.
        This function removes the first item on the packet
        queue. The function does not return the first item: to
        access the first item, the packetqueue_first() function
        must have been used prior to calling
        packetqueue_dequeue().

References packetqueue_item::buf, ctimer_stop(), i, packetqueue_item::lifetimer, list, list_head(), list_remove(), memb, memb_free(), NULL, and queuebuf_free().

int packetqueue_enqueue_packetbuf ( struct packetqueue q,
clock_time_t  lifetime,
void *  ptr 
)

Enqueue a packetbuf on a packet queue.

Parameters
qA pointer to a struct packetqueue.
lifetimeThe maximum time that the packet should stay in the packet queue, or zero if the packet should stay on the packet queue indefinitely.
ptrAn opaque, user-defined pointer that can be used to identify the packet when it later is dequeued.
Return values
ZeroIf memory could not be allocated for the packet.
Non-zeroIf the packet was successfully enqueued.
        This function enqueues the \ref packetbuf "packetbuf"
        to the packet queue pointed to by the q parameter. The
        packet queue must previously have been defined with
        PACKETQUEUE() and initialized with packetqueue_init().

        Each packet queue item has a maximum lifetime. When the
        lifetime expires, the packet queue item is
        automatically removed from the packet queue. If the
        lifetime parameter is given as zero, the packet never
        times out from the packet queue.

        Each packet queue item is tagged with a user-defined
        pointer. This pointer can be used to identify packets
        as they later are dequeued from the queue. This is
        useful if two modules is using the same packet queue:
        the modules can use the pointer to distinguish to which
        module a dequeued packet belongs.

References packetqueue_item::buf, ctimer_set(), i, packetqueue_item::lifetimer, list, list_add(), memb, memb_alloc(), memb_free(), NULL, packetqueue_item::ptr, ptr, packetqueue_item::queue, queuebuf_new_from_packetbuf(), and remove_queued_packet().

struct packetqueue_item * packetqueue_first ( struct packetqueue q)

Access the first item on the packet buffer.

Parameters
qA pointer to a struct packetqueue.
Returns
A pointer to the first item on the packet queue.
        This function returns the first item on the packet
        queue. The packet queue is unchanged by this
        function. To dequeue the first item on the list, use
        the packetqueue_dequeue() function.

References list, and list_head().

void packetqueue_init ( struct packetqueue q)

Initialize a packet queue.

Parameters
qA pointer to a struct packetqueue that was defined with PACKETQUEUE().
        This function initializes a packetqueue that has
        previously been defined with PACKETQUEUE().

References list, list_init(), memb, and memb_init().

int packetqueue_len ( struct packetqueue q)

Get the length of the packet queue.

Parameters
qA pointer to a struct packetqueue.
Returns
The number of packets queued on the packet queue
        This function returns the number of packets that are
        queued on the packet queue.

References list, and list_length().

void * packetqueue_ptr ( struct packetqueue_item i)

Access the user-defined pointer in a packet queue item.

Parameters
iA packet queue item, obtained with packetqueue_first().
Returns
A pointer to the user-defined pointer in the packet queue item.

References NULL, and packetqueue_item::ptr.

struct queuebuf * packetqueue_queuebuf ( struct packetqueue_item i)

Access the queuebuf in a packet queue item.

Parameters
iA packet queue item, obtained with packetqueue_first().
Returns
A pointer to the queuebuf in the packet queue item.

References packetqueue_item::buf, and NULL.

static void remove_queued_packet ( void *  item)
static