ieee802154: add ieee802154_skb_dst_pan helper

This patch adds ieee802154_skb_dst_pan function to get the pointer
address of the destination pan id at skb mac pointer.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
Alexander Aring
2016-07-06 23:32:24 +02:00
committed by Marcel Holtmann
parent 47ca5898eb
commit 9cc577dd25
2 changed files with 45 additions and 0 deletions

View File

@@ -257,6 +257,35 @@ static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
return get_unaligned_le16(skb_mac_header(skb));
}
/**
* ieee802154_skb_dst_pan - get the pointer to destination pan field
* @fc: mac header frame control field
* @skb: skb where the destination pan pointer will be get from
*/
static inline unsigned char *ieee802154_skb_dst_pan(__le16 fc,
const struct sk_buff *skb)
{
unsigned char *dst_pan;
switch (ieee802154_daddr_mode(fc)) {
case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE):
dst_pan = NULL;
break;
case cpu_to_le16(IEEE802154_FCTL_DADDR_SHORT):
case cpu_to_le16(IEEE802154_FCTL_DADDR_EXTENDED):
dst_pan = skb_mac_header(skb) +
IEEE802154_FC_LEN +
IEEE802154_SEQ_LEN;
break;
default:
WARN_ONCE(1, "invalid addr mode detected");
dst_pan = NULL;
break;
}
return dst_pan;
}
/**
* ieee802154_be64_to_le64 - copies and convert be64 to le64
* @le64_dst: le64 destination pointer