Skip to content
Snippets Groups Projects
Commit 66b36397 authored by Aaron Sowry's avatar Aaron Sowry Committed by hexluthor
Browse files

cpu/cc2538: Enable CRC checking of received packets (#5654)

parent cf3ee677
No related branches found
No related tags found
No related merge requests found
...@@ -300,14 +300,21 @@ static int _recv(netdev2_t *netdev, char *buf, int len, void *info) ...@@ -300,14 +300,21 @@ static int _recv(netdev2_t *netdev, char *buf, int len, void *info)
/* GNRC wants to know how much data we've got for it */ /* GNRC wants to know how much data we've got for it */
pkt_len = rfcore_read_byte(); pkt_len = rfcore_read_byte();
/* If the value of the first byte of the RX FIFO does not correspond /* Make sure pkt_len is sane */
to the amount of data received, then drop the packet. */ if (pkt_len > CC2538_RF_MAX_DATA_LEN) {
if (pkt_len != RFCORE_XREG_RXFIFOCNT) {
RFCORE_SFR_RFST = ISFLUSHRX; RFCORE_SFR_RFST = ISFLUSHRX;
mutex_unlock(&dev->mutex); mutex_unlock(&dev->mutex);
return -EOVERFLOW; return -EOVERFLOW;
} }
/* CRC check */
if (!(rfcore_peek_rx_fifo(pkt_len) & 0x80)) {
/* CRC failed; discard packet */
RFCORE_SFR_RFST = ISFLUSHRX;
mutex_unlock(&dev->mutex);
return -ENODATA;
}
if (len > 0) { if (len > 0) {
/* GNRC wants us to drop the packet */ /* GNRC wants us to drop the packet */
RFCORE_SFR_RFST = ISFLUSHRX; RFCORE_SFR_RFST = ISFLUSHRX;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment