1/* 2 * bcm_supenv.h -- Minimal data structures to support wlc_sup.c in user space 3 * 4 * Copyright (C) 2014, Broadcom Corporation 5 * All Rights Reserved. 6 * 7 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; 8 * the contents of this file may not be disclosed to third parties, copied 9 * or duplicated in any form, in whole or in part, without the prior 10 * written permission of Broadcom Corporation. 11 * 12 * $Id: bcm_supenv.h,v 1.9 2010-03-08 22:49:25 $ 13 */ 14 15#ifndef _bcm_supenv_h 16#define _bcm_supenv_h 17 18#include <proto/ethernet.h> 19#include <proto/802.11.h> 20 21#if defined(BCM_OSL) 22#include "osl.h" 23#else 24#include <bcm_osl.h> 25#include <bcm_lbuf.h> 26#endif 27 28#include <bcmutils.h> 29 30typedef struct wsec_iv { 31 uint32 hi; /* upper 32 bits of IV */ 32 uint16 lo; /* lower 16 bits of IV */ 33} wsec_iv_t; 34 35#include <wlioctl.h> 36 37#if defined(BCM_OSL) 38#define TXOFF 170 39#endif 40 41 42typedef struct wlc_bss_info 43{ 44 struct ether_addr BSSID; /* network BSSID */ 45 uint8 SSID_len; /* the length of SSID */ 46 uint8 SSID[32]; /* SSID string */ 47 struct dot11_bcn_prb *bcn_prb; /* beacon/probe response frame (ioctl na) */ 48 uint16 bcn_prb_len; /* beacon/probe response frame length (ioctl na) */ 49 50} wlc_bss_info_t; 51 52struct wlc_pub { 53 uint unit; 54 wlc_bss_info_t current_bss; /* STA BSS if active, else first AP BSS */ 55 osl_t *osh; /* pointer to os handle */ 56#ifdef WLCNT 57 wl_cnt_t _cnt; /* monolithic counters struct */ 58 wl_wme_cnt_t _wme_cnt; /* Counters for WMM */ 59#endif /* WLCNT */ 60#ifdef BCMWPA2 61 pmkid_cand_t pmkid_cand[MAXPMKID]; /* PMKID candidate list */ 62 uint npmkid_cand; /* num PMKID candidates */ 63 pmkid_t pmkid[MAXPMKID]; /* PMKID cache */ 64 uint npmkid; /* num cached PMKIDs */ 65#endif /* BCMWPA2 */ 66 67 68}; 69typedef struct wlc_pub wlc_pub_t; 70 71#ifdef WLCNT 72#define WLCNTINCR(a) ((a)++) 73#else 74#define WLCNTINCR(a) 75#endif /* WLCNT */ 76 77/* Lots of fakery to avoid source code changes! */ 78 79#define BCM_SUPFRMBUFSZ 2048 80#define WLC_MAXBSSCFG 4 81 82struct wlc_bsscfg { 83 struct wlc_info *wlc; /* wlc to which this bsscfg belongs. */ 84 bool inuse; /* is this config in use */ 85 bool up; /* is this configuration up */ 86 bool enable; /* is this configuration enabled */ 87 bool _ap; /* is this configuration an AP */ 88 89 90 void *sup; /* pointer to supplicant state */ 91 int sup_type; /* type of supplicant */ 92 void *authenticator; /* pointer to authenticator state */ 93 uint8 SSID_len; /* the length of SSID */ 94 uint8 SSID[DOT11_MAX_SSID_LEN]; /* SSID string */ 95 96 struct ether_addr BSSID; /* BSSID */ 97 struct ether_addr cur_etheraddr; /* BSSID */ 98 uint16 WPA_auth; /* WPA: authenticated key management */ 99 100 wsec_iv_t wpa_none_txiv; /* global txiv for WPA_NONE, tkip and aes */ 101 bool have_keys; /* keys installed */ 102 bool auth_pending; 103 ctx_t ctx; /* holds context pointers */ 104 105 uint8 sup_ies[256]; /* assoc req ie */ 106 uint8 sup_ies_len; 107 uint8 auth_ies[256]; /* probe resp ie */ 108 uint8 auth_ies_len; 109 struct dot11_assoc_resp *assoc_resp; /* last (re)association response */ 110 uint assoc_resp_len; 111 int btamp_enabled; 112 113 114}; 115 116typedef struct wlc_bsscfg wlc_bsscfg_t; 117struct wlc_info { 118 119 wlc_pub_t pub; /* wlc public state (must be first field of wlc) */ 120 void *wl; /* pointer to os-specific private state */ 121 bool sta_associated; /* true if STA bsscfg associated to AP */ 122 /* BSS Configurations */ 123 wlc_bsscfg_t bsscfg[WLC_MAXBSSCFG]; /* set of BSS configurations */ 124 125 wlc_bsscfg_t cfg; /* the primary bsscfg (can be AP or STA) */ 126 int sup_wpa2_eapver; 127 bool sup_m3sec_ok; 128 struct dot11_assoc_resp *assoc_resp; /* last (re)association response */ 129 uint assoc_resp_len; 130 131}; 132 133typedef struct wlc_info wlc_info_t; 134 135 136typedef struct supplicant supplicant_t; 137 138 139/* Absolutely minimalist pktbuffer utilities */ 140 141 142 143extern void bcm_supenv_init(void); 144 145extern void 146wlc_mac_event(wlc_info_t* wlc, uint msg, const struct ether_addr* addr, 147 uint result, uint status, uint auth_type, void *data, int datalen); 148 149extern void 150wlc_getrand(wlc_info_t *wlc, uint8 *buf, int buflen); 151 152extern char * 153bcm_ether_ntoa(const struct ether_addr *ea, char *buf); 154 155 156/* macros to help with different environments */ 157#define SEND_PKT(bsscfg, p) wpaif_sendpkt((bsscfg), (p)) 158 159#define PLUMB_TK(a, b) wpaif_plumb_ptk((a), (b)) 160 161#define PLUMB_GTK(pkey, bsscfg) \ 162 wpaif_plumb_gtk((pkey), (bsscfg)) 163 164#define AUTHORIZE(bsscfg) \ 165 wpaif_set_authorize(bsscfg) 166#define PUSH_KRK_TO_WLDRIVER(bsscfg, krk, krk_len) \ 167 wpaif_set_krk(bsscfg, krk, krk_len) 168 169#define DEAUTHENTICATE(bsscfg, reason) \ 170 wpaif_set_deauth(bsscfg, reason); 171 172extern int 173wpaif_plumb_ptk(wl_wsec_key_t *key, wlc_bsscfg_t *bsscfg); 174extern int 175wpaif_plumb_gtk(wl_wsec_key_t *key, wlc_bsscfg_t *bsscfg); 176extern int 177wpaif_set_authorize(wlc_bsscfg_t *bsscfg); 178extern int 179wpaif_set_deauth(wlc_bsscfg_t *bsscfg, int reason); 180 181extern int 182wpaif_sendpkt(wlc_bsscfg_t *bsscfg, void *p); 183extern int 184wpaif_set_krk(wlc_bsscfg_t *bsscfg, uint8 *krk, int krk_len); 185 186/* supplicant status callback */ 187void wpaif_forward_mac_event_cb(wlc_bsscfg_t *bsscfg, uint reason, uint status); 188 189#endif /* _bcm_supenv_h */ 190