linux/include/net/netfilter/nf_conntrack_expect.h
<<
>>
Prefs
   1/*
   2 * connection tracking expectations.
   3 */
   4
   5#ifndef _NF_CONNTRACK_EXPECT_H
   6#define _NF_CONNTRACK_EXPECT_H
   7
   8#include <net/netfilter/nf_conntrack.h>
   9#include <net/netfilter/nf_conntrack_zones.h>
  10
  11extern unsigned int nf_ct_expect_hsize;
  12extern unsigned int nf_ct_expect_max;
  13extern struct hlist_head *nf_ct_expect_hash;
  14
  15struct nf_conntrack_expect {
  16        /* Conntrack expectation list member */
  17        struct hlist_node lnode;
  18
  19        /* Hash member */
  20        struct hlist_node hnode;
  21
  22        /* We expect this tuple, with the following mask */
  23        struct nf_conntrack_tuple tuple;
  24        struct nf_conntrack_tuple_mask mask;
  25
  26        /* Function to call after setup and insertion */
  27        void (*expectfn)(struct nf_conn *new,
  28                         struct nf_conntrack_expect *this);
  29
  30        /* Helper to assign to new connection */
  31        struct nf_conntrack_helper *helper;
  32
  33        /* The conntrack of the master connection */
  34        struct nf_conn *master;
  35
  36        /* Timer function; deletes the expectation. */
  37        struct timer_list timeout;
  38
  39        /* Usage count. */
  40        atomic_t use;
  41
  42        /* Flags */
  43        unsigned int flags;
  44
  45        /* Expectation class */
  46        unsigned int class;
  47
  48#ifdef CONFIG_NF_NAT_NEEDED
  49        union nf_inet_addr saved_addr;
  50        /* This is the original per-proto part, used to map the
  51         * expected connection the way the recipient expects. */
  52        union nf_conntrack_man_proto saved_proto;
  53        /* Direction relative to the master connection. */
  54        enum ip_conntrack_dir dir;
  55#endif
  56
  57        struct rcu_head rcu;
  58};
  59
  60static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
  61{
  62        return nf_ct_net(exp->master);
  63}
  64
  65#define NF_CT_EXP_POLICY_NAME_LEN       16
  66
  67struct nf_conntrack_expect_policy {
  68        unsigned int    max_expected;
  69        unsigned int    timeout;
  70        char            name[NF_CT_EXP_POLICY_NAME_LEN];
  71};
  72
  73#define NF_CT_EXPECT_CLASS_DEFAULT      0
  74
  75int nf_conntrack_expect_pernet_init(struct net *net);
  76void nf_conntrack_expect_pernet_fini(struct net *net);
  77
  78int nf_conntrack_expect_init(void);
  79void nf_conntrack_expect_fini(void);
  80
  81struct nf_conntrack_expect *
  82__nf_ct_expect_find(struct net *net,
  83                    const struct nf_conntrack_zone *zone,
  84                    const struct nf_conntrack_tuple *tuple);
  85
  86struct nf_conntrack_expect *
  87nf_ct_expect_find_get(struct net *net,
  88                      const struct nf_conntrack_zone *zone,
  89                      const struct nf_conntrack_tuple *tuple);
  90
  91struct nf_conntrack_expect *
  92nf_ct_find_expectation(struct net *net,
  93                       const struct nf_conntrack_zone *zone,
  94                       const struct nf_conntrack_tuple *tuple);
  95
  96void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,
  97                                u32 portid, int report);
  98static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp)
  99{
 100        nf_ct_unlink_expect_report(exp, 0, 0);
 101}
 102
 103void nf_ct_remove_expectations(struct nf_conn *ct);
 104void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
 105
 106/* Allocate space for an expectation: this is mandatory before calling
 107   nf_ct_expect_related.  You will have to call put afterwards. */
 108struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me);
 109void nf_ct_expect_init(struct nf_conntrack_expect *, unsigned int, u_int8_t,
 110                       const union nf_inet_addr *,
 111                       const union nf_inet_addr *,
 112                       u_int8_t, const __be16 *, const __be16 *);
 113void nf_ct_expect_put(struct nf_conntrack_expect *exp);
 114int nf_ct_expect_related_report(struct nf_conntrack_expect *expect, 
 115                                u32 portid, int report);
 116static inline int nf_ct_expect_related(struct nf_conntrack_expect *expect)
 117{
 118        return nf_ct_expect_related_report(expect, 0, 0);
 119}
 120
 121#endif /*_NF_CONNTRACK_EXPECT_H*/
 122
 123