blob: 76359a2f2f0c901a161230d06ce98e94fb963e1b [file] [log] [blame]
Henry Ptasinskia9533e72010-09-08 21:04:42 -07001/*
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
Brett Rudley33279892010-10-01 18:03:27 -070017#include <typedefs.h>
18#include <linux/kernel.h>
19#include <linux/string.h>
20#include <linuxver.h>
Henry Ptasinskia9533e72010-09-08 21:04:42 -070021#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 */
Greg Kroah-Hartman36ef9a12010-10-05 10:02:49 -070027bool bcm_is_wfa_ie(u8 *ie, u8 **tlvs, uint *tlvs_len, u8 type)
Henry Ptasinskia9533e72010-09-08 21:04:42 -070028{
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
Greg Kroah-Hartman36ef9a12010-10-05 10:02:49 -070046wpa_ie_fixed_t *BCMROMFN(bcm_find_wpaie) (u8 * parse, uint len)
Jason Coopera2627bc2010-09-14 09:45:31 -040047{
Henry Ptasinskia9533e72010-09-08 21:04:42 -070048 bcm_tlv_t *ie;
49
50 while ((ie = bcm_parse_tlvs(parse, len, DOT11_MNG_VS_ID))) {
Greg Kroah-Hartman36ef9a12010-10-05 10:02:49 -070051 if (bcm_is_wpa_ie((u8 *) ie, &parse, &len)) {
Henry Ptasinskia9533e72010-09-08 21:04:42 -070052 return (wpa_ie_fixed_t *) ie;
53 }
54 }
55 return NULL;
56}