diff options
author | Alexander Aring <alex.aring@gmail.com> | 2013-08-16 15:59:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-20 16:23:11 -0400 |
commit | 4666669fc3b83f0d01b08c6b17432563f2eedcba (patch) | |
tree | 393f1fb642ac6aeff475f72e5b4a297385c2d5e0 /net/ieee802154 | |
parent | 31afe1f73e46221650acfcb411e6949f4a8f7571 (diff) |
6lowpan: introduce lowpan_fetch_skb function
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>
Diffstat (limited to 'net/ieee802154')
-rw-r--r-- | net/ieee802154/6lowpan.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h index 4b8f917658b5..a636545d8dcf 100644 --- a/net/ieee802154/6lowpan.h +++ b/net/ieee802154/6lowpan.h | |||
@@ -230,4 +230,16 @@ | |||
230 | dest = 16 bit inline */ | 230 | dest = 16 bit inline */ |
231 | #define LOWPAN_NHC_UDP_CS_P_11 0xF3 /* source & dest = 0xF0B + 4bit inline */ | 231 | #define LOWPAN_NHC_UDP_CS_P_11 0xF3 /* source & dest = 0xF0B + 4bit inline */ |
232 | 232 | ||
233 | static inline bool lowpan_fetch_skb(struct sk_buff *skb, | ||
234 | void *data, const unsigned int len) | ||
235 | { | ||
236 | if (unlikely(!pskb_may_pull(skb, len))) | ||
237 | return true; | ||
238 | |||
239 | skb_copy_from_linear_data(skb, data, len); | ||
240 | skb_pull(skb, len); | ||
241 | |||
242 | return false; | ||
243 | } | ||
244 | |||
233 | #endif /* __6LOWPAN_H__ */ | 245 | #endif /* __6LOWPAN_H__ */ |