47 #include "contiki-net.h"
52 struct packetbuf_attr packetbuf_attrs[PACKETBUF_NUM_ATTRS];
53 struct packetbuf_addr packetbuf_addrs[PACKETBUF_NUM_ADDRS];
56 static uint16_t buflen, bufptr;
57 static uint8_t hdrlen;
64 static uint8_t *packetbuf = (uint8_t *)packetbuf_aligned;
69 #define PRINTF(...) printf(__VA_ARGS__)
81 packetbuf_attr_clear();
91 memcpy(packetbuf, from, l);
103 for(i = 0; i < buflen; i++) {
118 return hdrlen + buflen;
132 packetbuf[i + size] = packetbuf[i];
153 PRINTF(
"packetbuf_set_len: len %d\n", len);
178 return bufptr + hdrlen;
188 packetbuf_attr_clear(
void)
191 memset(packetbuf_attrs, 0,
sizeof(packetbuf_attrs));
192 for(i = 0; i < PACKETBUF_NUM_ADDRS; ++i) {
198 packetbuf_attr_copyto(
struct packetbuf_attr *attrs,
199 struct packetbuf_addr *addrs)
201 memcpy(attrs, packetbuf_attrs,
sizeof(packetbuf_attrs));
202 memcpy(addrs, packetbuf_addrs,
sizeof(packetbuf_addrs));
206 packetbuf_attr_copyfrom(
struct packetbuf_attr *attrs,
207 struct packetbuf_addr *addrs)
209 memcpy(packetbuf_attrs, attrs,
sizeof(packetbuf_attrs));
210 memcpy(packetbuf_addrs, addrs,
sizeof(packetbuf_addrs));
213 #if !PACKETBUF_CONF_ATTRS_INLINE
215 packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val)
217 packetbuf_attrs[type].val = val;
222 packetbuf_attr(uint8_t type)
224 return packetbuf_attrs[type].val;
228 packetbuf_set_addr(uint8_t type,
const linkaddr_t *
addr)
230 linkaddr_copy(&packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr, addr);
235 packetbuf_addr(uint8_t type)
237 return &packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr;
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
void packetbuf_clear(void)
Clear and reset the packetbuf.
Default definitions of C compiler quirk work-arounds.
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
const linkaddr_t linkaddr_null
The null Rime address.
int packetbuf_holds_broadcast(void)
Checks whether the current packet is a broadcast.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
Header file for the Rime buffer (packetbuf) management
void packetbuf_compact(void)
Compact the packetbuf.
Header file for the Rime stack
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
int packetbuf_copyfrom(const void *from, uint16_t len)
Copy from external data into the packetbuf.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two Rime addresses.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
uint8_t packetbuf_hdrlen(void)
Get the length of the header in the packetbuf.
int packetbuf_copyto(void *to)
Copy the entire packetbuf to an external buffer.