日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 嵌入式 > 嵌入式分享
[導(dǎo)讀]這篇文章你將會(huì)看到嵌入式ARM-Linux上的常用應(yīng)用程序wpa_supplicant(以及wpa_supplicant依賴(lài)的libnl和openssl)的編譯、配置和運(yùn)行使用,iw、hostapd等應(yīng)用的編譯和使用。

這篇文章你將會(huì)看到嵌入式ARM-Linux上的常用應(yīng)用程序wpa_supplicant(以及wpa_supplicant依賴(lài)的libnl和openssl)的編譯、配置和運(yùn)行使用,iw、hostapd等應(yīng)用的編譯和使用。

wpa_supplicant編譯和配置運(yùn)行

從/zixunimg/eepwimg/w1.fi/wpa_supplicant/(git地址git://w1.fi/hostap.git)下載最新的wpa_supplicant源碼壓縮包,目前最新的為版本2.5. wpa_supplicant的編譯依賴(lài)于openssl和libnl庫(kù)(Netlink Protocol Library Suite (libnl)),openssl是ssl協(xié)議的開(kāi)源庫(kù)(OpenSSL, Secure Sockets Layer (SSL v2/v3) Transport Layer Security (TLS v1)).(壓縮包地址:/zixunimg/eepwimg/www.openssl.org/source/,Git地址:/zixunimg/eepwimg/github.com/openssl/openssl),libnl是網(wǎng)絡(luò)相關(guān)的庫(kù)(壓縮包地址:/zixunimg/eepwimg/www.infradead.org/~tgr/libnl/,Git地址 :/zixunimg/eepwimg/git.infradead.org/users/tgr/libnl.git)。

編譯libnl

解壓源代碼包。進(jìn)入libnl目錄,執(zhí)行./configure配置編譯環(huán)境;執(zhí)行make進(jìn)行編譯

export ARCH=arm

export CROSS_COMPILE=arm-linux-gnueabi-

./configure --prefix=/usr\

--sysconfdir=/etc \

--disable-static&&

make

然后執(zhí)行sudo make install,libnl.so會(huì)被安裝至/usr/local/lib/目錄下,相應(yīng)的頭文件也會(huì)被copy到/usr/local/include/netlink下。

如果報(bào)出編譯錯(cuò)誤:“../include/netlink_local.h:218:error ULONG_MAX undeclared",我們?cè)趯?duì)應(yīng)文件添加一個(gè)頭文件#include即可解決問(wèn)題;

編譯openssl

進(jìn)入openssl目錄,./config shared #一定要加shared,否則編譯出來(lái)的是靜態(tài)庫(kù)。執(zhí)行make進(jìn)行編譯,完成后執(zhí)行make install,編譯好的openssl庫(kù)和頭文件等被安裝在目錄/usr/local/ssl下

export ARCH=arm

export CROSS_COMPILE=arm-linux-gnueabi-

./config --prefix=/usr\

--openssldir=/etc/ssl \

--libdir=lib\

shared\

zlib-dynamic &&

make

If you want to disable installing the static libraries, use this sed:

sed -i s# libcrypto.a##;s# libssl.a## Makefile

Now, as therootuser:

make MANDIR=/usr/share/man MANSUFFIX=ssl install &&

install -dv -m755 /usr/share/doc/openssl-1.0.2e&&

cp -vfr doc/*/usr/share/doc/openssl-1.0.2e

編譯wpa_supplicant

添加修改配置文件

進(jìn)入wpa_supplicant/wpa_supplicant目錄,執(zhí)行cp defconfig .config拷貝生成編譯配置,然后修改配置文件.config,

#如果選擇的不是libnl的1.0版本,需要根據(jù)libnl的版本打開(kāi)下面的選項(xiàng)

CONFIG_LIBNL32=y

CONFIG_LIBNL20=y選擇libnl的版本

#添加openssl和libnl的頭文件和庫(kù)文件目錄,更新編譯鏈接環(huán)境變量

CFLAGS += -I/usr/local/ssl/include

CFLAGS += -I/usr/local/include/ libnl3

CFLAGS += -I/usr/local/include/netlink

LIBS += -L/usr/local/ssl/lib

LIBS += -L/usr/local/lib

LIBS_p += -L/usr/local/ssl/lib#不加此行,編wpa_passphrase出錯(cuò)。

cp defconfig .config

make CC=arm-linux-gnueabi-gcc

make install DESTDIR=/home/export/rootfs

執(zhí)行make進(jìn)行編譯

成功后生成三個(gè)目標(biāo)文件wpa_supplicant, wpa_cli, wpa_passphrase,至此編譯完成。

運(yùn)行wpa_supplicant

需要保證libssl庫(kù)在我們的搜索路徑里,否則不做處理,會(huì)出現(xiàn)找不到libnl, ssl和crypto庫(kù)的錯(cuò)誤。

./wpa_supplicant

./wpa_supplicant: error while loading shared libraries: libssl.so.1.1.0: cannot open shared object file: No such file or directory

將/usr/local/ssl/lib下的libssl.so.x.x.x和libcrypto.so.xxx拷貝到/lib目錄下即可,或者:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ssl/lib,或者在/etc/ld.so.conf文件中添加庫(kù)的搜索路徑。(或者在/etc/ld.so.conf.d下新建一個(gè).conf文件,將搜索路徑一行一個(gè)加入).

cp /usr/arm-linux-gnueabi/lib/libnl.so.1.1.4 /home/export/rootfs/lib/

cp /usr/arm-linux-gnueabi/lib/libcrypto.so.1.0.0 /home/export/rootfs/lib/

cp /usr/arm-linux-gnueabi/lib/libssl.so.1.0.0 /home/export/rootfs/lib/

配置wpa_supplicant

wpa_supplicant runs as a daemon and requires a configuration file. Create a file called /etc/wpa_supplicant.conf with the following contents:

network={

ssid="MySSID"

key_mgmt=WPA-PSK

proto=RSN

pairwise=CCMP TKIP

psk="MyPassPhrase"

}

The above file works with both WPA (TKIP) and WPA2 (CCMP/AES). Please insert your access point name at MySSID and your pass phrase at MyPassPhase.

Once configured, wpa_supplicant can be started using:

wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf

編譯錯(cuò)誤處理

Error#1

#######################################################################

CC ../src/drivers/driver_wired.c

../src/drivers/driver_nl80211.c:25:31: fatal error: netlink/genl/genl.h: No such file or directory

compilation terminated.

make: *** [../src/drivers/driver_nl80211.o] Error 1

#######################################################################

Solution #1

sudo apt-get -y install libssl-dev libnl-3-dev

echo CFLAGS +=-I/usr/include/libnl3/ >> .config

make

Error#2

../src/drivers/driver_nl80211.c:95:9: warning: passing argument 1 of ‘genl_ctrl_alloc_cache’ from incompatible pointer type [enabled by default]

/usr/include/libnl3/netlink/genl/ctrl.h:25:14: note: expected ‘struct nl_sock *’ but argument is of type ‘struct nl_handle *’

../src/drivers/driver_nl80211.c:95:9: error: too few arguments to function ‘genl_ctrl_alloc_cache’

/usr/include/libnl3/netlink/genl/ctrl.h:25:14: note: declared here

Solution #2

sudo apt-get install libnl-genl-3-dev

echo CONFIG_LIBNL32=y >> .config

make

Usage

usage:

wpa_supplicant [-BddhKLqqtvW] [-P] [-g] \

[-G] \

-i -c [-C] [-D] [-p] \

[-b] [-e] \

[-o] [-O] \

[-N -i -c [-C] [-D] \

[-p] [-b] [-I] …]

drivers:

nl80211 = Linux nl80211/cfg80211

wext = Linux wireless extensions (generic)

wired = Wired Ethernet driver

options:

-b = optional bridge interface name

-B = run daemon in the background

-c = Configuration file

-C = ctrl_interface parameter (only used if -c is not)

-i = interface name

-I = additional configuration file

-d = increase debugging verbosity (-dd even more)

-D = driver name (can be multiple drivers: nl80211,wext)

-e = entropy file

-g = global ctrl_interface

-G = global ctrl_interface group

-K = include keys (passwords, etc.) in debug output

-t = include timestamp in debug messages

-h = show this help text

-L = show license (BSD)

-o = override driver parameter for new interfaces

-O = override ctrl_interface parameter for new interfaces

-p = driver parameters

-P = PID file

-q = decrease debugging verbosity (-qq even less)

-v = show version

-W = wait for a control interface monitor before starting

-N = start describing new interface

example:

wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf

wpa_cli [-pctrl sockets>] [-i] [-hvB] [-a] \

[-P] [-g] [-G] [command..]

-h = help (show this usage text)

-v = shown version information

-a = run in daemon mode executing the action file based on events from

wpa_supplicant

-B = run a daemon in the background

default path: /var/run/wpa_supplicant

default interface: first interface found in socket path

commands:

status [verbose] = get current WPA/EAPOL/EAP status

ifname = get current interface name

ping = pings wpa_supplicant

relog = re-open log-file (allow rolling logs)

note = add a note to wpa_supplicant debug log

mib = get MIB variables (dot1x, dot11)

help [command] = show usage help

interface [ifname] = show interfaces/select interface

level = change debug level

license = show full wpa_cli license

quit = exit wpa_cli

set = set variables (shows list of variables when run without arguments)

get = get information

logon = IEEE 802.1X EAPOL state machine logon

logoff = IEEE 802.1X EAPOL state machine logoff

pmksa = show PMKSA cache

reassociate = force reassociation

preauthenticate = force preauthentication

identity = configure identity for an SSID

password = configure password for an SSID

new_password = change password for an SSID

pin = configure pin for an SSID

otp = configure one-time-password for an SSID

passphrase = configure private key passphrase

for an SSID

sim = report SIM operation result

bssid = set preferred BSSID for an SSID

blacklist = add a BSSID to the blacklist

blacklist clear = clear the blacklist

blacklist = display the blacklist

log_level [] = update the log level/timestamp

log_level = display the current log level and log options

list_networks = list configured networks

select_network = select a network (disable others)

enable_network = enable a network

disable_network = disable a network

add_network = add a network

remove_network = remove a network

set_network = set network variables (shows

list of variables when run without arguments)

get_network = get network variables

list_creds = list configured credentials

add_cred = add a credential

remove_cred = remove a credential

set_cred = set credential variables

save_config = save the current configuration

disconnect = disconnect and wait for reassociate/reconnect command before

connecting

reconnect = like reassociate, but only takes effect if already disconnected

scan = request new BSS scan

scan_results = get latest scan results

bss < | > = get detailed scan result info

get_capability = get capabilies

reconfigure = force wpa_supplicant to re-read its configuration file

terminate = terminate wpa_supplicant

interface_add

= adds new interface, all parameters but

are optional

interface_remove = removes the interface

interface_list = list available interfaces

ap_scan = set ap_scan parameter

scan_interval = set scan_interval parameter (in seconds)

bss_expire_age = set BSS expiration age parameter

bss_expire_count = set BSS expiration scan count parameter

bss_flush = set BSS flush age (0 by default)

stkstart = request STK negotiation with

ft_ds = request over-the-DS FT with

wps_pbc [BSSID] = start Wi-Fi Protected Setup: Push Button Configuration

wps_pin [PIN] = start WPS PIN method (returns PIN, if not hardcoded)

wps_check_pin = verify PIN checksum

wps_cancel Cancels the pending WPS operation

wps_reg = start WPS Registrar to configure an AP

wps_ap_pin [params..] = enable/disable AP PIN

wps_er_start [IP address] = start Wi-Fi Protected Setup External Registrar

wps_er_stop = stop Wi-Fi Protected Setup External Registrar

wps_er_pin = add an Enrollee PIN to External Registrar

wps_er_pbc = accept an Enrollee PBC using External Registrar

wps_er_learn = learn AP configuration

wps_er_set_config = set AP configuration for enrolling

wps_er_config = configure AP

ibss_rsn = request RSN authentication with in IBSS

sta = get information about an associated station (AP)

all_sta = get information about all associated stations (AP)

deauthenticate = deauthenticate a station

disassociate = disassociate a station

chan_switch [sec_channel_offset=] [center_freq1=] [center_freq2=] [bandwidth=] [blocktx] [ht|vht] = CSA parameters

suspend = notification of suspend/hibernate

resume = notification of resume/thaw

drop_sa = drop SA without deauth/disassoc (test command)

roam = roam to the specified BSS

p2p_find [timeout] [type=*] = find P2P Devices for up-to timeout seconds

p2p_stop_find = stop P2P Devices search

p2p_connect [ht40] = connect to a P2P Device

p2p_listen [timeout] = listen for P2P Devices for up-to timeout seconds

p2p_group_remove = remove P2P group interface (terminate group if GO)

p2p_group_add [ht40] = add a new P2P group (local end as GO)

p2p_prov_disc = request provisioning discovery

p2p_get_passphrase = get the passphrase for a group (GO only)

p2p_serv_disc_req = schedule service discovery request

p2p_serv_disc_cancel_req = cancel pending service discovery request

p2p_serv_disc_resp = service discovery response

p2p_service_update = indicate change in local services

p2p_serv_disc_external = set external processing of service discovery

p2p_service_flush = remove all stored service entries

p2p_service_add = add a local service

p2p_service_del [|service] = remove a local service

p2p_reject = reject connection attempts from a specific peer

p2p_invite [peer=addr] = invite peer

p2p_peers [discovered] = list known (optionally, only fully discovered) P2P peers

p2p_peer = show information about known P2P peer

p2p_set = set a P2P parameter

p2p_flush = flush P2P state

p2p_cancel = cancel P2P group formation

p2p_unauthorize

= unauthorize a peer

p2p_presence_req [ ] [ ] = request GO presence

p2p_ext_listen [ ] = set extended listen timing

p2p_remove_client = remove a peer from all groups

sta_autoconnect <0/1> = disable/enable automatic reconnection

tdls_discover = request TDLS discovery with

tdls_setup = request TDLS setup with

tdls_teardown = tear down TDLS with

signal_poll = get signal parameters

pktcnt_poll = get TX/RX packet counters

reauthenticate = trigger IEEE 802.1X/EAPOL reauthentication

raw = Sent unprocessed command

flush = flush wpa_supplicant state

radio_work = radio_work

Configuration

Setwpa_supplicant.confto the following:

You have to change the values according to the response of

# wpa_passphrase

.

For WPA-PSK

ctrl_interface=/var/run/wpa_supplicantctrl_interface_group=0eapol_version=1# ap_scan=2 was the one for me you may try 0 or 1 indstead of 2ap_scan=2fast_reauth=1network={ssid="my_network"proto=WPAkey_mgmt=WPA-PSKpairwise=TKIPgroup=TKIPpsk="secret_password"}

For WPA2-Personal

ctrl_interface=/var/run/wpa_supplicantctrl_interface_group=0ap_scan=1network={ssid="my_network"proto=RSNkey_mgmt=WPA-PSKpairwise=CCMP TKIPgroup=CCMP TKIPpsk="secret_password"}

Bringing up the network card manually

Bring up the network interface with

# ifconfig ath0 up

.

NOTE!

At the moment there is a problem within the madwifi driver or wpa_supplicant passing dhcp. That??s why I use a fixed IP.

There are two patches one for wpa_supllicant (/zixunimg/eepwimg/hostap.epitest.fi/bugz/show_bug.cgi?id=63) and one for madwifi

(/zixunimg/eepwimg/article.gmane.org/gmane.linux.drivers.madwifi.devel/1275). Each one is supposed to work.

Change the routes and add the default gateway.

Bringing up the device at boottime (forGentoousers)

Make a symbolic link

# cd /etc/init.d/

# ln -s net.lo net.ath0

Copywpa_supplicant.confto/etc/conf.d/wpa_supplicant.

Edit/etc/conf.d/net

##net#modules=( "wpa_supplicant" )wpa_supplicant_ath0="-Dmadwifi"modules=( "wpa_supplicant" )wpa_timeout_ath0=60config_ath0=(" netmask 255.255.255.0")routes_ath0=("default gw ")

Add net.ath0 to the default runlevel by executing

# rc-update add net.ath0 default

Make sure all needed modules are in/etc/modules.autoload/2.x

iw的編譯和配置運(yùn)行

iwis a new nl80211 (802.11 netlink interface) based CLI configuration utility for wireless devices.

Netlink Protocol Library Suite

iw requires theNetlink Protocol Library Suite (libnl)

Download, cross compile and install the Netlink Protocol libraries:

wget /zixunimg/eepwimg/www.infradead.org/~tgr/libnl/files/libnl-3.2.24.tar.gz

tar -xzf libnl-3.2.24.tar.gz

cd libnl-3.2.24

./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi

make

make install

cd include

make install

iw

With the Netlink Protocol Library Suite prerequisite installed, download and build theiwnl80211 based CLI configuration utility:

wget /zixunimg/eepwimg/www.kernel.org/pub/software/network/iw/iw-3.15.tar.gz

tar -xzf iw-3.15.tar.gz

cd iw-3.15/

export PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig

export CC=arm-linux-gnueabi-gcc

make

Manually install iw and required libraries on your target root-fs:

cp iw /home/export/rootfs/sbin/

cp /usr/arm-linux-gnueabi/lib/libnl-genl-3.so.200 /home/export/rootfs/lib/

cp /usr/arm-linux-gnueabi/lib/libnl-3.so.200 /home/export/rootfs/lib/

And update the dynamic linker run-time bindings on your target:

ldconfig -v

hostapd

hostapdis an 802.11 Access Point and IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator daemon.

Download, extract and build hostapd:

wget /zixunimg/eepwimg/hostap.epitest.fi/releases/hostapd-2.2.tar.gz

tar -xzf hostapd-2.2.tar.gz

cd hostapd-2.2/hostapd

cp defconfig .config

make CC=arm-linux-gnueabi-gcc

make install DESTDIR=/home/export/rootfs

rfkillis a userspace tool to query the state of the rfkill switches.

Download, extract and build rfkill:

wget/zixunimg/eepwimg/www.kernel.org/pub/software/network/rfkill/rfkill-0.5.tar.gz

tar -xzf rfkill-0.5.tar.gz

cd rfkill-0.5/

/zixunimg/eepwimg/houh-1984.blog.163.com

make CC=arm-linux-gnueabi-gcc

上面就是今天分享的那日通了。有興趣的可以回去試試看哦。

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀(guān)點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

LED驅(qū)動(dòng)電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: 驅(qū)動(dòng)電源

在工業(yè)自動(dòng)化蓬勃發(fā)展的當(dāng)下,工業(yè)電機(jī)作為核心動(dòng)力設(shè)備,其驅(qū)動(dòng)電源的性能直接關(guān)系到整個(gè)系統(tǒng)的穩(wěn)定性和可靠性。其中,反電動(dòng)勢(shì)抑制與過(guò)流保護(hù)是驅(qū)動(dòng)電源設(shè)計(jì)中至關(guān)重要的兩個(gè)環(huán)節(jié),集成化方案的設(shè)計(jì)成為提升電機(jī)驅(qū)動(dòng)性能的關(guān)鍵。

關(guān)鍵字: 工業(yè)電機(jī) 驅(qū)動(dòng)電源

LED 驅(qū)動(dòng)電源作為 LED 照明系統(tǒng)的 “心臟”,其穩(wěn)定性直接決定了整個(gè)照明設(shè)備的使用壽命。然而,在實(shí)際應(yīng)用中,LED 驅(qū)動(dòng)電源易損壞的問(wèn)題卻十分常見(jiàn),不僅增加了維護(hù)成本,還影響了用戶(hù)體驗(yàn)。要解決這一問(wèn)題,需從設(shè)計(jì)、生...

關(guān)鍵字: 驅(qū)動(dòng)電源 照明系統(tǒng) 散熱

根據(jù)LED驅(qū)動(dòng)電源的公式,電感內(nèi)電流波動(dòng)大小和電感值成反比,輸出紋波和輸出電容值成反比。所以加大電感值和輸出電容值可以減小紋波。

關(guān)鍵字: LED 設(shè)計(jì) 驅(qū)動(dòng)電源

電動(dòng)汽車(chē)(EV)作為新能源汽車(chē)的重要代表,正逐漸成為全球汽車(chē)產(chǎn)業(yè)的重要發(fā)展方向。電動(dòng)汽車(chē)的核心技術(shù)之一是電機(jī)驅(qū)動(dòng)控制系統(tǒng),而絕緣柵雙極型晶體管(IGBT)作為電機(jī)驅(qū)動(dòng)系統(tǒng)中的關(guān)鍵元件,其性能直接影響到電動(dòng)汽車(chē)的動(dòng)力性能和...

關(guān)鍵字: 電動(dòng)汽車(chē) 新能源 驅(qū)動(dòng)電源

在現(xiàn)代城市建設(shè)中,街道及停車(chē)場(chǎng)照明作為基礎(chǔ)設(shè)施的重要組成部分,其質(zhì)量和效率直接關(guān)系到城市的公共安全、居民生活質(zhì)量和能源利用效率。隨著科技的進(jìn)步,高亮度白光發(fā)光二極管(LED)因其獨(dú)特的優(yōu)勢(shì)逐漸取代傳統(tǒng)光源,成為大功率區(qū)域...

關(guān)鍵字: 發(fā)光二極管 驅(qū)動(dòng)電源 LED

LED通用照明設(shè)計(jì)工程師會(huì)遇到許多挑戰(zhàn),如功率密度、功率因數(shù)校正(PFC)、空間受限和可靠性等。

關(guān)鍵字: LED 驅(qū)動(dòng)電源 功率因數(shù)校正

在LED照明技術(shù)日益普及的今天,LED驅(qū)動(dòng)電源的電磁干擾(EMI)問(wèn)題成為了一個(gè)不可忽視的挑戰(zhàn)。電磁干擾不僅會(huì)影響LED燈具的正常工作,還可能對(duì)周?chē)娮釉O(shè)備造成不利影響,甚至引發(fā)系統(tǒng)故障。因此,采取有效的硬件措施來(lái)解決L...

關(guān)鍵字: LED照明技術(shù) 電磁干擾 驅(qū)動(dòng)電源

開(kāi)關(guān)電源具有效率高的特性,而且開(kāi)關(guān)電源的變壓器體積比串聯(lián)穩(wěn)壓型電源的要小得多,電源電路比較整潔,整機(jī)重量也有所下降,所以,現(xiàn)在的LED驅(qū)動(dòng)電源

關(guān)鍵字: LED 驅(qū)動(dòng)電源 開(kāi)關(guān)電源

LED驅(qū)動(dòng)電源是把電源供應(yīng)轉(zhuǎn)換為特定的電壓電流以驅(qū)動(dòng)LED發(fā)光的電壓轉(zhuǎn)換器,通常情況下:LED驅(qū)動(dòng)電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: LED 隧道燈 驅(qū)動(dòng)電源
關(guān)閉