diff options
author | Alexander Aring <aar@pengutronix.de> | 2016-07-06 23:32:25 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2016-07-08 13:23:12 +0200 |
commit | 19580cc1ed299c736b56b45c7576b477f185f8f5 (patch) | |
tree | 9462cfe0a4bfa24f5c7e91a96288353c441bf5d0 /include/net | |
parent | ieee802154: add ieee802154_skb_dst_pan helper (diff) | |
download | linux-19580cc1ed299c736b56b45c7576b477f185f8f5.tar.xz linux-19580cc1ed299c736b56b45c7576b477f185f8f5.zip |
ieee802154: add ieee802154_skb_src_pan helper
This patch adds ieee802154_skb_src_pan function to get the pointer
address of the source pan id at skb mac pointer.
Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/mac802154.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/include/net/mac802154.h b/include/net/mac802154.h index b3f7cd868fe9..ec01b35bc969 100644 --- a/include/net/mac802154.h +++ b/include/net/mac802154.h @@ -287,6 +287,65 @@ static inline unsigned char *ieee802154_skb_dst_pan(__le16 fc, } /** + * ieee802154_skb_src_pan - get the pointer to source pan field + * @fc: mac header frame control field + * @skb: skb where the source pan pointer will be get from + */ +static inline unsigned char *ieee802154_skb_src_pan(__le16 fc, + const struct sk_buff *skb) +{ + unsigned char *src_pan; + + switch (ieee802154_saddr_mode(fc)) { + case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE): + src_pan = NULL; + break; + case cpu_to_le16(IEEE802154_FCTL_SADDR_SHORT): + case cpu_to_le16(IEEE802154_FCTL_SADDR_EXTENDED): + /* if intra-pan and source addr mode is non none, + * then source pan id is equal destination pan id. + */ + if (ieee802154_is_intra_pan(fc)) { + src_pan = ieee802154_skb_dst_pan(fc, skb); + break; + } + + switch (ieee802154_daddr_mode(fc)) { + case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE): + src_pan = skb_mac_header(skb) + + IEEE802154_FC_LEN + + IEEE802154_SEQ_LEN; + break; + case cpu_to_le16(IEEE802154_FCTL_DADDR_SHORT): + src_pan = skb_mac_header(skb) + + IEEE802154_FC_LEN + + IEEE802154_SEQ_LEN + + IEEE802154_PAN_ID_LEN + + IEEE802154_SHORT_ADDR_LEN; + break; + case cpu_to_le16(IEEE802154_FCTL_DADDR_EXTENDED): + src_pan = skb_mac_header(skb) + + IEEE802154_FC_LEN + + IEEE802154_SEQ_LEN + + IEEE802154_PAN_ID_LEN + + IEEE802154_EXTENDED_ADDR_LEN; + break; + default: + WARN_ONCE(1, "invalid addr mode detected"); + src_pan = NULL; + break; + } + break; + default: + WARN_ONCE(1, "invalid addr mode detected"); + src_pan = NULL; + break; + } + + return src_pan; +} + +/** * ieee802154_be64_to_le64 - copies and convert be64 to le64 * @le64_dst: le64 destination pointer * @be64_src: be64 source pointer |