Staging: brcm80211: remove FALSE #define
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / brcm80211 / util / bcmwpa.c
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 #include <typedefs.h>
18 #include <linux/kernel.h>
19 #include <linux/string.h>
20 #include <linuxver.h>
21 #include <bcmutils.h>
22 #include <bcmwpa.h>
23
24 /* Is this body of this tlvs entry a WFA entry? If
25 * not update the tlvs buffer pointer/length.
26 */
27 bool bcm_is_wfa_ie(u8 *ie, u8 **tlvs, uint *tlvs_len, u8 type)
28 {
29 /* If the contents match the WFA_OUI and type */
30 if ((ie[TLV_LEN_OFF] > (WFA_OUI_LEN + 1)) &&
31 !bcmp(&ie[TLV_BODY_OFF], WFA_OUI, WFA_OUI_LEN) &&
32 type == ie[TLV_BODY_OFF + WFA_OUI_LEN]) {
33 return true;
34 }
35
36 /* point to the next ie */
37 ie += ie[TLV_LEN_OFF] + TLV_HDR_LEN;
38 /* calculate the length of the rest of the buffer */
39 *tlvs_len -= (int)(ie - *tlvs);
40 /* update the pointer to the start of the buffer */
41 *tlvs = ie;
42
43 return false;
44 }
45
46 wpa_ie_fixed_t *BCMROMFN(bcm_find_wpaie) (u8 * parse, uint len)
47 {
48 bcm_tlv_t *ie;
49
50 while ((ie = bcm_parse_tlvs(parse, len, DOT11_MNG_VS_ID))) {
51 if (bcm_is_wpa_ie((u8 *) ie, &parse, &len)) {
52 return (wpa_ie_fixed_t *) ie;
53 }
54 }
55 return NULL;
56 }