一、WPA_SUPPLICANT简介

1. 什么是wpa_supplicant

wpa_supplicant is a WPA Supplicant for Linux, BSD, Mac OS X, and Windows with support for WPA and WPA2 (IEEE 802.11i / RSN). It is suitable for both desktop/laptop computers and embedded systems. Supplicant is the IEEE 802.1X/WPA component that is used in the client stations. It implements key negotiation with a WPA Authenticator and it controls the roaming and IEEE 802.11 authentication/association of the wlan driver.

wpa_supplicant is designed to be a "daemon" program that runs in the background and acts as the backend component controlling the wireless connection. wpa_supplicant supports separate frontend programs and a text-based frontend (wpa_cli) and a GUI (wpa_gui) are included with wpa_supplicant.

wpa_supplicant uses a flexible build configuration that can be used to select which features are included. This allows minimal code size (from ca. 50 kB binary for WPA/WPA2-Personal and 130 kB binary for WPA/WPA2-Enterprise without debugging code to 450 kB with most features and full debugging support; these example sizes are from a build for x86 target).

2. 支持的WPA/IEEE 802.11i feature

WPA-PSK ("WPA-Personal")WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")key management for CCMP, TKIP, WEP104, WEP40WPA and full IEEE 802.11i/RSN/WPA2RSN: PMKSA caching, pre-authenticationIEEE 802.11rIEEE 802.11wWi-Fi Protected Setup (WPS)

3. 支持的无线无线网卡和驱动

Linux drivers that support nl80211/cfg80211 (most new drivers)Linux drivers that support Linux Wireless Extensions v19 or newer with WPA/WPA2 extensionsWired Ethernet driversBSD net80211 layer (e.g., Atheros driver) (FreeBSD 6-CURRENT and NetBSD current)Windows NDIS drivers (Windows; at least XP and 2000, others not tested)

4. WPA如何和AP建立联系

wpa_supplicant requests the kernel driver to scan neighboring BSSeswpa_supplicant selects a BSS based on its configurationwpa_supplicant requests the kernel driver to associate with the chosen  BSSif WPA-EAP: integrated IEEE 802.1X Supplicant completes EAP  authentication with the authentication server (proxied by the  Authenticator in the AP)If WPA-EAP: master key is received from the IEEE 802.1X SupplicantIf WPA-PSK: wpa_supplicant uses PSK as the master session keywpa_supplicant completes WPA 4-Way Handshake and Group Key Handshake  with the Authenticator (AP). WPA2 has integrated the initial Group Key  Handshake into the 4-Way Handshake.wpa_supplicant configures encryption keys for unicast and broadcastnormal data packets can be transmitted and received

二、移植wpa_supplicant和wifi驱动的步骤

1.  将厂商提供的HAL代码复制到hardware目录下,并修改Makefile

例如:realteck、broadcom、ti、qcomm等。

2.  修改ANDROID_SDK /device/<soc_vendor_name>/<board_name>/目录下的BoardConfig.mk

例如:

BOARD_WIFI_VENDOR := realtek
ifeq ($(BOARD_WIFI_VENDOR), realtek)
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
CONFIG_DRIVER_WEXT :=y
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_WLAN_DEVICE := rtl8192cu
#BOARD_WLAN_DEVICE := rtl8192du
#BOARD_WLAN_DEVICE := rtl8192ce
#BOARD_WLAN_DEVICE := rtl8192de
#BOARD_WLAN_DEVICE := rtl8723as
#BOARD_WLAN_DEVICE := rtl8723au
#BOARD_WLAN_DEVICE := rtl8189es
#BOARD_WLAN_DEVICE := rtl8723bs
#BOARD_WLAN_DEVICE := rtl8723bu
WIFI_DRIVER_MODULE_NAME := "wlan"
WIFI_DRIVER_MODULE_PATH  := "/system/lib/modules/wlan.ko"
WIFI_DRIVER_MODULE_ARG := "ifname=wlan0 if2name=p2p0"
endif

3. 修改ANDROID_SDK/device/<soc_vendor_name>/<board_name>/目录下的init.xxx.rc

例如:

service rtw_suppl_con /system/bin/wpa_supplicant \
-ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
-e/data/misc/wifi/entropy.bin -N \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-O/data/misc/wifi/sockets \
-g@android:wpa_wlan0
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot

