/*******************************************************************************
 * Agere Systems Inc.
 * Wireless device driver for Linux (wlags49).
 *
 * Copyright (c) 1998-2003 Agere Systems Inc. 
 * All rights reserved.
 *   http://www.agere.com
 *
 * Initially developed by TriplePoint, Inc.
 *   http://www.triplepoint.com
 *
 *------------------------------------------------------------------------------
 *
 *   Header for defintions and macros internal to the drvier.
 *
 *------------------------------------------------------------------------------
 *
 * SOFTWARE LICENSE
 *
 * This software is provided subject to the following terms and conditions,
 * which you should read carefully before using the software.  Using this
 * software indicates your acceptance of these terms and conditions.  If you do
 * not agree with these terms and conditions, do not use the software.
 *
 * Copyright © 2003 Agere Systems Inc.
 * All rights reserved.
 *
 * Redistribution and use in source or binary forms, with or without
 * modifications, are permitted provided that the following conditions are met:
 *
 * . Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following Disclaimer as comments in the code as
 *    well as in the documentation and/or other materials provided with the
 *    distribution.
 * 
 * . Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following Disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * . Neither the name of Agere Systems Inc. nor the names of the contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * Disclaimer
 *
 * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT 
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
 ******************************************************************************/




/*******************************************************************************
 * VERSION CONTROL INFORMATION
 *******************************************************************************
 *
 * $Author: vjs $
 * $Date: 2004/02/23 15:35:27 $
 * $Revision: 1.43 $
 * $Source: /cvsroot/wifi/wl_lkm/include/wireless/wl_internal.h,v $
 *
 ******************************************************************************/




#ifndef __WAVELAN2_H__
#define __WAVELAN2_H__




/*******************************************************************************
 *  include files
 ******************************************************************************/
#ifdef BUS_PCMCIA
#include <pcmcia/config.h>
#include <pcmcia/k_compat.h>
#include <pcmcia/version.h>
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/cisreg.h>
#include <pcmcia/ciscode.h>
#include <pcmcia/ds.h>
#endif  // BUS_PCMCIA

#ifdef HAS_WIRELESS_EXTENSIONS
#include <linux/wireless.h>
#if WIRELESS_EXT > 13
#include <net/iw_handler.h>
#endif // WIRELESS_EXT > 13
#define USE_DBM
#define RETURN_CURRENT_NETWORKNAME
#define USE_FREQUENCY
#endif /* HAS_WIRELESS_EXTENSIONS */

#include <linux/list.h>

#include <linux/interrupt.h>
#include <linux/tqueue.h>




/*******************************************************************************
 *  constant definitions
 ******************************************************************************/
#define p_u8    __u8
#define p_s8    __s8
#define p_u16   __u16
#define p_s16   __s16
#define p_u32   __u32
#define p_s32   __s32
#define p_char  char

#define MAX_KEY_LEN         (2 + (13 * 2)) // 0x plus 13 hex digit pairs
#define MB_SIZE             1024
#define MAX_ENC_LEN         104

#define MAX_SCAN_TIME_SEC   8
#define MAX_NAPS            64

#define CFG_MB_INFO         0x0820		//Mail Box Info Block

#define NUM_WDS_PORTS       6

#define WVLAN_MAX_LOOKAHEAD (HCF_MAX_MSG+46) /* as per s0005MIC_4.doc */


/* Min/Max/Default Parameter Values */
#if (HCF_TYPE) & HCF_TYPE_AP
#define PARM_DEFAULT_SSID                       "LinuxAP"
#else
#define PARM_DEFAULT_SSID                       "ANY"
#endif

#define PARM_MIN_NAME_LEN                       1
#define PARM_MAX_NAME_LEN                       32

#define PARM_MIN_CHANNEL                        1
#define PARM_MAX_CHANNEL                        14
#define PARM_DEFAULT_CHANNEL                    10 /* default 1 or 10  */

#define PARM_MIN_SYSTEM_SCALE                   1
#define PARM_MAX_SYSTEM_SCALE                   5
#define PARM_DEFAULT_SYSTEM_SCALE               1

#define PARM_MIN_TX_RATE                        1
#define PARM_MAX_TX_RATE                        7
#define PARM_DEFAULT_TX_RATE                    3

