]>
Commit | Line | Data |
---|---|---|
9fb9cbb1 YK |
1 | /* |
2 | * Copyright (C)2003,2004 USAGI/WIDE Project | |
3 | * | |
4 | * Header for use in defining a given L3 protocol for connection tracking. | |
5 | * | |
6 | * Author: | |
7 | * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
8 | * | |
9 | * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h | |
10 | */ | |
11 | ||
12 | #ifndef _NF_CONNTRACK_L3PROTO_H | |
13 | #define _NF_CONNTRACK_L3PROTO_H | |
df6fb868 | 14 | #include <linux/netlink.h> |
f73e924c | 15 | #include <net/netlink.h> |
9fb9cbb1 YK |
16 | #include <linux/seq_file.h> |
17 | #include <net/netfilter/nf_conntrack.h> | |
18 | ||
fd2c3ef7 | 19 | struct nf_conntrack_l3proto { |
9fb9cbb1 YK |
20 | /* L3 Protocol Family number. ex) PF_INET */ |
21 | u_int16_t l3proto; | |
22 | ||
23 | /* Protocol name */ | |
24 | const char *name; | |
25 | ||
26 | /* | |
27 | * Try to fill in the third arg: nhoff is offset of l3 proto | |
28 | * hdr. Return true if possible. | |
29 | */ | |
8ce8439a JE |
30 | bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff, |
31 | struct nf_conntrack_tuple *tuple); | |
9fb9cbb1 YK |
32 | |
33 | /* | |
34 | * Invert the per-proto part of the tuple: ie. turn xmit into reply. | |
35 | * Some packets can't be inverted: return 0 in that case. | |
36 | */ | |
8ce8439a JE |
37 | bool (*invert_tuple)(struct nf_conntrack_tuple *inverse, |
38 | const struct nf_conntrack_tuple *orig); | |
9fb9cbb1 YK |
39 | |
40 | /* Print out the per-protocol part of the tuple. */ | |
824f1fbe JP |
41 | void (*print_tuple)(struct seq_file *s, |
42 | const struct nf_conntrack_tuple *); | |
9fb9cbb1 | 43 | |
9fb9cbb1 YK |
44 | /* |
45 | * Called before tracking. | |
ffc30690 | 46 | * *dataoff: offset of protocol header (TCP, UDP,...) in skb |
9fb9cbb1 YK |
47 | * *protonum: protocol number |
48 | */ | |
ffc30690 YK |
49 | int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff, |
50 | unsigned int *dataoff, u_int8_t *protonum); | |
9fb9cbb1 | 51 | |
fdf70832 | 52 | int (*tuple_to_nlattr)(struct sk_buff *skb, |
c1d10adb PNA |
53 | const struct nf_conntrack_tuple *t); |
54 | ||
0c66dc1e FW |
55 | /* Called when netns wants to use connection tracking */ |
56 | int (*net_ns_get)(struct net *); | |
57 | void (*net_ns_put)(struct net *); | |
58 | ||
d0dba725 HE |
59 | /* |
60 | * Calculate size of tuple nlattr | |
61 | */ | |
62 | int (*nlattr_tuple_size)(void); | |
63 | ||
fdf70832 | 64 | int (*nlattr_to_tuple)(struct nlattr *tb[], |
c1d10adb | 65 | struct nf_conntrack_tuple *t); |
f73e924c | 66 | const struct nla_policy *nla_policy; |
c1d10adb | 67 | |
d0dba725 HE |
68 | size_t nla_size; |
69 | ||
9fb9cbb1 YK |
70 | /* Module (if any) which this is connected to. */ |
71 | struct module *me; | |
72 | }; | |
73 | ||
0e60ebe0 | 74 | extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX]; |
9fb9cbb1 | 75 | |
481fa373 | 76 | #ifdef CONFIG_SYSCTL |
6330750d | 77 | /* Protocol pernet registration. */ |
4e77be46 JP |
78 | int nf_ct_l3proto_pernet_register(struct net *net, |
79 | struct nf_conntrack_l3proto *proto); | |
481fa373 FW |
80 | #else |
81 | static inline int nf_ct_l3proto_pernet_register(struct net *n, | |
82 | struct nf_conntrack_l3proto *p) | |
83 | { | |
84 | return 0; | |
85 | } | |
86 | #endif | |
87 | ||
4e77be46 JP |
88 | void nf_ct_l3proto_pernet_unregister(struct net *net, |
89 | struct nf_conntrack_l3proto *proto); | |
6330750d G |
90 | |
91 | /* Protocol global registration. */ | |
4e77be46 JP |
92 | int nf_ct_l3proto_register(struct nf_conntrack_l3proto *proto); |
93 | void nf_ct_l3proto_unregister(struct nf_conntrack_l3proto *proto); | |
6330750d | 94 | |
4e77be46 | 95 | struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto); |
c1d10adb | 96 | |
9fb9cbb1 | 97 | /* Existing built-in protocols */ |
605dcad6 | 98 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic; |
ddc8d029 YK |
99 | |
100 | static inline struct nf_conntrack_l3proto * | |
101 | __nf_ct_l3proto_find(u_int16_t l3proto) | |
102 | { | |
103 | if (unlikely(l3proto >= AF_MAX)) | |
605dcad6 | 104 | return &nf_conntrack_l3proto_generic; |
923f4902 | 105 | return rcu_dereference(nf_ct_l3protos[l3proto]); |
ddc8d029 YK |
106 | } |
107 | ||
9fb9cbb1 | 108 | #endif /*_NF_CONNTRACK_L3PROTO_H*/ |