aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ieee802154.h
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-10-27 12:13:40 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-10-27 13:07:49 -0400
commitfa491001e4edae5ed68a562b61ed729968a3ca1c (patch)
treef6a2474c85b0ac0c0d46ec10f1048d8feafb37c3 /include/linux/ieee802154.h
parente176b681b00d2b60e9231072d3ca841f9ddc74ea (diff)
ieee802154: add valid psdu length helper
This patch adds a generic valid psdu length check function helper. This is useful to check the length field after receiving. For example the at86rf231 doesn't filter invalid psdu length. Sometimes the CRC can also be correct. If we get the lqi value with an invalid frame length the kernel may crash because we dereference an invalid pointer in the receive buffer. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include/linux/ieee802154.h')
-rw-r--r--include/linux/ieee802154.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 2dfab2db103a..6e50a2a1d485 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -23,7 +23,10 @@
23#ifndef LINUX_IEEE802154_H 23#ifndef LINUX_IEEE802154_H
24#define LINUX_IEEE802154_H 24#define LINUX_IEEE802154_H
25 25
26#include <linux/types.h>
27
26#define IEEE802154_MTU 127 28#define IEEE802154_MTU 127
29#define IEEE802154_MIN_PSDU_LEN 5
27 30
28#define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */ 31#define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */
29#define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */ 32#define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */
@@ -185,5 +188,13 @@ enum {
185 IEEE802154_SCAN_IN_PROGRESS = 0xfc, 188 IEEE802154_SCAN_IN_PROGRESS = 0xfc,
186}; 189};
187 190
191/**
192 * ieee802154_is_valid_psdu_len - check if psdu len is valid
193 * @len: psdu len with (MHR + payload + MFR)
194 */
195static inline bool ieee802154_is_valid_psdu_len(const u8 len)
196{
197 return (len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU);
198}
188 199
189#endif /* LINUX_IEEE802154_H */ 200#endif /* LINUX_IEEE802154_H */