defs.h 8.2 KB

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