|

楼主 |
发表于 2005-4-12 22:41:55
|
显示全部楼层
[php]
#define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
static struct nf_hook_ops nfho;
unsigned int hook_func(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *)){
struct sk_buff *sb = *skb;
if( sb->h.th->syn)
printk("SYN\n");
return NF_ACCEPT;
}
int init_module(){
nfho.hook = hook_func;
nfho.hooknum = NF_IP_PRE_ROUTING;
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho);
return 0;
}
void cleanup_module()
{
nf_unregister_hook(&nfho);
}
/* makefile
testsyn.o:syncookieproxy.c
gcc -c -I/usr/src/linux2.4/include syncookieproxy.c -o testsyn.o
*/
[/php] |
|