#define PARM_MIN_RTS_THRESHOLD                  0
#define PARM_MAX_RTS_THRESHOLD                  2347
#define PARM_DEFAULT_RTS_THRESHOLD              2347

#define PARM_DEFAULT_MICROWAVE_ROBUSTNESS       FALSE
#define PARM_DEFAULT_MICROWAVE_ROBUSTNESS_STR   "N"

#define PARM_DEFAULT_MAC_ADDRESS                { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }

#define PARM_DEFAULT_OWN_NAME                   "Linux"

#define PARM_DEFAULT_ENABLE_ENCRYPTION          0
#define PARM_MIN_ENABLE_ENCRYPTION              0
#define PARM_MAX_ENABLE_ENCRYPTION              7

#define PARM_DEFAULT_AUTH_KEY_MGMT_SUITE        0
#define PARM_MIN_AUTH_KEY_MGMT_SUITE            0
#define PARM_MAX_AUTH_KEY_MGMT_SUITE            4

#define PARM_MIN_TX_KEY                         1
#define PARM_MAX_TX_KEY                         4
#define PARM_DEFAULT_TX_KEY                     1

#define PARM_MIN_MULTICAST_RATE                 1
#define PARM_MAX_MULTICAST_RATE                 4
#define PARM_DEFAULT_MULTICAST_RATE             2

#define PARM_MIN_PORT_TYPE                      1
#define PARM_MAX_PORT_TYPE                      3
#define PARM_DEFAULT_PORT_TYPE                  1

#define PARM_DEFAULT_CREATE_IBSS                FALSE
#define PARM_DEFAULT_CREATE_IBSS_STR            "N"

#define PARM_DEFAULT_RX_MULTICAST               TRUE
#define PARM_DEFAULT_RX_MULTICAST_STR           "Y"

#define PARM_MIN_MAX_PM_SLEEP                   1
#define PARM_MAX_MAX_PM_SLEEP                   65535
#define PARM_DEFAULT_MAX_PM_SLEEP               100

#define PARM_MIN_AUTHENTICATION                 1
#define PARM_MAX_AUTHENTICATION                 2
#define PARM_DEFAULT_AUTHENTICATION             1

#define PARM_MIN_OWN_ATIM_WINDOW                0
#define PARM_MAX_OWN_ATIM_WINDOW                100
#define PARM_DEFAULT_OWN_ATIM_WINDOW            0

#define PARM_MIN_PM_HOLDOVER_DURATION           1
#define PARM_MAX_PM_HOLDOVER_DURATION           1000
#define PARM_DEFAULT_PM_HOLDOVER_DURATION       100

#define PARM_DEFAULT_PROMISCUOUS_MODE           FALSE
#define PARM_DEFAULT_PROMISCUOUS_MODE_STR       "N"

#define PARM_MIN_OWN_DTIM_PERIOD                1
#define PARM_MAX_OWN_DTIM_PERIOD                65535
#define PARM_DEFAULT_OWN_DTIM_PERIOD            1

#define PARM_DEFAULT_REJECT_ANY                 FALSE
#define PARM_DEFAULT_REJECT_ANY_STR             "N"

#define PARM_DEFAULT_EXCLUDE_UNENCRYPTED        TRUE
#define PARM_DEFAULT_EXCLUDE_UNENCRYPTED_STR    "N"

#define PARM_DEFAULT_MULTICAST_PM_BUFFERING     TRUE
#define PARM_DEFAULT_MULTICAST_PM_BUFFERING_STR "Y"

#define PARM_DEFAULT_INTRA_BSS_RELAY            TRUE
#define PARM_DEFAULT_INTRA_BSS_RELAY_STR        "Y"


/* The following definitions pertain to module and profile parameters */
#define PARM_TX_RATE                            TxRateControl
#define PARM_NAME_TX_RATE                       TEXT("TxRateControl")
#define PARM_TX_RATE1                           TxRateControl1
#define PARM_NAME_TX_RATE1                      TEXT("TxRateControl1")
#define PARM_TX_RATE2                           TxRateControl2
#define PARM_NAME_TX_RATE2                      TEXT("TxRateControl2")
#define PARM_TX_RATE3                           TxRateControl3
#define PARM_NAME_TX_RATE3                      TEXT("TxRateControl3")
#define PARM_TX_RATE4                           TxRateControl4
#define PARM_NAME_TX_RATE4                      TEXT("TxRateControl4")
#define PARM_TX_RATE5                           TxRateControl5
#define PARM_NAME_TX_RATE5                      TEXT("TxRateControl5")
#define PARM_TX_RATE6                           TxRateControl6
#define PARM_NAME_TX_RATE6                      TEXT("TxRateControl6")

