43 #define CONTIKIMAC_ID 0x00
52 #ifdef CONTIKIMAC_FRAMER_CONF_SHORTEST_PACKET_SIZE
53 #define SHORTEST_PACKET_SIZE CONTIKIMAC_FRAMER_CONF_SHORTEST_PACKET_SIZE
55 #define SHORTEST_PACKET_SIZE 43
58 #ifdef CONTIKIMAC_FRAMER_CONF_DECORATED_FRAMER
59 #define DECORATED_FRAMER CONTIKIMAC_FRAMER_CONF_DECORATED_FRAMER
61 #define DECORATED_FRAMER framer_802154
64 extern const struct framer DECORATED_FRAMER;
69 #define PRINTF(...) printf(__VA_ARGS__)
89 PRINTF(
"contikimac-framer: too large header\n");
93 chdr->id = CONTIKIMAC_ID;
96 hdr_len = DECORATED_FRAMER.create();
98 PRINTF(
"contikimac-framer: decorated framer failed\n");
102 return hdr_len +
sizeof(
struct hdr);
110 uint8_t zeroes_count;
113 if(transmit_len < SHORTEST_PACKET_SIZE) {
115 zeroes_count = SHORTEST_PACKET_SIZE - transmit_len;
123 create_and_secure(
void)
130 return FRAMER_FAILED;
134 if(!NETSTACK_LLSEC.on_frame_created()) {
135 PRINTF(
"contikimac-framer: securing failed\n");
136 return FRAMER_FAILED;
152 hdr_len = DECORATED_FRAMER.parse();
154 return FRAMER_FAILED;
158 if(chdr->id != CONTIKIMAC_ID) {
159 PRINTF(
"contikimac-framer: CONTIKIMAC_ID is missing\n");
160 return FRAMER_FAILED;
164 PRINTF(
"contikimac-framer: packetbuf_hdrreduce failed\n");
165 return FRAMER_FAILED;
171 return hdr_len +
sizeof(
struct hdr);
174 const struct framer contikimac_framer = {
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
Header file for the Rime buffer (packetbuf) management
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.
Creates and parses the ContikiMAC header.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
void packetbuf_compact(void)
Compact the packetbuf.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
Include file for the Contiki low-layer network stack (NETSTACK)