2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
18 #include <linux/kernel.h>
19 #include <linux/string.h>
24 /* Is this body of this tlvs entry a WFA entry? If
25 * not update the tlvs buffer pointer/length.
27 bool bcm_is_wfa_ie(u8
*ie
, u8
**tlvs
, uint
*tlvs_len
, u8 type
)
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
]) {
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 */
46 wpa_ie_fixed_t
*BCMROMFN(bcm_find_wpaie
) (u8
* parse
, uint len
)
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
;