分类: LINUX
2009-03-17 17:28:25
-------------------------------------------------
本文系本站原创,欢迎转载!
前天装ubuntu,照其他人方式用wpa_supplicant登录内网,搞了将近一下午都没搞成功,郁闷啊,最后偶然的机会用无线给搞定了。今天突然想到要将wpa_supplicant移植到开发板上,一则成功了的话,开发板就可以上网了,那多好,二则验证为什么我的ubuntu登录不了,于是上午看了802.1x的协议的一些东西,下午给移植成功了,过程如下移。
我们都知道在高一点版本的PC的Linux中,一般都带有wpa_supplicant,校内网一般用这个登录,今天就讲mini2440中的移植。
下载wpa_supplicant
下载后解压,
1修改Makefile文件,将
ifndef CC
CC=gcc
Endif
改为arm-linux-gcc
2再修改defconfig文件.
由于我们学校的认证是用md5方式,将defconfig中除CONFIG_EAP_MD5=y外的其他CONFIG_EAP_xx去掉,因为,其他方式可能需要有相关的库,如tls就需要libtls.so库,为了编译方便,将用不到的尽量不要,免得编译时出错,事实上开始我没有修改进行编译时就出现了libtsl.so库中相关函数Undefine的错误,因为arm-linux库中不可能有这个库,所以会编译失败。
# EAP-MD5
CONFIG_EAP_MD5=y //只保留这个
# EAP-MSCHAPv2
CONFIG_EAP_MSCHAPV2=y
# EAP-TLS
CONFIG_EAP_TLS=y
# EAL-PEAP
CONFIG_EAP_PEAP=y
# EAP-TTLS
CONFIG_EAP_TTLS=y
# EAP-GTC
CONFIG_EAP_GTC=y
# EAP-OTP
CONFIG_EAP_OTP=y
# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
#CONFIG_EAP_SIM=y
# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
#CONFIG_EAP_PSK=y
# EAP-PAX
#CONFIG_EAP_PAX=y
# LEAP
CONFIG_EAP_LEAP=y
# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
#CONFIG_EAP_AKA=y
# EAP-SAKE
#CONFIG_EAP_SAKE=y
# EAP-GPSK
#CONFIG_EAP_GPSK=y
# Include support for optional SHA256 cipher suite in EAP-GPSK
#CONFIG_EAP_GPSK_SHA256=y
然后执make就ok了,然后就下到开发板运行。
运行前要添加wpa_supplicant配置文件
我的配置文件如下
[root@FriendlyARM /]# cat /etc/lan.conf
ctrl_interface=/var/run/wpa_supplicant
# ctrl_interface_group=wheel
ap_scan=0
network={
key_mgmt=IEEE8021X
eap=MD5
identity="028xxxxxx@local"//改为你自己的号,上外网去掉@local
password="2475xxxx" //改为你自己的密码
eapol_flags=0
}
[root@FriendlyARM /]# wpa_supplicant -B -ieth0 -c /etc/lan.conf -Dwired
Ok了,
但是这是认证,我们还要获得Ip等相关信息,所以要动刀dhcp软件,
幸好mini2440带有udhcpc嵌入式动态ip客户端。
所以我们执行
[root@FriendlyARM /]#udhcpc eth0
Sending select for 10.20.29.40...
udhcpc[321]: Sending select for 10.20.29.40...
Waiting on select...
udhcpc[321]: Waiting on select...
oooooh!!! got some!
udhcpc[321]: oooooh!!! got some!
Lease of 10.20.29.40 obtained, lease time 14400
udhcpc[321]: Lease of 10.20.29.40 obtained, lease time 14400
vforking and execle'ing /usr/share/udhcpc/default.script
udhcpc[321]: vforking and execle'ing /usr/share/udhcpc/default.script
script /usr/share/udhcpc/default.script failed: No such file or directory
udhcpc[323]: script /usr/share/udhcpc/default.script failed: No such file or dir
ectory
entering none listen mode
从上面我们可以看出有错误,明显可以看出是红色的地方的错误,原来是这个文件不存在,
到baidu,google搜索一下发现,用busybox下sample文件夹下的simple.script代替即可。
root@FriendlyARM /bin]#mkdir /usr/share/udhcpc
root@FriendlyARM /bin]# mv /mnt/simple.script /usr/share/udhcpc/default.script
下面再试下udhcpc看行不行
[root@FriendlyARM /bin]# udhcpc eht0
v dhcpc (v1.2.0) started
adapter index 3
adapter hardware address 00:13:f6:6c:87:89
vforking and execle'ing /usr/share/udhcpc/default.script
entering raw listen mode
Opening raw socket on ifindex 3
adding option 0x35
adding option 0x3d
adding option 0x3c
Sending discover...
Waiting on select...
oooooh!!! got some!
adding option 0x35
adding option 0x3d
adding option 0x3c
adding option 0x32
adding option 0x36
Sending select for 10.20.29.40...
Waiting on select...
oooooh!!! got some!
adding option 0x35
adding option 0x3d
adding option 0x3c
adding option 0x32
adding option 0x36
Sending select for 10.20.29.40...
Waiting on select...
oooooh!!! got some!
Lease of 10.20.29.40 obtained, lease time 14400
vforking and execle'ing /usr/share/udhcpc/default.script
deleting routers
adding dns 202.112.14.151
adding dns 202.112.14.161
entering none listen mode
看来成功了
下面测试下
root@FriendlyARM /bin]# ping
PING (202.112.14.184): 56 data bytes
64 bytes from 202.112.14.184: icmp_seq=0 ttl=121 time=1.5 ms
64 bytes from 202.112.14.184: icmp_seq=1 ttl=121 time=1.1 ms
64 bytes from 202.112.14.184: icmp_seq=2 ttl=121 time=1.2 ms
64 bytes from 202.112.14.184: icmp_seq=3 ttl=121 time=1.2 ms
64 bytes from 202.112.14.184: icmp_seq=4 ttl=121 time=1.3 ms
64 bytes from 202.112.14.184: icmp_seq=5 ttl=121 time=1.2 ms
64 bytes from 202.112.14.184: icmp_seq=6 ttl=121 time=1.5 ms
64 bytes from 202.112.14.184: icmp_seq=7 ttl=121 time=2.3 ms
64 bytes from 202.112.14.184: icmp_seq=8 ttl=121 time=1.2 ms
成功
访问ftp测试
[root@FriendlyARM /bin]# ftp ftp1.stuhome.net
Connected to ftp1.stuhome.net.
220 202.115.22.17 FTP server ready
Name (ftp1.stuhome.net:root): qsh_sjj0412
331 Password required for qsh_sjj0412
Password:
230 User qsh_sjj0412 logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxrwxr-x 10 qsh_sjj0412 download 256 Mar 15 13:03 ACG
drwxr-xr-x 18 qsh_sjj0412 download 688 Sep 18 15:02 Game
ftp> cd Game
250 CWD command successful
ftp>dir
drwxrwxr-x 3 qsh_sjj0412 download 280 Feb 24 15:20 ??????????????????SPT?
??
drwxrwxr-x 4 qsh_sjj0412 download 304 Feb 24 15:22 ??????????????????ETC?
??
drwxrwxr-x 4 qsh_sjj0412 download 128 Jun 22 2008 ??????????????????TCG?
??
drwxrwxr-x 5 qsh_sjj0412 download 352 Mar 13 01:58 ???????????????AVG???
drwxrwxr-x 17 qsh_sjj0412 download 912 Feb 28 04:10 ???????????????ACT???
drwxrwxr-x 10 qsh_sjj0412 download 1072 Feb 28 04:10 ?????????????????????R
TS???
drwxrwxr-x 6 qsh_sjj0412 download 424 Feb 24 11:47 ??????????????????STG?
??
drwxrwxr-x 3 qsh_sjj0412 download 240 Mar 13 01:58 ???????????????FGT???
drwxrwxr-x 5 qsh_sjj0412 download 248 Mar 2 07:47 ???????????????
drwxrwxr-x 5 qsh_sjj0412 download 464 Feb 28 04:10 ???????????????SIM???
drwxrwxr-x 6 qsh_sjj0412 download 560 Dec 24 16:23 ????????????
drwxrwxr-x 7 qsh_sjj0412 download 544 Mar 2 06:44 ???????????????RCG???
drwxrwxr-x 18 qsh_sjj0412 download 1280 Mar 14 01:48 ??????????????????????
???????????FPS???
drwxrwxr-x 17 qsh_sjj0412 download 1224 Dec 24 16:26 ???????????????SLG???
drwxrwxr-x 22 qsh_sjj0412 download 1728 Mar 2 05:42 ?????????????????????R
PG???
226 Transfer complete
ftp>
成功。
下一步打算实现开发板路由功能,这样我们的主机就可以通过开发板上网了,开发板就相当于802.1x路由器了。
chinaunix网友2009-04-23 20:54:18
你好, 我们现在也在移植linux2.6.13, 但我们现在碰到一个问题,就是用udhcpc -i eth1去获取IP的时候只看到sending discover, 之后就超时, 在网络上抓包, 发现有dhcp offer. 之后板子还是不能获取IP, 在命令源代码中加调试信息, 发现根本收不到数据, 楼主能不能帮我解答下, 加我qq吧, 32696734
sjj04122009-04-08 20:08:12
我绝对是移植成功了的,上面的网友,请注意用词,最上面的网友196299389,我早些时候加过你的qq,且验证时说是8021,x的,但是你拒绝了。现在我说下我的开发板配置,mini2440,内核linux2.6.13,根文件系统中有udhcpc命令,也就是不需要移植dhcp客户端了dhclient,用udhcpc。搞嵌入式这一行,学习的过程就是解决问题的过程,baidu,google是很重要的,因为嵌入式是很专的,可能有点不一样(如cpu,内核版本,你的内核网络是否开启动态获取Ip支持等各方面),别人行的你就可能不行,如果我的文章确实间接的给你带来了麻烦,我再次抱歉,但是我上面写的绝对是真的,我也相信我的文章给读者会有益帮助。
chinaunix网友2009-04-02 20:35:58
经过验证,这个作者所写的纯粹是乱砍,不负责任的乱发表,虽然是他个人的博客,但是请后来者不要在这里耽误时间,我已经搞了三天全都是错误。算你狠,浪费了我们这么多时间。操你妈妈的BBBBBBBBBB