nf_conntrack_helper.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * connection tracking helpers.
  3. *
  4. * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
  5. * - generalize L3 protocol dependent part.
  6. *
  7. * Derived from include/linux/netfiter_ipv4/ip_conntrack_helper.h
  8. */
  9. #ifndef _NF_CONNTRACK_HELPER_H
  10. #define _NF_CONNTRACK_HELPER_H
  11. #include <net/netfilter/nf_conntrack.h>
  12. #include <net/netfilter/nf_conntrack_extend.h>
  13. #include <net/netfilter/nf_conntrack_expect.h>
  14. struct module;
  15. enum nf_ct_helper_flags {
  16. NF_CT_HELPER_F_USERSPACE = (1 << 0),
  17. NF_CT_HELPER_F_CONFIGURED = (1 << 1),
  18. };
  19. #define NF_CT_HELPER_NAME_LEN 16
  20. struct nf_conntrack_helper {
  21. struct hlist_node hnode; /* Internal use. */
  22. char name[NF_CT_HELPER_NAME_LEN]; /* name of the module */
  23. struct module *me; /* pointer to self */
  24. const struct nf_conntrack_expect_policy *expect_policy;
  25. /* length of internal data, ie. sizeof(struct nf_ct_*_master) */
  26. size_t data_len;
  27. /* Tuple of things we will help (compared against server response) */
  28. struct nf_conntrack_tuple tuple;
  29. /* Function to call when data passes; return verdict, or -1 to
  30. invalidate. */
  31. int (*help)(struct sk_buff *skb,
  32. unsigned int protoff,
  33. struct nf_conn *ct,
  34. enum ip_conntrack_info conntrackinfo);
  35. void (*destroy)(struct nf_conn *ct);
  36. int (*from_nlattr)(struct nlattr *attr, struct nf_conn *ct);
  37. int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct);
  38. unsigned int expect_class_max;
  39. unsigned int flags;
  40. unsigned int queue_num; /* For user-space helpers. */
  41. };
  42. struct nf_conntrack_helper *__nf_conntrack_helper_find(const char *name,
  43. u16 l3num, u8 protonum);
  44. struct nf_conntrack_helper *nf_conntrack_helper_try_module_get(const char *name,
  45. u16 l3num,
  46. u8 protonum);
  47. int nf_conntrack_helper_register(struct nf_conntrack_helper *);
  48. void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
  49. struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct,
  50. struct nf_conntrack_helper *helper,
  51. gfp_t gfp);
  52. int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
  53. gfp_t flags);
  54. void nf_ct_helper_destroy(struct nf_conn *ct);
  55. static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
  56. {
  57. return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
  58. }
  59. static inline void *nfct_help_data(const struct nf_conn *ct)
  60. {
  61. struct nf_conn_help *help;
  62. help = nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
  63. return (void *)help->data;
  64. }
  65. int nf_conntrack_helper_pernet_init(struct net *net);
  66. void nf_conntrack_helper_pernet_fini(struct net *net);
  67. int nf_conntrack_helper_init(void);
  68. void nf_conntrack_helper_fini(void);
  69. int nf_conntrack_broadcast_help(struct sk_buff *skb, unsigned int protoff,
  70. struct nf_conn *ct,
  71. enum ip_conntrack_info ctinfo,
  72. unsigned int timeout);
  73. struct nf_ct_helper_expectfn {
  74. struct list_head head;
  75. const char *name;
  76. void (*expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
  77. };
  78. __printf(3,4)
  79. void nf_ct_helper_log(struct sk_buff *skb, const struct nf_conn *ct,
  80. const char *fmt, ...);
  81. void nf_ct_helper_expectfn_register(struct nf_ct_helper_expectfn *n);
  82. void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n);
  83. struct nf_ct_helper_expectfn *
  84. nf_ct_helper_expectfn_find_by_name(const char *name);
  85. struct nf_ct_helper_expectfn *
  86. nf_ct_helper_expectfn_find_by_symbol(const void *symbol);
  87. extern struct hlist_head *nf_ct_helper_hash;
  88. extern unsigned int nf_ct_helper_hsize;
  89. #endif /*_NF_CONNTRACK_HELPER_H*/