搜档网
当前位置:搜档网 › wpa_supplicant_control_data_flow

wpa_supplicant_control_data_flow

wpa_supplicant controlling data flow

-------Take STA scan as example

1. Initialization

1). wpa_supplicant/main.c

In main() , four things are done:

A. Parse the parameters in init.rc. Normally it has following formart:

wpa_supplicant /system/bin/wpa_supplicant -Dwext -imlan0

-c/data/misc/wifi/wpa_supplicant.conf

Where , -D indicates what kind of driver is used, and here wireless extension is used; -i indicates the name of network interface; -c indicates the configure file name.

B. Invoke wpa_supplicant_init() to do some initialization jobs:

Create control interface like following:

priv->sock = socket(PF_UNIX,SOCK_DGRAM,0);

C. Invoke wpa_supplicant_add_iface() to add interface

1). Allocate a data structure of wpa_supplicant.

2). Invoke wpa_supplicant_init_iface() to do some job to initialize the interface. I,e set driver kind indicated by -D parameter.

3.Invoke wpa_supplicant_init_ifcace2()

D. Invoke wpa_supplicant_run() to run the wpa_supplicant main event loop.

2. How does wpa_supplicant receive and response the

command from upper layer

After the initialization has been done, wpa_supplicant do a event loop in function eloop_run() like following:

Where the most important thing is invoking select() system call to poll which file describe is ready to read, write or some exceptions have occurred. If an event is occurred, eloop_sock_table_dispatch() will process it like following:

3. Where registers the table->table[i].handler() call back

function

As shown in the eloop_sock_table_dispatch() function, wpa_supplicant handles the event by calling handler() call back function. So there must have some code to register the handler to wpa_supplicant like following:

Where, this function register a READ event handler called

wpa_supplicant_ctrl_iface_receive() to the eloop table whose prototype is :

And the priv->sock is create in the initialization.

4. Jobs of wpa_supplicant_ctrl_iface_receive()

The main job of wpa_supplicant_ctrl_iface_receive() is listen to the socket, and process the command received from UNIX socket:

5. Jobs of wpa_supplicant_ctrl_iface_process()

The main job of wpa_supplicant_ctrl_iface_process() is process the command like:

6. How dose wpa_supplicant invoke the driver`s ioctl()

function

A. Wpa_supplicant invokes the driver`s ioctl() function

through the kind of driver indicated by -D parameter, use wireless extension as default. See

wpa_supplicant_init_iface() .

wpa_supplicant_drivers[] arry is defined as follows:

wpa_drivers_wext_ops is defined as follows:

So when SCAN command is requested, wpa_supplicant will call the

wpa_drivers_wext_ops.scan , that is wpa_driver_wext_scan.

B. Jobs of wpa_driver_wext_scan

Call the driver`s ioctl() function through ioctl() system call:

Where the drv->ioctl_sock is created in wpa_driver_wext_init() as follows:

And wpa_driver_wext_int is called in wpa_supplicant_init_ifcace2() :

C. How does ioctl() system call access the driver`s ioctl() Refer :

NetDeviceIotclStructure.pdf

相关主题