#define PARM_SYSTEM_SCALE                       SystemScale
#define PARM_NAME_SYSTEM_SCALE                  TEXT("SystemScale")


#define PARM_CHANNEL                            OwnChannel
#define PARM_NAME_CHANNEL                       TEXT("OwnChannel")

#define PARM_RTS_THRESHOLD                      RTSThreshold
#define PARM_NAME_RTS_THRESHOLD                 TEXT("RTSThreshold")
#define PARM_RTS_THRESHOLD1                     RTSThreshold1
#define PARM_NAME_RTS_THRESHOLD1                TEXT("RTSThreshold1")
#define PARM_RTS_THRESHOLD2                     RTSThreshold2
#define PARM_NAME_RTS_THRESHOLD2                TEXT("RTSThreshold2")
#define PARM_RTS_THRESHOLD3                     RTSThreshold3
#define PARM_NAME_RTS_THRESHOLD3                TEXT("RTSThreshold3")
#define PARM_RTS_THRESHOLD4                     RTSThreshold4
#define PARM_NAME_RTS_THRESHOLD4                TEXT("RTSThreshold4")
#define PARM_RTS_THRESHOLD5                     RTSThreshold5
#define PARM_NAME_RTS_THRESHOLD5                TEXT("RTSThreshold5")
#define PARM_RTS_THRESHOLD6                     RTSThreshold6
#define PARM_NAME_RTS_THRESHOLD6                TEXT("RTSThreshold6")

#define PARM_PM_ENABLED                         PMEnabled
#define PARM_NAME_PM_ENABLED                    TEXT("PMEnabled")

#define PARM_PM_MODE                            PowerMode
#define PARM_NAME_PM_MODE                       TEXT("PowerMode")

#define PARM_RX_MULTICAST                       MulticastReceive
#define PARM_NAME_RX_MULTICAST                  TEXT("MulticastReceive")

#define PARM_MAX_SLEEP                          MaxSleepDuration
#define PARM_NAME_MAX_SLEEP                     TEXT("MaxSleepDuration")

#define PARM_CREATE_IBSS                        CreateIBSS
#define PARM_NAME_CREATE_IBSS                   TEXT("CreateIBSS")

#define PARM_MICROWAVE_ROBUSTNESS               MicroWaveRobustness
#define PARM_NAME_MICROWAVE_ROBUSTNESS          TEXT("MicroWaveRobustness")

#define PARM_MULTICAST_RATE                     MulticastRate
#define PARM_NAME_MULTICAST_RATE                TEXT("MulticastRate")

#define PARM_DESIRED_SSID                       DesiredSSID
#define PARM_NAME_DESIRED_SSID                  TEXT("DesiredSSID")

#define PARM_OWN_SSID                           OwnSSID
#define PARM_NAME_OWN_SSID                      TEXT("OwnSSID")

#define PARM_OWN_NAME                           OwnName
#define PARM_NAME_OWN_NAME                      TEXT("OwnName")

#define PARM_KEY1                               Key1
#define PARM_NAME_KEY1                          TEXT("Key1")
#define PARM_KEY2                               Key2
#define PARM_NAME_KEY2                          TEXT("Key2")
#define PARM_KEY3                               Key3
#define PARM_NAME_KEY3                          TEXT("Key3")
#define PARM_KEY4                               Key4
#define PARM_NAME_KEY4                          TEXT("Key4")

#define PARM_TX_KEY                             TxKey
#define PARM_NAME_TX_KEY                        TEXT("TxKey")

#define PARM_KEY_FORMAT                         AsciiHex
#define PARM_NAME_KEY_FORMAT                    TEXT("AsciiHex")

#define PARM_ENABLE_ENCRYPTION                  EnableEncryption
#define PARM_NAME_ENABLE_ENCRYPTION             TEXT("EnableEncryption")

#define PARM_ENCRYPTION                         Encryption
#define PARM_NAME_ENCRYPTION                    TEXT("Encryption")

#define PARM_AUTH_KEY_MGMT_SUITE                AuthKeyMgmtSuite
#define PARM_NAME_AUTH_KEY_MGMT_SUITE           TEXT("AuthKeyMgmtSuite")

