defs.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*
  2. * WPA Supplicant - Common definitions
  3. * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef DEFS_H
  15. #define DEFS_H
  16. #ifdef FALSE
  17. #undef FALSE
  18. #endif
  19. #ifdef TRUE
  20. #undef TRUE
  21. #endif
  22. typedef enum { FALSE = 0, TRUE = 1 } Boolean;
  23. #define WPA_CIPHER_NONE BIT(0)
  24. #define WPA_CIPHER_WEP40 BIT(1)
  25. #define WPA_CIPHER_WEP104 BIT(2)
  26. #define WPA_CIPHER_TKIP BIT(3)
  27. #define WPA_CIPHER_CCMP BIT(4)
  28. #ifdef CONFIG_IEEE80211W
  29. #define WPA_CIPHER_AES_128_CMAC BIT(5)
  30. #endif /* CONFIG_IEEE80211W */
  31. #define WPA_KEY_MGMT_IEEE8021X BIT(0)
  32. #define WPA_KEY_MGMT_PSK BIT(1)
  33. #define WPA_KEY_MGMT_NONE BIT(2)
  34. #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
  35. #define WPA_KEY_MGMT_WPA_NONE BIT(4)
  36. #define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
  37. #define WPA_KEY_MGMT_FT_PSK BIT(6)
  38. #define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
  39. #define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
  40. #define WPA_KEY_MGMT_WPS BIT(9)
  41. static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
  42. {
  43. return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
  44. WPA_KEY_MGMT_FT_IEEE8021X |
  45. WPA_KEY_MGMT_IEEE8021X_SHA256));
  46. }
  47. static inline int wpa_key_mgmt_wpa_psk(int akm)
  48. {
  49. return !!(akm & (WPA_KEY_MGMT_PSK |
  50. WPA_KEY_MGMT_FT_PSK |
  51. WPA_KEY_MGMT_PSK_SHA256));
  52. }
  53. static inline int wpa_key_mgmt_ft(int akm)
  54. {
  55. return !!(akm & (WPA_KEY_MGMT_FT_PSK |
  56. WPA_KEY_MGMT_FT_IEEE8021X));
  57. }
  58. static inline int wpa_key_mgmt_sha256(int akm)
  59. {
  60. return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
  61. WPA_KEY_MGMT_IEEE8021X_SHA256));
  62. }
  63. static inline int wpa_key_mgmt_wpa(int akm)
  64. {
  65. return wpa_key_mgmt_wpa_ieee8021x(akm) ||
  66. wpa_key_mgmt_wpa_psk(akm);
  67. }
  68. #define WPA_PROTO_WPA BIT(0)
  69. #define WPA_PROTO_RSN BIT(1)
  70. #define WPA_AUTH_ALG_OPEN BIT(0)
  71. #define WPA_AUTH_ALG_SHARED BIT(1)
  72. #define WPA_AUTH_ALG_LEAP BIT(2)
  73. #define WPA_AUTH_ALG_FT BIT(3)
  74. enum wpa_alg {
  75. WPA_ALG_NONE,
  76. WPA_ALG_WEP,
  77. WPA_ALG_TKIP,
  78. WPA_ALG_CCMP,
  79. WPA_ALG_IGTK,
  80. WPA_ALG_PMK
  81. };
  82. /**
  83. * enum wpa_cipher - Cipher suites
  84. */
  85. enum wpa_cipher {
  86. CIPHER_NONE,
  87. CIPHER_WEP40,
  88. CIPHER_TKIP,
  89. CIPHER_CCMP,
  90. CIPHER_WEP104
  91. };
  92. /**
  93. * enum wpa_key_mgmt - Key management suites
  94. */
  95. enum wpa_key_mgmt {
  96. KEY_MGMT_802_1X,
  97. KEY_MGMT_PSK,
  98. KEY_MGMT_NONE,
  99. KEY_MGMT_802_1X_NO_WPA,
  100. KEY_MGMT_WPA_NONE,
  101. KEY_MGMT_FT_802_1X,
  102. KEY_MGMT_FT_PSK,
  103. KEY_MGMT_802_1X_SHA256,
  104. KEY_MGMT_PSK_SHA256,
  105. KEY_MGMT_WPS
  106. };
  107. /**
  108. * enum wpa_states - wpa_supplicant state
  109. *
  110. * These enumeration values are used to indicate the current wpa_supplicant
  111. * state (wpa_s->wpa_state). The current state can be retrieved with
  112. * wpa_supplicant_get_state() function and the state can be changed by calling
  113. * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
  114. * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
  115. * to access the state variable.
  116. */
  117. enum wpa_states {
  118. /**
  119. * WPA_DISCONNECTED - Disconnected state
  120. *
  121. * This state indicates that client is not associated, but is likely to
  122. * start looking for an access point. This state is entered when a
  123. * connection is lost.
  124. */
  125. WPA_DISCONNECTED,
  126. /**
  127. * WPA_INTERFACE_DISABLED - Interface disabled
  128. *
  129. * This stat eis entered if the network interface is disabled, e.g.,
  130. * due to rfkill. wpa_supplicant refuses any new operations that would
  131. * use the radio until the interface has been enabled.
  132. */
  133. WPA_INTERFACE_DISABLED,
  134. /**
  135. * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
  136. *
  137. * This state is entered if there are no enabled networks in the
  138. * configuration. wpa_supplicant is not trying to associate with a new
  139. * network and external interaction (e.g., ctrl_iface call to add or
  140. * enable a network) is needed to start association.
  141. */
  142. WPA_INACTIVE,
  143. /**
  144. * WPA_SCANNING - Scanning for a network
  145. *
  146. * This state is entered when wpa_supplicant starts scanning for a
  147. * network.
  148. */
  149. WPA_SCANNING,
  150. /**
  151. * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
  152. *
  153. * This state is entered when wpa_supplicant has found a suitable BSS
  154. * to authenticate with and the driver is configured to try to
  155. * authenticate with this BSS. This state is used only with drivers
  156. * that use wpa_supplicant as the SME.
  157. */
  158. WPA_AUTHENTICATING,
  159. /**
  160. * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
  161. *
  162. * This state is entered when wpa_supplicant has found a suitable BSS
  163. * to associate with and the driver is configured to try to associate
  164. * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
  165. * state is entered when the driver is configured to try to associate
  166. * with a network using the configured SSID and security policy.
  167. */
  168. WPA_ASSOCIATING,
  169. /**
  170. * WPA_ASSOCIATED - Association completed
  171. *
  172. * This state is entered when the driver reports that association has
  173. * been successfully completed with an AP. If IEEE 802.1X is used
  174. * (with or without WPA/WPA2), wpa_supplicant remains in this state
  175. * until the IEEE 802.1X/EAPOL authentication has been completed.
  176. */
  177. WPA_ASSOCIATED,
  178. /**
  179. * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
  180. *
  181. * This state is entered when WPA/WPA2 4-Way Handshake is started. In
  182. * case of WPA-PSK, this happens when receiving the first EAPOL-Key
  183. * frame after association. In case of WPA-EAP, this state is entered
  184. * when the IEEE 802.1X/EAPOL authentication has been completed.
  185. */
  186. WPA_4WAY_HANDSHAKE,
  187. /**
  188. * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
  189. *
  190. * This state is entered when 4-Way Key Handshake has been completed
  191. * (i.e., when the supplicant sends out message 4/4) and when Group
  192. * Key rekeying is started by the AP (i.e., when supplicant receives
  193. * message 1/2).
  194. */
  195. WPA_GROUP_HANDSHAKE,
  196. /**
  197. * WPA_COMPLETED - All authentication completed
  198. *
  199. * This state is entered when the full authentication process is
  200. * completed. In case of WPA2, this happens when the 4-Way Handshake is
  201. * successfully completed. With WPA, this state is entered after the
  202. * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
  203. * completed after dynamic keys are received (or if not used, after
  204. * the EAP authentication has been completed). With static WEP keys and
  205. * plaintext connections, this state is entered when an association
  206. * has been completed.
  207. *
  208. * This state indicates that the supplicant has completed its
  209. * processing for the association phase and that data connection is
  210. * fully configured.
  211. */
  212. WPA_COMPLETED
  213. };
  214. #define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
  215. #define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
  216. #define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
  217. #define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
  218. #define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
  219. #define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
  220. /**
  221. * enum mfp_options - Management frame protection (IEEE 802.11w) options
  222. */
  223. enum mfp_options {
  224. NO_MGMT_FRAME_PROTECTION = 0,
  225. MGMT_FRAME_PROTECTION_OPTIONAL = 1,
  226. MGMT_FRAME_PROTECTION_REQUIRED = 2
  227. };
  228. /**
  229. * enum hostapd_hw_mode - Hardware mode
  230. */
  231. enum hostapd_hw_mode {
  232. HOSTAPD_MODE_IEEE80211B,
  233. HOSTAPD_MODE_IEEE80211G,
  234. HOSTAPD_MODE_IEEE80211A,
  235. NUM_HOSTAPD_MODES
  236. };
  237. /**
  238. * enum wpa_ctrl_req_type - Control interface request types
  239. */
  240. enum wpa_ctrl_req_type {
  241. WPA_CTRL_REQ_UNKNOWN,
  242. WPA_CTRL_REQ_EAP_IDENTITY,
  243. WPA_CTRL_REQ_EAP_PASSWORD,
  244. WPA_CTRL_REQ_EAP_NEW_PASSWORD,
  245. WPA_CTRL_REQ_EAP_PIN,
  246. WPA_CTRL_REQ_EAP_OTP,
  247. WPA_CTRL_REQ_EAP_PASSPHRASE,
  248. NUM_WPA_CTRL_REQS
  249. };
  250. /* Maximum number of EAP methods to store for EAP server user information */
  251. #define EAP_MAX_METHODS 8
  252. #endif /* DEFS_H */