Chinaunix首页 | 论坛 | 博客
  • 博客访问: 479428
  • 博文数量: 130
  • 博客积分: 2111
  • 博客等级: 大尉
  • 技术积分: 1373
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-28 09:55
个人简介

IT民工

文章分类

全部博文(130)

文章存档

2021年(1)

2019年(1)

2017年(3)

2014年(1)

2013年(3)

2012年(2)

2011年(3)

2010年(2)

2009年(114)

分类: LINUX

2009-09-01 12:45:35

nf_sockopt_ops编译出错解决办法
2008-04-11 11:33:10
在网上找的关于内核空间与用户空间数据传递的例程,编译内核模块时出错
我的linux内核include/linux/netfilter.h中有如下定义:
CODE:
struct nf_sockopt_ops
{
        struct list_head list;

        int pf;

        /* Non-inclusive ranges: use 0/0/NULL to never get called. */
        int set_optmin;
        int set_optmax;
        int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);

        int get_optmin;
        int get_optmax;
        int (*get)(struct sock *sk, int optval, void __user *user, int *len);

        /* Number of users inside set() or get(). */
        unsigned int use;
        struct task_struct *cleanup_task;
};


编译的出错信息如下:
/home/lwx/u_k_test/imp2/k.c:143: error: variable `imp2_ops' has initializer but incomplete type
/home/lwx/u_k_test/imp2/k.c:145: error: unknown field `hook' specified in initializer
/home/lwx/u_k_test/imp2/k.c:145: warning: excess elements in struct initializer
/home/lwx/u_k_test/imp2/k.c:145: warning: (near initialization for `imp2_ops')
/home/lwx/u_k_test/imp2/k.c:146: error: unknown field `owner' specified in initializer
/home/lwx/u_k_test/imp2/k.c:146: warning: excess elements in struct initializer
/home/lwx/u_k_test/imp2/k.c:146: warning: (near initialization for `imp2_ops')
/home/lwx/u_k_test/imp2/k.c:147: error: unknown field `pf' specified in initializer
/home/lwx/u_k_test/imp2/k.c:147: warning: excess elements in struct initializer
/home/lwx/u_k_test/imp2/k.c:147: warning: (near initialization for `imp2_ops')
/home/lwx/u_k_test/imp2/k.c:148: error: unknown field `hooknum' specified in initializer
/home/lwx/u_k_test/imp2/k.c:148: warning: excess elements in struct initializer
/home/lwx/u_k_test/imp2/k.c:148: warning: (near initialization for `imp2_ops')
/home/lwx/u_k_test/imp2/k.c:149: error: unknown field `priority' specified in initializer
/home/lwx/u_k_test/imp2/k.c:149: warning: excess elements in struct initializer
/home/lwx/u_k_test/imp2/k.c:149: warning: (near initialization for `imp2_ops')
/home/lwx/u_k_test/imp2/k.c: In function `init':
/home/lwx/u_k_test/imp2/k.c:163: warning: implicit declaration of function `nf_register_hook'
/home/lwx/u_k_test/imp2/k.c: In function `fini':
/home/lwx/u_k_test/imp2/k.c:172: warning: implicit declaration of function `nf_unregister_hook'
/home/lwx/u_k_test/imp2/k.c: At top level:
/home/lwx/u_k_test/imp2/k.c:143: error: storage size of `imp2_ops' isn't known
make[2]: *** [/home/lwx/u_k_test/imp2/k.o] 错误 1
make[1]: *** [_module_/home/lwx/u_k_test/imp2] 错误 2
make[1]: Leaving directory `/home/utu-linux_for_s3c2440_V1.5.3'
make: *** [all] 错误 2

在网上搜了一把,找到了dlutmmcl大侠的帖子:


/**
原来这个编译还跟linux源码的内核编译选项有很大的关系
aodv-uu的Makefile中的内核源码必须设置为板上内核的编译源码一致,并且不能修改。
我在kernel-2.4.26-free中的.config的networking options中加入netfilter模块。
**/

按他说的,我的是linux-2.6.13
makemenuconfig
选择  : Networking -> Networking options -> Network packet filtering (replaces ipchains)选项
再回到模块编译,呵呵,成功啦,感谢dlutmmcl大侠,留个记号
阅读(1950) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~