|
Contiki-Inga 3.x
|
The packetqueue module handles a list of queued packets. More...
Files | |
| file | packetqueue.c |
Packet queue management | |
| file | packetqueue.h |
Header file for the packetqueue module | |
Data Structures | |
| struct | packetqueue |
| Representation of a packet queue. More... | |
| struct | packetqueue_item |
| Representation of an item in a packet queue. More... | |
Macros | |
| #define | PACKETQUEUE(name, size) |
| Define a packet queue. More... | |
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_item * | packetqueue_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 queuebuf * | packetqueue_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... | |
The packetqueue module handles a list of queued packets.
| #define PACKETQUEUE | ( | name, | |
| size | |||
| ) |
Define a packet queue.
| 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 104 of file packetqueue.h.
| void packetqueue_dequeue | ( | struct packetqueue * | q | ) |
Remove the first item on the packet buffer.
| 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(). |
Definition at line 112 of file packetqueue.c.
References ctimer_stop(), list_head(), list_remove(), memb_free(), and NULL.
| int packetqueue_enqueue_packetbuf | ( | struct packetqueue * | q, |
| clock_time_t | lifetime, | ||
| void * | ptr | ||
| ) |
Enqueue a packetbuf on a packet queue.
| 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. |
| Zero | If memory could not be allocated for the packet. |
| Non-zero | If 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. |
Definition at line 69 of file packetqueue.c.
References ctimer_set(), list_add(), memb_alloc(), memb_free(), and NULL.
|
read |
Access the first item on the packet buffer.
| q | A pointer to a struct packetqueue. |
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. Definition at line 106 of file packetqueue.c.
References list_head().
| void packetqueue_init | ( | struct packetqueue * | q | ) |
Initialize a packet queue.
| q | A pointer to a struct packetqueue that was defined with PACKETQUEUE(). This function initializes a packetqueue that has
previously been defined with PACKETQUEUE(). |
Definition at line 49 of file packetqueue.c.
References list_init(), and memb_init().
| int packetqueue_len | ( | struct packetqueue * | q | ) |
Get the length of the packet queue.
| q | A pointer to a struct packetqueue. |
This function returns the number of packets that are
queued on the packet queue. Definition at line 126 of file packetqueue.c.
References list_length().
| void * packetqueue_ptr | ( | struct packetqueue_item * | i | ) |
Access the user-defined pointer in a packet queue item.
| i | A packet queue item, obtained with packetqueue_first(). |
Definition at line 142 of file packetqueue.c.
References NULL.
|
read |
Access the queuebuf in a packet queue item.
| i | A packet queue item, obtained with packetqueue_first(). |
Definition at line 132 of file packetqueue.c.
References NULL.
1.8.3.1