由于wpa_supplicant 不支持wireless tools(wext) 或者iw(nl80211)
的某些命令(跟wep,wpa 没关系),这样如果需要做测试比如set txpower,channel 等命令时
wpa_supplicant就不支持
但可以通过把iw,或者wireless tool 等命令加入到wpa_supplicant
中来实现,这样的好处,可以通过wpa_cli 调用,并且上层有jni
方便界面开发
实现wext接口wireless tools 命令到wpa_supplicant方法很简单
就是把wireless tools 代码弄到wpa supplicant中
并在wpa_driver_priv_driver_cmd添加接口
android2.3.4下
方法如下:
1. 在driver_wext.c中
wpa_driver_priv_driver_cmd 函数中
修改:
- + extern int dispatch(void *priv, char *cmd,char *buf, size_t buf_len);
- static int wpa_driver_priv_driver_cmd( void *priv, char *cmd, char *buf, size_t buf_len )
- {
- struct wpa_driver_wext_data *drv = priv;
- int ret = -1;
- wpa_printf(MSG_DEBUG, "%s %s", __func__, cmd);
- -
- if (os_strcasecmp(cmd, "start") == 0) {
- wpa_printf(MSG_DEBUG,"Start command");
- return (ret);
- @@ -2723,6 +2724,9 @@ static int wpa_driver_priv_driver_cmd( void *priv, char *cmd, char *buf, size_t
- }
- else if( os_strcasecmp(cmd, "btcoexstat") == 0 ) {
- }
- + else if( (ret = dispatch(priv,cmd, buf, buf_len)) >= 0){
- + return ret;
- + }
- else {
- wpa_printf(MSG_DEBUG,"Unsupported command");
- }
添加一个dispatch 命令接口
2. 将wrieless tools中iwconfig 部分内容移植过来
添加文件 如附件
driver_cmd.zip
然后将加的文件 加到wpa_supplicant 目录下的andorid.mk 中
3. 测试
进入wpa_cli 输入
driver get:命令
driver set:命令=value
命令字 可选iwconfig 中下面结构中第1个feild
- static const struct iwconfig_entry iwconfig_cmds[] = {
- { "essid", set_essid_info, 1, SIOCSIWESSID,
- "Set ESSID",
- "{NNN|any|on|off}" },
- { "mode", set_mode_info, 1, SIOCSIWMODE,
- "Set Mode", "{managed|ad-
- hoc|master|...}" },
- { "freq", set_freq_info, 1, SIOCSIWFREQ,
- "Set Frequency", "N.NNN[k|M|G]" },
- {
- "channel", set_freq_info, 1, SIOCSIWFREQ,
- "Set Frequency", "N" },
- { "bit", set_bitrate_info,
- 1, SIOCSIWRATE,
- "Set Bit Rate", "{N[k|M|G]|auto|fixed}" },
- { "rate", set_bitrate_info, 1, SIOCSIWRATE,
-
- "Set Bit Rate", "{N[k|M|G]|auto|fixed}" },
- { "power", set_power_info, 1, SIOCSIWPOWER,
- "Set Power
- Management", "{period N|timeout N|saving N|off}" },
- #ifndef WE_ESSENTIAL
- { "nickname", set_nick_info, 1,
- SIOCSIWNICKN,
- "Set Nickname", "NNN" },
- { "nwid", set_nwid_info, 1, SIOCSIWNWID,
- "Set NWID",
- "{NN|on|off}" },
- #ifdef USE_ADDRESS_SUBROUTINES
- { "ap", set_apaddr_info, 1, SIOCSIWAP,
- "Set AP Address",
- "{N|off|auto}" },
- #endif
- { "txpower", set_txpower_info, 1, SIOCSIWTXPOW,
- "Set Tx Power",
- "{NmW|NdBm|off|auto}" },
- { "sens", set_sens_info, 1, SIOCSIWSENS,
- "Set Sensitivity", "N" },
- { "retry",
- set_retry_info, 1, SIOCSIWRETRY,
- "Set Retry Limit", "{limit N|lifetime N}" },
- { "rts", set_rts_info,
- 1, SIOCSIWRTS,
- "Set RTS Threshold", "{N|auto|fixed|off}" },
- { "frag", set_frag_info, 1,
- SIOCSIWFRAG,
- "Set Fragmentation Threshold", "{N|auto|fixed|off}" },
- { "modulation", set_modulation_info, 1, SIOCGIWMODUL,
- "Set
- Modulation", "{11g|11a|CCK|OFDMg|...}" },
- #endif /* WE_ESSENTIAL */
- { "commit", set_commit_info, 0,
- SIOCSIWCOMMIT,
- "Commit changes", "" },
- { NULL, NULL, 0, 0, NULL, NULL },
- };
比如tx-power
取值
driver get:txpower
设置
driver get:txpower=20
4.nl80211 driver priv命令的实现
同样把 iw 部分代码,修改下支持dispatch接口
另外需要libnl ,需要将其build成android native lib
阅读(4002) | 评论(1) | 转发(0) |