nf_conntrack_core.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * This header is used to share core functionality between the
  3. * standalone connection tracking module, and the compatibility layer's use
  4. * of connection tracking.
  5. *
  6. * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
  7. * - generalize L3 protocol dependent part.
  8. *
  9. * Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h
  10. */
  11. #ifndef _NF_CONNTRACK_CORE_H
  12. #define _NF_CONNTRACK_CORE_H
  13. #include <linux/netfilter.h>
  14. #include <net/netfilter/nf_conntrack_l3proto.h>
  15. #include <net/netfilter/nf_conntrack_l4proto.h>
  16. #include <net/netfilter/nf_conntrack_ecache.h>
  17. /* This header is used to share core functionality between the
  18. standalone connection tracking module, and the compatibility layer's use
  19. of connection tracking. */
  20. unsigned int nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
  21. struct sk_buff *skb);
  22. int nf_conntrack_init_net(struct net *net);
  23. void nf_conntrack_cleanup_net(struct net *net);
  24. void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list);
  25. int nf_conntrack_proto_pernet_init(struct net *net);
  26. void nf_conntrack_proto_pernet_fini(struct net *net);
  27. int nf_conntrack_proto_init(void);
  28. void nf_conntrack_proto_fini(void);
  29. int nf_conntrack_init_start(void);
  30. void nf_conntrack_cleanup_start(void);
  31. void nf_conntrack_init_end(void);
  32. void nf_conntrack_cleanup_end(void);
  33. bool nf_ct_get_tuple(const struct sk_buff *skb, unsigned int nhoff,
  34. unsigned int dataoff, u_int16_t l3num, u_int8_t protonum,
  35. struct net *net,
  36. struct nf_conntrack_tuple *tuple,
  37. const struct nf_conntrack_l3proto *l3proto,
  38. const struct nf_conntrack_l4proto *l4proto);
  39. bool nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
  40. const struct nf_conntrack_tuple *orig,
  41. const struct nf_conntrack_l3proto *l3proto,
  42. const struct nf_conntrack_l4proto *l4proto);
  43. /* Find a connection corresponding to a tuple. */
  44. struct nf_conntrack_tuple_hash *
  45. nf_conntrack_find_get(struct net *net,
  46. const struct nf_conntrack_zone *zone,
  47. const struct nf_conntrack_tuple *tuple);
  48. int __nf_conntrack_confirm(struct sk_buff *skb);
  49. /* Confirm a connection: returns NF_DROP if packet must be dropped. */
  50. static inline int nf_conntrack_confirm(struct sk_buff *skb)
  51. {
  52. struct nf_conn *ct = (struct nf_conn *)skb->nfct;
  53. int ret = NF_ACCEPT;
  54. if (ct && !nf_ct_is_untracked(ct)) {
  55. if (!nf_ct_is_confirmed(ct))
  56. ret = __nf_conntrack_confirm(skb);
  57. if (likely(ret == NF_ACCEPT))
  58. nf_ct_deliver_cached_events(ct);
  59. }
  60. return ret;
  61. }
  62. void
  63. print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
  64. const struct nf_conntrack_l3proto *l3proto,
  65. const struct nf_conntrack_l4proto *proto);
  66. #ifdef CONFIG_LOCKDEP
  67. # define CONNTRACK_LOCKS 8
  68. #else
  69. # define CONNTRACK_LOCKS 1024
  70. #endif
  71. extern spinlock_t nf_conntrack_locks[CONNTRACK_LOCKS];
  72. extern spinlock_t nf_conntrack_expect_lock;
  73. #endif /* _NF_CONNTRACK_CORE_H */