一、AP快速设置:
1.sed the ssid
iwconfig ath0 essid “SSIDNAME”
2.set key
wpa_cli -g /var/run/hostapd/global raw ADD bss_config=ath0:/var/run/hostapd-ath0.conf
##将ath0认证信息移除:
wpa_cli -g /var/run/hostapd/global raw REMOVE ath0
ifconfig ath0 down
unbridge “ath1”
wlanconfig “ath1” destroy
rm /var/run/hostapd_cred_wifi1.bin
_wifi_updown enable
##将SSID相关认证信息写入:/var/run/hostapd-ath0.conf配置文件中:
调用hostapd_setup_vif()接口,该接口存在于/lib/wifi/hostapd.sh脚本中。
##注册ath0认证信息:
wpa_cli -g /var/run/hostapd/global raw ADD bss_config=ath0:/var/run/hostapd-ath0.conf
3.AP之WPS设置
(1)注册ap的WPS时间回调脚本:
hostapd_cli -i ath0 -P /var/run/hostapd_cli-ath0.pid -a /lib/wifi/wps-hostapd-update-uci -p /var/run/hostapd-wifi0 -B
hostapd_cli -i ath1 -P /var/run/hostapd_cli-ath1.pid -a /lib/wifi/wps-hostapd-update-uci -p /var/run/hostapd-wifi1 -B
(2)触发AP的WPS事件:
触发之前要检查是否nopbn的值为1?
iwpriv athx nopbn 1/0
To disable VAPs being notified when jump start button gets pushed【】
To check whether nopbn option is enabled for a specific vap
iwpriv ath0 get_nopbn
如果返回值为1,表明正在有其他WPS时间在处理,则不能触发wps时间。
否则通过下面命令触发wps:
hostapd_cli -i “ath0” -p “/var/run/hostapd-wifi0” wps_pbc
hostapd_cli -i “ath1” -p “/var/run/hostapd-wifi1” wps_pbc
参考:
——————————————————————————–
修改涉及到的文件:
M common_IPQ8064/qsdk/package/base-files/files/sbin/wifi
? common_IPQ8064/qsdk/qca/feeds/qca_10_4/net/qca-hostap-10.4/files/wps-supplicant-hotplug.sh
M common_IPQ8064/qsdk/qca/feeds/qca_10_4/net/qca-hostap-10.4/files/wps-supplicant-update-uci.sh
M common_IPQ8064/qsdk/qca/feeds/qca_10_4/net/qca-wifi-10.4/files/qcawifi.sh
增加命令:wifi reconfig_ap wifiX
该命令实现将uci配置文件中信息重新写入/var/run/hostapd-athX.conf文件,以使从Backhaul获取到的信息能更新到AP VAP接口中。
SSID:
iwconfig athN essid “Name of Network”
iwconfig ath0 essid AP50_Test
KEY:
iwconfig athN key [index] keyvalue
#iwconfig ath0 key [2] DEAD-BEEF-EA
#iwconfig ath0 key [1] s:AnASCIIkeyVal
#iwconfig ath0 key off
——————————————————————————–
二、STA快速设置
1.创建STA接口
wlanconfig ath01 create wlandev wifi0 wlanmode sta nosbeacon
(1)/usr/sbin/wlanconfig “ath01” create wlandev “wifi0” wlanmode “sta” nosbeacon
(2)生成相应的配置文件 /var/run/wpa_supplicant-ath01.conf
内容如下:
ctrl_interface=/var/run/wpa_supplicant-ath01
network={
scan_ssid=1
ssid=”CAP-5G”
key_mgmt=WPA-PSK
proto=RSN
psk=”1122334455″
pairwise=CCMP
group=CCMP TKIP
}
(3)brctl addif br-lan ath01
(4)ifconfig ath01 up
(5)wpa_cli -g /var/run/wpa_supplicantglobal interface_add ath01 /var/run/wpa_supplicant-ath01.conf athr /var/run/wpa_supplicant-ath01 “” br-lan ##实际上在上面将接口创建出来的时候如果/var/run/wpa_supplicant-ath01.config存在的话,会自动执行此步进行关联的。
(4)去掉之前的认证连接:
wpa_cli -g /var/run/wpa_supplicantglobal interface_remove ath01
(5)删除接口
wlanconfig ath01 destroy
2.STA停止操作
sta停止之后需要重新启动sta所在Radio上的AP接口(否则,AP接口无法提供服务):
ifconfig ath01 down ##停止ath01网络接口
brctl delif br-lan ath01 ##从桥中清除STA接口
wpa_cli -g /var/run/wpa_supplicantglobal interface_remove ath01 ##删除wpa-supplicant认证连接
wlanconfig ath01 destroy ##销毁STA接口
wifi reconfig_ap wifi0 ##重启wifi0 上的AP接口
ifconfig ath01 down/up之后,ath01要120秒后才能够正常通信。
ifconfig br-lan hw ether 08:6A:0A:D2:FC:25 ##设置br-lan的MAC地址
3.STA启动操作
/usr/sbin/wlanconfig “ath01” create wlandev “wifi0” wlanmode “sta” nosbeacon
iwpriv ath01 wds 1
brctl addif br-lan ath01
ifconfig ath01 up
wpa_supplicant -g /var/run/wpa_supplicantglobal -B -P /var/run/wpa_supplicant-global.pid ##必须保证wpa_supplicant进程存在
wpa_cli -g /var/run/wpa_supplicantglobal interface_add ath01 /var/run/wpa_supplicant-ath01.conf athr /var/run/wpa_supplicant-ath01 “” br-lan
完整实例:
(1)创建STA接口
/usr/sbin/wlanconfig “ath0” create wlandev “wifi0” wlanmode “sta” nosbeacon
(2)WDS配置
iwpriv ath0 wds 1
(3)准备认证信息
/var/run/wpa_supplicant-ath0.conf文件内容
ctrl_interface=/var/run/wpa_supplicant-ath0
network={
scan_ssid=1
ssid=”VVIC-5G”
key_mgmt=WPA-PSK
proto=RSN
psk=”83355323!@#”
pairwise=CCMP
group=CCMP TKIP
}
(4)检查wpa_supplicant进程是否存在,否则需要重启该进程:wpa_supplicant -g /var/run/wpa_supplicantglobal -B -P /var/run/wpa_supplicant-global.pid
(5)发送认证请求进行认证
wpa_cli -g /var/run/wpa_supplicantglobal interface_add ath0 /var/run/wpa_supplicant-ath0.conf athr /var/run/wpa_supplicant-ath0 “” br-lan
STA WPS关联动作
wpa_cli -p “/var/run/wpa_supplicant-ath01″ wps_pbc ##开始WPS关联动作
pid=/var/run/wps-hotplug-ath01.pid
wpa_cli -p”/var/run/wpa_supplicant-ath01” -a/lib/wifi/wps-supplicant-update-uci -P/var/run/wps-hotplug-ath01.pid -B ##注册接口状态改变后的回调脚本,对连接状态的改变进行相应动作。