service rtw_suppl /system/bin/wpa_supplicant \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-O/data/misc/wifi/sockets \
-e/data/misc/wifi/entropy.bin
-g@android:wpa_wlan0
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled

service dhcpcd_wlan0 /system/bin/dhcpcd -aABDKL
class main
disabled
oneshot

service dhcpcd_p2p /system/bin/dhcpcd -aABKL
class main
disabled
oneshot

service iprenew_wlan0 /system/bin/dhcpcd -n
class main
disabled
oneshot

service iprenew_p2p /system/bin/dhcpcd -n
class main
disabled
oneshot

4. 修改ANDROID_SDK/device/<soc_vendor_name>/<board_name>/目录下的device.mk

例如:

PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.
wifi.xml
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hard
ware.wifi.direct.xml
PRODUCT_PROPERTY_OVERRIDES += \
wifi.interface=wlan0

5. 修改ANDROID_SDK/frameworks/base/core/res/res/values/config.xml,配置wifi网络属性

array translatable="false" name="networkAttributes"> "wifi,1,1,1,-1,true" "bluetooth,7,7,0,-1,true" "ethernet,9,9,2,-1,true"</STRING-array>

array translatable="false" name="radioAttributes"> "1,1" "7,1" "9,1" </STRING-array>

array translatable="false" name="config_tether_wifi_regexs"> "wlan0" </STRING-array>

array translatable="false" name="config_tether_upstream_types"> 1 9 </INTEGER-array>

6. 将厂商提供的WPA_SUPPLICANT替换到ANDROID_SDK/external/wpa_suppliant_8目录下

7. 编译wifi驱动,将驱动配置成模块加载的方式,将生成的ko文件存放到BoardConfig.mk里面设置的ko文件路径下,并确认驱动模块名称一致

三、常用调试命令和技巧

1. 调试命令

     通过wpa_cli命令可以检测wpa_supplicant的运行状态

  • PING:心跳检测命令。客户端用它判断WPAS是否工作正常。WPAS收到”PING”命令后需要回复“PONG”。
  • MIB:客户端用该命令获取设备的MIB信息。
  • STATUS:客户端用该命令来获取WPAS的工作状态。
  • ADD_NETWORK:为WPAS添加一个新的无线网络。它将返回此新无线网络的id(从0开始)。注意:此network id非常重要,客户端后续将通过它来指明自己想操作的无线网络。
  • SET_NETWORK <network id> <variable> <value>:network id是无线网络的id。此命令用于设置指定无线网络的信息。其中variable为参数名,value为参数的值。
  • ENABLE_NETWORK <network id>:使能某个无线网络。此命令最终将促使WPAS发起一系列操作以加入该无线网络。

2. 调试技巧

    可以在wpa_supplicant里面增加一些log来跟踪指令的下发流程。

    通过在命令行终端输入getprop init.svc.wpa_servername 来检查wpa_supplicant进程是否在运行。

    wpa_supplicant起来后,可以通过查看wpa_cli ping或者wpa_cli status来检测wpa_suppliant通道是否正常。

    检查/system/etc/wifi/wpa_supplicant.conf和/data/misc/wifi/wpa_supplicant.conf中ctrl_interface是否正确。

    检查/dev/socket/wpa_wlan0、/data/misc/wifi/sockets/wlan0、/data/misc/wifi/sockets/p2p、wpa_ctrl_*等节点是否成功创建。

    通过lsmod检查驱动模块是否成功加载。

    通过查看/sys/class/rfkill/目录下是否生成rfkill*节点判断驱动加载过程是否OK。

