01663e5b33dfd1b0a9f1aba6836b5e3c48751971
[deliverable/linux.git] / include / net / netfilter / nf_conntrack_l3proto.h
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
14 #include <linux/seq_file.h>
15 #include <net/netfilter/nf_conntrack.h>
16
17 struct nf_conntrack_l3proto
18 {
19 /* Next pointer. */
20 struct list_head list;
21
22 /* L3 Protocol Family number. ex) PF_INET */
23 u_int16_t l3proto;
24
25 /* Protocol name */
26 const char *name;
27
28 /*
29 * Try to fill in the third arg: nhoff is offset of l3 proto
30 * hdr. Return true if possible.
31 */
32 int (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff,
33 struct nf_conntrack_tuple *tuple);
34
35 /*
36 * Invert the per-proto part of the tuple: ie. turn xmit into reply.
37 * Some packets can't be inverted: return 0 in that case.
38 */
39 int (*invert_tuple)(struct nf_conntrack_tuple *inverse,
40 const struct nf_conntrack_tuple *orig);
41
42 /* Print out the per-protocol part of the tuple. */
43 int (*print_tuple)(struct seq_file *s,
44 const struct nf_conntrack_tuple *);
45
46 /* Print out the private part of the conntrack. */
47 int (*print_conntrack)(struct seq_file *s, const struct nf_conn *);
48
49 /* Returns verdict for packet, or -1 for invalid. */
50 int (*packet)(struct nf_conn *conntrack,
51 const struct sk_buff *skb,
52 enum ip_conntrack_info ctinfo);
53
54 /*
55 * Called when a new connection for this protocol found;
56 * returns TRUE if it's OK. If so, packet() called next.
57 */
58 int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb);
59
60 /* Called when a conntrack entry is destroyed */
61 void (*destroy)(struct nf_conn *conntrack);
62
63 /*
64 * Called before tracking.
65 * *dataoff: offset of protocol header (TCP, UDP,...) in *pskb
66 * *protonum: protocol number
67 */
68 int (*prepare)(struct sk_buff **pskb, unsigned int hooknum,
69 unsigned int *dataoff, u_int8_t *protonum);
70
71 u_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple);
72
73 /* Module (if any) which this is connected to. */
74 struct module *me;
75 };
76
77 extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX];
78
79 /* Protocol registration. */
80 extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
81 extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
82
83 static inline struct nf_conntrack_l3proto *
84 nf_ct_find_l3proto(u_int16_t l3proto)
85 {
86 return nf_ct_l3protos[l3proto];
87 }
88
89 /* Existing built-in protocols */
90 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
91 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
92 extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto;
93 #endif /*_NF_CONNTRACK_L3PROTO_H*/
This page took 0.032579 seconds and 4 git commands to generate.