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> 5 6 struct ip_conntrack_protocol 7 { 8 /* Next pointer. */ 9 struct list_head list; 10 11 /* Protocol number. */ 12 u_int8_t proto; 13 14 /* Protocol name */ 15 const char *name; 16 17 /* Try to fill in the third arg; return true if possible. */ 18 int (*pkt_to_tuple)(const void *datah, size_t datalen, 19 struct ip_conntrack_tuple *tuple); 20 21 /* Invert the per-proto part of the tuple: ie. turn xmit into reply. 22 * Some packets can't be inverted: return 0 in that case. 23 */ 24 int (*invert_tuple)(struct ip_conntrack_tuple *inverse, 25 const struct ip_conntrack_tuple *orig); 26 27 /* Print out the per-protocol part of the tuple. */ 28 unsigned int (*print_tuple)(char *buffer, 29 const struct ip_conntrack_tuple *); 30 31 /* Print out the private part of the conntrack. */ 32 unsigned int (*print_conntrack)(char *buffer, 33 const struct ip_conntrack *); 34 35 /* Returns verdict for packet, or -1 for invalid. */ 36 int (*packet)(struct ip_conntrack *conntrack, 37 struct iphdr *iph, size_t len, 38 enum ip_conntrack_info ctinfo); 39 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, struct iphdr *iph, 43 size_t len); 44 45 /* Called when a conntrack entry is destroyed */ 46 void (*destroy)(struct ip_conntrack *conntrack); 47 48 /* Has to decide if a expectation matches one packet or not */ 49 int (*exp_matches_pkt)(struct ip_conntrack_expect *exp, 50 struct sk_buff **pskb); 51 52 /* Module (if any) which this is connected to. */ 53 struct module *me; 54 }; 55 56 /* Protocol registration. */ 57 extern int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto); 58 extern void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto); 59 60 /* Existing built-in protocols */ 61 extern struct ip_conntrack_protocol ip_conntrack_protocol_tcp; 62 extern struct ip_conntrack_protocol ip_conntrack_protocol_udp; 63 extern struct ip_conntrack_protocol ip_conntrack_protocol_icmp; 64 extern int ip_conntrack_protocol_tcp_init(void); 65 #endif /*_IP_CONNTRACK_PROTOCOL_H*/ 66