wireless tools移植
版本
下载地址
交叉编译配置
编译
移植
##
## Please check the configurion parameters below
##
## Installation directory. By default, go in /usr/local.
## Distributions should probably use /, but they probably know better...
ifndef PREFIX
#PREFIX = /usr/local
# Singcol Deng add
PREFIX = ./out
endif
CC = arm-hisiv100nptl-linux-gcc
AR = arm-hisiv100nptl-linux-ar
RANLIB = arm-hisiv100nptl-linux-ranlib
BUILD_STATIC = y
## Compiler to use (modify this for cross compile).
#CC = gcc
## Other tools you need to modify for cross compile (static lib only).
#AR = ar
#RANLIB = ranlib
## Uncomment this to build tools using static version of the library.
## Mostly useful for embedded platforms without ldd, or to create
## a local version (non-root).
# BUILD_STATIC = y
## Uncomment this to build without using libm (less efficient).
## This is mostly useful for embedded platforms without maths.
# BUILD_NOLIBM = y
## Uncomment this to strip binary from symbols. This reduce binary size.
## by a few percent but make debug worse...
# BUILD_STRIPPING = y
## Uncomment this to build with only essential functionality.
## This leaves out the less used features and cut in half the tools.
## This is mostly useful for embedded platforms without limited feature needs.
# BUILD_WE_ESSENTIAL = y
# ***************************************************************************
# ***** Most users should not need to change anything beyond this point *****
# ***************************************************************************
# Version of the Wireless Tools
WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
# Version of Wireless Extensions.
WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
# Always use local header for wireless extensions
WEXT_HEADER = wireless.$(WE_VERSION).h
# Targets to build
STATIC=libiw.a
DYNAMIC=libiw.so.$(WT_VERSION)
PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
MANPAGES7=wireless.7
MANPAGES5=iftab.5
EXTRAPROGS= macaddr iwmulticall
# Composition of the library :
OBJS = iwlib.o
# Select which library to build and to link tool with
ifdef BUILD_STATIC
IWLIB=$(STATIC)
IWLIB_INSTALL=install-static
else
IWLIB=$(DYNAMIC)
IWLIB_INSTALL=install-dynamic
endif
# Standard name for dynamic library so that the dynamic linker can pick it.
# We will just create a symbolic link to the real thing.
DYNAMIC_LINK= libiw.so
# Install directories
INSTALL_DIR= $(PREFIX)/sbin/
INSTALL_LIB= $(PREFIX)/lib/
INSTALL_INC= $(PREFIX)/include/
INSTALL_MAN= $(PREFIX)/man/
# Various commands
RM = rm -f
RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
LDCONFIG = ldconfig
# Do we want to build with or without libm ?
ifdef BUILD_NOLIBM
LIBS=
WELIB_FLAG= -DWE_NOLIBM=y
else
LIBS= -lm
endif
# Stripping or not ?
ifdef BUILD_STRIPPING
STRIPFLAGS= -Wl,-s
else
STRIPFLAGS=
endif
# Do we want to build with only essential functionality ?
ifdef BUILD_WE_ESSENTIAL
WEDEF_FLAG= -DWE_ESSENTIAL=y
endif
# Other flags
CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
-Wpointer-arith -Wcast-qual -Winline -I.
#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
DEPFLAGS=-MMD
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
PICFLAG=-fPIC
# Standard compilation targets
all:: $(IWLIB) $(PROGS)
%: %.o
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
%.o: %.c wireless.h
$(CC) $(XCFLAGS) -c $<
%.so: %.c wireless.h
$(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
iwconfig: iwconfig.o $(IWLIB)
iwlist: iwlist.o $(IWLIB)
iwpriv: iwpriv.o $(IWLIB)
iwspy: iwspy.o $(IWLIB)
iwgetid: iwgetid.o $(IWLIB)
iwevent: iwevent.o $(IWLIB)
ifrename: ifrename.o $(IWLIB)
macaddr: macaddr.o $(IWLIB)
# Always do symbol stripping here
iwmulticall: iwmulticall.o
$(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
# It's a kind of magic...
wireless.h:
cp $(WEXT_HEADER) wireless.h
# Compilation of the dynamic library
$(DYNAMIC): $(OBJS:.o=.so)
$(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
# Compilation of the static library
$(STATIC): $(OBJS:.o=.so)
$(RM) $@
$(AR) cru $@ $^
$(RANLIB) $@
# Installation : So crude but so effective ;-)
# Less crude thanks to many contributions ;-)
install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
# Install the dynamic library
install-dynamic:: $(DYNAMIC)
install -m 755 -d $(INSTALL_LIB)
install -m 755 $(DYNAMIC) $(INSTALL_LIB)
ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
@echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
@$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
# Install the static library
install-static:: $(STATIC)
install -m 755 -d $(INSTALL_LIB)
install -m 644 $(STATIC) $(INSTALL_LIB)
# All the binaries. Careful, no dependancy on install-dynamic
install-bin:: all
install -m 755 -d $(INSTALL_DIR)
install -m 755 $(PROGS) $(INSTALL_DIR)
# Headers to go with the wireless lib (dev)
install-hdr:: wireless.h
install -m 755 -d $(INSTALL_INC)
install -m 644 iwlib.h $(INSTALL_INC)
install -m 644 wireless.h $(INSTALL_INC)
# How could you live without those manapages ?
install-man::
install -m 755 -d $(INSTALL_MAN)/man8/
install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
install -m 755 -d $(INSTALL_MAN)/man7/
install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
install -m 755 -d $(INSTALL_MAN)/man5/
install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
install-iwmulticall:: iwmulticall
install -m 755 -d $(INSTALL_DIR)
install -m 755 $< $(INSTALL_DIR)/iwconfig
( cd $(INSTALL_DIR) ; \
ln -f -s iwconfig iwlist ; \
ln -f -s iwconfig iwspy ; \
ln -f -s iwconfig iwpriv ; \
ln -f -s iwconfig iwgetid )
clean::
$(RM_CMD)
realclean::
$(RM_CMD)
$(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
uninstall::
for f in $(PROGS); do \
$(RM) $(INSTALL_DIR)/$$f; \
done
$(RM) $(INSTALL_LIB)/$(STATIC)
$(RM) $(INSTALL_LIB)/$(DYNAMIC)
$(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
$(RM) $(INSTALL_INC)/iwlib.h
$(RM) $(INSTALL_INC)/wireless.h
for f in $(MANPAGES8); do \
$(RM) $(INSTALL_MAN)/man8/$$f; \
done
for f in $(MANPAGES7); do \
$(RM) $(INSTALL_MAN)/man7/$$f; \
done
for f in $(MANPAGES5); do \
$(RM) $(INSTALL_MAN)/man5/$$f; \
done
# Include dependancies
-include *.d
wpa_supplicant, wpa_cli移植
下载地址
连接开放WIFI
# iwconfig
# iwlist ra0 scan
# iwconfig ra0 essid "CM810"
# udhcpc -i ra0
查看当前设备的无线网络名字及相关信息
扫描无线网络
设置连接无需验证的无线网络
启动自动获取IP地址
连接加密的WIFI
配置文件:
# cat /home/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
network={
ssid="WiFi-61"
scan_ssid=1
proto=WPA RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="123456789"
}
命令:
# wpa_supplicant -i ra0 -c /home/wpa_supplicant.conf
# udhcpc -i ra0
wpa_supplicant, wpa_cli用法
wpa_supplicant 与wpa_cli 之间就是服务端与客户端之间的关系(cs模式)
先启动后台服务端
# wpa_supplicant -i ra0 -c /home/wpa_supplicant.conf &
# ===>rt_ioctl_giwscan. 17(17) BSS returned, data->length = 2665
Trying to associate with==>rt_ioctl_siwfreq::SIOCSIWFREQ(Channel=11)
2e:d2:1e:7b:34:f9 (SSID='WiFi-61' freq=2462 MHz)
PeerBeaconAtJoinAction(): HT-CtrlChannel=11, CentralChannel=>11
PeerBeaconAtJoinAction(): Set CentralChannel=11
Associated with 2e:d2:1e:7b:34:f9
WPA: Key negotiation completed with 2e:d2:1e:7b:34:f9 [PTK=CCMP GTK=CCMP]
CTRL-EVENT-CONNECTED - Connection to 2e:d2:1e:7b:34:f9 completed (auth) [id=0 id_str=]
运行客户端
# wpa_cli -i ra0 -p /var/run/wpa_supplicant
# wpa_cli v0.7.3
Copyright (c) 2004-2010, Jouni Malinen <j@w1.fi> and contributors
This program is free software. You can distribute it and/or modify it
under the terms of the GNU General Public License version 2.
Alternatively, this software may be distributed under the terms of the
BSD license. See README and COPYING for more details.
Interactive mode
>
备注:/var/run/wpa_supplicant 为启动wpa_supplicant后产生的套接字文件
# ls /var/run/wpa_supplicant -l
srwxrwx--- 1 root root 0 Jan 1 00:06 ra0
输入help,可以查看帮助信息
> help
commands:status [verbose] = get current WPA/EAPOL/EAP status
ping = pings wpa_supplicant
mib = get MIB variables (dot1x, dot11)
help = show this usage help
interface [ifname] = show interfaces/select interface
level <debug 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)
logon = IEEE 802.1X EAPOL state machine logon
logoff = IEEE 802.1X EAPOL state machine logoff
pmksa = show PMKSA cache
reassociate = force reassociation
preauthenticate <BSSID> = force preauthentication
identity <network id> <identity> = configure identity for an SSID
password <network id> <password> = configure password for an SSID
new_password <network id> <password> = change password for an SSID
pin <network id> <pin> = configure pin for an SSID
otp <network id> <password> = configure one-time-password for an SSID
passphrase <network id> <passphrase> = configure private key passphrase
for an SSID
bssid <network id> <BSSID> = set preferred BSSID for an SSID
list_networks = list configured networks
select_network <network id> = select a network (disable others)
enable_network <network id> = enable a network
disable_network <network id> = disable a network
add_network = add a network
remove_network <network id> = remove a network
set_network <network id> <variable> <value> = set network variables (shows
list of variables when run without arguments)
get_network <network id> <variable> = get network 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 <<idx> | <bssid>> = get detailed scan result info
get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = get capabilies
reconfigure = force wpa_supplicant to re-read its configuration file
terminate = terminate wpa_supplicant
interface_add <ifname> <confname> <driver> <ctrl_interface> <driver_param>
<bridge_name> = adds new interface, all parameters but <ifname>
are optional
interface_remove <ifname> = removes the interface
interface_list = list available interfaces
ap_scan <value> = set ap_scan parameter
stkstart <addr> = request STK negotiation with <addr>
ft_ds <addr> = request over-the-DS FT with <addr>
wps_pbc [BSSID] = start Wi-Fi Protected Setup: Push Button Configuration
wps_pin <BSSID> [PIN] = start WPS PIN method (returns PIN, if not hardcoded)
wps_reg <BSSID> <AP PIN> = start WPS Registrar to configure an AP
wps_er_start = start Wi-Fi Protected Setup External Registrar
wps_er_stop = stop Wi-Fi Protected Setup External Registrar
wps_er_pin <UUID> <PIN> = add an Enrollee PIN to External Registrar
wps_er_pbc <UUID> = accept an Enrollee PBC using External Registrar
wps_er_learn <UUID> <PIN> = learn AP configuration
ibss_rsn <addr> = request RSN authentication with <addr> in IBSS
suspend = notification of suspend/hibernate
resume = notification of resume/thaw
drop_sa = drop SA without deauth/disassoc (test command)
roam <addr> = roam to the specified BSS
>
扫描
> scan
OK> RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RtmpUSBNullFrameKickOut - Send NULL Frame Fail Due to In Null Context using...
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RTUSBKickBulkOut - Fail in BSS_SCAN_IN_PROGRESS
RtmpUSBNullFrameKickOut - Send NULL Frame Fail Due to In Null Context using...
===>rt_ioctl_giwscan. 22(22) BSS returned, data->length = 3350
<2>CTRL-EVENT-BSS-ADDED 17 34:23:87:db:db:c5
<2>CTRL-EVENT-BSS-ADDED 18 d4:ee:07:2d:78:d0
<2>CTRL-EVENT-BSS-ADDED 19 26:2d:27:2d:52:0d
<2>CTRL-EVENT-BSS-ADDED 20 22:48:9a:ab:68:6f
<2>CTRL-EVENT-BSS-ADDED 21 34:23:87:db:a1:27
<2>CTRL-EVENT-BSS-ADDED 22 64:09:80:5e:e6:86
<2>CTRL-EVENT-BSS-ADDED 23 c0:61:18:00:bd:68
<2>CTRL-EVENT-BSS-ADDED 24 14:75:90:2c:08:ca
<2>CTRL-EVENT-BSS-ADDED 25 2e:d2:1e:92:da:f5
<2>CTRL-EVENT-BSS-ADDED 26 c0:61:18:65:53:9c
<2>CTRL-EVENT-BSS-ADDED 27 d4:ee:07:30:9c:aa
<2>CTRL-EVENT-BSS-ADDED 28 2e:84:dc:80:e8:e9
<2>CTRL-EVENT-BSS-ADDED 29 2e:d2:1e:7b:35:77
<2>CTRL-EVENT-BSS-ADDED 30 26:2d:27:2d:ae:49
<2>CTRL-EVENT-BSS-ADDED 31 26:2d:27:2d:4f:e1
<2>CTRL-EVENT-BSS-ADDED 32 26:2d:27:2d:4f:bf
<2>CTRL-EVENT-BSS-ADDED 33 26:2d:27:2d:51:ff
<2>CTRL-EVENT-BSS-ADDED 34 c8:3a:35:20:c0:f0
<2>CTRL-EVENT-BSS-ADDED 35 2e:d2:1e:41:92:ab
<2>CTRL-EVENT-BSS-ADDED 36 52:48:9a:c6:4b:af
<2>CTRL-EVENT-BSS-ADDED 37 26:2d:27:2d:52:0f
<2>CTRL-EVENT-SCAN-RESULTS
>
查询扫描结果
> scan_result
bssid / frequency / signal level / flags / ssid2e:d2:1e:7b:34:f9 2462 199 [WPA2-PSK-CCMP][ESS] WiFi-61
26:2d:27:2d:51:9d 2462 201 [WPA2-PSK-CCMP][ESS] WIFIfree
d4:ee:07:2d:78:d0 2412 183 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] CLOUD_TEST
64:09:80:5e:e6:86 2427 183 [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] Xiaomi_E685
22:48:9a:ab:68:6f 2462 185 [WPA2-PSK-CCMP][ESS] LXTWiFi-64
26:2d:27:2d:52:0d 2462 185 [WPA2-PSK-CCMP][ESS] test_yy
34:23:87:db:db:c5 2462 187 [WPA2-PSK-CCMP][ESS] WIFI-221
c0:61:18:00:bd:68 2462 177 [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] TP-LINK_BD68_xx
2e:d2:1e:92:da:f5 2437 181 [WPA2-PSK-CCMP][ESS] Avj-PC
34:23:87:db:a1:27 2462 183 [WPA2-PSK-CCMP][ESS] 360______WiFi-B2
c0:61:18:65:53:9c 2437 177 [WPA2-PSK-TKIP+CCMP][ESS] HS_RD_SZ
c8:3a:35:01:bf:d0 2462 175 [WPA-PSK-CCMP][ESS] mike_wifi
14:75:90:2c:08:ca 2437 173 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] CMS_OCX
26:2d:27:2d:ae:49 2422 177 [WPA2-PSK-CCMP][ESS] 360______WiFi-HS
c8:3a:35:20:c0:f0 2422 177 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] Tenda_CentOS
d4:ee:07:30:9c:aa 2422 171 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS] HiWiFi_Stupid
2e:84:dc:80:e8:e9 2437 173 [WPA2-PSK-CCMP][ESS] TPLink-hw
26:2d:27:2d:4f:bf 2462 171 [WPA2-PSK-CCMP][ESS] kobe_lufei
2e:d2:1e:41:92:ab 2462 171 [WPA2-PSK-CCMP][ESS] HS_BD_SZ
52:48:9a:c6:4b:af 2462 171 [WPA2-PSK-CCMP][ESS] LieBaoWiFi746
22:48:9a:c6:60:21 2462 171 [WPA2-PSK-CCMP][ESS] 360WiFi-hgh
26:2d:27:2d:4f:95 2412 171 [WPA2-PSK-CCMP][ESS] 360wifi-199
26:2d:27:2d:51:ff 2462 171 [WPA2-PSK-CCMP][ESS] Ivan-PC
2a:5a:b6:31:19:df 2462 169 [WPA2-PSK-CCMP][ESS] 123
2a:5a:b6:5f:bb:5b 2462 167 [WPA2-PSK-CCMP][ESS] 5233
>
添加网络
> add_network
1>
设置ssid
> set_network 1 ssid "WFIFfree"
OK设置wifi密码
> set_network 1 psk "wifimeimima"
OK选择网络序号
> select_network 1
OK> CTRL-EVENT-DISCONNECTED bssid=00:00:00:00:00:00 reason=0
===>rt_ioctl_giwscan. 29(29) BSS returned, data->length = 4277
Trying to associate with==>rt_ioctl_siwfreq::SIOCSIWFREQ(Channel=11)
26:2d:27:2d:51:9d (SSID='WIFIfree' freq=2462 MHz)
PeerBeaconAtJoinAction(): HT-CtrlChannel=11, CentralChannel=>11
PeerBeaconAtJoinAction(): Set CentralChannel=11
Associated with 26:2d:27:2d:51:9d
WPA: Key negotiation completed with 26:2d:27:2d:51:9d [PTK=CCMP GTK=CCMP]
CTRL-EVENT-CONNECTED - Connection to 26:2d:27:2d:51:9d completed (reauth) [id=1 id_str=]
<2>CTRL-EVENT-DISCONNECTED bssid=00:00:00:00:00:00 reason=0
<2>CTRL-EVENT-BSS-ADDED 29 26:2d:27:2d:51:a3
<2>CTRL-EVENT-SCAN-RESULTS
<2>WPS-AP-AVAILABLE
<2>Trying to associate with 26:2d:27:2d:51:9d (SSID='WIFIfree' freq=2462 MHz)
<2>Associated with 26:2d:27:2d:51:9d
<2>WPA: Key negotiation completed with 26:2d:27:2d:51:9d [PTK=CCMP GTK=CCMP]
<2>CTRL-EVENT-CONNECTED - Connection to 26:2d:27:2d:51:9d completed (reauth) [id=1 id_str=]
>
网络使能
>enable_network 1
>ok
退出
> q
启动自动获取IP地址
# udhcpc -i ra0
udhcpc (v1.16.1) startedSetting IP address 0.0.0.0 on ra0
Sending discover...
Sending select for 192.168.253.7...
Lease of 192.168.253.7 obtained, lease time 36000
Setting IP address 192.168.253.7 on ra0
need update route and dns with ra0
Deleting routers
Adding router 192.168.253.1
Recreating /etc/resolv.conf
Adding DNS server 192.168.253.1
Adding DNS server 172.18.192.2
Set DNS config
DHCP over,send msg to netmgmt