Android系统如何移植wpa_supplicant及wifi驱动的更多相关文章

  1. Android wifi驱动的移植 realtek 8188

    Android wifi驱动的移植 一般我们拿到的android源代码中wifi应用层部分是好的, 主要是wifi芯片的驱动要移植并添加进去. wifi驱动的移植, 以realtek的8188etv为 ...

  2. WIFI驱动的移植 realtek 8188

    一般我们拿到的android源代码中wifi应用层部分是好的, 主要是wifi芯片的驱动要移植并添加进去. wifi驱动的移植, 以realtek的8188etv为例到官网下载相应的驱动, 解压后可以 ...

  3. android wifi驱动移植详细过程

    转自:http://bbs.imp3.net/thread-10558924-1-1.html 对于刚入手android没多久的人来说,android wifi 驱动的移植确实还是有难度的,不过参考了 ...

  4. 第一章 Android系统移植与驱动开发概述

    本书第一章首先简单概要地介绍了关于Android系统移植和驱动开发的相关内容. 所谓“移植”是指为特定的自己的设备,如手机定制Android的过程.自己开发一些程序(移植)装载在设备上,使得Andro ...

  5. 浅谈Android系统移植、Linux设备驱动

    一.Android系统架构 第一层:Linux内核 包括驱动程序,管理内存.进程.电源等资源的程序 第二层:C/C++代码库 包括Linux的.so文件以及嵌入到APK程序中的NDK代码 第三层:An ...

  6. Android系统移植与驱动开发----第一章

    第一章 Android系统移植与驱动开发 Android源代码定制完全属于自己的嵌入式系统,但是支持的设备不多,所以要移植,而在移植的过程中使用的不得不提的是驱动开发. Android系统构架主要包括 ...

  7. 第一章Android系统移植与驱动开发概述--读书笔记

    以前,初步学习过嵌入式Linux驱动开发的基础课程,对于驱动开发可以说是有了一点点微末的基础吧.首先我们要对Android嵌入式系统有一个初步的认识,Android系统发展到今天已经具备了完善的架构. ...

  8. Android系统移植与驱动开发

    21世纪,Android发展非常迅速,在市场上占有很大的比例,遥遥领先与iOS,很大程度上是因为任何人都可以利用Android的源代码定制完全属于自己的嵌入式开发系统,而不需要向Google交一分钱. ...

  9. Android平台开发-WIFI 驱动移植 -- 详细

    一.WIFI的基本架构(代码路径)     1.WIFI Settings应用程序:       packages/apps/Settings/src/com/android/settings/wif ...

随机推荐

  1. C#数字千分位

    C#中把数字转换成带两位小数的千分位字符 如1234567.891变成1,234,567.89 方法:String.Format("{0:N}",1234567.891);   / ...

  2. 【RAC】 RAC For W2K8R2 安装--创建ASM磁盘组(六)

    [RAC] RAC For W2K8R2 安装--创建ASM磁盘组(六) 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以 ...

  3. jemter csv参数化时注意问题

    csv设置 请求参数中引用参数注意点: 查看结果树-请求-http:查看结果,乱码问题解决 1.需要设置下请求体编码 csv设置线程共享模式: 所有线程:测试计划中所有线程,假如说有线程1到线程n ( ...

  4. python爬取数据分析

    一.python爬虫使用的模块 1.import requests 2.from bs4 import BeautifulSoup 3.pandas 数据分析高级接口模块 二. 爬取数据在第一个请求中 ...

  5. Python_soket

    1.socket建立连接,服务端,客户端代码如下: import socket #服务端,AF_INET:IPV4地址,SOCK_STREAM:TCP协议 sk=socket.socket(socke ...

  6. 【Pet HDU - 4707 】【利用并查集找深度】

    #include<iostream> #include<cstdio> #include<cstring> using namespace std; const i ...

  7. Jmeter连接mysql,如何用delete、update、insert真正删除、更改、插入数据库里的数据;

    1.如下图,当插入数据的时候如图对应填写,查询数据的时候上面插入的那条数据就会显示,但是如果不执行下图的提交数据:到数据库里查的时候,插入的这条数据实际上并没有插入成功: . 结果:如果没有提交数据, ...

  8. Vue和微信小程序区别

    一.生命周期 先贴两张图: vue生命周期 小程序生命周期 相比之下,小程序的钩子函数要简单得多. vue的钩子函数在跳转新页面时,钩子函数都会触发,但是小程序的钩子函数,页面不同的跳转方式,触发的钩 ...

  9. P1197 [JSOI2008]星球大战[并查集+图论]

    题目来源:洛谷 题目描述 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治着整个星系. 某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球 ...

  10. 项目Beta冲刺 - 凡事预则立

    课程: 软件工程1916|W(福州大学) 作业要求: 项目Beta冲刺 团队名称: 火鸡堂 作业目标: 尽力交付 火鸡堂 队员学号 队员姓名 博客地址 备注 221600111 彼术向 http:// ...