- Wpa_supplicant Introduction
Wpa_supplicant is used to support various encryption methods in wireless, including WEP, WPA/WPA2, and WAPI (China-specific), EAP (8021x). wpa_s communicates with the upper layer (framework) and the underlying (driver) through the socket, receives commands and passes the current state up, sends commands down to the driver and receives the various events that drive uploads, and strictly speaking, there is a cfg80211 in wap_s and driver. Cfg80211 can be understood as a Linux defined 80211 management control layer framework, such as scanning, connecting these common processes, each vendor according to the framework provided by the cfg80211 to write their own driver, to achieve specific frame sending and receiving. wpa_s How to handle the data in each socket see the Eloop Sun section.
is a picture on the Web page (http://zwz94.blog.163.com/blog/static/3206039520120149580531/) that can clearly see the location of the wpa_s in the entire WiFi architecture
- Wpa_supplicant Start-up
On Android phones, the wpa_supplicant boot is controlled by the framework, and Frameowork sets the property to start the service written in the init RC file, while generating two sockets, one to Wpa_ s send command, a receive wpa_s upload event
Service P2p_supplicant/system/bin/wpa_supplicant\ -ip2p0 -dnl80211 - C/Data/misc/wifi/p2p_supplicant.Conf\ - I./system/etc/wifi/p2p_supplicant_overlay.Conf- N \ -iwlan0 -dnl80211 - C/Data/misc/wifi/wpa_supplicant.Conf\ - I./system/etc/wifi/wpa_supplicant_overlay.Conf\ - o/Data/misc/wifi/sockets-puse_p2p_group_interface=1 -DD \ - e/Data/misc/wifi/entropy.Bin- G@android: Wpa_wlan0 class main socket wpa_wlan0 Dgram660WiFi WiFi disabled oneshot
where socket wpa_wlan0 Dgram 660 WiFi WiFi created a socket,wpa_s using the socket to receive the framework commands and to pass the event up. The framework will also call to connect to the socket, which will later
- Wpa_supplicant Startup Parameters
wpa_s allow many parameters to be passed in, parameters are case-sensitive
The parameters are in a total of 3 types,
- 3.1 Without subsequent content,
Have –BDHKLQSTUVW
-H: Help file
-L: Output license
-Q: Raise the wpa_s debug level (output log reduction), in contrast to-D
-V: Output wpa_s version number
-W: Wait until control Interface monitor runs again
-N: When you need to set up two network interface, you need to insert –N in the middle of two port parameters, for example, a network port is p2p0, need to insert-N, and then add another wlan0
- 3.2 With subsequent content, control wpa_s operation parameters, can also be called global parameters
struct Wpa_params is used in calling Wpa_supplicant_init () initialization wpa_s
structWpa_params {//-b: Running in the background as a daemon intDaemonize;//-w: Wait until control Interface monitor runs again intWait_for_monitor;//-p:pid_file-path to a PID (process ID) file Char*pid_file;//-d: The level of output log,-D is the default level, the-DD level is reduced by one level (output log will increase by one level), and so on, the code is set to Params.wpa_debug_level intWpa_debug_level;//-k: Print key in log intWpa_debug_show_keys;//-t: Increase timestamp in debug information intWpa_debug_timestamp;//ctrl_interface-global ctrl_iface Path/parameter //-g:global ctrl_interface (string is @android+sock_name, Sock_name is by init.rc) Char*ctrl_interface;//ctrl_interface_group-global ctrl_iface Group //-g:global ctrl_interface Group Char*ctrl_interface_group;//-u: Supports Dbus control Interface intDbus_ctrl_interface;//-f: Output log to File Const Char*wpa_debug_file_path;//-s: Output log to Syslog, default output to stdout intWpa_debug_syslog;//-t:log add Linux trace intwpa_debug_tracing;//-o: Setting up a directory for the Linux network Port Char*override_driver;//-o: Setting the directory for wpa_s control sockets Char*override_ctrl_interface;//-e:entropy_file-optional Entropy File Char*entropy_file;};
- 3.3 With subsequent content, interface-related, also called interface parameters
stored in struct struct wpa_interface, running Wpa_supplicant_add_iface () needs to pass in the struct
structWpa_interface {//-c:conf configuration file, which defines some parameters and some network nodes, typically wpa_supplicant.conf Const Char*confname;Supplemental options for the//-i:conf configuration file, typically wpa_supplicant_overlay.conf/ Const Char*confanother;//-m:p2p Network port configuration file Const Char*conf_p2p_dev;//-c: Parameters of the control port socket //function equivalent to conf file Const Char*ctrl_interface;type of//-d:driver, you can set multiple, such as Nl80211,wext Const Char*driver;//driver_param-driver Interface Parameters Const Char*driver_param;//-i:linux, you can define multiple, such as Wlan0 Const Char*ifname;//-b: Bridging the interface Const Char*bridge_ifname;//p2p_mgmt-interface used for peer management (peer Device Operations) intP2P_MGMT;};
- wpa_s Global Initialization
The main include EAP various methods of registration, Eloop (wpa_s run the main) parameters, with the framework of communication socket initialization
struct Wpa_global*Wpa_supplicant_init (struct wpa_params*params){//Global information, the contents of the params will be copied into the structurestruct Wpa_global*Global;//Initialize the EAP method with a corresponding method for each EAP modeRet=Eap_register_methods ();//Copy the information in the params to global Global =Os_zalloc (sizeof (*Global));//Initialize struct eloop_data, the struct is a global variable if(Eloop_init ()) Random_init (params -Entropy_file);//Connect with Fwks communication socket (defined in init.rc), and register the function that receives CMD Global -Ctrl_iface=Wpa_supplicant_global_ctrl_iface_init (Global); {//Initialize control socketWpas_global_ctrl_iface_open_sock (Global, Priv)< 0) {//Get the name of the socket-G pass in, corresponding to the init.rcOS_STRNCMP (CTRL,"@android:",9)== 0) {Priv -Sock=Android_get_control_socket (Ctrl+ 9);//Register function wpa_supplicant_global_ctrl_iface_process to receive socket data, distribute and process incoming commandsEloop_register_read_sock (priv -Sock, Wpa_supplicant_global_ctrl_iface_receive,Global, PRIV);//Register a function to send event to Fwks wpa_supplicant_ctrl_iface_sendWPA_MSG_REGISTER_CB (WPA_SUPPLICANT_CTRL_IFACE_MSG_CB); } }return Global;}
is a simple global initialization process
Next for Wpa_supplcant start –linux network interface parameter initialization
Android wpa_supplcant Startup--Global initialization