#define PARM_MAC_ADDRESS                        NetworkAddress
#define PARM_NAME_MAC_ADDRESS                   TEXT("NetworkAddress")

#define PARM_WDS_ADDRESS                        WDSAddress
#define PARM_NAME_WDS_ADDRESS					TEXT("WDSAddress")
#define PARM_WDS_ADDRESS1                       WDSAddress1
#define PARM_NAME_WDS_ADDRESS1					TEXT("WDSAddress1")
#define PARM_WDS_ADDRESS2                       WDSAddress2
#define PARM_NAME_WDS_ADDRESS2					TEXT("WDSAddress2")
#define PARM_WDS_ADDRESS3                       WDSAddress3
#define PARM_NAME_WDS_ADDRESS3					TEXT("WDSAddress3")
#define PARM_WDS_ADDRESS4                       WDSAddress4
#define PARM_NAME_WDS_ADDRESS4					TEXT("WDSAddress4")
#define PARM_WDS_ADDRESS5                       WDSAddress5
#define PARM_NAME_WDS_ADDRESS5					TEXT("WDSAddress5")
#define PARM_WDS_ADDRESS6                       WDSAddress6
#define PARM_NAME_WDS_ADDRESS6					TEXT("WDSAddress6")

#define PARM_VENDORDESCRIPTION                  VendorDescription
#define PARM_NAME_VENDORDESCRIPTION				TEXT("VendorDescription")

#define PARM_AP_MODE                            APMode
#define PARM_NAME_AP_MODE						TEXT("APMode")
#define PARM_DEFAULT_AP_MODE					FALSE

#define PARM_DOWNLOAD_FIRMWARE                  DownloadFirmware
#define PARM_NAME_DOWNLOAD_FIRMWARE             TEXT("DownloadFirmware")

#define PARM_CONFIGURED                         Configured
#define PARM_NAME_CONFIGURED					TEXT("Configured")

#define PARM_DRIVER_ENABLE                      DriverEnable
#define PARM_NAME_DRIVER_ENABLE					TEXT("DriverEnable")
#define PARM_DEFAULT_DRIVER_ENABLE				TRUE

#define PARM_OWN_ATIM_WINDOW                    OwnATIMWindow
#define PARM_NAME_OWN_ATIM_WINDOW				TEXT("OwnATIMWindow")

#define PARM_MAX_DATA_LENGTH                    MaxDataLength
#define PARM_NAME_MAX_DATA_LENGTH				TEXT("MaxDataLength")

#define PARM_PMEPS                              PMEPS
#define PARM_NAME_PMEPS                         TEXT("PMEPS")

#define PARM_PM_HOLDOVER_DURATION               PMHoldoverDuration
#define PARM_NAME_PM_HOLDOVER_DURATION          TEXT("PMHoldoverDuration")

#define PARM_OWN_DTIM_PERIOD                    OwnDTIMPeriod  
#define PARM_NAME_OWN_DTIM_PERIOD	            TEXT("OwnDTIMPeriod")

#define PARM_MULTICAST_PM_BUFFERING             MulticastPMBuffering
#define PARM_NAME_MULTICAST_PM_BUFFERING	    TEXT("MulticastPMBuffering")

#define PARM_REJECT_ANY                         RejectANY
#define PARM_NAME_REJECT_ANY				    TEXT("RejectANY")

#define PARM_AUTHENTICATION                     Authentication
#define PARM_NAME_AUTHENTICATION				TEXT("Authentication")

#define PARM_EXCLUDE_UNENCRYPTED                ExcludeUnencrypted
#define PARM_NAME_EXCLUDE_UNENCRYPTED           TEXT("ExcludeUnencrypted")

#define PARM_INTRA_BSS_RELAY                    IntraBSSRelay
#define PARM_NAME_INTRA_BSS_RELAY               TEXT("IntraBSSRelay")

#define PARM_NETWORK_TYPE                       NetworkType
#define PARM_NAME_NETWORK_TYPE					TEXT("NetworkType")
#define PARM_DEFAULT_NETWORK_TYPE   			0

#define PARM_PROMISCUOUS_MODE                   PromiscuousMode
#define PARM_NAME_PROMISCUOUS_MODE              TEXT("PromiscuousMode")

