43 #include "lib/random.h"
50 #define PRINTF(...) printf(__VA_ARGS__)
51 #define PRINTADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7])
54 #define PRINTADDR(addr)
57 static uint8_t mac_dsn;
58 static uint8_t initialized = 0;
59 static uint16_t mac_pan_id = IEEE802154_PANID;
63 is_broadcast_addr(uint8_t mode, uint8_t *addr)
65 int i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8;
81 memset(¶ms, 0,
sizeof(params));
85 mac_dsn = random_rand() & 0xff;
103 if(packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO)) {
104 params.
seq = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO);
106 params.
seq = mac_dsn++;
107 packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, params.
seq);
116 if(
sizeof(rimeaddr_t) == 2) {
136 packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
138 if(
sizeof(rimeaddr_t) == 2) {
166 PRINTF(
"15.4-OUT: too large header: %u\n", len);
181 frame.
dest_pid != FRAME802154_BROADCASTPANDID) {
183 PRINTF(
"15.4: for another pan %u\n", frame.
dest_pid);
187 packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, (rimeaddr_t *)&frame.
dest_addr);
190 packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (rimeaddr_t *)&frame.
src_addr);
193 packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, frame.
seq);
196 PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
197 PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
206 set_pan_id(uint16_t pan_id)
213 const struct framer framer_802154 = {
214 create, parse, set_pan_id