Contiki-NG
|
The packetbuf module does Contiki's buffer management. More...
Macros | |
#define | PACKETBUF_SIZE 128 |
The size of the packetbuf, in bytes. | |
Functions | |
void | packetbuf_clear (void) |
Clear and reset the packetbuf. More... | |
int | packetbuf_copyfrom (const void *from, uint16_t len) |
Copy from external data into the packetbuf. More... | |
int | packetbuf_copyto (void *to) |
Copy the entire packetbuf to an external buffer. More... | |
int | packetbuf_hdralloc (int size) |
Extend the header of the packetbuf, for outbound packets. More... | |
int | packetbuf_hdrreduce (int size) |
Reduce the header in the packetbuf, for incoming packets. More... | |
void | packetbuf_set_datalen (uint16_t len) |
Set the length of the data in the packetbuf. More... | |
void * | packetbuf_dataptr (void) |
Get a pointer to the data in the packetbuf. More... | |
void * | packetbuf_hdrptr (void) |
Get a pointer to the header in the packetbuf, for outbound packets. More... | |
uint16_t | packetbuf_datalen (void) |
Get the length of the data in the packetbuf. More... | |
uint8_t | packetbuf_hdrlen (void) |
Get the length of the header in the packetbuf. More... | |
uint16_t | packetbuf_totlen (void) |
Get the total length of the header and data in the packetbuf. More... | |
uint16_t | packetbuf_remaininglen (void) |
Get the total length of the remaining space in the packetbuf. More... | |
int | packetbuf_holds_broadcast (void) |
Checks whether the current packet is a broadcast. More... | |
The packetbuf module does Contiki's buffer management.
void packetbuf_clear | ( | void | ) |
Clear and reset the packetbuf.
This function clears the packetbuf and resets all internal state pointers (header size, header pointer, external data pointer). It is used before preparing a packet in the packetbuf.
Definition at line 75 of file packetbuf.c.
Referenced by output().
int packetbuf_copyfrom | ( | const void * | from, |
uint16_t | len | ||
) |
Copy from external data into the packetbuf.
from | A pointer to the data from which to copy |
len | The size of the data to copy |
The | number of bytes that was copied into the packetbuf This function copies data from a pointer into the packetbuf. If the data that is to be copied is larger than the packetbuf, only the data that fits in the packetbuf is copied. The number of bytes that could be copied into the rimbuf is returned. |
Definition at line 84 of file packetbuf.c.
int packetbuf_copyto | ( | void * | to | ) |
Copy the entire packetbuf to an external buffer.
to | A pointer to the buffer to which the data is to be copied |
The | number of bytes that was copied to the external buffer This function copies the packetbuf to an external buffer. Both the data portion and the header portion of the packetbuf is copied. The external buffer to which the packetbuf is to be copied must be able to accomodate at least PACKETBUF_SIZE bytes. The number of bytes that was copied to the external buffer is returned. |
Definition at line 96 of file packetbuf.c.
uint16_t packetbuf_datalen | ( | void | ) |
Get the length of the data in the packetbuf.
Definition at line 155 of file packetbuf.c.
Referenced by packetbuf_totlen(), and sixtop_input().
void * packetbuf_dataptr | ( | void | ) |
Get a pointer to the data in the packetbuf.
This function is used to get a pointer to the data in the packetbuf. The data is either stored in the packetbuf, or referenced to an external location.
Definition at line 143 of file packetbuf.c.
Referenced by output(), and sixtop_input().
int packetbuf_hdralloc | ( | int | size | ) |
Extend the header of the packetbuf, for outbound packets.
size | The number of bytes the header should be extended |
Non-zero | if the header could be extended, zero otherwise This function is used to allocate extra space in the header portion in the packetbuf, when preparing outbound packets for transmission. If the function is unable to allocate sufficient header space, the function returns zero and does not allocate anything. |
Definition at line 107 of file packetbuf.c.
uint8_t packetbuf_hdrlen | ( | void | ) |
Get the length of the header in the packetbuf.
Definition at line 161 of file packetbuf.c.
Referenced by packetbuf_totlen(), and sixtop_input().
void * packetbuf_hdrptr | ( | void | ) |
Get a pointer to the header in the packetbuf, for outbound packets.
Definition at line 149 of file packetbuf.c.
int packetbuf_hdrreduce | ( | int | size | ) |
Reduce the header in the packetbuf, for incoming packets.
size | The number of bytes the header should be reduced |
Non-zero | if the header could be reduced, zero otherwise This function is used to remove the first part of the header in the packetbuf, when processing incoming packets. If the function is unable to remove the requested amount of header space, the function returns zero and does not allocate anything. |
Definition at line 124 of file packetbuf.c.
int packetbuf_holds_broadcast | ( | void | ) |
Checks whether the current packet is a broadcast.
0 | iff current packet is not a broadcast |
Definition at line 231 of file packetbuf.c.
References linkaddr_cmp().
uint16_t packetbuf_remaininglen | ( | void | ) |
Get the total length of the remaining space in the packetbuf.
Definition at line 173 of file packetbuf.c.
References PACKETBUF_SIZE, and packetbuf_totlen().
void packetbuf_set_datalen | ( | uint16_t | len | ) |
Set the length of the data in the packetbuf.
len | The length of the data |
Definition at line 136 of file packetbuf.c.
uint16_t packetbuf_totlen | ( | void | ) |
Get the total length of the header and data in the packetbuf.
Definition at line 167 of file packetbuf.c.
References packetbuf_datalen(), and packetbuf_hdrlen().
Referenced by packetbuf_remaininglen().