2009-11-28 20:19:48 +01:00
|
|
|
/**
|
|
|
|
\page hostapd_ctrl_iface_page hostapd control interface
|
|
|
|
|
|
|
|
hostapd implements a control interface that can be used by
|
|
|
|
external programs to control the operations of the hostapd
|
|
|
|
daemon and to get status information and event notifications. There is
|
2015-01-03 14:44:35 +01:00
|
|
|
a small C library, in a form of a single C file, \ref wpa_ctrl.c, that
|
2009-11-28 20:19:48 +01:00
|
|
|
provides helper functions to facilitate the use of the control
|
|
|
|
interface. External programs can link this file into them and then use
|
2015-01-03 14:44:35 +01:00
|
|
|
the library functions documented in \ref wpa_ctrl.h to interact with
|
|
|
|
wpa_supplicant. This library can also be used with C++. \ref hostapd_cli.c
|
2009-11-28 20:19:48 +01:00
|
|
|
is an example program using this library.
|
|
|
|
|
|
|
|
There are multiple mechanisms for inter-process communication. For
|
|
|
|
example, Linux version of hostapd is using UNIX domain sockets for the
|
2015-01-03 14:44:35 +01:00
|
|
|
control interface. The use of the functions defined in \ref wpa_ctrl.h can
|
2009-11-28 20:19:48 +01:00
|
|
|
be used to hide the details of the used IPC from external programs.
|
|
|
|
|
|
|
|
|
|
|
|
\section using_ctrl_iface Using the control interface
|
|
|
|
|
|
|
|
External programs, e.g., a GUI or a configuration utility, that need to
|
2015-01-03 14:44:35 +01:00
|
|
|
communicate with hostapd should link in \ref wpa_ctrl.c. This
|
2009-11-28 20:19:48 +01:00
|
|
|
allows them to use helper functions to open connection to the control
|
2015-01-03 14:44:35 +01:00
|
|
|
interface with \ref wpa_ctrl_open() and to send commands with
|
|
|
|
\ref wpa_ctrl_request().
|
2009-11-28 20:19:48 +01:00
|
|
|
|
|
|
|
hostapd uses the control interface for two types of communication:
|
|
|
|
commands and unsolicited event messages. Commands are a pair of
|
|
|
|
messages, a request from the external program and a response from
|
2015-01-03 14:44:35 +01:00
|
|
|
hostapd. These can be executed using \ref wpa_ctrl_request().
|
2009-11-28 20:19:48 +01:00
|
|
|
Unsolicited event messages are sent by hostapd to the control
|
|
|
|
interface connection without specific request from the external program
|
|
|
|
for receiving each message. However, the external program needs to
|
2015-01-03 14:44:35 +01:00
|
|
|
attach to the control interface with \ref wpa_ctrl_attach() to receive these
|
2009-11-28 20:19:48 +01:00
|
|
|
unsolicited messages.
|
|
|
|
|
|
|
|
If the control interface connection is used both for commands and
|
|
|
|
unsolicited event messages, there is potential for receiving an
|
|
|
|
unsolicited message between the command request and response.
|
2015-01-03 14:44:35 +01:00
|
|
|
\ref wpa_ctrl_request() caller will need to supply a callback, msg_cb,
|
2009-11-28 20:19:48 +01:00
|
|
|
for processing these messages. Often it is easier to open two
|
2015-01-03 14:44:35 +01:00
|
|
|
control interface connections by calling \ref wpa_ctrl_open() twice and
|
2009-11-28 20:19:48 +01:00
|
|
|
then use one of the connections for commands and the other one for
|
|
|
|
unsolicited messages. This way command request/response pairs will
|
2015-01-03 14:44:35 +01:00
|
|
|
not be broken by unsolicited messages. \ref wpa_cli.c is an example of how
|
2009-11-28 20:19:48 +01:00
|
|
|
to use only one connection for both purposes and wpa_gui demonstrates
|
|
|
|
how to use two separate connections.
|
|
|
|
|
|
|
|
Once the control interface connection is not needed anymore, it should
|
2015-01-03 14:44:35 +01:00
|
|
|
be closed by calling \ref wpa_ctrl_close(). If the connection was used for
|
2009-11-28 20:19:48 +01:00
|
|
|
unsolicited event messages, it should be first detached by calling
|
2015-01-03 14:44:35 +01:00
|
|
|
\ref wpa_ctrl_detach().
|
2009-11-28 20:19:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
\section ctrl_iface_cmds Control interface commands
|
|
|
|
|
2015-01-03 14:44:35 +01:00
|
|
|
Following commands can be used with \ref wpa_ctrl_request():
|
2009-11-28 20:19:48 +01:00
|
|
|
|
|
|
|
\subsection ctrl_iface_PING PING
|
|
|
|
|
|
|
|
This command can be used to test whether hostapd is replying
|
|
|
|
to the control interface commands. The expected reply is \c PONG if the
|
|
|
|
connection is open and hostapd is processing commands.
|
|
|
|
|
|
|
|
*/
|