defs.h 10 KB

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