1 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // This file contains the definitions and data structures used by SW-MAC.
9 // 0.2 20021004 PD43 CCLiu6
10 // 20021018 PD43 CCLiu6
11 // Add enum_TxRate type
12 // Modify enum_STAState type
13 // 0.3 20021023 PE23 CYLiu update MAC session struct
15 // 20021122 PD43 Austin
16 // Deleted some unused.
17 // 20021129 PD43 Austin
18 // 20030617 increase the 802.11g definition
19 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
21 #ifndef _MAC_Structures_H_
22 #define _MAC_Structures_H_
24 #include <linux/skbuff.h>
26 /*=========================================================
27 // Some miscellaneous definitions
29 #define MAX_CHANNELS 30
30 #define MAC_ADDR_LENGTH 6
31 #define MAX_WEP_KEY_SIZE 16 /* 128 bits */
32 #define MAX_802_11_FRAGMENT_NUMBER 10 /* By spec */
34 /* ========================================================
35 // 802.11 Frame define
37 #define MASK_PROTOCOL_VERSION_TYPE 0x0F
38 #define MASK_FRAGMENT_NUMBER 0x000F
39 #define SEQUENCE_NUMBER_SHIFT 4
40 #define DIFFER_11_TO_3 18
41 #define DOT_11_MAC_HEADER_SIZE 24
42 #define DOT_11_SNAP_SIZE 6
43 #define DOT_11_DURATION_OFFSET 2
44 /* Sequence control offset */
45 #define DOT_11_SEQUENCE_OFFSET 22
46 /* The start offset of 802.11 Frame// */
47 #define DOT_11_TYPE_OFFSET 30
48 #define DOT_11_DATA_OFFSET 24
49 #define DOT_11_DA_OFFSET 4
50 #define DOT_3_TYPE_ARP 0x80F3
51 #define DOT_3_TYPE_IPX 0x8137
52 #define DOT_3_TYPE_OFFSET 12
55 #define ETHERNET_HEADER_SIZE 14
56 #define MAX_ETHERNET_PACKET_SIZE 1514
59 /* ----- management : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */
60 #define MAC_SUBTYPE_MNGMNT_ASSOC_REQUEST 0x00
61 #define MAC_SUBTYPE_MNGMNT_ASSOC_RESPONSE 0x10
62 #define MAC_SUBTYPE_MNGMNT_REASSOC_REQUEST 0x20
63 #define MAC_SUBTYPE_MNGMNT_REASSOC_RESPONSE 0x30
64 #define MAC_SUBTYPE_MNGMNT_PROBE_REQUEST 0x40
65 #define MAC_SUBTYPE_MNGMNT_PROBE_RESPONSE 0x50
66 #define MAC_SUBTYPE_MNGMNT_BEACON 0x80
67 #define MAC_SUBTYPE_MNGMNT_ATIM 0x90
68 #define MAC_SUBTYPE_MNGMNT_DISASSOCIATION 0xA0
69 #define MAC_SUBTYPE_MNGMNT_AUTHENTICATION 0xB0
70 #define MAC_SUBTYPE_MNGMNT_DEAUTHENTICATION 0xC0
72 /* ----- control : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */
73 #define MAC_SUBTYPE_CONTROL_PSPOLL 0xA4
74 #define MAC_SUBTYPE_CONTROL_RTS 0xB4
75 #define MAC_SUBTYPE_CONTROL_CTS 0xC4
76 #define MAC_SUBTYPE_CONTROL_ACK 0xD4
77 #define MAC_SUBTYPE_CONTROL_CFEND 0xE4
78 #define MAC_SUBTYPE_CONTROL_CFEND_CFACK 0xF4
80 /* ----- data : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */
81 #define MAC_SUBTYPE_DATA 0x08
82 #define MAC_SUBTYPE_DATA_CFACK 0x18
83 #define MAC_SUBTYPE_DATA_CFPOLL 0x28
84 #define MAC_SUBTYPE_DATA_CFACK_CFPOLL 0x38
85 #define MAC_SUBTYPE_DATA_NULL 0x48
86 #define MAC_SUBTYPE_DATA_CFACK_NULL 0x58
87 #define MAC_SUBTYPE_DATA_CFPOLL_NULL 0x68
88 #define MAC_SUBTYPE_DATA_CFACK_CFPOLL_NULL 0x78
90 /* ----- Frame Type of Bits (2, 3) */
91 #define MAC_TYPE_MANAGEMENT 0x00
92 #define MAC_TYPE_CONTROL 0x04
93 #define MAC_TYPE_DATA 0x08
95 /* ----- definitions for Management Frame Element ID (1 BYTE) */
96 #define ELEMENT_ID_SSID 0
97 #define ELEMENT_ID_SUPPORTED_RATES 1
98 #define ELEMENT_ID_FH_PARAMETER_SET 2
99 #define ELEMENT_ID_DS_PARAMETER_SET 3
100 #define ELEMENT_ID_CF_PARAMETER_SET 4
101 #define ELEMENT_ID_TIM 5
102 #define ELEMENT_ID_IBSS_PARAMETER_SET 6
104 #define ELEMENT_ID_CHALLENGE_TEXT 16
105 /* 17~31 reserved for challenge text extension */
106 /* 32~255 reserved */
108 #define ELEMENT_ID_ERP_INFORMATION 42
109 #define ELEMENT_ID_EXTENDED_SUPPORTED_RATES 50
113 #define ELEMENT_ID_RSN_WPA 221
115 #define ELEMENT_ID_RSN_WPA2 48
116 #endif /* endif WPA2 */
118 #define WLAN_MAX_PAIRWISE_CIPHER_SUITE_COUNT ((u16) 6)
119 #define WLAN_MAX_AUTH_KEY_MGT_SUITE_LIST_COUNT ((u16) 2)
121 /* ===================================================================
122 * Reason Code (Table 18): indicate the reason of DisAssoc, DeAuthen
123 * length of ReasonCode is 2 Octs.
124 * =================================================================== */
125 #define REASON_REASERED 0
126 #define REASON_UNSPECIDIED 1
127 #define REASON_PREAUTH_INVALID 2
128 #define DEAUTH_REASON_LEFT_BSS 3
129 #define DISASS_REASON_AP_INACTIVE 4
130 #define DISASS_REASON_AP_BUSY 5
131 #define REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
132 #define REASON_CLASS3_FRAME_FROM_NONASSO_STA 7
133 #define DISASS_REASON_LEFT_BSS 8
134 #define REASON_NOT_AUTH_YET 9
136 #define REASON_INVALID_IE 13
137 #define REASON_MIC_ERROR 14
138 #define REASON_4WAY_HANDSHAKE_TIMEOUT 15
139 #define REASON_GROUPKEY_UPDATE_TIMEOUT 16
140 #define REASON_IE_DIFF_4WAY_ASSOC 17
141 #define REASON_INVALID_MULTICAST_CIPHER 18
142 #define REASON_INVALID_UNICAST_CIPHER 19
143 #define REASON_INVALID_AKMP 20
144 #define REASON_UNSUPPORTED_RSNIE_VERSION 21
145 #define REASON_INVALID_RSNIE_CAPABILITY 22
146 #define REASON_802_1X_AUTH_FAIL 23
147 #define REASON_CIPHER_REJECT_PER_SEC_POLICY 14
150 //===========================================================
151 // enum_MMPDUResultCode --
152 // Status code (2 Octs) in the MMPDU's frame body. Table.19
154 //===========================================================
155 enum enum_MMPDUResultCode
157 // SUCCESS = 0, // Redefined
158 UNSPECIFIED_FAILURE = 1,
162 NOT_SUPPROT_CAPABILITIES = 10,
164 //REASSOCIATION_DENIED
166 REASSOC_DENIED_UNABLE_CFM_ASSOC_EXIST = 11,
168 //ASSOCIATION_DENIED_NOT_IN_STANDARD
170 ASSOC_DENIED_REASON_NOT_IN_STANDARD = 12,
171 PEER_NOT_SUPPORT_AUTH_ALGORITHM = 13,
172 AUTH_SEQNUM_OUT_OF_EXPECT = 14,
173 AUTH_REJECT_REASON_CHALLENGE_FAIL = 15,
174 AUTH_REJECT_REASON_WAIT_TIMEOUT = 16,
175 ASSOC_DENIED_REASON_AP_BUSY = 17,
176 ASSOC_DENIED_REASON_NOT_SUPPORT_BASIC_RATE = 18
177 } WB_MMPDURESULTCODE, *PWB_MMPDURESULTCODE;
180 #define RATE_BITMAP_1M 1
181 #define RATE_BITMAP_2M 2
182 #define RATE_BITMAP_5dot5M 5
183 #define RATE_BITMAP_6M 6
184 #define RATE_BITMAP_9M 9
185 #define RATE_BITMAP_11M 11
186 #define RATE_BITMAP_12M 12
187 #define RATE_BITMAP_18M 18
188 #define RATE_BITMAP_22M 22
189 #define RATE_BITMAP_24M 24
190 #define RATE_BITMAP_33M 17
191 #define RATE_BITMAP_36M 19
192 #define RATE_BITMAP_48M 25
193 #define RATE_BITMAP_54M 28
198 #define RATE_5dot5M 11
213 #define CAPABILITY_ESS_BIT 0x0001
214 #define CAPABILITY_IBSS_BIT 0x0002
215 #define CAPABILITY_CF_POLL_BIT 0x0004
216 #define CAPABILITY_CF_POLL_REQ_BIT 0x0008
217 #define CAPABILITY_PRIVACY_BIT 0x0010
218 #define CAPABILITY_SHORT_PREAMBLE_BIT 0x0020
219 #define CAPABILITY_PBCC_BIT 0x0040
220 #define CAPABILITY_CHAN_AGILITY_BIT 0x0080
221 #define CAPABILITY_SHORT_SLOT_TIME_BIT 0x0400
222 #define CAPABILITY_DSSS_OFDM_BIT 0x2000
225 struct Capability_Information_Element {
227 u16 __attribute__ ((packed)) wValue;
228 #ifdef _BIG_ENDIAN_ /* 20060926 add by anson's endian */
234 u8 Short_Slot_Time:1;
236 u8 Channel_Agility:1;
240 u8 CF_Poll_Request:1;
244 } __attribute__ ((packed)) Capability;
250 u8 CF_Poll_Request:1;
254 u8 Channel_Agility:1;
257 u8 Short_Slot_Time:1;
261 } __attribute__ ((packed)) Capability;
263 } __attribute__ ((packed)) ;
264 } __attribute__ ((packed));
266 struct FH_Parameter_Set_Element {
275 struct DS_Parameter_Set_Element {
281 struct Supported_Rates_Element {
284 u8 SupportedRates[8];
285 } __attribute__ ((packed));
287 struct SSID_Element {
291 } __attribute__ ((packed)) ;
293 struct CF_Parameter_Set_Element {
298 u8 CFP_MaxDuration[2]; /* in Time Units */
299 u8 CFP_DurRemaining[2]; /* in time units */
308 u8 Partial_Virtual_Bitmap[251];
311 struct IBSS_Parameter_Set_Element {
317 struct Challenge_Text_Element {
320 u8 Challenge_Text[253];
323 struct PHY_Parameter_Set_Element {
327 s32 aRxTxTurnaroundTime;
335 s32 aAirPropagationTime;
336 s32 aMACProcessingDelay;
338 s32 aPLCPHeaderLength;
339 s32 aMPDUDurationFactor;
346 struct ERP_Information_Element {
349 #ifdef _BIG_ENDIAN_ /* 20060926 add by anson's endian */
350 u8 Reserved:5; /* 20060926 add by anson */
351 u8 Barker_Preamble_Mode:1;
357 u8 Barker_Preamble_Mode:1;
362 struct Extended_Supported_Rates_Element {
365 u8 ExtendedSupportedRates[255];
366 } __attribute__ ((packed));
368 /* WPA(802.11i draft 3.0) */
369 #define VERSION_WPA 1
371 #define VERSION_WPA2 1
372 #endif /* end def _WPA2_ */
373 /* WPA2.0 OUI=00:50:F2, the MSB is reserved for suite type */
374 #define OUI_WPA 0x00F25000
376 /* for wpa2 change to 0x00ACOF04 by Ws 26/04/04 */
377 #define OUI_WPA2 0x00AC0F00
378 #endif /* end def _WPA2_ */
380 #define OUI_WPA_ADDITIONAL 0x01
381 #define WLAN_MIN_RSN_WPA_LENGTH 6 /* added by ws 09/10/04 */
383 #define WLAN_MIN_RSN_WPA2_LENGTH 2 /* Fix to 2 09/14/05 */
384 #endif /* end def _WPA2_ */
386 #define oui_wpa (u32)(OUI_WPA|OUI_WPA_ADDITIONAL)
388 #define WPA_OUI_BIG ((u32) 0x01F25000)/* added by ws 09/23/04 */
389 #define WPA_OUI_LITTLE ((u32) 0x01F25001)/* added by ws 09/23/04 */
390 /* 20061108 For WPS. It's little endian. Big endian is 0x0050F204 */
391 #define WPA_WPS_OUI cpu_to_le32(0x04F25000)
395 #define WPA2_OUI_BIG ((u32)0x01AC0F00)
396 #define WPA2_OUI_LITTLE ((u32)0x01AC0F01)
397 #endif /* end def _WPA2_ */
399 /* Authentication suite */
400 #define OUI_AUTH_WPA_NONE 0x00 /* for WPA_NONE */
401 #define OUI_AUTH_8021X 0x01
402 #define OUI_AUTH_PSK 0x02
404 #define OUI_CIPHER_GROUP_KEY 0x00 /* added by ws 05/21/04 */
405 #define OUI_CIPHER_WEP_40 0x01
406 #define OUI_CIPHER_TKIP 0x02
407 #define OUI_CIPHER_CCMP 0x04
408 #define OUI_CIPHER_WEP_104 0x05
410 struct suite_selector{
421 struct RSN_Information_Element{
424 /* WPA version 2.0 additional field, and should be 00:50:F2:01 */
425 struct suite_selector OuiWPAAdditional;
427 struct suite_selector GroupKeySuite;
428 u16 PairwiseKeySuiteCount;
429 struct suite_selector PairwiseKeySuite[1];
430 } __attribute__ ((packed));
431 struct RSN_Auth_Sub_Information_Element {
432 u16 AuthKeyMngtSuiteCount;
433 struct suite_selector AuthKeyMngtSuite[1];
434 } __attribute__ ((packed));
437 struct RSN_Capability_Element {
439 u16 __attribute__ ((packed)) wValue;
440 #ifdef _BIG_ENDIAN_ /* 20060927 add by anson's endian */
441 struct _RSN_Capability {
442 u16 __attribute__ ((packed)) Reserved2:8; /* 20051201 */
443 u16 __attribute__ ((packed)) Reserved1:2;
444 u16 __attribute__ ((packed)) GTK_Replay_Counter:2;
445 u16 __attribute__ ((packed)) PTK_Replay_Counter:2;
446 u16 __attribute__ ((packed)) No_Pairwise:1;
447 u16 __attribute__ ((packed)) Pre_Auth:1;
448 } __attribute__ ((packed)) RSN_Capability;
450 struct _RSN_Capability {
451 u16 __attribute__ ((packed)) Pre_Auth:1;
452 u16 __attribute__ ((packed)) No_Pairwise:1;
453 u16 __attribute__ ((packed)) PTK_Replay_Counter:2;
454 u16 __attribute__ ((packed)) GTK_Replay_Counter:2;
455 u16 __attribute__ ((packed)) Reserved1:2;
456 u16 __attribute__ ((packed)) Reserved2:8; /* 20051201 */
457 } __attribute__ ((packed)) RSN_Capability;
460 } __attribute__ ((packed)) ;
461 } __attribute__ ((packed)) ;
468 struct WPA2_RSN_Information_Element {
472 struct suite_selector GroupKeySuite;
473 u16 PairwiseKeySuiteCount;
474 struct suite_selector PairwiseKeySuite[1];
476 } __attribute__ ((packed));
478 struct WPA2_RSN_Auth_Sub_Information_Element {
479 u16 AuthKeyMngtSuiteCount;
480 struct suite_selector AuthKeyMngtSuite[1];
481 } __attribute__ ((packed));
484 struct PMKID_Information_Element {
486 struct pmkid pmkid[16];
487 } __attribute__ ((packed));
489 #endif /* enddef _WPA2_ */
490 /*============================================================
491 // MAC Frame structure (different type) and subfield structure
492 //============================================================*/
493 struct MAC_frame_control {
494 /* a combination of the [Protocol Version, Control Type, Control Subtype]*/
496 /* 20060927 add by anson's endian */
516 } __attribute__ ((packed));
518 struct Management_Frame {
519 /* 2B, ToDS,FromDS,MoreFrag,MoreData,Order=0 */
520 struct MAC_frame_control frame_control;
522 u8 DA[MAC_ADDR_LENGTH]; /* Addr1 */
523 u8 SA[MAC_ADDR_LENGTH]; /* Addr2 */
524 u8 BSSID[MAC_ADDR_LENGTH]; /* Addr3 */
525 u16 Sequence_Control;
526 /* Management Frame Body <= 325 bytes */
528 } __attribute__ ((packed));
530 /* SW-MAC don't Tx/Rx Control-Frame, HW-MAC do it. */
531 struct Control_Frame {
532 /* ToDS,FromDS,MoreFrag,Retry,MoreData,WEP,Order=0 */
533 struct MAC_frame_control frame_control;
535 u8 RA[MAC_ADDR_LENGTH];
536 u8 TA[MAC_ADDR_LENGTH];
538 } __attribute__ ((packed));
541 struct MAC_frame_control frame_control;
543 u8 Addr1[MAC_ADDR_LENGTH];
544 u8 Addr2[MAC_ADDR_LENGTH];
545 u8 Addr3[MAC_ADDR_LENGTH];
546 u16 Sequence_Control;
547 u8 Addr4[MAC_ADDR_LENGTH]; /* only exist when ToDS=FromDS=1 */
548 /* Data Frame Body <= 2312 */
550 } __attribute__ ((packed));
552 struct Disassociation_Frame_Body {
554 } __attribute__ ((packed));
556 struct Association_Request_Frame_Body {
557 u16 capability_information;
559 u8 Current_AP_Address[MAC_ADDR_LENGTH];/* for reassociation only */
560 /* SSID (2+32 bytes) */
561 /* Supported_Rates (2+8 bytes) */
562 } __attribute__ ((packed));
564 struct Association_Response_Frame_Body {
565 u16 capability_information;
568 struct Supported_Rates_Element supportedRates;
569 } __attribute__ ((packed));
571 /*struct Reassociation_Request_Frame_Body
573 u16 capability_information;
575 u8 Current_AP_Address[MAC_ADDR_LENGTH];
577 // Supported_Rates (2+8 bytes)
579 /* eliminated by WS 07/22/04 comboined with associateion request frame. */
581 struct Reassociation_Response_Frame_Body {
582 u16 capability_information;
585 struct Supported_Rates_Element supportedRates;
586 } __attribute__ ((packed));
588 struct Deauthentication_Frame_Body {
590 } __attribute__ ((packed));
593 struct Probe_Response_Frame_Body {
596 u16 Capability_Information;
599 // PHY parameter Set (DS Parameters)
601 // IBSS parameter Set */
602 } __attribute__ ((packed));
604 struct Authentication_Frame_Body {
608 /* NB: don't include ChallengeText in this structure
609 // struct Challenge_Text_Element sChallengeTextElement;
611 } __attribute__ ((packed));
614 #endif /* _MAC_Structure_H_ */