1 #ifndef __LINUX_SKBUFF_WRAPPER_H
2 #define __LINUX_SKBUFF_WRAPPER_H 1
4 #include_next <linux/skbuff.h>
6 #include <linux/version.h>
8 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
9 /* Emulate Linux 2.6.17 and later behavior, in which kfree_skb silently ignores
10 * null pointer arguments. */
11 #define kfree_skb(skb) kfree_skb_maybe_null(skb)
12 static inline void kfree_skb_maybe_null(struct sk_buff *skb)
14 if (likely(skb != NULL))
20 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
21 /* Note that CHECKSUM_PARTIAL is not implemented, but this allows us to at
22 * least test against it: see update_csum() in forward.c. */
23 #define CHECKSUM_PARTIAL 3
24 #define CHECKSUM_COMPLETE CHECKSUM_HW
25 #endif /* linux kernel < 2.6.19 */
28 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
30 #define mac_header mac.raw
31 #define network_header nh.raw
33 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
38 static inline void skb_reset_transport_header(struct sk_buff *skb)
40 skb->h.raw = skb->data;
43 static inline void skb_set_transport_header(struct sk_buff *skb,
46 skb->h.raw = skb->data + offset;
49 static inline unsigned char *skb_network_header(const struct sk_buff *skb)
54 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
56 skb->nh.raw = skb->data + offset;
59 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
64 static inline void skb_reset_mac_header(struct sk_buff *skb)
66 skb->mac_header = skb->data;
69 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
71 skb->mac.raw = skb->data + offset;
74 static inline int skb_transport_offset(const struct sk_buff *skb)
76 return skb_transport_header(skb) - skb->data;
79 static inline int skb_network_offset(const struct sk_buff *skb)
81 return skb_network_header(skb) - skb->data;
84 static inline void skb_copy_to_linear_data(struct sk_buff *skb,
86 const unsigned int len)
88 memcpy(skb->data, from, len);
90 #endif /* linux kernel < 2.6.22 */