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