53 #ifndef __PACKETBUF_H__
54 #define __PACKETBUF_H__
56 #include "contiki-conf.h"
62 #ifdef PACKETBUF_CONF_SIZE
63 #define PACKETBUF_SIZE PACKETBUF_CONF_SIZE
65 #define PACKETBUF_SIZE 128
71 #ifdef PACKETBUF_CONF_HDR_SIZE
72 #define PACKETBUF_HDR_SIZE PACKETBUF_CONF_HDR_SIZE
74 #define PACKETBUF_HDR_SIZE 48
101 void packetbuf_hdr_remove(
int bytes);
319 typedef uint16_t packetbuf_attr_t;
321 struct packetbuf_attr {
323 packetbuf_attr_t val;
325 struct packetbuf_addr {
330 #define PACKETBUF_ATTR_PACKET_TYPE_DATA 0
331 #define PACKETBUF_ATTR_PACKET_TYPE_ACK 1
332 #define PACKETBUF_ATTR_PACKET_TYPE_STREAM 2
333 #define PACKETBUF_ATTR_PACKET_TYPE_STREAM_END 3
334 #define PACKETBUF_ATTR_PACKET_TYPE_TIMESTAMP 4
340 PACKETBUF_ATTR_CHANNEL,
341 PACKETBUF_ATTR_NETWORK_ID,
342 PACKETBUF_ATTR_LINK_QUALITY,
344 PACKETBUF_ATTR_TIMESTAMP,
345 PACKETBUF_ATTR_RADIO_TXPOWER,
346 PACKETBUF_ATTR_LISTEN_TIME,
347 PACKETBUF_ATTR_TRANSMIT_TIME,
348 PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
349 PACKETBUF_ATTR_MAC_SEQNO,
350 PACKETBUF_ATTR_MAC_ACK,
353 PACKETBUF_ATTR_RELIABLE,
354 PACKETBUF_ATTR_PACKET_ID,
355 PACKETBUF_ATTR_PACKET_TYPE,
356 PACKETBUF_ATTR_REXMIT,
357 PACKETBUF_ATTR_MAX_REXMIT,
358 PACKETBUF_ATTR_NUM_REXMIT,
359 PACKETBUF_ATTR_PENDING,
364 PACKETBUF_ATTR_EPACKET_ID,
365 PACKETBUF_ATTR_EPACKET_TYPE,
366 PACKETBUF_ATTR_ERELIABLE,
369 PACKETBUF_ADDR_SENDER,
370 PACKETBUF_ADDR_RECEIVER,
371 PACKETBUF_ADDR_ESENDER,
372 PACKETBUF_ADDR_ERECEIVER,
377 #define PACKETBUF_NUM_ADDRS 4
378 #define PACKETBUF_NUM_ATTRS (PACKETBUF_ATTR_MAX - PACKETBUF_NUM_ADDRS)
379 #define PACKETBUF_ADDR_FIRST PACKETBUF_ADDR_SENDER
381 #define PACKETBUF_IS_ADDR(type) ((type) >= PACKETBUF_ADDR_FIRST)
383 #if PACKETBUF_CONF_ATTRS_INLINE
385 extern struct packetbuf_attr packetbuf_attrs[];
386 extern struct packetbuf_addr packetbuf_addrs[];
388 static int packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val);
389 static packetbuf_attr_t packetbuf_attr(uint8_t type);
390 static int packetbuf_set_addr(uint8_t type,
const rimeaddr_t *addr);
391 static const rimeaddr_t *packetbuf_addr(uint8_t type);
394 packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val)
397 packetbuf_attrs[type].val = val;
400 static inline packetbuf_attr_t
401 packetbuf_attr(uint8_t type)
403 return packetbuf_attrs[type].val;
407 packetbuf_set_addr(uint8_t type,
const rimeaddr_t *addr)
410 rimeaddr_copy(&packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr, addr);
414 static inline const rimeaddr_t *
415 packetbuf_addr(uint8_t type)
417 return &packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr;
420 int packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val);
421 packetbuf_attr_t packetbuf_attr(uint8_t type);
422 int packetbuf_set_addr(uint8_t type,
const rimeaddr_t *addr);
423 const rimeaddr_t *packetbuf_addr(uint8_t type);
426 void packetbuf_attr_clear(
void);
428 void packetbuf_attr_copyto(
struct packetbuf_attr *attrs,
429 struct packetbuf_addr *addrs);
430 void packetbuf_attr_copyfrom(
struct packetbuf_attr *attrs,
431 struct packetbuf_addr *addrs);
433 #define PACKETBUF_ATTRIBUTES(...) { __VA_ARGS__ PACKETBUF_ATTR_LAST }
434 #define PACKETBUF_ATTR_LAST { PACKETBUF_ATTR_NONE, 0 }
436 #define PACKETBUF_ATTR_BIT 1
437 #define PACKETBUF_ATTR_BYTE 8
438 #define PACKETBUF_ADDRSIZE (sizeof(rimeaddr_t) * PACKETBUF_ATTR_BYTE)
440 struct packetbuf_attrlist {