defs.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*
  2. * WPA Supplicant - Common definitions
  3. * Copyright (c) 2004-2015, 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. #define WPA_KEY_MGMT_IEEE8021X_SUITE_B BIT(16)
  48. #define WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 BIT(17)
  49. static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
  50. {
  51. return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
  52. WPA_KEY_MGMT_FT_IEEE8021X |
  53. WPA_KEY_MGMT_CCKM |
  54. WPA_KEY_MGMT_OSEN |
  55. WPA_KEY_MGMT_IEEE8021X_SHA256 |
  56. WPA_KEY_MGMT_IEEE8021X_SUITE_B |
  57. WPA_KEY_MGMT_IEEE8021X_SUITE_B_192));
  58. }
  59. static inline int wpa_key_mgmt_wpa_psk(int akm)
  60. {
  61. return !!(akm & (WPA_KEY_MGMT_PSK |
  62. WPA_KEY_MGMT_FT_PSK |
  63. WPA_KEY_MGMT_PSK_SHA256 |
  64. WPA_KEY_MGMT_SAE |
  65. WPA_KEY_MGMT_FT_SAE));
  66. }
  67. static inline int wpa_key_mgmt_ft(int akm)
  68. {
  69. return !!(akm & (WPA_KEY_MGMT_FT_PSK |
  70. WPA_KEY_MGMT_FT_IEEE8021X |
  71. WPA_KEY_MGMT_FT_SAE));
  72. }
  73. static inline int wpa_key_mgmt_sae(int akm)
  74. {
  75. return !!(akm & (WPA_KEY_MGMT_SAE |
  76. WPA_KEY_MGMT_FT_SAE));
  77. }
  78. static inline int wpa_key_mgmt_sha256(int akm)
  79. {
  80. return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
  81. WPA_KEY_MGMT_IEEE8021X_SHA256 |
  82. WPA_KEY_MGMT_OSEN |
  83. WPA_KEY_MGMT_IEEE8021X_SUITE_B));
  84. }
  85. static inline int wpa_key_mgmt_sha384(int akm)
  86. {
  87. return !!(akm & WPA_KEY_MGMT_IEEE8021X_SUITE_B_192);
  88. }
  89. static inline int wpa_key_mgmt_suite_b(int akm)
  90. {
  91. return !!(akm & (WPA_KEY_MGMT_IEEE8021X_SUITE_B |
  92. WPA_KEY_MGMT_IEEE8021X_SUITE_B_192));
  93. }
  94. static inline int wpa_key_mgmt_wpa(int akm)
  95. {
  96. return wpa_key_mgmt_wpa_ieee8021x(akm) ||
  97. wpa_key_mgmt_wpa_psk(akm) ||
  98. wpa_key_mgmt_sae(akm);
  99. }
  100. static inline int wpa_key_mgmt_wpa_any(int akm)
  101. {
  102. return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
  103. }
  104. static inline int wpa_key_mgmt_cckm(int akm)
  105. {
  106. return akm == WPA_KEY_MGMT_CCKM;
  107. }
  108. #define WPA_PROTO_WPA BIT(0)
  109. #define WPA_PROTO_RSN BIT(1)
  110. #define WPA_PROTO_WAPI BIT(2)
  111. #define WPA_PROTO_OSEN BIT(3)
  112. #define WPA_AUTH_ALG_OPEN BIT(0)
  113. #define WPA_AUTH_ALG_SHARED BIT(1)
  114. #define WPA_AUTH_ALG_LEAP BIT(2)
  115. #define WPA_AUTH_ALG_FT BIT(3)
  116. #define WPA_AUTH_ALG_SAE BIT(4)
  117. enum wpa_alg {
  118. WPA_ALG_NONE,
  119. WPA_ALG_WEP,
  120. WPA_ALG_TKIP,
  121. WPA_ALG_CCMP,
  122. WPA_ALG_IGTK,
  123. WPA_ALG_PMK,
  124. WPA_ALG_GCMP,
  125. WPA_ALG_SMS4,
  126. WPA_ALG_KRK,
  127. WPA_ALG_GCMP_256,
  128. WPA_ALG_CCMP_256,
  129. WPA_ALG_BIP_GMAC_128,
  130. WPA_ALG_BIP_GMAC_256,
  131. WPA_ALG_BIP_CMAC_256
  132. };
  133. /**
  134. * enum wpa_states - wpa_supplicant state
  135. *
  136. * These enumeration values are used to indicate the current wpa_supplicant
  137. * state (wpa_s->wpa_state). The current state can be retrieved with
  138. * wpa_supplicant_get_state() function and the state can be changed by calling
  139. * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
  140. * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
  141. * to access the state variable.
  142. */
  143. enum wpa_states {
  144. /**
  145. * WPA_DISCONNECTED - Disconnected state
  146. *
  147. * This state indicates that client is not associated, but is likely to
  148. * start looking for an access point. This state is entered when a
  149. * connection is lost.
  150. */
  151. WPA_DISCONNECTED,
  152. /**
  153. * WPA_INTERFACE_DISABLED - Interface disabled
  154. *
  155. * This state is entered if the network interface is disabled, e.g.,
  156. * due to rfkill. wpa_supplicant refuses any new operations that would
  157. * use the radio until the interface has been enabled.
  158. */
  159. WPA_INTERFACE_DISABLED,
  160. /**
  161. * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
  162. *
  163. * This state is entered if there are no enabled networks in the
  164. * configuration. wpa_supplicant is not trying to associate with a new
  165. * network and external interaction (e.g., ctrl_iface call to add or
  166. * enable a network) is needed to start association.
  167. */
  168. WPA_INACTIVE,
  169. /**
  170. * WPA_SCANNING - Scanning for a network
  171. *
  172. * This state is entered when wpa_supplicant starts scanning for a
  173. * network.
  174. */
  175. WPA_SCANNING,
  176. /**
  177. * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
  178. *
  179. * This state is entered when wpa_supplicant has found a suitable BSS
  180. * to authenticate with and the driver is configured to try to
  181. * authenticate with this BSS. This state is used only with drivers
  182. * that use wpa_supplicant as the SME.
  183. */
  184. WPA_AUTHENTICATING,
  185. /**
  186. * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
  187. *
  188. * This state is entered when wpa_supplicant has found a suitable BSS
  189. * to associate with and the driver is configured to try to associate
  190. * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
  191. * state is entered when the driver is configured to try to associate
  192. * with a network using the configured SSID and security policy.
  193. */
  194. WPA_ASSOCIATING,
  195. /**
  196. * WPA_ASSOCIATED - Association completed
  197. *
  198. * This state is entered when the driver reports that association has
  199. * been successfully completed with an AP. If IEEE 802.1X is used
  200. * (with or without WPA/WPA2), wpa_supplicant remains in this state
  201. * until the IEEE 802.1X/EAPOL authentication has been completed.
  202. */
  203. WPA_ASSOCIATED,
  204. /**
  205. * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
  206. *
  207. * This state is entered when WPA/WPA2 4-Way Handshake is started. In
  208. * case of WPA-PSK, this happens when receiving the first EAPOL-Key
  209. * frame after association. In case of WPA-EAP, this state is entered
  210. * when the IEEE 802.1X/EAPOL authentication has been completed.
  211. */
  212. WPA_4WAY_HANDSHAKE,
  213. /**
  214. * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
  215. *
  216. * This state is entered when 4-Way Key Handshake has been completed
  217. * (i.e., when the supplicant sends out message 4/4) and when Group
  218. * Key rekeying is started by the AP (i.e., when supplicant receives
  219. * message 1/2).
  220. */
  221. WPA_GROUP_HANDSHAKE,
  222. /**
  223. * WPA_COMPLETED - All authentication completed
  224. *
  225. * This state is entered when the full authentication process is
  226. * completed. In case of WPA2, this happens when the 4-Way Handshake is
  227. * successfully completed. With WPA, this state is entered after the
  228. * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
  229. * completed after dynamic keys are received (or if not used, after
  230. * the EAP authentication has been completed). With static WEP keys and
  231. * plaintext connections, this state is entered when an association
  232. * has been completed.
  233. *
  234. * This state indicates that the supplicant has completed its
  235. * processing for the association phase and that data connection is
  236. * fully configured.
  237. */
  238. WPA_COMPLETED
  239. };
  240. #define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
  241. #define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
  242. #define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
  243. #define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
  244. #define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
  245. #define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
  246. /**
  247. * enum mfp_options - Management frame protection (IEEE 802.11w) options
  248. */
  249. enum mfp_options {
  250. NO_MGMT_FRAME_PROTECTION = 0,
  251. MGMT_FRAME_PROTECTION_OPTIONAL = 1,
  252. MGMT_FRAME_PROTECTION_REQUIRED = 2,
  253. };
  254. #define MGMT_FRAME_PROTECTION_DEFAULT 3
  255. /**
  256. * enum hostapd_hw_mode - Hardware mode
  257. */
  258. enum hostapd_hw_mode {
  259. HOSTAPD_MODE_IEEE80211B,
  260. HOSTAPD_MODE_IEEE80211G,
  261. HOSTAPD_MODE_IEEE80211A,
  262. HOSTAPD_MODE_IEEE80211AD,
  263. HOSTAPD_MODE_IEEE80211ANY,
  264. NUM_HOSTAPD_MODES
  265. };
  266. /**
  267. * enum wpa_ctrl_req_type - Control interface request types
  268. */
  269. enum wpa_ctrl_req_type {
  270. WPA_CTRL_REQ_UNKNOWN,
  271. WPA_CTRL_REQ_EAP_IDENTITY,
  272. WPA_CTRL_REQ_EAP_PASSWORD,
  273. WPA_CTRL_REQ_EAP_NEW_PASSWORD,
  274. WPA_CTRL_REQ_EAP_PIN,
  275. WPA_CTRL_REQ_EAP_OTP,
  276. WPA_CTRL_REQ_EAP_PASSPHRASE,
  277. WPA_CTRL_REQ_SIM,
  278. WPA_CTRL_REQ_PSK_PASSPHRASE,
  279. WPA_CTRL_REQ_EXT_CERT_CHECK,
  280. NUM_WPA_CTRL_REQS
  281. };
  282. /* Maximum number of EAP methods to store for EAP server user information */
  283. #define EAP_MAX_METHODS 8
  284. enum mesh_plink_state {
  285. PLINK_IDLE = 1,
  286. PLINK_OPN_SNT,
  287. PLINK_OPN_RCVD,
  288. PLINK_CNF_RCVD,
  289. PLINK_ESTAB,
  290. PLINK_HOLDING,
  291. PLINK_BLOCKED, /* not defined in the IEEE 802.11 standard */
  292. };
  293. enum set_band {
  294. WPA_SETBAND_AUTO,
  295. WPA_SETBAND_5G,
  296. WPA_SETBAND_2G
  297. };
  298. enum wpa_radio_work_band {
  299. BAND_2_4_GHZ = BIT(0),
  300. BAND_5_GHZ = BIT(1),
  301. BAND_60_GHZ = BIT(2),
  302. };
  303. #endif /* DEFS_H */