]> Pileus Git - ~andy/linux/commitdiff
6lowpan: introduce lowpan_fetch_skb function
authorAlexander Aring <alex.aring@gmail.com>
Fri, 16 Aug 2013 19:59:56 +0000 (21:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Aug 2013 20:23:11 +0000 (13:23 -0700)
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>
net/ieee802154/6lowpan.h

index 4b8f917658b52fa028200d9ec1ab788130ecd143..a636545d8dcfda14ab76f296fa37bb3276a92ccc 100644 (file)
                                        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__ */