Linux:交叉编译WiFi工具iwconfig(wireless tools)、iw、wpa_supplicant、DHCP、hostapd(文末附使用方法)

wireless tools

下载:
  http://www.linuxfromscratch.org/blfs/view/svn/basicnet/wireless_tools.html
编译:

tar xzvf wireless_tools.29.tar.gz
cd wireless_tools.29/
vi Makefile
	CC = arm-linux-gnueabihf-gcc
	AR = arm-linux-gnueabihf-ar
	RANLIB = arm-linux-gnueabihf-ranlib
make

拷贝:
  iwlist iwconfig iwspy iwpriv ifrename iwevent iwgetid -> 目标板:/usr/bin/
  libiw.so.29 -> 目标板:/usr/lib/


iw

iw工具是iwconfig的替代者,而在编译iw前需要先编译所依赖的libnl库。
① libnl
下载:
  http://www.infradead.org/~tgr/libnl/files/
编译:

tar xzvf libnl-3.2.25.tar.gz
cd libnl-3.2.25/
mkdir tmp
./configure --host=arm-linux-gnueabihf --prefix=$PWD/tmp/
make
make install

拷贝:
  tmp/lib/* -> 目标板:/usr/lib/

② iw
下载:
  https://mirrors.edge.kernel.org/pub/software/network/iw/
编译:

tar xzvf iw-3.11.tar.gz
cd iw-3.11/
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/linriming/test/wifi_tools/libnl-3.2.25/tmp/lib/pkgconfig
make CC=arm-linux-gnueabihf-gcc

拷贝:
  iw -> 目标板:/usr/bin/


wpa_supplicant

  前面wireless tools和iw工具都只能连接OPEN和WEP加密方式的WiFi,而wpa_supplicant除了以上两种加密方式,还支持WPA/WPA2加密方式的WiFi。
  wpa_supplicant依赖于libopenssl库和libnl库,需要先编译。
① libopenssl
下载:
  https://www.openssl.org/source/
编译:

tar xzvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g/
mkdir tmp
./config shared no-asm --prefix=$PWD/tmp/
vi Makefile
	CROSS_COMPILE=arm-linux-gnueabihf-
	CNF_CFLAGS=-pthread 
	CNF_CXXFLAGS=-std=c++11 -lpthread 
make
make install

拷贝:
  tmp/lib/* -> 目标板:/usr/lib/

② libnl
  参考iw工具的libnl编译。

③ wpa_supplicant
下载:
  https://w1.fi/releases/
编译:

tar xzvf wpa_supplicant-2.7.tar.gz
cd wpa_supplicant-2.7/wpa_supplicant/
cp defconfig .config
vi .config
	# openssl
	CFLAGS += -I/home/linriming/test/wifi_tools/openssl-1.1.1g/tmp/include
	LIBS += -L/home/linriming/test/wifi_tools/openssl-1.1.1g/tmp/lib -lssl -lcrypto

	# libnl
	CFLAGS += -I/home/linriming/test/wifi_tools/libnl-3.2.25/tmp/include/libnl3
	LIBS += -L/home/linriming/test/wifi_tools/libnl-3.2.25/tmp/lib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/linriming/test/wifi_tools/libnl-3.2.25/tmp/lib/pkgconfig
make CC=arm-linux-gnueabihf-gcc

拷贝:
  wpa_cli wpa_supplicant wpa_passphrase -> 目标板:/usr/bin/


DHCP

下载:
  ftp://ftp.isc.org/isc/dhcp/
编译:

tar xzvf dhcp-4.2.6.tar.gz
cd dhcp-4.2.6/
./configure --host=arm-linux-gnueabihf ac_cv_file__dev_random=yes
tar xzvf bind/bind.tar.gz -C bind/
vi bind/bind-9.9.5/lib/export/dns/Makefile.in
	gen: ${srcdir}/gen.c
		 ${BUILD_CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ ${srcdir}/gen.c ${LIBS}
vi bind/Makefile
	(cd ${bindsrcdir} && ./configure BUILD_CC=gcc c_cv_file__dev_random=yes --host=arm-linux-gnueabihf --with-randomdev=no --disable-kqueue.......
mkdir tmp
make
make DESTDIR=$PWD/tmp install

拷贝:
  tmp/usr/local/sbin/dhclient、dhcpd -> 目标板:/sbin/
  tmp/usr/local/etc/dhclient.conf.example、dhcpd.conf.example -> 目标板并改名:/etc/dhclient.conf、dhcpd.conf
  client/scripts/linux -> 目标板:/sbin/dhclient-script
  chmod +x dhclient-script
  vi dhclient-script
    #!/bin/bash -> #!/bin/sh


hostapd

① libopenssl
  参考wpa_supplicant工具的libopenssl编译。

② libnl
  参考iw工具的libnl编译。

② hostapd
下载:
  https://w1.fi/releases/
编译:

tar xzvf hostapd-2.9.tar.gz
cd hostapd-2.9/hostapd/
cp defconfig .config
vi .config
	# openssl
	CFLAGS += -I/home/linriming/test/wifi_tools/openssl-1.1.1g/tmp/include
	LIBS += -L/home/linriming/test/wifi_tools/openssl-1.1.1g/tmp/lib -lssl -lcrypto

	# libnl
	CFLAGS += -I/home/linriming/test/wifi_tools/libnl-3.2.25/tmp/include/libnl3
	LIBS += -L/home/linriming/test/wifi_tools/libnl-3.2.25/tmp/lib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/linriming/test/wifi_tools/libnl-3.2.25/tmp/lib/pkgconfig
make CC=arm-linux-gnueabihf-gcc

拷贝:
  hostapd hostapd_cli -> 目标板:/usr/bin/


使用方法

https://blog.csdn.net/weixin_44498318/article/details/107428543

你可能感兴趣的:(Linux基础)