48 #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 hdrptr;
64 static uint8_t *packetbuf = (uint8_t *)packetbuf_aligned;
66 static uint8_t *packetbufptr;
71 #define PRINTF(...) printf(__VA_ARGS__)
84 packetbuf_attr_clear();
100 memcpy(packetbufptr, from, l);
113 }
else if (bufptr > 0) {
116 packetbuf[i] = packetbuf[bufptr + i];
129 PRINTF(
"packetbuf_write_hdr: header:\n");
131 PRINTF(
"0x%02x, ", packetbuf[i]);
147 char *bufferptr = buffer;
151 bufferptr += sprintf(bufferptr,
"0x%02x, ", packetbuf[i]);
153 PRINTF(
"packetbuf_write: header: %s\n", buffer);
156 for(i = bufptr; i < buflen + bufptr; ++i) {
157 bufferptr += sprintf(bufferptr,
"0x%02x, ", packetbufptr[i]);
159 PRINTF(
"packetbuf_write: data: %s\n", buffer);
183 packetbuf_hdr_remove(
int size)
203 PRINTF(
"packetbuf_set_len: len %d\n", len);
216 return (
void *)(&packetbuf[hdrptr]);
258 packetbuf_attr_clear(
void)
261 for(i = 0; i < PACKETBUF_NUM_ATTRS; ++i) {
262 packetbuf_attrs[i].val = 0;
264 for(i = 0; i < PACKETBUF_NUM_ADDRS; ++i) {
270 packetbuf_attr_copyto(
struct packetbuf_attr *attrs,
271 struct packetbuf_addr *addrs)
273 memcpy(attrs, packetbuf_attrs,
sizeof(packetbuf_attrs));
274 memcpy(addrs, packetbuf_addrs,
sizeof(packetbuf_addrs));
278 packetbuf_attr_copyfrom(
struct packetbuf_attr *attrs,
279 struct packetbuf_addr *addrs)
281 memcpy(packetbuf_attrs, attrs,
sizeof(packetbuf_attrs));
282 memcpy(packetbuf_addrs, addrs,
sizeof(packetbuf_addrs));
285 #if !PACKETBUF_CONF_ATTRS_INLINE
287 packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val)
290 packetbuf_attrs[type].val = val;
295 packetbuf_attr(uint8_t type)
297 return packetbuf_attrs[type].val;
301 packetbuf_set_addr(uint8_t type,
const rimeaddr_t *addr)
304 rimeaddr_copy(&packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr, addr);
309 packetbuf_addr(uint8_t type)
311 return &packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr;