]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
9fb9cbb1 YK |
2 | /* |
3 | * Copyright (C)2003,2004 USAGI/WIDE Project | |
4 | * | |
5 | * Header for use in defining a given L3 protocol for connection tracking. | |
6 | * | |
7 | * Author: | |
8 | * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
9 | * | |
10 | * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h | |
11 | */ | |
12 | ||
13 | #ifndef _NF_CONNTRACK_L3PROTO_H | |
14 | #define _NF_CONNTRACK_L3PROTO_H | |
df6fb868 | 15 | #include <linux/netlink.h> |
f73e924c | 16 | #include <net/netlink.h> |
9fb9cbb1 YK |
17 | #include <linux/seq_file.h> |
18 | #include <net/netfilter/nf_conntrack.h> | |
19 | ||
fd2c3ef7 | 20 | struct nf_conntrack_l3proto { |
9fb9cbb1 YK |
21 | /* L3 Protocol Family number. ex) PF_INET */ |
22 | u_int16_t l3proto; | |
23 | ||
0d035100 FW |
24 | /* size of tuple nlattr, fills a hole */ |
25 | u16 nla_size; | |
26 | ||
9fb9cbb1 YK |
27 | /* |
28 | * Try to fill in the third arg: nhoff is offset of l3 proto | |
29 | * hdr. Return true if possible. | |
30 | */ | |
8ce8439a JE |
31 | bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff, |
32 | struct nf_conntrack_tuple *tuple); | |
9fb9cbb1 YK |
33 | |
34 | /* | |
35 | * Invert the per-proto part of the tuple: ie. turn xmit into reply. | |
36 | * Some packets can't be inverted: return 0 in that case. | |
37 | */ | |
8ce8439a JE |
38 | bool (*invert_tuple)(struct nf_conntrack_tuple *inverse, |
39 | const struct nf_conntrack_tuple *orig); | |
9fb9cbb1 | 40 | |
9fb9cbb1 YK |
41 | /* |
42 | * Called before tracking. | |
ffc30690 | 43 | * *dataoff: offset of protocol header (TCP, UDP,...) in skb |
9fb9cbb1 YK |
44 | * *protonum: protocol number |
45 | */ | |
ffc30690 YK |
46 | int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff, |
47 | unsigned int *dataoff, u_int8_t *protonum); | |
9fb9cbb1 | 48 | |
0d035100 | 49 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK) |
fdf70832 | 50 | int (*tuple_to_nlattr)(struct sk_buff *skb, |
c1d10adb | 51 | const struct nf_conntrack_tuple *t); |
fdf70832 | 52 | int (*nlattr_to_tuple)(struct nlattr *tb[], |
c1d10adb | 53 | struct nf_conntrack_tuple *t); |
f73e924c | 54 | const struct nla_policy *nla_policy; |
0d035100 | 55 | #endif |
c1d10adb | 56 | |
0d035100 FW |
57 | /* Called when netns wants to use connection tracking */ |
58 | int (*net_ns_get)(struct net *); | |
59 | void (*net_ns_put)(struct net *); | |
d0dba725 | 60 | |
9fb9cbb1 YK |
61 | /* Module (if any) which this is connected to. */ |
62 | struct module *me; | |
63 | }; | |
64 | ||
b7b5fda4 | 65 | extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[NFPROTO_NUMPROTO]; |
9fb9cbb1 | 66 | |
6330750d | 67 | /* Protocol global registration. */ |
b3480fe0 FW |
68 | int nf_ct_l3proto_register(const struct nf_conntrack_l3proto *proto); |
69 | void nf_ct_l3proto_unregister(const struct nf_conntrack_l3proto *proto); | |
6330750d | 70 | |
b3480fe0 | 71 | const struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto); |
c1d10adb | 72 | |
9fb9cbb1 | 73 | /* Existing built-in protocols */ |
605dcad6 | 74 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic; |
ddc8d029 YK |
75 | |
76 | static inline struct nf_conntrack_l3proto * | |
77 | __nf_ct_l3proto_find(u_int16_t l3proto) | |
78 | { | |
b7b5fda4 | 79 | if (unlikely(l3proto >= NFPROTO_NUMPROTO)) |
605dcad6 | 80 | return &nf_conntrack_l3proto_generic; |
923f4902 | 81 | return rcu_dereference(nf_ct_l3protos[l3proto]); |
ddc8d029 YK |
82 | } |
83 | ||
9fb9cbb1 | 84 | #endif /*_NF_CONNTRACK_L3PROTO_H*/ |