大侠帮帮忙,关于用户层程序调用自己写的模块函数问题
时间:2009-03-30
来源:互联网
自己写了某一内核模块 通过insmod已经加载到了内核成功(kernel 2.6.25.14)
但用户程序这边需要调用模块的某一函数(如下的getDropCount())
模块代码如下:
static long count=0;
long getDropCount()
{
return count;
}
由于某种原因,不能使此方法注册为一个系统调用(存储在sys_call_table里面)
跪求大侠帮忙,最好给出具体方法。
模块代码如下:
static unsigned int drop_ip = 16820416;
//static unsigned int drop_ip = 123456;
static long count=0;
long getDropCount()
{
return count;
}
unsigned int hook_fund(unsigned int hooknum,struct sk_buff *skb,const struct net_device *in,const struct net_device *out,int(*okfn)(struct sk_buff*))
{
.....
}
int init(void)
{
nfho.hook=hook_fund;
nfho.hooknum = 1;
nfho.pf=PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho);
return 0;
}
void exit(void)
{
nf_unregister_hook(&nfho);
}
module_init(init);
module_exit(exit);
MODULE_LICENSE("GPL");
//以上模块被加载到内核空间
现在用户要获取到那个count值,所以想调用那个getDropCount()方法???
但用户程序这边需要调用模块的某一函数(如下的getDropCount())
模块代码如下:
static long count=0;
long getDropCount()
{
return count;
}
由于某种原因,不能使此方法注册为一个系统调用(存储在sys_call_table里面)
跪求大侠帮忙,最好给出具体方法。
模块代码如下:
static unsigned int drop_ip = 16820416;
//static unsigned int drop_ip = 123456;
static long count=0;
long getDropCount()
{
return count;
}
unsigned int hook_fund(unsigned int hooknum,struct sk_buff *skb,const struct net_device *in,const struct net_device *out,int(*okfn)(struct sk_buff*))
{
.....
}
int init(void)
{
nfho.hook=hook_fund;
nfho.hooknum = 1;
nfho.pf=PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho);
return 0;
}
void exit(void)
{
nf_unregister_hook(&nfho);
}
module_init(init);
module_exit(exit);
MODULE_LICENSE("GPL");
//以上模块被加载到内核空间
现在用户要获取到那个count值,所以想调用那个getDropCount()方法???
作者: C_J 发布时间: 2009-03-30
在这拜膜下chinaUnix的“独孤九剑”大哥!!! 问题继续~~~~~~~
作者: C_J 发布时间: 2009-03-30
把模块注册成一个字符设备驱动,然后用ioctl来进行调用。
作者: Andiry 发布时间: 2009-03-30
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28