1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * apConn.c
3981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
4981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * All rights reserved.
6981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
7981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Redistribution and use in source and binary forms, with or without
8981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * modification, are permitted provided that the following conditions
9981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * are met:
10981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
11981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions of source code must retain the above copyright
12981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer.
13981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions in binary form must reproduce the above copyright
14981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer in
15981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    the documentation and/or other materials provided with the
16981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    distribution.
17981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Neither the name Texas Instruments nor the names of its
18981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    contributors may be used to endorse or promote products derived
19981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    from this software without specific prior written permission.
20981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
21981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
33981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
34981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \file apConn.c
35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \brief AP Connection
36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \see apConn.h
38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/****************************************************************************
41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                                                                          *
42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   MODULE:  AP Connection                                                 *
43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   PURPOSE:                                                               *
44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   Roaming ability of eSTA is implemented by Roaming Manager Component and
45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   described in "Roaming Manager module LLD" document, and by
46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   AP Connection module. AP Connection module implemented as two sub-modules:
47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   The major one is AP Connection, that is responsible for:
48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   - providing Roaming Manager with access to other parts of WLAN Driver,
49981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   - implementing low levels of roaming mechanism.
50981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   Current BSS sub-module takes care of:
51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   - maintaining database of current AP info,
52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   - providing access to database of current AP info.
53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                                                                          *
54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt ****************************************************************************/
55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define __FILE_ID__  FILE_ID_21
57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "osApi.h"
58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "report.h"
59981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "sme.h"
60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "siteMgrApi.h"
61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "smeApi.h"
62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "PowerMgr_API.h"
63981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TrafficMonitorAPI.h"
64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "qosMngr_API.h"
65981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
66981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt #include "XCCMngr.h"
67981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
68981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "measurementMgrApi.h"
69981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "connApi.h"
70981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "EvHandler.h"
71981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "apConn.h"
72981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "currBss.h"
73981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "fsm.h"
74981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "scrApi.h"
75981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "regulatoryDomainApi.h"
76981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TWDriver.h"
77981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "DrvMainModules.h"
78981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
79981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
80981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*----------------------*/
81981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Constants and macros */
82981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*----------------------*/
83981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
84981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG
85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt #define    AP_CONN_VALIDATE_HANDLE(hAPConnection)  \
86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (hAPConnection == NULL)  \
87981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {   \
88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT(("FATAL ERROR: AP Connection context is not initiated\n"));  \
89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK; \
90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#else
92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt #define    AP_CONN_VALIDATE_HANDLE(hAPConnection)
93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define MAX_ROAMING_TRIGGERS  ROAMING_TRIGGER_LAST
96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
97981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_SEND_DEAUTH_PACKET_FLAG(roamingEventType) \
98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if ((roamingEventType >= ROAMING_TRIGGER_MAX_TX_RETRIES) && \
99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                (roamingEventType != ROAMING_TRIGGER_SECURITY_ATTACK)) \
100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            { \
101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pAPConnection->sendDeauthPacket = TI_FALSE; \
102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Init bits */
105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*--------------*/
108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Enumerations */
109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*--------------*/
110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* AP Connection state machine states
113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef enum
115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_IDLE = 0,          /**< Initial state */
117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_WAIT_ROAM,         /**< Connected to AP, waiting for start roaming command */
118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_SWITCHING_CHANNEL, /**< Connected to AP, switch channel in progress */
119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_WAIT_CONNECT_CMD,  /**< SCR allocated, PS mode entered; wait for cmd from Roam Mngr */
120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_PREPARE_HAND_OFF,  /**< Request CCKM for new AP, wait for response */
121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_CONNECTING,        /**< Performing Connection to new AP; wait for response from Conn SM */
122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_DISCONNECTING,     /**< Wait for completion of current link disconnection */
123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_REESTABLISH_VOICE, /**< Wait for completion of voice TSPEC re-negotiation */
124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_STATE_LAST
125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} apConn_smStates;
126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* AP Connection state machine events
130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef enum
132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_PREPARE_FOR_ROAMING= 0,/**< Sent by Roam MNGR when roaming event occurs */
134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_FINISHED_OK,           /**< Indicates successful completion of request sent to Conn SM */
135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_FINISHED_NOT_OK,       /**< Indicates unsuccessful completion of request sent to Conn SM */
136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_RETAIN_CURRENT_AP,     /**< Sent by Roam MNGR when it wishes to give-up roaming */
137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_START,                 /**< Sent by SME when first time link to AP is established */
138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_START_ROAM,            /**< Sent by Roam MNGR when it wishes to roam to new AP */
139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_START_SWITCH_CHANNEL,  /**< Sent by Switch channel module when starting switch channel process (tx enabled) */
140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_FINISHED_SWITCH_CH,    /**< Sent by Switch channel module when finishing switch channel process (tx enabled) */
141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_FINISHED_HAND_OVER,    /**< Sent by XCC module when finishing hand-over */
142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_STOP,                  /**< Disconnect current link, send stop indication to other modules */
143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONNECT_EVENT_LAST
144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} apConn_smEvents;
145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define AP_CONNECT_NUM_STATES       AP_CONNECT_STATE_LAST
147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define AP_CONNECT_NUM_EVENTS       AP_CONNECT_EVENT_LAST
148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*----------*/
151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Typedefs */
152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*----------*/
153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*------------*/
155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Structures */
156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*------------*/
157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* AP Connection control block
160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Following structure defines parameters that can be configured externally,
161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* internal variables, AP Connection state machine and handlers of other modules
162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* used by AP Connection module
163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef struct _apConn_t
165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* AP Connection state machine */
167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    fsm_stateMachine_t      *apConnSM;          /**< AP Connection module state machine */
168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8                currentState;       /**< AP Connection state machine current state */
169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Internal parameters */
171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 firstAttempt2Roam;  /**< TI_TRUE if still connected to original AP, TI_FALSE otherwise */
172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 roamingEnabled;     /**< If TI_FALSE, act like if no roaming callback registered. */
173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_roamingTrigger_e roamReason;         /**< The most severe and recent reason for roaming */
174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	APDisconnect_t			APDisconnect;		/**< The AP disconnect trigger extra information */
175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    bssEntry_t              *newAP;             /**< Stores parameters of roaming candidate */
176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_connRequest_e    requestType;        /**< Stores type of roaming request */
177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_INT8                 rssiThreshold;      /**< Stores recently configured RSSI threshold */
178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8                snrThreshold;       /**< Stores recently configured SNR threshold */
179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8                txFailureThreshold; /**< Stores recently configured consec. no ack threshold */
180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8                lowRateThreshold;   /**< Stores recently configured consec. no ack threshold */
181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               vsIElength;         /**< Length of vendor specific info-element for assoc req (if defined) */
182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    char                    *vsIEbuf;           /**< Pointer to vendor specific info-element for assoc req (if defined) */
183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 isRssiTriggerMaskedOut;
184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 isSnrTriggerMaskedOut;
185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 isConsTxFailureMaskedOut;
186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 islowRateTriggerMaskedOut;
187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 removeKeys;         /**< Indicates whether keys should be removed after disconnect or not */
188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 ignoreDeauthReason0;/**< Indicates whether to ignore DeAuth with reason 0, required for Rogue AP test XCC-V2 */
189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 sendDeauthPacket;   /**< Indicates whether to send DEAUTH packet when discommecting or not */
190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8                deauthPacketReasonCode;   /**< Indicates what error code to indicate in the DEAUTH packet  */
191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 voiceTspecConfigured;/**< Shall be set to TI_TRUE before roaming in case the TSPEC is configured */
192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 videoTspecConfigured;/**< Shall be set to TRUE before roaming in case the TSPEC is configured */
193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 reNegotiateTSPEC;   /**< Shall be set to TI_TRUE before hand-over if requested by Roaming Manager */
194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL                 resetReportedRoamingStatistics; /**< Shall be set to TI_TRUE if starting to measure traffic */
195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT16               lastRoamingDelay;
196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               roamingStartedTimestamp;
197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8                roamingSuccesfulHandoverNum;
198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL					bNonRoamingDisAssocReason; /**< Indicate whether last disconnection was called from outside (SME) */
199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /** Callback functions, registered by Roaming manager */
201653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    apConn_roamMngrEventCallb_t  roamEventCallb;         /**< roam event triggers */
202653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    apConn_roamMngrCallb_t       reportStatusCallb;      /**< connection status events  */
203653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    apConn_roamMngrCallb_t       returnNeighborApsCallb; /**< neighbor APs list update */
204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Handlers of other modules used by AP Connection */
206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hOs;
207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hReport;
208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hCurrBSS;
209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hRoamMng;
210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hSme;
211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hSiteMgr;
212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hXCCMngr;
213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hConnSm;
214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hPrivacy;
215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hQos;
216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hEvHandler;
217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hScr;
218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hAssoc;
219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hRegulatoryDomain;
220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE               hMlme;
221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Counters for statistics */
223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               roamingTriggerEvents[MAX_ROAMING_TRIGGERS];
224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               roamingSuccesfulHandoverTotalNum;
225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               roamingFailedHandoverNum;
226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               retainCurrAPNum;
227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               disconnectFromRoamMngrNum;
228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32               stopFromSmeNum;
229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} apConn_t;
230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*-------------------------------*/
233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Internal functions prototypes */
234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*-------------------------------*/
235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* SM functions */
237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_smEvent(TI_UINT8 *currState, TI_UINT8 event, void* data);
238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_smNop(void *pData);
239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_smUnexpected(void *pData);
240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_startWaitingForTriggers(void *pData);
241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_connectedToNewAP(void *pData);
242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_configureDriverBeforeRoaming(void *pData);
243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_stopConnection(void *pData);
244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_invokeConnectionToNewAp(void *pData);
245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_reportDisconnected(void *pData);
246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_retainAP(void *pData);
247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_requestCCKM(void *pData);
248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_reportConnFail(void *pData);
249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_swChFinished(void *pData);
250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_handleTspecReneg (void *pData);
251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* other functions */
253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void apConn_calcNewTsf(apConn_t *hAPConnection, TI_UINT8 *tsfTimeStamp, TI_UINT32 newSiteOsTimeStamp, TI_UINT32 beaconInterval);
255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_qosMngrReportResultCallb (TI_HANDLE hApConn, trafficAdmRequestStatus_e result);
257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void		 apConn_reportConnStatusToSME	 (apConn_t *pAPConnection);
258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*-------------------------------*/
261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Public functions prototypes 	 */
262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*-------------------------------*/
263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_create
267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Create the AP Connection context:
271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* allocate memory for internal variables;
272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* create state machine.
273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - hOs - OS handler
277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Pointer to the AP Connection on success, NULL on failure
281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* (unable to allocate memory or other error).
282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_HANDLE apConn_create(TI_HANDLE hOs)
286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_STATUS   status;
288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((pAPConnection = os_memoryAlloc(hOs, sizeof(apConn_t))) != NULL)
291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->hOs = hOs;
293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        status = fsm_Create(hOs, &(pAPConnection->apConnSM), AP_CONNECT_NUM_STATES, AP_CONNECT_NUM_EVENTS);
295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (status == TI_OK)
296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Succeeded to create AP Connection module context - return pointer to it */
298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return pAPConnection;
299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else /* Failed to create state machine */
301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error creating apConnSM - aborting\n"));
303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Free pre-allocated control block */
304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memoryFree(hOs, pAPConnection, sizeof(apConn_t));
305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return NULL;
306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else /* Failed to allocate control block */
309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return NULL;
312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_unload
318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Finish AP Connection module work:
322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* release the allocation for state machine and internal variables.
323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_unload(TI_HANDLE hAPConnection)
334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection;
336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE (hAPConnection);
338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)hAPConnection;
340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Unload state machine */
342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    fsm_Unload (pAPConnection->hOs, pAPConnection->apConnSM);
343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Free pre-allocated control block */
345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryFree (pAPConnection->hOs, pAPConnection, sizeof(apConn_t));
346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_init
353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Prepare AP Connection module to work: initiate internal variables, start state machine
357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pStadHandles  - The driver modules handles  \n
361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  void
365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_init (TStadHandlesList *pStadHandles)
369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)(pStadHandles->hAPConnection);
371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /** State Machine matrix */
373023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    static fsm_actionCell_t apConn_matrix[AP_CONNECT_NUM_STATES][AP_CONNECT_NUM_EVENTS] =
374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for IDLE state */
376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* PREPARE_FOR_ROAMING  */
377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* FINISHED_OK          */
378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* FINISHED_NOT_OK      */
379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* RETAIN_CURRENT_AP    */
380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM,apConn_startWaitingForTriggers},/* START                */
381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* START_ROAM           */
382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* START_SWITCH_CHANNEL */
383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smNop},                      /* FINISHED_SWITCH_CH   */
384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smNop},                      /* FINISHED_HAND_OVER   */
385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}                /* STOP                 */
386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        },
387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for WAIT_ROAM state */
388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_WAIT_CONNECT_CMD,apConn_configureDriverBeforeRoaming},/* PREPARE_FOR_ROAMING  */
389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_OK          */
390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_NOT_OK      */
391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* RETAIN_CURRENT_AP    */
392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* START                */
393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* START_ROAM           */
394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smNop},     /* START_SWITCH_CHANNEL */
395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_SWITCH_CH   */
396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_HAND_OVER   */
397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP                 */
398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        },
399981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for SWITCHING_CHANNEL state */
400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* PREPARE_FOR_ROAMING  */
401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* FINISHED_OK          */
402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* FINISHED_NOT_OK      */
403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* RETAIN_CURRENT_AP    */
404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* START                */
405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* START_ROAM           */
406981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_swChFinished},  /* START_SWITCH_CHANNEL */
407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smNop},                 /* FINISHED_SWITCH_CH   */
408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* FINISHED_HAND_OVER   */
409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        },
411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for WAIT_CONNECT_CMD state */
412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* PREPARE_FOR_ROAMING  */
413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_OK          */
414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_NOT_OK      */
415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM, apConn_retainAP},              /* RETAIN_CURRENT_AP    */
416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* START                */
417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_requestCCKM},    /* START_ROAM           */
418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* START_SWITCH_CHANNEL */
419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_SWITCH_CH   */
420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_HAND_OVER   */
421981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
422981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        },
423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for PREPARE_HAND_OFF state */
424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* PREPARE_FOR_ROAMING  */
425981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* FINISHED_OK          */
426981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* FINISHED_NOT_OK      */
427981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* RETAIN_CURRENT_AP    */
428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* START                */
429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* START_ROAM           */
430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* START_SWITCH_CHANNEL */
431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* FINISHED_SWITCH_CH   */
432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_CONNECTING, apConn_invokeConnectionToNewAp},/* FINISHED_HAND_OVER */
433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        },
435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for CONNECTING state */
436981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* PREPARE_FOR_ROAMING  */
437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_REESTABLISH_VOICE,apConn_handleTspecReneg},/* FINISHED_OK             */
438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_reportConnFail}, /* FINISHED_NOT_OK      */
439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* RETAIN_CURRENT_AP    */
440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* START                */
441981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* START_ROAM           */
442981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* START_SWITCH_CHANNEL */
443981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* FINISHED_SWITCH_CH   */
444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* FINISHED_HAND_OVER   */
445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        },
447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for DISCONNECTING state */
448981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* PREPARE_FOR_ROAMING  */
449981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_reportDisconnected},     /* FINISHED_OK          */
450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_IDLE, apConn_reportDisconnected},     /* FINISHED_NOT_OK      */
451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* RETAIN_CURRENT_AP    */
452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_smUnexpected},  /* START                */
453981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* START_ROAM           */
454981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* START_SWITCH_CHANNEL */
455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* FINISHED_SWITCH_CH   */
456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* FINISHED_HAND_OVER   */
457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* STOP                 */
458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        },
459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* next state and actions for REESTABLISH_VOICE state */
460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* PREPARE_FOR_ROAMING  */
461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_ROAM,apConn_connectedToNewAP},       /* FINISHED_OK          */
462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_reportConnFail}, /* FINISHED_NOT_OK      */
463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* RETAIN_CURRENT_AP    */
464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* START                */
465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* START_ROAM           */
466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* START_SWITCH_CHANNEL */
467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* FINISHED_SWITCH_CH   */
468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* FINISHED_HAND_OVER   */
469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    };
472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    fsm_Config(pAPConnection->apConnSM,
474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt               (fsm_Matrix_t)&apConn_matrix[0][0],
475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt               AP_CONNECT_NUM_STATES,
476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt               AP_CONNECT_NUM_EVENTS,
477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt               (fsm_eventActivation_t)apConn_smEvent,
478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt               pAPConnection->hOs);
479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hReport      = pStadHandles->hReport;
481981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hCurrBSS     = pStadHandles->hCurrBss;
482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hRoamMng     = pStadHandles->hRoamingMngr;
483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hSme         = pStadHandles->hSme;
484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hSiteMgr     = pStadHandles->hSiteMgr;
485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hXCCMngr     = pStadHandles->hXCCMngr;
486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hConnSm      = pStadHandles->hConn;
487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hPrivacy     = pStadHandles->hRsn;
488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hQos         = pStadHandles->hQosMngr;
489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hEvHandler   = pStadHandles->hEvHandler;
490981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hScr         = pStadHandles->hSCR;
491981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hAssoc       = pStadHandles->hAssoc;
492981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hMlme        = pStadHandles->hMlmeSm;
493981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->hRegulatoryDomain = pStadHandles->hRegulatoryDomain;
494981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
495981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->currentState = AP_CONNECT_STATE_IDLE;
496981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->firstAttempt2Roam = TI_TRUE;
497981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingEnabled = TI_TRUE;
498981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->reportStatusCallb = NULL;
499981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamEventCallb = NULL;
500981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->returnNeighborApsCallb = NULL;
501981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
502981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
503981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
504981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_SetDefaults  (TI_HANDLE hAPConnection, apConnParams_t *pApConnParams)
505981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
506981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
507981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32  index;
508981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
509981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->ignoreDeauthReason0 = pApConnParams->ignoreDeauthReason0;
510981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
511981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (index=ROAMING_TRIGGER_NONE; index<ROAMING_TRIGGER_LAST; index++)
512981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
513981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->roamingTriggerEvents[index] = 0;
514981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
515981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingSuccesfulHandoverNum = 0;
516981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingSuccesfulHandoverTotalNum = 0;
517981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingFailedHandoverNum = 0;
518981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->retainCurrAPNum = 0;
519981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->disconnectFromRoamMngrNum = 0;
520981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->stopFromSmeNum = 0;
521981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->txFailureThreshold = NO_ACK_DEFAULT_THRESHOLD;
522981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->lowRateThreshold = LOW_RATE_DEFAULT_THRESHOLD;
523981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->rssiThreshold = RSSI_DEFAULT_THRESHOLD;
524981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->snrThreshold = SNR_DEFAULT_THRESHOLD;
525981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->vsIElength = 0;
526981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->isRssiTriggerMaskedOut = TI_FALSE;
527981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->isSnrTriggerMaskedOut = TI_TRUE;
528981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->islowRateTriggerMaskedOut = TI_FALSE;
529981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->isConsTxFailureMaskedOut = TI_FALSE;
530981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->removeKeys = TI_TRUE;
531981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->sendDeauthPacket = TI_TRUE;       /* Default behavior is radio On - send DISASSOC frame */
532981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->deauthPacketReasonCode = STATUS_UNSPECIFIED;
533981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->voiceTspecConfigured = TI_FALSE;
534981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->videoTspecConfigured = TI_FALSE;
535981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->resetReportedRoamingStatistics = TI_FALSE;
536981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->reNegotiateTSPEC = TI_FALSE;
537981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->bNonRoamingDisAssocReason = TI_FALSE;
538981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
539981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingStartedTimestamp = 0;
540981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->lastRoamingDelay = 0;
541981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingSuccesfulHandoverNum = 0;
542981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
543981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
544981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
546981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
547981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* apConn_isPsRequiredBeforeScan
548981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
549981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
550981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
551981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* verify if the PS required before scan according if roaming triger is part of ROAMING_TRIGGER_LOW_QUALITY_GROUP
552981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
553981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
554981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
555981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - hAPConnection - pointer to module\n
556981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
557981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
558981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
559981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TRUE or FALSE.
560981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
561981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
562981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
563981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_BOOL apConn_isPsRequiredBeforeScan(TI_HANDLE hAPConnection)
564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
565981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t * pAPConnection = (apConn_t *) hAPConnection;
566981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* check if part of ROAMING_TRIGGER_LOW_QUALITY_GROUP */
568981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pAPConnection->roamReason <= ROAMING_TRIGGER_MAX_TX_RETRIES)
569981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		return TI_TRUE;
570981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
571981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		return TI_FALSE;
572981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
573981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
574981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
575981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
576981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
577981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
578981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_ConnCompleteInd
579981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
580981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
581981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
582981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Inform AP Connection about successful / unsuccessful completion
583981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* of link establishing
584981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
585981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
586981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
587981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - result - TI_OK if successfully connected, TI_NOK otherwise  \n
588981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
589981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
590981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
591981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  None.
592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
593981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
594981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_ConnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, TI_UINT32 uStatusCode)
596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
597981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (status == STATUS_SUCCESSFUL)
600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
605981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_getRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam)
610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t * pAPConnection = (apConn_t *) hAPConnection;
612981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pParam->lowRssiThreshold = pAPConnection->rssiThreshold;
614981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pParam->lowSnrThreshold = pAPConnection->snrThreshold;
615981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pParam->txRateThreshold = pAPConnection->lowRateThreshold;
616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pParam->dataRetryThreshold = pAPConnection->txFailureThreshold;
617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    currBSS_getRoamingParams(pAPConnection->hCurrBSS,
619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             &pParam->numExpectedTbttForBSSLoss,
620981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             &pParam->lowQualityForBackgroungScanCondition,
621981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             &pParam->normalQualityForBackgroungScanCondition);
622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
623981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
624981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_setRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam)
627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
630981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
632981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* If low quality trigger threshold is set to 0 - this is the request to ignore this trigger */
633981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Otherwise store it */
634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pParam->lowRssiThreshold == (TI_INT8)AP_CONNECT_TRIGGER_IGNORED)
635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->isRssiTriggerMaskedOut = TI_TRUE;
637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pParam->lowRssiThreshold = pAPConnection->rssiThreshold;
638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->isRssiTriggerMaskedOut = TI_FALSE;
642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->rssiThreshold = pParam->lowRssiThreshold;
643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
644981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pParam->txRateThreshold == AP_CONNECT_TRIGGER_IGNORED)
646981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
647981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->islowRateTriggerMaskedOut = TI_TRUE;
648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pParam->txRateThreshold = pAPConnection->lowRateThreshold;
649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
650981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->islowRateTriggerMaskedOut = TI_FALSE;
653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->lowRateThreshold = pParam->txRateThreshold;
654981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
655981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
656981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pParam->dataRetryThreshold == AP_CONNECT_TRIGGER_IGNORED)
657981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
658981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->isConsTxFailureMaskedOut = TI_TRUE;
659981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pParam->dataRetryThreshold = pAPConnection->txFailureThreshold;
660981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
661981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
662981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
663981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->isConsTxFailureMaskedOut = TI_FALSE;
664981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->txFailureThreshold = pParam->dataRetryThreshold;
665981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
666981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
667981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->isSnrTriggerMaskedOut = TI_FALSE;
668981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->snrThreshold = pParam->lowSnrThreshold;
669981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
670981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    currBSS_updateRoamingTriggers(pAPConnection->hCurrBSS, pParam);
671981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
675981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_registerRoamMngrCallb(TI_HANDLE hAPConnection,
676653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                                       apConn_roamMngrEventCallb_t  roamEventCallb,
677653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                                       apConn_roamMngrCallb_t       reportStatusCallb,
678653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                                       apConn_roamMngrCallb_t       returnNeighborApsCallb)
679981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
680981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection;
681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_connStatus_t reportStatus;
682981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
683981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)hAPConnection;
687981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
688981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamEventCallb = roamEventCallb;
689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->reportStatusCallb = reportStatusCallb;
690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((pAPConnection->roamingEnabled) && (pAPConnection->currentState != AP_CONNECT_STATE_IDLE))
691981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
692653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        param.paramType   = ASSOC_ASSOCIATION_REQ_PARAM;
693981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
694981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        assoc_getParam(pAPConnection->hAssoc, &param);
695981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBuf = (char *)(param.content.assocReqBuffer.buffer);
696981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBufLength = param.content.assocReqBuffer.bufferSize;
697981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
698981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.status = CONN_STATUS_CONNECTED;
699981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
700981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
701981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    ((apConn_t *)hAPConnection)->returnNeighborApsCallb = returnNeighborApsCallb;
702981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
703981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
704981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
705981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
706981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_unregisterRoamMngrCallb(TI_HANDLE hAPConnection)
707981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
708981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection;
709981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
710981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
711981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
712981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection = (apConn_t *)hAPConnection;
713981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
714981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->roamEventCallb = NULL;
715981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->reportStatusCallb = NULL;
716981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->returnNeighborApsCallb = NULL;
717981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
718981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((pAPConnection->currentState != AP_CONNECT_STATE_IDLE) && (pAPConnection->currentState != AP_CONNECT_STATE_WAIT_ROAM))
719981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
720981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Roaming Manager is unregistering it's callbacks in the middle of roaming - disconnect */
721981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
722981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
723981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
724981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
725981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
726981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_disconnect(TI_HANDLE hAPConnection)
727981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
728981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection;
729981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
730981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
731981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
732981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)hAPConnection;
733981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_SEND_DEAUTH_PACKET_FLAG(pAPConnection->roamReason);
734981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pAPConnection->roamReason == ROAMING_TRIGGER_SECURITY_ATTACK)
735981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pAPConnection->deauthPacketReasonCode = STATUS_MIC_FAILURE;
736981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
737981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pAPConnection->deauthPacketReasonCode = STATUS_UNSPECIFIED;
738981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
739981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->disconnectFromRoamMngrNum++;
740981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
741981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
742981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
743981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
744981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_getStaCapabilities(TI_HANDLE hAPConnection,
745981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                    apConn_staCapabilities_t *ie_list)
746981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
747981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
748981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_staCapabilities_t *pList;
749981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
750981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
751981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
752981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
753981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pList = ie_list;
754981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
755981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get authentication suite type */
756981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = RSN_EXT_AUTHENTICATION_MODE;
757981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsn_getParam(pAPConnection->hPrivacy, &param);
758981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
759981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (param.content.rsnExtAuthneticationMode)
760981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
761981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_OPEN:
762981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeOpen;
763981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
764981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_SHARED_KEY:
765981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeShared;
766981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
767981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_AUTO_SWITCH:
768981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeAutoSwitch;
769981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
770981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_WPA:
771981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeWPA;
772981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
773981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_WPAPSK:
774981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeWPAPSK;
775981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
776981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_WPANONE:
777981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeWPANone;
778981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
779981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_WPA2:
780981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeWPA2;
781981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
782981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case RSN_EXT_AUTH_MODE_WPA2PSK:
783981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeWPA2PSK;
784981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
785981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        default:
786981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->authMode = os802_11AuthModeOpen;
787981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
788981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
789981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
790981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get encryption type */
791981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
792981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsn_getParam(pAPConnection->hPrivacy, &param);
793981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
794981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (param.content.rsnEncryptionStatus)
795981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
796981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case TWD_CIPHER_NONE:
797981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->encryptionType = OS_ENCRYPTION_TYPE_NONE;
798981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
799981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case TWD_CIPHER_WEP:
800981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case TWD_CIPHER_WEP104:
801981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->encryptionType = OS_ENCRYPTION_TYPE_WEP;
802981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
803981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case TWD_CIPHER_TKIP:
804981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case TWD_CIPHER_CKIP:
805981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->encryptionType = OS_ENCRYPTION_TYPE_TKIP;
806981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
807981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case TWD_CIPHER_AES_WRAP:
808981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case TWD_CIPHER_AES_CCMP:
809981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->encryptionType = OS_ENCRYPTION_TYPE_AES;
810981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
811981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        default:
812981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->encryptionType = OS_ENCRYPTION_TYPE_NONE;
813981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
814981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
815981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
816981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get supported rates */
817981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM;
818981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    siteMgr_getParam(pAPConnection->hSiteMgr, &param);
819981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryCopy(pAPConnection->hOs, (void *)param.content.siteMgrDesiredSupportedRateSet.ratesString, pList->rateMask, sizeof(OS_802_11_RATES_EX));
820981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
821981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get mode: 2.4G, 5G or Dual */
822981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
823981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    siteMgr_getParam(pAPConnection->hSiteMgr, &param);
824981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pList->networkType = (OS_802_11_NETWORK_TYPE)param.content.siteMgrDot11Mode;
825981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch(param.content.siteMgrDot11Mode)
826981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
827981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case DOT11_B_MODE:
828981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->networkType = os802_11DS;
829981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
830981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case DOT11_A_MODE:
831981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->networkType = os802_11OFDM5;
832981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
833981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case DOT11_G_MODE:
834981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->networkType = os802_11OFDM24;
835981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
836981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case DOT11_DUAL_MODE:
837981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->networkType = os802_11Automode;
838981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
839981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        default:
840981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->networkType = os802_11DS;
841981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
842981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
843981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
844981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
845981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get XCC status */
846981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
847981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = XCC_ENABLED;
848981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    XCCMngr_getParam(pAPConnection->hXCCMngr, &param);
849981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pList->XCCEnabled = (param.content.XCCEnabled==XCC_MODE_ENABLED)? TI_TRUE : TI_FALSE;
850981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#else
851981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pList->XCCEnabled = TI_FALSE;
852981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
853981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
854981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get QoS type */
855981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = QOS_MNGR_ACTIVE_PROTOCOL;
856981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    qosMngr_getParams(pAPConnection->hQos, &param);
857981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pList->qosEnabled = param.content.qosSiteProtocol != QOS_NONE;
858981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
859981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pList->regDomain = REG_DOMAIN_FIXED;
860981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get regulatory domain type */
861981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
862981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    regulatoryDomain_getParam(pAPConnection->hRegulatoryDomain, &param);
863981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (param.content.spectrumManagementEnabled)
864981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {   /* 802.11h is enabled (802.11h includes 802.11d) */
865981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pList->regDomain = REG_DOMAIN_80211H;
866981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
867981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
868981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
869981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
870981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    regulatoryDomain_getParam(pAPConnection->hRegulatoryDomain, &param);
871981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (param.content.regulatoryDomainEnabled)
872981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   /* 802.11d is enabled */
873981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pList->regDomain = REG_DOMAIN_80211D;
874981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
875981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
876981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
877981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
878981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
879981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_connectToAP(TI_HANDLE hAPConnection,
880981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             bssEntry_t *newAP,
881981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             apConn_connRequest_t *request,
882981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             TI_BOOL reNegotiateTspec)
883981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
884981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
885981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
886981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
887981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
888981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->requestType = request->requestType;
889981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
890981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (request->requestType)
891981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
892981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case AP_CONNECT_RETAIN_CURR_AP:
893981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_RETAIN_CURRENT_AP, pAPConnection);
894981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
895981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
896981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case AP_CONNECT_FULL_TO_AP:
897981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->removeKeys = TI_TRUE;
898981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->newAP = newAP;
899981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->roamingFailedHandoverNum++;
900981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->reNegotiateTSPEC = reNegotiateTspec;
901981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_ROAM, pAPConnection);
902981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
903981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
904981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case AP_CONNECT_FAST_TO_AP:
905981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case AP_CONNECT_RECONNECT_CURR_AP:
906981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->removeKeys = TI_FALSE;
907981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->newAP = newAP;
908981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->roamingFailedHandoverNum++;
909981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pAPConnection->reNegotiateTSPEC = reNegotiateTspec;
910981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_ROAM, pAPConnection);
911981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
912981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
913981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        default:
914981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
915981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
916981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
917981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* If there is vendor specific IE to attach to Assoc req, store it now */
918981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (request->dataBufLength > 0)
919981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
920981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->vsIEbuf = request->dataBuf;
921981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->vsIElength = request->dataBufLength;
922981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
923981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
924981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
925981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
926981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
927981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtbssEntry_t *apConn_getBSSParams(TI_HANDLE hAPConnection)
928981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
929981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG
930981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (hAPConnection == NULL) /* Failed to allocate control block */
931981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
932981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
933981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return NULL;
934981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
935981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
936981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
937981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return currBSS_getBssInfo(((apConn_t *)hAPConnection)->hCurrBSS);
938981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
939981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
940981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_BOOL apConn_isSiteBanned(TI_HANDLE hAPConnection, TMacAddr * givenAp)
941981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
942981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t * pAPConnection = (apConn_t *) hAPConnection;
943981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
944981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return rsn_isSiteBanned(pAPConnection->hPrivacy, *givenAp);
945981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
946981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
947981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_BOOL apConn_getPreAuthAPStatus(TI_HANDLE hAPConnection, TMacAddr *givenAp)
948981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
949981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
950981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t     param;
951981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
952981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
953981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
954981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = RSN_PRE_AUTH_STATUS;
955981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    MAC_COPY (param.content.rsnApMac, *givenAp);
956981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsn_getParam(pAPConnection->hPrivacy, &param);
957981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
958981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return param.content.rsnPreAuthStatus;
959981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
960981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
961981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_preAuthenticate(TI_HANDLE hAPConnection, bssList_t *listAPs)
962981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
963981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
964981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TBssidList4PreAuth  apList;
965981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32           listIndex, apListIndex;
966981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    bssEntry_t          *pCurrentAP;
967981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8            *pRsnIEs;
968981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
969981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG
970981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((hAPConnection == NULL) || (listAPs == NULL))
971981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
972981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT(("FATAL ERROR: AP Connection context is not initiated\n"));
973981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
974981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
975981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
976981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_reserveResources \n");
977981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
978981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
979981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (listIndex=0, apListIndex=0; listIndex<listAPs->numOfEntries; listIndex++)
980981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
981981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        MAC_COPY (apList.bssidList[apListIndex].bssId,
982981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt				  listAPs->BSSList[listIndex].BSSID);
983981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
984981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* search in the buffer pointer to the beginning of the
985981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            RSN IE according to the IE ID */
986981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (!mlmeParser_ParseIeBuffer (pAPConnection->hMlme, listAPs->BSSList[listIndex].pBuffer, listAPs->BSSList[listIndex].bufferLength, RSN_IE_ID, &pRsnIEs, NULL, 0))
987981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
988981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE0(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_preAuthenticate, no RSN IE was found \n");
989981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE_INFO_HEX(pAPConnection->hReport, listAPs->BSSList[listIndex].pBuffer, listAPs->BSSList[listIndex].bufferLength);
990981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            continue;
991981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
992981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
993981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apList.bssidList[apListIndex].pRsnIEs = (dot11_RSN_t*)pRsnIEs;
994981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apList.bssidList[apListIndex].rsnIeLen = apList.bssidList[apListIndex].pRsnIEs->hdr[1] + 2;
995981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apListIndex++;
996981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
997981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
998981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Start pre-auth after any Conn succ (including first),
999981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    and not only when a New BSSID was added, in order to save/refresh
1000981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    PMKID of the current AP.*/
1001981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1002981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Add the current BSSID to the list */
1003981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCurrentAP = apConn_getBSSParams(pAPConnection);
1004981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        MAC_COPY (apList.bssidList[apListIndex].bssId, pCurrentAP->BSSID);
1005981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* search in the buffer pointer to the beginning of the
1006981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            RSN IE according to the IE ID */
1007981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1008981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (!mlmeParser_ParseIeBuffer (pAPConnection->hMlme, pCurrentAP->pBuffer, pCurrentAP->bufferLength, RSN_IE_ID, &pRsnIEs, NULL, 0))
1009981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1010981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE6(pAPConnection->hReport, REPORT_SEVERITY_ERROR, "apConn_preAuthenticate, no RSN IE was found in the current BSS, BSSID=0x%x-0x%x-0x%x-0x%x-0x%x-0x%x \n", pCurrentAP->BSSID[0], pCurrentAP->BSSID[1], pCurrentAP->BSSID[2], pCurrentAP->BSSID[3], pCurrentAP->BSSID[4], pCurrentAP->BSSID[5]);
1011981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            report_PrintDump (pCurrentAP->pBuffer, pCurrentAP->bufferLength);
1012981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apList.bssidList[apListIndex].pRsnIEs = NULL;
1013981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apList.bssidList[apListIndex].rsnIeLen = 0;
1014981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1015981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
1016981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1017981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apList.bssidList[apListIndex].pRsnIEs = (dot11_RSN_t*)pRsnIEs;
1018981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apList.bssidList[apListIndex].rsnIeLen = apList.bssidList[apListIndex].pRsnIEs->hdr[1] + 2;
1019981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1020981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apList.NumOfItems = apListIndex+1;
1021981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rsn_startPreAuth(pAPConnection->hPrivacy, &apList);
1022981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1023981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1024981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1025981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1026981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_prepareToRoaming(TI_HANDLE hAPConnection, apConn_roamingTrigger_e reason)
1027981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1028981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1029981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1030981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
1031981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1032981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamReason = reason;
1033981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1034981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_PREPARE_FOR_ROAMING, pAPConnection);
1035981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1036981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1037981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1038981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1039981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_indicateSwitchChannelInProgress
1040981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1041981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1042981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1043981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* This function is called when switch channel process is started; it will trigger
1044981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* AP Connection state machine from 'Wait for roaming start' to 'Switch channel in progress'
1045981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* state.
1046981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1047981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1048981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1049981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - reason - the reason for roaming \n
1050981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1051981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1052981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1053981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1054981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1055981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1056981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1057981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_indicateSwitchChannelInProgress(TI_HANDLE hAPConnection)
1058981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1059981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1060981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1061981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
1062981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1063981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_SWITCH_CHANNEL, pAPConnection);
1064981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1065981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1066981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1067981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1068981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1069981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1070981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_indicateSwitchChannelFinished
1071981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1072981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1073981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1074981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* This function is called when switch channel process is finished
1075981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1076981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1077981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1078981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - reason - the reason for roaming \n
1079981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1080981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1081981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1082981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1083981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1084981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1085981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1086981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_indicateSwitchChannelFinished(TI_HANDLE hAPConnection)
1087981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1088981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1089981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1090981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
1091981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1092981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_SWITCH_CH, pAPConnection);
1093981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1094981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1095981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1096981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1097981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1098981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1099981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_start
1101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called by SME module when new connection has been successfully established (first time connection)
1105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - isValidBSS - if TI_FALSE, no roaming shall be performed, disconnect upon any roaming event;
1109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*                   other parameters of current AP can be received from Current BSS module
1110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_start(TI_HANDLE hAPConnection, TI_BOOL roamingEnabled)
1118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
1122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingEnabled = roamingEnabled;
1124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START, pAPConnection);
1126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_stop
1133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called by SME module when current connection must be taken down
1137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* (due to driver download, connection failure or any other reason)
1138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_stop(TI_HANDLE hAPConnection, TI_BOOL removeKeys)
1148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->stopFromSmeNum++;
1152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->removeKeys = removeKeys;
1153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->sendDeauthPacket = TI_TRUE;
1154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->reNegotiateTSPEC = TI_FALSE;
1155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->voiceTspecConfigured = TI_FALSE;
1156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->videoTspecConfigured = TI_FALSE;
1157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Mark that the connection is stopped due to reason outside the scope of this module */
1159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pAPConnection->roamReason == ROAMING_TRIGGER_SECURITY_ATTACK)
1160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pAPConnection->bNonRoamingDisAssocReason = TI_FALSE;
1161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else
1162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pAPConnection->bNonRoamingDisAssocReason = TI_TRUE;
1163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
1165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_reportRoamingEvent
1172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called when one of roaming events occur
1176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - roamingEventType
1180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pRoamingEventData - in case of 'Tx rate' event, or AP disconnect
1181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_reportRoamingEvent(TI_HANDLE hAPConnection,
1189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                    apConn_roamingTrigger_e roamingEventType,
1190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                    roamingEventData_u *pRoamingEventData)
1191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;  /* parameter for retrieving BSSID */
1194653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    TI_UINT16 reasonCode = 0;
1195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hAPConnection);
1197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE4(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_reportRoamingEvent, type=%d, cur_state=%d, roamingEnabled=%d, roamEventCallb=%p  \n", roamingEventType, pAPConnection->currentState, pAPConnection->roamingEnabled, pAPConnection->roamEventCallb);
1199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 1. Check if this is Rogue AP test case */
1201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (roamingEventType == ROAMING_TRIGGER_AP_DISCONNECT)
1202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		if (pRoamingEventData != NULL)
1204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		{	/* Save the disconnect reason for future use */
1205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pAPConnection->APDisconnect.uStatusCode     = pRoamingEventData->APDisconnect.uStatusCode;
1206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			pAPConnection->APDisconnect.bDeAuthenticate = pRoamingEventData->APDisconnect.bDeAuthenticate;
1207653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            reasonCode = pRoamingEventData->APDisconnect.uStatusCode;
1208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		}
1209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if ((pAPConnection->ignoreDeauthReason0) && (pRoamingEventData!=NULL) &&
1210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt               (pAPConnection->APDisconnect.uStatusCode == 0))
1211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   /* This is required for Rogue AP test,
1212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                When Rogue AP due to invalid User name, deauth with reason 0 arrives before the Rogue AP,
1213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                and this XCC test fails.*/
1214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE0(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_reportRoamingEvent, Ignore DeAuth with reason 0 \n");
1215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return TI_OK;
1216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_reportRoamingEvent, DeAuth with reason %d \n", pAPConnection->APDisconnect.uStatusCode);
1218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pAPConnection->APDisconnect.uStatusCode == STATUS_CODE_802_1X_AUTHENTICATION_FAILED)
1220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt          #ifdef XCC_MODULE_INCLUDED
1222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TI_STATUS    status;
1223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Raise the EAP-Failure as event */
1225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            status = XCCMngr_rogueApDetected (pAPConnection->hXCCMngr, RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED);
1226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt          #endif
1227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Remove AP from candidate list for a specified amount of time */
1230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
1231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        	siteMgr_getParam(pAPConnection->hSiteMgr, &param);
1232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE1(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "current station is banned from the roaming candidates list for %d Ms\n", RSN_AUTH_FAILURE_TIMEOUT);
1234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            rsn_banSite(pAPConnection->hPrivacy, param.content.siteMgrDesiredBSSID, RSN_SITE_BAN_LEVEL_FULL, RSN_AUTH_FAILURE_TIMEOUT);
1236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 2. Check if received trigger is masked out */
1241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (((pAPConnection->isConsTxFailureMaskedOut) && (roamingEventType == ROAMING_TRIGGER_MAX_TX_RETRIES)) ||
1242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        ((pAPConnection->isRssiTriggerMaskedOut)   && (roamingEventType == ROAMING_TRIGGER_LOW_QUALITY)) ||
1243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        ((pAPConnection->isSnrTriggerMaskedOut)    && (roamingEventType == ROAMING_TRIGGER_LOW_SNR)) ||
1244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        ((pAPConnection->islowRateTriggerMaskedOut)&& (roamingEventType == ROAMING_TRIGGER_LOW_TX_RATE)))
1245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_reportRoamingEvent, trigger ignored \n");
1247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_OK;
1248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 3.  Valid trigger received: */
1251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 3a. Update statistics */
1252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingTriggerEvents[roamingEventType]++;
1253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* 3b. Store the most severe trigger */
1255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pAPConnection->roamReason < roamingEventType)
1256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
1257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pAPConnection->roamReason = roamingEventType;
1258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
1259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 3c. Check if Roaming Manager is available */
1261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (((!pAPConnection->roamingEnabled) || (pAPConnection->roamEventCallb == NULL) ||
1262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt          (pAPConnection->currentState == AP_CONNECT_STATE_IDLE))
1263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        && (roamingEventType >= ROAMING_TRIGGER_LOW_TX_RATE)
1264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		&& (roamingEventType != ROAMING_TRIGGER_MAX_TX_RETRIES))
1265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt       /* 'Any SSID' configured, meaning Roaming Manager is not allowed to perform roaming,
1267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt           or Roaming Manager is not registered for roaming events;
1268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt           unless this is trigger to change parameters of background scan, disconnect the link */
1269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "Disconnecting link due to roaming event: ev = %d\n", roamingEventType);
1270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*  Handle IBSS case TBD to remove
1272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            Handle also the case where A first connection is in progress, and
1273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            de-auth arrived. */
1274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pAPConnection->currentState == AP_CONNECT_STATE_IDLE)
1275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		{
1276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			sme_ReportApConnStatus(pAPConnection->hSme, STATUS_DISCONNECT_DURING_CONNECT, pAPConnection->APDisconnect.uStatusCode);
1277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		}
1278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
1279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Infra-structure BSS case - disconnect the link */
1281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (roamingEventType >= ROAMING_TRIGGER_AP_DISCONNECT)
1282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pAPConnection->removeKeys = TI_TRUE;
1284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pAPConnection->removeKeys = TI_FALSE;
1288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            UPDATE_SEND_DEAUTH_PACKET_FLAG(roamingEventType);
1290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			if (roamingEventType == ROAMING_TRIGGER_SECURITY_ATTACK)
1291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt				pAPConnection->deauthPacketReasonCode = STATUS_MIC_FAILURE;
1292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			else
1293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt				pAPConnection->deauthPacketReasonCode = STATUS_UNSPECIFIED;
1294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
1295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_OK;
1297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 4. Check if we are in the middle of switching channel */
1300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->currentState == AP_CONNECT_STATE_SWITCHING_CHANNEL)
1301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Trigger received in the middle of switch channel, continue without reporting Roaming Manager */
1303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "Roaming event during switch channel: ev = %d\n", roamingEventType);
1304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_OK;
1305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 5. Report Roaming Manager */
1308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((pAPConnection->roamingEnabled == TI_TRUE) && (pAPConnection->roamEventCallb != NULL))
1309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "Roaming event raised: ev = %d\n", roamingEventType);
1311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (roamingEventType == ROAMING_TRIGGER_LOW_QUALITY)
1312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            EvHandlerSendEvent(pAPConnection->hEvHandler, IPC_EVENT_LOW_RSSI, NULL,0);
1314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Report to Roaming Manager */
1316653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        pAPConnection->roamEventCallb(pAPConnection->hRoamMng, &roamingEventType, reasonCode);
1317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_RoamHandoffFinished
1326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called when XCC module receives response from the supplicant or recognizes
1330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* timeout while waiting for the response
1331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_RoamHandoffFinished(TI_HANDLE hAPConnection)
1339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG
1343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (hAPConnection == NULL) /* Failed to allocate control block */
1344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
1346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return;
1347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
1349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_HAND_OVER, pAPConnection);
1351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_DisconnCompleteInd
1357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* DISASSOCIATE Packet was sent - proceed with stopping the module
1361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
1365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  None
1369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_DisconnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, TI_UINT32 uStatusCode)
1373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
1377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_updateNeighborAPsList
1383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called by XCC Manager when Priority APs are found
1387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_updateNeighborAPsList(TI_HANDLE hAPConnection, neighborAPList_t *pListOfpriorityAps)
1397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1399981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->returnNeighborApsCallb != NULL )
1401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->returnNeighborApsCallb(pAPConnection->hRoamMng, pListOfpriorityAps);
1403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1406981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_getRoamingStatistics
1410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called from Measurement XCC sub-module when preparing TSM report to the AP.
1414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS: AP Connection handle
1416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  total number of successful roams
1420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  delay of the latest successful roam
1421981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1422981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_getRoamingStatistics(TI_HANDLE hAPConnection, TI_UINT8 *roamingCount, TI_UINT16 *roamingDelay)
1425981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1426981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1427981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get (and clear) total number of successful roams */
1429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *roamingCount = pAPConnection->roamingSuccesfulHandoverNum;
1430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingSuccesfulHandoverNum = 0;
1431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Get delay of the latest roam */
1433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *roamingDelay = pAPConnection->lastRoamingDelay;
1434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->lastRoamingDelay = 0;
1435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1436981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1441981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1442981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_resetRoamingStatistics
1443981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called from Measurement XCC sub-module in order to re-start roaming statistics.
1447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1448981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS: AP Connection handle
1449981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  total number of successful roams
1453981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  delay of the latest successful roam
1454981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_resetRoamingStatistics(TI_HANDLE hAPConnection)
1458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->resetReportedRoamingStatistics = TI_TRUE;
1462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingSuccesfulHandoverNum = 0;
1463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->lastRoamingDelay = 0;
1464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_printStatistics
1470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called by Site Manager when request to print statistics is requested from CLI
1474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS: AP Connection handle
1476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1481981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_printStatistics(TI_HANDLE hAPConnection)
1484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("-------------- Roaming Statistics ---------------\n\n"));
1486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Low TX rate = %d\n",     ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_TX_RATE]));
1487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Low SNR = %d\n",         ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_SNR]));
1488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Low Quality = %d\n",     ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_QUALITY]));
1489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- MAX TX retries = %d\n",  ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_MAX_TX_RETRIES]));
1490981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- BSS Loss TX = %d\n",     ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_BSS_LOSS]));
1491981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Switch Channel = %d\n",  ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_SWITCH_CHANNEL]));
1492981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- AP Disconnect = %d\n",   ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_AP_DISCONNECT]));
1493981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- SEC attack = %d\n",      ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_SECURITY_ATTACK]));
1494981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("\n"));
1495981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Successful roaming = %d\n",                  ((apConn_t *)hAPConnection)->roamingSuccesfulHandoverTotalNum));
1496981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- UnSuccessful roaming = %d\n",                ((apConn_t *)hAPConnection)->roamingFailedHandoverNum));
1497981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Giving up roaming = %d\n",                   ((apConn_t *)hAPConnection)->retainCurrAPNum));
1498981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Disconnect cmd from roaming manager = %d\n", ((apConn_t *)hAPConnection)->disconnectFromRoamMngrNum));
1499981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("- Disconnect cmd from SME = %d\n",             ((apConn_t *)hAPConnection)->stopFromSmeNum));
1500981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("\n"));
1501981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1502981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1503981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1504981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1505981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1506981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1507981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_getVendorSpecificIE
1508981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1509981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1510981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1511981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Called by Association SM when request to associate is built and sent to AP;
1512981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* returns request updated with vendor specific info-element
1513981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1514981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1515981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1516981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - hAPConnection - AP Connection handle\n
1517981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  O   - pRequest - pointer to request buffer\n
1518981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  O   - len - size of returned IE\n
1519981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1520981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1521981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1522981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1523981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1524981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1525981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1526981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS apConn_getVendorSpecificIE(TI_HANDLE hAPConnection, TI_UINT8 *pRequest, TI_UINT32 *len)
1527981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1528981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
1529981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1530981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->vsIElength > 0)
1531981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1532981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        *len = pAPConnection->vsIElength;
1533981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryCopy(pAPConnection->hOs, pRequest, pAPConnection->vsIEbuf, pAPConnection->vsIElength);
1534981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1535981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
1536981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1537981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        *len = 0;
1538981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1539981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1540981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1541981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1542981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1543981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Internal functions implementation */
1544981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1546981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1547981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1548981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_smEvent
1549981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1550981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1551981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1552981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* AP Connection state machine transition function
1553981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1554981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1555981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1556981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I/O - currentState - current state in the state machine\n
1557981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - event - specific event for the state machine\n
1558981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
1559981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1560981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1561981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1562981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
1563981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1565981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1566981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_smEvent(TI_UINT8 *currState, TI_UINT8 event, void* data)
1567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1568981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_STATUS   status;
1569981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8       nextState;
1570981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
1571981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1572981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)data;
1573981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    status = fsm_GetNextState(pAPConnection->apConnSM, (TI_UINT8)*currState, event, &nextState);
1574981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (status == TI_OK)
1575981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1576981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		TRACE3( pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_smEvent: <currentState = %d, event = %d> --> nextState = %d\n", *currState, event, nextState);
1577981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1578981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        status = fsm_Event(pAPConnection->apConnSM, (TI_UINT8 *)currState, event, pAPConnection);
1579981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return status;
1580981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1581981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
1582981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1583981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pAPConnection->hReport, REPORT_SEVERITY_ERROR, "apConn_smEvent, fsm_GetNextState error\n");
1584981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return status;
1585981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1586981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1587981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1588981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1589981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1590981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1591981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_smNop - Do nothing
1592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1593981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1594981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Do nothing in the SM.
1596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1597981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context \n
1600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1605981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_smNop(void *pData)
1608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	apConn_t *hReport = ((apConn_t *)pData)->hReport;
1610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE0(hReport, REPORT_SEVERITY_INFORMATION, "apConn_smNop\n");
1611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1612981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1614981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1615981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_smUnexpected - Unexpected event
1618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1620981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1621981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Unexpected event in the SM.
1622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1623981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1624981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context \n
1626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK if successful, TI_NOK otherwise.
1630981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1632981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1633981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_smUnexpected(void *pData)
1634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE0(((apConn_t *)pData)->hReport, REPORT_SEVERITY_INFORMATION, "apConn_smUnexpected\n");
1636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_NOK;
1637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_startWaitingForTriggers
1643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1644981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1646981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* SME informs AP Connection module about successfull link establishment; start wiating for roaming triggers
1647981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1650981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context \n
1651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1654981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
1655981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1656981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1657981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1658981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_startWaitingForTriggers(void *pData)
1659981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1660981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
1661981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_connStatus_t reportStatus;
1662981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
1663981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1664981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)pData;
1665981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1666981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((pAPConnection->roamingEnabled) && (pAPConnection->reportStatusCallb != NULL))
1667981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1668653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        param.paramType   = ASSOC_ASSOCIATION_REQ_PARAM;
1669981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1670981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        assoc_getParam(pAPConnection->hAssoc, &param);
1671981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBuf = (char *)(param.content.assocReqBuffer.buffer);
1672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBufLength = param.content.assocReqBuffer.bufferSize;
1673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.status = CONN_STATUS_CONNECTED;
1675981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
1676981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1677981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->firstAttempt2Roam = TI_TRUE;
1678981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
1679981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->removeKeys = TI_TRUE;
1680981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->sendDeauthPacket = TI_TRUE;
1681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->reNegotiateTSPEC = TI_FALSE;
1682981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->voiceTspecConfigured = TI_FALSE;
1683981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->videoTspecConfigured = TI_FALSE;
1684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1687981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1688981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_connectedToNewAP
1691981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1692981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1693981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1694981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* After roaming was requested, Connection SM informs AP Connection module about
1695981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* successful link re-establishment; start waiting for roaming triggers
1696981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1697981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1698981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1699981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context \n
1700981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1701981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1702981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1703981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
1704981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1705981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1706981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1707981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_connectedToNewAP(void *pData)
1708981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1709981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
1710981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_connStatus_t reportStatus;
1711981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
1712981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1713981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)pData;
1714981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1715981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Configure SCR group back to connection */
1716981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scr_setGroup (pAPConnection->hScr, SCR_GID_CONNECTED);
1717981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1718981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Erase vendor specific info-element if was defined for last AP Assoc request */
1719981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->vsIElength = 0;
1720981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1721981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* TBD Notify Curr BSS module about update of current AP database */
1722981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1723981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->roamingFailedHandoverNum>0)
1724981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1725981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->roamingFailedHandoverNum--;
1726981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1727981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Report Roaming Manager */
1728981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->reportStatusCallb != NULL)
1729981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1730653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        param.paramType   = ASSOC_ASSOCIATION_REQ_PARAM;
1731981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1732981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        assoc_getParam(pAPConnection->hAssoc, &param);
1733981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBuf = (char *)(param.content.assocReqBuffer.buffer);
1734981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBufLength = param.content.assocReqBuffer.bufferSize;
1735981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1736981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.status = CONN_STATUS_HANDOVER_SUCCESS;
1737981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1738981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
1739981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1740981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->firstAttempt2Roam = TI_TRUE;
1741981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
1742981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamingSuccesfulHandoverTotalNum++;
1743981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->removeKeys = TI_TRUE;
1744981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->sendDeauthPacket = TI_TRUE;
1745981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->reNegotiateTSPEC = TI_FALSE;
1746981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->voiceTspecConfigured = TI_FALSE;
1747981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->videoTspecConfigured = TI_FALSE;
1748981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1749981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1750981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (!pAPConnection->resetReportedRoamingStatistics)
1751981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1752981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->roamingSuccesfulHandoverNum++;
1753981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->lastRoamingDelay =
1754981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	        (TI_UINT16)os_timeStampMs(pAPConnection->hOs) - pAPConnection->roamingStartedTimestamp;
1755981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1756981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
1757981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1758981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->resetReportedRoamingStatistics = TI_FALSE;
1759981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1760981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1761981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Raise event of Roaming Completion */
1762981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE0(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "EvHandlerSendEvent -ROAMING_COMPLETE\n");
1763981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    EvHandlerSendEvent(pAPConnection->hEvHandler, IPC_EVENT_ROAMING_COMPLETE, NULL, 0);
1764981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1765981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1766981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1767981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1768981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1769981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1770981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1771981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_stopConnection
1772981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1773981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1774981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1775981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Stop required before roaming was started
1776981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1777981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1778981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1779981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
1780981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1781981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1782981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1783981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
1784981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1785981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1786981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1787981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_stopConnection(void *pData)
1788981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1789981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection;
1790981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    DisconnectType_e disConnType;
1791981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)pData;
1792981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1793981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE2(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, "apConn_stopConnection, calls conn_stop, removeKeys=%d, sendDeauthPacket=%d \n", pAPConnection->removeKeys, pAPConnection->sendDeauthPacket);
1794981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1795981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Erase vendor specific info-element if was defined for last AP Assoc request */
1796981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->vsIElength = 0;
1797981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1798981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* In case AP connection was stopped by SME, and radioOn is false, meaning immidiate shutdown is required without disassoc frame */
1799981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Otherwise, ask for normal disconnection with disassoc frame */
1800981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    disConnType = (pAPConnection->sendDeauthPacket == TI_TRUE) ? DISCONNECT_DE_AUTH : DISCONNECT_IMMEDIATE;
1801981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1802981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1803981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1804981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* set the SCr group to connecting */
1805981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scr_setGroup (pAPConnection->hScr, SCR_GID_CONNECT);
1806981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1807981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Stop Connection state machine - always immediate TBD */
1808981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	conn_stop(pAPConnection->hConnSm,
1809981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			  disConnType,
1810981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			  pAPConnection->deauthPacketReasonCode,
1811653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			  pAPConnection->removeKeys, /* for Roaming, do not remove the keys */
1812981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			  apConn_DisconnCompleteInd,
1813981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt			  pAPConnection);
1814981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1815981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->deauthPacketReasonCode = STATUS_UNSPECIFIED;
1816981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1817981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1818981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1819981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1820981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1821981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1822981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1823981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_reportDisconnected
1824981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1825981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1826981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1827981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Moving from 'Disconnecting' state to 'Idle':
1828981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*   RoamMgr.status("not-connected")
1829981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1830981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1831981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1832981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
1833981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1834981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1835981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1836981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
1837981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1838981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1839981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1840981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_reportDisconnected(void *pData)
1841981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1842981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
1843981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_connStatus_t reportStatus;
1844981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1845981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)pData;
1846981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1847981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->reportStatusCallb != NULL)
1848981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1849981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.status = CONN_STATUS_NOT_CONNECTED;
1850981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
1851981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1852981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1853981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->firstAttempt2Roam = TI_TRUE;
1854981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1855981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Notify SME */
1856981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_reportConnStatusToSME(pAPConnection);
1857981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1858981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1859981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1860981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1861981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1862981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1863981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1864981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_retainAP
1865981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1866981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1867981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1868981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Roaming Manager gives up on roaming.
1869981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Moving from 'Wait for connection command' back to 'Wait for roam started.
1870981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1871981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1872981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1873981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
1874981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1875981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1876981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1877981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
1878981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1879981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1880981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1881981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_retainAP(void *data)
1882981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1883981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
1884981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_connStatus_t reportStatus;
1885981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
1886981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1887981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)data;
1888981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1889981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Configure SCR group back to connection */
1890981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scr_setGroup (pAPConnection->hScr, SCR_GID_CONNECTED);
1891981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1892981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Report Roaming Manager */
1893981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->reportStatusCallb != NULL)
1894981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1895653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        param.paramType   = ASSOC_ASSOCIATION_REQ_PARAM;
1896981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1897981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        assoc_getParam(pAPConnection->hAssoc, &param);
1898981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBuf = (char *)(param.content.assocReqBuffer.buffer);
1899981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBufLength = param.content.assocReqBuffer.bufferSize;
1900981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1901981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.status = CONN_STATUS_HANDOVER_SUCCESS;
1902981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1903981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
1904981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1905981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->retainCurrAPNum++;
1906981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1907981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
1908981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->removeKeys = TI_TRUE;
1909981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->sendDeauthPacket = TI_TRUE;
1910981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->reNegotiateTSPEC = TI_FALSE;
1911981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->voiceTspecConfigured = TI_FALSE;
1912981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->videoTspecConfigured = TI_FALSE;
1913981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1914981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1915981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1916981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1917981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1918981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1919981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1920981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_requestCCKM
1921981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1922981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1923981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1924981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Roaming Manager requests to roaming.
1925981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Get CCKM (prepare hand-off).
1926981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1927981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1928981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1929981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
1930981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1931981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1932981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1933981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
1934981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1935981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
1936981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1937981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_requestCCKM(void *data)
1938981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1939981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
1940981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_STATUS   status;
1941981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1942981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection = (apConn_t *)data;
1943981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1944981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
1945981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Send request to XCC module */
1946981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_calcNewTsf(pAPConnection, (TI_UINT8 *)&(pAPConnection->newAP->lastRxTSF), pAPConnection->newAP->lastRxHostTimestamp, pAPConnection->newAP->beaconInterval);
1947981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    status = XCCMngr_startCckm(pAPConnection->hXCCMngr, &(pAPConnection->newAP->BSSID), (TI_UINT8 *)&(pAPConnection->newAP->lastRxTSF));
1948981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#else
1949981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        status  = TI_OK;
1950981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apConn_RoamHandoffFinished(pAPConnection);
1951981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
1952981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return status;
1953981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1954981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1955981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1956981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
1957981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1958981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1959981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* calcNewTsfTimestamp - Calculates the TSF
1960981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1961981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
1962981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1963981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Calculates the TSF according to the delta of the TSF from the last Beacon/Probe Resp and the current time.
1964981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1965981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
1966981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1967981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - hRoamingMngr - pointer to the roamingMngr SM context  \n
1968981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I/O - tsfTimeStamp - the TSF field in the site entry of the roaming candidate AP
1969981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - newSiteOsTimeStamp - the TS field in the site entry of the roaming candidate AP
1970981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1971981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
1972981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1973981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  Nothing.
1974981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1975981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
1976981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
1977981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void apConn_calcNewTsf(apConn_t *hAPConnection, TI_UINT8 *tsfTimeStamp, TI_UINT32 newSiteOsTimeStamp, TI_UINT32 beaconInterval)
1978981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1979981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection = hAPConnection;
1980981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32      osTimeStamp = os_timeStampMs(pAPConnection->hOs);
1981981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32      deltaTimeStamp;
1982981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32      tsfLsdw,tsfMsdw, newOsTimeStamp;
1983981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32      remainder;
1984981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8       newTsfTimestamp[TIME_STAMP_LEN];
1985981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1986981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* get the delta TS between the TS of the last Beacon/ProbeResp-from the site table
1987981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    and the current TS */
1988981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    deltaTimeStamp = osTimeStamp - newSiteOsTimeStamp;
1989981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    tsfLsdw = *((TI_UINT32*)&tsfTimeStamp[0]);
1990981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    tsfMsdw = *((TI_UINT32*)&tsfTimeStamp[4]);
1991981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1992981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE2(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, " TSF time LSDW reversed=%x, TSF time MSDW reversed=%x\n", tsfLsdw, tsfMsdw);
1993981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1994981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    deltaTimeStamp = deltaTimeStamp*1000;/* from mSec to uSec*/
1995981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Before adding, save remainder */
1996981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    remainder = tsfTimeStamp[3] + ((deltaTimeStamp & 0xff000000) >> 24);
1997981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1998981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* The LS DW of the TS is the TSF taken from the last Beacon/Probe Resp
1999981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        + the delta TS from the time the Beacon/Probe Resp arrive till now. */
2000981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newOsTimeStamp = deltaTimeStamp+tsfLsdw;
2001981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2002981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* substracting one beacon interval */
2003981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newOsTimeStamp -= (beaconInterval * 1024); /* im usec */
2004981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2005981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* save just for debug printout */
2006981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    deltaTimeStamp +=osTimeStamp; /* uMsec */
2007981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* update the LSB of the TSF */
2008981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[0] = newOsTimeStamp & 0x000000ff;
2009981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[1] = (newOsTimeStamp & 0x0000ff00) >> 8;
2010981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[2] = (newOsTimeStamp & 0x00ff0000) >> 16;
2011981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[3] = (newOsTimeStamp & 0xff000000) >> 24;
2012981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2013981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* increase the MSB in case of overflow */
2014981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (remainder > 0xff)
2015981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2016981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        tsfMsdw++;
2017981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2018981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2019981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* update the MSB of the TSF */
2020981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[4] = tsfMsdw & 0x000000ff;
2021981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[5] = (tsfMsdw & 0x0000ff00) >> 8;
2022981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[6] = (tsfMsdw & 0x00ff0000) >> 16;
2023981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    newTsfTimestamp[7] = (tsfMsdw & 0xff000000) >> 24;
2024981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2025981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE11(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, " NEW TSF time: reversedTsfTimeStamp= 0x%x, New deltaTimeStamp= 0x%x, \n remainder=0x%x, new tsfTimeStamp=%x-%x-%x-%x-%x-%x-%x-%x\n", newOsTimeStamp, deltaTimeStamp, remainder, newTsfTimestamp[0], newTsfTimestamp[1], newTsfTimestamp[2], newTsfTimestamp[3], newTsfTimestamp[4], newTsfTimestamp[5], newTsfTimestamp[6], newTsfTimestamp[7]);
2026981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2027981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryCopy(pAPConnection->hOs, tsfTimeStamp, newTsfTimestamp, TIME_STAMP_LEN);
2028981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2029981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
2030981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2031981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2032981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
2033981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2034981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_invokeConnectionToNewAp
2035981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2036981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
2037981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2038981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Got CCKM (hand-off), start re-connection to another AP
2039981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2040981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
2041981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2042981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
2043981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2044981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
2045981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2046981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
2047981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2048981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
2049981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
2050981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_invokeConnectionToNewAp(void *data)
2051981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2052981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection;
2053981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    EConnType    connType;
2054981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
2055981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8     staPrivacySupported, apPrivacySupported;
2056981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL      renegotiateTspec = TI_FALSE;
2057981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2058981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection = (apConn_t *)data;
2059981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2060981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->roamingStartedTimestamp = os_timeStampMs(pAPConnection->hOs);
2061981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2062981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Check privacy compatibility */
2063981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
2064981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsn_getParam(pAPConnection->hPrivacy, &param);
2065981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2066981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    staPrivacySupported = (param.content.rsnEncryptionStatus == TWD_CIPHER_NONE) ? TI_FALSE : TI_TRUE;
2067981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apPrivacySupported  = ((pAPConnection->newAP->capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TI_TRUE : TI_FALSE;
2068981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2069981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (staPrivacySupported != apPrivacySupported)
2070981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2071981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        param.paramType = RSN_MIXED_MODE;
2072981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rsn_getParam(pAPConnection->hPrivacy, &param);
2073981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2074981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (apPrivacySupported ||
2075981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            (!param.content.rsnMixedMode && staPrivacySupported))
2076981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
2077981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE2(pAPConnection->hReport, REPORT_SEVERITY_WARNING, ": failed privacy comparison %d vs. %d\n", staPrivacySupported, apPrivacySupported);
2078981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return (apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection));
2079981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
2080981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2081981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2082981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Update data info of desired AP; in case of first attempt to roam,
2083981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt       store previous primary site info */
2084981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (siteMgr_overwritePrimarySite(pAPConnection->hSiteMgr, pAPConnection->newAP, pAPConnection->firstAttempt2Roam) != TI_OK)
2085981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2086981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pAPConnection->hReport, REPORT_SEVERITY_WARNING, ": failed to ovewrite Primary Site\n");
2087981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return (apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection));
2088981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2089981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2090981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Update re-associate parameter of MLME */
2091981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->requestType == AP_CONNECT_FAST_TO_AP)
2092981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2093981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        connType = CONN_TYPE_ROAM;
2094981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2095981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
2096981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2097981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        connType = CONN_TYPE_FIRST_CONN;
2098981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2099981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
2101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Check the need in TSPEC re-negotiation */
2102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ( (pAPConnection->voiceTspecConfigured || pAPConnection->videoTspecConfigured) && pAPConnection->reNegotiateTSPEC )
2103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* If the candidate AP is at least XCCver4 AP, try to re-negotiate TSPECs */
2105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (XCCMngr_parseXCCVer(pAPConnection->hXCCMngr,
2106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                pAPConnection->newAP->pBuffer,
2107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                pAPConnection->newAP->bufferLength) >= 4)
2108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
2109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            renegotiateTspec = TI_TRUE;
2110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
2111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
2113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE2(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, ": calls conn_start, removeKeys=%d, renegotiateTSPEC=%d\n", pAPConnection->removeKeys, renegotiateTspec);
2115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Start Connection state machine */
2117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return conn_start(pAPConnection->hConnSm,
2118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                      connType,
2119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                      apConn_ConnCompleteInd,
2120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                      pAPConnection,
2121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                      pAPConnection->removeKeys,
2122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                      renegotiateTspec);
2123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
2127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_reportConnFail
2129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
2131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Got 'Failed' indication from Connection state machine - inform Roaming Manager Module
2133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
2135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
2137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
2139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
2141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
2143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
2144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_reportConnFail(void *data)
2145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection;
2147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_connStatus_t reportStatus;
2148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
2149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection = (apConn_t *)data;
2151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->firstAttempt2Roam = TI_FALSE;
2153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->resetReportedRoamingStatistics = TI_FALSE;
2154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Erase vendor specific info-element if was defined for last AP Assoc request */
2156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->vsIElength = 0;
2157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Report to Roaming Manager */
2159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->reportStatusCallb != NULL)
2160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2161653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        param.paramType   = ASSOC_ASSOCIATION_REQ_PARAM;
2162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        assoc_getParam(pAPConnection->hAssoc, &param);
2164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBuf = (char *)(param.content.assocReqBuffer.buffer);
2165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.dataBufLength = param.content.assocReqBuffer.bufferSize;
2166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        reportStatus.status = CONN_STATUS_HANDOVER_FAILURE;
2168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
2170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
2173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
2177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_configureSCR
2179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
2181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Got 'Failed' indication from Connection state machine - inform Roaming Manager Module
2183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
2185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
2187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
2189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
2191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
2193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
2194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_configureDriverBeforeRoaming(void *pData)
2195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t    *pAPConnection = (apConn_t*)pData;
2197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
2198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Configure SCR group of allowed clients according to 'Roaming' rule */
2200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scr_setGroup (pAPConnection->hScr, SCR_GID_ROAMING);
2201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
2202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    qosMngr_getParams(pAPConnection->hQos, &param);
2203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->voiceTspecConfigured = param.content.TspecConfigure.voiceTspecConfigure;
2204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->videoTspecConfigured = param.content.TspecConfigure.videoTspecConfigure;
2205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pAPConnection->resetReportedRoamingStatistics = TI_FALSE;
2206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
2207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
2211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_swChFinished
2213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
2215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Switch channel completed; if there were roaming Manager triggers meanwhile,
2217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* inform Roaming Manager Module
2218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
2220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
2222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
2224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
2226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
2228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
2229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_swChFinished(void *pData)
2230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)pData;
2232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Inform Current BSS module */
2234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    currBSS_restartRssiCounting(pAPConnection->hCurrBSS);
2235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* If there are unreported roaming triggers of 'No AP' type,
2237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt       report them now to roaming manager */
2238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->roamReason >= ROAMING_TRIGGER_MAX_TX_RETRIES)
2239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if ((pAPConnection->roamingEnabled == TI_TRUE) &&
2241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            (pAPConnection->roamEventCallb != NULL))
2242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
2243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Report to Roaming Manager */
2244653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            pAPConnection->roamEventCallb(pAPConnection->hRoamMng, &pAPConnection->roamReason, (TI_UINT16)0);
2245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
2246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
2248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
2250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
2253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
2257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_handleTspecReneg
2259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
2261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* This function will be called when moving from CONNECTING state to
2263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* START_TSPEC_RENEGOTIATION state. It checks if TSPEC re-negotiation was requested
2264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* by roaming manager, if the TSPEC for voice was defined by user application,
2265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* if the re-negotiation was performed during hand-over.
2266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* If so, it will trigger moving to WAIT_ROAM state, otherwise it will start
2267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* TSPEC negotiation, staying in the REESTABLISHING_VOICE state and waiting
2268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* for results.
2269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
2271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pData - pointer to AP Connection context\n
2273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
2275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
2277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
2279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
2280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_handleTspecReneg (void *pData)
2281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)pData;
2283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t param;
2284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pAPConnection->voiceTspecConfigured && pAPConnection->reNegotiateTSPEC)
2286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
2288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        qosMngr_getParams(pAPConnection->hQos, &param);
2289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (param.content.TspecConfigure.voiceTspecConfigure == TI_TRUE)
2291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
2292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* TSPEC is already configured, move to CONNECTED */
2293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
2294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
2295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
2296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
2297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            param.paramType = QOS_MNGR_RESEND_TSPEC_REQUEST;
2298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            param.content.qosRenegotiateTspecRequest.callback = (void *)apConn_qosMngrReportResultCallb;
2299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            param.content.qosRenegotiateTspecRequest.handler = pData;
2300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (qosMngr_setParams(pAPConnection->hQos, &param) != TI_OK)
2302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
2303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Re-negotiation of TSPEC cannot be performed */
2304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
2305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
2306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return TI_OK;
2307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
2308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
2310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* No need to re-negotiate TSPEC, move to CONNECTED */
2312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
2313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
2318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_qosMngrReportResultCallb
2320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
2322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* This function will be transferred to QoS manager upon request to start negotiation
2324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* of the TSPEC for voice and signaling, and will be called when the voice TSPEC
2325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* renegotiation is completed. The function will generate FINISHED_OK or
2326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* FINISHED_NOK events to the state machine of AP Connection, triggering change of
2327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* the current state.
2328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
2330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - hApConn - pointer to AP Connection context\n
2332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - result - returned by Traffic admission control\n
2333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
2335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  TI_OK on success, TI_NOK otherwise.
2337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
2339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
2340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS apConn_qosMngrReportResultCallb (TI_HANDLE hApConn, trafficAdmRequestStatus_e result)
2341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hApConn;
2343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    AP_CONN_VALIDATE_HANDLE(hApConn);
2345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (result == STATUS_TRAFFIC_ADM_REQUEST_ACCEPT)
2347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
2349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
2351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
2352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
2353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
2354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
2355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
2358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* apConn_reportConnStatusToSME
2360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b Description:
2362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* Sends report to SME regarding the connection status
2364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b ARGS:
2366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  I   - pAPConnection  - pointer to AP Connection context\n
2368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \b RETURNS:
2370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*  OK on success, NOK otherwise.
2372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*
2373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt* \sa
2374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt*/
2375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void apConn_reportConnStatusToSME (apConn_t *pAPConnection)
2376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTRACE3(pAPConnection->hReport, REPORT_SEVERITY_INFORMATION, " roamingTrigger = %d, APDisconnectStatusCode = %d, bNonRoamingDisAssocReason = %d\n", pAPConnection->roamReason, pAPConnection->APDisconnect.uStatusCode, 		pAPConnection->bNonRoamingDisAssocReason);
2379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	/* Check if an outside reason caused the disconnection. */
2381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	if (pAPConnection->bNonRoamingDisAssocReason)
2382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
2383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		pAPConnection->bNonRoamingDisAssocReason = TI_FALSE;
2384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		sme_ReportApConnStatus(pAPConnection->hSme, STATUS_UNSPECIFIED, 0);
2385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
2386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* DisAssociation happened due to roaming trigger */
2387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else if (pAPConnection->roamReason == ROAMING_TRIGGER_AP_DISCONNECT)
2388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{	/* AP disconnect is a special case of the status delivered to SME */
2389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		mgmtStatus_e mgmtStatus = ( pAPConnection->APDisconnect.bDeAuthenticate ? STATUS_AP_DEAUTHENTICATE : STATUS_AP_DISASSOCIATE );
2390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		sme_ReportApConnStatus(pAPConnection->hSme, mgmtStatus, pAPConnection->APDisconnect.uStatusCode);
2391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
2392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	else	/* Finally, just send the last roaming trigger */
2393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	{
2394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt		sme_ReportApConnStatus(pAPConnection->hSme, STATUS_ROAMING_TRIGGER, (TI_UINT32)pAPConnection->roamReason);
2395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	}
2396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2399981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid apConn_setDeauthPacketReasonCode(TI_HANDLE hAPConnection, TI_UINT8 deauthReasonCode)
2400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
2401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
2402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
2403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->deauthPacketReasonCode = deauthReasonCode;
2404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	pAPConnection->roamReason = ROAMING_TRIGGER_SECURITY_ATTACK;
2405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
2406