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)
85 is_broadcast_addr(uint8_t mode, uint8_t *
addr)
87 int i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8;
103 memset(¶ms, 0,
sizeof(params));
109 #if NETSTACK_CONF_WITH_RIME
136 packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
147 #if NETSTACK_CONF_BRIDGE_MODE
176 PRINTF(
"6MAC-UT: too large header: %u\n", len);
181 send_list(mac_callback_t sent,
void *ptr,
struct rdc_buf_list *buf_list)
183 if(buf_list !=
NULL) {
184 queuebuf_to_packetbuf(buf_list->buf);
201 frame.
dest_pid != FRAME802154_BROADCASTPANDID) {
203 PRINTF(
"6MAC: for another pan %u\n", frame.
dest_pid);
207 packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, (linkaddr_t *)&frame.
dest_addr);
208 #if !NETSTACK_CONF_BRIDGE_MODE
209 if(!
linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
212 PRINTF(
"6MAC: not for us\n");
218 packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (linkaddr_t *)&frame.
src_addr);
221 PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
222 PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
224 NETSTACK_MAC.input();
226 PRINTF(
"6MAC: failed to parse hdr\n");
233 return NETSTACK_RADIO.on();
237 off(
int keep_radio_on)
240 return NETSTACK_RADIO.on();
242 return NETSTACK_RADIO.off();
254 static unsigned short
255 channel_check_interval(
void)
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
int frame802154_hdrlen(frame802154_t *p)
Calculates the length of the frame header.
uint8_t security_enabled
1 bit.
uint16_t src_pid
Source PAN ID.
void(* send_list)(mac_callback_t sent_callback, void *ptr, struct rdc_buf_list *list)
Send a packet list.
unsigned short(* channel_check_interval)(void)
Returns the channel check interval, expressed in clock_time_t ticks.
uint8_t dest_addr[8]
Destination address.
uint16_t dest_pid
Destination PAN ID.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
frame802154_fcf_t fcf
Frame control field.
int(* off)(int keep_radio_on)
Turn the MAC layer off.
int payload_len
Length of payload field.
uint8_t frame_pending
1 bit.
int(* on)(void)
Turn the MAC layer on.
uint8_t src_addr[8]
Source address.
static uint16_t mac_dst_pan_id
The 16-bit identifier of the PAN on which the device is sending to.
uint8_t seq
Sequence number.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
uint8_t * payload
Pointer to 802.15.4 payload.
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.
Header file for the Rime buffer (packetbuf) management
int frame802154_create(frame802154_t *p, uint8_t *buf)
Creates a frame for transmission over the air.
The MAC layer transmission could not be performed because of a fatal error.
void(* init)(void)
Initialize the RDC driver.
The MAC layer transmission was OK.
#define NULL
The null pointer.
static void send_packet(mac_callback_t sent, void *ptr)
802.15.4 frame creation and parsing functions
unsigned short random_rand(void)
Generates a new random number using the cc2538 RNG.
static uint8_t mac_dsn
The sequence number (0x00 - 0xff) added to the transmitted data or MAC command frame.
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
uint8_t src_addr_mode
2 bit.
uint8_t dest_addr_mode
2 bit.
MAC interface for packaging radio packets into 802.15.4 frames
uint8_t panid_compression
1 bit.
The structure of a RDC (radio duty cycling) driver in Contiki.
uint8_t ack_required
1 bit.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
Header file for the Rime queue buffer management
int packetbuf_hdralloc(int size)
Extend the header of the packetbuf, for outbound packets.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two Rime addresses.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
linkaddr_t linkaddr_node_addr
The Rime address of the node.
static uint16_t mac_src_pan_id
The 16-bit identifier of the PAN on which the device is operating.
uint8_t frame_version
2 bit.
int packetbuf_hdrreduce(int size)
Reduce the header in the packetbuf, for incoming packets.
Parameters used by the frame802154_create() function.
Include file for the Contiki low-layer network stack (NETSTACK)