9430f5271124b84d2d0c785af2064ba9c61ca725
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / include / linux / skbuff.h
1 #ifndef __LINUX_SKBUFF_WRAPPER_H
2 #define __LINUX_SKBUFF_WRAPPER_H 1
3
4 #include_next <linux/skbuff.h>
5
6 #include <linux/version.h>
7
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)
13 {
14         if (likely(skb != NULL))
15                 (kfree_skb)(skb);
16 }
17 #endif
18
19
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 */
26
27
28 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
29
30 #define mac_header mac.raw
31 #define network_header nh.raw
32
33 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
34 {
35         return skb->h.raw;
36 }
37
38 static inline void skb_set_transport_header(struct sk_buff *skb,
39                         const int offset)
40 {
41         skb->h.raw = skb->data + offset;
42 }
43
44 static inline unsigned char *skb_network_header(const struct sk_buff *skb)
45 {
46         return skb->nh.raw;
47 }
48
49 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
50 {
51         skb->nh.raw = skb->data + offset;
52 }
53
54 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
55 {
56         return skb->mac.raw;
57 }
58
59 static inline void skb_reset_mac_header(struct sk_buff *skb)
60 {
61         skb->mac_header = skb->data;
62 }
63
64 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
65 {
66         skb->mac.raw = skb->data + offset;
67 }
68
69 static inline int skb_transport_offset(const struct sk_buff *skb)
70 {
71     return skb_transport_header(skb) - skb->data;
72 }
73 #endif /* linux kernel < 2.6.22 */
74
75 #endif