[PATCH 1/1] ieee802154-cc2520: Check CRC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add checking the "CRC_OK" bit at the end of incoming packets to make
sure the cc2520 driver only passes up valid packets. Because the AUTOCRC
bit in the FRMCTRL0 register is set to 1 after init, the CC2520 handles
checking the CRC of incoming packets and sets the most significant bit
of the last byte of the incoming packet to 1 if the check passed. This
patch simply checks that bit.

Signed-off-by: Brad Campbell <bradjc5@xxxxxxxxx>
---
 drivers/net/ieee802154/cc2520.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index e65b605..b54edbf 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -450,6 +450,17 @@ cc2520_read_rxfifo(struct cc2520_private *priv, u8 *data, u8 len, u8 *lqi)
 
 	mutex_unlock(&priv->buffer_mutex);
 
+	/* If we are reading the actual packet and not just the length byte,
+	 * check that the CRC is valid.
+	 */
+	if (len > 1) {
+		/* Most significant bit of the last byte of the data buffer
+		 * is a 1 bit CRC indicator. See section 20.3.4.
+		 */
+		if (data[len - 1] >> 7 == 0)
+			return -EINVAL;
+	}
+
 	return status;
 }
 
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux