1 #ifndef IEEE_802_11
2 #define IEEE_802_11
3 
4 #include <linux/types.h>
5 
6 enum ieee_802_11_link_status_failure_reason {
7 	reserved0, Unspecified=1, Previous_not_valid,
8 	Sender_Quits_ESS_or_IBSS,
9 	Due_Inactivity, AP_Overload,
10 	Class_2_from_NonAuth,
11 	Class_3_from_NonAuth,
12 	Sender_Quits_BSS,
13 	Association_requester_not_authenticated,
14 	Reserved10
15 };
16 
17 
18 #define IEEE_802_11_LINK_STATUS_FAILURE_REASON_STRINGS \
19 {	\
20         {reserved0,		0xff," Reserved reason "},\
21         {Unspecified,		0xff," Unspecified Reason "},\
22         {Previous_not_valid,	0xff," Previous Authentication no longer valid "},\
23         {Sender_Quits_ESS_or_IBSS,0xff," Deauthenticated because sending station is leaving (has left) IBSS or ESS "},\
24         {Due_Inactivity,	0xff," Disassociated due to inactivity "},\
25         {AP_Overload,		0xff," Disassociated because AP is unable to handle all currently associated stations "},\
26         {Class_2_from_NonAuth,	0xff," Class 2 frame received from non-Authenticated station"},\
27         {Class_3_from_NonAuth,	0xff," Class 3 frame received from non�Associated station"},\
28         {Sender_Quits_BSS,	0xff," Disassociated because sending station is leaving (has left) BSS"},\
29         {Association_requester_not_authenticated,0xff," Station requesting (Re)Association is not Authenticated with responding station"},\
30         {Reserved10,		0xff," Reserved"},\
31 	{0,0,NULL}\
32 };
33 
34 
35 
36 struct ieee_802_11_header {
37 	u16	frame_control;// needs to be subtyped
38 	u16	duration;
39 	u8	mac1[6];
40 	u8	mac2[6];
41 	u8	mac3[6];
42 	u16	SeqCtl;
43 	u8	mac4[6];
44 	u16	gapLen;
45 	u8	gap[8];
46 };
47 
48 
49 struct ieee_802_3_header {
50 
51 	u16	status;
52 	u16	payload_length;
53 	u8	dst_mac[6];
54 	u8	src_mac[6];
55 
56 };
57 
58 #define P80211_OUI_LEN 3
59 
60 struct ieee_802_11_snap_header {
61 
62 	u8    dsap;   /* always 0xAA */
63 	u8    ssap;   /* always 0xAA */
64 	u8    ctrl;   /* always 0x03 */
65 	u8    oui[P80211_OUI_LEN];    /* organizational universal id */
66 
67 } __attribute__ ((packed));
68 
69 #define P80211_LLC_OUI_LEN 3
70 
71 struct ieee_802_11_802_1H_header {
72 
73 	u8    dsap;
74 	u8    ssap;   /* always 0xAA */
75 	u8    ctrl;   /* always 0x03 */
76 	u8    oui[P80211_OUI_LEN];    /* organizational universal id */
77 	u16    unknown1;      /* packet type ID fields */
78 	u16    unknown2;		/* here is something like length in some cases */
79 } __attribute__ ((packed));
80 
81 struct ieee_802_11_802_2_header {
82 
83 	u8    dsap;
84 	u8    ssap;   /* always 0xAA */
85 	u8    ctrl;   /* always 0x03 */
86 	u8    oui[P80211_OUI_LEN];    /* organizational universal id */
87 	u8    type;      /* packet type ID field. i guess,  */
88 
89 } __attribute__ ((packed));
90 
91 
92 
93 // following is incoplete and may be incorrect and need reorganization
94 
95 #define ieee_802_11_frame_type_Management	0x00
96 #define ieee_802_11_frame_type_Control		0x01
97 #define ieee_802_11_frame_type_Data		0x10
98 #define ieee_802_11_frame_type_Reserved		0x11
99 
100 #define ieee_802_11_frame_subtype_Association_Req	0x0 // Association Request
101 #define ieee_802_11_frame_subtype_Association_Resp	0x1 // Association Response
102 #define ieee_802_11_frame_subtype_Reassociation_Req	0x2 // Reassociation Request
103 #define ieee_802_11_frame_subtype_Reassociation_Resp	0x3 // Reassociation Response
104 #define ieee_802_11_frame_subtype_Probe_Req		0x4 // Probe Request
105 #define ieee_802_11_frame_subtype_Probe_Resp		0x5 // Probe Response
106 #define ieee_802_11_frame_subtype_Beacon 		0x8 // Beacon
107 #define ieee_802_11_frame_subtype_ATIM 			0x9 // ATIM
108 #define ieee_802_11_frame_subtype_Disassociation 	0xA // Disassociation
109 #define ieee_802_11_frame_subtype_Authentication 	0xB // Authentication
110 #define ieee_802_11_frame_subtype_Deauthentication 	0xC // Deauthentication
111 #define ieee_802_11_frame_subtype_PS_Poll 		0xA // PS-Poll
112 #define ieee_802_11_frame_subtype_RTS 			0xB // RTS
113 #define ieee_802_11_frame_subtype_CTS 			0xC // CTS
114 #define ieee_802_11_frame_subtype_ACK 			0xD // ACK
115 #define ieee_802_11_frame_subtype_CFEnd 		0xE // CF-End
116 #define ieee_802_11_frame_subtype_CFEnd_CFAck 		0xF // CF-End + CF-Ack
117 #define ieee_802_11_frame_subtype_Data 			0x0 // Data
118 #define ieee_802_11_frame_subtype_Data_CFAck 		0x1 // Data + CF-Ack
119 #define ieee_802_11_frame_subtype_Data_CF_Poll 		0x2 // Data + CF-Poll
120 #define ieee_802_11_frame_subtype_Data_CF_AckCF_Poll 	0x3 // Data + CF-Ack + CF-Poll
121 #define ieee_802_11_frame_subtype_NullFunction 		0x4 // Null Function (no data)
122 #define ieee_802_11_frame_subtype_CF_Ack 		0x5 // CF-Ack (no data)
123 #define ieee_802_11_frame_subtype_CF_Poll 		0x6 // CF-Poll (no data)
124 #define ieee_802_11_frame_subtype_CF_AckCF_Poll 	0x7 // CF-Ack + CF-Poll (no data)
125 
126 
127 #define ieee_802_11_frame_subtype_strings {\
128 	{ ieee_802_11_frame_subtype_Association_Req,	0xF,"f  Association Request"},\
129 	{ ieee_802_11_frame_subtype_Association_Resp,	0xF,"1  Association Response"},\
130 	{ ieee_802_11_frame_subtype_Reassociation_Req,	0xF,"2  Reassociation Request"},\
131 	{ ieee_802_11_frame_subtype_Reassociation_Resp,	0xF,"3  Reassociation Response"},\
132 	{ ieee_802_11_frame_subtype_Probe_Req	,	0xF,"4  Probe Request"},\
133 	{ ieee_802_11_frame_subtype_Probe_Resp	,	0xF,"5  Probe Response"},\
134 	{ ieee_802_11_frame_subtype_Beacon 	,	0xF,"8  Beacon"},\
135 	{ ieee_802_11_frame_subtype_ATIM 	,	0xF,"9  ATIM"},\
136 	{ ieee_802_11_frame_subtype_Disassociation,	0xF,"A  Disassociation"},\
137 	{ ieee_802_11_frame_subtype_Authentication,	0xF,"B  Authentication"},\
138 	{ ieee_802_11_frame_subtype_Deauthentication,	0xF,"C  Deauthentication"},\
139 	{ ieee_802_11_frame_subtype_PS_Poll 	,	0xF,"A  PS-Poll"},\
140 	{ ieee_802_11_frame_subtype_RTS 	,	0xF,"B  RTS"},\
141 	{ ieee_802_11_frame_subtype_CTS 	,	0xF,"C  CTS"},\
142 	{ ieee_802_11_frame_subtype_ACK 	,	0xF,"D  ACK"},\
143 	{ ieee_802_11_frame_subtype_CFEnd	,	0xF,"E  CF-End"},\
144 	{ ieee_802_11_frame_subtype_CFEnd_CFAck ,	0xF,"F  CF-End + CF-Ack"},\
145 	{ ieee_802_11_frame_subtype_Data 	,	0xF,"0  Data"},\
146 	{ ieee_802_11_frame_subtype_Data_CFAck 	,	0xF,"1  Data + CF-Ack"},\
147 	{ ieee_802_11_frame_subtype_Data_CFPoll ,	0xF,"2  Data + CF-Poll"},\
148 	{ ieee_802_11_frame_subtype_Data_CFAck_CFPoll,	0xF,"3  Data + CF-Ack + CF-Poll"},\
149 	{ ieee_802_11_frame_subtype_Null_Function ,	0xF,"4  Null Function (no data)"},\
150 	{ ieee_802_11_frame_subtype_CFAck ,		0xF,"5  CF-Ack (no data)"},\
151 	{ ieee_802_11_frame_subtype_CFPoll ,		0xF,"6  CF-Poll (no data)"},\
152 	{ ieee_802_11_frame_subtype_CFAck_CFPoll,	0xF,"y7  CF-Ack + CF-Poll (no data)"},\
153 	{ 0,0,NULL}\
154 }
155 struct ieee_802_11_frame_subtype_class {
156 	u8	subtype;
157 	u8	mask;
158 	u8	class;
159 	u8	type;
160 };
161 #define ieee_802_11_frame_subtype_classes {\
162 	{ ieee_802_11_frame_subtype_Association_Req,	0xF,2,ieee_802_11_frame_type_Management},\
163 	{ ieee_802_11_frame_subtype_Association_Resp,	0xF,2,ieee_802_11_frame_type_Management},\
164 	{ ieee_802_11_frame_subtype_Reassociation_Req,	0xF,2,ieee_802_11_frame_type_Management},\
165 	{ ieee_802_11_frame_subtype_Reassociation_Resp,	0xF,2,ieee_802_11_frame_type_Management},\
166 	{ ieee_802_11_frame_subtype_Probe_Req	,	0xF,1,ieee_802_11_frame_type_Management},\
167 	{ ieee_802_11_frame_subtype_Probe_Resp	,	0xF,1,ieee_802_11_frame_type_Management},\
168 	{ ieee_802_11_frame_subtype_Beacon 	,	0xF,1,ieee_802_11_frame_type_Management},\
169 	{ ieee_802_11_frame_subtype_ATIM 	,	0xF,1,ieee_802_11_frame_type_Management},\
170 	{ ieee_802_11_frame_subtype_Disassociation,	0xF,2,ieee_802_11_frame_type_Management},\
171 	{ ieee_802_11_frame_subtype_Authentication,	0xF,1,ieee_802_11_frame_type_Management},\
172 	{ ieee_802_11_frame_subtype_Deauthentication,	0xF,3,ieee_802_11_frame_type_Management},\
173 	{ ieee_802_11_frame_subtype_PS-Poll 	,	0xF,3,ieee_802_11_frame_type_Control},\
174 	{ ieee_802_11_frame_subtype_RTS 	,	0xF,1,ieee_802_11_frame_type_Control},\
175 	{ ieee_802_11_frame_subtype_CTS 	,	0xF,1,ieee_802_11_frame_type_Control},\
176 	{ ieee_802_11_frame_subtype_ACK 	,	0xF,1,ieee_802_11_frame_type_Control},\
177 	{ ieee_802_11_frame_subtype_CFEnd	,	0xF,1,ieee_802_11_frame_type_Control},\
178 	{ ieee_802_11_frame_subtype_CFEnd_CFAck ,	0xF,1,ieee_802_11_frame_type_Control},\
179 	{ ieee_802_11_frame_subtype_Data 	,	0xF,3,ieee_802_11_frame_type_Data},\
180 	{ ieee_802_11_frame_subtype_Data_CFAck 	,	0xF,3,ieee_802_11_frame_type_Data},\
181 	{ ieee_802_11_frame_subtype_Data_CF_Poll 	0xF,3,ieee_802_11_frame_type_Data},\
182 	{ ieee_802_11_frame_subtype_Data_CF_AckCF_Poll,	0xF,3,ieee_802_11_frame_type_Data},\
183 	{ ieee_802_11_frame_subtype_NullFunction 	0xF,1,ieee_802_11_frame_type_Data},\
184 	{ ieee_802_11_frame_subtype_CF_Ack ,		0xF,1,ieee_802_11_frame_type_Data},\
185 	{ ieee_802_11_frame_subtype_CF_Poll ,		0xF,1,ieee_802_11_frame_type_Data},\
186 	{ ieee_802_11_frame_subtype_CF_AckCF_Poll,	0xF,1,ieee_802_11_frame_type_Data},\
187 	{ 0,0,NULL}\
188 }
189 
190 
191 #endif
192