00001
00016 #ifndef IEEE802_11_H
00017 #define IEEE802_11_H
00018
00019
00020
00021 #define WLAN_FC_PVER (BIT(1) | BIT(0))
00022 #define WLAN_FC_TODS BIT(8)
00023 #define WLAN_FC_FROMDS BIT(9)
00024 #define WLAN_FC_MOREFRAG BIT(10)
00025 #define WLAN_FC_RETRY BIT(11)
00026 #define WLAN_FC_PWRMGT BIT(12)
00027 #define WLAN_FC_MOREDATA BIT(13)
00028 #define WLAN_FC_ISWEP BIT(14)
00029 #define WLAN_FC_ORDER BIT(15)
00030
00031 #define WLAN_FC_GET_TYPE(fc) (((fc) & (BIT(3) | BIT(2))) >> 2)
00032 #define WLAN_FC_GET_STYPE(fc) \
00033 (((fc) & (BIT(7) | BIT(6) | BIT(5) | BIT(4))) >> 4)
00034
00035 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
00036 #define WLAN_GET_SEQ_SEQ(seq) \
00037 (((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
00038
00039 #define WLAN_FC_TYPE_MGMT 0
00040 #define WLAN_FC_TYPE_CTRL 1
00041 #define WLAN_FC_TYPE_DATA 2
00042
00043
00044 #define WLAN_FC_STYPE_ASSOC_REQ 0
00045 #define WLAN_FC_STYPE_ASSOC_RESP 1
00046 #define WLAN_FC_STYPE_REASSOC_REQ 2
00047 #define WLAN_FC_STYPE_REASSOC_RESP 3
00048 #define WLAN_FC_STYPE_PROBE_REQ 4
00049 #define WLAN_FC_STYPE_PROBE_RESP 5
00050 #define WLAN_FC_STYPE_BEACON 8
00051 #define WLAN_FC_STYPE_ATIM 9
00052 #define WLAN_FC_STYPE_DISASSOC 10
00053 #define WLAN_FC_STYPE_AUTH 11
00054 #define WLAN_FC_STYPE_DEAUTH 12
00055 #define WLAN_FC_STYPE_ACTION 13
00056
00057
00058 #define WLAN_FC_STYPE_PSPOLL 10
00059 #define WLAN_FC_STYPE_RTS 11
00060 #define WLAN_FC_STYPE_CTS 12
00061 #define WLAN_FC_STYPE_ACK 13
00062 #define WLAN_FC_STYPE_CFEND 14
00063 #define WLAN_FC_STYPE_CFENDACK 15
00064
00065
00066 #define WLAN_FC_STYPE_DATA 0
00067 #define WLAN_FC_STYPE_DATA_CFACK 1
00068 #define WLAN_FC_STYPE_DATA_CFPOLL 2
00069 #define WLAN_FC_STYPE_DATA_CFACKPOLL 3
00070 #define WLAN_FC_STYPE_NULLFUNC 4
00071 #define WLAN_FC_STYPE_CFACK 5
00072 #define WLAN_FC_STYPE_CFPOLL 6
00073 #define WLAN_FC_STYPE_CFACKPOLL 7
00074 #define WLAN_FC_STYPE_QOS_DATA 8
00075
00076
00077 #define WLAN_AUTH_OPEN 0
00078 #define WLAN_AUTH_SHARED_KEY 1
00079
00080 #define WLAN_AUTH_CHALLENGE_LEN 128
00081
00082 #define WLAN_CAPABILITY_ESS BIT(0)
00083 #define WLAN_CAPABILITY_IBSS BIT(1)
00084 #define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
00085 #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
00086 #define WLAN_CAPABILITY_PRIVACY BIT(4)
00087 #define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
00088 #define WLAN_CAPABILITY_PBCC BIT(6)
00089 #define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
00090 #define WLAN_CAPABILITY_SPECTRUM_MGMT BIT(8)
00091 #define WLAN_CAPABILITY_SHORT_SLOT_TIME BIT(10)
00092 #define WLAN_CAPABILITY_DSSS_OFDM BIT(13)
00093
00094
00095 #define WLAN_STATUS_SUCCESS 0
00096 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
00097 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
00098 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
00099 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
00100 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
00101 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
00102 #define WLAN_STATUS_CHALLENGE_FAIL 15
00103 #define WLAN_STATUS_AUTH_TIMEOUT 16
00104 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
00105 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
00106
00107 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
00108 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
00109 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
00110
00111 #define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
00112 #define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
00113 #define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
00114
00115 #define WLAN_STATUS_INVALID_IE 40
00116 #define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
00117 #define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
00118 #define WLAN_STATUS_AKMP_NOT_VALID 43
00119 #define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
00120 #define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
00121 #define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
00122
00123
00124 #define WLAN_REASON_UNSPECIFIED 1
00125 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
00126 #define WLAN_REASON_DEAUTH_LEAVING 3
00127 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
00128 #define WLAN_REASON_DISASSOC_AP_BUSY 5
00129 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
00130 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
00131 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
00132 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
00133
00134 #define WLAN_REASON_INVALID_IE 13
00135 #define WLAN_REASON_MICHAEL_MIC_FAILURE 14
00136 #define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
00137 #define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
00138 #define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
00139 #define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
00140 #define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
00141 #define WLAN_REASON_AKMP_NOT_VALID 20
00142 #define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
00143 #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
00144 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
00145 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24
00146
00147
00148
00149 #define WLAN_EID_SSID 0
00150 #define WLAN_EID_SUPP_RATES 1
00151 #define WLAN_EID_FH_PARAMS 2
00152 #define WLAN_EID_DS_PARAMS 3
00153 #define WLAN_EID_CF_PARAMS 4
00154 #define WLAN_EID_TIM 5
00155 #define WLAN_EID_IBSS_PARAMS 6
00156 #define WLAN_EID_COUNTRY 7
00157 #define WLAN_EID_CHALLENGE 16
00158
00159 #define WLAN_EID_PWR_CONSTRAINT 32
00160 #define WLAN_EID_PWR_CAPABILITY 33
00161 #define WLAN_EID_TPC_REQUEST 34
00162 #define WLAN_EID_TPC_REPORT 35
00163 #define WLAN_EID_SUPPORTED_CHANNELS 36
00164 #define WLAN_EID_CHANNEL_SWITCH 37
00165 #define WLAN_EID_MEASURE_REQUEST 38
00166 #define WLAN_EID_MEASURE_REPORT 39
00167 #define WLAN_EID_QUITE 40
00168 #define WLAN_EID_IBSS_DFS 41
00169
00170 #define WLAN_EID_ERP_INFO 42
00171 #define WLAN_EID_RSN 48
00172 #define WLAN_EID_EXT_SUPP_RATES 50
00173 #define WLAN_EID_GENERIC 221
00174 #define WLAN_EID_VENDOR_SPECIFIC 221
00175
00176
00177 struct ieee80211_mgmt {
00178 u16 frame_control;
00179 u16 duration;
00180 u8 da[6];
00181 u8 sa[6];
00182 u8 bssid[6];
00183 u16 seq_ctrl;
00184 union {
00185 struct {
00186 u16 auth_alg;
00187 u16 auth_transaction;
00188 u16 status_code;
00189
00190 u8 variable[0];
00191 } __attribute__ ((packed)) auth;
00192 struct {
00193 u16 reason_code;
00194 } __attribute__ ((packed)) deauth;
00195 struct {
00196 u16 capab_info;
00197 u16 listen_interval;
00198
00199 u8 variable[0];
00200 } __attribute__ ((packed)) assoc_req;
00201 struct {
00202 u16 capab_info;
00203 u16 status_code;
00204 u16 aid;
00205
00206 u8 variable[0];
00207 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
00208 struct {
00209 u16 capab_info;
00210 u16 listen_interval;
00211 u8 current_ap[6];
00212
00213 u8 variable[0];
00214 } __attribute__ ((packed)) reassoc_req;
00215 struct {
00216 u16 reason_code;
00217 } __attribute__ ((packed)) disassoc;
00218 struct {
00219
00220 u8 variable[0];
00221 } __attribute__ ((packed)) probe_req;
00222 struct {
00223 u8 timestamp[8];
00224 u16 beacon_int;
00225 u16 capab_info;
00226
00227
00228 u8 variable[0];
00229 } __attribute__ ((packed)) probe_resp;
00230 struct {
00231 u8 timestamp[8];
00232 u16 beacon_int;
00233 u16 capab_info;
00234
00235
00236 u8 variable[0];
00237 } __attribute__ ((packed)) beacon;
00238 struct {
00239 u8 category;
00240 union {
00241 struct {
00242 u8 action_code;
00243 u8 dialog_token;
00244 u8 status_code;
00245 u8 variable[0];
00246 } __attribute__ ((packed)) wme_action;
00247 struct{
00248 u8 action_code;
00249 u8 element_id;
00250 u8 length;
00251 u8 switch_mode;
00252 u8 new_chan;
00253 u8 switch_count;
00254 } __attribute__ ((packed)) chan_switch;
00255 } u;
00256 } __attribute__ ((packed)) action;
00257 } u;
00258 } __attribute__ ((packed));
00259
00260
00261 #define ERP_INFO_NON_ERP_PRESENT BIT(0)
00262 #define ERP_INFO_USE_PROTECTION BIT(1)
00263 #define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
00264
00265
00266 struct ieee802_11_elems {
00267 u8 *ssid;
00268 u8 ssid_len;
00269 u8 *supp_rates;
00270 u8 supp_rates_len;
00271 u8 *fh_params;
00272 u8 fh_params_len;
00273 u8 *ds_params;
00274 u8 ds_params_len;
00275 u8 *cf_params;
00276 u8 cf_params_len;
00277 u8 *tim;
00278 u8 tim_len;
00279 u8 *ibss_params;
00280 u8 ibss_params_len;
00281 u8 *challenge;
00282 u8 challenge_len;
00283 u8 *erp_info;
00284 u8 erp_info_len;
00285 u8 *ext_supp_rates;
00286 u8 ext_supp_rates_len;
00287 u8 *wpa_ie;
00288 u8 wpa_ie_len;
00289 u8 *rsn_ie;
00290 u8 rsn_ie_len;
00291 u8 *wme;
00292 u8 wme_len;
00293 u8 *wme_tspec;
00294 u8 wme_tspec_len;
00295 u8 *power_cap;
00296 u8 power_cap_len;
00297 u8 *supp_channels;
00298 u8 supp_channels_len;
00299 };
00300
00301 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
00302
00303
00304 struct hostapd_frame_info {
00305 u32 phytype;
00306 u32 channel;
00307 u32 datarate;
00308 u32 ssi_signal;
00309
00310 unsigned int passive_scan:1;
00311 };
00312
00313
00314 void ieee802_11_send_deauth(struct hostapd_data *hapd, u8 *addr, u16 reason);
00315 void ieee802_11_mgmt(struct hostapd_data *hapd, u8 *buf, size_t len,
00316 u16 stype, struct hostapd_frame_info *fi);
00317 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
00318 u16 stype, int ok);
00319 ParseRes ieee802_11_parse_elems(struct hostapd_data *hapd, u8 *start,
00320 size_t len,
00321 struct ieee802_11_elems *elems,
00322 int show_errors);
00323 void ieee802_11_print_ssid(const u8 *ssid, u8 len);
00324 void ieee80211_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr,
00325 int local);
00326 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
00327 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
00328 char *buf, size_t buflen);
00329 u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta,
00330 int probe);
00331 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid);
00332 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid);
00333
00334 #endif
00335