defs.h 7.9 KB

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