/*========================================================================== FUNCTION WLANBAP_Close DESCRIPTION Called by vos_close during general driver close procedure. BAP will clean up all the internal resources. DEPENDENCIES PARAMETERS IN pvosGCtx: pointer to the global vos context; a handle to BAP's control block can be extracted from its context RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page fault VOS_STATUS_SUCCESS: Everything is good :) SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANBAP_Close ( v_PVOID_t pvosGCtx ) { ptBtampContext pBtampCtx = NULL; /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*------------------------------------------------------------------------ Sanity check Extract BAP control block ------------------------------------------------------------------------*/ pBtampCtx = VOS_GET_BAP_CB(pvosGCtx); if ( NULL == pBtampCtx ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Invalid BAP pointer from pvosGCtx on WLANBAP_Close"); return VOS_STATUS_E_FAULT; } /*------------------------------------------------------------------------ Cleanup BAP control block. ------------------------------------------------------------------------*/ VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Close"); WLANBAP_CleanCB(pBtampCtx, 1 /* empty queues/lists/pkts if any*/); #if defined(ANI_OS_TYPE_ANDROID) && defined(WLAN_BTAMP_FEATURE) BSL_Deinit(pvosGCtx); #endif /*------------------------------------------------------------------------ Free BAP context from VOSS global ------------------------------------------------------------------------*/ vos_free_context(pvosGCtx, VOS_MODULE_ID_BAP, pBtampCtx); return VOS_STATUS_SUCCESS; }/* WLANBAP_Close */
// //This function alwasy assume the incoming vos_packet is 802_3 frame. static int authRsnRxFrameHandler( v_PVOID_t pvosGCtx, vos_pkt_t *pPacket ) { int retVal = ANI_ERROR; tAniPacket *pAniPacket; tBtampContext *ctx; tAuthRsnFsm *fsm; /* Validate params */ if ((pvosGCtx == NULL) || (NULL == pPacket)) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "param is NULL in %s", __func__); return retVal; } ctx = (tBtampContext *)VOS_GET_BAP_CB( pvosGCtx ); if (NULL == ctx) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "ctx is NULL in %s", __func__); return retVal; } fsm = &ctx->uFsm.authFsm; if (NULL == fsm) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "fsm is NULL in %s", __func__); return retVal; } do { //ToDO: We need to synchronize this. For now, use the simplest form, drop the packet comes later. if( fsm->fReceiving ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, " ******authRsnRxFrameHandler receive eapol packet while processing. Drop the new comer\n" ); break; } fsm->fReceiving = VOS_TRUE; retVal = bapRsnFormPktFromVosPkt( &pAniPacket, pPacket ); if( !ANI_IS_STATUS_SUCCESS( retVal ) ) break; //Now we can process the eapol frame //handler will free the pAniPacket bapRsnEapolHandler( fsm, pAniPacket, VOS_TRUE ); }while( 0 ); fsm->fReceiving = VOS_FALSE; vos_pkt_return_packet( pPacket ); return retVal; }
static int suppRsnTxCompleteHandler( v_PVOID_t pvosGCtx, vos_pkt_t *pPacket, VOS_STATUS retStatus ) { tBtampContext *ctx = (tBtampContext *)VOS_GET_BAP_CB( pvosGCtx ); tAuthRsnFsm *fsm; vos_pkt_return_packet( pPacket ); if (pvosGCtx == NULL) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "param is NULL in %s", __func__); return ANI_ERROR; } if (NULL == ctx) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "ctx is NULL in %s", __func__); return ANI_ERROR; } fsm = &ctx->uFsm.authFsm; if (NULL == fsm) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "fsm is NULL in %s", __func__); return ANI_ERROR; } //Synchronization needed if(!VOS_IS_STATUS_SUCCESS( retStatus ) ) { //This is bad. VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Supp: TL Tx complete with error %d current state is %d\n", retStatus, fsm->currentState ); if( fsm->numTries <= suppConsts.maxTries ) { //retransmit fsm->numTries++; if( !VOS_IS_STATUS_SUCCESS( bapRsnSendEapolFrame( fsm->ctx->pvosGCtx, fsm->lastEapol ) ) ) { bapSuppDisconnect( fsm->ctx->pvosGCtx ); } } else { bapSuppDisconnect( fsm->ctx->pvosGCtx ); } } return ANI_OK; }
/*========================================================================== FUNCTION WLANBAP_Start DESCRIPTION Called as part of the overall start procedure (vos_start). BAP will use this call to register with TL as the BAP entity for BT-AMP RSN frames. DEPENDENCIES PARAMETERS IN pvosGCtx: pointer to the global vos context; a handle to BAP's control block can be extracted from its context RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page fault VOS_STATUS_SUCCESS: Everything is good :) Other codes can be returned as a result of a BAL failure; SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANBAP_Start ( v_PVOID_t pvosGCtx ) { ptBtampContext pBtampCtx = NULL; VOS_STATUS vosStatus; /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*------------------------------------------------------------------------ Sanity check Extract BAP control block ------------------------------------------------------------------------*/ pBtampCtx = VOS_GET_BAP_CB(pvosGCtx); if ( NULL == pBtampCtx ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Invalid BAP pointer from pvosGCtx on WLANBAP_Start"); return VOS_STATUS_E_FAULT; } /*------------------------------------------------------------------------ Register with TL as an BT-AMP RSN client ------------------------------------------------------------------------*/ VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Start TL register"); /*------------------------------------------------------------------------ Register with CSR for Roam (connection status) Events ------------------------------------------------------------------------*/ VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Start CSR Register"); /* Initialize the BAP Tx packet monitor timer */ WLANBAP_InitConnectionAcceptTimer (pBtampCtx ); WLANBAP_InitLinkSupervisionTimer(pBtampCtx); vosStatus = vos_timer_init( &pBtampCtx->bapTxPktMonitorTimer, VOS_TIMER_TYPE_SW, /* use this type */ WLANBAP_TxPacketMonitorHandler, pBtampCtx); vosStatus = vos_lock_init(&pBtampCtx->bapLock); if(!VOS_IS_STATUS_SUCCESS(vosStatus)) { VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"Lock Init Fail"); } return vosStatus; }/* WLANBAP_Start */
static int authRsnTxCompleteHandler( v_PVOID_t pvosGCtx, vos_pkt_t *pPacket, VOS_STATUS retStatus ) { tBtampContext *ctx = (tBtampContext *)VOS_GET_BAP_CB( pvosGCtx ); tAuthRsnFsm *fsm; vos_pkt_return_packet( pPacket ); if (NULL == ctx) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "ctx is NULL in %s", __func__); return ANI_ERROR; } fsm = &ctx->uFsm.authFsm; if (NULL == fsm) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "fsm is NULL in %s", __func__); return ANI_ERROR; } if(!VOS_IS_STATUS_SUCCESS( retStatus ) ) { //No need to do anything. Retransmit is handled by timeout VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth: TL Tx complete with error %d current state is %d \n", retStatus, fsm->currentState ); } if( PTK_START == fsm->currentState ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO, " Auth: start msg2 timer\n" ); //Start msg2Timer fsm->numTries++; vos_timer_stop( &fsm->msg2Timer ); vos_timer_start(&fsm->msg2Timer, authConsts.timeoutPeriod); } else if( ( PTK_INIT_NEGO == fsm->currentState ) || ( PTK_INIT_NEGO_TX == fsm->currentState ) ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO, " Auth: start msg4 timer\n" ); fsm->numTries++; vos_timer_stop( &fsm->msg4Timer ); vos_timer_start(&fsm->msg4Timer, authConsts.timeoutPeriod); } return ANI_OK; }
/*========================================================================== FUNCTION WLANBAP_Stop DESCRIPTION Called by vos_stop to stop operation in BAP, before close. BAP will suspend all BT-AMP Protocol Adaption Layer operation and will wait for the close request to clean up its resources. DEPENDENCIES PARAMETERS IN pvosGCtx: pointer to the global vos context; a handle to BAP's control block can be extracted from its context RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page fault VOS_STATUS_SUCCESS: Everything is good :) SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANBAP_Stop ( v_PVOID_t pvosGCtx ) { ptBtampContext pBtampCtx = NULL; VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*------------------------------------------------------------------------ Sanity check Extract BAP control block ------------------------------------------------------------------------*/ pBtampCtx = VOS_GET_BAP_CB(pvosGCtx); if ( NULL == pBtampCtx ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Invalid BAP pointer from pvosGCtx on WLANBAP_Stop"); return VOS_STATUS_E_FAULT; } /*------------------------------------------------------------------------ Stop BAP (de-register RSN handler!?) ------------------------------------------------------------------------*/ vosStatus = WLANBAP_DeinitConnectionAcceptTimer(pBtampCtx); if ( VOS_STATUS_SUCCESS != vosStatus) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Couldn't destroy bapConnectionAcceptTimer"); } vosStatus = WLANBAP_DeinitLinkSupervisionTimer(pBtampCtx); if ( VOS_STATUS_SUCCESS != vosStatus) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Couldn't destroy bapLinkSupervisionTimer"); } vosStatus = vos_timer_destroy ( &pBtampCtx->bapTxPktMonitorTimer ); if ( VOS_STATUS_SUCCESS != vosStatus) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Couldn't destroy bapTxPktMonitorTimer"); } vos_lock_destroy(&pBtampCtx->bapLock); return VOS_STATUS_SUCCESS; }/* WLANBAP_Stop */
/*========================================================================== FUNCTION WLANBAP_RxCallback DESCRIPTION This function is called by TL call this function for all frames except for Data frames DEPENDENCIES PARAMETERS pvosGCtx: pointer to the global vos context; a handle to BAP's control block can be extracted from its context pPacket Vos packet frameType Frame type RETURN VALUE None SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANBAP_RxCallback ( v_PVOID_t pvosGCtx, vos_pkt_t *pPacket, WLANTL_BAPFrameEnumType frameType ) { ptBtampContext pBtampCtx = NULL; pBtampCtx = VOS_GET_BAP_CB(pvosGCtx); if ( NULL == pBtampCtx ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Invalid BAP pointer from pvosGCtx on WLANBAP_Start"); return VOS_STATUS_E_FAULT; } switch (frameType) { case WLANTL_BT_AMP_TYPE_LS_REQ: /* Fall through */ case WLANTL_BT_AMP_TYPE_LS_REP: { /* Link supervision frame, process this frame */ VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: link Supervision packet received over TL: %d, => BAP", __func__, frameType); WLANBAP_RxProcLsPkt((ptBtampHandle)pBtampCtx, pBtampCtx->phy_link_handle, frameType, pPacket); break; } case WLANTL_BT_AMP_TYPE_AR: /* Fall through */ case WLANTL_BT_AMP_TYPE_SEC: { /* Call the RSN callback handler */ bapRsnRxCallback (pvosGCtx, pPacket); break; } default: VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s: Invalid frametype from TL: %d, => BAP", __func__, frameType); } return ( VOS_STATUS_SUCCESS ); }
/*========================================================================== FUNCTION WLANBAP_Open DESCRIPTION Called at driver initialization (vos_open). BAP will initialize all its internal resources and will wait for the call to start to register with the other modules. DEPENDENCIES PARAMETERS IN pvosGCtx: pointer to the global vos context; a handle to BAP's control block can be extracted from its context RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page fault VOS_STATUS_SUCCESS: Everything is good :) SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANBAP_Open ( v_PVOID_t pvosGCtx ) { ptBtampContext pBtampCtx = NULL; /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*------------------------------------------------------------------------ Allocate (and sanity check?!) BAP control block ------------------------------------------------------------------------*/ vos_alloc_context(pvosGCtx, VOS_MODULE_ID_BAP, (v_VOID_t**)&pBtampCtx, sizeof(tBtampContext)); pBtampCtx = VOS_GET_BAP_CB(pvosGCtx); if ( NULL == pBtampCtx ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Invalid BAP pointer from pvosGCtx on WLANBAP_Open"); //"Failed to allocate BAP pointer from pvosGCtx on WLANBAP_Open"); return VOS_STATUS_E_FAULT; } /*------------------------------------------------------------------------ Clean up BAP control block, initialize all values ------------------------------------------------------------------------*/ VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Open"); WLANBAP_CleanCB(pBtampCtx, 0 /*do not empty*/); // Setup the "link back" to the VOSS context pBtampCtx->pvosGCtx = pvosGCtx; // Store a pointer to the BAP context provided by VOSS gpBtampCtx = pBtampCtx; /*------------------------------------------------------------------------ Allocate internal resources ------------------------------------------------------------------------*/ return VOS_STATUS_SUCCESS; }/* WLANBAP_Open */
static VOS_STATUS bapRsnTxCompleteCallback( v_PVOID_t pvosGCtx, vos_pkt_t *pPacket, VOS_STATUS retStatus ) { int retVal; ptBtampContext btampContext; // use btampContext value tCsrRoamSetKey setKeyInfo; tSuppRsnFsm *fsm; if (NULL == pvosGCtx) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "pvosGCtx is NULL in %s", __func__); return VOS_STATUS_E_FAULT; } btampContext = VOS_GET_BAP_CB(pvosGCtx); if (NULL == btampContext) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "btampContext is NULL in %s", __func__); return VOS_STATUS_E_FAULT; } fsm = &btampContext->uFsm.suppFsm; if (NULL == fsm) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "fsm is NULL in %s", __func__); return VOS_STATUS_E_FAULT; } //If we get a disconect from upper layer before getting the pkt from TL the //bapRsnFsmTxCmpHandler could be NULL //VOS_ASSERT( bapRsnFsmTxCmpHandler ); if( bapRsnFsmTxCmpHandler ) { //Change the state //Call auth or supp FSM's handler bapRsnFsmTxCmpHandler( pvosGCtx, pPacket, retStatus ); } else { vos_pkt_return_packet( pPacket ); return (VOS_STATUS_SUCCESS ); } //fsm->suppCtx->ptk contains the 3 16-bytes keys. We need the last one. /* We will move the Set key to EAPOL Completion handler. We found a race condition betweem sending EAPOL frame and setting Key */ if (BAP_SET_RSN_KEY == gReadToSetKey) { vos_mem_zero( &setKeyInfo, sizeof( tCsrRoamSetKey ) ); setKeyInfo.encType = eCSR_ENCRYPT_TYPE_AES; setKeyInfo.keyDirection = eSIR_TX_RX; vos_mem_copy( setKeyInfo.peerMac, fsm->suppCtx->authMac, sizeof( tAniMacAddr ) ); setKeyInfo.paeRole = 0; //this is a supplicant setKeyInfo.keyId = 0; //always setKeyInfo.keyLength = CSR_AES_KEY_LEN; vos_mem_copy( setKeyInfo.Key, (v_U8_t *)fsm->suppCtx->ptk + (2 * CSR_AES_KEY_LEN ), CSR_AES_KEY_LEN ); if( !VOS_IS_STATUS_SUCCESS( bapSetKey( fsm->ctx->pvosGCtx, &setKeyInfo ) ) ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, " Supp: gotoStateStaKeySet fail to set key\n" ); retVal = ANI_ERROR; } gReadToSetKey = BAP_RESET_RSN_KEY; } return (VOS_STATUS_SUCCESS ); }
static VOS_STATUS bapRsnTxCompleteCallback( v_PVOID_t pvosGCtx, vos_pkt_t *pPacket, VOS_STATUS retStatus ) { int retVal; ptBtampContext btampContext; // tCsrRoamSetKey setKeyInfo; tSuppRsnFsm *fsm; if (NULL == pvosGCtx) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "pvosGCtx is NULL in %s", __func__); return VOS_STATUS_E_FAULT; } btampContext = VOS_GET_BAP_CB(pvosGCtx); if (NULL == btampContext) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "btampContext is NULL in %s", __func__); return VOS_STATUS_E_FAULT; } fsm = &btampContext->uFsm.suppFsm; if (NULL == fsm) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "fsm is NULL in %s", __func__); return VOS_STATUS_E_FAULT; } // // // if( bapRsnFsmTxCmpHandler ) { // // bapRsnFsmTxCmpHandler( pvosGCtx, pPacket, retStatus ); } else { vos_pkt_return_packet( pPacket ); return (VOS_STATUS_SUCCESS ); } // /* */ if (BAP_SET_RSN_KEY == gReadToSetKey) { vos_mem_zero( &setKeyInfo, sizeof( tCsrRoamSetKey ) ); setKeyInfo.encType = eCSR_ENCRYPT_TYPE_AES; setKeyInfo.keyDirection = eSIR_TX_RX; vos_mem_copy( setKeyInfo.peerMac, fsm->suppCtx->authMac, sizeof( tAniMacAddr ) ); setKeyInfo.paeRole = 0; // setKeyInfo.keyId = 0; // setKeyInfo.keyLength = CSR_AES_KEY_LEN; vos_mem_copy( setKeyInfo.Key, (v_U8_t *)fsm->suppCtx->ptk + (2 * CSR_AES_KEY_LEN ), CSR_AES_KEY_LEN ); if( !VOS_IS_STATUS_SUCCESS( bapSetKey( fsm->ctx->pvosGCtx, &setKeyInfo ) ) ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, " Supp: gotoStateStaKeySet fail to set key\n" ); retVal = ANI_ERROR; } gReadToSetKey = BAP_RESET_RSN_KEY; } return (VOS_STATUS_SUCCESS ); }