0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 #ifndef _P80211HDR_H
0062 #define _P80211HDR_H
0063
0064 #include <linux/if_ether.h>
0065
0066
0067 #define WLAN_CRC_LEN 4
0068 #define WLAN_BSSID_LEN 6
0069 #define WLAN_HDR_A3_LEN 24
0070 #define WLAN_HDR_A4_LEN 30
0071 #define WLAN_SSID_MAXLEN 32
0072 #define WLAN_DATA_MAXLEN 2312
0073 #define WLAN_WEP_IV_LEN 4
0074 #define WLAN_WEP_ICV_LEN 4
0075
0076
0077
0078 #define WLAN_FTYPE_MGMT 0x00
0079 #define WLAN_FTYPE_CTL 0x01
0080 #define WLAN_FTYPE_DATA 0x02
0081
0082
0083
0084 #define WLAN_FSTYPE_ASSOCREQ 0x00
0085 #define WLAN_FSTYPE_ASSOCRESP 0x01
0086 #define WLAN_FSTYPE_REASSOCREQ 0x02
0087 #define WLAN_FSTYPE_REASSOCRESP 0x03
0088 #define WLAN_FSTYPE_PROBEREQ 0x04
0089 #define WLAN_FSTYPE_PROBERESP 0x05
0090 #define WLAN_FSTYPE_BEACON 0x08
0091 #define WLAN_FSTYPE_ATIM 0x09
0092 #define WLAN_FSTYPE_DISASSOC 0x0a
0093 #define WLAN_FSTYPE_AUTHEN 0x0b
0094 #define WLAN_FSTYPE_DEAUTHEN 0x0c
0095
0096
0097 #define WLAN_FSTYPE_BLOCKACKREQ 0x8
0098 #define WLAN_FSTYPE_BLOCKACK 0x9
0099 #define WLAN_FSTYPE_PSPOLL 0x0a
0100 #define WLAN_FSTYPE_RTS 0x0b
0101 #define WLAN_FSTYPE_CTS 0x0c
0102 #define WLAN_FSTYPE_ACK 0x0d
0103 #define WLAN_FSTYPE_CFEND 0x0e
0104 #define WLAN_FSTYPE_CFENDCFACK 0x0f
0105
0106
0107 #define WLAN_FSTYPE_DATAONLY 0x00
0108 #define WLAN_FSTYPE_DATA_CFACK 0x01
0109 #define WLAN_FSTYPE_DATA_CFPOLL 0x02
0110 #define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
0111 #define WLAN_FSTYPE_NULL 0x04
0112 #define WLAN_FSTYPE_CFACK 0x05
0113 #define WLAN_FSTYPE_CFPOLL 0x06
0114 #define WLAN_FSTYPE_CFACK_CFPOLL 0x07
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 #define WLAN_GET_FC_FTYPE(n) ((((u16)(n)) & GENMASK(3, 2)) >> 2)
0136 #define WLAN_GET_FC_FSTYPE(n) ((((u16)(n)) & GENMASK(7, 4)) >> 4)
0137 #define WLAN_GET_FC_TODS(n) ((((u16)(n)) & (BIT(8))) >> 8)
0138 #define WLAN_GET_FC_FROMDS(n) ((((u16)(n)) & (BIT(9))) >> 9)
0139 #define WLAN_GET_FC_ISWEP(n) ((((u16)(n)) & (BIT(14))) >> 14)
0140
0141 #define WLAN_SET_FC_FTYPE(n) (((u16)(n)) << 2)
0142 #define WLAN_SET_FC_FSTYPE(n) (((u16)(n)) << 4)
0143 #define WLAN_SET_FC_TODS(n) (((u16)(n)) << 8)
0144 #define WLAN_SET_FC_FROMDS(n) (((u16)(n)) << 9)
0145 #define WLAN_SET_FC_ISWEP(n) (((u16)(n)) << 14)
0146
0147 #define DOT11_RATE5_ISBASIC_GET(r) (((u8)(r)) & BIT(7))
0148
0149
0150
0151 struct p80211_hdr {
0152 __le16 frame_control;
0153 u16 duration_id;
0154 u8 address1[ETH_ALEN];
0155 u8 address2[ETH_ALEN];
0156 u8 address3[ETH_ALEN];
0157 u16 sequence_control;
0158 u8 address4[ETH_ALEN];
0159 } __packed;
0160
0161
0162
0163 static inline u16 wlan_ctl_framelen(u16 fstype)
0164 {
0165 switch (fstype) {
0166 case WLAN_FSTYPE_BLOCKACKREQ:
0167 return 24;
0168 case WLAN_FSTYPE_BLOCKACK:
0169 return 152;
0170 case WLAN_FSTYPE_PSPOLL:
0171 case WLAN_FSTYPE_RTS:
0172 case WLAN_FSTYPE_CFEND:
0173 case WLAN_FSTYPE_CFENDCFACK:
0174 return 20;
0175 case WLAN_FSTYPE_CTS:
0176 case WLAN_FSTYPE_ACK:
0177 return 14;
0178 default:
0179 return 4;
0180 }
0181 }
0182
0183 #define WLAN_FCS_LEN 4
0184
0185
0186 static inline u16 p80211_headerlen(u16 fctl)
0187 {
0188 u16 hdrlen = 0;
0189
0190 switch (WLAN_GET_FC_FTYPE(fctl)) {
0191 case WLAN_FTYPE_MGMT:
0192 hdrlen = WLAN_HDR_A3_LEN;
0193 break;
0194 case WLAN_FTYPE_DATA:
0195 hdrlen = WLAN_HDR_A3_LEN;
0196 if (WLAN_GET_FC_TODS(fctl) && WLAN_GET_FC_FROMDS(fctl))
0197 hdrlen += ETH_ALEN;
0198 break;
0199 case WLAN_FTYPE_CTL:
0200 hdrlen = wlan_ctl_framelen(WLAN_GET_FC_FSTYPE(fctl)) -
0201 WLAN_FCS_LEN;
0202 break;
0203 default:
0204 hdrlen = WLAN_HDR_A3_LEN;
0205 }
0206
0207 return hdrlen;
0208 }
0209
0210 #endif