不限流量网站空间,网站建设速度如何解决,成都科技网站建设费,做网站弄什么语言本文介绍了嵌入式ARM-Linux上的常用应用程序wpa_supplicant(以及wpa_supplicant依赖的libnl和openssl)的编译、配置和运行使用#xff0c;iw、hostapd等应用的编译和使用。wpa_supplicant 编译和配置运行从https://w1.fi/wpa_supplicant/ (git地址git://w1.fi/hostap.git)下载…本文介绍了嵌入式ARM-Linux上的常用应用程序wpa_supplicant(以及wpa_supplicant依赖的libnl和openssl)的编译、配置和运行使用iw、hostapd等应用的编译和使用。wpa_supplicant 编译和配置运行从https://w1.fi/wpa_supplicant/ (git地址git://w1.fi/hostap.git)下载最新的wpa_supplicant源码压缩包目前最新的为版本2.5. wpa_supplicant的编译依赖于openssl和libnl库(Netlink Protocol Library Suite (libnl))openssl是ssl协议的开源库(OpenSSL , Secure Sockets Layer (SSL v2/v3) Transport Layer Security (TLS v1)).(压缩包地址http://www.openssl.org/source/ Git地址https://github.com/openssl/openssl )libnl是网络相关的库(压缩包地址http://www.infradead.org/~tgr/libnl/ Git地址 http://git.infradead.org/users/tgr/libnl.git)。编译libnl解压源代码包。进入libnl目录执行 ./configure 配置编译环境执行make进行编译export ARCHarmexport CROSS_COMPILEarm-linux-gnueabi-./configure --prefix/usr \--sysconfdir/etc \--disable-static make然后执行sudo make installlibnl.so会被安装至/usr/local/lib/目录下相应的头文件也会被copy到/usr/local/include/netlink下。如果报出编译错误“../include/netlink_local.h:218:error ULONG_MAX undeclared我们在对应文件添加一个头文件 #include即可解决问题编译openssl进入openssl目录 ./config shared # 一定要加shared, 否则编译出来的是静态库。执行make进行编译完成后执行make install编译好的openssl库和头文件等被安装在目录/usr/local/ssl下export ARCHarmexport CROSS_COMPILEarm-linux-gnueabi-./config --prefix/usr \--openssldir/etc/ssl \--libdirlib \shared \zlib-dynamic makeIf you want to disable installing the static libraries, use this sed:sed -i s# libcrypto.a##;s# libssl.a## MakefileNow, as the root user:make MANDIR/usr/share/man MANSUFFIXssl install install -dv -m755 /usr/share/doc/openssl-1.0.2e cp -vfr doc/* /usr/share/doc/openssl-1.0.2e编译wpa_supplicant添加修改配置文件进入wpa_supplicant/wpa_supplicant目录执行cp defconfig .config 拷贝生成编译配置然后修改配置文件 .config#如果选择的不是libnl的1.0版本需要根据libnl的版本打开下面的选项CONFIG_LIBNL32yCONFIG_LIBNL20y 选择libnl的版本#添加openssl和libnl的头文件和库文件目录更新编译链接环境变量CFLAGS -I/usr/local/ssl/includeCFLAGS -I/usr/local/include/ libnl3CFLAGS -I/usr/local/include/netlinkLIBS -L/usr/local/ssl/libLIBS -L/usr/local/libLIBS_p -L/usr/local/ssl/lib # 不加此行编wpa_passphrase出错。cp defconfig .configmake CCarm-linux-gnueabi-gccmake install DESTDIR/home/export/rootfs执行make进行编译成功后生成三个目标文件wpa_supplicant, wpa_cli, wpa_passphrase至此编译完成。运行wpa_supplicant需要保证libssl库在我们的搜索路径里否则不做处理会出现找不到libnl, ssl 和crypto库的错误。./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 文件中添加库的搜索路径。(或者在/etc/ld.so.conf.d 下新建一个.conf文件将搜索路径一行一个加入).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_supplicantwpa_supplicant runs as a daemon and requires a configuration file. Create a file called /etc/wpa_supplicant.conf with the following contents:network{ssidMySSIDkey_mgmtWPA-PSKprotoRSNpairwiseCCMP TKIPpskMyPassPhrase}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编译错误处理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 directorycompilation terminated.make: *** [../src/drivers/driver_nl80211.o] Error 1#######################################################################Solution #1sudo apt-get -y install libssl-dev libnl-3-devecho CFLAGS -I/usr/include/libnl3/ .configmakeError#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 hereSolution #2sudo apt-get install libnl-genl-3-devecho CONFIG_LIBNL32y .configmakeUsageusage: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/cfg80211wext Linux wireless extensions (generic)wired Wired Ethernet driveroptions:-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 interfaceexample:wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.confwpa_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 fromwpa_supplicant-B run a daemon in the backgrounddefault path: /var/run/wpa_supplicantdefault interface: first interface found in socket pathcommands:status [verbose] get current WPA/EAPOL/EAP statusifname get current interface nameping pings wpa_supplicantrelog re-open log-file (allow rolling logs)note add a note to wpa_supplicant debug logmib get MIB variables (dot1x, dot11)help [command] show usage helpinterface [ifname] show interfaces/select interfacelevel change debug levellicense show full wpa_cli licensequit exit wpa_cliset set variables (shows list of variables when run without arguments)get get informationlogon IEEE 802.1X EAPOL state machine logonlogoff IEEE 802.1X EAPOL state machine logoffpmksa show PMKSA cachereassociate force reassociationpreauthenticate force preauthenticationidentity configure identity for an SSIDpassword configure password for an SSIDnew_password change password for an SSIDpin configure pin for an SSIDotp configure one-time-password for an SSIDpassphrase configure private key passphrasefor an SSIDsim report SIM operation resultbssid set preferred BSSID for an SSIDblacklist add a BSSID to the blacklistblacklist clear clear the blacklistblacklist display the blacklistlog_level [] update the log level/timestamplog_level display the current log level and log optionslist_networks list configured networksselect_network select a network (disable others)enable_network enable a networkdisable_network disable a networkadd_network add a networkremove_network remove a networkset_network set network variables (showslist of variables when run without arguments)get_network get network variableslist_creds list configured credentialsadd_cred add a credentialremove_cred remove a credentialset_cred set credential variablessave_config save the current configurationdisconnect disconnect and wait for reassociate/reconnect command beforeconnectingreconnect like reassociate, but only takes effect if already disconnectedscan request new BSS scanscan_results get latest scan resultsbss | get detailed scan result infoget_capability get capabiliesreconfigure force wpa_supplicant to re-read its configuration fileterminate terminate wpa_supplicantinterface_add adds new interface, all parameters but are optionalinterface_remove removes the interfaceinterface_list list available interfacesap_scan set ap_scan parameterscan_interval set scan_interval parameter (in seconds)bss_expire_age set BSS expiration age parameterbss_expire_count set BSS expiration scan count parameterbss_flush set BSS flush age (0 by default)stkstart request STK negotiation withft_ds request over-the-DS FT with wps_pbc [BSSID] start Wi-Fi Protected Setup: Push Button Configurationwps_pin [PIN] start WPS PIN method (returns PIN, if not hardcoded)wps_check_pin verify PIN checksumwps_cancel Cancels the pending WPS operationwps_reg start WPS Registrar to configure an APwps_ap_pin [params..] enable/disable AP PINwps_er_start [IP address] start Wi-Fi Protected Setup External Registrarwps_er_stop stop Wi-Fi Protected Setup External Registrarwps_er_pin add an Enrollee PIN to External Registrarwps_er_pbc accept an Enrollee PBC using External Registrarwps_er_learn learn AP configurationwps_er_set_config set AP configuration for enrollingwps_er_config configure APibss_rsn request RSN authentication with in IBSSsta get information about an associated station (AP)all_sta get information about all associated stations (AP)deauthenticate deauthenticate a stationdisassociate disassociate a stationchan_switch [sec_channel_offset] [center_freq1] [center_freq2] [bandwidth] [blocktx] [ht|vht] CSA parameterssuspend notification of suspend/hibernateresume notification of resume/thawdrop_sa drop SA without deauth/disassoc (test command)roam roam to the specified BSSp2p_find [timeout] [type*] find P2P Devices for up-to timeout secondsp2p_stop_find stop P2P Devices searchp2p_connect [ht40] connect to a P2P Devicep2p_listen [timeout] listen for P2P Devices for up-to timeout secondsp2p_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 discoveryp2p_get_passphrase get the passphrase for a group (GO only)p2p_serv_disc_req schedule service discovery requestp2p_serv_disc_cancel_req cancel pending service discovery requestp2p_serv_disc_resp service discovery responsep2p_service_update indicate change in local servicesp2p_serv_disc_external set external processing of service discoveryp2p_service_flush remove all stored service entriesp2p_service_add add a local servicep2p_service_del [|service] remove a local servicep2p_reject reject connection attempts from a specific peerp2p_invite [peeraddr] invite peerp2p_peers [discovered] list known (optionally, only fully discovered) P2P peersp2p_peer show information about known P2P peerp2p_set set a P2P parameterp2p_flush flush P2P statep2p_cancel cancel P2P group formationp2p_unauthorize unauthorize a peerp2p_presence_req [] [] request GO presencep2p_ext_listen [] set extended listen timingp2p_remove_client remove a peer from all groupssta_autoconnect 0/1 disable/enable automatic reconnectiontdls_discover request TDLS discovery withtdls_setup request TDLS setup withtdls_teardown tear down TDLS withsignal_poll get signal parameterspktcnt_poll get TX/RX packet countersreauthenticate trigger IEEE 802.1X/EAPOL reauthenticationraw Sent unprocessed commandflush flush wpa_supplicant stateradio_work radio_work ConfigurationSet wpa_supplicant.conf to the following:You have to change the values according to the response of# wpa_passphrase .For WPA-PSKctrl_interface/var/run/wpa_supplicantctrl_interface_group0eapol_version1# ap_scan2 was the one for me you may try 0 or 1 indstead of 2ap_scan2fast_reauth1network{ssidmy_networkprotoWPAkey_mgmtWPA-PSKpairwiseTKIPgroupTKIPpsksecret_password}For WPA2-Personalctrl_interface/var/run/wpa_supplicantctrl_interface_group0ap_scan1network{ssidmy_networkprotoRSNkey_mgmtWPA-PSKpairwiseCCMP TKIPgroupCCMP TKIPpsksecret_password}Bringing up the network card manuallyBring 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 (http://hostap.epitest.fi/bugz/show_bug.cgi?id63) and one for madwifi(http://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 (for Gentoo users)Make a symbolic link# cd /etc/init.d/# ln -s net.lo net.ath0Copy wpa_supplicant.conf to /etc/conf.d/wpa_supplicant.Edit /etc/conf.d/net##net#modules( wpa_supplicant )wpa_supplicant_ath0-Dmadwifimodules( wpa_supplicant )wpa_timeout_ath060config_ath0(netmask 255.255.255.0)routes_ath0(default gw )Add net.ath0 to the default runlevel by executing# rc-update add net.ath0 defaultMake sure all needed modules are in /etc/modules.autoload/2.xiw的编译和配置运行iw is a new nl80211 (802.11 netlink interface) based CLI configuration utility for wireless devices.Netlink Protocol Library SuiteDownload, cross compile and install the Netlink Protocol libraries:wget http://www.infradead.org/~tgr/libnl/files/libnl-3.2.24.tar.gztar -xzf libnl-3.2.24.tar.gzcd libnl-3.2.24./configure --hostarm-linux-gnueabi --prefix/usr/arm-linux-gnueabimakemake installcd includemake installiwWith the Netlink Protocol Library Suite prerequisite installed, download and build the iw nl80211 based CLI configuration utility:wget https://www.kernel.org/pub/software/network/iw/iw-3.15.tar.gztar -xzf iw-3.15.tar.gzcd iw-3.15/export PKG_CONFIG_PATH/usr/arm-linux-gnueabi/lib/pkgconfigexport CCarm-linux-gnueabi-gccmakeManually 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 -vhostapdhostapd is an 802.11 Access Point and IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator daemon.Download, extract and build hostapd:wget http://hostap.epitest.fi/releases/hostapd-2.2.tar.gztar -xzf hostapd-2.2.tar.gzcd hostapd-2.2/hostapdcp defconfig .configmake CCarm-linux-gnueabi-gccmake install DESTDIR/home/export/rootfsrfkill is a userspace tool to query the state of the rfkill switches.Download, extract and build rfkill:tar -xzf rfkill-0.5.tar.gzcd rfkill-0.5/make CCarm-linux-gnueabi-gcc