|
有段时间没来了
我的解决办法已经写清楚了把:
。。。。。。
就是开发板里跑的内核,必须用它编译好的源码目录作为aodv移植的源码目录
如果你没有你的内核源码,那你就得重新编译一次,再把内核下载到板子上
记得要在.config的networking options中加入netfilter模块(编译内核代码时make menuconfig时加上)
--------------------------------------------------------------------
问题已解决:
问题解决了
原来这个编译还跟linux源码的内核编译选项有很大的关系
aodv-uu的Makefile中的内核源码必须设置为板上内核的编译源码一致,并且不能修改。
我在kernel-2.4.26-free中的.config的networking options中加入netfilter模块。
-----------------------------------------------------------------------
最近移植aodv路由协议。kaodv-mod.c在附件里,
我在redhat9.0(kernel2.4.20)上装这个aodv-uu-0.9.3没有任何问题
但我用交叉编译的时候就出现了一下的问题:
1、出现问题地方主要是一个结构体的初始化:
nf_hook_ops的定义在/include/linux/netfileter.h中:
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, unsigned int len);
int get_optmin;
int get_optmax;
int (*get)(struct sock *sk, int optval, void *user, int *len);
/* Number of users inside set() or get(). */
unsigned int use;
struct task_struct *cleanup_task;
};
初始化:
408:static struct nf_hook_ops kaodv_ops[] = {
409: {
410: .hook = kaodv_hook,
411:#ifdef KERNEL26
412: .owner = THIS_MODULE,
413:#endif
414: .pf = PF_INET,
415: .hooknum = NF_IP_PRE_ROUTING,
416: .priority = NF_IP_PRI_FIRST,
417: },
418: {
419 .hook = kaodv_hook,
420#ifdef KERNEL26
421 .owner = THIS_MODULE,
422#endif
423 .pf = PF_INET,
424 .hooknum = NF_IP_LOCAL_OUT,
425 .priority = NF_IP_PRI_FILTER,
426 },
427 {
428 .hook = kaodv_hook,
429#ifdef KERNEL26
430 .owner = THIS_MODULE,
431#endif
432 .pf = PF_INET,
433 .hooknum = NF_IP_POST_ROUTING,
434 .priority = NF_IP_PRI_FILTER,
435 },
};
错误:
kaodv-mod.c:408: error: elements of array `kaodv_ops' have incomplete type
kaodv-mod.c:410: error: unknown field `hook' specified in initializer
kaodv-mod.c:410: warning: excess elements in struct initializer
kaodv-mod.c:410: warning: (near initialization for `kaodv_ops[0]')
kaodv-mod.c:414: error: unknown field `pf' specified in initializer
kaodv-mod.c:414: warning: excess elements in struct initializer
kaodv-mod.c:414: warning: (near initialization for `kaodv_ops[0]')
kaodv-mod.c:415: error: unknown field `hooknum' specified in initializer
kaodv-mod.c:415: warning: excess elements in struct initializer
kaodv-mod.c:415: warning: (near initialization for `kaodv_ops[0]')
kaodv-mod.c:416: error: unknown field `priority' specified in initializer
kaodv-mod.c:416: warning: excess elements in struct initializer
kaodv-mod.c:416: warning: (near initialization for `kaodv_ops[0]')
kaodv-mod.c:419: error: unknown field `hook' specified in initializer
kaodv-mod.c:419: warning: excess elements in struct initializer
kaodv-mod.c:419: warning: (near initialization for `kaodv_ops[1]')
kaodv-mod.c:423: error: unknown field `pf' specified in initializer
kaodv-mod.c:423: warning: excess elements in struct initializer
kaodv-mod.c:423: warning: (near initialization for `kaodv_ops[1]')
kaodv-mod.c:424: error: unknown field `hooknum' specified in initializer
kaodv-mod.c:424: warning: excess elements in struct initializer
kaodv-mod.c:424: warning: (near initialization for `kaodv_ops[1]')
kaodv-mod.c:425: error: unknown field `priority' specified in initializer
kaodv-mod.c:425: warning: excess elements in struct initializer
kaodv-mod.c:425: warning: (near initialization for `kaodv_ops[1]')
kaodv-mod.c:428: error: unknown field `hook' specified in initializer
kaodv-mod.c:428: warning: excess elements in struct initializer
kaodv-mod.c:428: warning: (near initialization for `kaodv_ops[2]')
kaodv-mod.c:432: error: unknown field `pf' specified in initializer
kaodv-mod.c:432: warning: excess elements in struct initializer
kaodv-mod.c:432: warning: (near initialization for `kaodv_ops[2]')
kaodv-mod.c:433: error: unknown field `hooknum' specified in initializer
kaodv-mod.c:433: warning: excess elements in struct initializer
kaodv-mod.c:433: warning: (near initialization for `kaodv_ops[2]')
kaodv-mod.c:434: error: unknown field `priority' specified in initializer
kaodv-mod.c:434: warning: excess elements in struct initializer
kaodv-mod.c:434: warning: (near initialization for `kaodv_ops[2]')
2、
468:ret = nf_register_hook(&kaodv_ops[0]);
kaodv-mod.c:468: error: invalid use of undefined type `struct nf_hook_ops'
473:ret = nf_register_hook(&kaodv_ops[1]);
kaodv-mod.c:473: error: invalid use of undefined type `struct nf_hook_ops'
r477:et = nf_register_hook(&kaodv_ops[2]);
kaodv-mod.c:477: error: invalid use of undefined type `struct nf_hook_ops'
520:nf_unregister_hook(&kaodv_ops[1]);
kaodv-mod.c:520: error: invalid use of undefined type `struct nf_hook_ops'
522:nf_unregister_hook(&kaodv_ops[0]);
kaodv-mod.c:522: error: invalid use of undefined type `struct nf_hook_ops'
struct nf_hook_ops这个结构体都在netfilter.h中定义了,也包括了这个头文件,为啥这里说未定义的类型呢?
3、
543:for (i = 0; i < sizeof(kaodv_ops) / sizeof(struct nf_hook_ops); i++)
544: nf_unregister_hook(&kaodv_ops);
kaodv-mod.c:543: error: invalid application of `sizeof' to an incomplete type
kaodv-mod.c:543: error: invalid application of `sizeof' to an incomplete type
kaodv-mod.c:543: warning: division by zero
kaodv-mod.c:544: error: invalid use of undefined type `struct nf_hook_ops'
所以主要问题是在第一个问题处,我查了很多资料,我感觉这个初始化应该没什么问题啊?
还不知道是什么问题?
高手给点意见
谢谢啊 |
|