资源描述
移植wpa_supplicant到arm-linux
宿主機開發環境:Ubuntu 10.10 /Fedora 12 32 bits
目標開發板:Mini6410 arm-linux
內核Kernel: 2.6.38
交叉編譯器CROSS_COMPILE:arm-linux-gcc-4.5.1
1.移植準備
a. 下載 openssl源代碼 (使用openssl-0.9.8e )
官網: http://www.openssl.org/source/
源碼:http://www.openssl.org/source/openssl-0.9.8e.tar.gz
b. 下載 wpa_supplicant源代碼 (使用wpa_supplicant-0.7.3 )
官網:http://hostap.epitest.fi/wpa_supplicant/
源碼:http://hostap.epitest.fi/releases/wpa_supplicant-0.7.3.tar.gz
c: 下載:libtommath源代碼(libtommath_0.39.orig.tar.gz)
源碼:ftp://220.165.12.10/debian/pool/main/libt/libtommath/libtommath_0.39.orig.tar.gz
2. 編譯openssl
a.將openssl解到 wpa_supplicant/patches 目錄下
# tar zxvf openssl-0.9.8e.tar.gz -C ../ wpa_supplicant-0.7.3/patches/
b.將openssl-0.9.8-tls-extensions.patch拷貝到 wpa_supplicant/patches/openssl-0.9.8e 目錄下
# cp wpa_supplicant-0.7.3/patches/openssl-0.9.8e-tls-extensions.patch openssl-0.9.8e/
c.patch openssl-0.9.8e
# patch -p1 < openssl-0.9.8e-tls-extensions.patch
d. 編譯openssl
方式1.
# ./Configure linux-elf-arm -DB_ENDIAN linux:' arm-linux-gcc' shared --prefix=/usr/local/openssl
# make CC=arm-linux-gcc install
>>產生 libssl.a 及libcrypto.a
方式2.
# ./Configure no-asm --prefix=/usr/local/openssl
# make CC=arm-linux-gcc install
>>產生 libssl.so及libcrypto.so
3.編譯libtommath-0.39
a.將libtommath-0.39解到/usr/src/ 目錄下
# tar zxvf libtommath_0.39.orig.tar.gz -C /usr/src
b.編譯libtommath
# make CC=arm-linux-gcc
產生libtommath.a
4. 編譯wpa_supplicant(增加WPS功能)
#cp defconfig .config
CONFIG_DRIVER_WEXT=y
CONFIG_IEEE8021X_EAPOL=y
CONFIG_EAP_FAST=y
CONFIG_TLS=openssl
CONFIG_TLS=internal
CONFIG_INTERNAL_LIBTOMMATH=y
ifndef CONFIG_INTERNAL_LIBTOMMATH
LTM_PATH=/usr/src/libtommath-0.39
CFLAGS += -I$(LTM_PATH)
LIBS += -L$(LTM_PATH)
LIBS_p += -L$(LTM_PATH)
endif
CONFIG_WPS=y
CONFIG_EAP_WPS=y
#vim .config
CC= gcc -L/usr/local/ssl/lib/
CFLAGS += -I/usr/local/ssl/include/
LIBS += -L/usr/local/ssl/lib/
#make CC=arm-linux-gcc install
修正WEP中open/share 無法正確選擇
WPA_SUPPLICANT 當遇到WEP加密時,由於無法判斷是採用OPEN/SHARE,通常會在聲稱.conf檔中加入auth_alg=OPEN SHARED(至少Android遇到),但事實上某些wifi網卡驅動不能實現同時OPEN和SHARED同時設置,任意時刻只能用一個,這裏給出解決 不能同時設置的方法,在wpa_supplicant.c:wpa_supplicant_associate()中加入以下內容:
if (ssid->auth_alg) {
algs = 0;
if (ssid->auth_alg & WPA_AUTH_ALG_OPEN)
algs |= AUTH_ALG_OPEN_SYSTEM;
if (ssid->auth_alg & WPA_AUTH_ALG_SHARED)
algs |= AUTH_ALG_SHARED_KEY;
if (ssid->auth_alg & WPA_AUTH_ALG_LEAP)
algs |= AUTH_ALG_LEAP;
wpa_printf(MSG_DEBUG, "Overriding auth_alg selection: 0x%x",
algs);
//新增這段
if ((algs & AUTH_ALG_OPEN_SYSTEM) && (algs & AUTH_ALG_SHARED_KEY) ) {
algs = AUTH_ALG_SHARED_KEY;
G_TRY_CONNECT ++;
if (G_TRY_CONNECT >= 4) {
algs = AUTH_ALG_OPEN_SYSTEM;
wpa_printf(MSG_DEBUG, "RAYDEBUG--------------------change to ALG_OPEN_SYSTEM");
}
}
}
Wpa_supplicant.conf 說明
#Arm-linux/linux //建立socket
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheelupdate_config=1 (可以在wpa_cli中保存配置檔)
#ap_scan=1
#Android //建立socket
ctrl_interface=DIR=/data/misc/wifi
ctrl_interface_group=wifi
update_config=1 (可以在wpa_cli中保存配置檔)
#ap_scan=1
##WPA/WPA2
# WPA-PSK, PSK use ASCII (只要密碼正確就允許)
#network={
# ssid="AcSiP" //AP名稱
#psk="1111111111" //密碼
# #Higher priority use first
# priority=5
#}
# The same as above, assign SSID for AP without brocast SSID(針對那些拒絕廣播SSID的AP)
#network={
#network={
# ssid="second ssid"
# scan_ssid=1
# psk="very secret passphrase"
# priority=2
#}
# Allow WPA-PSK only. Allow any valid password set(允許使用任何合法的加密方式的組合)
#network={
# ssid="example"
# proto=WPA
# key_mgmt=WPA-PSK
# pairwise=CCMP TKIP
# group=CCMP TKIP WEP104 WEP40
# psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
# priority=2
#}
# Plaintext( Not use 802.1X )明文连接方式(不使用WPA和IEEE802.1X)
#network={
# ssid="plaintext-test"
# key_mgmt=NONE
#}
# Shared WEP, Not use IEEE 802.11 Shared Key(不使用WPA和IEEE802.1X)
network={
ssid=""Test1"
key_mgmt=NONE
# 引號包含的密鑰是ASCII密鑰
wep_key0="abcde"
# 沒有引號包含的密鑰是十六進位密鑰
wep_key1=0102030405
wep_key2="1234567890123"
wep_tx_keyidx=0
priority=5
}
#Shared WEP, Use IEEE 802.11 Shared Key
#network={
# ssid="Test1"
# key_mgmt=NONE
# wep_key0="aaaaa"
# wep_key1="aaaaa"
# wep_key2="aaaaa"
# wep_key3="aaaaa"
# wep_tx_keyidx=0
# priority=5
# auth_alg=SHARED
#}
#IBSS/ad-hoc with WPA-None/TKIP
#network={
# ssid="test adhoc"
# mode=1
# proto=WPA
# key_mgmt=WPA-NONE
# pairwise=NONE
# group=TKIP
# psk="secret passphrase"
#}
wpa_cli說明
# wpa_cli -i <interface> status (看看目前的狀態)
# wpa_cli -i <interface> help (查看參數與指令)
# wpa_cli -i <interface> terminate (關閉wpa_supplicant)
# wpa_cli -i <interface> interface (查看有那些無線網卡介面)
# wpa_cli -i <interface> list_networks (查看wpa_supplicant.conf檔裡的設定)
# wpa_cli -i <interface> select_network (選擇不同的AP,id為AP代號0,1,2,3...)
# wpa_cli -i <interface> enable_network
# wpa_cli -i <interface> disable_network
# wpa_cli -i <interface> remove_network (刪除AP資訊)
# wpa_cli -i <interface> reconfigure (重新讀取wpa_supplicant.conf設定內容)
# wpa_cli -i <interface> save_config (儲存寫入到wpa_supplicant.conf中,否責變更無效)
# wpa_cli -i <interface> disconnect (斷線)
# wpa_cli -i <interface> reconnect (重新連線)
# wpa_cli -i <interface> scan (掃描附近的AP)
# wpa_cli -i <interface> scan_results (印出附近AP的相關資訊)
以上常常用到的差不多是disconnect, reconnect, scan, scan_results, select_network, list_networks, status, reconfigure
測試WPS
wpa_supplicant.conf
##Arm-linux/linux:建立socket
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0update_config=1
#ap_scan=1
eapol_version=1
fast_reauth=1
##Android:建立socket
ctrl_interface=DIR=/data/misc/wifi
ctrl_interface_group=wifi
update_config=1
#ap_scan=1
eapol_version=1
fast_reauth=1
wpa_cli使用
wpa_supplicant -dd -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf&
wpa_cli terminate
Interactive mode
>scan //獲得BSSID
>wps_pbc [BSSID] //開始WPS Push button
>wps_pin <BSSID> [PIN] // 開始WPS PIN方法, PIN
//-----------------------------------
你好,我在按照您的方法来一直wpa——application的时候后,在编译wpa_supplicant-0.7.3的时候,提示了很多错误,undefined reference to `dh5_derive_shared'
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/wps/wps_common.c:85: undefined reference to `dh5_free'
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/wps/wps_common.c:102: undefined reference to `sha256_vector'
../src/wps/wps_attr_build.o: In function `wps_build_public_key':
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/wps/wps_attr_build.c:40: undefined reference to `dh5_free'
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/wps/wps_attr_build.c:41: undefined reference to `dh5_init'
../src/eapol_supp/eapol_supp_sm.o: In function `eapol_sm_processKey':
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/eapol_supp/eapol_supp_sm.c:753: undefined reference to `rc4_skip'
../src/eap_peer/eap.o: In function `eap_peer_sm_deinit':
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/eap_peer/eap.c:1281: undefined reference to `tls_deinit'
../src/eap_peer/eap.o: In function `eap_peer_sm_init':
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/eap_peer/eap.c:1256: undefined reference to `tls_init'
../src/eap_peer/eap.o: In function `eap_sm_parseEapReq':
/usr/local/arm/wpa/wpa_supplicant-0.7.3/wpa_supplicant/../src/eap_peer/eap.c:1096: undefined reference to `md5_vector'
../src/eap_peer/eap_tls_common.o: In function `eap_tls_process_output':
我想问一下,这些问题怎么解决呢?
//-------------------------------------
這個是我原始參考的網頁:
.tw/url?sa=t&rct=j&q=wpa_supplicant+wps&source=web&cd=1&ved=0CFkQFjAA&url=https%3A%2F%2Fbugzilla.altlinux.org%2Fattachment.cgi%3Fid%3D4573&ei=ZoIgUNStDKrYmAXIs4GIDg&usg=AFQjCNFoIMIzSI0ip5RTxgP2FJKENaHVBA
請把你的環境及.config重新確認...在ubuntu的話請你先確認wpa_supplicant-0.73 可以直接編譯....否則移植會缺少library
Fedora因為library幾乎都直接安裝了,所以沒有缺檔的問題
展开阅读全文