wpa_ctrl_open()

Updated: April 19, 2023

Open a control connection to the WPA control interface

Synopsis:

#include <wpa_ctrl.h>
struct wpa_ctrl* wpa_ctrl_open(const char *ctrl_path)

Arguments:

ctrl_path
Path for UNIX domain sockets; this is ignored if UDP sockets are used. Usually, this is /var/run/wpa_supplicant or /var/run/hostapd. The path must match what is configured in the options of wpa_supplicant and hostapd. Because this path is published by those services, other programs using the control connection must use the same path to use the same socket.

Library:

libwpactrl

Description:

This function opens a control connection to the WPA control interface. The control connection can be used for either commands or event messages, or both. But in the last case, when issuing any command, you must provide a callback function to wpa_ctrl_request(), to handle any unsolicited event messages received between the command request and the response. Often, it's easier to open two control connections by calling wpa_ctrl_open() twice and to then use one for commands and the other for event messages.

For a control connection used for event messages, you must then call wpa_ctrl_attach().

When you no longer need a control connection, you should close it by calling wpa_ctrl_close().

Returns:

A pointer to abstract control connection data on success, NULL on failure