#define PARM_PORT_TYPE                          PortType
#define PARM_NAME_PORT_TYPE                     TEXT("PortType")



/*******************************************************************************
 *  macro definitions
 ******************************************************************************/
/* The following macro ensures that no symbols are exported, minimizing the 
   chance of a symbol collision in the kernel */
EXPORT_NO_SYMBOLS;

#define NELEM(arr) (sizeof(arr) / sizeof(arr[0]))

#define WVLAN_VALID_MAC_ADDRESS( x ) \
((x[0]!=0xFF) && (x[1]!=0xFF) && (x[2]!=0xFF) && (x[3]!=0xFF) && (x[4]!=0xFF) && (x[5]!=0xFF))




/*******************************************************************************
 * type definitions
 ******************************************************************************/
#undef FALSE
#undef TRUE

typedef enum
{
    FALSE = 0,
    TRUE  = 1
}
bool_t;


typedef struct _ScanResult
{
	//hcf_16        len;
	//hcf_16        typ;
    int             scan_complete;
    int             num_aps;
	SCAN_RS_STRCT   APTable [MAX_NAPS];
} 
ScanResult;


typedef struct _LINK_STATUS_STRCT
{
    hcf_16  len;
    hcf_16  typ;
    hcf_16  linkStatus;     /* 1..5 */
}
LINK_STATUS_STRCT;


typedef struct _ASSOC_STATUS_STRCT
{
    hcf_16  len;
    hcf_16  typ;
    hcf_16  assocStatus;            /* 1..3 */
    hcf_8   staAddr[ETH_ALEN];
    hcf_8   oldApAddr[ETH_ALEN];
}
ASSOC_STATUS_STRCT;


typedef struct _SECURITY_STATUS_STRCT
{
    hcf_16  len;
    hcf_16  typ;
    hcf_16  securityStatus;     /* 1..3 */
    hcf_8   staAddr[ETH_ALEN];
    hcf_16  reason;     
}
SECURITY_STATUS_STRCT;

#define WVLAN_WMP_PDU_TYPE_LT_REQ       0x00
#define WVLAN_WMP_PDU_TYPE_LT_RSP       0x01
#define WVLAN_WMP_PDU_TYPE_APL_REQ      0x02
#define WVLAN_WMP_PDU_TYPE_APL_RSP      0x03

typedef struct wvlan_eth_hdr
{
    unsigned char   dst[ETH_ALEN];           /* Destination address. */
    unsigned char   src[ETH_ALEN];           /* Source address. */
    unsigned short  len;                    /* Length of the PDU. */
}
WVLAN_ETH_HDR, *PWVLAN_ETH_HDR;

typedef struct wvlan_llc_snap
{
    unsigned char   dsap;                   /* DSAP (0xAA) */
    unsigned char   ssap;                   /* SSAP (0xAA) */
    unsigned char   ctrl;                   /* Control (0x03) */
    unsigned char   oui[3];                 /* Organization Unique ID (00-60-1d). */
    unsigned char   specid[2];              /* Specific ID code (00-01). */
}
WVLAN_LLC_SNAP, *PWVLAN_LLC_SNAP;


typedef struct wvlan_lt_hdr
{
    unsigned char   version;                /* Version (0x00) */
    unsigned char   type;                   /* PDU type: 0-req/1-resp. */
    unsigned short  id;                     /* Identifier to associate resp to req. */
}
WVLAN_LT_HDR, *PWVLAN_LT_HDR;


typedef struct wvlan_wmp_hdr
{
    unsigned char   version;                /* Version  */
    unsigned char   type;                   /* PDU type */
}
WVLAN_WMP_HDR, *PWVLAN_WMP_HDR;


#define FILLER_SIZE             1554
#define TEST_PATTERN_SIZE       54


typedef struct wvlan_lt_req
{
	unsigned char   Filler[TEST_PATTERN_SIZE];   /* minimal length of 54 bytes */
}
WVLAN_LT_REQ, *PWVLAN_LT_REQ;


typedef struct wvlan_lt_rsp
{
	char           name[32];
	/* Measured Data */
	unsigned char  signal;
	unsigned char  noise;
	unsigned char  rxFlow;	
	unsigned char  dataRate;
	unsigned short protocol;
	/* Capabilities */
	unsigned char  station;
	unsigned char  dataRateCap;
	unsigned char  powerMgmt[4];
	unsigned char  robustness[4];
	unsigned char  scaling;
	unsigned char  reserved[5];
}
WVLAN_LT_RSP, *PWVLAN_LT_RSP;


