~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/netfilter/nf_conntrack_helper.h

Version: ~ [ linux-5.19-rc3 ] ~ [ linux-5.18.5 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.48 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.123 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.199 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.248 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.284 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.319 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 
 10 #ifndef _NF_CONNTRACK_HELPER_H
 11 #define _NF_CONNTRACK_HELPER_H
 12 #include <linux/refcount.h>
 13 #include <net/netfilter/nf_conntrack.h>
 14 #include <net/netfilter/nf_conntrack_extend.h>
 15 #include <net/netfilter/nf_conntrack_expect.h>
 16 
 17 struct module;
 18 
 19 enum nf_ct_helper_flags {
 20         NF_CT_HELPER_F_USERSPACE        = (1 << 0),
 21         NF_CT_HELPER_F_CONFIGURED       = (1 << 1),
 22 };
 23 
 24 #define NF_CT_HELPER_NAME_LEN   16
 25 
 26 struct nf_conntrack_helper {
 27         struct hlist_node hnode;        /* Internal use. */
 28 
 29         char name[NF_CT_HELPER_NAME_LEN]; /* name of the module */
 30         refcount_t refcnt;
 31         struct module *me;              /* pointer to self */
 32         const struct nf_conntrack_expect_policy *expect_policy;
 33 
 34         /* Tuple of things we will help (compared against server response) */
 35         struct nf_conntrack_tuple tuple;
 36 
 37         /* Function to call when data passes; return verdict, or -1 to
 38            invalidate. */
 39         int (*help)(struct sk_buff *skb,
 40                     unsigned int protoff,
 41                     struct nf_conn *ct,
 42                     enum ip_conntrack_info conntrackinfo);
 43 
 44         void (*destroy)(struct nf_conn *ct);
 45 
 46         int (*from_nlattr)(struct nlattr *attr, struct nf_conn *ct);
 47         int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct);
 48         unsigned int expect_class_max;
 49 
 50         unsigned int flags;
 51 
 52         /* For user-space helpers: */
 53         unsigned int queue_num;
 54         /* length of userspace private data stored in nf_conn_help->data */
 55         u16 data_len;
 56 };
 57 
 58 /* Must be kept in sync with the classes defined by helpers */
 59 #define NF_CT_MAX_EXPECT_CLASSES        4
 60 
 61 /* nf_conn feature for connections that have a helper */
 62 struct nf_conn_help {
 63         /* Helper. if any */
 64         struct nf_conntrack_helper __rcu *helper;
 65 
 66         struct hlist_head expectations;
 67 
 68         /* Current number of expected connections */
 69         u8 expecting[NF_CT_MAX_EXPECT_CLASSES];
 70 
 71         /* private helper information. */
 72         char data[32] __aligned(8);
 73 };
 74 
 75 #define NF_CT_HELPER_BUILD_BUG_ON(structsize) \
 76         BUILD_BUG_ON((structsize) > FIELD_SIZEOF(struct nf_conn_help, data))
 77 
 78 struct nf_conntrack_helper *__nf_conntrack_helper_find(const char *name,
 79                                                        u16 l3num, u8 protonum);
 80 
 81 struct nf_conntrack_helper *nf_conntrack_helper_try_module_get(const char *name,
 82                                                                u16 l3num,
 83                                                                u8 protonum);
 84 void nf_conntrack_helper_put(struct nf_conntrack_helper *helper);
 85 
 86 void nf_ct_helper_init(struct nf_conntrack_helper *helper,
 87                        u16 l3num, u16 protonum, const char *name,
 88                        u16 default_port, u16 spec_port, u32 id,
 89                        const struct nf_conntrack_expect_policy *exp_pol,
 90                        u32 expect_class_max,
 91                        int (*help)(struct sk_buff *skb, unsigned int protoff,
 92                                    struct nf_conn *ct,
 93                                    enum ip_conntrack_info ctinfo),
 94                        int (*from_nlattr)(struct nlattr *attr,
 95                                           struct nf_conn *ct),
 96                        struct module *module);
 97 
 98 int nf_conntrack_helper_register(struct nf_conntrack_helper *);
 99 void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
100 
101 int nf_conntrack_helpers_register(struct nf_conntrack_helper *, unsigned int);
102 void nf_conntrack_helpers_unregister(struct nf_conntrack_helper *,
103                                      unsigned int);
104 
105 struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct,
106                                           struct nf_conntrack_helper *helper,
107                                           gfp_t gfp);
108 
109 int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
110                               gfp_t flags);
111 
112 void nf_ct_helper_destroy(struct nf_conn *ct);
113 
114 static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
115 {
116         return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
117 }
118 
119 static inline void *nfct_help_data(const struct nf_conn *ct)
120 {
121         struct nf_conn_help *help;
122 
123         help = nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
124 
125         return (void *)help->data;
126 }
127 
128 int nf_conntrack_helper_pernet_init(struct net *net);
129 void nf_conntrack_helper_pernet_fini(struct net *net);
130 
131 int nf_conntrack_helper_init(void);
132 void nf_conntrack_helper_fini(void);
133 
134 int nf_conntrack_broadcast_help(struct sk_buff *skb, unsigned int protoff,
135                                 struct nf_conn *ct,
136                                 enum ip_conntrack_info ctinfo,
137                                 unsigned int timeout);
138 
139 struct nf_ct_helper_expectfn {
140         struct list_head head;
141         const char *name;
142         void (*expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp);
143 };
144 
145 __printf(3,4)
146 void nf_ct_helper_log(struct sk_buff *skb, const struct nf_conn *ct,
147                       const char *fmt, ...);
148 
149 void nf_ct_helper_expectfn_register(struct nf_ct_helper_expectfn *n);
150 void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n);
151 struct nf_ct_helper_expectfn *
152 nf_ct_helper_expectfn_find_by_name(const char *name);
153 struct nf_ct_helper_expectfn *
154 nf_ct_helper_expectfn_find_by_symbol(const void *symbol);
155 
156 extern struct hlist_head *nf_ct_helper_hash;
157 extern unsigned int nf_ct_helper_hsize;
158 
159 #endif /*_NF_CONNTRACK_HELPER_H*/
160 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp