wpa_ctrl.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /*
  2. * wpa_supplicant/hostapd control interface library
  3. * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef WPA_CTRL_H
  9. #define WPA_CTRL_H
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /* wpa_supplicant control interface - fixed message prefixes */
  14. /** Interactive request for identity/password/pin */
  15. #define WPA_CTRL_REQ "CTRL-REQ-"
  16. /** Response to identity/password/pin request */
  17. #define WPA_CTRL_RSP "CTRL-RSP-"
  18. /* Event messages with fixed prefix */
  19. /** Authentication completed successfully and data connection enabled */
  20. #define WPA_EVENT_CONNECTED "CTRL-EVENT-CONNECTED "
  21. /** Disconnected, data connection is not available */
  22. #define WPA_EVENT_DISCONNECTED "CTRL-EVENT-DISCONNECTED "
  23. /** Association rejected during connection attempt */
  24. #define WPA_EVENT_ASSOC_REJECT "CTRL-EVENT-ASSOC-REJECT "
  25. /** wpa_supplicant is exiting */
  26. #define WPA_EVENT_TERMINATING "CTRL-EVENT-TERMINATING "
  27. /** Password change was completed successfully */
  28. #define WPA_EVENT_PASSWORD_CHANGED "CTRL-EVENT-PASSWORD-CHANGED "
  29. /** EAP-Request/Notification received */
  30. #define WPA_EVENT_EAP_NOTIFICATION "CTRL-EVENT-EAP-NOTIFICATION "
  31. /** EAP authentication started (EAP-Request/Identity received) */
  32. #define WPA_EVENT_EAP_STARTED "CTRL-EVENT-EAP-STARTED "
  33. /** EAP method proposed by the server */
  34. #define WPA_EVENT_EAP_PROPOSED_METHOD "CTRL-EVENT-EAP-PROPOSED-METHOD "
  35. /** EAP method selected */
  36. #define WPA_EVENT_EAP_METHOD "CTRL-EVENT-EAP-METHOD "
  37. /** EAP peer certificate from TLS */
  38. #define WPA_EVENT_EAP_PEER_CERT "CTRL-EVENT-EAP-PEER-CERT "
  39. /** EAP peer certificate alternative subject name component from TLS */
  40. #define WPA_EVENT_EAP_PEER_ALT "CTRL-EVENT-EAP-PEER-ALT "
  41. /** EAP TLS certificate chain validation error */
  42. #define WPA_EVENT_EAP_TLS_CERT_ERROR "CTRL-EVENT-EAP-TLS-CERT-ERROR "
  43. /** EAP status */
  44. #define WPA_EVENT_EAP_STATUS "CTRL-EVENT-EAP-STATUS "
  45. /** EAP authentication completed successfully */
  46. #define WPA_EVENT_EAP_SUCCESS "CTRL-EVENT-EAP-SUCCESS "
  47. /** EAP authentication failed (EAP-Failure received) */
  48. #define WPA_EVENT_EAP_FAILURE "CTRL-EVENT-EAP-FAILURE "
  49. /** Network block temporarily disabled (e.g., due to authentication failure) */
  50. #define WPA_EVENT_TEMP_DISABLED "CTRL-EVENT-SSID-TEMP-DISABLED "
  51. /** Temporarily disabled network block re-enabled */
  52. #define WPA_EVENT_REENABLED "CTRL-EVENT-SSID-REENABLED "
  53. /** New scan started */
  54. #define WPA_EVENT_SCAN_STARTED "CTRL-EVENT-SCAN-STARTED "
  55. /** New scan results available */
  56. #define WPA_EVENT_SCAN_RESULTS "CTRL-EVENT-SCAN-RESULTS "
  57. /** Scan command failed */
  58. #define WPA_EVENT_SCAN_FAILED "CTRL-EVENT-SCAN-FAILED "
  59. /** wpa_supplicant state change */
  60. #define WPA_EVENT_STATE_CHANGE "CTRL-EVENT-STATE-CHANGE "
  61. /** A new BSS entry was added (followed by BSS entry id and BSSID) */
  62. #define WPA_EVENT_BSS_ADDED "CTRL-EVENT-BSS-ADDED "
  63. /** A BSS entry was removed (followed by BSS entry id and BSSID) */
  64. #define WPA_EVENT_BSS_REMOVED "CTRL-EVENT-BSS-REMOVED "
  65. /** Change in the signal level was reported by the driver */
  66. #define WPA_EVENT_SIGNAL_CHANGE "CTRL-EVENT-SIGNAL-CHANGE "
  67. /** Regulatory domain channel */
  68. #define WPA_EVENT_REGDOM_CHANGE "CTRL-EVENT-REGDOM-CHANGE "
  69. /** RSN IBSS 4-way handshakes completed with specified peer */
  70. #define IBSS_RSN_COMPLETED "IBSS-RSN-COMPLETED "
  71. /** Notification of frequency conflict due to a concurrent operation.
  72. *
  73. * The indicated network is disabled and needs to be re-enabled before it can
  74. * be used again.
  75. */
  76. #define WPA_EVENT_FREQ_CONFLICT "CTRL-EVENT-FREQ-CONFLICT "
  77. /** Frequency ranges that the driver recommends to avoid */
  78. #define WPA_EVENT_AVOID_FREQ "CTRL-EVENT-AVOID-FREQ "
  79. /** WPS overlap detected in PBC mode */
  80. #define WPS_EVENT_OVERLAP "WPS-OVERLAP-DETECTED "
  81. /** Available WPS AP with active PBC found in scan results */
  82. #define WPS_EVENT_AP_AVAILABLE_PBC "WPS-AP-AVAILABLE-PBC "
  83. /** Available WPS AP with our address as authorized in scan results */
  84. #define WPS_EVENT_AP_AVAILABLE_AUTH "WPS-AP-AVAILABLE-AUTH "
  85. /** Available WPS AP with recently selected PIN registrar found in scan results
  86. */
  87. #define WPS_EVENT_AP_AVAILABLE_PIN "WPS-AP-AVAILABLE-PIN "
  88. /** Available WPS AP found in scan results */
  89. #define WPS_EVENT_AP_AVAILABLE "WPS-AP-AVAILABLE "
  90. /** A new credential received */
  91. #define WPS_EVENT_CRED_RECEIVED "WPS-CRED-RECEIVED "
  92. /** M2D received */
  93. #define WPS_EVENT_M2D "WPS-M2D "
  94. /** WPS registration failed after M2/M2D */
  95. #define WPS_EVENT_FAIL "WPS-FAIL "
  96. /** WPS registration completed successfully */
  97. #define WPS_EVENT_SUCCESS "WPS-SUCCESS "
  98. /** WPS enrollment attempt timed out and was terminated */
  99. #define WPS_EVENT_TIMEOUT "WPS-TIMEOUT "
  100. /* PBC mode was activated */
  101. #define WPS_EVENT_ACTIVE "WPS-PBC-ACTIVE "
  102. /* PBC mode was disabled */
  103. #define WPS_EVENT_DISABLE "WPS-PBC-DISABLE "
  104. #define WPS_EVENT_ENROLLEE_SEEN "WPS-ENROLLEE-SEEN "
  105. #define WPS_EVENT_OPEN_NETWORK "WPS-OPEN-NETWORK "
  106. /* WPS ER events */
  107. #define WPS_EVENT_ER_AP_ADD "WPS-ER-AP-ADD "
  108. #define WPS_EVENT_ER_AP_REMOVE "WPS-ER-AP-REMOVE "
  109. #define WPS_EVENT_ER_ENROLLEE_ADD "WPS-ER-ENROLLEE-ADD "
  110. #define WPS_EVENT_ER_ENROLLEE_REMOVE "WPS-ER-ENROLLEE-REMOVE "
  111. #define WPS_EVENT_ER_AP_SETTINGS "WPS-ER-AP-SETTINGS "
  112. #define WPS_EVENT_ER_SET_SEL_REG "WPS-ER-AP-SET-SEL-REG "
  113. /* MESH events */
  114. #define MESH_GROUP_STARTED "MESH-GROUP-STARTED "
  115. #define MESH_GROUP_REMOVED "MESH-GROUP-REMOVED "
  116. #define MESH_PEER_CONNECTED "MESH-PEER-CONNECTED "
  117. #define MESH_PEER_DISCONNECTED "MESH-PEER-DISCONNECTED "
  118. /** Mesh SAE authentication failure. Wrong password suspected. */
  119. #define MESH_SAE_AUTH_FAILURE "MESH-SAE-AUTH-FAILURE "
  120. #define MESH_SAE_AUTH_BLOCKED "MESH-SAE-AUTH-BLOCKED "
  121. /* WMM AC events */
  122. #define WMM_AC_EVENT_TSPEC_ADDED "TSPEC-ADDED "
  123. #define WMM_AC_EVENT_TSPEC_REMOVED "TSPEC-REMOVED "
  124. #define WMM_AC_EVENT_TSPEC_REQ_FAILED "TSPEC-REQ-FAILED "
  125. /** P2P device found */
  126. #define P2P_EVENT_DEVICE_FOUND "P2P-DEVICE-FOUND "
  127. /** P2P device lost */
  128. #define P2P_EVENT_DEVICE_LOST "P2P-DEVICE-LOST "
  129. /** A P2P device requested GO negotiation, but we were not ready to start the
  130. * negotiation */
  131. #define P2P_EVENT_GO_NEG_REQUEST "P2P-GO-NEG-REQUEST "
  132. #define P2P_EVENT_GO_NEG_SUCCESS "P2P-GO-NEG-SUCCESS "
  133. #define P2P_EVENT_GO_NEG_FAILURE "P2P-GO-NEG-FAILURE "
  134. #define P2P_EVENT_GROUP_FORMATION_SUCCESS "P2P-GROUP-FORMATION-SUCCESS "
  135. #define P2P_EVENT_GROUP_FORMATION_FAILURE "P2P-GROUP-FORMATION-FAILURE "
  136. #define P2P_EVENT_GROUP_STARTED "P2P-GROUP-STARTED "
  137. #define P2P_EVENT_GROUP_REMOVED "P2P-GROUP-REMOVED "
  138. #define P2P_EVENT_CROSS_CONNECT_ENABLE "P2P-CROSS-CONNECT-ENABLE "
  139. #define P2P_EVENT_CROSS_CONNECT_DISABLE "P2P-CROSS-CONNECT-DISABLE "
  140. /* parameters: <peer address> <PIN> */
  141. #define P2P_EVENT_PROV_DISC_SHOW_PIN "P2P-PROV-DISC-SHOW-PIN "
  142. /* parameters: <peer address> */
  143. #define P2P_EVENT_PROV_DISC_ENTER_PIN "P2P-PROV-DISC-ENTER-PIN "
  144. /* parameters: <peer address> */
  145. #define P2P_EVENT_PROV_DISC_PBC_REQ "P2P-PROV-DISC-PBC-REQ "
  146. /* parameters: <peer address> */
  147. #define P2P_EVENT_PROV_DISC_PBC_RESP "P2P-PROV-DISC-PBC-RESP "
  148. /* parameters: <peer address> <status> */
  149. #define P2P_EVENT_PROV_DISC_FAILURE "P2P-PROV-DISC-FAILURE"
  150. /* parameters: <freq> <src addr> <dialog token> <update indicator> <TLVs> */
  151. #define P2P_EVENT_SERV_DISC_REQ "P2P-SERV-DISC-REQ "
  152. /* parameters: <src addr> <update indicator> <TLVs> */
  153. #define P2P_EVENT_SERV_DISC_RESP "P2P-SERV-DISC-RESP "
  154. #define P2P_EVENT_SERV_ASP_RESP "P2P-SERV-ASP-RESP "
  155. #define P2P_EVENT_INVITATION_RECEIVED "P2P-INVITATION-RECEIVED "
  156. #define P2P_EVENT_INVITATION_RESULT "P2P-INVITATION-RESULT "
  157. #define P2P_EVENT_FIND_STOPPED "P2P-FIND-STOPPED "
  158. #define P2P_EVENT_PERSISTENT_PSK_FAIL "P2P-PERSISTENT-PSK-FAIL id="
  159. #define P2P_EVENT_PRESENCE_RESPONSE "P2P-PRESENCE-RESPONSE "
  160. #define P2P_EVENT_NFC_BOTH_GO "P2P-NFC-BOTH-GO "
  161. #define P2P_EVENT_NFC_PEER_CLIENT "P2P-NFC-PEER-CLIENT "
  162. #define P2P_EVENT_NFC_WHILE_CLIENT "P2P-NFC-WHILE-CLIENT "
  163. #define P2P_EVENT_FALLBACK_TO_GO_NEG "P2P-FALLBACK-TO-GO-NEG "
  164. #define P2P_EVENT_FALLBACK_TO_GO_NEG_ENABLED "P2P-FALLBACK-TO-GO-NEG-ENABLED "
  165. /* parameters: <PMF enabled> <timeout in ms> <Session Information URL> */
  166. #define ESS_DISASSOC_IMMINENT "ESS-DISASSOC-IMMINENT "
  167. #define P2P_EVENT_REMOVE_AND_REFORM_GROUP "P2P-REMOVE-AND-REFORM-GROUP "
  168. #define P2P_EVENT_P2PS_PROVISION_START "P2PS-PROV-START "
  169. #define P2P_EVENT_P2PS_PROVISION_DONE "P2PS-PROV-DONE "
  170. #define INTERWORKING_AP "INTERWORKING-AP "
  171. #define INTERWORKING_BLACKLISTED "INTERWORKING-BLACKLISTED "
  172. #define INTERWORKING_NO_MATCH "INTERWORKING-NO-MATCH "
  173. #define INTERWORKING_ALREADY_CONNECTED "INTERWORKING-ALREADY-CONNECTED "
  174. #define INTERWORKING_SELECTED "INTERWORKING-SELECTED "
  175. /* Credential block added; parameters: <id> */
  176. #define CRED_ADDED "CRED-ADDED "
  177. /* Credential block modified; parameters: <id> <field> */
  178. #define CRED_MODIFIED "CRED-MODIFIED "
  179. /* Credential block removed; parameters: <id> */
  180. #define CRED_REMOVED "CRED-REMOVED "
  181. #define GAS_RESPONSE_INFO "GAS-RESPONSE-INFO "
  182. /* parameters: <addr> <dialog_token> <freq> */
  183. #define GAS_QUERY_START "GAS-QUERY-START "
  184. /* parameters: <addr> <dialog_token> <freq> <status_code> <result> */
  185. #define GAS_QUERY_DONE "GAS-QUERY-DONE "
  186. /* parameters: <addr> <result> */
  187. #define ANQP_QUERY_DONE "ANQP-QUERY-DONE "
  188. #define HS20_SUBSCRIPTION_REMEDIATION "HS20-SUBSCRIPTION-REMEDIATION "
  189. #define HS20_DEAUTH_IMMINENT_NOTICE "HS20-DEAUTH-IMMINENT-NOTICE "
  190. #define EXT_RADIO_WORK_START "EXT-RADIO-WORK-START "
  191. #define EXT_RADIO_WORK_TIMEOUT "EXT-RADIO-WORK-TIMEOUT "
  192. #define RRM_EVENT_NEIGHBOR_REP_RXED "RRM-NEIGHBOR-REP-RECEIVED "
  193. #define RRM_EVENT_NEIGHBOR_REP_FAILED "RRM-NEIGHBOR-REP-REQUEST-FAILED "
  194. /* hostapd control interface - fixed message prefixes */
  195. #define WPS_EVENT_PIN_NEEDED "WPS-PIN-NEEDED "
  196. #define WPS_EVENT_NEW_AP_SETTINGS "WPS-NEW-AP-SETTINGS "
  197. #define WPS_EVENT_REG_SUCCESS "WPS-REG-SUCCESS "
  198. #define WPS_EVENT_AP_SETUP_LOCKED "WPS-AP-SETUP-LOCKED "
  199. #define WPS_EVENT_AP_SETUP_UNLOCKED "WPS-AP-SETUP-UNLOCKED "
  200. #define WPS_EVENT_AP_PIN_ENABLED "WPS-AP-PIN-ENABLED "
  201. #define WPS_EVENT_AP_PIN_DISABLED "WPS-AP-PIN-DISABLED "
  202. #define AP_STA_CONNECTED "AP-STA-CONNECTED "
  203. #define AP_STA_DISCONNECTED "AP-STA-DISCONNECTED "
  204. #define AP_REJECTED_MAX_STA "AP-REJECTED-MAX-STA "
  205. #define AP_REJECTED_BLOCKED_STA "AP-REJECTED-BLOCKED-STA "
  206. #define AP_EVENT_ENABLED "AP-ENABLED "
  207. #define AP_EVENT_DISABLED "AP-DISABLED "
  208. #define INTERFACE_ENABLED "INTERFACE-ENABLED "
  209. #define INTERFACE_DISABLED "INTERFACE-DISABLED "
  210. #define ACS_EVENT_STARTED "ACS-STARTED "
  211. #define ACS_EVENT_COMPLETED "ACS-COMPLETED "
  212. #define ACS_EVENT_FAILED "ACS-FAILED "
  213. #define DFS_EVENT_RADAR_DETECTED "DFS-RADAR-DETECTED "
  214. #define DFS_EVENT_NEW_CHANNEL "DFS-NEW-CHANNEL "
  215. #define DFS_EVENT_CAC_START "DFS-CAC-START "
  216. #define DFS_EVENT_CAC_COMPLETED "DFS-CAC-COMPLETED "
  217. #define DFS_EVENT_NOP_FINISHED "DFS-NOP-FINISHED "
  218. #define AP_CSA_FINISHED "AP-CSA-FINISHED "
  219. /* BSS Transition Management Response frame received */
  220. #define BSS_TM_RESP "BSS-TM-RESP "
  221. /* BSS command information masks */
  222. #define WPA_BSS_MASK_ALL 0xFFFDFFFF
  223. #define WPA_BSS_MASK_ID BIT(0)
  224. #define WPA_BSS_MASK_BSSID BIT(1)
  225. #define WPA_BSS_MASK_FREQ BIT(2)
  226. #define WPA_BSS_MASK_BEACON_INT BIT(3)
  227. #define WPA_BSS_MASK_CAPABILITIES BIT(4)
  228. #define WPA_BSS_MASK_QUAL BIT(5)
  229. #define WPA_BSS_MASK_NOISE BIT(6)
  230. #define WPA_BSS_MASK_LEVEL BIT(7)
  231. #define WPA_BSS_MASK_TSF BIT(8)
  232. #define WPA_BSS_MASK_AGE BIT(9)
  233. #define WPA_BSS_MASK_IE BIT(10)
  234. #define WPA_BSS_MASK_FLAGS BIT(11)
  235. #define WPA_BSS_MASK_SSID BIT(12)
  236. #define WPA_BSS_MASK_WPS_SCAN BIT(13)
  237. #define WPA_BSS_MASK_P2P_SCAN BIT(14)
  238. #define WPA_BSS_MASK_INTERNETW BIT(15)
  239. #define WPA_BSS_MASK_WIFI_DISPLAY BIT(16)
  240. #define WPA_BSS_MASK_DELIM BIT(17)
  241. #define WPA_BSS_MASK_MESH_SCAN BIT(18)
  242. /* VENDOR_ELEM_* frame id values */
  243. enum wpa_vendor_elem_frame {
  244. VENDOR_ELEM_PROBE_REQ_P2P = 0,
  245. VENDOR_ELEM_PROBE_RESP_P2P = 1,
  246. VENDOR_ELEM_PROBE_RESP_P2P_GO = 2,
  247. VENDOR_ELEM_BEACON_P2P_GO = 3,
  248. VENDOR_ELEM_P2P_PD_REQ = 4,
  249. VENDOR_ELEM_P2P_PD_RESP = 5,
  250. VENDOR_ELEM_P2P_GO_NEG_REQ = 6,
  251. VENDOR_ELEM_P2P_GO_NEG_RESP = 7,
  252. VENDOR_ELEM_P2P_GO_NEG_CONF = 8,
  253. VENDOR_ELEM_P2P_INV_REQ = 9,
  254. VENDOR_ELEM_P2P_INV_RESP = 10,
  255. VENDOR_ELEM_P2P_ASSOC_REQ = 11,
  256. VENDOR_ELEM_P2P_ASSOC_RESP = 12,
  257. VENDOR_ELEM_ASSOC_REQ = 13,
  258. NUM_VENDOR_ELEM_FRAMES
  259. };
  260. /* wpa_supplicant/hostapd control interface access */
  261. /**
  262. * wpa_ctrl_open - Open a control interface to wpa_supplicant/hostapd
  263. * @ctrl_path: Path for UNIX domain sockets; ignored if UDP sockets are used.
  264. * Returns: Pointer to abstract control interface data or %NULL on failure
  265. *
  266. * This function is used to open a control interface to wpa_supplicant/hostapd.
  267. * ctrl_path is usually /var/run/wpa_supplicant or /var/run/hostapd. This path
  268. * is configured in wpa_supplicant/hostapd and other programs using the control
  269. * interface need to use matching path configuration.
  270. */
  271. struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path);
  272. /**
  273. * wpa_ctrl_close - Close a control interface to wpa_supplicant/hostapd
  274. * @ctrl: Control interface data from wpa_ctrl_open()
  275. *
  276. * This function is used to close a control interface.
  277. */
  278. void wpa_ctrl_close(struct wpa_ctrl *ctrl);
  279. /**
  280. * wpa_ctrl_request - Send a command to wpa_supplicant/hostapd
  281. * @ctrl: Control interface data from wpa_ctrl_open()
  282. * @cmd: Command; usually, ASCII text, e.g., "PING"
  283. * @cmd_len: Length of the cmd in bytes
  284. * @reply: Buffer for the response
  285. * @reply_len: Reply buffer length
  286. * @msg_cb: Callback function for unsolicited messages or %NULL if not used
  287. * Returns: 0 on success, -1 on error (send or receive failed), -2 on timeout
  288. *
  289. * This function is used to send commands to wpa_supplicant/hostapd. Received
  290. * response will be written to reply and reply_len is set to the actual length
  291. * of the reply. This function will block for up to two seconds while waiting
  292. * for the reply. If unsolicited messages are received, the blocking time may
  293. * be longer.
  294. *
  295. * msg_cb can be used to register a callback function that will be called for
  296. * unsolicited messages received while waiting for the command response. These
  297. * messages may be received if wpa_ctrl_request() is called at the same time as
  298. * wpa_supplicant/hostapd is sending such a message. This can happen only if
  299. * the program has used wpa_ctrl_attach() to register itself as a monitor for
  300. * event messages. Alternatively to msg_cb, programs can register two control
  301. * interface connections and use one of them for commands and the other one for
  302. * receiving event messages, in other words, call wpa_ctrl_attach() only for
  303. * the control interface connection that will be used for event messages.
  304. */
  305. int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len,
  306. char *reply, size_t *reply_len,
  307. void (*msg_cb)(char *msg, size_t len));
  308. /**
  309. * wpa_ctrl_attach - Register as an event monitor for the control interface
  310. * @ctrl: Control interface data from wpa_ctrl_open()
  311. * Returns: 0 on success, -1 on failure, -2 on timeout
  312. *
  313. * This function registers the control interface connection as a monitor for
  314. * wpa_supplicant/hostapd events. After a success wpa_ctrl_attach() call, the
  315. * control interface connection starts receiving event messages that can be
  316. * read with wpa_ctrl_recv().
  317. */
  318. int wpa_ctrl_attach(struct wpa_ctrl *ctrl);
  319. /**
  320. * wpa_ctrl_detach - Unregister event monitor from the control interface
  321. * @ctrl: Control interface data from wpa_ctrl_open()
  322. * Returns: 0 on success, -1 on failure, -2 on timeout
  323. *
  324. * This function unregisters the control interface connection as a monitor for
  325. * wpa_supplicant/hostapd events, i.e., cancels the registration done with
  326. * wpa_ctrl_attach().
  327. */
  328. int wpa_ctrl_detach(struct wpa_ctrl *ctrl);
  329. /**
  330. * wpa_ctrl_recv - Receive a pending control interface message
  331. * @ctrl: Control interface data from wpa_ctrl_open()
  332. * @reply: Buffer for the message data
  333. * @reply_len: Length of the reply buffer
  334. * Returns: 0 on success, -1 on failure
  335. *
  336. * This function will receive a pending control interface message. The received
  337. * response will be written to reply and reply_len is set to the actual length
  338. * of the reply.
  339. * wpa_ctrl_recv() is only used for event messages, i.e., wpa_ctrl_attach()
  340. * must have been used to register the control interface as an event monitor.
  341. */
  342. int wpa_ctrl_recv(struct wpa_ctrl *ctrl, char *reply, size_t *reply_len);
  343. /**
  344. * wpa_ctrl_pending - Check whether there are pending event messages
  345. * @ctrl: Control interface data from wpa_ctrl_open()
  346. * Returns: 1 if there are pending messages, 0 if no, or -1 on error
  347. *
  348. * This function will check whether there are any pending control interface
  349. * message available to be received with wpa_ctrl_recv(). wpa_ctrl_pending() is
  350. * only used for event messages, i.e., wpa_ctrl_attach() must have been used to
  351. * register the control interface as an event monitor.
  352. */
  353. int wpa_ctrl_pending(struct wpa_ctrl *ctrl);
  354. /**
  355. * wpa_ctrl_get_fd - Get file descriptor used by the control interface
  356. * @ctrl: Control interface data from wpa_ctrl_open()
  357. * Returns: File descriptor used for the connection
  358. *
  359. * This function can be used to get the file descriptor that is used for the
  360. * control interface connection. The returned value can be used, e.g., with
  361. * select() while waiting for multiple events.
  362. *
  363. * The returned file descriptor must not be used directly for sending or
  364. * receiving packets; instead, the library functions wpa_ctrl_request() and
  365. * wpa_ctrl_recv() must be used for this.
  366. */
  367. int wpa_ctrl_get_fd(struct wpa_ctrl *ctrl);
  368. #ifdef ANDROID
  369. /**
  370. * wpa_ctrl_cleanup() - Delete any local UNIX domain socket files that
  371. * may be left over from clients that were previously connected to
  372. * wpa_supplicant. This keeps these files from being orphaned in the
  373. * event of crashes that prevented them from being removed as part
  374. * of the normal orderly shutdown.
  375. */
  376. void wpa_ctrl_cleanup(void);
  377. #endif /* ANDROID */
  378. #ifdef CONFIG_CTRL_IFACE_UDP
  379. /* Port range for multiple wpa_supplicant instances and multiple VIFs */
  380. #define WPA_CTRL_IFACE_PORT 9877
  381. #define WPA_CTRL_IFACE_PORT_LIMIT 50 /* decremented from start */
  382. #define WPA_GLOBAL_CTRL_IFACE_PORT 9878
  383. #define WPA_GLOBAL_CTRL_IFACE_PORT_LIMIT 20 /* incremented from start */
  384. char * wpa_ctrl_get_remote_ifname(struct wpa_ctrl *ctrl);
  385. #endif /* CONFIG_CTRL_IFACE_UDP */
  386. #ifdef __cplusplus
  387. }
  388. #endif
  389. #endif /* WPA_CTRL_H */