typedef struct wvlan_rx_wmp_hdr
{
	unsigned short status;
	unsigned short reserved1[2];
	unsigned char  silence;
	unsigned char  signal;
	unsigned char  rate;
	unsigned char  rxFlow;
	unsigned short reserved2[2];
	unsigned short frameControl;	
	unsigned short duration;
	unsigned short address1[3];
	unsigned short address2[3];
	unsigned short address3[3];
	unsigned short sequenceControl;
	unsigned short address4[3];
#ifdef HERMES2
	unsigned short reserved3[5];
	unsigned short reserved4;
#endif /* HERMES2 */
	unsigned short HeaderDataLen;
} 
WVLAN_RX_WMP_HDR, *PWVLAN_RX_WMP_HDR;


typedef struct wvlan_linktest_req_pdu 
{
    WVLAN_ETH_HDR     ethHdr;
    WVLAN_LLC_SNAP    llcSnap;
    WVLAN_LT_HDR      ltHdr;
    WVLAN_LT_REQ      ltReq;
} 
WVLAN_LINKTEST_REQ_PDU, *PWVLAN_LINKTEST_REQ_PDU;


typedef struct wvlan_linktest_rsp_pdu
{
    WVLAN_RX_WMP_HDR  wmpRxHdr;
    WVLAN_ETH_HDR     ethHdr;
    WVLAN_LLC_SNAP    llcSnap;
    WVLAN_LT_HDR      ltHdr;
    WVLAN_LT_RSP      ltRsp;
}
WVLAN_LINKTEST_RSP_PDU, *PWVLAN_LINKTEST_RSP_PDU;


typedef struct _LINKTEST_RSP_STRCT
{
    hcf_16                   len;
    hcf_16                   typ;
    WVLAN_LINKTEST_RSP_PDU   ltRsp;
}
LINKTEST_RSP_STRCT;


typedef struct wvlan_wmp_rsp_pdu
{
    WVLAN_RX_WMP_HDR  wmpRxHdr;
    WVLAN_ETH_HDR     ethHdr;
    WVLAN_LLC_SNAP    llcSnap;
    WVLAN_WMP_HDR     wmpHdr;
}
WVLAN_WMP_RSP_PDU, *PWVLAN_WMP_RSP_PDU;


typedef struct _WMP_RSP_STRCT
{
    hcf_16              len;
    hcf_16              typ;
    WVLAN_WMP_RSP_PDU   wmpRsp;
}
WMP_RSP_STRCT;


typedef struct _PROBE_RESP 
{
	// first part: 802.11
	hcf_16	length;
	hcf_16	infoType;
	hcf_16	reserved0;
	//hcf_8	signal;
	hcf_8	silence;
    hcf_8	signal;     // Moved signal here as signal/noise values were flipped
	hcf_8	rxFlow;
	hcf_8	rate;
	hcf_16	reserved1[2];
	
	// second part:
	hcf_16	frameControl;
	hcf_16	durID;
	hcf_8	address1[6];
	hcf_8	address2[6];
	hcf_8	BSSID[6];					//! this is correct, right ?
	hcf_16	sequence;
	hcf_8	address4[6];

#if ((HCF_TYPE) & HCF_TYPE_HII)
	hcf_8	reserved2[12];
#endif	/*((HCF_TYPE) & HCF_TYPE_HII) */

	hcf_16	dataLength;
										// the information in the next 3 fields (DA/SA/LenType) is actually not filled in.
	hcf_8	DA[6];
	hcf_8	SA[6];
	hcf_16	lenType;
	
	hcf_8	timeStamp[8];
	hcf_16	beaconInterval;
	hcf_16	capability;
	hcf_8	rawData[200];				//! <<< think about this number !
	hcf_16	flags;
} 
PROBE_RESP, *PPROBE_RESP;


typedef struct _ProbeResult
{
    int         scan_complete;
    int         num_aps;
    PROBE_RESP  ProbeTable[MAX_NAPS];
}
ProbeResult;

/* Definitions used to parse capabilities out of the probe responses */
#define CAPABILITY_ESS      0x0001
#define CAPABILITY_IBSS     0x0002
#define CAPABILITY_PRIVACY  0x0010

