45 #define CONTIKIMAC_ID 0x00
54 #ifdef CONTIKIMAC_FRAMER_CONF_SHORTEST_PACKET_SIZE
55 #define SHORTEST_PACKET_SIZE CONTIKIMAC_FRAMER_CONF_SHORTEST_PACKET_SIZE
57 #define SHORTEST_PACKET_SIZE 43
60 #ifdef CONTIKIMAC_FRAMER_CONF_DECORATED_FRAMER
61 #define DECORATED_FRAMER CONTIKIMAC_FRAMER_CONF_DECORATED_FRAMER
63 #define DECORATED_FRAMER framer_802154
66 extern const struct framer DECORATED_FRAMER;
71 #define PRINTF(...) printf(__VA_ARGS__)
76 static void pad(
void);
89 return DECORATED_FRAMER.length() +
sizeof(
struct hdr);
99 PRINTF(
"contikimac-framer: too large header\n");
100 return FRAMER_FAILED;
103 chdr->id = CONTIKIMAC_ID;
107 hdr_len = DECORATED_FRAMER.create();
109 PRINTF(
"contikimac-framer: decorated framer failed\n");
110 return FRAMER_FAILED;
115 return hdr_len +
sizeof(
struct hdr);
123 uint8_t zeroes_count;
126 if(transmit_len < SHORTEST_PACKET_SIZE) {
128 zeroes_count = SHORTEST_PACKET_SIZE - transmit_len;
141 hdr_len = DECORATED_FRAMER.parse();
143 return FRAMER_FAILED;
147 if(chdr->id != CONTIKIMAC_ID) {
148 PRINTF(
"contikimac-framer: CONTIKIMAC_ID is missing\n");
149 return FRAMER_FAILED;
153 PRINTF(
"contikimac-framer: packetbuf_hdrreduce failed\n");
154 return FRAMER_FAILED;
159 return hdr_len +
sizeof(
struct hdr);
162 const struct framer contikimac_framer = {
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
Creates and parses the ContikiMAC header.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
Header file for the Rime buffer (packetbuf) management
void packetbuf_compact(void)
Compact the packetbuf.
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in 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.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
Include file for the Contiki low-layer network stack (NETSTACK)