+ -
当前位置:首页 → 问答吧 → 大侠帮帮忙,关于用户层程序调用自己写的模块函数问题

大侠帮帮忙,关于用户层程序调用自己写的模块函数问题

时间: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()方法???

作者: C_J   发布时间: 2009-03-30

在这拜膜下chinaUnix的“独孤九剑”大哥!!! 问题继续~~~~~~~

作者: C_J   发布时间: 2009-03-30

把模块注册成一个字符设备驱动,然后用ioctl来进行调用。

作者: Andiry   发布时间: 2009-03-30

热门下载

更多