/* Definitions used to parse the Information Elements out of probe responses */
#define DS_INFO_ELEM                        0x03
#define GENERIC_INFO_ELEM                   0xdd
#define WPA_MAX_IE_LEN                      40
#define WPA_SELECTOR_LEN                    4
#define WPA_OUI_TYPE                        { 0x00, 0x50, 0xf2, 1 }
#define WPA_VERSION                         1
#define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X     { 0x00, 0x50, 0xf2, 1 }
#define WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X   { 0x00, 0x50, 0xf2, 2 }
#define WPA_CIPHER_SUITE_NONE               { 0x00, 0x50, 0xf2, 0 }
#define WPA_CIPHER_SUITE_WEP40              { 0x00, 0x50, 0xf2, 1 }
#define WPA_CIPHER_SUITE_TKIP               { 0x00, 0x50, 0xf2, 2 }
#define WPA_CIPHER_SUITE_WRAP               { 0x00, 0x50, 0xf2, 3 }
#define WPA_CIPHER_SUITE_CCMP               { 0x00, 0x50, 0xf2, 4 }
#define WPA_CIPHER_SUITE_WEP104             { 0x00, 0x50, 0xf2, 5 }

typedef enum wvlan_drv_mode
{
    WVLAN_DRV_MODE_NO_DOWNLOAD,     /* this is the same as STA for Hermes 1    */
                                    /* it is also only applicable for Hermes 1 */
    WVLAN_DRV_MODE_STA,
    WVLAN_DRV_MODE_AP,
    WVLAN_DRV_MODE_MAX
}
WVLAN_DRV_MODE, *PWVLAN_DRV_MODE;


typedef enum wvlan_port_state
{
    WVLAN_PORT_STATE_DISABLED,
    WVLAN_PORT_STATE_ENABLED
}
WVLAN_PORT_STATE, *PWVLAN_PORT_STATE;


typedef enum wvlan_pm_state
{
    WVLAN_PM_STATE_DISABLED,
    WVLAN_PM_STATE_ENHANCED,
    WVLAN_PM_STATE_STANDARD
}
WVLAN_PM_STATE, *PWVLAN_PM_STATE;


typedef struct wvlan_frame 
{
    struct sk_buff  *skb;       /* sk_buff for frame. */
    hcf_16          port;       /* MAC port for the frame. */
    hcf_16          len;        /* Length of the frame. */
} 
WVLAN_FRAME, *PWVLAN_FRAME;


typedef struct wvlan_lframe 
{
    struct list_head    node;   /* Node in the list */
    WVLAN_FRAME	        frame;  /* Frame. */
} 
WVLAN_LFRAME, *PWVLAN_LFRAME;



#define DEFAULT_NUM_TX_FRAMES           48
#define TX_Q_LOW_WATER_MARK             (DEFAULT_NUM_TX_FRAMES/3)

#define WVLAN_MAX_TX_QUEUES             1


#ifdef USE_WDS

typedef struct wvlan_wds_if
{
    struct net_device           *dev;
    int                         is_registered;
    int                         netif_queue_on;
    struct net_device_stats     stats;
    hcf_16                      rtsThreshold;
    hcf_16                      txRateCntl;
    hcf_8                       wdsAddress[ETH_ALEN];
} WVLAN_WDS_IF, *PWVLAN_WDS_IF;

#endif  /* USE_WDS */


/* Structures used to deal with TKIP Pairwise and Group Keys */
/*
typedef struct wl_tkip_mapped
{
    hcf_8  eth_addr[ETH_ALEN];
    u8     key[16];
    u64    tsc;
    u64    rsc;
    u64    tx_mic;
    u64    rx_mic;
} WL_TKIP_MAPPED, *PWL_TKIP_MAPPED;

typedef struct wl_tkip_default
{
    hcf_16 tx_key;
    u64    rsc;
    u8     key[16];
    u64    tx_mic;
    u64    rx_mic;
    u64    tsc;
} WL_TKIP_DEFAULT, *PWL_TKIP_DEFAULT;
*/

struct wl_private
{

#ifdef BUS_PCMCIA
    dev_node_t                  node;
#endif


