nf_conntrack_compat.h 3.1 KB

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