49 #define LOG_MODULE "CSMA" 50 #define LOG_LEVEL LOG_LEVEL_MAC 56 csma_output_packet(sent, ptr);
62 #if CSMA_SEND_SOFT_ACK 64 uint8_t *original_dataptr;
72 LOG_DBG(
"ignored ack\n");
73 }
else if(NETSTACK_FRAMER.parse() < 0) {
75 }
else if(!
linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
78 LOG_WARN(
"not for us\n");
86 LOG_WARN(
"drop duplicate link layer packet from ");
87 LOG_WARN_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
88 LOG_WARN_(
", seqno %u\n", packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
93 #if CSMA_SEND_SOFT_ACK 101 uint8_t ackdata[CSMA_ACK_LEN] = {0, 0, 0};
103 ackdata[0] = FRAME802154_ACKFRAME;
105 ackdata[2] = info154.
seq;
106 NETSTACK_RADIO.send(ackdata, CSMA_ACK_LEN);
111 LOG_INFO(
"received packet from ");
112 LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
113 LOG_INFO_(
", seqno %u, len %u\n", packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO),
packetbuf_datalen());
114 NETSTACK_NETWORK.input();
122 return NETSTACK_RADIO.on();
128 return NETSTACK_RADIO.off();
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
int(* on)(void)
Turn the MAC layer on.
frame802154_fcf_t fcf
Frame control field.
The 802.15.4 standard CSMA protocol (nonbeacon-enabled).
The structure of a MAC protocol driver in Contiki.
The 802.15.4 standard CSMA protocol (nonbeacon-enabled)
static void send_packet(linkaddr_t *dest)
This function is called by the 6lowpan code to send out a packet.
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
int mac_sequence_is_duplicate(void)
Tell whether the packetbuf is a duplicate packet.
Header file for MAC sequence numbers management
int(* off)(void)
Turn the MAC layer off.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
int packetbuf_holds_broadcast(void)
Checks whether the current packet is a broadcast.
Parameters used by the frame802154_create() function.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
void(* init)(void)
Initialize the MAC driver.
uint8_t seq
Sequence number.
Header file for the Packet buffer (packetbuf) management
Include file for the Contiki low-layer network stack (NETSTACK)
void mac_sequence_register_seqno(void)
Register the sequence number of the packetbuf.
uint8_t dest_addr[8]
Destination address.
Header file for the logging system
uint8_t ack_required
1 bit.