CSMA: Do not parse twice/Acknowledge MAC command frames, too

This commit is contained in:
kkrentz 2018-04-30 06:54:00 -07:00
parent e4dcba32c9
commit 74780d5962
3 changed files with 8 additions and 19 deletions

View File

@ -60,11 +60,7 @@ static void
input_packet(void)
{
#if CSMA_SEND_SOFT_ACK
int original_datalen;
uint8_t *original_dataptr;
original_datalen = packetbuf_datalen();
original_dataptr = packetbuf_dataptr();
uint8_t ackdata[CSMA_ACK_LEN];
#endif
if(packetbuf_datalen() == CSMA_ACK_LEN) {
@ -91,20 +87,11 @@ input_packet(void)
}
#if CSMA_SEND_SOFT_ACK
{
frame802154_t info154;
frame802154_parse(original_dataptr, original_datalen, &info154);
if(info154.fcf.frame_type == FRAME802154_DATAFRAME &&
info154.fcf.ack_required != 0 &&
linkaddr_cmp((linkaddr_t *)&info154.dest_addr,
&linkaddr_node_addr)) {
uint8_t ackdata[CSMA_ACK_LEN] = {0, 0, 0};
ackdata[0] = FRAME802154_ACKFRAME;
ackdata[1] = 0;
ackdata[2] = info154.seq;
NETSTACK_RADIO.send(ackdata, CSMA_ACK_LEN);
}
if(packetbuf_attr(PACKETBUF_ATTR_MAC_ACK)) {
ackdata[0] = FRAME802154_ACKFRAME;
ackdata[1] = 0;
ackdata[2] = ((uint8_t *)packetbuf_hdrptr())[2];
NETSTACK_RADIO.send(ackdata, CSMA_ACK_LEN);
}
#endif /* CSMA_SEND_SOFT_ACK */
if(!duplicate) {

View File

@ -240,6 +240,7 @@ parse(void)
if(hdr_len && packetbuf_hdrreduce(hdr_len)) {
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, frame.fcf.frame_type);
packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, frame.fcf.ack_required);
if(frame.fcf.dest_addr_mode) {
if(frame.dest_pid != frame802154_get_pan_id() &&

View File

@ -87,6 +87,7 @@ parse(void)
}
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (linkaddr_t *)&frame.src_addr);
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, frame.seq);
packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, frame.fcf.ack_required);
return 0;
}
#endif