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>
8 struct ip_conntrack_protocol
10 /* Protocol number. */
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,
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 /* Has to decide if a expectation matches one packet or not */
48 int (*exp_matches_pkt)(struct ip_conntrack_expect *exp,
49 const struct sk_buff *skb);
51 int (*error)(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
52 unsigned int hooknum);
54 /* Module (if any) which this is connected to. */
58 #define MAX_IP_CT_PROTO 256
59 extern struct ip_conntrack_protocol *ip_ct_protos[MAX_IP_CT_PROTO];
61 /* Protocol registration. */
62 extern int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto);
63 extern void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto);
65 static inline struct ip_conntrack_protocol *ip_ct_find_proto(u_int8_t protocol)
67 return ip_ct_protos[protocol];
70 /* Existing built-in protocols */
71 extern struct ip_conntrack_protocol ip_conntrack_protocol_tcp;
72 extern struct ip_conntrack_protocol ip_conntrack_protocol_udp;
73 extern struct ip_conntrack_protocol ip_conntrack_protocol_icmp;
74 extern struct ip_conntrack_protocol ip_conntrack_generic_protocol;
75 extern int ip_conntrack_protocol_tcp_init(void);
77 /* Log invalid packets */
78 extern unsigned int ip_ct_log_invalid;
81 #ifdef DEBUG_INVALID_PACKETS
82 #define LOG_INVALID(proto) \
83 (ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW)
85 #define LOG_INVALID(proto) \
86 ((ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW) \
90 #define LOG_INVALID(proto) 0
91 #endif /* CONFIG_SYSCTL */
93 #endif /*_IP_CONNTRACK_PROTOCOL_H*/