]>
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 | ||
0d035100 FW |
23 | /* size of tuple nlattr, fills a hole */ |
24 | u16 nla_size; | |
25 | ||
9fb9cbb1 YK |
26 | /* Protocol name */ |
27 | const char *name; | |
28 | ||
29 | /* | |
30 | * Try to fill in the third arg: nhoff is offset of l3 proto | |
31 | * hdr. Return true if possible. | |
32 | */ | |
8ce8439a JE |
33 | bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff, |
34 | struct nf_conntrack_tuple *tuple); | |
9fb9cbb1 YK |
35 | |
36 | /* | |
37 | * Invert the per-proto part of the tuple: ie. turn xmit into reply. | |
38 | * Some packets can't be inverted: return 0 in that case. | |
39 | */ | |
8ce8439a JE |
40 | bool (*invert_tuple)(struct nf_conntrack_tuple *inverse, |
41 | const struct nf_conntrack_tuple *orig); | |
9fb9cbb1 YK |
42 | |
43 | /* Print out the per-protocol part of the tuple. */ | |
824f1fbe JP |
44 | void (*print_tuple)(struct seq_file *s, |
45 | const struct nf_conntrack_tuple *); | |
9fb9cbb1 | 46 | |
9fb9cbb1 YK |
47 | /* |
48 | * Called before tracking. | |
ffc30690 | 49 | * *dataoff: offset of protocol header (TCP, UDP,...) in skb |
9fb9cbb1 YK |
50 | * *protonum: protocol number |
51 | */ | |
ffc30690 YK |
52 | int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff, |
53 | unsigned int *dataoff, u_int8_t *protonum); | |
9fb9cbb1 | 54 | |
0d035100 | 55 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK) |
fdf70832 | 56 | int (*tuple_to_nlattr)(struct sk_buff *skb, |
c1d10adb | 57 | const struct nf_conntrack_tuple *t); |
fdf70832 | 58 | int (*nlattr_to_tuple)(struct nlattr *tb[], |
c1d10adb | 59 | struct nf_conntrack_tuple *t); |
f73e924c | 60 | const struct nla_policy *nla_policy; |
0d035100 | 61 | #endif |
c1d10adb | 62 | |
0d035100 FW |
63 | /* Called when netns wants to use connection tracking */ |
64 | int (*net_ns_get)(struct net *); | |
65 | void (*net_ns_put)(struct net *); | |
d0dba725 | 66 | |
9fb9cbb1 YK |
67 | /* Module (if any) which this is connected to. */ |
68 | struct module *me; | |
69 | }; | |
70 | ||
b7b5fda4 | 71 | extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[NFPROTO_NUMPROTO]; |
9fb9cbb1 | 72 | |
6330750d | 73 | /* Protocol global registration. */ |
4e77be46 JP |
74 | int nf_ct_l3proto_register(struct nf_conntrack_l3proto *proto); |
75 | void nf_ct_l3proto_unregister(struct nf_conntrack_l3proto *proto); | |
6330750d | 76 | |
4e77be46 | 77 | struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto); |
c1d10adb | 78 | |
9fb9cbb1 | 79 | /* Existing built-in protocols */ |
605dcad6 | 80 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic; |
ddc8d029 YK |
81 | |
82 | static inline struct nf_conntrack_l3proto * | |
83 | __nf_ct_l3proto_find(u_int16_t l3proto) | |
84 | { | |
b7b5fda4 | 85 | if (unlikely(l3proto >= NFPROTO_NUMPROTO)) |
605dcad6 | 86 | return &nf_conntrack_l3proto_generic; |
923f4902 | 87 | return rcu_dereference(nf_ct_l3protos[l3proto]); |
ddc8d029 YK |
88 | } |
89 | ||
9fb9cbb1 | 90 | #endif /*_NF_CONNTRACK_L3PROTO_H*/ |