Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / netfilter_ipv4 / ip_conntrack_protocol.h
blobe20b57c5e1b7685053be9a0ff5a814d65dab1580
1 /* Header for use in defining a given protocol for connection tracking. */
2 #ifndef _IP_CONNTRACK_PROTOCOL_H
3 #define _IP_CONNTRACK_PROTOCOL_H
4 #include <linux/netfilter_ipv4/ip_conntrack.h>
6 struct seq_file;
8 struct ip_conntrack_protocol
10 /* Protocol number. */
11 u_int8_t proto;
13 /* Protocol name */
14 const char *name;
16 /* Try to fill in the third arg: dataoff is offset past IP
17 hdr. Return true if possible. */
18 int (*pkt_to_tuple)(const struct sk_buff *skb,
19 unsigned int dataoff,
20 struct ip_conntrack_tuple *tuple);
22 /* Invert the per-proto part of the tuple: ie. turn xmit into reply.
23 * Some packets can't be inverted: return 0 in that case.
25 int (*invert_tuple)(struct ip_conntrack_tuple *inverse,
26 const struct ip_conntrack_tuple *orig);
28 /* Print out the per-protocol part of the tuple. Return like seq_* */
29 int (*print_tuple)(struct seq_file *,
30 const struct ip_conntrack_tuple *);
32 /* Print out the private part of the conntrack. */
33 int (*print_conntrack)(struct seq_file *, const struct ip_conntrack *);
35 /* Returns verdict for packet, or -1 for invalid. */
36 int (*packet)(struct ip_conntrack *conntrack,
37 const struct sk_buff *skb,
38 enum ip_conntrack_info ctinfo);
40 /* Called when a new connection for this protocol found;
41 * returns TRUE if it's OK. If so, packet() called next. */
42 int (*new)(struct ip_conntrack *conntrack, const struct sk_buff *skb);
44 /* Called when a conntrack entry is destroyed */
45 void (*destroy)(struct ip_conntrack *conntrack);
47 int (*error)(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
48 unsigned int hooknum);
50 /* Module (if any) which this is connected to. */
51 struct module *me;
54 #define MAX_IP_CT_PROTO 256
55 extern struct ip_conntrack_protocol *ip_ct_protos[MAX_IP_CT_PROTO];
57 /* Protocol registration. */
58 extern int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto);
59 extern void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto);
61 static inline struct ip_conntrack_protocol *ip_ct_find_proto(u_int8_t protocol)
63 return ip_ct_protos[protocol];
66 /* Existing built-in protocols */
67 extern struct ip_conntrack_protocol ip_conntrack_protocol_tcp;
68 extern struct ip_conntrack_protocol ip_conntrack_protocol_udp;
69 extern struct ip_conntrack_protocol ip_conntrack_protocol_icmp;
70 extern struct ip_conntrack_protocol ip_conntrack_generic_protocol;
71 extern int ip_conntrack_protocol_tcp_init(void);
73 /* Log invalid packets */
74 extern unsigned int ip_ct_log_invalid;
76 #ifdef CONFIG_SYSCTL
77 #ifdef DEBUG_INVALID_PACKETS
78 #define LOG_INVALID(proto) \
79 (ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW)
80 #else
81 #define LOG_INVALID(proto) \
82 ((ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW) \
83 && net_ratelimit())
84 #endif
85 #else
86 #define LOG_INVALID(proto) 0
87 #endif /* CONFIG_SYSCTL */
89 #endif /*_IP_CONNTRACK_PROTOCOL_H*/