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_set_transport_header(struct sk_buff *skb,
41 skb->h.raw = skb->data + offset;
44 static inline unsigned char *skb_network_header(const struct sk_buff *skb)
49 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
51 skb->nh.raw = skb->data + offset;
54 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
59 static inline void skb_reset_mac_header(struct sk_buff *skb)
61 skb->mac_header = skb->data;
64 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
66 skb->mac.raw = skb->data + offset;
69 static inline int skb_transport_offset(const struct sk_buff *skb)
71 return skb_transport_header(skb) - skb->data;
73 #endif /* linux kernel < 2.6.22 */