summaryrefslogtreecommitdiffstats
path: root/include/net/mac802154.h
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-09-02 14:21:29 +0200
committerMarcel Holtmann <marcel@holtmann.org>2015-09-17 13:20:04 +0200
commit54552d03023cfd485cedf8d7471d1554139d58aa (patch)
tree9e624523707527367ae0c385bcc6445117c6bd07 /include/net/mac802154.h
parentieee802154: 6lowpan: add check for reserved dispatch (diff)
downloadlinux-54552d03023cfd485cedf8d7471d1554139d58aa.tar.xz
linux-54552d03023cfd485cedf8d7471d1554139d58aa.zip
ieee802154: 6lowpan: check on valid 802.15.4 frame
This patch adds frame control checks to check if the received frame is something which could contain a 6LoWPAN packet. Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com> Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include/net/mac802154.h')
-rw-r--r--include/net/mac802154.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index b7f99615224b..32bd7c0467d4 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -250,6 +250,21 @@ struct ieee802154_ops {
};
/**
+ * ieee802154_get_fc_from_skb - get the frame control field from an skb
+ * @skb: skb where the frame control field will be get from
+ */
+static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
+{
+ /* return some invalid fc on failure */
+ if (unlikely(skb->mac_len < 2)) {
+ WARN_ON(1);
+ return cpu_to_le16(0);
+ }
+
+ return (__force __le16)__get_unaligned_memmove16(skb_mac_header(skb));
+}
+
+/**
* ieee802154_be64_to_le64 - copies and convert be64 to le64
* @le64_dst: le64 destination pointer
* @be64_src: be64 source pointer