aodv-0.9.6移植

交叉编译aodv路由算法

将aodv路由算法移植到友善之臂的6410开发板上

友善之臂的6410开发板的内核是2.6.38

我使用fedora9平台

 


首先搭建好arm-linux-gcc编译环境

友善之臂的6410光盘附有搭建方法:
Step1:将光盘Linux 目录中的arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz 复制到Fedora9
某个目录下如tmp/,然后进入到该目录,执行解压命令:
#cd /tmp
#tar xvzf arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz –C /
注意:C 后面有个空格,并且C 是大写的,它是英文单词“Change”的第一个字母,
在此是改变目录的意思。
执行该命令,将把 arm-linux-gcc 安装到/opt/FriendlyARM/toolschain/4.5.1 目录。
Step2:把编译器路径加入系统环境变量,运行命令
#gedit /root/.bashrc
编辑/root/.bashrc 文件,注意“bashrc”前面有一个“.”,修改最后一行为export
PATH=$PATH: /opt/FriendlyARM/toolschain/4.5.1/bin,注意路径一定要写对,否则将不会有
效。

重新登录系统(不必重启机器,开始->logout 即可),使以上设置生效,在命令行输入
arm-linux-gcc –v,会出现如下信息,这说明交叉编译环境已经成功安装。

root@seraph-desktop:/home/seraph/aodv-uu-0.9.6/lnx# arm-linux-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gcc
COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolschain/4.5.1/libexec/gcc/arm-none-linux-gnueabi/4.5.1/lto-wrapper
Target: arm-none-linux-gnueabi
Configured with: /work/toolchain/build/src/gcc-4.5.1/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.5.1 --with-sysroot=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --enable-languages=c,c++ --disable-multilib --with-cpu=arm1176jzf-s --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=softfp --with-pkgversion=ctng-1.8.1-FA --with-bugurl=http://www.arm9.net/ --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-gmp=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpfr=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-ppl=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-cloog=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpc=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-libelf=/work/toolchain/build/arm-none-linux-gnueabi/build/static --enable-threads=posix --with-local-prefix=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.5.1 (ctng-1.8.1-FA)

----------------我是分割线--------------------

然后修改Makefile后
修改内核路径
#KERNEL_DIR=/lib/modules/$(KERNEL)/build 
#KERNEL_INC=$(KERNEL_DIR)/include 
KERNEL_DIR=/usr/src/linux-2.6.38 
KERNEL_INC=/usr/src/linux-2.6.38/include 
设置交叉编译工具
CC=arm-linux-gcc

----------------我还是分割线--------------------

出现了以下的错误
Error:Array type has incomplete element type
Error:field name not in record or union initializer
Error:near initialization for ‘kaodv_ops’

错误原因是aodv程序需要netfilter模块,解决方法是重新编译内核将netfilter加进去。
Networking ---> 
Networking options ---> 
*Network packet filtering framework (Netfilter) ---> 
IP: Netfilter Configuration ---> 
<M> IP Userspace queueing via NETLINK (OBSOLETE)

  

然后进入linux-2.6.38源码

 make config_h46 .config

 make dep

 make modules

 make modules install

 

将kaodv-netlink.c中
static DECLARE_MUTEX(kaodvnl_sem);
修改为:static DEFINE_SEMAPHORE(kaodvnl_sem);

 

In file included from /home/seraph/aodv-uu-0.9.6/lnx/kaodv-debug.c:25:0: 
/home/seraph/aodv-uu-0.9.6/lnx/kaodv-debug.h: In function 'print_ip': 
/home/seraph/aodv-uu-0.9.6/lnx/kaodv-debug.h:42:2: error: implicit declaration of function 'sprintf' 
/home/seraph/aodv-uu-0.9.6/lnx/kaodv-debug.h:42:2: warning: incompatible implicit declaration of built-in function 'sprintf' 
/home/seraph/aodv-uu-0.9.6/lnx/kaodv-debug.h: In function 'print_eth': 
/home/seraph/aodv-uu-0.9.6/lnx/kaodv-debug.h:58:2: warning: incompatible implicit declaration of built-in function 'sprintf'

这两个错误找不到sprintf是由于没有#include <stdio.h>
在对应的文件lnx/kaodv-debug.h程序中添加#include <stdio.h>后,又出现找不到stdio.h的错误。
/home/seraph/aodv-uu-0.9.6/lnx/kaodv-debug.h:25:19: fatal error: stdio.h: No such file or directory 
原因是在用户态下没有sprintf加#include <stdio.h>
而这个这段程序师在内核态所以要加#include <linux/kernel.h>

 

手动添加路由功能:

       

echo "1" > /proc/sys/net/ipv4/ip_forward
insmod kaodv.ko
scan-wifi
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid adhoc
ifconfig wlan0 192.168.0.1
./aodvd &

 

进入linux2.6.38 make scripts

 

ok 最后生成aodvd 文件和kaodv.ko 编译成功!
感谢网上的各位linuxer的文章帮我解决很多问题!

注:你的内核也必须支持<*> IP Userspace queueing via NETLINK (OBSOLETE)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值