一切福田,不離方寸,從心而覓,感無不通。

linux下移植wifi之安装iw and iw操作(五)

第四节 安装iw and iw操作
一、 先查看README,获取了三个有用点:
1.    This is 'iw', a tool to use nl80211(iw需要nl80211)
2.  To build iw, just enter 'make'. If that fails, set the
PKG_CONFIG_PATH environment variable to allow the Makefile
to find libnl.(通过这个参数来指定libnl库的位置)
3.  'iw' is currently maintained at http://git.sipsolutions.net/iw.git/,(iw软件下载网站)
4.  some more documentation is available at
http://wireless.kernel.org/en/users/Documentation/iw. (iw 操作说明文档)

解压:tar -xf /mnt/hgfs/linux_share/0711/iw-4.9.tar.xz
nl80211已经安装了,通过PKG_CONFIG_PATH变量,我们已经指定了nl80211头文件和库的路径,可以通过命令进行查看。
命令:echo $PKG_CONFIG_PATH
得:/home/clh/work/libnl-3.2.25/tmp/lib/pkgconfig:
二、编译
在info.c的代码前面添加
#define htole16(X)  (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff)

修改Makefile ,加上libnl的头文件 和 lib库。

CFLAGS += -I/home/clh/work/libnl-3.2.25/tmp/include/libnl3
LDFLAGS += -L/home/clh/work/libnl-3.2.25/tmp/lib

make CC=arm-linux-gcc
make DESTDIR=$PWD/tmp install
三、将iw工具复制到根文件系统
cp tmp/usr/sbin/* /opt/rootfs/bin/     /*iw*/

四、iw 工具的操作
iw help                     //help 帮助信息
iw list                     //Getting device capabilities 列出WIFI网卡的性能
ifconfig wlan0 up
iw dev wlan0 scan             //Scanning     扫描WIFI AP
iw wlan0 connect hello      //Establishing a basic connection  连接到WIFI AP:hello (open)
iw wlan0 connect hello keys d:0:happygrilclh0 // 连接到WIFI AP:hello (WEP) "happygrilclh0" 是密码
d: default, 0: 第0个密码
ifconfig wlan0 192.168.2.200
ping 192.168.2.1            //ping 连接的AP的网关
iw wlan0 disconnect         //断开链接
注意点:
操作过程中,会出现这个警告,不用理会。
cfg80211: Calling CRDA to update world regulatory domain

下一节讲wpa加密的网络管理方法
————————————————
版权声明:本文为CSDN博主「happygrilclh」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/happygrilclh/article/details/81045583