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 int (*error
)(struct sk_buff
*skb
, enum ip_conntrack_info
*ctinfo
,
48 unsigned int hooknum
);
50 /* Module (if any) which this is connected to. */
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
;
77 #ifdef DEBUG_INVALID_PACKETS
78 #define LOG_INVALID(proto) \
79 (ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW)
81 #define LOG_INVALID(proto) \
82 ((ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW) \
86 #define LOG_INVALID(proto) 0
87 #endif /* CONFIG_SYSCTL */
89 #endif /*_IP_CONNTRACK_PROTOCOL_H*/