45#include "packetutils.h"
52#define LOG_MODULE "BR-MAC"
53#define LOG_LEVEL LOG_LEVEL_NONE
55#define MAX_CALLBACKS 16
56static int callback_pos;
63 struct packetbuf_attr attrs[PACKETBUF_NUM_ATTRS];
64 struct packetbuf_addr addrs[PACKETBUF_NUM_ADDRS];
67static struct tx_callback callbacks[MAX_CALLBACKS];
73#if LLSEC802154_USES_AUX_HEADER
74 if(packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL) ==
75 PACKETBUF_ATTR_SECURITY_LEVEL_DEFAULT) {
76 packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL,
77 CSMA_LLSEC_SECURITY_LEVEL);
84packet_sent(uint8_t sessionid, uint8_t status, uint8_t tx)
86 if(sessionid < MAX_CALLBACKS) {
87 struct tx_callback *callback;
88 callback = &callbacks[sessionid];
90 packetbuf_attr_copyfrom(callback->attrs, callback->addrs);
91 mac_call_sent_callback(callback->cback, callback->ptr, status, tx);
93 LOG_ERR(
"Session id (%d) >= MAX_CALLBACKS (%d)\n", sessionid,
99setup_callback(mac_callback_t sent,
void *ptr)
101 struct tx_callback *callback;
102 int tmp = callback_pos;
103 callback = &callbacks[callback_pos];
104 callback->cback = sent;
106 packetbuf_attr_copyto(callback->attrs, callback->addrs);
109 if(callback_pos >= MAX_CALLBACKS) {
127 packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);
130 packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_DATAFRAME);
137 if(NETSTACK_FRAMER.create() < 0) {
139 LOG_WARN(
"send failed, too large header\n");
143#if SERIALIZE_ATTRIBUTES
144 size = packetutils_serialize_atts(&buf[3],
sizeof(buf) - 3);
149 LOG_WARN(
"send failed, too large header\n");
152 sid = setup_callback(sent, ptr);
169 if(NETSTACK_FRAMER.parse() < 0) {
172 NETSTACK_NETWORK.input();
192 return 127 - NETSTACK_FRAMER.length();
202const struct mac_driver border_router_mac_driver = {
Border router header file.
802.15.4 frame creation and parsing functions
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
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.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
void packetbuf_clear(void)
Clear and reset the packetbuf.
static void send_packet(void)
This function is called by the 6lowpan code to send out a packet.
Header file for the logging system.
void mac_sequence_set_dsn(void)
Sets and increments the destination sequence number.
void mac_sequence_init(void)
brief Initializes the destination sequence number to a random value.
Header file for MAC sequence numbers management.
@ MAC_TX_ERR_FATAL
The MAC layer transmission could not be performed because of insufficient queue space,...
Include file for the Contiki low-layer network stack (NETSTACK)
static void packet_input(void)
Called by the radio driver process when a frame has been received.
Header file for the Packet buffer (packetbuf) management.
Header file for the Packet queue buffer management.
The structure of a MAC protocol driver in Contiki.
int(* on)(void)
Turn the MAC layer on.
int(* max_payload)(void)
Read out estimated max payload size based on payload in packetbuf.
int(* off)(void)
Turn the MAC layer off.
void(* init)(void)
Initialize the MAC driver.