blob: 686722a7677627ce6779e32fc86e377902105763 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*===========================================================================
23
24 s a p M o d u l e . C
25
26 OVERVIEW:
27
28 This software unit holds the implementation of the WLAN SAP modules
29 functions providing EXTERNAL APIs. It is also where the global SAP module
30 context gets initialised
31
32 DEPENDENCIES:
33
34 Are listed for each API below.
35
36 Copyright (c) 2010 QUALCOMM Incorporated.
37 All Rights Reserved.
38 Qualcomm Confidential and Proprietary
39===========================================================================*/
40
41/*===========================================================================
42
43 EDIT HISTORY FOR FILE
44
45
46 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
49
50
51 when who what, where, why
52---------- --- --------------------------------------------------------
5303/15/10 SOFTAP team Created module
5406/03/10 js Added support to hostapd driven
55 * deauth/disassoc/mic failure
56
57===========================================================================*/
58
59/* $Header$ */
60
61/*----------------------------------------------------------------------------
62 * Include Files
63 * -------------------------------------------------------------------------*/
64#include "wlan_qct_tl.h"
65#include "vos_trace.h"
66
67// Pick up the sme callback registration API
68#include "sme_Api.h"
69
70// SAP API header file
71
72#include "sapInternal.h"
73#if defined(FEATURE_WLAN_NON_INTEGRATED_SOC)
74#include "halInternal.h"
75#endif
76#include "smeInside.h"
77
78/*----------------------------------------------------------------------------
79 * Preprocessor Definitions and Constants
80 * -------------------------------------------------------------------------*/
81#define SAP_DEBUG
82
83/*----------------------------------------------------------------------------
84 * Type Declarations
85 * -------------------------------------------------------------------------*/
86
87
88/*----------------------------------------------------------------------------
89 * Global Data Definitions
90 * -------------------------------------------------------------------------*/
91
92/*----------------------------------------------------------------------------
93 * External declarations for global context
94 * -------------------------------------------------------------------------*/
95// No! Get this from VOS.
96// The main per-Physical Link (per WLAN association) context.
97ptSapContext gpSapCtx = NULL;
98
99/*----------------------------------------------------------------------------
100 * Static Variable Definitions
101 * -------------------------------------------------------------------------*/
102
103/*----------------------------------------------------------------------------
104 * Static Function Declarations and Definitions
105 * -------------------------------------------------------------------------*/
106
107/*----------------------------------------------------------------------------
108 * Externalized Function Definitions
109* -------------------------------------------------------------------------*/
110
111/*----------------------------------------------------------------------------
112 * Function Declarations and Documentation
113 * -------------------------------------------------------------------------*/
114
115/*==========================================================================
116 FUNCTION WLANSAP_Open
117
118 DESCRIPTION
119 Called at driver initialization (vos_open). SAP will initialize
120 all its internal resources and will wait for the call to start to
121 register with the other modules.
122
123 DEPENDENCIES
124
125 PARAMETERS
126
127 IN
128 pvosGCtx : Pointer to the global vos context; a handle to SAP's
129 control block can be extracted from its context
130
131 RETURN VALUE
132 The result code associated with performing the operation
133
134 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
135 fault
136 VOS_STATUS_SUCCESS: Success
137
138 SIDE EFFECTS
139============================================================================*/
140VOS_STATUS
141WLANSAP_Open
142(
143 v_PVOID_t pvosGCtx
144)
145{
146
147 ptSapContext pSapCtx = NULL;
148 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
149 VOS_ASSERT(pvosGCtx);
150 /*------------------------------------------------------------------------
151 Allocate (and sanity check?!) SAP control block
152 ------------------------------------------------------------------------*/
153 vos_alloc_context(pvosGCtx, VOS_MODULE_ID_SAP, (v_VOID_t **)&pSapCtx, sizeof(tSapContext));
154
155 if (NULL == pSapCtx)
156 {
157 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
158 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
159 return VOS_STATUS_E_FAULT;
160 }
161
162 vos_mem_zero(pSapCtx, sizeof(tSapContext));
163
164 /*------------------------------------------------------------------------
165 Clean up SAP control block, initialize all values
166 ------------------------------------------------------------------------*/
167 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANSAP_Open");
168
169 WLANSAP_CleanCB(pSapCtx, 0 /*do not empty*/);
170
171 // Setup the "link back" to the VOSS context
172 pSapCtx->pvosGCtx = pvosGCtx;
173
174 // Store a pointer to the SAP context provided by VOSS
175 gpSapCtx = pSapCtx;
176
177 /*------------------------------------------------------------------------
178 Allocate internal resources
179 ------------------------------------------------------------------------*/
180
181 return VOS_STATUS_SUCCESS;
182}// WLANSAP_Open
183
184/*==========================================================================
185 FUNCTION WLANSAP_Start
186
187 DESCRIPTION
188 Called as part of the overall start procedure (vos_start). SAP will
189 use this call to register with TL as the SAP entity for
190 SAP RSN frames.
191
192 DEPENDENCIES
193
194 PARAMETERS
195
196 IN
197 pvosGCtx : Pointer to the global vos context; a handle to SAP's
198 control block can be extracted from its context
199
200 RETURN VALUE
201 The result code associated with performing the operation
202
203 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
204 fault
205 VOS_STATUS_SUCCESS: Success
206
207 SIDE EFFECTS
208============================================================================*/
209
210VOS_STATUS
211WLANSAP_Start
212(
213 v_PVOID_t pvosGCtx
214)
215{
216#ifdef WLAN_SOFTAP_FEATURE
217 ptSapContext pSapCtx = NULL;
218
219 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
220
221 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
222 "WLANSAP_Start invoked successfully\n");
223 /*------------------------------------------------------------------------
224 Sanity check
225 Extract SAP control block
226 ------------------------------------------------------------------------*/
227 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
228 if ( NULL == pSapCtx )
229 {
230 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
231 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
232 return VOS_STATUS_E_FAULT;
233 }
234
235 /*------------------------------------------------------------------------
236 For now, presume security is not enabled.
237 -----------------------------------------------------------------------*/
238 pSapCtx->ucSecEnabled = WLANSAP_SECURITY_ENABLED_STATE;
239
240
241 /*------------------------------------------------------------------------
242 Now configure the roaming profile links. To SSID and bssid.
243 ------------------------------------------------------------------------*/
244 // We have room for two SSIDs.
245 pSapCtx->csrRoamProfile.SSIDs.numOfSSIDs = 1; // This is true for now.
246 pSapCtx->csrRoamProfile.SSIDs.SSIDList = pSapCtx->SSIDList; //Array of two
247 pSapCtx->csrRoamProfile.SSIDs.SSIDList[0].SSID.length = 0;
248 pSapCtx->csrRoamProfile.SSIDs.SSIDList[0].handoffPermitted = VOS_FALSE;
249 pSapCtx->csrRoamProfile.SSIDs.SSIDList[0].ssidHidden = pSapCtx->SSIDList[0].ssidHidden;
250
251 pSapCtx->csrRoamProfile.BSSIDs.numOfBSSIDs = 1; // This is true for now.
252 pSapCtx->csrRoamProfile.BSSIDs.bssid = &pSapCtx->bssid;
253
254 // Now configure the auth type in the roaming profile. To open.
255 pSapCtx->csrRoamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM; // open is the default
256
257 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pSapCtx->SapGlobalLock)))
258 {
259 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
260 "WLANSAP_Start failed init lock\n");
261 return VOS_STATUS_E_FAULT;
262 }
263
264
265#endif
266
267 return VOS_STATUS_SUCCESS;
268}/* WLANSAP_Start */
269
270/*==========================================================================
271
272 FUNCTION WLANSAP_Stop
273
274 DESCRIPTION
275 Called by vos_stop to stop operation in SAP, before close. SAP will suspend all
276 BT-AMP Protocol Adaption Layer operation and will wait for the close
277 request to clean up its resources.
278
279 DEPENDENCIES
280
281 PARAMETERS
282
283 IN
284 pvosGCtx : Pointer to the global vos context; a handle to SAP's
285 control block can be extracted from its context
286
287 RETURN VALUE
288 The result code associated with performing the operation
289
290 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
291 fault
292 VOS_STATUS_SUCCESS: Success
293
294 SIDE EFFECTS
295============================================================================*/
296VOS_STATUS
297WLANSAP_Stop
298(
299 v_PVOID_t pvosGCtx
300)
301{
302
303#ifdef WLAN_SOFTAP_FEATURE
304 ptSapContext pSapCtx = NULL;
305
306 /*------------------------------------------------------------------------
307 Sanity check
308 Extract SAP control block
309 ------------------------------------------------------------------------*/
310 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
311 "WLANSAP_Stop invoked successfully ");
312
313 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
314 if (NULL == pSapCtx)
315 {
316 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
317 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
318 return VOS_STATUS_E_FAULT;
319 }
320
321 sapFreeRoamProfile(&pSapCtx->csrRoamProfile);
322
323 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pSapCtx->SapGlobalLock ) ) )
324 {
325 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
326 "WLANSAP_Stop failed destroy lock\n");
327 return VOS_STATUS_E_FAULT;
328 }
329 /*------------------------------------------------------------------------
330 Stop SAP (de-register RSN handler!?)
331 ------------------------------------------------------------------------*/
332#endif
333
334 return VOS_STATUS_SUCCESS;
335}/* WLANSAP_Stop */
336
337/*==========================================================================
338 FUNCTION WLANSAP_Close
339
340 DESCRIPTION
341 Called by vos_close during general driver close procedure. SAP will clean up
342 all the internal resources.
343
344 DEPENDENCIES
345
346 PARAMETERS
347
348 IN
349 pvosGCtx : Pointer to the global vos context; a handle to SAP's
350 control block can be extracted from its context
351
352 RETURN VALUE
353 The result code associated with performing the operation
354
355 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
356 fault
357 VOS_STATUS_SUCCESS: Success
358
359 SIDE EFFECTS
360============================================================================*/
361VOS_STATUS
362WLANSAP_Close
363(
364 v_PVOID_t pvosGCtx
365)
366{
367#ifdef WLAN_SOFTAP_FEATURE
368 ptSapContext pSapCtx = NULL;
369 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
370
371 /*------------------------------------------------------------------------
372 Sanity check
373 Extract SAP control block
374 ------------------------------------------------------------------------*/
375 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
376 "WLANSAP_Close invoked");
377
378 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
379 if (NULL == pSapCtx)
380 {
381 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
382 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
383 return VOS_STATUS_E_FAULT;
384 }
385
386 /*------------------------------------------------------------------------
387 Cleanup SAP control block.
388 ------------------------------------------------------------------------*/
389 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANSAP_Close");
390 WLANSAP_CleanCB(pSapCtx, VOS_TRUE /* empty queues/lists/pkts if any*/);
391
392 /*------------------------------------------------------------------------
393 Free SAP context from VOSS global
394 ------------------------------------------------------------------------*/
395 vos_free_context(pvosGCtx, VOS_MODULE_ID_SAP, pSapCtx);
396
397#endif
398 return VOS_STATUS_SUCCESS;
399}/* WLANSAP_Close */
400
401/*----------------------------------------------------------------------------
402 * Utility Function implementations
403 * -------------------------------------------------------------------------*/
404
405/*==========================================================================
406
407 FUNCTION WLANSAP_CleanCB
408
409 DESCRIPTION
410 Clear out all fields in the SAP context.
411
412 DEPENDENCIES
413
414 PARAMETERS
415
416 IN
417 pvosGCtx : Pointer to the global vos context; a handle to SAP's
418 control block can be extracted from its context
419
420 RETURN VALUE
421 The result code associated with performing the operation
422
423 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
424 fault
425 VOS_STATUS_SUCCESS: Success
426
427 SIDE EFFECTS
428============================================================================*/
429VOS_STATUS
430WLANSAP_CleanCB
431(
432 ptSapContext pSapCtx,
433 v_U32_t freeFlag // 0 /*do not empty*/);
434)
435{
436#ifdef WLAN_SOFTAP_FEATURE
437 /*------------------------------------------------------------------------
438 Sanity check SAP control block
439 ------------------------------------------------------------------------*/
440
441 if (NULL == pSapCtx)
442 {
443 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
444 "%s: Invalid SAP pointer", __FUNCTION__);
445 return VOS_STATUS_E_FAULT;
446 }
447
448 /*------------------------------------------------------------------------
449 Clean up SAP control block, initialize all values
450 ------------------------------------------------------------------------*/
451 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANSAP_CleanCB");
452
453 vos_mem_zero( pSapCtx, sizeof(tSapContext));
454
455 pSapCtx->pvosGCtx = NULL;
456
457 pSapCtx->sapsMachine= eSAP_DISCONNECTED;
458
459 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Initializing State: %d, sapContext value = %x",
460 __FUNCTION__, pSapCtx->sapsMachine, pSapCtx);
461 pSapCtx->sessionId = 0;
462 pSapCtx->channel = 0;
463
464#endif
465 return VOS_STATUS_SUCCESS;
466}// WLANSAP_CleanCB
467
468/*==========================================================================
469 FUNCTION WLANSAP_pmcFullPwrReqCB
470
471 DESCRIPTION
472 Callback provide to PMC in the pmcRequestFullPower API.
473
474 DEPENDENCIES
475
476 PARAMETERS
477
478 IN
479 callbackContext: The user passed in a context to identify
480 status: The halStatus
481
482 RETURN VALUE
483 None
484
485 SIDE EFFECTS
486============================================================================*/
487void
488WLANSAP_pmcFullPwrReqCB
489(
490 void *callbackContext,
491 eHalStatus status
492)
493{
494 if(HAL_STATUS_SUCCESS(status))
495 {
496 //If success what else to be handled???
497 }
498 else
499 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700500 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 "WLANSAP_pmcFullPwrReqCB: PMC failed to put the chip in Full power\n");
502
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 }
504
505}// WLANSAP_pmcFullPwrReqCB
506/*==========================================================================
507 FUNCTION WLANSAP_getState
508
509 DESCRIPTION
510 This api returns the current SAP state to the caller.
511
512 DEPENDENCIES
513
514 PARAMETERS
515
516 IN
517 pContext : Pointer to Sap Context structure
518
519 RETURN VALUE
520 Returns the SAP FSM state.
521============================================================================*/
522
523v_U8_t WLANSAP_getState
524(
525 v_PVOID_t pvosGCtx
526)
527{
528 ptSapContext pSapCtx = NULL;
529
530 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
531
532 if ( NULL == pSapCtx )
533 {
534 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
535 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
536 return VOS_STATUS_E_FAULT;
537 }
538 return pSapCtx->sapsMachine;
539}
540
541/*==========================================================================
542 FUNCTION WLANSAP_StartBss
543
544 DESCRIPTION
545 This api function provides SAP FSM event eWLAN_SAP_PHYSICAL_LINK_CREATE for
546 starting AP BSS
547
548 DEPENDENCIES
549
550 PARAMETERS
551
552 IN
553 pContext : Pointer to Sap Context structure
554 pQctCommitConfig : Pointer to configuration structure passed down from HDD(HostApd for Android)
555 hdd_SapEventCallback: Callback function in HDD called by SAP to inform HDD about SAP results
556 pUsrContext : Parameter that will be passed back in all the SAP callback events.
557
558 RETURN VALUE
559 The result code associated with performing the operation
560
561 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
562 fault
563 VOS_STATUS_SUCCESS: Success
564
565 SIDE EFFECTS
566============================================================================*/
567VOS_STATUS
568WLANSAP_StartBss
569(
570 v_PVOID_t pvosGCtx,//pwextCtx
571 tpWLAN_SAPEventCB pSapEventCallback,
572 tsap_Config_t *pConfig,
573 v_PVOID_t pUsrContext
574)
575{
576 tWLAN_SAPEvent sapEvent; /* State machine event*/
577 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
578 ptSapContext pSapCtx = NULL;
579 tANI_BOOLEAN restartNeeded;
580 tHalHandle hHal;
581
582 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
583
584 /*------------------------------------------------------------------------
585 Sanity check
586 Extract SAP control block
587 ------------------------------------------------------------------------*/
588 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
589 "WLANSAP_StartBss");
590
591 if (VOS_STA_SAP_MODE == vos_get_conparam ())
592 {
593 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
594 if ( NULL == pSapCtx )
595 {
596 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
597 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
598 return VOS_STATUS_E_FAULT;
599 }
600 pSapCtx->sapsMachine = eSAP_DISCONNECTED;
601
602 /* Channel selection is auto or configured */
603 pSapCtx->channel = pConfig->channel;
604 pSapCtx->pUsrContext = pUsrContext;
605
606 //Set the BSSID to your "self MAC Addr" read the mac address from Configuation ITEM received from HDD
607 pSapCtx->csrRoamProfile.BSSIDs.numOfBSSIDs = 1;
608 vos_mem_copy(pSapCtx->csrRoamProfile.BSSIDs.bssid,
609 pSapCtx->self_mac_addr,
610 sizeof( tCsrBssid ) );
611
612 //Save a copy to SAP context
613 vos_mem_copy(pSapCtx->csrRoamProfile.BSSIDs.bssid,
614 pConfig->self_macaddr.bytes, sizeof(v_MACADDR_t));
615 vos_mem_copy(pSapCtx->self_mac_addr,
616 pConfig->self_macaddr.bytes, sizeof(v_MACADDR_t));
617
618 //copy the configuration items to csrProfile
619 sapconvertToCsrProfile( pConfig, eCSR_BSS_TYPE_INFRA_AP, &pSapCtx->csrRoamProfile);
620 hHal = (tHalHandle)VOS_GET_HAL_CB(pvosGCtx);
621 if (NULL == hHal)
622 {
623 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
624 "%s: Invalid MAC context from pvosGCtx", __FUNCTION__);
625 }
626 else
627 {
628 //If concurrent session is running that is already associated
629 //then we just follow that sessions country info (whether
630 //present or not doesn't maater as we have to follow whatever
631 //STA session does)
632 if (0 == sme_GetConcurrentOperationChannel(hHal))
633 {
634 /* Setting the region/country information */
635 sme_setRegInfo(hHal, pConfig->countryCode);
636 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
637 }
638 }
639
640 // Copy MAC filtering settings to sap context
641 pSapCtx->eSapMacAddrAclMode = pConfig->SapMacaddr_acl;
642 vos_mem_copy(pSapCtx->acceptMacList, pConfig->accept_mac, sizeof(pConfig->accept_mac));
643 pSapCtx->nAcceptMac = pConfig->num_accept_mac;
644 sapSortMacList(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
645 vos_mem_copy(pSapCtx->denyMacList, pConfig->deny_mac, sizeof(pConfig->deny_mac));
646 pSapCtx->nDenyMac = pConfig->num_deny_mac;
647 sapSortMacList(pSapCtx->denyMacList, pSapCtx->nDenyMac);
648
649 /* Fill in the event structure for FSM */
650 sapEvent.event = eSAP_HDD_START_INFRA_BSS;
651 sapEvent.params = 0;//pSapPhysLinkCreate
652
653 /* Store the HDD callback in SAP context */
654 pSapCtx->pfnSapEventCallback = pSapEventCallback;
655
656 /* Handle event*/
657 vosStatus = sapFsm(pSapCtx, &sapEvent);
658 }
659 else
660 {
661 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
662 "SoftAp role has not been enabled");
663 }
664
665 return vosStatus;
666}// WLANSAP_StartBss
667
668/*==========================================================================
669 FUNCTION WLANSAP_StopBss
670
671 DESCRIPTION
672 This api function provides SAP FSM event eSAP_HDD_STOP_INFRA_BSS for
673 stopping AP BSS
674
675 DEPENDENCIES
676
677 PARAMETERS
678
679 IN
680 pvosGCtx : Pointer to the global vos context; a handle to SAP's
681 control block can be extracted from its contexe
682
683 RETURN VALUE
684 The result code associated with performing the operation
685
686 VOS_STATUS_E_FAULT: Pointer to VOSS GC is NULL ; access would cause a page
687 fault
688 VOS_STATUS_SUCCESS: Success
689
690 SIDE EFFECTS
691============================================================================*/
692VOS_STATUS
693WLANSAP_StopBss
694(
695 v_PVOID_t pvosGCtx
696)
697{
698 tWLAN_SAPEvent sapEvent; /* State machine event*/
699 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
700 ptSapContext pSapCtx = NULL;
701 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
702
703 /*------------------------------------------------------------------------
704 Sanity check
705 Extract SAP control block
706 ------------------------------------------------------------------------*/
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
708 "WLANSAP_StopBss");
709
710 if ( NULL == pvosGCtx )
711 {
712 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
713 "%s: Invalid Global VOSS handle", __FUNCTION__);
714 return VOS_STATUS_E_FAULT;
715 }
716
717 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
718
719 if (NULL == pSapCtx )
720 {
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
722 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
723 return VOS_STATUS_E_FAULT;
724 }
725
726 /* Fill in the event structure for FSM */
727 sapEvent.event = eSAP_HDD_STOP_INFRA_BSS;
728 sapEvent.params = 0;
729
730 /* Handle event*/
731 vosStatus = sapFsm(pSapCtx, &sapEvent);
732
733 return vosStatus;
734}
735
736/*==========================================================================
737 FUNCTION WLANSAP_GetAssocStations
738
739 DESCRIPTION
740 This api function is used to probe the list of associated stations from various modules of CORE stack
741
742 DEPENDENCIES
743 NA.
744
745 PARAMETERS
746
747 IN
748 pvosGCtx : Pointer to vos global context structure
749 modId : Module from whom list of associtated stations is supposed to be probed. If an invalid module is passed
750 then by default VOS_MODULE_ID_PE will be probed
751 IN/OUT
752 pAssocStas : Pointer to list of associated stations that are known to the module specified in mod parameter
753
754 NOTE: The memory for this list will be allocated by the caller of this API
755
756 RETURN VALUE
757 The VOS_STATUS code associated with performing the operation
758
759 VOS_STATUS_SUCCESS: Success
760
761 SIDE EFFECTS
762============================================================================*/
763VOS_STATUS
764WLANSAP_GetAssocStations
765(
766 v_PVOID_t pvosGCtx,
767 VOS_MODULE_ID modId,
768 tpSap_AssocMacAddr pAssocStas
769)
770{
771 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
772
773 /*------------------------------------------------------------------------
774 Sanity check
775 Extract SAP control block
776 ------------------------------------------------------------------------*/
777 if (NULL == pSapCtx)
778 {
779 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
780 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
781 return VOS_STATUS_E_FAULT;
782 }
783
784 sme_RoamGetAssociatedStas( VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
785 modId,
786 pSapCtx->pUsrContext,
787 (v_PVOID_t *)pSapCtx->pfnSapEventCallback,
788 (v_U8_t *)pAssocStas );
789
790 return VOS_STATUS_SUCCESS;
791}
792
793
794/*==========================================================================
795 FUNCTION WLANSAP_RemoveWpsSessionOverlap
796
797 DESCRIPTION
798 This api function provides for Ap App/HDD to remove an entry from session session overlap info.
799
800 DEPENDENCIES
801 NA.
802
803 PARAMETERS
804
805 IN
806 pvosGCtx: Pointer to vos global context structure
807 pRemoveMac: pointer to v_MACADDR_t for session MAC address
808
809 RETURN VALUE
810 The VOS_STATUS code associated with performing the operation
811
812 VOS_STATUS_SUCCESS: Success
813 VOS_STATUS_E_FAULT: Session is not dectected. The parameter is function not valid.
814
815 SIDE EFFECTS
816============================================================================*/
817VOS_STATUS
818WLANSAP_RemoveWpsSessionOverlap
819
820(
821 v_PVOID_t pvosGCtx,
822 v_MACADDR_t pRemoveMac
823)
824{
825 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
826
827 /*------------------------------------------------------------------------
828 Sanity check
829 Extract SAP control block
830 ------------------------------------------------------------------------*/
831 if (NULL == pSapCtx)
832 {
833 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
834 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
835 return VOS_STATUS_E_FAULT;
836 }
837
838 sme_RoamGetWpsSessionOverlap( VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
839 pSapCtx->pUsrContext,
840 (v_PVOID_t *)pSapCtx->pfnSapEventCallback,
841 pRemoveMac);
842
843 return VOS_STATUS_SUCCESS;
844}
845
846/*==========================================================================
847 FUNCTION WLANSAP_getWpsSessionOverlap
848
849 DESCRIPTION
850 This api function provides for Ap App/HDD to get WPS session overlap info.
851
852 DEPENDENCIES
853 NA.
854
855 PARAMETERS
856
857 IN
858 pvosGCtx: Pointer to vos global context structure
859
860 RETURN VALUE
861 The VOS_STATUS code associated with performing the operation
862
863 VOS_STATUS_SUCCESS: Success
864
865 SIDE EFFECTS
866============================================================================*/
867VOS_STATUS
868WLANSAP_getWpsSessionOverlap
869(
870 v_PVOID_t pvosGCtx
871)
872{
873 v_MACADDR_t pRemoveMac = VOS_MAC_ADDR_ZERO_INITIALIZER;
874
875 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
876
877 /*------------------------------------------------------------------------
878 Sanity check
879 Extract SAP control block
880 ------------------------------------------------------------------------*/
881 if (NULL == pSapCtx)
882 {
883 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
884 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
885 return VOS_STATUS_E_FAULT;
886 }
887
888 sme_RoamGetWpsSessionOverlap( VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
889 pSapCtx->pUsrContext,
890 (v_PVOID_t *)pSapCtx->pfnSapEventCallback,
891 pRemoveMac);
892
893 return VOS_STATUS_SUCCESS;
894}
895
896
897/* This routine will set the mode of operation for ACL dynamically*/
898VOS_STATUS
899WLANSAP_SetMode ( v_PVOID_t pvosGCtx, v_U32_t mode)
900{
901 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
902
903 if (NULL == pSapCtx)
904 {
905 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
906 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
907 return VOS_STATUS_E_FAULT;
908 }
909
910 pSapCtx->eSapMacAddrAclMode = (eSapMacAddrACL)mode;
911 return VOS_STATUS_SUCCESS;
912}
913
914/* This routine will clear all the entries in accept list as well as deny list */
915
916VOS_STATUS
917WLANSAP_ClearACL( v_PVOID_t pvosGCtx)
918{
919 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
920 v_U8_t i;
921
922 if (NULL == pSapCtx)
923 {
924 return VOS_STATUS_E_RESOURCES;
925 }
926
927 if (pSapCtx->denyMacList != NULL)
928 {
929 for (i = 0; i < (pSapCtx->nDenyMac-1); i++)
930 {
931 vos_mem_zero((pSapCtx->denyMacList+i)->bytes, sizeof(v_MACADDR_t));
932
933 }
934 }
935 sapPrintACL(pSapCtx->denyMacList, pSapCtx->nDenyMac);
936 pSapCtx->nDenyMac = 0;
937
938 if (pSapCtx->acceptMacList!=NULL)
939 {
940 for (i = 0; i < (pSapCtx->nAcceptMac-1); i++)
941 {
942 vos_mem_zero((pSapCtx->acceptMacList+i)->bytes, sizeof(v_MACADDR_t));
943
944 }
945 }
946 sapPrintACL(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
947 pSapCtx->nAcceptMac = 0;
948
949 return VOS_STATUS_SUCCESS;
950}
951
952VOS_STATUS
953WLANSAP_ModifyACL
954(
955 v_PVOID_t pvosGCtx,
956 v_U8_t *pPeerStaMac,
957 eSapACLType listType,
958 eSapACLCmdType cmd
959)
960{
961 eSapBool staInWhiteList=eSAP_FALSE, staInBlackList=eSAP_FALSE;
962 v_U8_t staWLIndex, staBLIndex;
963 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
964
965 if (NULL == pSapCtx)
966 {
967 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
968 "%s: Invalid SAP Context", __FUNCTION__);
969 return VOS_STATUS_E_FAULT;
970 }
971
972 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"Modify ACL entered\n"
973 "Before modification of ACL\n"
974 "size of accept and deny lists %d %d",
975 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
976 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** WHITE LIST ***");
977 sapPrintACL(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
978 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** BLACK LIST ***");
979 sapPrintACL(pSapCtx->denyMacList, pSapCtx->nDenyMac);
980
981 /* the expectation is a mac addr will not be in both the lists at the same time.
982 It is the responsiblity of userspace to ensure this */
983 staInWhiteList = sapSearchMacList(pSapCtx->acceptMacList, pSapCtx->nAcceptMac, pPeerStaMac, &staWLIndex);
984 staInBlackList = sapSearchMacList(pSapCtx->denyMacList, pSapCtx->nDenyMac, pPeerStaMac, &staBLIndex);
985
986 if (staInWhiteList && staInBlackList)
987 {
988 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
989 "Peer mac %02x:%02x:%02x:%02x:%02x:%02x found in white and black lists."
990 "Initial lists passed incorrect. Cannot execute this command.",
991 pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], pPeerStaMac[3],
992 pPeerStaMac[4], pPeerStaMac[5]);
993 return VOS_STATUS_E_FAILURE;
994
995 }
996
997 switch(listType)
998 {
999 case eSAP_WHITE_LIST:
1000 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW, "cmd %d", cmd);
1001 if (cmd == ADD_STA_TO_ACL)
1002 {
1003 //error check
1004 // if list is already at max, return failure
1005 if (pSapCtx->nAcceptMac == MAX_MAC_ADDRESS_ACCEPTED)
1006 {
1007 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1008 "White list is already maxed out. Cannot accept %02x:%02x:%02x:%02x:%02x:%02x",
1009 pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], pPeerStaMac[3],
1010 pPeerStaMac[4], pPeerStaMac[5]);
1011 return VOS_STATUS_E_FAILURE;
1012 }
1013 if (staInWhiteList)
1014 {
1015 //Do nothing if already present in white list. Just print a warning
1016 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1017 "MAC address already present in white list %02x:%02x:%02x:%02x:%02x:%02x",
1018 pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], pPeerStaMac[3],
1019 pPeerStaMac[4], pPeerStaMac[5]);
1020 } else
1021 {
1022 if (staInBlackList)
1023 {
1024 //remove it from black list before adding to the white list
1025 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1026 "STA present in black list so first remove from it");
1027 sapRemoveMacFromACL(pSapCtx->denyMacList, &pSapCtx->nDenyMac, staBLIndex);
1028 }
1029 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1030 "... Now add to the white list");
1031 sapAddMacToACL(pSapCtx->acceptMacList, &pSapCtx->nAcceptMac, pPeerStaMac);
1032 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW, "size of accept and deny lists %d %d",
1033 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
1034 }
1035 }
1036 else if (cmd == DELETE_STA_FROM_ACL)
1037 {
1038 if (staInWhiteList)
1039 {
1040 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, "Delete from white list");
1041 sapRemoveMacFromACL(pSapCtx->acceptMacList, &pSapCtx->nAcceptMac, staWLIndex);
1042 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW, "size of accept and deny lists %d %d",
1043 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
1044 }
1045 else
1046 {
1047 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1048 "MAC address to be deleted is not present in the white list %02x:%02x:%02x:%02x:%02x:%02x",
1049 pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], pPeerStaMac[3],
1050 pPeerStaMac[4], pPeerStaMac[5]);
1051 return VOS_STATUS_E_FAILURE;
1052 }
1053 }
1054 else
1055 {
1056 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "Invalid cmd type passed");
1057 return VOS_STATUS_E_FAILURE;
1058 }
1059 break;
1060
1061 case eSAP_BLACK_LIST:
1062 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,
1063 "cmd %d", cmd);
1064 if (cmd == ADD_STA_TO_ACL)
1065 {
1066 //error check
1067 // if list is already at max, return failure
1068 if (pSapCtx->nDenyMac == MAX_MAC_ADDRESS_ACCEPTED)
1069 {
1070 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1071 "Black list is already maxed out. Cannot accept %02x:%02x:%02x:%02x:%02x:%02x",
1072 pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], pPeerStaMac[3],
1073 pPeerStaMac[4], pPeerStaMac[5]);
1074 return VOS_STATUS_E_FAILURE;
1075 }
1076 if (staInBlackList)
1077 {
1078 //Do nothing if already present in white list
1079 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1080 "MAC address already present in black list %02x:%02x:%02x:%02x:%02x:%02x",
1081 pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], pPeerStaMac[3],
1082 pPeerStaMac[4], pPeerStaMac[5]);
1083 } else
1084 {
1085 if (staInWhiteList)
1086 {
1087 //remove it from white list before adding to the white list
1088 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1089 "Present in white list so first remove from it");
1090 sapRemoveMacFromACL(pSapCtx->acceptMacList, &pSapCtx->nAcceptMac, staWLIndex);
1091 }
1092 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1093 "... Now add to black list");
1094 sapAddMacToACL(pSapCtx->denyMacList, &pSapCtx->nDenyMac, pPeerStaMac);
1095 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"size of accept and deny lists %d %d",
1096 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
1097 }
1098 }
1099 else if (cmd == DELETE_STA_FROM_ACL)
1100 {
1101 if (staInBlackList)
1102 {
1103 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, "Delete from black list");
1104 sapRemoveMacFromACL(pSapCtx->denyMacList, &pSapCtx->nDenyMac, staBLIndex);
1105 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"no accept and deny mac %d %d",
1106 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
1107 }
1108 else
1109 {
1110 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1111 "MAC address to be deleted is not present in the black list %02x:%02x:%02x:%02x:%02x:%02x",
1112 pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], pPeerStaMac[3],
1113 pPeerStaMac[4], pPeerStaMac[5]);
1114 return VOS_STATUS_E_FAILURE;
1115 }
1116 }
1117 else
1118 {
1119 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "Invalid cmd type passed");
1120 return VOS_STATUS_E_FAILURE;
1121 }
1122 break;
1123
1124 default:
1125 {
1126 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1127 "Invalid list type passed %d",listType);
1128 return VOS_STATUS_E_FAILURE;
1129 }
1130 }
1131 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"After modification of ACL");
1132 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** WHITE LIST ***");
1133 sapPrintACL(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
1134 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** BLACK LIST ***");
1135 sapPrintACL(pSapCtx->denyMacList, pSapCtx->nDenyMac);
1136 return VOS_STATUS_SUCCESS;
1137}
1138
1139/*==========================================================================
1140 FUNCTION WLANSAP_DisassocSta
1141
1142 DESCRIPTION
1143 This api function provides for Ap App/HDD initiated disassociation of station
1144
1145 DEPENDENCIES
1146 NA.
1147
1148 PARAMETERS
1149
1150 IN
1151 pvosGCtx : Pointer to vos global context structure
1152 pPeerStaMac : Mac address of the station to disassociate
1153
1154 RETURN VALUE
1155 The VOS_STATUS code associated with performing the operation
1156
1157 VOS_STATUS_SUCCESS: Success
1158
1159 SIDE EFFECTS
1160============================================================================*/
1161VOS_STATUS
1162WLANSAP_DisassocSta
1163(
1164 v_PVOID_t pvosGCtx,
1165 v_U8_t *pPeerStaMac
1166)
1167{
1168 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1169
1170 /*------------------------------------------------------------------------
1171 Sanity check
1172 Extract SAP control block
1173 ------------------------------------------------------------------------*/
1174 if (NULL == pSapCtx)
1175 {
1176 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1177 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1178 return VOS_STATUS_E_FAULT;
1179 }
1180
1181 sme_RoamDisconnectSta(VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
1182 pPeerStaMac);
1183
1184 return VOS_STATUS_SUCCESS;
1185}
1186
1187#ifdef WLAN_SOFTAP_FEATURE
1188/*==========================================================================
1189 FUNCTION WLANSAP_DeauthSta
1190
1191 DESCRIPTION
1192 This api function provides for Ap App/HDD initiated deauthentication of station
1193
1194 DEPENDENCIES
1195 NA.
1196
1197 PARAMETERS
1198
1199 IN
1200 pvosGCtx : Pointer to vos global context structure
1201 pPeerStaMac : Mac address of the station to deauthenticate
1202
1203 RETURN VALUE
1204 The VOS_STATUS code associated with performing the operation
1205
1206 VOS_STATUS_SUCCESS: Success
1207
1208 SIDE EFFECTS
1209============================================================================*/
1210VOS_STATUS
1211WLANSAP_DeauthSta
1212(
1213 v_PVOID_t pvosGCtx,
1214 v_U8_t *pPeerStaMac
1215)
1216{
1217 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1218
1219 /*------------------------------------------------------------------------
1220 Sanity check
1221 Extract SAP control block
1222 ------------------------------------------------------------------------*/
1223 if (NULL == pSapCtx)
1224 {
1225 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1226 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1227 return VOS_STATUS_E_FAULT;
1228 }
1229
1230 sme_RoamDeauthSta(VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
1231 pPeerStaMac);
1232
1233 return VOS_STATUS_SUCCESS;
1234}
1235/*==========================================================================
1236 FUNCTION WLANSAP_SetChannelRange
1237
1238 DESCRIPTION
1239 This api function sets the range of channels for AP.
1240
1241 DEPENDENCIES
1242 NA.
1243
1244 PARAMETERS
1245
1246 IN
1247 startChannel : start channel
1248 endChannel : End channel
1249 operatingBand : Operating band (2.4GHz/5GHz)
1250
1251 RETURN VALUE
1252 The VOS_STATUS code associated with performing the operation
1253
1254 VOS_STATUS_SUCCESS: Success
1255
1256 SIDE EFFECTS
1257============================================================================*/
1258VOS_STATUS
1259WLANSAP_SetChannelRange(tHalHandle hHal,v_U8_t startChannel, v_U8_t endChannel,
1260 v_U8_t operatingBand)
1261{
1262
1263 v_U8_t validChannelFlag =0;
1264 v_U8_t loopStartCount =0;
1265 v_U8_t loopEndCount =0;
1266 v_U8_t bandStartChannel =0;
1267 v_U8_t bandEndChannel =0;
1268
1269 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1270 "WLANSAP_SetChannelRange:startChannel %d,EndChannel %d,Operatingband:%d",
1271 startChannel,endChannel,operatingBand);
1272
1273 /*------------------------------------------------------------------------
1274 Sanity check
1275 ------------------------------------------------------------------------*/
1276 if (( WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND_APMIN > operatingBand)||
1277 (WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND_APMAX < operatingBand))
1278 {
1279 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1280 "Invalid operatingBand on WLANSAP_SetChannelRange");
1281 return VOS_STATUS_E_FAULT;
1282 }
1283 if (( WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL_APMIN > startChannel)||
1284 (WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL_APMAX < startChannel))
1285 {
1286 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1287 "Invalid startChannel value on WLANSAP_SetChannelRange");
1288 return VOS_STATUS_E_FAULT;
1289 }
1290 if (( WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL_APMIN > endChannel)||
1291 (WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL_APMAX < endChannel))
1292 {
1293 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1294 "Invalid endChannel value on WLANSAP_SetChannelRange");
1295 return VOS_STATUS_E_FAULT;
1296 }
1297 switch(operatingBand)
1298 {
1299 case RF_SUBBAND_2_4_GHZ:
1300 bandStartChannel = RF_CHAN_1;
1301 bandEndChannel = RF_CHAN_14;
1302 break;
1303
1304 case RF_SUBBAND_5_LOW_GHZ:
1305 bandStartChannel = RF_CHAN_36;
1306 bandEndChannel = RF_CHAN_64;
1307 break;
1308
1309 case RF_SUBBAND_5_MID_GHZ:
1310 bandStartChannel = RF_CHAN_100;
1311 bandEndChannel = RF_CHAN_140;
1312 break;
1313
1314 case RF_SUBBAND_5_HIGH_GHZ:
1315 bandStartChannel = RF_CHAN_149;
1316 bandEndChannel = RF_CHAN_165;
1317 break;
1318
1319 case RF_SUBBAND_4_9_GHZ:
1320 bandStartChannel = RF_CHAN_240;
1321 bandEndChannel = RF_CHAN_216;
1322 break;
1323 default:
1324 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1325 "Invalid operatingBand value on WLANSAP_SetChannelRange");
1326 break;
1327 }
1328
1329 /* Validating the start channel is in range or not*/
1330 for(loopStartCount = bandStartChannel ; loopStartCount <= bandEndChannel ;
1331 loopStartCount++)
1332 {
1333 if(rfChannels[loopStartCount].channelNum == startChannel )
1334 {
1335 /* start channel is in the range */
1336 break;
1337 }
1338 }
1339 /* Validating the End channel is in range or not*/
1340 for(loopEndCount = bandStartChannel ; loopEndCount <= bandEndChannel ;
1341 loopEndCount++)
1342 {
1343 if(rfChannels[loopEndCount].channelNum == endChannel )
1344 {
1345 /* End channel is in the range */
1346 break;
1347 }
1348 }
1349 if((loopStartCount > bandEndChannel)||(loopEndCount > bandEndChannel))
1350 {
1351 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1352 "%s: Invalid startChannel-%d or EndChannel-%d for band -%d",
1353 __FUNCTION__,startChannel,endChannel,operatingBand);
1354 /* Supplied channels are nt in the operating band so set the default
1355 channels for the given operating band */
1356 startChannel = rfChannels[bandStartChannel].channelNum;
1357 endChannel = rfChannels[bandEndChannel].channelNum;;
1358 }
1359
1360 /*Search for the Active channels in the given range */
1361 for( loopStartCount = bandStartChannel; loopStartCount <= bandEndChannel; loopStartCount++ )
1362 {
1363 if((startChannel <= rfChannels[loopStartCount].channelNum)&&
1364 (endChannel >= rfChannels[loopStartCount].channelNum ))
1365 {
1366 if( regChannels[loopStartCount].enabled )
1367 {
1368 validChannelFlag = 1;
1369 break;
1370 }
1371 }
1372 }
1373 if(0 == validChannelFlag)
1374 {
1375 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1376 "%s-No active channels present in the given range for the current region",
1377 __FUNCTION__);
1378 /* There is no active channel in the supplied range.Updating the config
1379 with the default channels in the given band so that we can select the best channel in the sub-band*/
1380 startChannel = rfChannels[bandStartChannel].channelNum;
1381 endChannel = rfChannels[bandEndChannel].channelNum;;
1382 }
1383
1384 if (ccmCfgSetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND,
1385 operatingBand, NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1386 {
1387 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1388 "Could not pass on WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND to CCn");
1389 return VOS_STATUS_E_FAULT;
1390 }
1391 if (ccmCfgSetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL,
1392 startChannel, NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1393 {
1394
1395 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1396 "Could not pass on WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL to CCM");
1397 return VOS_STATUS_E_FAULT;
1398
1399 }
1400 if (ccmCfgSetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL,
1401 endChannel, NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1402 {
1403
1404 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1405 "Could not pass on WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL to CCM");
1406 return VOS_STATUS_E_FAULT;
1407 }
1408 return VOS_STATUS_SUCCESS;
1409}
1410#endif
1411
1412/*==========================================================================
1413 FUNCTION WLANSAP_SetCounterMeasure
1414
1415 DESCRIPTION
1416 This api function is used to disassociate all the stations and prevent
1417 association for any other station.Whenever Authenticator receives 2 mic failures
1418 within 60 seconds, Authenticator will enable counter measure at SAP Layer.
1419 Authenticator will start the 60 seconds timer. Core stack will not allow any
1420 STA to associate till HDD disables counter meassure. Core stack shall kick out all the
1421 STA which are currently associated and DIASSOC Event will be propogated to HDD for
1422 each STA to clean up the HDD STA table.Once the 60 seconds timer expires, Authenticator
1423 will disable the counter meassure at core stack. Now core stack can allow STAs to associate.
1424
1425 DEPENDENCIES
1426 NA.
1427
1428 PARAMETERS
1429
1430 IN
1431pvosGCtx: Pointer to vos global context structure
1432bEnable: If TRUE than all stations will be disassociated and no more will be allowed to associate. If FALSE than CORE
1433will come out of this state.
1434
1435 RETURN VALUE
1436 The VOS_STATUS code associated with performing the operation
1437
1438 VOS_STATUS_SUCCESS: Success
1439
1440 SIDE EFFECTS
1441============================================================================*/
1442VOS_STATUS
1443WLANSAP_SetCounterMeasure
1444(
1445 v_PVOID_t pvosGCtx,
1446 v_BOOL_t bEnable
1447)
1448{
1449 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1450
1451 /*------------------------------------------------------------------------
1452 Sanity check
1453 Extract SAP control block
1454 ------------------------------------------------------------------------*/
1455 if (NULL == pSapCtx)
1456 {
1457 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1458 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1459 return VOS_STATUS_E_FAULT;
1460 }
1461
1462 sme_RoamTKIPCounterMeasures(VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId, bEnable);
1463
1464 return VOS_STATUS_SUCCESS;
1465}
1466
1467/*==========================================================================
1468
1469 FUNCTION WLANSAP_SetKeysSta
1470
1471 DESCRIPTION
1472 This api function provides for Ap App/HDD to set key for a station.
1473
1474 DEPENDENCIES
1475 NA.
1476
1477 PARAMETERS
1478
1479 IN
1480pvosGCtx: Pointer to vos global context structure
1481pSetKeyInfo: tCsrRoamSetKey structure for the station
1482
1483 RETURN VALUE
1484 The VOS_STATUS code associated with performing the operation
1485
1486 VOS_STATUS_SUCCESS: Success
1487
1488 SIDE EFFECTS
1489============================================================================*/
1490VOS_STATUS
1491WLANSAP_SetKeySta
1492(
1493 v_PVOID_t pvosGCtx, tCsrRoamSetKey *pSetKeyInfo
1494)
1495{
1496 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1497 ptSapContext pSapCtx = NULL;
1498 v_PVOID_t hHal = NULL;
1499 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1500 v_U32_t roamId=0xFF;
1501
1502 if (VOS_STA_SAP_MODE == vos_get_conparam ( ))
1503 {
1504 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1505 if (NULL == pSapCtx)
1506 {
1507 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1508 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1509 return VOS_STATUS_E_FAULT;
1510 }
1511 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1512 if (NULL == hHal)
1513 {
1514 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1515 "%s: Invalid HAL pointer from pvosGCtx", __FUNCTION__);
1516 return VOS_STATUS_E_FAULT;
1517 }
1518 halStatus = sme_RoamSetKey(hHal, pSapCtx->sessionId, pSetKeyInfo, &roamId);
1519
1520 if (halStatus == eHAL_STATUS_SUCCESS)
1521 {
1522 vosStatus = VOS_STATUS_SUCCESS;
1523 } else
1524 {
1525 vosStatus = VOS_STATUS_E_FAULT;
1526 }
1527 }
1528 else
1529 vosStatus = VOS_STATUS_E_FAULT;
1530
1531 return vosStatus;
1532}
1533
1534/*==========================================================================
1535 FUNCTION WLANSAP_DelKeySta
1536
1537 DESCRIPTION
1538 This api function provides for Ap App/HDD to delete key for a station.
1539
1540 DEPENDENCIES
1541 NA.
1542
1543 PARAMETERS
1544
1545 IN
1546pvosGCtx: Pointer to vos global context structure
1547pSetKeyInfo: tCsrRoamRemoveKey structure for the station
1548
1549 RETURN VALUE
1550 The VOS_STATUS code associated with performing the operation
1551
1552 VOS_STATUS_SUCCESS: Success
1553
1554 SIDE EFFECTS
1555============================================================================*/
1556VOS_STATUS
1557WLANSAP_DelKeySta
1558(
1559 v_PVOID_t pvosGCtx,
1560 tCsrRoamRemoveKey *pRemoveKeyInfo
1561)
1562{
1563 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1564 ptSapContext pSapCtx = NULL;
1565 v_PVOID_t hHal = NULL;
1566 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1567 v_U32_t roamId=0xFF;
1568 tCsrRoamRemoveKey RemoveKeyInfo;
1569
1570 if (VOS_STA_SAP_MODE == vos_get_conparam ( ))
1571 {
1572 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1573 if (NULL == pSapCtx)
1574 {
1575 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1576 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1577 return VOS_STATUS_E_FAULT;
1578 }
1579
1580 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1581 if (NULL == hHal)
1582 {
1583 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1584 "%s: Invalid HAL pointer from pvosGCtx", __FUNCTION__);
1585 return VOS_STATUS_E_FAULT;
1586 }
1587
1588 vos_mem_zero(&RemoveKeyInfo, sizeof(RemoveKeyInfo));
1589 RemoveKeyInfo.encType = pRemoveKeyInfo->encType;
1590 vos_mem_copy(RemoveKeyInfo.peerMac, pRemoveKeyInfo->peerMac, WNI_CFG_BSSID_LEN);
1591 RemoveKeyInfo.keyId = pRemoveKeyInfo->keyId;
1592
1593 halStatus = sme_RoamRemoveKey(hHal, pSapCtx->sessionId, &RemoveKeyInfo, &roamId);
1594
1595 if (HAL_STATUS_SUCCESS(halStatus))
1596 {
1597 vosStatus = VOS_STATUS_SUCCESS;
1598 }
1599 else
1600 {
1601 vosStatus = VOS_STATUS_E_FAULT;
1602 }
1603 }
1604 else
1605 vosStatus = VOS_STATUS_E_FAULT;
1606
1607 return vosStatus;
1608}
1609
1610VOS_STATUS
1611WLANSap_getstationIE_information(v_PVOID_t pvosGCtx,
1612 v_U32_t *pLen,
1613 v_U8_t *pBuf)
1614{
1615 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1616 ptSapContext pSapCtx = NULL;
1617 v_U32_t len = 0;
1618
1619 if (VOS_STA_SAP_MODE == vos_get_conparam ( )){
1620 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1621 if (NULL == pSapCtx)
1622 {
1623 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1624 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1625 return VOS_STATUS_E_FAULT;
1626 }
1627 if (pLen)
1628 {
1629 len = *pLen;
1630 *pLen = pSapCtx->nStaWPARSnReqIeLength;
1631 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1632 "%s: WPAIE len : %x", __FUNCTION__, *pLen);
1633 if(pBuf)
1634 {
1635 if(len >= pSapCtx->nStaWPARSnReqIeLength)
1636 {
1637 vos_mem_copy( pBuf, pSapCtx->pStaWpaRsnReqIE, pSapCtx->nStaWPARSnReqIeLength);
1638 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1639 "%s: WPAIE: %02x:%02x:%02x:%02x:%02x:%02x",
1640 __FUNCTION__,
1641 pBuf[0], pBuf[1], pBuf[2],
1642 pBuf[3], pBuf[4], pBuf[5]);
1643 vosStatus = VOS_STATUS_SUCCESS;
1644 }
1645 }
1646 }
1647 }
1648
1649 if( VOS_STATUS_E_FAILURE == vosStatus)
1650 {
1651 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1652 "%s: Error unable to populate the RSNWPAIE",
1653 __FUNCTION__);
1654 }
1655
1656 return vosStatus;
1657
1658}
1659
1660/*==========================================================================
1661 FUNCTION WLANSAP_Set_WpsIe
1662
1663 DESCRIPTION
1664 This api function provides for Ap App/HDD to set WPS IE.
1665
1666 DEPENDENCIES
1667 NA.
1668
1669 PARAMETERS
1670
1671 IN
1672pvosGCtx: Pointer to vos global context structure
1673pWPSIE: tSap_WPSIE structure that include WPS IEs
1674
1675 RETURN VALUE
1676 The VOS_STATUS code associated with performing the operation
1677
1678 VOS_STATUS_SUCCESS: Success
1679
1680 SIDE EFFECTS
1681============================================================================*/
1682VOS_STATUS
1683WLANSAP_Set_WpsIe
1684(
1685 v_PVOID_t pvosGCtx, tSap_WPSIE *pSap_WPSIe
1686)
1687{
1688 ptSapContext pSapCtx = NULL;
1689 v_PVOID_t hHal = NULL;
1690
1691 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1692 "%s, %d", __FUNCTION__, __LINE__);
1693
1694 if(VOS_STA_SAP_MODE == vos_get_conparam ( )) {
1695 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1696 if ( NULL == pSapCtx )
1697 {
1698 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1699 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1700 return VOS_STATUS_E_FAULT;
1701 }
1702
1703 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1704 if ( NULL == hHal ){
1705 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1706 "%s: Invalid HAL pointer from pvosGCtx", __FUNCTION__);
1707 return VOS_STATUS_E_FAULT;
1708 }
1709
1710 if ( sap_AcquireGlobalLock( pSapCtx ) == VOS_STATUS_SUCCESS )
1711 {
1712 if (pSap_WPSIe->sapWPSIECode == eSAP_WPS_BEACON_IE)
1713 {
1714 vos_mem_copy(&pSapCtx->APWPSIEs.SirWPSBeaconIE, &pSap_WPSIe->sapwpsie.sapWPSBeaconIE, sizeof(tSap_WPSBeaconIE));
1715 }
1716 else if (pSap_WPSIe->sapWPSIECode == eSAP_WPS_PROBE_RSP_IE)
1717 {
1718 vos_mem_copy(&pSapCtx->APWPSIEs.SirWPSProbeRspIE, &pSap_WPSIe->sapwpsie.sapWPSProbeRspIE, sizeof(tSap_WPSProbeRspIE));
1719 }
1720 else
1721 {
1722 sap_ReleaseGlobalLock( pSapCtx );
1723 return VOS_STATUS_E_FAULT;
1724 }
1725 sap_ReleaseGlobalLock( pSapCtx );
1726 return VOS_STATUS_SUCCESS;
1727 }
1728 else
1729 return VOS_STATUS_E_FAULT;
1730 }
1731 else
1732 return VOS_STATUS_E_FAULT;
1733}
1734
1735/*==========================================================================
1736 FUNCTION WLANSAP_Update_WpsIe
1737
1738 DESCRIPTION
1739 This api function provides for Ap App/HDD to update WPS IEs.
1740
1741 DEPENDENCIES
1742 NA.
1743
1744 PARAMETERS
1745
1746 IN
1747pvosGCtx: Pointer to vos global context structure
1748
1749 RETURN VALUE
1750 The VOS_STATUS code associated with performing the operation
1751
1752 VOS_STATUS_SUCCESS: Success
1753
1754 SIDE EFFECTS
1755============================================================================*/
1756VOS_STATUS
1757WLANSAP_Update_WpsIe
1758(
1759 v_PVOID_t pvosGCtx
1760)
1761{
1762 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
1763 ptSapContext pSapCtx = NULL;
1764 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1765 v_PVOID_t hHal = NULL;
1766
1767 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1768 "%s, %d", __FUNCTION__, __LINE__);
1769
1770 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
1771 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1772 if ( NULL == pSapCtx )
1773 {
1774 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1775 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1776 return VOS_STATUS_E_FAULT;
1777 }
1778
1779 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1780 if ( NULL == hHal ){
1781 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1782 "%s: Invalid HAL pointer from pvosGCtx", __FUNCTION__);
1783 return VOS_STATUS_E_FAULT;
1784 }
1785
1786 halStatus = sme_RoamUpdateAPWPSIE( hHal, pSapCtx->sessionId, &pSapCtx->APWPSIEs);
1787
1788 if(halStatus == eHAL_STATUS_SUCCESS) {
1789 vosStatus = VOS_STATUS_SUCCESS;
1790 } else
1791 {
1792 vosStatus = VOS_STATUS_E_FAULT;
1793 }
1794
1795 }
1796
1797 return vosStatus;
1798}
1799
1800/*==========================================================================
1801 FUNCTION WLANSAP_Get_WPS_State
1802
1803 DESCRIPTION
1804 This api function provides for Ap App/HDD to check if WPS session in process.
1805
1806 DEPENDENCIES
1807 NA.
1808
1809 PARAMETERS
1810
1811 IN
1812pvosGCtx: Pointer to vos global context structure
1813
1814 OUT
1815pbWPSState: Pointer to variable to indicate if it is in WPS Registration state
1816
1817 RETURN VALUE
1818 The VOS_STATUS code associated with performing the operation
1819
1820 VOS_STATUS_SUCCESS: Success
1821
1822 SIDE EFFECTS
1823============================================================================*/
1824VOS_STATUS
1825WLANSAP_Get_WPS_State
1826(
1827 v_PVOID_t pvosGCtx, v_BOOL_t *bWPSState
1828)
1829{
1830 ptSapContext pSapCtx = NULL;
1831 v_PVOID_t hHal = NULL;
1832
1833 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1834 "%s, %d", __FUNCTION__, __LINE__);
1835
1836 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
1837
1838 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1839 if ( NULL == pSapCtx )
1840 {
1841 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1842 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1843 return VOS_STATUS_E_FAULT;
1844 }
1845
1846 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1847 if ( NULL == hHal ){
1848 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1849 "%s: Invalid HAL pointer from pvosGCtx", __FUNCTION__);
1850 return VOS_STATUS_E_FAULT;
1851 }
1852
1853 if ( sap_AcquireGlobalLock(pSapCtx ) == VOS_STATUS_SUCCESS )
1854 {
1855 if(pSapCtx->APWPSIEs.SirWPSProbeRspIE.FieldPresent & SIR_WPS_PROBRSP_SELECTEDREGISTRA_PRESENT)
1856 *bWPSState = eANI_BOOLEAN_TRUE;
1857 else
1858 *bWPSState = eANI_BOOLEAN_FALSE;
1859
1860 sap_ReleaseGlobalLock( pSapCtx );
1861
1862 return VOS_STATUS_SUCCESS;
1863 }
1864 else
1865 return VOS_STATUS_E_FAULT;
1866 }
1867 else
1868 return VOS_STATUS_E_FAULT;
1869
1870}
1871
1872VOS_STATUS
1873sap_AcquireGlobalLock
1874(
1875 ptSapContext pSapCtx
1876)
1877{
1878 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
1879
1880 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &pSapCtx->SapGlobalLock) ) )
1881 {
1882 vosStatus = VOS_STATUS_SUCCESS;
1883 }
1884
1885 return (vosStatus);
1886}
1887
1888VOS_STATUS
1889sap_ReleaseGlobalLock
1890(
1891 ptSapContext pSapCtx
1892)
1893{
1894 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
1895
1896 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &pSapCtx->SapGlobalLock) ) )
1897 {
1898 vosStatus = VOS_STATUS_SUCCESS;
1899 }
1900
1901 return (vosStatus);
1902}
1903
1904/*==========================================================================
1905 FUNCTION WLANSAP_Set_WPARSNIes
1906
1907 DESCRIPTION
1908 This api function provides for Ap App/HDD to set AP WPA and RSN IE in its beacon and probe response.
1909
1910 DEPENDENCIES
1911 NA.
1912
1913 PARAMETERS
1914
1915 IN
1916 pvosGCtx: Pointer to vos global context structure
1917 pWPARSNIEs: buffer to the WPA/RSN IEs
1918 WPARSNIEsLen: length of WPA/RSN IEs
1919
1920 RETURN VALUE
1921 The VOS_STATUS code associated with performing the operation
1922
1923 VOS_STATUS_SUCCESS: Success
1924
1925 SIDE EFFECTS
1926============================================================================*/
1927VOS_STATUS WLANSAP_Set_WPARSNIes(v_PVOID_t pvosGCtx, v_U8_t *pWPARSNIEs, v_U32_t WPARSNIEsLen)
1928{
1929
1930 ptSapContext pSapCtx = NULL;
1931 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1932 v_PVOID_t hHal = NULL;
1933
1934 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
1935 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1936 if ( NULL == pSapCtx )
1937 {
1938 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1939 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
1940 return VOS_STATUS_E_FAULT;
1941 }
1942
1943 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1944 if ( NULL == hHal ){
1945 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1946 "%s: Invalid HAL pointer from pvosGCtx", __FUNCTION__);
1947 return VOS_STATUS_E_FAULT;
1948 }
1949
1950 pSapCtx->APWPARSNIEs.length = (tANI_U16)WPARSNIEsLen;
1951 vos_mem_copy(pSapCtx->APWPARSNIEs.rsnIEdata, pWPARSNIEs, WPARSNIEsLen);
1952
1953 halStatus = sme_RoamUpdateAPWPARSNIEs( hHal, pSapCtx->sessionId, &pSapCtx->APWPARSNIEs);
1954
1955 if(halStatus == eHAL_STATUS_SUCCESS) {
1956 return VOS_STATUS_SUCCESS;
1957 } else
1958 {
1959 return VOS_STATUS_E_FAULT;
1960 }
1961 }
1962
1963 return VOS_STATUS_E_FAULT;
1964}
1965
1966VOS_STATUS WLANSAP_GetStatistics(v_PVOID_t pvosGCtx, tSap_SoftapStats *statBuf, v_BOOL_t bReset)
1967{
1968 if (NULL == pvosGCtx)
1969 {
1970 return VOS_STATUS_E_FAULT;
1971 }
1972
1973 return (WLANTL_GetSoftAPStatistics(pvosGCtx, statBuf, bReset));
1974}
1975
1976#ifdef WLAN_FEATURE_P2P
1977/*==========================================================================
1978
1979 FUNCTION WLANSAP_SendAction
1980
1981 DESCRIPTION
1982 This api function provides to send action frame sent by upper layer.
1983
1984 DEPENDENCIES
1985 NA.
1986
1987 PARAMETERS
1988
1989 IN
1990 pvosGCtx: Pointer to vos global context structure
1991 pBuf: Pointer of the action frame to be transmitted
1992 len: Length of the action frame
1993
1994 RETURN VALUE
1995 The VOS_STATUS code associated with performing the operation
1996
1997 VOS_STATUS_SUCCESS: Success
1998
1999 SIDE EFFECTS
2000============================================================================*/
2001VOS_STATUS WLANSAP_SendAction( v_PVOID_t pvosGCtx, const tANI_U8 *pBuf,
Jeff Johnsone7245742012-09-05 17:12:55 -07002002 tANI_U32 len, tANI_U16 wait )
Jeff Johnson295189b2012-06-20 16:38:30 -07002003{
2004 ptSapContext pSapCtx = NULL;
2005 v_PVOID_t hHal = NULL;
2006 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2007
2008 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2009 {
2010 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2011 if (NULL == pSapCtx)
2012 {
2013 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2014 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
2015 return VOS_STATUS_E_FAULT;
2016 }
2017 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2018 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2019 {
2020 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2021 "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
2022 __FUNCTION__, hHal, pSapCtx->isSapSessionOpen );
2023 return VOS_STATUS_E_FAULT;
2024 }
2025
Jeff Johnsone7245742012-09-05 17:12:55 -07002026 halStatus = sme_sendAction( hHal, pSapCtx->sessionId, pBuf, len, 0 , 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 if ( eHAL_STATUS_SUCCESS == halStatus )
2029 {
2030 return VOS_STATUS_SUCCESS;
2031 }
2032 }
2033
2034 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2035 "Failed to Send Action Frame");
2036
2037 return VOS_STATUS_E_FAULT;
2038}
2039
2040/*==========================================================================
2041
2042 FUNCTION WLANSAP_RemainOnChannel
2043
2044 DESCRIPTION
2045 This api function provides to set Remain On channel on specified channel
2046 for specified duration.
2047
2048 DEPENDENCIES
2049 NA.
2050
2051 PARAMETERS
2052
2053 IN
2054 pvosGCtx: Pointer to vos global context structure
2055 channel: Channel on which driver has to listen
2056 duration: Duration for which driver has to listen on specified channel
2057 callback: Callback function to be called once Listen is done.
2058 pContext: Context needs to be called in callback function.
2059
2060 RETURN VALUE
2061 The VOS_STATUS code associated with performing the operation
2062
2063 VOS_STATUS_SUCCESS: Success
2064
2065 SIDE EFFECTS
2066============================================================================*/
2067VOS_STATUS WLANSAP_RemainOnChannel( v_PVOID_t pvosGCtx,
2068 tANI_U8 channel, tANI_U32 duration,
2069 remainOnChanCallback callback,
2070 void *pContext )
2071{
2072 ptSapContext pSapCtx = NULL;
2073 v_PVOID_t hHal = NULL;
2074 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2075
2076 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2077 {
2078 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2079 if (NULL == pSapCtx)
2080 {
2081 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2082 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
2083 return VOS_STATUS_E_FAULT;
2084 }
2085 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2086 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2087 {
2088 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2089 "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
2090 __FUNCTION__, hHal, pSapCtx->isSapSessionOpen );
2091 return VOS_STATUS_E_FAULT;
2092 }
2093
2094 halStatus = sme_RemainOnChannel( hHal, pSapCtx->sessionId,
2095 channel, duration, callback, pContext );
2096
2097 if( eHAL_STATUS_SUCCESS == halStatus )
2098 {
2099 return VOS_STATUS_SUCCESS;
2100 }
2101 }
2102
2103 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2104 "Failed to Set Remain on Channel");
2105
2106 return VOS_STATUS_E_FAULT;
2107}
2108
2109/*==========================================================================
2110
2111 FUNCTION WLANSAP_CancelRemainOnChannel
2112
2113 DESCRIPTION
2114 This api cancel previous remain on channel request.
2115
2116 DEPENDENCIES
2117 NA.
2118
2119 PARAMETERS
2120
2121 IN
2122 pvosGCtx: Pointer to vos global context structure
2123
2124 RETURN VALUE
2125 The VOS_STATUS code associated with performing the operation
2126
2127 VOS_STATUS_SUCCESS: Success
2128
2129 SIDE EFFECTS
2130============================================================================*/
2131VOS_STATUS WLANSAP_CancelRemainOnChannel( v_PVOID_t pvosGCtx )
2132{
2133 ptSapContext pSapCtx = NULL;
2134 v_PVOID_t hHal = NULL;
2135 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2136
2137 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2138 {
2139 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2140 if (NULL == pSapCtx)
2141 {
2142 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2143 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
2144 return VOS_STATUS_E_FAULT;
2145 }
2146 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2147 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2148 {
2149 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2150 "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
2151 __FUNCTION__, hHal, pSapCtx->isSapSessionOpen );
2152 return VOS_STATUS_E_FAULT;
2153 }
2154
2155 halStatus = sme_CancelRemainOnChannel( hHal, pSapCtx->sessionId );
2156
2157 if( eHAL_STATUS_SUCCESS == halStatus )
2158 {
2159 return VOS_STATUS_SUCCESS;
2160 }
2161 }
2162
2163 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2164 "Failed to Cancel Remain on Channel");
2165
2166 return VOS_STATUS_E_FAULT;
2167}
2168
2169/*==========================================================================
2170
2171 FUNCTION WLANSAP_RegisterMgmtFrame
2172
2173 DESCRIPTION
2174 HDD use this API to register specified type of frame with CORE stack.
2175 On receiving such kind of frame CORE stack should pass this frame to HDD
2176
2177 DEPENDENCIES
2178 NA.
2179
2180 PARAMETERS
2181
2182 IN
2183 pvosGCtx: Pointer to vos global context structure
2184 frameType: frameType that needs to be registered with PE.
2185 matchData: Data pointer which should be matched after frame type is matched.
2186 matchLen: Length of the matchData
2187
2188 RETURN VALUE
2189 The VOS_STATUS code associated with performing the operation
2190
2191 VOS_STATUS_SUCCESS: Success
2192
2193 SIDE EFFECTS
2194============================================================================*/
2195VOS_STATUS WLANSAP_RegisterMgmtFrame( v_PVOID_t pvosGCtx, tANI_U16 frameType,
2196 tANI_U8* matchData, tANI_U16 matchLen )
2197{
2198 ptSapContext pSapCtx = NULL;
2199 v_PVOID_t hHal = NULL;
2200 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2201
2202 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2203 {
2204 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2205 if (NULL == pSapCtx)
2206 {
2207 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2208 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
2209 return VOS_STATUS_E_FAULT;
2210 }
2211 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2212 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2213 {
2214 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2215 "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
2216 __FUNCTION__, hHal, pSapCtx->isSapSessionOpen );
2217 return VOS_STATUS_E_FAULT;
2218 }
2219
2220 halStatus = sme_RegisterMgmtFrame(hHal, pSapCtx->sessionId,
2221 frameType, matchData, matchLen);
2222
2223 if( eHAL_STATUS_SUCCESS == halStatus )
2224 {
2225 return VOS_STATUS_SUCCESS;
2226 }
2227 }
2228
2229 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2230 "Failed to Register MGMT frame");
2231
2232 return VOS_STATUS_E_FAULT;
2233}
2234
2235/*==========================================================================
2236
2237 FUNCTION WLANSAP_DeRegisterMgmtFrame
2238
2239 DESCRIPTION
2240 This API is used to deregister previously registered frame.
2241
2242 DEPENDENCIES
2243 NA.
2244
2245 PARAMETERS
2246
2247 IN
2248 pvosGCtx: Pointer to vos global context structure
2249 frameType: frameType that needs to be De-registered with PE.
2250 matchData: Data pointer which should be matched after frame type is matched.
2251 matchLen: Length of the matchData
2252
2253 RETURN VALUE
2254 The VOS_STATUS code associated with performing the operation
2255
2256 VOS_STATUS_SUCCESS: Success
2257
2258 SIDE EFFECTS
2259============================================================================*/
2260VOS_STATUS WLANSAP_DeRegisterMgmtFrame( v_PVOID_t pvosGCtx, tANI_U16 frameType,
2261 tANI_U8* matchData, tANI_U16 matchLen )
2262{
2263 ptSapContext pSapCtx = NULL;
2264 v_PVOID_t hHal = NULL;
2265 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2266
2267 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2268 {
2269 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2270 if (NULL == pSapCtx)
2271 {
2272 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2273 "%s: Invalid SAP pointer from pvosGCtx", __FUNCTION__);
2274 return VOS_STATUS_E_FAULT;
2275 }
2276 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2277 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2278 {
2279 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2280 "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
2281 __FUNCTION__, hHal, pSapCtx->isSapSessionOpen );
2282 return VOS_STATUS_E_FAULT;
2283 }
2284
2285 halStatus = sme_DeregisterMgmtFrame( hHal, pSapCtx->sessionId,
2286 frameType, matchData, matchLen );
2287
2288 if( eHAL_STATUS_SUCCESS == halStatus )
2289 {
2290 return VOS_STATUS_SUCCESS;
2291 }
2292 }
2293
2294 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2295 "Failed to Deregister MGMT frame");
2296
2297 return VOS_STATUS_E_FAULT;
2298}
2299#endif // WLAN_FEATURE_P2P