defs.h 8.2 KB

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