Skip to content

Commit

Permalink
6lowpan: introduce lowpan_fetch_skb function
Browse files Browse the repository at this point in the history
This patch adds a helper function to parse the ipv6 header to a
6lowpan header in stream.

This function checks first if we can pull data with a specific
length from a skb. If this seems to be okay, we copy skb data to
a destination pointer and run skb_pull.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Reviewed-by: Werner Almesberger <werner@almesberger.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alexander Aring authored and David S. Miller committed Aug 20, 2013
1 parent 31afe1f commit 4666669
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions net/ieee802154/6lowpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,16 @@
dest = 16 bit inline */
#define LOWPAN_NHC_UDP_CS_P_11 0xF3 /* source & dest = 0xF0B + 4bit inline */

static inline bool lowpan_fetch_skb(struct sk_buff *skb,
void *data, const unsigned int len)
{
if (unlikely(!pskb_may_pull(skb, len)))
return true;

skb_copy_from_linear_data(skb, data, len);
skb_pull(skb, len);

return false;
}

#endif /* __6LOWPAN_H__ */

0 comments on commit 4666669

Please sign in to comment.