]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/net/netfilter/nf_conntrack_protocol.h
[NETFILTER]: Add nf_conntrack subsystem.
[mirror_ubuntu-jammy-kernel.git] / include / net / netfilter / nf_conntrack_protocol.h
1 /*
2 * Header for use in defining a given protocol for connection tracking.
3 *
4 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
5 * - generalized L3 protocol dependent part.
6 *
7 * Derived from include/linux/netfiter_ipv4/ip_conntrack_protcol.h
8 */
9
10 #ifndef _NF_CONNTRACK_PROTOCOL_H
11 #define _NF_CONNTRACK_PROTOCOL_H
12 #include <net/netfilter/nf_conntrack.h>
13
14 struct seq_file;
15
16 struct nf_conntrack_protocol
17 {
18 /* Next pointer. */
19 struct list_head list;
20
21 /* L3 Protocol number. */
22 u_int16_t l3proto;
23
24 /* Protocol number. */
25 u_int8_t proto;
26
27 /* Protocol name */
28 const char *name;
29
30 /* Try to fill in the third arg: dataoff is offset past network protocol
31 hdr. Return true if possible. */
32 int (*pkt_to_tuple)(const struct sk_buff *skb,
33 unsigned int dataoff,
34 struct nf_conntrack_tuple *tuple);
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. Return like seq_* */
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 unsigned int dataoff,
53 enum ip_conntrack_info ctinfo,
54 int pf,
55 unsigned int hooknum);
56
57 /* Called when a new connection for this protocol found;
58 * returns TRUE if it's OK. If so, packet() called next. */
59 int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb,
60 unsigned int dataoff);
61
62 /* Called when a conntrack entry is destroyed */
63 void (*destroy)(struct nf_conn *conntrack);
64
65 int (*error)(struct sk_buff *skb, unsigned int dataoff,
66 enum ip_conntrack_info *ctinfo,
67 int pf, unsigned int hooknum);
68
69 /* Module (if any) which this is connected to. */
70 struct module *me;
71 };
72
73 /* Existing built-in protocols */
74 extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6;
75 extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4;
76 extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6;
77 extern struct nf_conntrack_protocol nf_conntrack_generic_protocol;
78
79 #define MAX_NF_CT_PROTO 256
80 extern struct nf_conntrack_protocol **nf_ct_protos[PF_MAX];
81
82 extern struct nf_conntrack_protocol *
83 nf_ct_find_proto(u_int16_t l3proto, u_int8_t protocol);
84
85 /* Protocol registration. */
86 extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol *proto);
87 extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto);
88
89 /* Log invalid packets */
90 extern unsigned int nf_ct_log_invalid;
91
92 #ifdef CONFIG_SYSCTL
93 #ifdef DEBUG_INVALID_PACKETS
94 #define LOG_INVALID(proto) \
95 (nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW)
96 #else
97 #define LOG_INVALID(proto) \
98 ((nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) \
99 && net_ratelimit())
100 #endif
101 #else
102 #define LOG_INVALID(proto) 0
103 #endif /* CONFIG_SYSCTL */
104
105 #endif /*_NF_CONNTRACK_PROTOCOL_H*/