52 #include "lib/random.h"
58 #define PRINTF(...) printf(__VA_ARGS__)
59 #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])
62 #define PRINTADDR(addr)
69 static uint8_t mac_dsn;
75 static uint16_t mac_dst_pan_id = IEEE802154_PANID;
81 static uint16_t mac_src_pan_id = IEEE802154_PANID;
85 is_broadcast_addr(uint8_t mode, uint8_t *addr)
87 int i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8;
97 send_packet(mac_callback_t sent,
void *ptr)
103 memset(¶ms, 0,
sizeof(params));
116 params.
seq = mac_dsn++;
138 packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
143 params.
src_pid = mac_src_pan_id;
174 PRINTF(
"6MAC-UT: too large header: %u\n", len);
189 if(frame.
dest_pid != mac_src_pan_id &&
190 frame.
dest_pid != FRAME802154_BROADCASTPANDID) {
192 PRINTF(
"6MAC: for another pan %u\n", frame.
dest_pid);
196 packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, (rimeaddr_t *)&frame.
dest_addr);
197 if(!
rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
200 PRINTF(
"6MAC: not for us\n");
205 packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (rimeaddr_t *)&frame.
src_addr);
208 PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
209 PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
211 NETSTACK_MAC.input();
213 PRINTF(
"6MAC: failed to parse hdr\n");
220 return NETSTACK_RADIO.on();
224 off(
int keep_radio_on)
227 return NETSTACK_RADIO.on();
229 return NETSTACK_RADIO.off();
236 mac_dsn = random_rand() % 256;
241 static unsigned short
242 channel_check_interval(
void)