2 * Copyright (C)2003,2004 USAGI/WIDE Project
4 * Header for use in defining a given L3 protocol for connection tracking.
7 * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
9 * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h
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>
19 struct nf_conntrack_l3proto
{
20 /* L3 Protocol Family number. ex) PF_INET */
27 * Try to fill in the third arg: nhoff is offset of l3 proto
28 * hdr. Return true if possible.
30 bool (*pkt_to_tuple
)(const struct sk_buff
*skb
, unsigned int nhoff
,
31 struct nf_conntrack_tuple
*tuple
);
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.
37 bool (*invert_tuple
)(struct nf_conntrack_tuple
*inverse
,
38 const struct nf_conntrack_tuple
*orig
);
40 /* Print out the per-protocol part of the tuple. */
41 void (*print_tuple
)(struct seq_file
*s
,
42 const struct nf_conntrack_tuple
*);
45 * Called before tracking.
46 * *dataoff: offset of protocol header (TCP, UDP,...) in skb
47 * *protonum: protocol number
49 int (*get_l4proto
)(const struct sk_buff
*skb
, unsigned int nhoff
,
50 unsigned int *dataoff
, u_int8_t
*protonum
);
52 int (*tuple_to_nlattr
)(struct sk_buff
*skb
,
53 const struct nf_conntrack_tuple
*t
);
56 * Calculate size of tuple nlattr
58 int (*nlattr_tuple_size
)(void);
60 int (*nlattr_to_tuple
)(struct nlattr
*tb
[],
61 struct nf_conntrack_tuple
*t
);
62 const struct nla_policy
*nla_policy
;
66 /* Init l3proto pernet data */
67 int (*init_net
)(struct net
*net
);
69 /* Module (if any) which this is connected to. */
73 extern struct nf_conntrack_l3proto __rcu
*nf_ct_l3protos
[AF_MAX
];
75 /* Protocol pernet registration. */
76 int nf_ct_l3proto_pernet_register(struct net
*net
,
77 struct nf_conntrack_l3proto
*proto
);
78 void nf_ct_l3proto_pernet_unregister(struct net
*net
,
79 struct nf_conntrack_l3proto
*proto
);
81 /* Protocol global registration. */
82 int nf_ct_l3proto_register(struct nf_conntrack_l3proto
*proto
);
83 void nf_ct_l3proto_unregister(struct nf_conntrack_l3proto
*proto
);
85 struct nf_conntrack_l3proto
*nf_ct_l3proto_find_get(u_int16_t l3proto
);
87 /* Existing built-in protocols */
88 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic
;
90 static inline struct nf_conntrack_l3proto
*
91 __nf_ct_l3proto_find(u_int16_t l3proto
)
93 if (unlikely(l3proto
>= AF_MAX
))
94 return &nf_conntrack_l3proto_generic
;
95 return rcu_dereference(nf_ct_l3protos
[l3proto
]);
98 #endif /*_NF_CONNTRACK_L3PROTO_H*/