- 论坛徽章:
- 0
|
#include<linux/config.h>;
#include<linux/module.h>;
#include<linux/ip.h>;
#include<linux/netfilter_ipv4.h>;
static unsigned int my_hook(unsigned int hook,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff*))
{
unsigned char *data=(void *)(*skb)->;nh.iph+(*skb)->;nh.iph->;ihl*4;
(*skb)->;nfcache=NFC_UNKNOWN;
IF((*skb)->;len==100)
{
printk("my_hook:dropping packet!\n" ;
return NF_DROP;
}
return NF_ACCEPT;
}
static struct nf_hook_ops my_ops=
{
{NULL,NULL},
my_hook,
PF_INET,
NF_IP_LOCAL_OUT,
NF_IP_PRI_FILTER-1
}
int init_module(void)
{
return nf_register_hook(&my_ops);
}
void cleanup_module(void)
{
nf_unregister_hook(&my_ops);
} |
|