55 #include "contiki-conf.h"
63 #ifdef PACKETBUF_CONF_SIZE
64 #define PACKETBUF_SIZE PACKETBUF_CONF_SIZE
66 #define PACKETBUF_SIZE 128
69 #ifdef PACKETBUF_CONF_WITH_PACKET_TYPE
70 #define PACKETBUF_WITH_PACKET_TYPE PACKETBUF_CONF_WITH_PACKET_TYPE
72 #define PACKETBUF_WITH_PACKET_TYPE NETSTACK_CONF_WITH_RIME
209 typedef uint16_t packetbuf_attr_t;
211 struct packetbuf_attr {
212 packetbuf_attr_t val;
214 struct packetbuf_addr {
218 #define PACKETBUF_ATTR_PACKET_TYPE_DATA 0
219 #define PACKETBUF_ATTR_PACKET_TYPE_ACK 1
220 #define PACKETBUF_ATTR_PACKET_TYPE_STREAM 2
221 #define PACKETBUF_ATTR_PACKET_TYPE_STREAM_END 3
222 #define PACKETBUF_ATTR_PACKET_TYPE_TIMESTAMP 4
228 PACKETBUF_ATTR_CHANNEL,
229 PACKETBUF_ATTR_NETWORK_ID,
230 PACKETBUF_ATTR_LINK_QUALITY,
232 PACKETBUF_ATTR_TIMESTAMP,
233 PACKETBUF_ATTR_RADIO_TXPOWER,
234 PACKETBUF_ATTR_LISTEN_TIME,
235 PACKETBUF_ATTR_TRANSMIT_TIME,
236 PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
237 PACKETBUF_ATTR_MAC_SEQNO,
238 PACKETBUF_ATTR_MAC_ACK,
239 PACKETBUF_ATTR_IS_CREATED_AND_SECURED,
240 #if TSCH_WITH_LINK_SELECTOR
241 PACKETBUF_ATTR_TSCH_SLOTFRAME,
242 PACKETBUF_ATTR_TSCH_TIMESLOT,
246 #if PACKETBUF_WITH_PACKET_TYPE
247 PACKETBUF_ATTR_PACKET_TYPE,
249 #if NETSTACK_CONF_WITH_RIME
250 PACKETBUF_ATTR_PACKET_ID,
251 PACKETBUF_ATTR_RELIABLE,
252 PACKETBUF_ATTR_REXMIT,
253 PACKETBUF_ATTR_MAX_REXMIT,
254 PACKETBUF_ATTR_NUM_REXMIT,
256 PACKETBUF_ATTR_PENDING,
257 PACKETBUF_ATTR_FRAME_TYPE,
258 #if LLSEC802154_USES_AUX_HEADER
259 PACKETBUF_ATTR_SECURITY_LEVEL,
261 #if LLSEC802154_USES_FRAME_COUNTER
262 PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1,
263 PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3,
265 #if LLSEC802154_USES_EXPLICIT_KEYS
266 PACKETBUF_ATTR_KEY_ID_MODE,
267 PACKETBUF_ATTR_KEY_INDEX,
268 PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1,
272 #if NETSTACK_CONF_WITH_RIME
275 PACKETBUF_ATTR_EPACKET_ID,
276 PACKETBUF_ATTR_EPACKET_TYPE,
277 PACKETBUF_ATTR_ERELIABLE,
281 PACKETBUF_ADDR_SENDER,
282 PACKETBUF_ADDR_RECEIVER,
283 #if NETSTACK_CONF_WITH_RIME
284 PACKETBUF_ADDR_ESENDER,
285 PACKETBUF_ADDR_ERECEIVER,
291 #if NETSTACK_CONF_WITH_RIME
292 #define PACKETBUF_NUM_ADDRS 4
294 #define PACKETBUF_NUM_ADDRS 2
296 #define PACKETBUF_NUM_ATTRS (PACKETBUF_ATTR_MAX - PACKETBUF_NUM_ADDRS)
297 #define PACKETBUF_ADDR_FIRST PACKETBUF_ADDR_SENDER
299 #define PACKETBUF_IS_ADDR(type) ((type) >= PACKETBUF_ADDR_FIRST)
301 #if PACKETBUF_CONF_ATTRS_INLINE
303 extern struct packetbuf_attr packetbuf_attrs[];
304 extern struct packetbuf_addr packetbuf_addrs[];
307 packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val)
309 packetbuf_attrs[type].val = val;
312 static inline packetbuf_attr_t
313 packetbuf_attr(uint8_t type)
315 return packetbuf_attrs[type].val;
319 packetbuf_set_addr(uint8_t type,
const linkaddr_t *
addr)
321 linkaddr_copy(&packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr, addr);
325 static inline const linkaddr_t *
326 packetbuf_addr(uint8_t type)
328 return &packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].addr;
331 int packetbuf_set_attr(uint8_t type,
const packetbuf_attr_t val);
332 packetbuf_attr_t packetbuf_attr(uint8_t type);
333 int packetbuf_set_addr(uint8_t type,
const linkaddr_t *
addr);
334 const linkaddr_t *packetbuf_addr(uint8_t type);
343 void packetbuf_attr_clear(
void);
345 void packetbuf_attr_copyto(
struct packetbuf_attr *attrs,
346 struct packetbuf_addr *addrs);
347 void packetbuf_attr_copyfrom(
struct packetbuf_attr *attrs,
348 struct packetbuf_addr *addrs);
350 #define PACKETBUF_ATTRIBUTES(...) { __VA_ARGS__ PACKETBUF_ATTR_LAST }
351 #define PACKETBUF_ATTR_LAST { PACKETBUF_ATTR_NONE, 0 }
353 #define PACKETBUF_ATTR_BIT 1
354 #define PACKETBUF_ATTR_BYTE 8
355 #define PACKETBUF_ADDRSIZE (LINKADDR_SIZE * PACKETBUF_ATTR_BYTE)
357 struct packetbuf_attrlist {
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
void packetbuf_clear(void)
Clear and reset the packetbuf.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
Common functionality of 802.15.4-compliant llsec_drivers.
int packetbuf_holds_broadcast(void)
Checks whether the current packet is a broadcast.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
void packetbuf_compact(void)
Compact the packetbuf.
Header file for the Rime address representation
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
int packetbuf_copyfrom(const void *from, uint16_t len)
Copy from external data into the packetbuf.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
uint8_t packetbuf_hdrlen(void)
Get the length of the header in the packetbuf.
int packetbuf_copyto(void *to)
Copy the entire packetbuf to an external buffer.