1
2
3
4
5
6
7
8
9
10
11
12#ifndef _NF_CONNTRACK_L3PROTO_H
13#define _NF_CONNTRACK_L3PROTO_H
14#include <linux/netlink.h>
15#include <net/netlink.h>
16#include <linux/seq_file.h>
17#include <net/netfilter/nf_conntrack.h>
18
19struct nf_conntrack_l3proto {
20
21 u_int16_t l3proto;
22
23
24 const char *name;
25
26
27
28
29
30 bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff,
31 struct nf_conntrack_tuple *tuple);
32
33
34
35
36
37 bool (*invert_tuple)(struct nf_conntrack_tuple *inverse,
38 const struct nf_conntrack_tuple *orig);
39
40
41 void (*print_tuple)(struct seq_file *s,
42 const struct nf_conntrack_tuple *);
43
44
45
46
47
48
49 int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff,
50 unsigned int *dataoff, u_int8_t *protonum);
51
52 int (*tuple_to_nlattr)(struct sk_buff *skb,
53 const struct nf_conntrack_tuple *t);
54
55
56 int (*net_ns_get)(struct net *);
57 void (*net_ns_put)(struct net *);
58
59
60
61
62 int (*nlattr_tuple_size)(void);
63
64 int (*nlattr_to_tuple)(struct nlattr *tb[],
65 struct nf_conntrack_tuple *t);
66 const struct nla_policy *nla_policy;
67
68 size_t nla_size;
69
70
71 struct module *me;
72};
73
74extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX];
75
76#ifdef CONFIG_SYSCTL
77
78int nf_ct_l3proto_pernet_register(struct net *net,
79 struct nf_conntrack_l3proto *proto);
80#else
81static inline int nf_ct_l3proto_pernet_register(struct net *n,
82 struct nf_conntrack_l3proto *p)
83{
84 return 0;
85}
86#endif
87
88void nf_ct_l3proto_pernet_unregister(struct net *net,
89 struct nf_conntrack_l3proto *proto);
90
91
92int nf_ct_l3proto_register(struct nf_conntrack_l3proto *proto);
93void nf_ct_l3proto_unregister(struct nf_conntrack_l3proto *proto);
94
95struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto);
96
97
98extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic;
99
100static inline struct nf_conntrack_l3proto *
101__nf_ct_l3proto_find(u_int16_t l3proto)
102{
103 if (unlikely(l3proto >= AF_MAX))
104 return &nf_conntrack_l3proto_generic;
105 return rcu_dereference(nf_ct_l3protos[l3proto]);
106}
107
108#endif
109