RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / net / ipv4 / netfilter / ipt_exp.c
blobba3fe1d5fc5253f75478a5bdb4d16d3576496bc4
1 /*
3 Experimental Netfilter Crap
4 Copyright (C) 2006 Jonathan Zarate
6 */
7 #include <linux/module.h>
8 #include <linux/skbuff.h>
9 #include <linux/version.h>
10 #include <linux/file.h>
11 #include <net/sock.h>
13 #include <linux/netfilter_ipv4/ip_tables.h>
14 #include <linux/netfilter_ipv4/ipt_exp.h>
15 #include "../../bridge/br_private.h"
18 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
19 static int
20 #else
21 static bool
22 #endif
23 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
24 match(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out,
25 const struct xt_match *match, const void *matchinfo, int offset,
26 unsigned int protoff, int *hotdrop)
27 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) */
28 match(const struct sk_buff *skb, const struct xt_match_param *par)
29 #endif
31 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
32 // const struct ipt_exp_info *info = matchinfo;
33 #else
34 // const struct ipt_exp_info *info = par->matchinfo;
35 #endif
37 if ((skb_mac_header(skb) >= skb->head) && ((skb_mac_header(skb) + ETH_HLEN) <= skb->data)) {
38 printk(KERN_INFO "exp src=%02X:%02X:%02X:%02X:%02X:%02X dst=%02X:%02X:%02X:%02X:%02X:%02X\n",
39 eth_hdr(skb)->h_source[0], eth_hdr(skb)->h_source[1], eth_hdr(skb)->h_source[2],
40 eth_hdr(skb)->h_source[3], eth_hdr(skb)->h_source[4], eth_hdr(skb)->h_source[5],
41 eth_hdr(skb)->h_dest[0], eth_hdr(skb)->h_dest[1], eth_hdr(skb)->h_dest[2],
42 eth_hdr(skb)->h_dest[3], eth_hdr(skb)->h_dest[4], eth_hdr(skb)->h_dest[5]);
43 return 1;
45 printk(KERN_INFO "exp mac=%p head=%p in=%p\n", skb_mac_header(skb), skb->head, in);
46 return 0;
49 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
50 static int
51 #else
52 static bool
53 #endif
54 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
55 checkentry(const char *tablename, const void *inf, const struct xt_match *match,
56 void *matchinfo, unsigned int hook_mask)
57 #else
58 checkentry(const struct xt_mtchk_param *par)
59 #endif
61 return 1;
64 static struct xt_match exp_match = {
65 .name = "exp",
66 .family = AF_INET,
67 .match = &match,
68 .matchsize = sizeof(struct ipt_exp_info),
69 .checkentry = &checkentry,
70 .destroy = NULL,
71 .me = THIS_MODULE
74 static int __init init(void)
76 printk(KERN_INFO "exp init " __DATE__ " " __TIME__ "\n");
77 return xt_register_match(&exp_match);
80 static void __exit fini(void)
82 printk(KERN_INFO "exp fini\n");
83 xt_unregister_match(&exp_match);
86 module_init(init);
87 module_exit(fini);
88 MODULE_LICENSE("GPL");