:去打开wpa_supplicant.命令行如下:
service wpa_supplicant /system/bin/wpa_supplicant -Dfawext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd
main()
解析传入参数后初始化:
iface->confname=/data/misc/wifi/wpa_supplicant.conf
iface->driver =fawext
params.wpa_debug_level--
iface->ifname=wlan0
global = wpa_supplicant_init(¶ms); //
eap_peer_register_methods(); //注册加密处理函数
初始化global
eloop_init(global)------》eloop.user_data = global
global->ctrl_iface = wpa_supplicant_global_ctrl_iface_init(global);
global->dbus_ctrl_iface =
wpa_supplicant_dbus_ctrl_iface_init(global);
if (global->dbus_ctrl_iface == NULL) {
wpa_supplicant_deinit(global);
return NULL;
}
wpa_supplicant_daemon(global->params.pid_file)
wpa_supplicant_global_ctrl_iface_init()
传入global参数:
#ifdef ANDROID
priv->sock = android_get_control_socket(global->params.ctrl_interface);
if (priv->sock >= 0)
goto havesock;
#endif
如果没定义android或者获取失败:
创建soket:
priv->sock = socket(PF_UNIX, SOCK_DGRAM, 0);
如果成功:
创建sock注册监听sock及其处理函数:wpa_supplicant_global_ctrl_iface_receive()
根据接受的字符串,调用处理:返回reply(字符串)
reply = wpa_supplicant_global_ctrl_iface_process(global, buf,
&reply_len);
if (reply) {
sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from,
fromlen);
os_free(reply);
} else if (reply_len) {
sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from,
fromlen);
}
wpa_supplicant_add_iface(global, &ifaces[i])
wpa_supplicant_init_iface()
wpa_supplicant_set_driver()//选择驱动接口
exitcode = wpa_supplicant_run(global)
wpa_supplicant_global_ctrl_iface_init()