Packet queue
[The Rime communication stack]

The packetqueue module handles a list of queued packets. More...

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.


Defines

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

Packet queue functions.



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

Packet queue item functions



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

Detailed Description

The packetqueue module handles a list of queued packets.


Define Documentation

#define PACKETQUEUE ( name,
size   ) 
Value:
LIST(name##_list); \
                                MEMB(name##_memb, struct packetqueue_item, size); \
                                static struct packetqueue name = { &name##_list, \
                                                                   &name##_memb }

Define a packet queue.

Parameters:
name The variable name of the packet queue
size The maximum size of the packet queue

This statement defines a packet queue. A packet queue is defined on a per-module basis.

Definition at line 105 of file packetqueue.h.


Function Documentation

void packetqueue_dequeue ( struct packetqueue q  ) 

Remove the first item on the packet buffer.

Parameters:
q A 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().

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

Enqueue a packetbuf on a packet queue.

Parameters:
q A pointer to a struct packetqueue.
lifetime The maximum time that the packet should stay in the packet queue, or zero if the packet should stay on the packet queue indefinitely.
ptr An opaque, user-defined pointer that can be used to identify the packet when it later is dequeued.
Return values:
Zero If memory could not be allocated for the packet.
Non-zero If the packet was successfully enqueued.

This function enqueues the 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.

struct packetqueue_item * packetqueue_first ( struct packetqueue q  )  [read]

Access the first item on the packet buffer.

Parameters:
q A 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.

void packetqueue_init ( struct packetqueue q  ) 

Initialize a packet queue.

Parameters:
q A pointer to a struct packetqueue that was defined with PACKETQUEUE().

This function initializes a packetqueue that has previously been defined with PACKETQUEUE().

int packetqueue_len ( struct packetqueue q  ) 

Get the length of the packet queue.

Parameters:
q A 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.

void * packetqueue_ptr ( struct packetqueue_item i  ) 

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

Parameters:
i A packet queue item, obtained with packetqueue_first().
Returns:
A pointer to the user-defined pointer in the packet queue item.
struct queuebuf * packetqueue_queuebuf ( struct packetqueue_item i  )  [read]

Access the queuebuf in a packet queue item.

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

Generated on Mon Apr 11 14:23:51 2011 for Contiki 2.5 by  doxygen 1.6.1