Extending wpa_supplicant for kernel mac80211 control

wpa_supplicant is a popular cross platform tool for wifi network configuration. On linux kernel, wpa_supplicant can use NetLink (nl80211) to pass commands and arguments to the configuration API of IEEE 802.11 (cfg80211). In this post, I will go through the different edits needed to pass arguments from userspace to mac80211 through wpa_supplicant. I will use my work on WiFi augmentation which allows wpa_supplicant to configure mac80211 to control its medium access control behavior.

wpa_supplicant has two main components: wpa_supplicant daemon and the wpa_cli client program. The edits I will present will be in both the daemon and the client. My edits assumes the existence of some functions in kernel that the user of wpa_supplicant is attempting to invoke.

The edit starts with the wpa_cli (client) code. The wpa_cli code maintains an array of all commands it can process mapped to callback functions that should be executed on the invocation of that command. The array can be found at wpa_supplicant/wpa_cli.c "const struct wpa_cli_cmd wpa_cli_commands":

The array element specifies the function to call which requires adding the function as specified below which is added to the same file:
The above function gets the parameters passed through the client and calls the wpa_cli_cmd or wpa_cli_commad functions (note that wpa_cli_cmd calls wpa_cli_commad) which are implemented to pass the arguments eventually to the wpa_supplicant_ctrl_iface_process function in wpa_supplicant/ctrl_iface.c file. The function is basically a bug switch statement that invoke different functions based on the command string passed through wpa_cli_cmd :
The handler function should be implemented in wpa_supplicant/wpa_supplicant.c and should look something like as follows that first obtains network information to select the network to control in kernel and calls the Station Management Entity (sme) function:
The sme function calls the driver function. The driver interface is implemented in wpa_supplicant/driver_i.h which requires extending the struct wpa_driver_ops structure to include the function corresponding to sample_change. The driver function creates an nl80211 message. I will cover the edits to the nl80211 driver and the nl80211 implementation in kernel in a following post.

Comments

Popular posts from this blog

Integrating Click Router and GNURadio

Attaching a WiFi Dongle to an AR Drone 2.0 (a.k.a. Compiling Drivers for ARM Based Devices)

CUDA compilation on Linux (Makefiles)