免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 691 | 回复: 0
打印 上一主题 下一主题

这个内核模块为什么不能编译通过 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-10-15 14:33 |只看该作者 |倒序浏览
#include <linux/module.h>;
#include <linux/kernel.h>;
#include <linux/netfilter.h>;
#include <linux/netfilter_ipv4.h>;
#include <linux/string.h>;

static struct nf_hook_ops nfho;
static char *drop_if="lo";
static char *temp="eth0";

int init_module(void);
void cleanup_module(void);

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 *))

{
  if ( strcmp(in->;name,drop_if) == 0 ){  //this is line 18
   }
   return NF_ACCEPT;
}

int init_module()
{
    nfho.hook = hook_func;         /* 处理函数 */
    nfho.hooknum  = NF_IP_PRE_ROUTING; /* 使用IPv4的第一个hook */
    nfho.pf       = PF_INET;
    nfho.priority = NF_IP_PRI_FIRST;   /* 让我们的函数首先执行 */

    nf_register_hook(&nfho); printk("a net hook installed\n";

    return 0;
}

void cleanup_module()
{
    nf_unregister_hook(&nfho);
    printk("uninstall a net hook\n";
}

Makefile 的内容为:
TARGET  := nethook
WARN    := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
//CFLAGS  := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CFLAGS  := -O2 -DMODULE -D__KERNEL__  ${INCLUDE}
CC      := gcc
${TARGET}.o: ${TARGET}.c

.PHONY: clean

每次编译总是出现如下错误信息:
nethook #make
gcc -O2 -DMODULE -D__KERNEL__  -isystem /lib/modules/`uname -r`/build/include   -c -o nethook.o nethook.c
nethook.c: In function `hook_func':
nethook.c:18: dereferencing pointer to incomplete type
make: *** [nethook.o] Error 1
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP