p80211hdr.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 FILE_LICENCE ( GPL2_ONLY );
00061
00062 #ifndef _P80211HDR_H
00063 #define _P80211HDR_H
00064
00065
00066
00067
00068
00069
00070
00071 #ifndef _WLAN_COMPAT_H
00072 #include <wlan/wlan_compat.h>
00073 #endif
00074
00075
00076
00077
00078
00079
00080 #define WLAN_ADDR_LEN 6
00081 #define WLAN_CRC_LEN 4
00082 #define WLAN_BSSID_LEN 6
00083 #define WLAN_BSS_TS_LEN 8
00084 #define WLAN_HDR_A3_LEN 24
00085 #define WLAN_HDR_A4_LEN 30
00086 #define WLAN_SSID_MAXLEN 32
00087 #define WLAN_DATA_MAXLEN 2312
00088 #define WLAN_A3FR_MAXLEN (WLAN_HDR_A3_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
00089 #define WLAN_A4FR_MAXLEN (WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
00090 #define WLAN_BEACON_FR_MAXLEN (WLAN_HDR_A3_LEN + 334)
00091 #define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_A3_LEN + 0)
00092 #define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_A3_LEN + 2)
00093 #define WLAN_ASSOCREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 48)
00094 #define WLAN_ASSOCRESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 16)
00095 #define WLAN_REASSOCREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 54)
00096 #define WLAN_REASSOCRESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 16)
00097 #define WLAN_PROBEREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 44)
00098 #define WLAN_PROBERESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 78)
00099 #define WLAN_AUTHEN_FR_MAXLEN (WLAN_HDR_A3_LEN + 261)
00100 #define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_A3_LEN + 2)
00101 #define WLAN_WEP_NKEYS 4
00102 #define WLAN_WEP_MAXKEYLEN 13
00103 #define WLAN_CHALLENGE_IE_LEN 130
00104 #define WLAN_CHALLENGE_LEN 128
00105 #define WLAN_WEP_IV_LEN 4
00106 #define WLAN_WEP_ICV_LEN 4
00107
00108
00109
00110 #define WLAN_FTYPE_MGMT 0x00
00111 #define WLAN_FTYPE_CTL 0x01
00112 #define WLAN_FTYPE_DATA 0x02
00113
00114
00115
00116 #define WLAN_FSTYPE_ASSOCREQ 0x00
00117 #define WLAN_FSTYPE_ASSOCRESP 0x01
00118 #define WLAN_FSTYPE_REASSOCREQ 0x02
00119 #define WLAN_FSTYPE_REASSOCRESP 0x03
00120 #define WLAN_FSTYPE_PROBEREQ 0x04
00121 #define WLAN_FSTYPE_PROBERESP 0x05
00122 #define WLAN_FSTYPE_BEACON 0x08
00123 #define WLAN_FSTYPE_ATIM 0x09
00124 #define WLAN_FSTYPE_DISASSOC 0x0a
00125 #define WLAN_FSTYPE_AUTHEN 0x0b
00126 #define WLAN_FSTYPE_DEAUTHEN 0x0c
00127
00128
00129 #define WLAN_FSTYPE_BLOCKACKREQ 0x8
00130 #define WLAN_FSTYPE_BLOCKACK 0x9
00131 #define WLAN_FSTYPE_PSPOLL 0x0a
00132 #define WLAN_FSTYPE_RTS 0x0b
00133 #define WLAN_FSTYPE_CTS 0x0c
00134 #define WLAN_FSTYPE_ACK 0x0d
00135 #define WLAN_FSTYPE_CFEND 0x0e
00136 #define WLAN_FSTYPE_CFENDCFACK 0x0f
00137
00138
00139 #define WLAN_FSTYPE_DATAONLY 0x00
00140 #define WLAN_FSTYPE_DATA_CFACK 0x01
00141 #define WLAN_FSTYPE_DATA_CFPOLL 0x02
00142 #define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
00143 #define WLAN_FSTYPE_NULL 0x04
00144 #define WLAN_FSTYPE_CFACK 0x05
00145 #define WLAN_FSTYPE_CFPOLL 0x06
00146 #define WLAN_FSTYPE_CFACK_CFPOLL 0x07
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 #define WLAN_GET_FC_PVER(n) (((UINT16)(n)) & (BIT0 | BIT1))
00172 #define WLAN_GET_FC_FTYPE(n) ((((UINT16)(n)) & (BIT2 | BIT3)) >> 2)
00173 #define WLAN_GET_FC_FSTYPE(n) ((((UINT16)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
00174 #define WLAN_GET_FC_TODS(n) ((((UINT16)(n)) & (BIT8)) >> 8)
00175 #define WLAN_GET_FC_FROMDS(n) ((((UINT16)(n)) & (BIT9)) >> 9)
00176 #define WLAN_GET_FC_MOREFRAG(n) ((((UINT16)(n)) & (BIT10)) >> 10)
00177 #define WLAN_GET_FC_RETRY(n) ((((UINT16)(n)) & (BIT11)) >> 11)
00178 #define WLAN_GET_FC_PWRMGT(n) ((((UINT16)(n)) & (BIT12)) >> 12)
00179 #define WLAN_GET_FC_MOREDATA(n) ((((UINT16)(n)) & (BIT13)) >> 13)
00180 #define WLAN_GET_FC_ISWEP(n) ((((UINT16)(n)) & (BIT14)) >> 14)
00181 #define WLAN_GET_FC_ORDER(n) ((((UINT16)(n)) & (BIT15)) >> 15)
00182
00183 #define WLAN_SET_FC_PVER(n) ((UINT16)(n))
00184 #define WLAN_SET_FC_FTYPE(n) (((UINT16)(n)) << 2)
00185 #define WLAN_SET_FC_FSTYPE(n) (((UINT16)(n)) << 4)
00186 #define WLAN_SET_FC_TODS(n) (((UINT16)(n)) << 8)
00187 #define WLAN_SET_FC_FROMDS(n) (((UINT16)(n)) << 9)
00188 #define WLAN_SET_FC_MOREFRAG(n) (((UINT16)(n)) << 10)
00189 #define WLAN_SET_FC_RETRY(n) (((UINT16)(n)) << 11)
00190 #define WLAN_SET_FC_PWRMGT(n) (((UINT16)(n)) << 12)
00191 #define WLAN_SET_FC_MOREDATA(n) (((UINT16)(n)) << 13)
00192 #define WLAN_SET_FC_ISWEP(n) (((UINT16)(n)) << 14)
00193 #define WLAN_SET_FC_ORDER(n) (((UINT16)(n)) << 15)
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 #define WLAN_GET_SEQ_FRGNUM(n) (((UINT16)(n)) & (BIT0|BIT1|BIT2|BIT3))
00207 #define WLAN_GET_SEQ_SEQNUM(n) ((((UINT16)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
00208
00209
00210
00211
00212
00213 #define WLAN_HDR_A3_DATAP(p) (((UINT8*)(p)) + WLAN_HDR_A3_LEN)
00214 #define WLAN_HDR_A4_DATAP(p) (((UINT8*)(p)) + WLAN_HDR_A4_LEN)
00215
00216 #define DOT11_RATE5_ISBASIC_GET(r) (((UINT8)(r)) & BIT7)
00217
00218
00219
00220
00221
00222 typedef UINT8 wlan_bss_ts_t[WLAN_BSS_TS_LEN];
00223
00224
00225
00226 typedef struct p80211_hdr_a3
00227 {
00228 UINT16 fc;
00229 UINT16 dur;
00230 UINT8 a1[WLAN_ADDR_LEN];
00231 UINT8 a2[WLAN_ADDR_LEN];
00232 UINT8 a3[WLAN_ADDR_LEN];
00233 UINT16 seq;
00234 } __WLAN_ATTRIB_PACK__ p80211_hdr_a3_t;
00235
00236 typedef struct p80211_hdr_a4
00237 {
00238 UINT16 fc;
00239 UINT16 dur;
00240 UINT8 a1[WLAN_ADDR_LEN];
00241 UINT8 a2[WLAN_ADDR_LEN];
00242 UINT8 a3[WLAN_ADDR_LEN];
00243 UINT16 seq;
00244 UINT8 a4[WLAN_ADDR_LEN];
00245 } __WLAN_ATTRIB_PACK__ p80211_hdr_a4_t;
00246
00247 typedef union p80211_hdr
00248 {
00249 p80211_hdr_a3_t a3;
00250 p80211_hdr_a4_t a4;
00251 } __WLAN_ATTRIB_PACK__ p80211_hdr_t;
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 #define WLAN_CTL_FRAMELEN(fstype) (\
00264 (fstype) == WLAN_FSTYPE_BLOCKACKREQ ? 24 : \
00265 (fstype) == WLAN_FSTYPE_BLOCKACK ? 152 : \
00266 (fstype) == WLAN_FSTYPE_PSPOLL ? 20 : \
00267 (fstype) == WLAN_FSTYPE_RTS ? 20 : \
00268 (fstype) == WLAN_FSTYPE_CTS ? 14 : \
00269 (fstype) == WLAN_FSTYPE_ACK ? 14 : \
00270 (fstype) == WLAN_FSTYPE_CFEND ? 20 : \
00271 (fstype) == WLAN_FSTYPE_CFENDCFACK ? 20 : 4)
00272
00273 #define WLAN_FCS_LEN 4
00274
00275
00276 inline static UINT16 p80211_headerlen(UINT16 fctl)
00277 {
00278 UINT16 hdrlen = 0;
00279
00280 switch ( WLAN_GET_FC_FTYPE(fctl) ) {
00281 case WLAN_FTYPE_MGMT:
00282 hdrlen = WLAN_HDR_A3_LEN;
00283 break;
00284 case WLAN_FTYPE_DATA:
00285 hdrlen = WLAN_HDR_A3_LEN;
00286 if ( WLAN_GET_FC_TODS(fctl) && WLAN_GET_FC_FROMDS(fctl) ) {
00287 hdrlen += WLAN_ADDR_LEN;
00288 }
00289 break;
00290 case WLAN_FTYPE_CTL:
00291 hdrlen = WLAN_CTL_FRAMELEN(WLAN_GET_FC_FSTYPE(fctl)) -
00292 WLAN_FCS_LEN;
00293 break;
00294 default:
00295 hdrlen = WLAN_HDR_A3_LEN;
00296 }
00297
00298 return hdrlen;
00299 }
00300
00301 #endif