defs.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * WPA Supplicant - Common definitions
  3. * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef DEFS_H
  15. #define DEFS_H
  16. #ifdef FALSE
  17. #undef FALSE
  18. #endif
  19. #ifdef TRUE
  20. #undef TRUE
  21. #endif
  22. typedef enum { FALSE = 0, TRUE = 1 } Boolean;
  23. #define WPA_CIPHER_NONE BIT(0)
  24. #define WPA_CIPHER_WEP40 BIT(1)
  25. #define WPA_CIPHER_WEP104 BIT(2)
  26. #define WPA_CIPHER_TKIP BIT(3)
  27. #define WPA_CIPHER_CCMP BIT(4)
  28. #ifdef CONFIG_IEEE80211W
  29. #define WPA_CIPHER_AES_128_CMAC BIT(5)
  30. #endif /* CONFIG_IEEE80211W */
  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. static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
  42. {
  43. return akm == WPA_KEY_MGMT_IEEE8021X ||
  44. akm == WPA_KEY_MGMT_FT_IEEE8021X ||
  45. akm == WPA_KEY_MGMT_IEEE8021X_SHA256;
  46. }
  47. static inline int wpa_key_mgmt_wpa_psk(int akm)
  48. {
  49. return akm == WPA_KEY_MGMT_PSK ||
  50. akm == WPA_KEY_MGMT_FT_PSK ||
  51. akm == WPA_KEY_MGMT_PSK_SHA256;
  52. }
  53. static inline int wpa_key_mgmt_ft(int akm)
  54. {
  55. return akm == WPA_KEY_MGMT_FT_PSK ||
  56. akm == WPA_KEY_MGMT_FT_IEEE8021X;
  57. }
  58. static inline int wpa_key_mgmt_sha256(int akm)
  59. {
  60. return akm == WPA_KEY_MGMT_PSK_SHA256 ||
  61. akm == WPA_KEY_MGMT_IEEE8021X_SHA256;
  62. }
  63. #define WPA_PROTO_WPA BIT(0)
  64. #define WPA_PROTO_RSN BIT(1)
  65. #define WPA_AUTH_ALG_OPEN BIT(0)
  66. #define WPA_AUTH_ALG_SHARED BIT(1)
  67. #define WPA_AUTH_ALG_LEAP BIT(2)
  68. enum wpa_alg {
  69. WPA_ALG_NONE,
  70. WPA_ALG_WEP,
  71. WPA_ALG_TKIP,
  72. WPA_ALG_CCMP,
  73. WPA_ALG_IGTK,
  74. WPA_ALG_PMK
  75. };
  76. enum wpa_cipher {
  77. CIPHER_NONE,
  78. CIPHER_WEP40,
  79. CIPHER_TKIP,
  80. CIPHER_CCMP,
  81. CIPHER_WEP104
  82. };
  83. enum wpa_key_mgmt {
  84. KEY_MGMT_802_1X,
  85. KEY_MGMT_PSK,
  86. KEY_MGMT_NONE,
  87. KEY_MGMT_802_1X_NO_WPA,
  88. KEY_MGMT_WPA_NONE,
  89. KEY_MGMT_FT_802_1X,
  90. KEY_MGMT_FT_PSK,
  91. KEY_MGMT_802_1X_SHA256,
  92. KEY_MGMT_PSK_SHA256,
  93. KEY_MGMT_WPS
  94. };
  95. /**
  96. * enum wpa_states - wpa_supplicant state
  97. *
  98. * These enumeration values are used to indicate the current wpa_supplicant
  99. * state (wpa_s->wpa_state). The current state can be retrieved with
  100. * wpa_supplicant_get_state() function and the state can be changed by calling
  101. * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
  102. * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
  103. * to access the state variable.
  104. */
  105. enum wpa_states {
  106. /**
  107. * WPA_DISCONNECTED - Disconnected state
  108. *
  109. * This state indicates that client is not associated, but is likely to
  110. * start looking for an access point. This state is entered when a
  111. * connection is lost.
  112. */
  113. WPA_DISCONNECTED,
  114. /**
  115. * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
  116. *
  117. * This state is entered if there are no enabled networks in the
  118. * configuration. wpa_supplicant is not trying to associate with a new
  119. * network and external interaction (e.g., ctrl_iface call to add or
  120. * enable a network) is needed to start association.
  121. */
  122. WPA_INACTIVE,
  123. /**
  124. * WPA_SCANNING - Scanning for a network
  125. *
  126. * This state is entered when wpa_supplicant starts scanning for a
  127. * network.
  128. */
  129. WPA_SCANNING,
  130. /**
  131. * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
  132. *
  133. * This state is entered when wpa_supplicant has found a suitable BSS
  134. * to authenticate with and the driver is configured to try to
  135. * authenticate with this BSS. This state is used only with drivers
  136. * that use wpa_supplicant as the SME.
  137. */
  138. WPA_AUTHENTICATING,
  139. /**
  140. * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
  141. *
  142. * This state is entered when wpa_supplicant has found a suitable BSS
  143. * to associate with and the driver is configured to try to associate
  144. * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
  145. * state is entered when the driver is configured to try to associate
  146. * with a network using the configured SSID and security policy.
  147. */
  148. WPA_ASSOCIATING,
  149. /**
  150. * WPA_ASSOCIATED - Association completed
  151. *
  152. * This state is entered when the driver reports that association has
  153. * been successfully completed with an AP. If IEEE 802.1X is used
  154. * (with or without WPA/WPA2), wpa_supplicant remains in this state
  155. * until the IEEE 802.1X/EAPOL authentication has been completed.
  156. */
  157. WPA_ASSOCIATED,
  158. /**
  159. * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
  160. *
  161. * This state is entered when WPA/WPA2 4-Way Handshake is started. In
  162. * case of WPA-PSK, this happens when receiving the first EAPOL-Key
  163. * frame after association. In case of WPA-EAP, this state is entered
  164. * when the IEEE 802.1X/EAPOL authentication has been completed.
  165. */
  166. WPA_4WAY_HANDSHAKE,
  167. /**
  168. * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
  169. *
  170. * This state is entered when 4-Way Key Handshake has been completed
  171. * (i.e., when the supplicant sends out message 4/4) and when Group
  172. * Key rekeying is started by the AP (i.e., when supplicant receives
  173. * message 1/2).
  174. */
  175. WPA_GROUP_HANDSHAKE,
  176. /**
  177. * WPA_COMPLETED - All authentication completed
  178. *
  179. * This state is entered when the full authentication process is
  180. * completed. In case of WPA2, this happens when the 4-Way Handshake is
  181. * successfully completed. With WPA, this state is entered after the
  182. * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
  183. * completed after dynamic keys are received (or if not used, after
  184. * the EAP authentication has been completed). With static WEP keys and
  185. * plaintext connections, this state is entered when an association
  186. * has been completed.
  187. *
  188. * This state indicates that the supplicant has completed its
  189. * processing for the association phase and that data connection is
  190. * fully configured.
  191. */
  192. WPA_COMPLETED
  193. };
  194. #define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
  195. #define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
  196. #define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
  197. #define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
  198. #define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
  199. #define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
  200. enum mfp_options {
  201. NO_IEEE80211W = 0,
  202. IEEE80211W_OPTIONAL = 1,
  203. IEEE80211W_REQUIRED = 2
  204. };
  205. enum hostapd_hw_mode {
  206. HOSTAPD_MODE_IEEE80211B,
  207. HOSTAPD_MODE_IEEE80211G,
  208. HOSTAPD_MODE_IEEE80211A,
  209. NUM_HOSTAPD_MODES
  210. };
  211. #endif /* DEFS_H */