hostapd_ctrl_iface.doxygen 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. \page hostapd_ctrl_iface_page hostapd control interface
  3. hostapd implements a control interface that can be used by
  4. external programs to control the operations of the hostapd
  5. daemon and to get status information and event notifications. There is
  6. a small C library, in a form of a single C file, \ref wpa_ctrl.c, that
  7. provides helper functions to facilitate the use of the control
  8. interface. External programs can link this file into them and then use
  9. the library functions documented in \ref wpa_ctrl.h to interact with
  10. wpa_supplicant. This library can also be used with C++. \ref hostapd_cli.c
  11. is an example program using this library.
  12. There are multiple mechanisms for inter-process communication. For
  13. example, Linux version of hostapd is using UNIX domain sockets for the
  14. control interface. The use of the functions defined in \ref wpa_ctrl.h can
  15. be used to hide the details of the used IPC from external programs.
  16. \section using_ctrl_iface Using the control interface
  17. External programs, e.g., a GUI or a configuration utility, that need to
  18. communicate with hostapd should link in \ref wpa_ctrl.c. This
  19. allows them to use helper functions to open connection to the control
  20. interface with \ref wpa_ctrl_open() and to send commands with
  21. \ref wpa_ctrl_request().
  22. hostapd uses the control interface for two types of communication:
  23. commands and unsolicited event messages. Commands are a pair of
  24. messages, a request from the external program and a response from
  25. hostapd. These can be executed using \ref wpa_ctrl_request().
  26. Unsolicited event messages are sent by hostapd to the control
  27. interface connection without specific request from the external program
  28. for receiving each message. However, the external program needs to
  29. attach to the control interface with \ref wpa_ctrl_attach() to receive these
  30. unsolicited messages.
  31. If the control interface connection is used both for commands and
  32. unsolicited event messages, there is potential for receiving an
  33. unsolicited message between the command request and response.
  34. \ref wpa_ctrl_request() caller will need to supply a callback, msg_cb,
  35. for processing these messages. Often it is easier to open two
  36. control interface connections by calling \ref wpa_ctrl_open() twice and
  37. then use one of the connections for commands and the other one for
  38. unsolicited messages. This way command request/response pairs will
  39. not be broken by unsolicited messages. \ref wpa_cli.c is an example of how
  40. to use only one connection for both purposes and wpa_gui demonstrates
  41. how to use two separate connections.
  42. Once the control interface connection is not needed anymore, it should
  43. be closed by calling \ref wpa_ctrl_close(). If the connection was used for
  44. unsolicited event messages, it should be first detached by calling
  45. \ref wpa_ctrl_detach().
  46. \section ctrl_iface_cmds Control interface commands
  47. Following commands can be used with \ref wpa_ctrl_request():
  48. \subsection ctrl_iface_PING PING
  49. This command can be used to test whether hostapd is replying
  50. to the control interface commands. The expected reply is \c PONG if the
  51. connection is open and hostapd is processing commands.
  52. */