external/wpa_supplicant_8/wpa_supplicant/defconfig
# Disable roaming in wpa_supplicant
#CONFIG_NO_ROAMING=y
external/wpa_supplicant_8/wpa_supplicant/android.config
# Disable roaming in wpa_supplicant
CONFIG_NO_ROAMING=y
我认为Android代码中配置项会在android.config文件中查找对应的配置项,而非Android的代码则在defconfig文件中查找对应的配置项.android.config和defconfig是属于两套不同的编译体制Makefile和Android.mk,所以android.config和defconfig两者不存在先谁后谁的关系.只是在不同的编译方法中会选择不同的文件进行选择配置项.
当然其他的功能的配置项以此类推.想在wpa_supplicant中关闭某一项的功能,则找到对应的配置项进行关闭.类似于之前文档关闭p2p功能一样.
external/wpa_supplicant_8/wpa_supplicant/Makefile
ifdef CONFIG_NO_ROAMING
CFLAGS += -DCONFIG_NO_ROAMING
endif
Makefile会在defconfig文件中查找配置项.
在Android源码中的如下的文件中external/wpa_supplicant_8/wpa_supplicant/Android.mk
# Disable roaming in wpa_supplicant
ifdef CONFIG_NO_ROAMING
L_CFLAGS += -DCONFIG_NO_ROAMING
endif
Android.mk会在android.config文件中查找配置项.
我认为当android.config配置文件中配置了对应的配置项之后,编译文件会根据配置项的内容进行查找,如果配置项被使能,那么此处就会在编译的时候增加对应的使能标(CONFIG_NO_ROAMING).这样代码中就认为配置项被配置(使能).
在external/wpa_supplicant_8/wpa_supplicant/events.c
static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
struct wpa_bss *selected,
struct wpa_ssid *ssid)
{
......
#ifndef CONFIG_NO_ROAMING
int min_diff;
int to_5ghz;
#endif /* CONFIG_NO_ROAMING */
......
#ifndef CONFIG_NO_ROAMING
wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation");
wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR
" level=%d snr=%d est_throughput=%u",
MAC2STR(current_bss->bssid), current_bss->level,
current_bss->snr, current_bss->est_throughput);
wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR
" level=%d snr=%d est_throughput=%u",
MAC2STR(selected->bssid), selected->level,
selected->snr, selected->est_throughput);
if (wpa_s->current_ssid->bssid_set &&
os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) ==
0) {
wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS "
"has preferred BSSID");
return 1;
}
if (selected->est_throughput > current_bss->est_throughput + 5000) {
wpa_dbg(wpa_s, MSG_DEBUG,
"Allow reassociation - selected BSS has better estimated throughput");
return 1;
}
to_5ghz = selected->freq > 4000 && current_bss->freq < 4000;
if (current_bss->level < 0 &&
current_bss->level > selected->level + to_5ghz * 2) {
wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better "
"signal level");
return 0;
}
min_diff = 2;
if (current_bss->level < 0) {
if (current_bss->level < -85)
min_diff = 1;
else if (current_bss->level < -80)
min_diff = 2;
else if (current_bss->level < -75)
min_diff = 3;
else if (current_bss->level < -70)
min_diff = 4;
else
min_diff = 5;
}
if (to_5ghz) {
/* Make it easier to move to 5 GHz band */
if (min_diff > 2)
min_diff -= 2;
else
min_diff = 0;
}
if (abs(current_bss->level - selected->level) < min_diff) {
wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference "
"in signal level");
return 0;
}
return 1;
#else /* CONFIG_NO_ROAMING */
return 0;
#endif /* CONFIG_NO_ROAMING */
}
WPAS难度较大的一个重要原因是其注释较少,很多变量的含义没有任何解释。笔者也为此大伤脑筋。不得以,只能通过查看WPAS代码的历史版本来寻根溯源。经过实践,笔者总结了利用git来查询WPAS历史版本信息的一些步骤,分别如下。
用git clone命令下载WPAS官方代码。
git clone git://w1.fi/srv/git/hostap.git