分类: 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-01 21:12:24
我今天装上了ubuntu8.10, 在设置所有的设置后make ,出现如下提示: make :*** No rule to make target 'config.o', needed by 'wpa_supplicant',stop 出现这样的提示是什么意思啊 怎么处理啊
chinaunix网友2009-03-29 17:15:50
我开发板内核是linux2-.6.13,红帽可能不是用udhcpc,而是用dhclient eth0,还有你通不了是说指ping不通我外网。
chinaunix网友2009-03-27 22:49:16
兄弟,我找了好苦才找到你的这片文章啊,可是我在红帽下跑不通 啊,想请教请教你啊,我的QQ是196299389,我的电话是15879798150,希望能得到兄弟的帮助啊,我在此不胜感激啊