Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 1 | #ifndef _NF_CONNTRACK_COMPAT_H |
| 2 | #define _NF_CONNTRACK_COMPAT_H |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | |
| 6 | #if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE) |
| 7 | |
| 8 | #include <linux/netfilter_ipv4/ip_conntrack.h> |
| 9 | |
| 10 | #ifdef CONFIG_IP_NF_CONNTRACK_MARK |
| 11 | static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb, |
| 12 | u_int32_t *ctinfo) |
| 13 | { |
| 14 | struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo); |
| 15 | |
| 16 | if (ct) |
| 17 | return &ct->mark; |
| 18 | else |
| 19 | return NULL; |
| 20 | } |
| 21 | #endif /* CONFIG_IP_NF_CONNTRACK_MARK */ |
| 22 | |
James Morris | 7c9728c | 2006-06-09 00:31:46 -0700 | [diff] [blame] | 23 | #ifdef CONFIG_IP_NF_CONNTRACK_SECMARK |
| 24 | static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb, |
| 25 | u_int32_t *ctinfo) |
| 26 | { |
| 27 | struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo); |
| 28 | |
| 29 | if (ct) |
| 30 | return &ct->secmark; |
| 31 | else |
| 32 | return NULL; |
| 33 | } |
| 34 | #endif /* CONFIG_IP_NF_CONNTRACK_SECMARK */ |
| 35 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 36 | #ifdef CONFIG_IP_NF_CT_ACCT |
| 37 | static inline struct ip_conntrack_counter * |
| 38 | nf_ct_get_counters(const struct sk_buff *skb) |
| 39 | { |
| 40 | enum ip_conntrack_info ctinfo; |
| 41 | struct ip_conntrack *ct = ip_conntrack_get(skb, &ctinfo); |
| 42 | |
| 43 | if (ct) |
| 44 | return ct->counters; |
| 45 | else |
| 46 | return NULL; |
| 47 | } |
| 48 | #endif /* CONFIG_IP_NF_CT_ACCT */ |
| 49 | |
| 50 | static inline int nf_ct_is_untracked(const struct sk_buff *skb) |
| 51 | { |
| 52 | return (skb->nfct == &ip_conntrack_untracked.ct_general); |
| 53 | } |
| 54 | |
| 55 | static inline void nf_ct_untrack(struct sk_buff *skb) |
| 56 | { |
| 57 | skb->nfct = &ip_conntrack_untracked.ct_general; |
| 58 | } |
| 59 | |
| 60 | static inline int nf_ct_get_ctinfo(const struct sk_buff *skb, |
| 61 | enum ip_conntrack_info *ctinfo) |
| 62 | { |
| 63 | struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo); |
| 64 | return (ct != NULL); |
| 65 | } |
| 66 | |
| 67 | #else /* CONFIG_IP_NF_CONNTRACK */ |
| 68 | |
| 69 | #include <net/netfilter/ipv4/nf_conntrack_ipv4.h> |
| 70 | #include <net/netfilter/nf_conntrack.h> |
| 71 | |
| 72 | #ifdef CONFIG_NF_CONNTRACK_MARK |
| 73 | |
| 74 | static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb, |
| 75 | u_int32_t *ctinfo) |
| 76 | { |
| 77 | struct nf_conn *ct = nf_ct_get(skb, ctinfo); |
| 78 | |
| 79 | if (ct) |
| 80 | return &ct->mark; |
| 81 | else |
| 82 | return NULL; |
| 83 | } |
| 84 | #endif /* CONFIG_NF_CONNTRACK_MARK */ |
| 85 | |
James Morris | 7c9728c | 2006-06-09 00:31:46 -0700 | [diff] [blame] | 86 | #ifdef CONFIG_NF_CONNTRACK_SECMARK |
| 87 | static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb, |
| 88 | u_int32_t *ctinfo) |
| 89 | { |
| 90 | struct nf_conn *ct = nf_ct_get(skb, ctinfo); |
| 91 | |
| 92 | if (ct) |
| 93 | return &ct->secmark; |
| 94 | else |
| 95 | return NULL; |
| 96 | } |
| 97 | #endif /* CONFIG_NF_CONNTRACK_MARK */ |
| 98 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 99 | #ifdef CONFIG_NF_CT_ACCT |
| 100 | static inline struct ip_conntrack_counter * |
| 101 | nf_ct_get_counters(const struct sk_buff *skb) |
| 102 | { |
| 103 | enum ip_conntrack_info ctinfo; |
| 104 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
| 105 | |
| 106 | if (ct) |
| 107 | return ct->counters; |
| 108 | else |
| 109 | return NULL; |
| 110 | } |
| 111 | #endif /* CONFIG_NF_CT_ACCT */ |
| 112 | |
| 113 | static inline int nf_ct_is_untracked(const struct sk_buff *skb) |
| 114 | { |
| 115 | return (skb->nfct == &nf_conntrack_untracked.ct_general); |
| 116 | } |
| 117 | |
| 118 | static inline void nf_ct_untrack(struct sk_buff *skb) |
| 119 | { |
| 120 | skb->nfct = &nf_conntrack_untracked.ct_general; |
| 121 | } |
| 122 | |
| 123 | static inline int nf_ct_get_ctinfo(const struct sk_buff *skb, |
| 124 | enum ip_conntrack_info *ctinfo) |
| 125 | { |
| 126 | struct nf_conn *ct = nf_ct_get(skb, ctinfo); |
| 127 | return (ct != NULL); |
| 128 | } |
| 129 | |
| 130 | #endif /* CONFIG_IP_NF_CONNTRACK */ |
| 131 | |
| 132 | #endif /* __KERNEL__ */ |
| 133 | |
| 134 | #endif /* _NF_CONNTRACK_COMPAT_H */ |