upstream Makefile doesn't have an install target
[debian/uapevent] / uapevent.h
1 /** @file  uapevent.h
2  *
3  *  @brief Header file for uapevent application
4  * 
5  * Copyright (C) 2008-2009, Marvell International Ltd. 
6  *
7  * This software file (the "File") is distributed by Marvell International 
8  * Ltd. under the terms of the GNU General Public License Version 2, June 1991 
9  * (the "License").  You may use, redistribute and/or modify this File in 
10  * accordance with the terms and conditions of the License, a copy of which 
11  * is available along with the File in the gpl.txt file or by writing to 
12  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
13  * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
14  *
15  * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 
16  * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 
17  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about 
18  * this warranty disclaimer.
19  *
20  */
21 /************************************************************************
22 Change log:
23     03/18/08: Initial creation
24 ************************************************************************/
25
26 #ifndef _UAP_H
27 #define _UAP_H
28
29 #if (BYTE_ORDER == LITTLE_ENDIAN)
30 #undef BIG_ENDIAN
31 #endif
32
33 /** 16 bits byte swap */
34 #define swap_byte_16(x) \
35   ((u16)((((u16)(x) & 0x00ffU) << 8) | \
36          (((u16)(x) & 0xff00U) >> 8)))
37
38 /** 32 bits byte swap */
39 #define swap_byte_32(x) \
40   ((u32)((((u32)(x) & 0x000000ffUL) << 24) | \
41          (((u32)(x) & 0x0000ff00UL) <<  8) | \
42          (((u32)(x) & 0x00ff0000UL) >>  8) | \
43          (((u32)(x) & 0xff000000UL) >> 24)))
44
45 /** 64 bits byte swap */
46 #define swap_byte_64(x) \
47   ((u64)((u64)(((u64)(x) & 0x00000000000000ffULL) << 56) | \
48          (u64)(((u64)(x) & 0x000000000000ff00ULL) << 40) | \
49          (u64)(((u64)(x) & 0x0000000000ff0000ULL) << 24) | \
50          (u64)(((u64)(x) & 0x00000000ff000000ULL) <<  8) | \
51          (u64)(((u64)(x) & 0x000000ff00000000ULL) >>  8) | \
52          (u64)(((u64)(x) & 0x0000ff0000000000ULL) >> 24) | \
53          (u64)(((u64)(x) & 0x00ff000000000000ULL) >> 40) | \
54          (u64)(((u64)(x) & 0xff00000000000000ULL) >> 56) ))
55
56 #ifdef BIG_ENDIAN
57 /** Convert from 16 bit little endian format to CPU format */
58 #define uap_le16_to_cpu(x) swap_byte_16(x)
59 /** Convert from 32 bit little endian format to CPU format */
60 #define uap_le32_to_cpu(x) swap_byte_32(x)
61 /** Convert from 64 bit little endian format to CPU format */
62 #define uap_le64_to_cpu(x) swap_byte_64(x)
63 /** Convert to 16 bit little endian format from CPU format */
64 #define uap_cpu_to_le16(x) swap_byte_16(x)
65 /** Convert to 32 bit little endian format from CPU format */
66 #define uap_cpu_to_le32(x) swap_byte_32(x)
67 /** Convert to 64 bit little endian format from CPU format */
68 #define uap_cpu_to_le64(x) swap_byte_64(x)
69 #else /* BIG_ENDIAN */
70 /** Do nothing */
71 #define uap_le16_to_cpu(x) x
72 /** Do nothing */
73 #define uap_le32_to_cpu(x) x
74 /** Do nothing */
75 #define uap_le64_to_cpu(x) x
76 /** Do nothing */
77 #define uap_cpu_to_le16(x) x
78 /** Do nothing */
79 #define uap_cpu_to_le32(x) x
80 /** Do nothing */
81 #define uap_cpu_to_le64(x) x
82 #endif /* BIG_ENDIAN */
83
84 /** uAP application version string */
85 #define UAP_VERSION         "uAP 1.4"
86
87 /** Success */
88 #define UAP_SUCCESS     1
89 /** Failure */
90 #define UAP_FAILURE     -1
91
92 #ifdef __GNUC__
93 /** Structure packing begins */
94 #define PACK_START
95 /** Structure packeing end */
96 #define PACK_END  __attribute__ ((packed))
97 #else
98 /** Structure packing begins */
99 #define PACK_START   __packed
100 /** Structure packeing end */
101 #define PACK_END
102 #endif
103
104 #ifndef ETH_ALEN
105 /** MAC address length */
106 #define ETH_ALEN    6
107 #endif
108
109 /** Netlink protocol number */
110 #define NETLINK_MARVELL         (MAX_LINKS - 1)
111 /** Netlink maximum payload size */
112 #define NL_MAX_PAYLOAD          1024
113 /** Netlink multicast group number */
114 #define NL_MULTICAST_GROUP      1
115 /** Default wait time in seconds for events */
116 #define UAP_RECV_WAIT_DEFAULT   10
117
118 /** Character, 1 byte */
119 typedef char s8;
120 /** Unsigned character, 1 byte */
121 typedef unsigned char u8;
122
123 /** Short integer */
124 typedef signed short s16;
125 /** Unsigned short integer */
126 typedef unsigned short u16;
127
128 /** Long integer */
129 typedef signed long s32;
130 /** Unsigned long integer */
131 typedef unsigned long u32;
132
133 /** event ID mask */
134 #define EVENT_ID_MASK                   0x0fff
135
136 /** Event header */
137 typedef PACK_START struct _EVENTHEADER
138 {
139     /** Event ID */
140     u32 EventId;
141     /** Event data */
142     u8 EventData[0];
143 } PACK_END EVENTHEADER;
144
145 /** Event ID length */
146 #define EVENT_ID_LEN    4
147
148 /** Event ID: STA deauth */
149 #define MICRO_AP_EV_ID_STA_DEAUTH   44
150
151 /** Event ID: STA associated */
152 #define MICRO_AP_EV_ID_STA_ASSOC    45
153
154 /** Event ID: BSS started */
155 #define MICRO_AP_EV_ID_BSS_START    46
156
157 /** Event ID: Debug event */
158 #define MICRO_AP_EV_ID_DEBUG         54
159
160 /** Event ID: BSS idle event */
161 #define MICRO_AP_EV_BSS_IDLE         67
162
163 /** Event ID: BSS active event */
164 #define MICRO_AP_EV_BSS_ACTIVE       68
165
166 /** TLV buffer header*/
167 typedef PACK_START struct _tlvbuf_header
168 {
169     /** Header type */
170     u16 type;
171     /** Header length */
172     u16 len;
173 } PACK_END tlvbuf_header;
174
175 /** TLV ID : WAPI Information */
176 #define MRVL_WAPI_INFO_TLV_ID        0x0167
177
178 /** TLV ID : Management Frame */
179 #define MRVL_MGMT_FRAME_TLV_ID       0x0168
180 /** Assoc Request */
181 #define SUBTYPE_ASSOC_REQUEST           0
182 /** Assoc Response */
183 #define SUBTYPE_ASSOC_RESPONSE          1
184 /** ReAssoc Request */
185 #define SUBTYPE_REASSOC_REQUEST         2
186 /** ReAssoc Response */
187 #define SUBTYPE_REASSOC_RESPONSE        3
188
189 /** Event body : STA deauth */
190 typedef PACK_START struct _EVENTBUF_STA_DEAUTH
191 {
192     /** Deauthentication reason */
193     u16 ReasonCode;
194     /** MAC address of deauthenticated STA */
195     u8 StaMacAddress[ETH_ALEN];
196 } PACK_END EVENTBUF_STA_DEAUTH;
197
198 /** Event body : STA associated */
199 typedef PACK_START struct _EVENTBUF_STA_ASSOC
200 {
201     /** Reserved */
202     u8 Reserved[2];
203     /** MAC address of associated STA */
204     u8 StaMacAddress[ETH_ALEN];
205     /** Assoc request/response buffer */
206     u8 AssocPayload[0];
207 } PACK_END EVENTBUF_STA_ASSOC;
208
209 /** Event body : BSS started */
210 typedef PACK_START struct _EVENTBUF_BSS_START
211 {
212     /** Reserved */
213     u8 Reserved[2];
214     /** MAC address of BSS */
215     u8 apMacAddress[ETH_ALEN];
216 } PACK_END EVENTBUF_BSS_START;
217
218 /**
219  *                 IEEE 802.11 MAC Message Data Structures                   
220  *                                                                           
221  * Each IEEE 802.11 MAC message includes a MAC header, a frame body (which   
222  * can be empty), and a frame check sequence field. This section gives the   
223  * structures that used for the MAC message headers and frame bodies that    
224  * can exist in the three types of MAC messages - 1) Control messages,       
225  * 2) Data messages, and 3) Management messages.                             
226  */
227 #ifdef BIG_ENDIAN
228 typedef PACK_START struct _IEEEtypes_FrameCtl_t
229 {
230         /** Order */
231     u8 Order:1;
232         /** Wep */
233     u8 Wep:1;
234         /** MoreData */
235     u8 MoreData:1;
236         /** PwrMgmt */
237     u8 PwrMgmt:1;
238         /** Retry */
239     u8 Retry:1;
240         /** MoreFrag */
241     u8 MoreFrag:1;
242         /** FromDs */
243     u8 FromDs:1;
244         /** ToDs */
245     u8 ToDs:1;
246         /** Subtype */
247     u8 Subtype:4;
248         /** Type */
249     u8 Type:2;
250     /** Protocol Version */
251     u8 ProtocolVersion:2;
252 } PACK_END IEEEtypes_FrameCtl_t;
253 #else
254 typedef PACK_START struct _IEEEtypes_FrameCtl_t
255 {
256         /** Protocol Version */
257     u8 ProtocolVersion:2;
258         /** Type */
259     u8 Type:2;
260         /** Subtype */
261     u8 Subtype:4;
262         /** ToDs */
263     u8 ToDs:1;
264         /** FromDs */
265     u8 FromDs:1;
266         /** MoreFrag */
267     u8 MoreFrag:1;
268         /** Retry */
269     u8 Retry:1;
270         /** PwrMgmt */
271     u8 PwrMgmt:1;
272         /** MoreData */
273     u8 MoreData:1;
274         /** Wep */
275     u8 Wep:1;
276         /** Order */
277     u8 Order:1;
278 } PACK_END IEEEtypes_FrameCtl_t;
279 #endif
280
281 /** IEEEtypes_AssocRqst_t */
282 typedef PACK_START struct _IEEEtypes_AssocRqst_t
283 {
284         /** CapInfo */
285     u16 CapInfo;
286         /** ListenInterval */
287     u16 ListenInterval;
288         /** IE Buffer */
289     u8 IEBuffer[0];
290 } PACK_END IEEEtypes_AssocRqst_t;
291
292 /** IEEEtypes_AssocRsp_t */
293 typedef PACK_START struct _IEEEtypes_AssocRsp_t
294 {
295         /** CapInfo */
296     u16 CapInfo;
297         /** StatusCode */
298     u16 StatusCode;
299         /** AID */
300     u16 AId;
301 } PACK_END IEEEtypes_AssocRsp_t;
302
303 /** IEEEtypes_ReAssocRqst_t */
304 typedef PACK_START struct _IEEEtypes_ReAssocRqst_t
305 {
306         /** CapInfo */
307     u16 CapInfo;
308         /** ListenInterval */
309     u16 ListenInterval;
310         /** Current APAddr */
311     u8 CurrentApAddr[ETH_ALEN];
312         /** IE Buffer */
313     u8 IEBuffer[0];
314 } PACK_END IEEEtypes_ReAssocRqst_t;
315
316 /** MrvlIEtypes_WapiInfoSet_t */
317 typedef PACK_START struct _MrvlIEtypes_WapiInfoSet_t
318 {
319         /** Type */
320     u16 Type;
321         /** Length */
322     u16 Len;
323         /** Multicast PN */
324     u8 MulticastPN[16];
325 } PACK_END MrvlIEtypes_WapiInfoSet_t;
326
327 /** MrvlIETypes_MgmtFrameSet_t */
328 typedef PACK_START struct _MrvlIETypes_MgmtFrameSet_t
329 {
330         /** Type */
331     u16 Type;
332         /** Length */
333     u16 Len;
334         /** Frame Control */
335     IEEEtypes_FrameCtl_t FrameControl;
336         /** Frame Contents */
337     u8 FrameContents[0];
338 } PACK_END MrvlIETypes_MgmtFrameSet_t;
339
340 /**Debug Type : Event */
341 #define DEBUG_TYPE_EVENT        0
342 /**Debug Type : Info */
343 #define DEBUG_TYPE_INFO         1
344
345 /** Major debug id: Authenticator */
346 #define DEBUG_ID_MAJ_AUTHENTICATOR      1
347 /** Minor debug id: PWK1 */
348 #define DEBUG_MAJ_AUTH_MIN_PWK1         0
349 /** Minor debug id: PWK2 */
350 #define DEBUG_MAJ_AUTH_MIN_PWK2         1
351 /** Minor debug id: PWK3 */
352 #define DEBUG_MAJ_AUTH_MIN_PWK3         2
353 /** Minor debug id: PWK4 */
354 #define DEBUG_MAJ_AUTH_MIN_PWK4         3
355 /** Minor debug id: GWK1 */
356 #define DEBUG_MAJ_AUTH_MIN_GWK1         4
357 /** Minor debug id: GWK2 */
358 #define DEBUG_MAJ_AUTH_MIN_GWK2         5
359 /** Minor debug id: station reject */
360 #define DEBUG_MAJ_AUTH_MIN_STA_REJ      6
361 /** Minor debug id: EAPOL_TR */
362 #define DEBUG_MAJ_AUTH_MIN_EAPOL_TR     7
363
364 /** Major debug id: Assoicate agent */
365 #define DEBUG_ID_MAJ_ASSOC_AGENT        2
366 /** Minor debug id: WPA IE*/
367 #define DEBUG_ID_MAJ_ASSOC_MIN_WPA_IE   0
368 /** Minor debug id: station reject */
369 #define DEBUG_ID_MAJ_ASSOC_MIN_STA_REJ  1
370
371 /** ether_hdr */
372 typedef PACK_START struct
373 {
374         /** dest address */
375     u8 da[ETH_ALEN];
376         /** src address */
377     u8 sa[ETH_ALEN];
378         /** header type */
379     u16 type;
380 } PACK_END ether_hdr_t;
381
382 /** 8021x header */
383 typedef PACK_START struct
384 {
385         /** protocol version*/
386     u8 protocol_ver;
387         /** packet type*/
388     u8 pckt_type;
389         /** packet len */
390     u8 pckt_body_len;
391 } PACK_END Hdr_8021x_t;
392
393 /** nonce size */
394 #define NONCE_SIZE      32
395 /** max wpa ie len */
396 #define MAX_WPA_IE_LEN       64
397 /** EAPOL mic size */
398 #define EAPOL_MIC_SIZE        16
399
400 /** EAPOL key message */
401 typedef PACK_START struct
402 {
403         /** Ether header */
404     ether_hdr_t Ether_Hdr;
405         /** 8021x header */
406     Hdr_8021x_t hdr_8021x;
407         /** desc_type */
408     u8 desc_type;
409         /** key info */
410     u16 k;
411         /** key length */
412     u16 key_length;
413         /** replay count */
414     u32 replay_cnt[2];
415         /** key nonce */
416     u8 key_nonce[NONCE_SIZE];
417         /** key IV */
418     u8 EAPOL_key_IV[16];
419         /** key RSC */
420     u8 key_RSC[8];
421         /** key ID */
422     u8 key_ID[8];
423         /** key MIC */
424     u8 key_MIC[EAPOL_MIC_SIZE];
425         /** key len */
426     u16 key_material_len;
427         /** key data */
428     u8 key_data[MAX_WPA_IE_LEN];
429 } PACK_END EAPOL_KeyMsg_Debug_t;
430
431 /** failure after receive EAPOL MSG2 PMK */
432 #define REJECT_STATE_FAIL_EAPOL_2       1
433 /** failure after receive EAPOL MSG4 PMK*/
434 #define REJECT_STATE_FAIL_EAPOL_4       2
435 /** failure after receive EAPOL Group MSG2 GWK */
436 #define REJECT_STATE_FAIL_EAPOL_GROUP_2  3
437
438 /** Fail reason: Invalid ie */
439 #define IEEEtypes_REASON_INVALID_IE     13
440 /** Fail reason: Mic failure */
441 #define IEEEtypes_REASON_MIC_FAILURE    14
442
443 /** station reject */
444 typedef PACK_START struct
445 {
446         /** reject state */
447     u8 reject_state;
448         /** reject reason */
449     u16 reject_reason;
450         /** station mac address */
451     u8 staMacAddr[ETH_ALEN];
452 } PACK_END sta_reject_t;
453
454 /** wpa_ie */
455 typedef PACK_START struct
456 {
457         /** station mac address */
458     u8 staMacAddr[ETH_ALEN];
459         /** wpa ie */
460     u8 wpa_ie[MAX_WPA_IE_LEN];
461 } PACK_END wpaIe_t;
462
463 /** initial state of the state machine */
464 #define EAPOL_START             1
465 /** sent eapol msg1, wait for msg2 from the client */
466 #define EAPOL_WAIT_PWK2         2
467 /** sent eapol msg3, wait for msg4 from the client */
468 #define EAPOL_WAIT_PWK4         3
469 /** sent eapol group key msg1, wait for group msg2 from the client */
470 #define EAPOL_WAIT_GTK2         4
471 /** eapol handshake complete */
472 #define EAPOL_END               5
473
474 /** eapol state */
475 typedef PACK_START struct
476 {
477         /** eapol state*/
478     u8 eapolState;
479         /** station address*/
480     u8 staMacAddr[ETH_ALEN];
481 } PACK_END eapolState_t;
482
483 /**debug Info */
484 typedef PACK_START union
485 {
486         /** eapol key message */
487     EAPOL_KeyMsg_Debug_t eapol_pwkMsg;
488         /** station reject*/
489     sta_reject_t sta_reject;
490         /** wpa ie */
491     wpaIe_t wpaIe;
492         /** eapol state */
493     eapolState_t eapol_state;
494 } PACK_END dInfo;
495
496 /** Event body : Debug */
497 typedef PACK_START struct _EVENTBUF_DEBUG
498 {
499         /** debug type */
500     u8 debugtype;
501         /** Major debug id */
502     u32 debugIdMajor;
503         /** Minor debug id */
504     u32 debugIdMinor;
505         /** debug Info */
506     dInfo info;
507 } PACK_END EVENTBUF_DEBUG;
508 #endif /* _UAP_H */