55 #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,
351 PACKETBUF_ATTR_IS_CREATED_AND_SECURED,
354 PACKETBUF_ATTR_RELIABLE,
355 PACKETBUF_ATTR_PACKET_ID,
356 PACKETBUF_ATTR_PACKET_TYPE,
357 PACKETBUF_ATTR_REXMIT,
358 PACKETBUF_ATTR_MAX_REXMIT,
359 PACKETBUF_ATTR_NUM_REXMIT,
360 PACKETBUF_ATTR_PENDING,
361 PACKETBUF_ATTR_FRAME_TYPE,
362 #if LLSEC802154_SECURITY_LEVEL
363 PACKETBUF_ATTR_SECURITY_LEVEL,
364 PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1,
365 PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3,
366 #if LLSEC802154_USES_EXPLICIT_KEYS
367 PACKETBUF_ATTR_KEY_ID_MODE,
368 PACKETBUF_ATTR_KEY_INDEX,
369 PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1,
376 PACKETBUF_ATTR_EPACKET_ID,
377 PACKETBUF_ATTR_EPACKET_TYPE,
378 PACKETBUF_ATTR_ERELIABLE,
381 PACKETBUF_ADDR_SENDER,
382 PACKETBUF_ADDR_RECEIVER,
383 PACKETBUF_ADDR_ESENDER,
384 PACKETBUF_ADDR_ERECEIVER,
390 #if !LLSEC802154_SECURITY_LEVEL
392 PACKETBUF_ATTR_SECURITY_LEVEL,
393 PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1,
394 PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3
399 #if !LLSEC802154_USES_EXPLICIT_KEYS
401 PACKETBUF_ATTR_KEY_ID_MODE,
402 PACKETBUF_ATTR_KEY_INDEX,
403 PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1
407 #define PACKETBUF_NUM_ADDRS 4
408 #define PACKETBUF_NUM_ATTRS (PACKETBUF_ATTR_MAX - PACKETBUF_NUM_ADDRS)
409 #define PACKETBUF_ADDR_FIRST PACKETBUF_ADDR_SENDER
411 #define PACKETBUF_IS_ADDR(type) ((type) >= PACKETBUF_ADDR_FIRST)
413 #if PACKETBUF_CONF_ATTRS_INLINE
415 extern struct packetbuf_attr packetbuf_attrs[];
416 extern struct packetbuf_addr packetbuf_addrs[];
418 static int packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val);
419 static packetbuf_attr_t packetbuf_attr(uint8_t type);
420 static int packetbuf_set_addr(uint8_t type,
const linkaddr_t *addr);
421 static const linkaddr_t *packetbuf_addr(uint8_t type);
424 packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val)
427 packetbuf_attrs[type].val = val;
430 static inline packetbuf_attr_t
431 packetbuf_attr(uint8_t type)
433 return packetbuf_attrs[type].val;
437 packetbuf_set_addr(uint8_t type,
const linkaddr_t *addr)
440 linkaddr_copy(&packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr, addr);
444 static inline const linkaddr_t *
445 packetbuf_addr(uint8_t type)
447 return &packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr;
450 int packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val);
451 packetbuf_attr_t packetbuf_attr(uint8_t type);
452 int packetbuf_set_addr(uint8_t type,
const linkaddr_t *addr);
453 const linkaddr_t *packetbuf_addr(uint8_t type);
456 void packetbuf_attr_clear(
void);
458 void packetbuf_attr_copyto(
struct packetbuf_attr *attrs,
459 struct packetbuf_addr *addrs);
460 void packetbuf_attr_copyfrom(
struct packetbuf_attr *attrs,
461 struct packetbuf_addr *addrs);
463 #define PACKETBUF_ATTRIBUTES(...) { __VA_ARGS__ PACKETBUF_ATTR_LAST }
464 #define PACKETBUF_ATTR_LAST { PACKETBUF_ATTR_NONE, 0 }
466 #define PACKETBUF_ATTR_BIT 1
467 #define PACKETBUF_ATTR_BYTE 8
468 #define PACKETBUF_ADDRSIZE (LINKADDR_SIZE * PACKETBUF_ATTR_BYTE)
470 struct packetbuf_attrlist {
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
int packetbuf_copyfrom(const void *from, uint16_t len)
Copy from external data into the packetbuf.
uint8_t packetbuf_hdrlen(void)
Get the length of the header in the packetbuf.
void packetbuf_set_datalen(uint16_t len)
Set 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.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
void * packetbuf_reference_ptr(void)
Get a pointer to external data referenced by the packetbuf.
int packetbuf_copyto(void *to)
Copy the entire packetbuf to an external buffer.
void packetbuf_compact(void)
Compact the packetbuf.
void packetbuf_clear_hdr(void)
Clear and reset the header of the packetbuf.
int packetbuf_copyto_hdr(uint8_t *to)
Copy the header portion of the packetbuf to an external buffer.
void packetbuf_clear(void)
Clear and reset the packetbuf.
void packetbuf_reference(void *ptr, uint16_t len)
Point the packetbuf to external data.
Common functionality of 802.15.4-compliant llsec_drivers.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
int packetbuf_is_reference(void)
Check if the packetbuf references external data.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
Header file for the Rime address representation