The cc2420 does offer hardware CRC calculation and we are using it in this
driver. Once the CRC is checked in hardware the two CRC bytes get replaced with
measurement informations and a FCS bit flag telling about the result of
the CRC check.

So far the driver did pass all frmaes into the stack without checking for the
correct CRC result. This patch checks if the FCS flag is good and drops the
frame if not.

Signed-off-by: Stefan Schmidt <ste...@datenfreihafen.org>
---
 drivers/ieee802154/cc2420.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/ieee802154/cc2420.c b/drivers/ieee802154/cc2420.c
index 50761de..8f4b177 100644
--- a/drivers/ieee802154/cc2420.c
+++ b/drivers/ieee802154/cc2420.c
@@ -406,6 +406,7 @@ static int cc2420_rx(struct cc2420_local *lp)
 {
        u8 len = 128;
        u8 lqi = 0; /* link quality */
+       u8 fcs = 0;
        int rc;
        struct sk_buff *skb;
 
@@ -419,6 +420,14 @@ static int cc2420_rx(struct cc2420_local *lp)
                return -EINVAL;
        }
 
+       /* Check FCS flag */
+       fcs = skb->data[len-1];
+       if (!(fcs >> 7)) {
+               dev_dbg(&lp->spi->dev, "Received packet with wrong FCS; 
ingnore.\n");
+               kfree_skb(skb);
+               return -EINVAL;
+       }
+
        /* Clip last two bytes. When using hardware FCS they get replaced with
         * correlation value, FCS flag and RSSI value */
        skb_trim(skb, len-2);
-- 
1.7.5.4


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to