3 * @brief Header file for uapevent application
5 * Copyright (C) 2008-2009, Marvell International Ltd.
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.
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.
21 /************************************************************************
23 03/18/08: Initial creation
24 ************************************************************************/
29 #if (BYTE_ORDER == LITTLE_ENDIAN)
33 /** 16 bits byte swap */
34 #define swap_byte_16(x) \
35 ((u16)((((u16)(x) & 0x00ffU) << 8) | \
36 (((u16)(x) & 0xff00U) >> 8)))
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)))
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) ))
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 */
71 #define uap_le16_to_cpu(x) x
73 #define uap_le32_to_cpu(x) x
75 #define uap_le64_to_cpu(x) x
77 #define uap_cpu_to_le16(x) x
79 #define uap_cpu_to_le32(x) x
81 #define uap_cpu_to_le64(x) x
82 #endif /* BIG_ENDIAN */
84 /** uAP application version string */
85 #define UAP_VERSION "uAP 1.4"
90 #define UAP_FAILURE -1
93 /** Structure packing begins */
95 /** Structure packeing end */
96 #define PACK_END __attribute__ ((packed))
98 /** Structure packing begins */
99 #define PACK_START __packed
100 /** Structure packeing end */
105 /** MAC address length */
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
118 /** Character, 1 byte */
120 /** Unsigned character, 1 byte */
121 typedef unsigned char u8;
124 typedef signed short s16;
125 /** Unsigned short integer */
126 typedef unsigned short u16;
129 typedef signed long s32;
130 /** Unsigned long integer */
131 typedef unsigned long u32;
134 #define EVENT_ID_MASK 0x0fff
137 typedef PACK_START struct _EVENTHEADER
143 } PACK_END EVENTHEADER;
145 /** Event ID length */
146 #define EVENT_ID_LEN 4
148 /** Event ID: STA deauth */
149 #define MICRO_AP_EV_ID_STA_DEAUTH 44
151 /** Event ID: STA associated */
152 #define MICRO_AP_EV_ID_STA_ASSOC 45
154 /** Event ID: BSS started */
155 #define MICRO_AP_EV_ID_BSS_START 46
157 /** Event ID: Debug event */
158 #define MICRO_AP_EV_ID_DEBUG 54
160 /** Event ID: BSS idle event */
161 #define MICRO_AP_EV_BSS_IDLE 67
163 /** Event ID: BSS active event */
164 #define MICRO_AP_EV_BSS_ACTIVE 68
166 /** TLV buffer header*/
167 typedef PACK_START struct _tlvbuf_header
173 } PACK_END tlvbuf_header;
175 /** TLV ID : WAPI Information */
176 #define MRVL_WAPI_INFO_TLV_ID 0x0167
178 /** TLV ID : Management Frame */
179 #define MRVL_MGMT_FRAME_TLV_ID 0x0168
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
189 /** Event body : STA deauth */
190 typedef PACK_START struct _EVENTBUF_STA_DEAUTH
192 /** Deauthentication reason */
194 /** MAC address of deauthenticated STA */
195 u8 StaMacAddress[ETH_ALEN];
196 } PACK_END EVENTBUF_STA_DEAUTH;
198 /** Event body : STA associated */
199 typedef PACK_START struct _EVENTBUF_STA_ASSOC
203 /** MAC address of associated STA */
204 u8 StaMacAddress[ETH_ALEN];
205 /** Assoc request/response buffer */
207 } PACK_END EVENTBUF_STA_ASSOC;
209 /** Event body : BSS started */
210 typedef PACK_START struct _EVENTBUF_BSS_START
214 /** MAC address of BSS */
215 u8 apMacAddress[ETH_ALEN];
216 } PACK_END EVENTBUF_BSS_START;
219 * IEEE 802.11 MAC Message Data Structures
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.
228 typedef PACK_START struct _IEEEtypes_FrameCtl_t
250 /** Protocol Version */
251 u8 ProtocolVersion:2;
252 } PACK_END IEEEtypes_FrameCtl_t;
254 typedef PACK_START struct _IEEEtypes_FrameCtl_t
256 /** Protocol Version */
257 u8 ProtocolVersion:2;
278 } PACK_END IEEEtypes_FrameCtl_t;
281 /** IEEEtypes_AssocRqst_t */
282 typedef PACK_START struct _IEEEtypes_AssocRqst_t
286 /** ListenInterval */
290 } PACK_END IEEEtypes_AssocRqst_t;
292 /** IEEEtypes_AssocRsp_t */
293 typedef PACK_START struct _IEEEtypes_AssocRsp_t
301 } PACK_END IEEEtypes_AssocRsp_t;
303 /** IEEEtypes_ReAssocRqst_t */
304 typedef PACK_START struct _IEEEtypes_ReAssocRqst_t
308 /** ListenInterval */
310 /** Current APAddr */
311 u8 CurrentApAddr[ETH_ALEN];
314 } PACK_END IEEEtypes_ReAssocRqst_t;
316 /** MrvlIEtypes_WapiInfoSet_t */
317 typedef PACK_START struct _MrvlIEtypes_WapiInfoSet_t
325 } PACK_END MrvlIEtypes_WapiInfoSet_t;
327 /** MrvlIETypes_MgmtFrameSet_t */
328 typedef PACK_START struct _MrvlIETypes_MgmtFrameSet_t
335 IEEEtypes_FrameCtl_t FrameControl;
336 /** Frame Contents */
338 } PACK_END MrvlIETypes_MgmtFrameSet_t;
340 /**Debug Type : Event */
341 #define DEBUG_TYPE_EVENT 0
342 /**Debug Type : Info */
343 #define DEBUG_TYPE_INFO 1
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
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
372 typedef PACK_START struct
380 } PACK_END ether_hdr_t;
383 typedef PACK_START struct
385 /** protocol version*/
391 } PACK_END Hdr_8021x_t;
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
400 /** EAPOL key message */
401 typedef PACK_START struct
404 ether_hdr_t Ether_Hdr;
406 Hdr_8021x_t hdr_8021x;
416 u8 key_nonce[NONCE_SIZE];
424 u8 key_MIC[EAPOL_MIC_SIZE];
426 u16 key_material_len;
428 u8 key_data[MAX_WPA_IE_LEN];
429 } PACK_END EAPOL_KeyMsg_Debug_t;
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
438 /** Fail reason: Invalid ie */
439 #define IEEEtypes_REASON_INVALID_IE 13
440 /** Fail reason: Mic failure */
441 #define IEEEtypes_REASON_MIC_FAILURE 14
443 /** station reject */
444 typedef PACK_START struct
450 /** station mac address */
451 u8 staMacAddr[ETH_ALEN];
452 } PACK_END sta_reject_t;
455 typedef PACK_START struct
457 /** station mac address */
458 u8 staMacAddr[ETH_ALEN];
460 u8 wpa_ie[MAX_WPA_IE_LEN];
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 */
475 typedef PACK_START struct
479 /** station address*/
480 u8 staMacAddr[ETH_ALEN];
481 } PACK_END eapolState_t;
484 typedef PACK_START union
486 /** eapol key message */
487 EAPOL_KeyMsg_Debug_t eapol_pwkMsg;
489 sta_reject_t sta_reject;
493 eapolState_t eapol_state;
496 /** Event body : Debug */
497 typedef PACK_START struct _EVENTBUF_DEBUG
501 /** Major debug id */
503 /** Minor debug id */
507 } PACK_END EVENTBUF_DEBUG;