为啥我这段netfilter的代码在2.6内核下没效果
时间:2006-04-07
来源:互联网
#define __KERNEL__
#define MODULE
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/ip.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/skbuff.h>
#include <linux/udp.h>
#include <linux/tcp.h>
#include <net/tcp.h>
#include <linux/in.h>
MODULE_LICENSE("GPL");
//每经过一个数据包就会调用这个函数一次。
unsigned int pb_hook( unsigned int hooknum,
struct sk_buff **pskb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff*) )
{
printk("receive one pkt\n");
return NF_ACCEPT;
}
static struct nf_hook_ops nfo_ip_local_in = {
{NULL,NULL},
pb_hook,
PF_INET,
NF_IP_LOCAL_IN,
NF_IP_PRI_FIRST
};
static int __init pb_test_init(void)
{
return nf_register_hook(&nfo_ip_local_in);
}
module_init(pb_test_init);
static void __exit pb_test_exit(void)
{
nf_unregister_hook(&nfo_ip_local_in);
}
module_exit(pb_test_exit);
2.4下完全正常
#define MODULE
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/ip.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/skbuff.h>
#include <linux/udp.h>
#include <linux/tcp.h>
#include <net/tcp.h>
#include <linux/in.h>
MODULE_LICENSE("GPL");
//每经过一个数据包就会调用这个函数一次。
unsigned int pb_hook( unsigned int hooknum,
struct sk_buff **pskb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff*) )
{
printk("receive one pkt\n");
return NF_ACCEPT;
}
static struct nf_hook_ops nfo_ip_local_in = {
{NULL,NULL},
pb_hook,
PF_INET,
NF_IP_LOCAL_IN,
NF_IP_PRI_FIRST
};
static int __init pb_test_init(void)
{
return nf_register_hook(&nfo_ip_local_in);
}
module_init(pb_test_init);
static void __exit pb_test_exit(void)
{
nf_unregister_hook(&nfo_ip_local_in);
}
module_exit(pb_test_exit);
2.4下完全正常
作者: pink_tulip 发布时间: 2006-04-07
研究了
struct nf_hook_ops都变了。
成员加了一个struct module,有谁了解么?
struct nf_hook_ops都变了。
成员加了一个struct module,有谁了解么?
作者: pink_tulip 发布时间: 2006-04-08
这样行不行?
。。。。
owner = THIS_MODULE,
。。。。
。。。。
owner = THIS_MODULE,
。。。。
作者: 铁丝上的比目鱼 发布时间: 2006-04-13
初始化结构出错了,2.6中struct nf_hook_ops多了东西。
struct nf_hook_ops nfo_ip_local_in=
{
.list={ NULL, NULL},
.hook= pb_hook,
.pf=PF_INET,
.hooknum=NF_IP_LOCAL_IN,
.priority=NF_IP_PRI_FIRST
};
,新成员不用也行
struct nf_hook_ops nfo_ip_local_in=
{
.list={ NULL, NULL},
.hook= pb_hook,
.pf=PF_INET,
.hooknum=NF_IP_LOCAL_IN,
.priority=NF_IP_PRI_FIRST
};
,新成员不用也行
作者: smallpeg 发布时间: 2006-04-19
请问那个新成员是干啥的?
作者: pink_tulip 发布时间: 2006-04-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28