wpa_ctrl_request()
Send a command request to the WPA control interface
Synopsis:
#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))
Arguments:
- ctrl
- Control connection data from wpa_ctrl_open()
- cmd
- Command to send, usually as ASCII text (e.g.,
PING
). For the list of commands that can be sent, see the next section. - cmd_len
- Length of the command, in bytes
- reply
- Buffer for storing the response
- reply_len
- Pointer to memory for storing the response length, in bytes
- msg_cb
- Callback function for unsolicited event messages, or NULL if no callback is needed
Library:
libwpactrlDescription:
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).
Returns:
- 0
- Success
- -1
- Failure on sending the command or receiving the response
- -2
- Failure due to timeout