    struct net_device           *dev;
    struct net_device           *dev_next;
    spinlock_t                  slock;
    struct tq_struct            task;
    struct net_device_stats     stats;


#ifdef WIRELESS_EXT
    struct iw_statistics        wstats;
    int                         spy_number;
    u_char                      spy_address[IW_MAX_SPY][ETH_ALEN];
    struct iw_quality           spy_stat[IW_MAX_SPY];
#endif // WIRELESS_EXT


    IFB_STRCT                   hcfCtx;
    u_long                      flags;
    int                         is_registered;
    CFG_DRV_INFO_STRCT          driverInfo;
    CFG_IDENTITY_STRCT          driverIdentity;
    
    CFG_FW_IDENTITY_STRCT       StationIdentity;
    CFG_PRI_IDENTITY_STRCT      PrimaryIdentity;
    CFG_PRI_IDENTITY_STRCT      NICIdentity;
    
    ltv_t                       ltvRecord;
    u_long                      txBytes;
    hcf_16                      maxPort;        /* 0 for STA, 6 for AP */
    
    u_char                      lookAheadBuf[WVLAN_MAX_LOOKAHEAD];

    hcf_8                       PortType;           // 1 - 3 (1 [Normal] | 3 [AdHoc])
    hcf_8                       Channel;            // 0 - 14 (0)
    hcf_8                       TxRateControl;      // 1 - 7 (3)
    hcf_8                       DistanceBetweenAPs; // 1 - 3 (1)
    hcf_16                      RTSThreshold;       // 0 - 2347 (2347)
    hcf_8                       PMEnabled;          // 0 - 1 (0)
    hcf_8                       MicrowaveRobustness;// 0 - 1 (0)
    hcf_8                       CreateIBSS;         // 0 - 1 (0)
    hcf_8                       MulticastReceive;   // 0 - 1 (1)
    hcf_16                      MaxSleepDuration;   // 0 - 65535 (100)
    hcf_8                       MACAddress[ETH_ALEN];
    char                        NetworkName[HCF_MAX_NAME_LEN+1];
    char                        StationName[HCF_MAX_NAME_LEN+1];
    hcf_8                       EnableEncryption;   // 0 - 1 (0)
    char                        Key1[MAX_KEY_LEN+1];
    char                        Key2[MAX_KEY_LEN+1];
    char                        Key3[MAX_KEY_LEN+1];
    char                        Key4[MAX_KEY_LEN+1];
    hcf_8                       TransmitKeyID;      // 1 - 4 (1)
    CFG_DEFAULT_KEYS_STRCT	    DefaultKeys;
    u_char                      mailbox[MB_SIZE];
    char                        szEncryption[MAX_ENC_LEN];
    
    hcf_16                      driverEnable;
    hcf_16                      wolasEnable;
    hcf_16                      atimWindow;
    hcf_16                      holdoverDuration;
    hcf_8                       MulticastRate;      // 1 - 4 (2)
    
    hcf_16                      authentication; // is this AP specific?
    hcf_16                      promiscuousMode;
    WVLAN_DRV_MODE              DownloadFirmware;   // 0 - 2 (0 [None] | 1 [STA] | 2 [AP])

    hcf_16                      AuthKeyMgmtSuite;

    WVLAN_FRAME                 txF;
    WVLAN_LFRAME                txList[DEFAULT_NUM_TX_FRAMES];
    struct list_head            txFree;
    struct list_head            txQ[WVLAN_MAX_TX_QUEUES]; 
    int                         netif_queue_on;
    int                         txQ_count;
    DESC_STRCT                  desc_rx;
    DESC_STRCT                  desc_tx;


    WVLAN_PORT_STATE            portState;

    ScanResult                  scan_results;
    ProbeResult                 probe_results;
    int                         probe_num_aps;


#ifdef USE_RTS
    int                         useRTS;
#endif  // USE_RTS


#if (HCF_TYPE) & HCF_TYPE_AP
    hcf_8                       DTIMPeriod;         // 1 - 255 (1)
    hcf_16                      multicastPMBuffering;
    hcf_8                       RejectAny;          // 0 - 1 (0)
    hcf_8                       ExcludeUnencrypted; // 0 - 1 (1)
    hcf_16                      intraBSSRelay;

#ifdef USE_WDS
    WVLAN_WDS_IF                wds_port[NUM_WDS_PORTS];
#endif  /* USE_WDS */
#endif // HCF_AP
};




#endif  // __WAVELAN2_H__
