Commit 0ea0b9af authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

ieee802154: 6lowpan: fix intra pan id check

The RIOT-OS stack does send intra-pan frames but don't set the intra pan
flag inside the mac header. It seems this is valid frame addressing but
inefficient. Anyway this patch adds a new function for intra pan
addressing, doesn't matter if intra pan flag or source and destination
are the same. The newly introduction function will be used to check on
intra pan addressing for 6lowpan.
Signed-off-by: default avatarAlexander Aring <aar@pengutronix.de>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 19580cc1
...@@ -345,6 +345,25 @@ static inline unsigned char *ieee802154_skb_src_pan(__le16 fc, ...@@ -345,6 +345,25 @@ static inline unsigned char *ieee802154_skb_src_pan(__le16 fc,
return src_pan; return src_pan;
} }
/**
* ieee802154_skb_is_intra_pan_addressing - checks whenever the mac addressing
* is an intra pan communication
* @fc: mac header frame control field
* @skb: skb where the source and destination pan should be get from
*/
static inline bool ieee802154_skb_is_intra_pan_addressing(__le16 fc,
const struct sk_buff *skb)
{
unsigned char *dst_pan = ieee802154_skb_dst_pan(fc, skb),
*src_pan = ieee802154_skb_src_pan(fc, skb);
/* if one is NULL is no intra pan addressing */
if (!dst_pan || !src_pan)
return false;
return !memcmp(dst_pan, src_pan, IEEE802154_PAN_ID_LEN);
}
/** /**
* ieee802154_be64_to_le64 - copies and convert be64 to le64 * ieee802154_be64_to_le64 - copies and convert be64 to le64
* @le64_dst: le64 destination pointer * @le64_dst: le64 destination pointer
......
...@@ -262,7 +262,7 @@ static inline bool lowpan_rx_h_check(struct sk_buff *skb) ...@@ -262,7 +262,7 @@ static inline bool lowpan_rx_h_check(struct sk_buff *skb)
/* check on ieee802154 conform 6LoWPAN header */ /* check on ieee802154 conform 6LoWPAN header */
if (!ieee802154_is_data(fc) || if (!ieee802154_is_data(fc) ||
!ieee802154_is_intra_pan(fc)) !ieee802154_skb_is_intra_pan_addressing(fc, skb))
return false; return false;
/* check if we can dereference the dispatch */ /* check if we can dereference the dispatch */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment