1 #include <linux/types.h>
2 #include <linux/sched.h>
3 #include <linux/timer.h>
4 #include <linux/netfilter.h>
5 #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
6
7 unsigned long ip_ct_generic_timeout = 600*HZ;
8
generic_pkt_to_tuple(const void * datah,size_t datalen,struct ip_conntrack_tuple * tuple)9 static int generic_pkt_to_tuple(const void *datah, size_t datalen,
10 struct ip_conntrack_tuple *tuple)
11 {
12 tuple->src.u.all = 0;
13 tuple->dst.u.all = 0;
14
15 return 1;
16 }
17
generic_invert_tuple(struct ip_conntrack_tuple * tuple,const struct ip_conntrack_tuple * orig)18 static int generic_invert_tuple(struct ip_conntrack_tuple *tuple,
19 const struct ip_conntrack_tuple *orig)
20 {
21 tuple->src.u.all = 0;
22 tuple->dst.u.all = 0;
23
24 return 1;
25 }
26
27 /* Print out the per-protocol part of the tuple. */
generic_print_tuple(char * buffer,const struct ip_conntrack_tuple * tuple)28 static unsigned int generic_print_tuple(char *buffer,
29 const struct ip_conntrack_tuple *tuple)
30 {
31 return 0;
32 }
33
34 /* Print out the private part of the conntrack. */
generic_print_conntrack(char * buffer,const struct ip_conntrack * state)35 static unsigned int generic_print_conntrack(char *buffer,
36 const struct ip_conntrack *state)
37 {
38 return 0;
39 }
40
41 /* Returns verdict for packet, or -1 for invalid. */
established(struct ip_conntrack * conntrack,struct iphdr * iph,size_t len,enum ip_conntrack_info conntrackinfo)42 static int established(struct ip_conntrack *conntrack,
43 struct iphdr *iph, size_t len,
44 enum ip_conntrack_info conntrackinfo)
45 {
46 ip_ct_refresh(conntrack, ip_ct_generic_timeout);
47 return NF_ACCEPT;
48 }
49
50 /* Called when a new connection for this protocol found. */
51 static int
new(struct ip_conntrack * conntrack,struct iphdr * iph,size_t len)52 new(struct ip_conntrack *conntrack, struct iphdr *iph, size_t len)
53 {
54 return 1;
55 }
56
57 struct ip_conntrack_protocol ip_conntrack_generic_protocol
58 = { { NULL, NULL }, 0, "unknown",
59 generic_pkt_to_tuple, generic_invert_tuple, generic_print_tuple,
60 generic_print_conntrack, established, new, NULL, NULL, NULL };
61
62