47 #include "contiki-net.h" 51 struct packetbuf_attr packetbuf_attrs[PACKETBUF_NUM_ATTRS];
52 struct packetbuf_addr packetbuf_addrs[PACKETBUF_NUM_ADDRS];
55 static uint16_t buflen, bufptr;
56 static uint8_t hdrlen;
63 static uint8_t *packetbuf = (uint8_t *)packetbuf_aligned;
68 #define PRINTF(...) printf(__VA_ARGS__) 80 packetbuf_attr_clear();
90 memcpy(packetbuf, from, l);
103 return hdrlen + buflen;
117 packetbuf[i + size] = packetbuf[i];
138 PRINTF(
"packetbuf_set_len: len %d\n", len);
163 return bufptr + hdrlen;
179 packetbuf_attr_clear(
void)
182 memset(packetbuf_attrs, 0,
sizeof(packetbuf_attrs));
183 for(i = 0; i < PACKETBUF_NUM_ADDRS; ++i) {
189 packetbuf_attr_copyto(
struct packetbuf_attr *attrs,
190 struct packetbuf_addr *addrs)
192 memcpy(attrs, packetbuf_attrs,
sizeof(packetbuf_attrs));
193 memcpy(addrs, packetbuf_addrs,
sizeof(packetbuf_addrs));
197 packetbuf_attr_copyfrom(
struct packetbuf_attr *attrs,
198 struct packetbuf_addr *addrs)
200 memcpy(packetbuf_attrs, attrs,
sizeof(packetbuf_attrs));
201 memcpy(packetbuf_addrs, addrs,
sizeof(packetbuf_addrs));
205 packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val)
207 packetbuf_attrs[type].val = val;
212 packetbuf_attr(uint8_t type)
214 return packetbuf_attrs[type].val;
218 packetbuf_set_addr(uint8_t type,
const linkaddr_t *
addr)
220 linkaddr_copy(&packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr, addr);
225 packetbuf_addr(uint8_t type)
227 return &packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr;
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
void packetbuf_clear(void)
Clear and reset the packetbuf.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
uint16_t packetbuf_remaininglen(void)
Get the total length of the remaining space in the packetbuf.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
int packetbuf_copyto(void *to)
Copy the entire packetbuf to an external buffer.
uint8_t packetbuf_hdrlen(void)
Get the length of the header in the packetbuf.
const linkaddr_t linkaddr_null
The null link-layer address.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
int packetbuf_copyfrom(const void *from, uint16_t len)
Copy from external data into the packetbuf.
int packetbuf_holds_broadcast(void)
Checks whether the current packet is a broadcast.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
Header file for the Packet buffer (packetbuf) management
Default definitions of C compiler quirk work-arounds.
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.