/*****************************************************************************
* Copyright (c) 2001-2004 Digi International Inc., All Rights Reserved
*
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
*
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
* 802.11 wireless driver API and parameters
*****************************************************************************/

#ifndef _WLN_API_H
#define _WLN_API_H

#include "Npttypes.h"

#ifdef __cplusplus
extern "C" {
#endif

/*ad*
 * Wireless driver/WPA provides the interface between the wireless
 * hardware and the TCP/IP stack and provides services needed for wireless
 * security.
 *
 * The wireless security features include support for WPA/WPA2 (802.11i),
 * which supersedes the previous security specification, Wired Equivalent
 * Privacy (WEP), which was shown to have severe security weaknesses.
 *
 * WPA2 authentication includes support for TLS, TTLS, and PEAP, with
 * CHAP, GTC, MD5, MSCHAP, MSCHAPv2, OTP, and PAP authentication methods
 * available for use with TTLS and PEAP.  WPA2 Encryption includes
 * AES-based CCMP, which provides confidentiality, integrity and origin
 * authentication.  WPA2 also includes support for client certificates
 * (for use with TLS), and verification of server certificates.
 *
 * In addition, WEP with 802.1x authentication (dynamic WEP keying) and
 * Cisco LEAP are also supported.
 *
 * Other features of the driver also include separate authentication and
 * encryption settings, settings for short preamble, and antenna diversity.
 * The ability to query current authentication, encryption (@link wln_get_params)
 * and wireless network statistics (@link wln_get_stats), and the ability
 * for SSID/RSSI scanning (@link wln_scan).
 *
 * @note To enable the wireless driver, set @link BSP_WANT_WIRELESS in
 * bsp.h to TRUE.  Set @link BSP_WANT_WPA to TRUE to also enable WPA2.
 *
 * @category wireless
 * @since 6.0
 * @overview Wireless Driver
 * @include "wpa_api.h"
 * @library  wpa,crypto,ssl
 * @platform connectwiem,connectwime,connectcorewi9c_a,connectwisp
 * @external
 *
*ad*/


/*ad*
 * The following are parameter size definitions for the wireless driver.
 *
 * @name WirelessParam "Wireless parameter sizes"
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_ADDR_SIZE         MAC address size
 * @param WLN_SSID_SIZE         SSID max size
 * @param WLN_WPAIE_SIZE        WPA info element size
 * @param WLN_KEY_NUM           Number of keys (0-3)
 * @param WLN_WEP40_SIZE        WEP-40 key size
 * @param WLN_WEP104_SIZE       WEP-104 key size
 * @param WLN_PSK_SIZE          WPA pre-shared key size
 * @param WLN_IDENT_SIZE        User identity size
 * @param WLN_PWD_SIZE          User password size
 * @param WLN_COUNTRY_STRLEN    Country string length for 802.11d
 *
 *
 * @note 802.11d support (WLN_COUNTRY_STRLEN) was added for v7.0.
*ad*/
#define WLN_ADDR_SIZE           6
#define WLN_SSID_SIZE           32
#define WLN_WPAIE_SIZE          40
#define WLN_KEY_NUM             4
#define WLN_WEP40_SIZE          5
#define WLN_WEP104_SIZE         13
#define WLN_PSK_SIZE            32
#define WLN_IDENT_SIZE          32
#define WLN_PWD_SIZE            32
#define WLN_COUNTRY_STRLEN      3

/*ad*
 * Wireless channel number values.
 *
 * @name WirelessChanNum "Channel number values"
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_CHAN_NUM          Number of channels (1-14)
 * @param WLN_CHAN_SCAN         Scan all channels
 * @param WLN_CHANMASK_ALL      Mask of all channels
*ad*/
#define WLN_CHAN_NUM            14
#define WLN_CHAN_SCAN           0
#define WLN_CHANMASK_ALL        0x00003fff


/*ad*
 * Provides the reason for disassociating from an AP.  See reason parameter
 * in @link wln_disassociate call.
 *
 * @name WirelessDisassociateReason "Disassociate Reason"
 *
 * @since 7.0
 * @category wireless
 * @external
 * @see @link wln_disassociate
 *
 * @param WLN_REAS_NOLONGERVALID    Client associated but not authorized
 * @param WLN_REAS_DEAUTH_LEAVING   The access point went offline, deauthenticating the client
 * @param WLN_REAS_INACTIVITY       Client session timeout exceeded
*ad*/
#define WLN_REAS_NOLONGERVALID  2
#define WLN_REAS_DEAUTH_LEAVING 3
#define WLN_REAS_INACTIVITY     4


/*ad*
 * Wireless band number values.
 *
 * @name WirelessBandNum "Band number values"
 *
 * @since 6.1
 * @category wireless
 * @see @link wln_params
 *
 * @param WLN_BAND_DEFAULT      Use Default hardware behavior (usually search all bands)
 * @param WLN_BAND_A            Use 802.11a (5 GHz)
 * @param WLN_BAND_B            Use 802.11bg (2.4 Ghz)
 * @param WLN_BAND_MAX          add any bands before this
*ad*/
#define WLN_BAND_DEFAULT 0
#define WLN_BAND_A       1
#define WLN_BAND_B       2
#define WLN_BAND_MAX     3

/*ad*
 * Authentication parameter values.
 * Any combination of these values may be specified to indicate which
 * authentication methods are allowed.  The actual method used will be selected
 * based on the capabilities of the wireless network being joined.
 *
 * @name WirelessAuthenParam "Authentication parameter values."
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_AUTH_ANY          Any available authentication method
 * @param WLN_AUTH_OPEN         Open system
 * @param WLN_AUTH_SHAREDKEY    Shared Key
 * @param WLN_AUTH_WEP_8021X    WEP with 802.1x authentication
 * @param WLN_AUTH_WPA_PSK      WPA with pre-shared key
 * @param WLN_AUTH_WPA_8021X    WPA with 802.1x authentication
 * @param WLN_AUTH_LEAP         Cisco LEAP
 *
 * @note	WEP keys parameters must be set if WLN_AUTH_SHAREDKEY is used.
 *          wpa_psk parameter must be set if WLN_AUTH_WPA_PSK is used.
 *          identity and password parameters must be set if WLN_AUTH_WEP_8021X
 *          or WLN_AUTH_WPA_8021X is used.
*ad*/
#define WLN_AUTH_ANY            0xffffffff
#define WLN_AUTH_OPEN           0x00000001
#define WLN_AUTH_SHAREDKEY      0x00000002
#define WLN_AUTH_WEP_8021X      0x00000004
#define WLN_AUTH_WPA_PSK        0x00000008
#define WLN_AUTH_WPA_8021X      0x00000010
#define WLN_AUTH_LEAP           0x00000020

/*ad*
 * encrypt parameter values used in @link wln_params and @link wln_status structures.
 *
 * Any combination of these values may be specified to indicate which
 * encryption methods are allowed.  The actual method used will be selected
 * based on the capabilities of the wireless network being joined.
 * This parameter only applies when WPA is being used.
 *
 * @name EncryptValues "Encryption parameter values."
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 * @see @link wln_status
 *
 * @param WLN_ENCR_ANY          Any available encryption method
 * @param WLN_ENCR_OPEN         Open system (no encryption)
 * @param WLN_ENCR_WEP          WEP
 * @param WLN_ENCR_TKIP         TKIP
 * @param WLN_ENCR_CCMP         CCMP (AES)
 *
 * @note	WEP keys parameters must be set if WLN_ENCR_WEP is used
 *          without 802.1x authentication.
*ad*/
#define	WLN_ENCR_ANY            0xffffffff
#define	WLN_ENCR_OPEN           0x00000001
#define	WLN_ENCR_WEP            0x00000002
#define	WLN_ENCR_TKIP           0x00000004
#define	WLN_ENCR_CCMP           0x00000008

/*ad*
 * EAP authentication method parameter values.
 * Any combination of these values may be specified to indicate which
 * authentication methods are allowed.  The actual method used will be selected
 * based on the capabilities of the wireless network being joined.
 * This parameter only applies when WPA with 802.1x authenticaion is being used.
 *
 * @name EAPValues "EAP authentication parameter values."
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_EAP_ANY           Any available authentication method
 * @param WLN_EAP_INNER_ANY     Any available inner authentication method
 * @param WLN_EAP_LEAP          Cicso LEAP
 * @param WLN_EAP_PEAP          Protected EAP
 * @param WLN_EAP_TLS           TLS (requires client certificate)
 * @param WLN_EAP_TTLS          Tunnelled TLS
 * @param WLN_EAP_GTC           PEAP/TTLS inner protocol: Generic token card
 * @param WLN_EAP_MD5           PEAP/TTLS inner protocol: MD5
 * @param WLN_EAP_MSCHAPV2      PEAP/TTLS inner protocol: MSCHAP version 2
 * @param WLN_EAP_OTP           PEAP/TTLS inner protocol: One time password
 * @param WLN_EAP_TTLS_CHAP     TTLS inner protocol: Challenge handshake
 * @param WLN_EAP_TTLS_MSCHAP   TTLS inner protocol: Microsoft CHAP
 * @param WLN_EAP_TTLS_MSCHAPV2 TTLS inner protocol: Microsoft CHAP version 2
 * @param WLN_EAP_TTLS_PAP      TTLS inner protocol: Password
 *
 * @note	One or more of WLN_EAP_GTC, WLN_EAP_MD5, WLN_EAP_MSCHAPV2,
 *          WLN_EAP_OTP, and WLN_EAP_TLS may be combined with WLN_EAP_PEAP
 *          or WLN_EAP_TTLS to specify the inner protocols to allow.
 *          One or more of WLN_EAP_TTLS_xxx may also be combined with WLN_EAP_TTLS.
*ad*/
#define WLN_EAP_ANY             0xffffffff
#define WLN_EAP_INNER_ANY       0xffffff00
#define WLN_EAP_LEAP            0x00000001
#define WLN_EAP_PEAP            0x00000002
#define WLN_EAP_TLS             0x00000004
#define WLN_EAP_TTLS            0x00000008
#define WLN_EAP_GTC             0x00000100
#define WLN_EAP_MD5             0x00000200
#define WLN_EAP_MSCHAPV2        0x00000400
#define WLN_EAP_OTP             0x00000800
#define WLN_EAP_TTLS_CHAP       0x00010000
#define WLN_EAP_TTLS_MSCHAP     0x00020000
#define WLN_EAP_TTLS_MSCHAPV2   0x00040000
#define WLN_EAP_TTLS_PAP        0x00080000


/*ad*
 * Option parameter values used in a @link wln_params structure.
 *
 * @name WirelessOptionValues "Wireless option parameter values"
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_OPT_ANTDIV        Enable antenna diversity
 * @param WLN_OPT_SHORTPRE      Enable short preamble
 * @param WLN_OPT_VERIFYCERT    Enable server certificate verification
 * @param WLN_OPT_BONLY         Use only 802.11b rates in 2.4 GHz band
 * @param WLN_OPT_RTSPROT       Use RTS/CTS protection frames for 802.11g
 * @param WLN_OPT_FIXEDRATE     Use fixed transmit rate
 * @param WLN_OPT_MULTI_DOMAIN  Enable 802.11 Multi domain capability (802.11d)
 *
 * @note 802.11d support (WLN_OPT_MULTI_DOMAIN) was added for v7.0.
*ad*/
#define WLN_OPT_ANTDIV          0x00000001
#define WLN_OPT_SHORTPRE        0x00000002
#define WLN_OPT_VERIFYCERT      0x00000004
#define WLN_OPT_BONLY           0x00000008
#define WLN_OPT_RTSPROT         0x00000010
#define WLN_OPT_FIXEDRATE       0x00000020
#define WLN_OPT_MULTI_DOMAIN    0x00000040

/*
 * Power saving mode parameter values.
 * A range of 0 to 5 is allowed.
 *
 * @name PowerModeParam "Power mode parameter"
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_PWR_MAX       Max power use (always on)
 * @param WLN_PWR_MIN       Min power use
 */
#define WLN_PWR_MAX             0
#define WLN_PWR_MIN             5

/*
 * Transmit power parameter values.
 * A range of 0 to 16 is allowed.
 * This may be further limited on some hardware.
 *
 * @name TxPowerParam "Transmit power parameter"
 *
 * @since 7.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_TXPOWER_MAX       Max transmit power
 * @param WLN_TXPOWER_DEFAULT   Default transmit power
 * @param WLN_TXPOWER_MIN       Min transmit power
 */
#define WLN_TXPOWER_MAX         16
#define WLN_TXPOWER_DEFAULT     16
#define WLN_TXPOWER_MIN         0

/*ad*
 * Capability field values.
 *
 * @name WirelessCapValues "Wireless capability field values"
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_status
 *
 * @param WLN_CAP_ESS           Extended service set (infrastructure)
 * @param WLN_CAP_IBSS          Independent BSS (ad hoc)
 * @param WLN_CAP_POLLABLE      Contention free pollable
 * @param WLN_CAP_POLLREQ       Contention free poll request
 * @param WLN_CAP_PRIVACY       Privacy (WEP) required
 * @param WLN_CAP_SHORTPRE      Short preambles allowed
 * @param WLN_CAP_PBCC          PBCC modulation allowed
 * @param WLN_CAP_AGILITY       Channel agility in use
*ad*/
#define WLN_CAP_ESS             0x0001
#define WLN_CAP_IBSS            0x0002
#define WLN_CAP_POLLABLE        0x0004
#define WLN_CAP_POLLREQ         0x0008
#define WLN_CAP_PRIVACY         0x0010
#define WLN_CAP_SHORTPRE        0x0020
#define WLN_CAP_PBCC            0x0040
#define WLN_CAP_AGILITY         0x0080

/*ad*
 * Rate field values.
 *
 * @name WirelessRateValues "Wireless rate field values"
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_scan_bss
 *
 * @param WLN_RATE_1_MBPS       1 mbps
 * @param WLN_RATE_2_MBPS       2 mbps
 * @param WLN_RATE_5_5_MBPS     5.5 mbps
 * @param WLN_RATE_11_MBPS      11 mbps
 * @param WLN_RATE_6_MBPS       6 mbps
 * @param WLN_RATE_9_MBPS       9 mbps
 * @param WLN_RATE_12_MBPS      12 mbps
 * @param WLN_RATE_18_MBPS      18 mbps
 * @param WLN_RATE_24_MBPS      24 mbps
 * @param WLN_RATE_36_MBPS      36 mbps
 * @param WLN_RATE_48_MBPS      48 mbps
 * @param WLN_RATE_54_MBPS      54 mbps
*ad*/
#define WLN_RATE_1_MBPS         0x0001
#define WLN_RATE_2_MBPS         0x0002
#define WLN_RATE_5_5_MBPS       0x0004
#define WLN_RATE_11_MBPS        0x0008
#define WLN_RATE_6_MBPS         0x0010
#define WLN_RATE_9_MBPS         0x0020
#define WLN_RATE_12_MBPS        0x0040
#define WLN_RATE_18_MBPS        0x0080
#define WLN_RATE_24_MBPS        0x0100
#define WLN_RATE_36_MBPS        0x0200
#define WLN_RATE_48_MBPS        0x0400
#define WLN_RATE_54_MBPS        0x0800

/*ad*
 * MAC address type
 *
 * @since 6.0
 * @external
 * @category wireless
 *
*ad*/
typedef uint8 mac_addr[WLN_ADDR_SIZE];


/*ad*
 * Possible values for APP_WLN_BSS_TYPE, which is #defined in appconf.h.
 *
 * @since 7.0
 * @category wireless
 * @external
 * @see @link wln_bss
 * @name APP_WLN_BSS_Values "Values for APP_WLN_BSS_TYPE"
 *
 * @note    The enumerated values defined by wln_bss cannot be used to set
 *          the value of APP_WLN_BSS_TYPE because the C preprocessor does not
 *          understand enumerated types and will parse them as zero.
 *
 * @param APP_WLN_BSS_ESS           Join infrastructure (access point)
 * @param APP_WLN_BSS_IBSS          Join or create independent (ad hoc)
 * @param APP_WLN_BSS_IBSS_JOIN     Join only independent (ad hoc)
 * @param APP_WLN_BSS_ANY           Join any type
 * @param APP_WLN_BSS_NONE          Do not join a BSS
*ad*/
#define APP_WLN_BSS_ESS             (0)
#define APP_WLN_BSS_IBSS            (1)
#define APP_WLN_BSS_IBSS_JOIN       (2)
#define APP_WLN_BSS_ANY             (3)
#define APP_WLN_BSS_NONE            (4)



/*ad*
 * BSS (wireless network) type values
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_params
 *
 * @param WLN_BSS_ESS           Join infrastructure (access point)
 * @param WLN_BSS_IBSS          Join or create independent (ad hoc)
 * @param WLN_BSS_IBSS_JOIN     Join only independent (ad hoc)
 * @param WLN_BSS_ANY           Join any type
 * @param WLN_BSS_NONE          Do not join a BSS
*ad*/
typedef enum {
    WLN_BSS_ESS         = APP_WLN_BSS_ESS,
    WLN_BSS_IBSS        = APP_WLN_BSS_IBSS,
    WLN_BSS_IBSS_JOIN   = APP_WLN_BSS_IBSS_JOIN,
    WLN_BSS_ANY         = APP_WLN_BSS_ANY,
    WLN_BSS_NONE        = APP_WLN_BSS_NONE
} wln_bss;

/*ad*
 * Association state values
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_status
 *
 * @param WLN_ST_STOPPED        Driver not running
 * @param WLN_ST_SCANNING       Scanning for BSS
 * @param WLN_ST_ASSOC_ESS      Associated with ESS
 * @param WLN_ST_AUTH_ESS       Authenticated with ESS (using dynamic keys)
 * @param WLN_ST_JOIN_IBSS      Joined ad hoc IBSS
 * @param WLN_ST_START_IBSS     Started ad hoc IBSS
*ad*/
typedef enum {
    WLN_ST_STOPPED,
    WLN_ST_SCANNING,
    WLN_ST_ASSOC_ESS,
    WLN_ST_AUTH_ESS,
    WLN_ST_JOIN_IBSS,
    WLN_ST_START_IBSS
} wln_state;

/*ad*
 * Event types
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_event_cb
 * @see @link wln_associate
 * @see @link wln_disassociate
 *
 * @param WLN_EVT_ASSOC         Associated with BSS
 * @param WLN_EVT_DISASSOC      Disassociated from BSS
 * @param WLN_EVT_MIC_FAIL      MIC failure
 * @param WLN_EVT_JOIN          Joined a BSS
 * @param WLN_EVT_SCAN_RESULTS  BSS scan results
 *
 * @note    Parameter associated with each event:
 *
 * <list type="unordered">
 *      <item> WLN_EVT_ASSOC        BSS ID </item>
 *      <item> WLN_EVT_DISASSOC     BSS ID </item>
 *      <item> WLN_EVT_MIC_FAIL     pointer to BOOL, TRUE if pairwise key </item>
 *      <item> WLN_EVT_JOIN         BSS ID </item>
 *      <item> WLN_EVT_SCAN_RESULTS pointer to @link wln_scan_data </item>
 * </list>
 *
 * After receiving a WLN_EVT_JOIN event, the application
 * should call @link wln_associate to assoicate with the BSS,
 * or @link wln_disassociate to reject it.  If WPA is enabled,
 * this is done by the WPA application.
*ad*/
typedef enum {
    WLN_EVT_ASSOC,
    WLN_EVT_DISASSOC,
    WLN_EVT_MIC_FAIL,
    WLN_EVT_JOIN,
    WLN_EVT_SCAN_RESULTS
} wln_event;

/*ad*
 * Key type values
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_set_key
 *
 * @param WLN_KEY_NONE          Delete current key
 * @param WLN_KEY_WEP           WEP
 * @param WLN_KEY_TKIP          TKIP
 * @param WLN_KEY_CCMP          CCMP (AES)
*ad*/
typedef enum {
    WLN_KEY_NONE,
    WLN_KEY_WEP,
    WLN_KEY_TKIP,
    WLN_KEY_CCMP
} wln_key_type;

/*ad*
 * Error codes
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_set_params
 *
 * @param WLN_SUCCESS       Successful
 * @param WLN_ERR_NULL      NULL parameter pointer
 * @param WLN_ERR_BSSTYPE   Bad BSS type value
 * @param WLN_ERR_SSID      Bad SSID value
 * @param WLN_ERR_CHANNEL   Bad channel number
 * @param WLN_ERR_STAADDR   Bad station MAC address
 * @param WLN_ERR_AUTH      Unsupported authentication type
 * @param WLN_ERR_ENCR      Unsupported encryption type
 * @param WLN_ERR_WEPID     Bad WEP key index
 * @param WLN_ERR_WEPKEY    Bad WEP key size
 * @param WLN_ERR_POWER     Bad power management value
 * @param WLN_ERR_TXPOWER   Bad transmit power value
*ad*/
typedef enum {
    WLN_SUCCESS     = 0,
    WLN_ERR_NULL    = -1,
    WLN_ERR_BSSTYPE = -2,
    WLN_ERR_SSID    = -3,
    WLN_ERR_CHANNEL = -4,
    WLN_ERR_STAADDR = -5,
    WLN_ERR_AUTH    = -6,
    WLN_ERR_ENCR    = -7,
    WLN_ERR_WEPID   = -8,
    WLN_ERR_WEPKEY  = -9,
    WLN_ERR_POWER   = -10,
    WLN_ERR_TXPOWER = -11
} wln_error;

/*ad*
 * Wireless parameters structure.
 * Used by both wireless driver and WPA application.
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_set_params
 * @see @link EncryptValues
 * @see @link EAPValues
 * @see @link WirelessOptionValues
 * @see @link wln_bss
 * @see @link WirelessBandNum
 * @see @link wln_get_params
 * @see @link wln_set_params
 * @see @link WirelessParam
 * @see @link WirelessChanNum
 *
 * @param bss_type      Network type: one of @link wln_bss
 * @param ssid          Current service set ID.  (Size limited to WLN_SSID_SIZE.  See @link WirelessParam)
 * @param ssid_len      Service set ID length in bytes.  Set to 0 to search.  This length is limited to WLN_SSID_SIZE.  See @link WirelessParam.
 * @param channel       1 through WLN_CHAN_NUM or use 0 or WLN_CHAN_SCAN to scan all channels.  See @link WirelessChanNum for details.
 * @param sta_addr      Station MAC address
 * @param authen        Authentication types allowed: one or more of @link WirelessAuthenParam
 * @param encrypt       Encryption types allowed: one or more of @link EncryptValues
 * @param wep_key_id    WEP key index: 0-3
 * @param wep_key_len   WEP key length: 0, 5, or 13
 * @param wep_key       WEP keys
 * @param wpa_psk       WPA pre-shared key
 * @param eap_methods   802.1x/EAP authentication methods allowed: one or more of @link EAPValues
 * @param identity      User identity (login), ASCII NUL terminated
 * @param password      User password, ASCII NUL terminated
 * @param options       Bitmap of options: one or more of @link WirelessOptionValues
 * @param chan_mask     Bitmap of allowed channels: bit 0 is channel 1, etc.
 * @param tx_rate       Max transmit rate (in 100 kbps), 0 to use any rate
 * @param rts_thresh    RTS threshold, 0 to use default of 2347. Its range is from 0 to 2347
 * @param frag_thresh   Fragmentation threshold, 0 to use default of 1536. Valid range is all even selections from 256 to 1536 bytes
 * @param power_mode    Desired Power management mode: 0-5.
 * @param tx_power      Transmit power, 0-16 dBm
 * @param band          Wireless band to use @link WirelessBandNum
 *
 * @note    Channels 1-14 are in the 2.4GHz band (802.11b/g).
 *
 *          WEP keys are used if WLN_AUTH_SHAREDKEY is set in authen,
 *          or if WLN_ENCR_WEP is set in encrypt and 802.1x authentication is not used.
 *          wpa_psk is used if WLN_AUTH_WPA_PSK is set in authen.
 *          identity and password are used if WLN_AUTH_WEP_8021X or WLN_AUTH_WPA_8021X
 *          is set in authen.
 *
 *          Not all hardware supports the power_mode member, thus the parameter
 *          could be ignored.
 *
 *          The tx_rate argument is in units of 100 kbps.  For example, a setting
 *          of 540 corresponds to 54000 kbps (54 mbps).  A setting of 0 will cause
 *          the driver to use the maximum allowed rate.
 *
*ad*/
typedef struct {
    wln_bss     bss_type;
    uint8       ssid[WLN_SSID_SIZE];
    int         ssid_len;
    int         channel;
    mac_addr    sta_addr;
    uint32      authen;
    uint32      encrypt;
    int         wep_key_id;
    int         wep_key_len;
    uint8       wep_key[WLN_KEY_NUM][WLN_WEP104_SIZE];
    uint8       wpa_psk[WLN_PSK_SIZE];
    uint32      eap_methods;
    char        identity[WLN_IDENT_SIZE+1];
    char        password[WLN_PWD_SIZE+1];
    uint32      options;
    uint32      chan_mask;
    int         tx_rate;
    int         rts_thresh;
    int         frag_thresh;
    int         power_mode;
    int         band;
    int         tx_power;
} wln_params;

/*ad*
 * Wireless status information structure
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_get_status
 * @see @link EncryptValues
 * @see @link WirelessCapValues
 * @see @link WirelessAuthenParam
 * @see @link wln_state
 * @see @link WirelessParam
 *
 * @param state         Associationn state: one of @link wln_state
 * @param ssid          Current service set ID.  (Size limited to WLN_SSID_SIZE.  See @link WirelessParam)
 * @param ssid_len      Service set ID length in bytes.  This length is limited to WLN_SSID_SIZE.  See @link WirelessParam.
 * @param channel       Current channel: 1-14
 * @param bss_addr      BSS ID (AP MAC address)
 * @param bss_caps      BSS capabilities, one of more of @link WirelessCapValues
 * @param wpa_info      WPA information element
 * @param rsn_info      RSN (WPA2) information element
 * @param authen        Authentication used: one of @link WirelessAuthenParam
 * @param encrypt       Encryption types used: one or more of @link EncryptValues
 * @param tx_rate       Current transmit rate (in 100 kbps)
 * @param rx_rate       Last received rate (in 100 kbps)
 * @param rx_signal     Last received signal strength (in dBm)
 * @param tx_power      Transmit power (in dBm) obtained from beacon (802.11d)
 * @param country_info  Contry string length in contry information element
 *
 * @note    The tx_rate argument is in units of 100 kbps.  For example, a setting
 *          of 540 corresponds to 54000 kbps (54 mbps).
 *
 *          The rx_signal value is typically in the range of -30 dBm (strong) to -90 dBm (weak).
 *
*ad*/
typedef struct {
    wln_state   state;
    uint8       ssid[WLN_SSID_SIZE];
    int         ssid_len;
    int         channel;
    mac_addr    bss_addr;
    uint16      bss_caps;
    uint8       wpa_info[WLN_WPAIE_SIZE];
    uint8       rsn_info[WLN_WPAIE_SIZE];
    uint32      authen;
    uint32      encrypt;
    int         tx_rate;
    int         rx_rate;
    int         rx_signal;
    int         tx_power;
    uint8       country_info[WLN_COUNTRY_STRLEN + 1];   /* +1 to word align */
} wln_status;

/*ad*
 * Wireless statistics structure.
 * This structure may constain additional driver-specific stats
 * following the listed items.  The @link wln_get_stats function returns
 * the actual size of the available data.
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_get_stats
 *
 * @param tx_bytes      Bytes transmitted
 * @param tx_frames     Directed frames transmitted
 * @param tx_bc_frames  Broadcast frames transmitted
 * @param rx_bytes      Bytes received
 * @param rx_frames     Directed frames received
 * @param rx_bc_frames  Broadcast frames received
*ad*/
typedef struct {
    int tx_bytes;
    int tx_frames;
    int tx_bc_frames;
    int rx_bytes;
    int rx_frames;
    int rx_bc_frames;
} wln_stats;

/*ad*
 * Wireless network (BSS) scan information structure.
 * This structure is part of the wln_scan_data structure.
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_scan_data
 * @see @link WirelessCapValues
 * @see @link WirelessRateValues
 * @see @link WirelessParam
 * @see @link WirelessChanNum
 *
 * @param ssid          Current service set ID.  (Size limited to WLN_SSID_SIZE.  See @link WirelessParam)
 * @param ssid_len      Service set ID length in bytes.  Set to 0 to search.  This length is limited to WLN_SSID_SIZE.  See @link WirelessParam.
 * @param channel       1 through WLN_CHAN_NUM or use 0 or WLN_CHAN_SCAN to scan all channels.  See @link WirelessChanNum for details.
 * @param bss_addr      BSS ID (AP MAC address)
 * @param bss_caps      BSS capabilities, one of more of @link WirelessCapValues
 * @param wpa_info      WPA information element
 * @param rsn_info      RSN (WPA2) information element
 * @param erp_info      802.11g extended rate PHY information
 * @param rates         Operational rates, one or more of @link WirelessRateValues
 * @param rates_basic   Basic rates, one or more of @link WirelessRateValues
 * @param atim          Ad hoc ATIM window size
 * @param tx_rate       Maximum transmit rate (in units of 100 kbps), so 540 == 54 mbps
 * @param rx_signal     Received signal strength (in dBm)
 *
 * @note    The tx_rate argument is in units of 100 kbps.  For example, a setting
 *          of 540 corresponds to 54000 kbps (54 mbps).
 *
 *          The (Operational) rate is the set of all rates, required and optional, allowed by the
 *          access point.
 *
 *          The rates_basic is the set of basic (required) rates.  A device must be able to receive
 *          all basic rates to associate with an Access Point.
 *
 *          The rx_signal value is typically in the range of -30 dBm (strong) to -90 dBm (weak).
 *
*ad*/
typedef struct {
    uint8       ssid[WLN_SSID_SIZE];
    int         ssid_len;
    int         channel;
    mac_addr    bss_addr;
    uint16      bss_caps;
    uint8       wpa_info[WLN_WPAIE_SIZE];
    uint8       rsn_info[WLN_WPAIE_SIZE];
    uint8       erp_info;
    uint16      rates;
    uint16      rates_basic;
    uint16      atim;
    int         tx_rate;
    int         rx_signal;
} wln_scan_bss;

/*ad*
 * Wireless network (BSS) scan information structure.
 * This structure is returned with a WLN_EVT_SCAN_RESULTS event
 * after a network scan is initiated by @link wln_scan call.
 *
 * @since 6.0
 * @category wireless
 * @external
 * @see @link wln_scan
 * @see @link wln_scan_bss
 *
 * @param count         Number of networks found
 * @param bss           Array of network information
*ad*/
typedef struct {
    int             count;
    wln_scan_bss    bss[1];
} wln_scan_data;

/*
 * Wireless driver API
 */

/*ad*
 * Install wireless driver into OS network stack.
 *
 * @external
 * @category wireless
 * @since 6.0
 *
 * @param ifname	network interface name (e.g. "wln0")
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_install(char * ifname);


/*ad*
 * Get wireless parameters.
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_params
 *
 * @param params    area to store parameters
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_get_params(wln_params * params);

/*ad*
 * Set wireless parameters.
 * Must be called before starting wireless interface.
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_params
 *
 * @param params    parameters to set
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_set_params(wln_params * params);

/*ad*
 * Get wireless status information.
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_status
 *
 * @param status    area to store data
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_get_status(wln_status * status);


/*ad*
 * Get wireless statistics counters.
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_stats
 *
 * @param stats     area to store data
 * @param size      maximum size of data in bytes
 *
 * @return size     actual size of data available
*ad*/
int wln_get_stats(wln_stats * stats, int size);

/*ad*
 * Scan for wireless networks.
 * Results are returned with a WLN_EVT_SCAN_RESULTS event.
 *
 * @external
 * @category wireless
 * @since 7.0
 * @see @link wln_set_event_cb
 * @see @link wln_remove_event_cb
 * @see @link wln_event_cb
 * @see @link wln_associate
 * @see @link wln_disassociate
 * @see @link WirelessChanNum
 *
 * @param ssid      Service set ID
 * @param ssid_len  SSID length in bytes.  Use 0 to scan for all SSIDs
 * @param channel   1 through WLN_CHAN_NUM or use 0 or WLN_CHAN_SCAN to scan all channels.  See @link WirelessChanNum for details.
 *
 * @return 0        successful
 * @return negative error
 *
 * @note    Device will remain associated with the current network if any.
 *          Some interruption to data flow may occur during the scan process.
*ad*/
int wln_scan(uint8 * ssid, int ssid_len, int channel);

/*ad*
 * Associate with a wireless network.
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_disassociate
 *
 * @param ssid      Service set ID
 * @param ssid_len  SSID length in bytes, 0 to scan all
 * @param channel   1 through WLN_CHAN_NUM or use 0 or WLN_CHAN_SCAN to scan all channels.  See @link WirelessChanNum for details.
 * @param bss_addr  BSS to associate with
 * @param bss_caps  BSS capabilities, one of more of @link WirelessCapValues
 * @param wpa_ie    WPA info element to send, NULL if none
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_associate(uint8 * ssid, int ssid_len, int channel, mac_addr bss_addr, uint16 bss_caps, uint8 * wpa_ie);

/*ad*
 * Disassociate from a wireless network.
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_associate
 * @see @link WirelessDisassociateReason
 *
 * @param bss_addr  BSS to disassociate from
 * @param reason    Reason code for disassociation.  Use @link WirelessDisassociateReason codes.
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_disassociate(mac_addr bss_addr, int reason);

/*ad*
 * Set an encryption key.
 * Keys may be changed while the wireless interface is running.
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_key_type
 *
 * @param type      key type, one of @link wln_key_type
 * @param addr      peer station if pairwise key, broadcast address if group key
 * @param id        key index (0-3)
 * @param tx        TRUE if key is used to transmit
 * @param key       key data
 * @param key_len   key length in bytes
 * @param seq       packet sequence number, NULL if none
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_set_key(wln_key_type type, mac_addr addr, int id, BOOL tx, uint8 * key, int key_len, uint8 * seq);

/*ad*
 * Send a packet to the wireless network.
 *
 * @external
 * @category wireless
 * @since 6.0
 *
 * @param data      packet containing ethernet header and payload
 * @param len       total length in bytes
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_send(uint8 * data, int len);

/*ad*
 * Received packet callback function pointer type
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_set_receive_cb
 *
 * @param context   value given to @link wln_set_receive_cb
 * @param src       source MAC address
 * @param data      payload data
 * @param len       data size in bytes
*ad*/
typedef void(* wln_receive_cb)(void * context, mac_addr src, uint8 * data, int len);

/*ad*
 * Set callback function for received packets.  One callback can be set for 
 * each protocol type.  Protocol types without a callback are sent to the OS 
 * network stack.
 *
 * @note    When ep_type is set to WLN_MONITOR_TYPE (see @link WirelessEPTypes), the system 
 *          goes into promiscuous mode where callback function func receives all network 
 *          traffic.
 *
 *          To disable promiscuous/monitor mode, and resume normal operation, call
 *          the @link wln_set_receive_cb function with ep_type set to WLN_MONITOR_TYPE
 *          and a NULL callback function.
 *
 *			If you wish the module to be silent (no wireless frames transmitted) while in
 *			promiscuous/monitor mode, the network type must be set to WLN_BSS_NONE or 
 *			"Do not join a BSS". If the unit is setup for any other mode, probe requests and 
 *			responses may still be transmitted.
 *
 *
 * @external
 * @category wireless
 * @since 6.0
 * @see @link wln_receive_cb
 * @see @link WirelessEPTypes
 *
 * @param ep_type   Protocol Type: one of @link WirelessEPTypes 
 * @param func      callback function
 * @param context   value passed to callback function
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_set_receive_cb(int ep_type, wln_receive_cb func, void * context);

/*ad*
 * Event callback function pointer type
 *
 * @external
 * @category wireless
 * @since 6.3
 * @see @link wln_event
 * @see @link wln_set_event_cb
 *
 * @param context   value given to @link wln_set_event_cb
 * @param event     event type, one of @link wln_event
 * @param param     event-specific parameter
*ad*/
typedef void (* wln_event_cb)(void * context, wln_event event, void * param);

/*ad*
 * Sets the event callback function.  When any @link wln_event occurs, the 
 * callback function is invoked.  
 *
 * Note this callback function can be called from interrupt context, thus extreme care 
 * should be taken when implementing the callback function.  See programmers guide and 
 * references for programming limitations during interrupt context.
 * 
 * @note    Note this callback function can be called from interrupt context.
 *
 * @see @link wln_scan
 * @see @link wln_remove_event_cb
 * @see @link wln_event_cb
 * @external
 * @category wireless
 * @since 6.3
 *
 * @param func      callback function
 * @param context   value passed to callback function
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_set_event_cb(wln_event_cb func, void * context);

/*ad*
 * Remove event callback function set by @link wln_set_event_cb call.
 *
 * @see @link wln_scan
 * @see @link wln_set_event_cb
 * @see @link wln_event_cb
 * @external
 * @category wireless
 * @since 7.0
 *
 * @param func      callback function
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_remove_event_cb(wln_event_cb func);

/*ad*
 * Protocol Type used in the ep_type parameter in the @link wln_set_receive_cb call.
 *
 * Typically should be WLN_STANDARD_TYPE for registering callback functions.  Use 
 * WLN_MONITOR_TYPE for enabling/disabling the wireless driver Promiscuous/monitor mode.
 * The Promiscuous/monitor mode causes the hardware to receive all network traffic.
 * 
 * When @link wln_set_receive_cb is called with an ep_type of WLN_MONITOR_TYPE and a non NULL 
 * callback function, the driver will be in a promiscuous or monitor mode.  This mode passes all
 * received frames to the callback function with the data buffer pointer pointing to the mac header, 
 * and the data buffer length.
 * 
 * To disable this promiscuous/monitor mode, and resume normal operation, call the @link wln_set_receive_cb function
 * with WLN_MONITOR_TYPE ep_type and NULL as the callback function. The driver will then disable the
 * hardware promiscuous mode bit and the driver will no longer be in the monitor mode.
 *
 * @name WirelessEPTypes "Wireless EP Types"
 * @param WLN_STANDARD_TYPE         Used to set callbacks in standard wireless driver operation.
 * @param WLN_MONITOR_TYPE          Used to set callback for all traffic received in the promiscuous or monitor mode
 *
 * @see @link wln_set_receive_cb
 * @external
 * @category wireless
 * @since 7.1
 *
 *
*ad*/
#define WLN_STANDARD_TYPE  0
#define WLN_MONITOR_TYPE   0xffff

/*ad*
 * To start the wireless driver. 
 * 
 * Netos starts the wirless driver and wpa supplicant according to the settings 
 * in bsp.h and application dialog. If the application needs to change the parameters
 * of the wireless driver configuration, the application MUST call @link wln_stop first, and 
 * call @link wpa_supplicant_terminate if wpa is enabled, then call the wln_set_xxxx functions 
 * to change the parameters. The application can then call @link wpa_supplicant_init if wpa is enabled,
 * and call this function to restart the wireless driver.
 *
 * @external
 * @category wireless
 * @since 7.1
 * @platform connectwiem,connectwime,connectwisp,connectcorewi9c_a
 * @see @link wln_stop
 * @see @link wln_start
 * @see @link wln_set_params
 * @see @link wln_set_receive_cb
 * @see @link wln_set_event_cb
 * @see @link wln_event_cb
 * @see @link wpa_supplicant_init
 * @see @link wpa_supplicant_terminate
 *
 * @return 0        successful
 * @return negative error
*ad*/
int wln_start(void);

/*ad*
 * To stop the wireless driver.
 *
 * Netos starts the wirless driver and wpa supplicant according to the settings 
 * in bsp.h and application dialog. If the application needs to change the parameters
 * of the wireless driver configuration, it MUST call this function first, and 
 * call @link wpa_supplicant_terminate if wpa is enabled, then call the wln_set_xxxx functions 
 * to change the parameters. The application can then call @link wpa_supplicant_init if wpa is enabled,
 * and call @link wln_start to restart the wireless driver.
 *
 * @external
 * @category wireless
 * @since 7.1
 * @platform connectwiem,connectwime,connectwisp,connectcorewi9c_a
 * @see @link wln_start
 * @see @link wln_set_params
 * @see @link wln_set_receive_cb
 * @see @link wln_set_event_cb
 * @see @link wln_event_cb
 * @see @link wpa_supplicant_init
 * @see @link wpa_supplicant_terminate
 *
*ad*/
void wln_stop(void);



#ifdef __cplusplus
}
#endif


#endif /* _WLN_API_H */




