Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | |
Brett Rudley | 3327989 | 2010-10-01 18:03:27 -0700 | [diff] [blame] | 17 | #include <typedefs.h> |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/string.h> |
| 20 | #include <linuxver.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | */ |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 27 | bool bcm_is_wfa_ie(u8 *ie, u8 **tlvs, uint *tlvs_len, u8 type) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 46 | wpa_ie_fixed_t *BCMROMFN(bcm_find_wpaie) (u8 * parse, uint len) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 47 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 48 | bcm_tlv_t *ie; |
| 49 | |
| 50 | while ((ie = bcm_parse_tlvs(parse, len, DOT11_MNG_VS_ID))) { |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 51 | if (bcm_is_wpa_ie((u8 *) ie, &parse, &len)) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 52 | return (wpa_ie_fixed_t *) ie; |
| 53 | } |
| 54 | } |
| 55 | return NULL; |
| 56 | } |