Staging: Add initial release of brcm80211 - Broadcom 802.11n wireless LAN driver.
[linux-2.6-block.git] / drivers / staging / brcm80211 / include / bcmwpa.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef _BCMWPA_H_
18 #define _BCMWPA_H_
19
20 #include <proto/wpa.h>
21 #include <proto/802.11.h>
22 #include <wlioctl.h>
23
24 /* Field sizes for WPA key hierarchy */
25 #define WPA_MIC_KEY_LEN         16
26 #define WPA_ENCR_KEY_LEN        16
27 #define WPA_TEMP_ENCR_KEY_LEN   16
28 #define WPA_TEMP_TX_KEY_LEN     8
29 #define WPA_TEMP_RX_KEY_LEN     8
30
31 #define PMK_LEN                 32
32 #define TKIP_PTK_LEN            64
33 #define TKIP_TK_LEN             32
34 #define AES_PTK_LEN             48
35 #define AES_TK_LEN              16
36
37 /* limits for pre-shared key lengths */
38 #define WPA_MIN_PSK_LEN         8
39 #define WPA_MAX_PSK_LEN         64
40
41 #define WLC_SW_KEYS(wlc, bsscfg) ((((wlc)->wsec_swkeys) || \
42         ((bsscfg)->wsec & WSEC_SWFLAG)))
43
44 #define WSEC_WEP_ENABLED(wsec)  ((wsec) & WEP_ENABLED)
45 #define WSEC_TKIP_ENABLED(wsec) ((wsec) & TKIP_ENABLED)
46 #define WSEC_AES_ENABLED(wsec)  ((wsec) & AES_ENABLED)
47 #define WSEC_ENABLED(wsec)      ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
48 #define WSEC_SES_OW_ENABLED(wsec)       ((wsec) & SES_OW_ENABLED)
49 #define IS_WPA_AUTH(auth)       ((auth) == WPA_AUTH_NONE || \
50                                  (auth) == WPA_AUTH_UNSPECIFIED || \
51                                  (auth) == WPA_AUTH_PSK)
52 #define INCLUDES_WPA_AUTH(auth) \
53                         ((auth) & (WPA_AUTH_NONE | WPA_AUTH_UNSPECIFIED | WPA_AUTH_PSK))
54
55 #define IS_WPA2_AUTH(auth)      ((auth) == WPA2_AUTH_UNSPECIFIED || \
56                                  (auth) == WPA2_AUTH_PSK)(
57 #define INCLUDES_WPA2_AUTH(auth) \
58                         ((auth) & (WPA2_AUTH_UNSPECIFIED | \
59                                    WPA2_AUTH_PSK))
60
61 #define IS_WPA_AKM(akm) ((akm) == RSN_AKM_NONE || \
62                                  (akm) == RSN_AKM_UNSPECIFIED || \
63                                  (akm) == RSN_AKM_PSK)
64 #define IS_WPA2_AKM(akm)        ((akm) == RSN_AKM_UNSPECIFIED || \
65                                  (akm) == RSN_AKM_PSK)
66
67 #define MAX_ARRAY 1
68 #define MIN_ARRAY 0
69
70 /* convert wsec to WPA mcast cipher. algo is needed only when WEP is enabled. */
71 #define WPA_MCAST_CIPHER(wsec, algo)    (WSEC_WEP_ENABLED(wsec) ? \
72                 ((algo) == CRYPTO_ALGO_WEP128 ? WPA_CIPHER_WEP_104 : WPA_CIPHER_WEP_40) : \
73                         WSEC_TKIP_ENABLED(wsec) ? WPA_CIPHER_TKIP : \
74                         WSEC_AES_ENABLED(wsec) ? WPA_CIPHER_AES_CCM : \
75                         WPA_CIPHER_NONE)
76
77 /* Look for a WPA IE; return it's address if found, NULL otherwise */
78 extern wpa_ie_fixed_t *BCMROMFN(bcm_find_wpaie) (uint8 * parse, uint len);
79
80 /* Check whether the given IE looks like WFA IE with the specific type. */
81 extern bool bcm_is_wfa_ie(uint8 * ie, uint8 ** tlvs, uint * tlvs_len,
82                           uint8 type);
83 /* Check whether pointed-to IE looks like WPA. */
84 #define bcm_is_wpa_ie(ie, tlvs, len)    bcm_is_wfa_ie(ie, tlvs, len, WFA_OUI_TYPE_WPA)
85
86 #endif                          /* _BCMWPA_H_ */