1. 程式人生 > >wpa_supplicant 客戶端介紹和原始碼安裝

wpa_supplicant 客戶端介紹和原始碼安裝

linux 系統平臺:

一. wpa_supplicant介紹

WPA是WiFi Protected Access的縮寫,中文含義為“WiFi網路安全存取”。WPA是一種基於標準的可互操作的WLAN安全性增強解決方案,可大大增強現有以及未來無線區域網絡的資料保護和訪問控制水平。
Wpa_supplicant是一個免費的IEEE 802.1x客戶端軟體,支援多種作業系統,包括:Linux,BSD, 蘋果計算機的Mac OS, 以及微軟的Windows作業系統。它同時支援(無線受保護訪問)WPA和WPA2(IEEE 802.11i / RSN)。Wpa_supplicant被設計成在後臺執行來控制無線連線。同時擁有圖形使用者介面和命令列介面來監聽執行的客戶端。通過這些使用者介面,使用者可以看到所有可得到的網路
直譯為: 使用者空間802.1x/WPA請求者(無線client端),適用於linux /BSD/Windows驅動

也就是說,wpa_supplicant是一個client側使用的程序,它包含了802.1x、WPA的請求工作。

二. 原始碼安裝指南

  • 依賴庫安裝

    依賴庫原始碼地址:
    http://ftp.gnu.org/gnu/bison/
    https://linux.softpedia.com/get/Programming/Interpreters/Flex-23296.shtml
    http://www.infradead.org/~tgr/libnl/files/libnl-3.2.25.tar.gz
    https://www.openssl.org/source/

  • 依賴庫原始碼:

    bison-3.2.tar.gz;flex-2.6.4.tar.gz; libnl-3.2.25.tar.gz ; openssl-1.1.1.tar.gz
    依賴庫安裝說明:
    前三個依賴庫編譯安裝方法類似 :{

    1. tar -xvf libnl-3.2.25.tar.gz || bison-3.2.tar.gz || flex-2.6.4.tar.gz
    2. cd libnl-3.2.25 || bison-3.2.tar.gz || flex-2.6.4.tar.gz
    3. ./configure --prefix=/usr/local/ || ./configure --prefix=/usr/local/tmp/ (linbn-3.2.25特定安裝目錄)
    4. make //編譯
    5. make install
  • openssl 原始碼安裝:

    {

    1. 在資料夾下解壓縮,執行如下命令:
      a) tar -xzf openssl-1.1.1.tar.gz
      b) 得到openssl-1.1.1資料夾。
    2. 進入解壓目錄,執行如下命令
      i. cd openssl-1.1.1
    3. 設定Openssl 安裝路徑,( --prefix )引數為欲安裝之目錄,執行如下命令:
      i. ./config --prefix=/usr/local/openssl
    4. 執行命令./config -t
    5. 執行make,編譯Openssl,編譯需要等待一定的時間。
    6. 執行make install,安裝 Openssl,安裝也需要一定的時間。
      }
  • Wpa_supplicant 安裝

1.解壓

tar -xzf wpa_supplicant-2.6.tar.gz
cd wpa_supplicant-2.6/wpa_supplicant

2.編譯與安裝

#cp  deconfig .config
  Vi .config 
修改.config,使能CONFIG_LIBNL32=y
   修改Makefile ,加上libnl 和 opnssl的標頭檔案 和 lib庫。
CFLAGS += -I/usr/local/openssl/include
LIBS += -L/usr/local/openssl/lib
CFLAGS += -I/usr/local/tmp/include/libnl3
LDFLAGS += -L/usr/local/tmp/lib
將自帶的defconfig改名為.config並編輯,開啟如下選項:
CONFIG_LIBNL32=y
:wq
	#make;  
常見錯誤:

1.WPA_suppclient 錯誤
(1)
[email protected]:/wpa_supplicant/; make
/usr/bin/ld: cannot find -lnl
collect2: ld returned 1 exit status
make: *** [hostapd] Error 1
將自帶的defconfig改名為.config並編輯,開啟如下選項:
CONFIG_LIBNL32=y
原因:{
vi src/drivers/drivers.mk +38
發現下面這幾句。
ifdef CONFIG_LIBNL32
DRV_LIBS += -lnl-3
DRV_LIBS += -lnl-genl-3
DRV_CFLAGS += -DCONFIG_LIBNL20 -I/usr/include/libnl3
那麼我們只需要,在配置檔案.config裡,加
CONFIG_LIBNL32 = y 就可以了。

(2){
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
則需要將libnl-3.0.pc所在目錄新增到PKG_CONFIG_PATH變數中,先用如下命令檢視所在目錄:
 find / -name "libnl-3.0.pc"
/lib/pkgconfig/libnl-3.0.pc
在/etc/bash.bash的最後一行加:export PKG_CONFIG_PATH=/lib/pkgconfig/:$PKG_CONFIG_PATH
重啟一次環境變數:source /etc/bash.bashrc
確認環境變數:    echo $PKG_CONFIG_PATH

}
2.openssl 安裝錯誤
{
/usr/bin/ld: cannot find -lcrypto
ll /usr/lib64/libssl*,得到
-rwxr-xr-x. 1 root root 242112 Jul 17 2012 /usr/lib64/libssl3.so
lrwxrwxrwx. 1 root root 15 Nov 30 01:31 /usr/lib64/libssl.so.10 -> libssl.so.1.0.0
-rwxr-xr-x. 1 root root 372488 Aug 23 2012 /usr/lib64/libssl.so.1.0.0
根本原因是,雖然有libssl的動態庫檔案,但沒有檔名為 libssl.so 的檔案,ld找不到它
於是新增軟連結:
ln -s /usr/lib64/libssl.so.1.0.0 /usr/lib64/libssl.so
ln -s /usr/lib64/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so
}
{
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory 這是由於openssl庫的位置不正確造成的。

解決方法:
在root使用者下執行:
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
}