46 #include "contiki-net.h"
50 #ifdef QUEUEBUF_CONF_REF_NUM
51 #define QUEUEBUF_REF_NUM QUEUEBUF_CONF_REF_NUM
53 #define QUEUEBUF_REF_NUM 2
58 struct queuebuf *
next;
65 struct packetbuf_attr attrs[PACKETBUF_NUM_ATTRS];
66 struct packetbuf_addr addrs[PACKETBUF_NUM_ADDRS];
76 MEMB(bufmem,
struct queuebuf, QUEUEBUF_NUM);
77 MEMB(refbufmem,
struct queuebuf_ref, QUEUEBUF_REF_NUM);
87 #define PRINTF(...) printf(__VA_ARGS__)
92 #ifdef QUEUEBUF_CONF_STATS
93 #define QUEUEBUF_STATS QUEUEBUF_CONF_STATS
95 #define QUEUEBUF_STATS 0
99 uint8_t queuebuf_len, queuebuf_ref_len, queuebuf_max_len;
109 queuebuf_max_len = QUEUEBUF_NUM;
115 queuebuf_new_from_packetbuf_debug(
const char *file,
int line)
118 queuebuf_new_from_packetbuf(
void)
121 struct queuebuf *buf;
122 struct queuebuf_ref *rbuf;
134 PRINTF(
"queuebuf_new_from_packetbuf: could not allocate a reference queuebuf\n");
136 return (
struct queuebuf *)rbuf;
148 PRINTF(
"queuebuf len %d\n", queuebuf_len);
149 printf(
"#A q=%d\n", queuebuf_len);
150 if(queuebuf_len == queuebuf_max_len + 1) {
157 packetbuf_attr_copyto(buf->attrs, buf->addrs);
159 PRINTF(
"queuebuf_new_from_packetbuf: could not allocate a queuebuf\n");
166 queuebuf_update_attr_from_packetbuf(
struct queuebuf *buf)
168 packetbuf_attr_copyto(buf->attrs, buf->addrs);
172 queuebuf_free(
struct queuebuf *buf)
174 if(memb_inmemb(&bufmem, buf)) {
178 printf(
"#A q=%d\n", queuebuf_len);
183 }
else if(memb_inmemb(&refbufmem, buf)) {
192 queuebuf_to_packetbuf(
struct queuebuf *b)
194 struct queuebuf_ref *r;
196 if(memb_inmemb(&bufmem, b)) {
198 packetbuf_attr_copyfrom(b->attrs, b->addrs);
199 }
else if(memb_inmemb(&refbufmem, b)) {
200 r = (
struct queuebuf_ref *)b;
209 queuebuf_dataptr(
struct queuebuf *b)
211 struct queuebuf_ref *r;
213 if(memb_inmemb(&bufmem, b)) {
215 }
else if(memb_inmemb(&refbufmem, b)) {
216 r = (
struct queuebuf_ref *)b;
223 queuebuf_datalen(
struct queuebuf *b)
229 queuebuf_addr(
struct queuebuf *b, uint8_t type)
231 return &b->addrs[type - PACKETBUF_ADDR_FIRST].addr;
235 queuebuf_attr(
struct queuebuf *b, uint8_t type)
237 return b->attrs[type].val;
241 queuebuf_debug_print(
void)
245 printf(
"queuebuf_list: ");
248 printf(
"%s,%d,%lu ", q->file, q->line, q->time);