Hi, On 06/28/2016 12:00 AM, Alexander Aring wrote: > 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@xxxxxxxxxxxxxx> > --- > include/linux/ieee802154.h | 13 ++++++++++++ > include/net/mac802154.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 63 insertions(+) > ... > > /** > + * 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): > + src_pan = skb_mac_header(skb) + > + IEEE802154_FC_LEN + > + IEEE802154_SEQ_LEN; > + > + switch (ieee802154_daddr_mode(fc)) { > + case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE): This case is more complicated than it looks like: If it's intra_pan and there is no destination pan (because daddr is none), then the source pan should be NULL. If it's not intra_pan then there is no destination address but source address is available with own pan id field. I will fix it in v3. > + break; > + case cpu_to_le16(IEEE802154_FCTL_DADDR_SHORT): > + if (!ieee802154_is_intra_pan(fc)) { > + src_pan += IEEE802154_PAN_ID_LEN + > + IEEE802154_SHORT_ADDR_LEN; > + } > + break; > + case cpu_to_le16(IEEE802154_FCTL_DADDR_EXTENDED): > + if (!ieee802154_is_intra_pan(fc)) { > + src_pan += IEEE802154_PAN_ID_LEN + > + IEEE802154_EXTENDED_ADDR_LEN; > + } > + break; > + default: > + WARN_ONCE(1, "invalid addr mode detected"); > + src_pan = NULL; > + break; > + } > + break; - Alex -- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html