diff options
author | Alexander Aring <alex.aring@gmail.com> | 2014-10-27 12:13:41 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-10-27 13:07:49 -0400 |
commit | d0e73c470471a0f2eda02de44fb17f020b32269c (patch) | |
tree | 5d17e157409f73aa6738432b6900d295d9ae6d2b | |
parent | fa491001e4edae5ed68a562b61ed729968a3ca1c (diff) |
at86rf230: use ieee802154_is_valid_psdu_len helper
This patch adds the ieee802154_is_valid_psdu_len function to validate
the psdu length. If the psdu length is invalid we use the maximum
payload to receive also corrupted frames in monitor mode.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | drivers/net/ieee802154/at86rf230.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c index e4fbcaa602b6..368791b28585 100644 --- a/drivers/net/ieee802154/at86rf230.c +++ b/drivers/net/ieee802154/at86rf230.c | |||
@@ -788,26 +788,11 @@ at86rf230_tx_trac_status(void *context) | |||
788 | 788 | ||
789 | static void | 789 | static void |
790 | at86rf230_rx(struct at86rf230_local *lp, | 790 | at86rf230_rx(struct at86rf230_local *lp, |
791 | const u8 *data, u8 len) | 791 | const u8 *data, const u8 len) |
792 | { | 792 | { |
793 | u8 lqi; | ||
794 | struct sk_buff *skb; | 793 | struct sk_buff *skb; |
795 | u8 rx_local_buf[AT86RF2XX_MAX_BUF]; | 794 | u8 rx_local_buf[AT86RF2XX_MAX_BUF]; |
796 | 795 | ||
797 | if (len < 2) | ||
798 | return; | ||
799 | |||
800 | /* read full frame buffer and invalid lqi value to lowest | ||
801 | * indicator if frame was is in a corrupted state. | ||
802 | */ | ||
803 | if (len > IEEE802154_MTU) { | ||
804 | lqi = 0; | ||
805 | len = IEEE802154_MTU; | ||
806 | dev_vdbg(&lp->spi->dev, "corrupted frame received\n"); | ||
807 | } else { | ||
808 | lqi = data[len]; | ||
809 | } | ||
810 | |||
811 | memcpy(rx_local_buf, data, len); | 796 | memcpy(rx_local_buf, data, len); |
812 | enable_irq(lp->spi->irq); | 797 | enable_irq(lp->spi->irq); |
813 | 798 | ||
@@ -822,7 +807,7 @@ at86rf230_rx(struct at86rf230_local *lp, | |||
822 | /* We do not put CRC into the frame */ | 807 | /* We do not put CRC into the frame */ |
823 | skb_trim(skb, len - 2); | 808 | skb_trim(skb, len - 2); |
824 | 809 | ||
825 | ieee802154_rx_irqsafe(lp->hw, skb, lqi); | 810 | ieee802154_rx_irqsafe(lp->hw, skb, rx_local_buf[len]); |
826 | } | 811 | } |
827 | 812 | ||
828 | static void | 813 | static void |
@@ -831,7 +816,12 @@ at86rf230_rx_read_frame_complete(void *context) | |||
831 | struct at86rf230_state_change *ctx = context; | 816 | struct at86rf230_state_change *ctx = context; |
832 | struct at86rf230_local *lp = ctx->lp; | 817 | struct at86rf230_local *lp = ctx->lp; |
833 | const u8 *buf = lp->irq.buf; | 818 | const u8 *buf = lp->irq.buf; |
834 | const u8 len = buf[1]; | 819 | u8 len = buf[1]; |
820 | |||
821 | if (!ieee802154_is_valid_psdu_len(len)) { | ||
822 | dev_vdbg(&lp->spi->dev, "corrupted frame received\n"); | ||
823 | len = IEEE802154_MTU; | ||
824 | } | ||
835 | 825 | ||
836 | at86rf230_rx(lp, buf + 2, len); | 826 | at86rf230_rx(lp, buf + 2, len); |
837 | } | 827 | } |