Updated: October 28, 2024 |
Send a command request to the WPA control interface
#include <wpa_ctrl.h>
int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len, char *reply, size_t *reply_len, void(*msg_cb)(char *msg, size_t len))
This function sends a command request to the WPA control interface. The received response will be written into reply, and reply_len will be set to the length of the command response. This function blocks for up to 10 seconds while awaiting the response, but if unsolicited messages (i.e., events) are received, it can block for longer.
You can specify msg_cb to register a callback function that will handle unsolicited messages. These messages can be received if your program called wpa_ctrl_attach() to register as an event monitor and then called wpa_ctrl_request() at the same time as the WPA control interface was sending such a message.
Alternatively, your program can create two control connections and use one for commands and the other for event messages (and call wpa_ctrl_attach() only for the connection used for events).