在自动信道文件中。函数处理流程进行:
Main() ../hostapd/main.c + 552
hostapd_wpa_event() ../src/ap/drv_callbacks.c +1017 在该函数中通过接收 事件 是否 为 EVENT_CHANNEL_LIST_CHANGED,触发hostapd 更新信道。而这个事件在什么地方发送的呢? src/drivers/Driver_nl80211.c +2754
分别会在 NL80211_CMD_REG_CHANGE 和 NL80211_CMD_REG_BEACON_HINT 这两个事件下。
hostapd_channel_list_updated() ../src/ap/hostapd.c +992
--------setup_interface2(iface); ../src/ap/hostapd.c +1060
---------------hostapd_select_hw_mode() 信道是在这调用检查信道功能,判断是否channel =0, 如果=0 就进行自动信道选择。
------------------------ hostapd_check_chans(iface) src/ap/hw_features.c +973 这函数中就是触发自动信道功能的。
-------------------------------acs_init() // 初始化运行调用自动信道功能
----------------------------------------------acs_request_scan()
这个才是自动信道 处理流程:
-------------main:709-----------
-------------hostapd_setup_interface:1249-----------
-------------setup_interface:1048-----------
-------------setup_interface:1058-----------
-------------setup_interface2:1066-----------
-------------setup_interface2:1071-----------
-------------hostapd_select_hw_mode:974-----------
-------------hostapd_check_chans:857-----------
-------------acs_init:795-----------
NL80211_CMD_REG_CHANGE 事件
wiphy_register()
/*
* This can happen on global regulatory changes or device specific settings
* based on custom world regulatory domains.
*/
nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_CHANGE); // .. \compat-wireless-2013-06-27\drivers\net\wireless\nl80211.c +9301
hostapd_select_hw_mode 选择 hw 模式 在该函数中会检查信道。
switch (hostapd_check_chans(iface)) {
case HOSTAPD_CHAN_VALID:
return 0;
case HOSTAPD_CHAN_ACS: /* ACS will run and later complete */
return 1;
case HOSTAPD_CHAN_INVALID:
default:
hostapd_notify_bad_chans(iface);
return -3;
}
nl80211作为用户空间的配置管理。
struct wpa_driver_ops *wpa_drivers[] =
{
#ifdef CONFIG_DRIVER_NL80211
&wpa_driver_nl80211_ops,
}
const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.init2 = wpa_driver_nl80211_init, src/drivers/Driver_nl80211.c +11443
}
------- wpa_driver_nl80211_init()/ i802_init()
---------------wpa_driver_nl80211_drv_init() src/drivers/Driver_nl80211.c +3780
---------------------wpa_driver_nl80211_init_nl src/drivers/Driver_nl80211.c +3621
-----------------------------------process_drv_event src/drivers/Driver_nl80211.c +2794
--------------------------------------------------do_process_drv_event()
static int process_drv_event(struct nl_msg *msg, void *arg)
root@xxxxxx:/# hostapd -ddd -P /var/run/wifi-phy0.pid /var/run/hostapd-phy0.conf
Configuration file: /var/run/hostapd-phy0.conf
Channel not configured (hw_mode/channel in hostapd.conf)
Could not select hw_mode and channel. (-3)
wlan0: Unable to setup interface.
关于自动信道功能:
Hostapd 20131120 版本
Acs 中:
* How does it work
* ----------------
* 1. passive scans are used to collect survey data
* (it is assumed that scan trigger collection of survey data in driver)
* 2. interference factor is calculated for each channel
* 3. ideal channel is picked depending on channel width by using adjacent
* channel interference factors
Hostapd 20131120 版本实现原理:
具体自动信道实现acs 处理
Acs 发出扫描请求,调用驱动进行扫描hostapd_driver_scan();
2. 分析计算干扰数据
3. 根据计算出的结果选择一个理想信道然后赋值
iface->conf->channel = ideal_chan->chan;
struct hostapd_iface *iface
自动选择信道:
在分析自动选择信号到后,可以找到调用自动信道的位置为:
hostapd_select_hw_mode() 函数中,进行信号注册,等待接收信号SIGUSR1, 如果收到了信号,进入信号处理函数进行选择信道。
#ifdef CONFIG_ACS
if(iface->conf->channel == 0)
{
iface_G = iface;
signal(SIGUSR1, sig_han);
}
#endif
设置hostapd 配置文件里面的信道方法:
system("sed -i \"s/$\(cat /var/run/hostapd-phy0.conf | grep \"channel=\"\)/channel=6/g\" /var/run/hostapd-phy0.conf");