ctrl_iface.doxygen 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. /**
  2. \page ctrl_iface_page %wpa_supplicant control interface
  3. %wpa_supplicant implements a control interface that can be used by
  4. external programs to control the operations of the %wpa_supplicant
  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, 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 wpa_ctrl.h to interact with
  10. %wpa_supplicant. This library can also be used with C++. wpa_cli.c and
  11. wpa_gui are example programs using this library.
  12. There are multiple mechanisms for inter-process communication. For
  13. example, Linux version of %wpa_supplicant is using UNIX domain sockets
  14. for the control interface and Windows version UDP sockets. The use of
  15. the functions defined in wpa_ctrl.h can be used to hide the details of
  16. the used IPC from external programs.
  17. \section using_ctrl_iface Using the control interface
  18. External programs, e.g., a GUI or a configuration utility, that need to
  19. communicate with %wpa_supplicant should link in wpa_ctrl.c. This
  20. allows them to use helper functions to open connection to the control
  21. interface with wpa_ctrl_open() and to send commands with
  22. wpa_ctrl_request().
  23. %wpa_supplicant uses the control interface for two types of communication:
  24. commands and unsolicited event messages. Commands are a pair of
  25. messages, a request from the external program and a response from
  26. %wpa_supplicant. These can be executed using wpa_ctrl_request().
  27. Unsolicited event messages are sent by %wpa_supplicant to the control
  28. interface connection without specific request from the external program
  29. for receiving each message. However, the external program needs to
  30. attach to the control interface with wpa_ctrl_attach() to receive these
  31. unsolicited messages.
  32. If the control interface connection is used both for commands and
  33. unsolicited event messages, there is potential for receiving an
  34. unsolicited message between the command request and response.
  35. wpa_ctrl_request() caller will need to supply a callback, msg_cb,
  36. for processing these messages. Often it is easier to open two
  37. control interface connections by calling wpa_ctrl_open() twice and
  38. then use one of the connections for commands and the other one for
  39. unsolicited messages. This way command request/response pairs will
  40. not be broken by unsolicited messages. wpa_cli is an example of how
  41. to use only one connection for both purposes and wpa_gui demonstrates
  42. how to use two separate connections.
  43. Once the control interface connection is not needed anymore, it should
  44. be closed by calling wpa_ctrl_close(). If the connection was used for
  45. unsolicited event messages, it should be first detached by calling
  46. wpa_ctrl_detach().
  47. \section ctrl_iface_cmds Control interface commands
  48. Following commands can be used with wpa_ctrl_request():
  49. \subsection ctrl_iface_PING PING
  50. This command can be used to test whether %wpa_supplicant is replying
  51. to the control interface commands. The expected reply is \c PONG if the
  52. connection is open and %wpa_supplicant is processing commands.
  53. \subsection ctrl_iface_MIB MIB
  54. Request a list of MIB variables (dot1x, dot11). The output is a text
  55. block with each line in \c variable=value format. For example:
  56. \verbatim
  57. dot11RSNAOptionImplemented=TRUE
  58. dot11RSNAPreauthenticationImplemented=TRUE
  59. dot11RSNAEnabled=FALSE
  60. dot11RSNAPreauthenticationEnabled=FALSE
  61. dot11RSNAConfigVersion=1
  62. dot11RSNAConfigPairwiseKeysSupported=5
  63. dot11RSNAConfigGroupCipherSize=128
  64. dot11RSNAConfigPMKLifetime=43200
  65. dot11RSNAConfigPMKReauthThreshold=70
  66. dot11RSNAConfigNumberOfPTKSAReplayCounters=1
  67. dot11RSNAConfigSATimeout=60
  68. dot11RSNAAuthenticationSuiteSelected=00-50-f2-2
  69. dot11RSNAPairwiseCipherSelected=00-50-f2-4
  70. dot11RSNAGroupCipherSelected=00-50-f2-4
  71. dot11RSNAPMKIDUsed=
  72. dot11RSNAAuthenticationSuiteRequested=00-50-f2-2
  73. dot11RSNAPairwiseCipherRequested=00-50-f2-4
  74. dot11RSNAGroupCipherRequested=00-50-f2-4
  75. dot11RSNAConfigNumberOfGTKSAReplayCounters=0
  76. dot11RSNA4WayHandshakeFailures=0
  77. dot1xSuppPaeState=5
  78. dot1xSuppHeldPeriod=60
  79. dot1xSuppAuthPeriod=30
  80. dot1xSuppStartPeriod=30
  81. dot1xSuppMaxStart=3
  82. dot1xSuppSuppControlledPortStatus=Authorized
  83. dot1xSuppBackendPaeState=2
  84. dot1xSuppEapolFramesRx=0
  85. dot1xSuppEapolFramesTx=440
  86. dot1xSuppEapolStartFramesTx=2
  87. dot1xSuppEapolLogoffFramesTx=0
  88. dot1xSuppEapolRespFramesTx=0
  89. dot1xSuppEapolReqIdFramesRx=0
  90. dot1xSuppEapolReqFramesRx=0
  91. dot1xSuppInvalidEapolFramesRx=0
  92. dot1xSuppEapLengthErrorFramesRx=0
  93. dot1xSuppLastEapolFrameVersion=0
  94. dot1xSuppLastEapolFrameSource=00:00:00:00:00:00
  95. \endverbatim
  96. \subsection ctrl_iface_STATUS STATUS
  97. Request current WPA/EAPOL/EAP status information. The output is a text
  98. block with each line in \c variable=value format. For example:
  99. \verbatim
  100. bssid=02:00:01:02:03:04
  101. ssid=test network
  102. pairwise_cipher=CCMP
  103. group_cipher=CCMP
  104. key_mgmt=WPA-PSK
  105. wpa_state=COMPLETED
  106. ip_address=192.168.1.21
  107. Supplicant PAE state=AUTHENTICATED
  108. suppPortStatus=Authorized
  109. EAP state=SUCCESS
  110. \endverbatim
  111. \subsection ctrl_iface_STATUS-VERBOSE STATUS-VERBOSE
  112. Same as STATUS, but with more verbosity (i.e., more \c variable=value pairs).
  113. \verbatim
  114. bssid=02:00:01:02:03:04
  115. ssid=test network
  116. id=0
  117. pairwise_cipher=CCMP
  118. group_cipher=CCMP
  119. key_mgmt=WPA-PSK
  120. wpa_state=COMPLETED
  121. ip_address=192.168.1.21
  122. Supplicant PAE state=AUTHENTICATED
  123. suppPortStatus=Authorized
  124. heldPeriod=60
  125. authPeriod=30
  126. startPeriod=30
  127. maxStart=3
  128. portControl=Auto
  129. Supplicant Backend state=IDLE
  130. EAP state=SUCCESS
  131. reqMethod=0
  132. methodState=NONE
  133. decision=COND_SUCC
  134. ClientTimeout=60
  135. \endverbatim
  136. \subsection ctrl_iface_PMKSA PMKSA
  137. Show PMKSA cache
  138. \verbatim
  139. Index / AA / PMKID / expiration (in seconds) / opportunistic
  140. 1 / 02:00:01:02:03:04 / 000102030405060708090a0b0c0d0e0f / 41362 / 0
  141. 2 / 02:00:01:33:55:77 / 928389281928383b34afb34ba4212345 / 362 / 1
  142. \endverbatim
  143. \subsection ctrl_iface_SET SET <variable> <value>
  144. Set variables:
  145. - EAPOL::heldPeriod
  146. - EAPOL::authPeriod
  147. - EAPOL::startPeriod
  148. - EAPOL::maxStart
  149. - dot11RSNAConfigPMKLifetime
  150. - dot11RSNAConfigPMKReauthThreshold
  151. - dot11RSNAConfigSATimeout
  152. Example command:
  153. \verbatim
  154. SET EAPOL::heldPeriod 45
  155. \endverbatim
  156. \subsection ctrl_iface_LOGON LOGON
  157. IEEE 802.1X EAPOL state machine logon.
  158. \subsection ctrl_iface_LOGOFF LOGOFF
  159. IEEE 802.1X EAPOL state machine logoff.
  160. \subsection ctrl_iface_REASSOCIATE REASSOCIATE
  161. Force reassociation.
  162. \subsection ctrl_iface_RECONNECT RECONNECT
  163. Connect if disconnected (i.e., like \c REASSOCIATE, but only connect
  164. if in disconnected state).
  165. \subsection ctrl_iface_PREAUTH PREAUTH <BSSID>
  166. Start pre-authentication with the given BSSID.
  167. \subsection ctrl_iface_ATTACH ATTACH
  168. Attach the connection as a monitor for unsolicited events. This can
  169. be done with wpa_ctrl_attach().
  170. \subsection ctrl_iface_DETACH DETACH
  171. Detach the connection as a monitor for unsolicited events. This can
  172. be done with wpa_ctrl_detach().
  173. \subsection ctrl_iface_LEVEL LEVEL <debug level>
  174. Change debug level.
  175. \subsection ctrl_iface_RECONFIGURE RECONFIGURE
  176. Force %wpa_supplicant to re-read its configuration data.
  177. \subsection ctrl_iface_TERMINATE TERMINATE
  178. Terminate %wpa_supplicant process.
  179. \subsection ctrl_iface_BSSID BSSID <network id> <BSSID>
  180. Set preferred BSSID for a network. Network id can be received from the
  181. \c LIST_NETWORKS command output.
  182. \subsection ctrl_iface_LIST_NETWORKS LIST_NETWORKS
  183. List configured networks.
  184. \verbatim
  185. network id / ssid / bssid / flags
  186. 0 example network any [CURRENT]
  187. \endverbatim
  188. (note: fields are separated with tabs)
  189. \subsection ctrl_iface_DISCONNECT DISCONNECT
  190. Disconnect and wait for \c REASSOCIATE or \c RECONNECT command before
  191. connecting.
  192. \subsection ctrl_iface_SCAN SCAN
  193. Request a new BSS scan.
  194. \subsection ctrl_iface_SCAN_RESULTS SCAN_RESULTS
  195. Get the latest scan results.
  196. \verbatim
  197. bssid / frequency / signal level / flags / ssid
  198. 00:09:5b:95:e0:4e 2412 208 [WPA-PSK-CCMP] jkm private
  199. 02:55:24:33:77:a3 2462 187 [WPA-PSK-TKIP] testing
  200. 00:09:5b:95:e0:4f 2412 209 jkm guest
  201. \endverbatim
  202. (note: fields are separated with tabs)
  203. \subsection ctrl_iface_BSS BSS
  204. Get detailed per-BSS scan results. \c BSS command can be used to
  205. iterate through scan results one BSS at a time and to fetch all
  206. information from the found BSSes. This provides access to the same
  207. data that is available through \c SCAN_RESULTS but in a way that
  208. avoids problems with large number of scan results not fitting in the
  209. ctrl_iface messages.
  210. There are two options for selecting the BSS with the \c BSS command:
  211. "BSS <idx>" requests information for the BSS identified by the index
  212. (0 .. size-1) in the scan results table and "BSS <BSSID>" requests
  213. information for the given BSS (based on BSSID in 00:01:02:03:04:05
  214. format).
  215. BSS information is presented in following format. Please note that new
  216. fields may be added to this field=value data, so the ctrl_iface user
  217. should be prepared to ignore values it does not understand.
  218. \verbatim
  219. bssid=00:09:5b:95:e0:4e
  220. freq=2412
  221. beacon_int=0
  222. capabilities=0x0011
  223. qual=51
  224. noise=161
  225. level=212
  226. tsf=0000000000000000
  227. ie=000b6a6b6d2070726976617465010180dd180050f20101000050f20401000050f20401000050f2020000
  228. ssid=jkm private
  229. \endverbatim
  230. \subsection ctrl_iface_SELECT_NETWORK SELECT_NETWORK <network id>
  231. Select a network (disable others). Network id can be received from the
  232. \c LIST_NETWORKS command output.
  233. \subsection ctrl_iface_ENABLE_NETWORK ENABLE_NETWORK <network id>
  234. Enable a network. Network id can be received from the
  235. \c LIST_NETWORKS command output. Special network id \c all can be
  236. used to enable all network.
  237. \subsection ctrl_iface_DISABLE_NETWORK DISABLE_NETWORK <network id>
  238. Disable a network. Network id can be received from the
  239. \c LIST_NETWORKS command output. Special network id \c all can be
  240. used to disable all network.
  241. \subsection ctrl_iface_ADD_NETWORK ADD_NETWORK
  242. Add a new network. This command creates a new network with empty
  243. configuration. The new network is disabled and once it has been
  244. configured it can be enabled with \c ENABLE_NETWORK command. \c ADD_NETWORK
  245. returns the network id of the new network or FAIL on failure.
  246. \subsection ctrl_iface_REMOVE_NETWORK REMOVE_NETWORK <network id>
  247. Remove a network. Network id can be received from the
  248. \c LIST_NETWORKS command output. Special network id \c all can be
  249. used to remove all network.
  250. \subsection ctrl_iface_SET_NETWORK SET_NETWORK <network id> <variable> <value>
  251. Set network variables. Network id can be received from the
  252. \c LIST_NETWORKS command output.
  253. This command uses the same variables and data formats as the
  254. configuration file. See example wpa_supplicant.conf for more details.
  255. - ssid (network name, SSID)
  256. - psk (WPA passphrase or pre-shared key)
  257. - key_mgmt (key management protocol)
  258. - identity (EAP identity)
  259. - password (EAP password)
  260. - ...
  261. \subsection ctrl_iface_GET_NETWORK GET_NETWORK <network id> <variable>
  262. Get network variables. Network id can be received from the
  263. \c LIST_NETWORKS command output.
  264. \subsection ctrl_iface_SAVE_CONFIG SAVE_CONFIG
  265. Save the current configuration.
  266. \section ctrl_iface_interactive Interactive requests
  267. If %wpa_supplicant needs additional information during authentication
  268. (e.g., password), it will use a specific prefix, \c CTRL-REQ-
  269. (\a WPA_CTRL_REQ macro) in an unsolicited event message. An external
  270. program, e.g., a GUI, can provide such information by using
  271. \c CTRL-RSP- (\a WPA_CTRL_RSP macro) prefix in a command with matching
  272. field name.
  273. The following fields can be requested in this way from the user:
  274. - IDENTITY (EAP identity/user name)
  275. - PASSWORD (EAP password)
  276. - NEW_PASSWORD (New password if the server is requesting password change)
  277. - PIN (PIN code for accessing a SIM or smartcard)
  278. - OTP (one-time password; like password, but the value is used only once)
  279. - PASSPHRASE (passphrase for a private key file)
  280. \verbatim
  281. CTRL-REQ-<field name>-<network id>-<human readable text>
  282. CTRL-RSP-<field name>-<network id>-<value>
  283. \endverbatim
  284. For example, request from %wpa_supplicant:
  285. \verbatim
  286. CTRL-REQ-PASSWORD-1-Password needed for SSID test-network
  287. \endverbatim
  288. And a matching reply from the GUI:
  289. \verbatim
  290. CTRL-RSP-PASSWORD-1-secret
  291. \endverbatim
  292. \subsection ctrl_iface_GET_CAPABILITY GET_CAPABILITY <option> [strict]
  293. Get list of supported functionality (eap, pairwise, group,
  294. proto). Supported functionality is shown as space separate lists of
  295. values used in the same format as in %wpa_supplicant configuration.
  296. If optional argument, 'strict', is added, only the values that the
  297. driver claims to explicitly support are included. Without this, all
  298. available capabilities are included if the driver does not provide
  299. a mechanism for querying capabilities.
  300. Example request/reply pairs:
  301. \verbatim
  302. GET_CAPABILITY eap
  303. AKA FAST GTC LEAP MD5 MSCHAPV2 OTP PAX PEAP PSK SIM TLS TTLS
  304. \endverbatim
  305. \verbatim
  306. GET_CAPABILITY pairwise
  307. CCMP TKIP NONE
  308. \endverbatim
  309. \verbatim
  310. GET_CAPABILITY pairwise strict
  311. \endverbatim
  312. \verbatim
  313. GET_CAPABILITY group
  314. CCMP TKIP WEP104 WEP40
  315. \endverbatim
  316. \verbatim
  317. GET_CAPABILITY key_mgmt
  318. WPA-PSK WPA-EAP IEEE8021X NONE
  319. \endverbatim
  320. \verbatim
  321. GET_CAPABILITY proto
  322. RSN WPA
  323. \endverbatim
  324. \verbatim
  325. GET_CAPABILITY auth_alg
  326. OPEN SHARED LEAP
  327. \endverbatim
  328. \subsection ctrl_iface_AP_SCAN AP_SCAN <ap_scan value>
  329. Change ap_scan value:
  330. 0 = no scanning,
  331. 1 = %wpa_supplicant requests scans and uses scan results to select the AP,
  332. 2 = %wpa_supplicant does not use scanning and just requests driver to
  333. associate and take care of AP selection
  334. \subsection ctrl_iface_INTERFACES INTERFACES
  335. List configured interfaces.
  336. \verbatim
  337. wlan0
  338. eth0
  339. \endverbatim
  340. */