/** * \fn mlme_assocRequestMsgBuild * \brief buils association request * * The function builds the association request according to the given parames * * \param pCtx - pointer to mlme_t * \param reqBuf - <output> pointer to built assoc request buffer * \param reqLen - <output> length of built assoc request buffer * * \return TI_OK if auth send successfully * TI_NOK otherwise * * \sa mlme_sendAssocRequest */ TI_STATUS mlme_assocRequestMsgBuild(mlme_t *pCtx, TI_UINT8* reqBuf, TI_UINT32* reqLen) { TI_STATUS status; TI_UINT8 *pRequest; TI_UINT32 len; paramInfo_t param; TTwdParamInfo tTwdParam; TI_UINT16 capabilities; TI_BOOL spectrumManagementEnabled; ECipherSuite eCipherSuite = TWD_CIPHER_NONE; /* To be used for checking whether AP supports HT rates and TKIP */ pRequest = reqBuf; *reqLen = 0; /* insert capabilities */ status = mlme_assocCapBuild(pCtx, &capabilities); if (status == TI_OK) { *(TI_UINT16*)pRequest = ENDIAN_HANDLE_WORD(capabilities); } else { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build assoc Capa\n"); return TI_NOK; } pRequest += sizeof(TI_UINT16); *reqLen += sizeof(TI_UINT16); /* insert listen interval */ tTwdParam.paramType = TWD_LISTEN_INTERVAL_PARAM_ID; status = TWD_GetParam (pCtx->hTWD, &tTwdParam); if (status == TI_OK) { *(TI_UINT16*)pRequest = ENDIAN_HANDLE_WORD((TI_UINT16)tTwdParam.content.halCtrlListenInterval); } else { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to get listen interval\n"); return TI_NOK; } pRequest += sizeof(TI_UINT16); *reqLen += sizeof(TI_UINT16); if (pCtx->reAssoc) { /* Insert currentAPAddress element only in reassoc request*/ param.paramType = SITE_MGR_PREV_SITE_BSSID_PARAM; status = siteMgr_getParam(pCtx->hSiteMgr, ¶m); if (status == TI_OK) { MAC_COPY (pRequest, param.content.siteMgrDesiredBSSID); TRACE6(pCtx->hReport, REPORT_SEVERITY_INFORMATION, "ASSOC_SM: ASSOC_REQ - prev AP = %x-%x-%x-%x-%x-%x\n", param.content.siteMgrDesiredBSSID[0], param.content.siteMgrDesiredBSSID[1], param.content.siteMgrDesiredBSSID[2], param.content.siteMgrDesiredBSSID[3], param.content.siteMgrDesiredBSSID[4], param.content.siteMgrDesiredBSSID[5]); pRequest += MAC_ADDR_LEN; *reqLen += MAC_ADDR_LEN; } else { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: ASSOC_REQ - No prev AP \n"); return status; } } /* insert SSID element */ status = mlme_assocSSIDBuild(pCtx, pRequest, &len); if (status != TI_OK) { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build SSID IE\n"); return TI_NOK; } pRequest += len; *reqLen += len; /* insert Rates element */ status = mlme_assocRatesBuild(pCtx, pRequest, &len); if (status != TI_OK) { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build rates IE\n"); return TI_NOK; } pRequest += len; *reqLen += len; /* Checking if the station supports Spectrum Management (802.11h) */ param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM; status = regulatoryDomain_getParam(pCtx->hRegulatoryDomain,¶m); spectrumManagementEnabled = param.content.spectrumManagementEnabled; /* Checking the selected AP capablities */ param.paramType = SITE_MGR_SITE_CAPABILITY_PARAM; status = siteMgr_getParam(pCtx->hSiteMgr,¶m); if (status == TI_OK && spectrumManagementEnabled && param.content.siteMgrSiteCapability & (DOT11_SPECTRUM_MANAGEMENT != 0)) { /* insert Power capability element */ status = mlme_assocPowerCapabilityBuild(pCtx, pRequest, &len); if (status != TI_OK) { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build Power IE\n"); return TI_NOK; } pRequest += len; *reqLen += len; } #ifdef XCC_MODULE_INCLUDED status = rsn_getXCCExtendedInfoElement(pCtx->hRsn, pRequest, (TI_UINT8*)&len); if (status != TI_OK) { return TI_NOK; } pRequest += len; *reqLen += len; if (pCtx->reAssoc) { /* insert CCKM information element only in reassoc */ status = XCCMngr_getCckmInfoElement(pCtx->hXCCMngr, pRequest, (TI_UINT8*)&len); if (status != TI_OK) { return TI_NOK; } pRequest += len; *reqLen += len; } status = XCCMngr_getXCCVersionInfoElement(pCtx->hXCCMngr, pRequest, (TI_UINT8*)&len); if (status != TI_OK) { return TI_NOK; } pRequest += len; *reqLen += len; /* Insert Radio Mngt Capability IE */ status = measurementMgr_radioMngtCapabilityBuild(pCtx->hMeasurementMgr, pRequest, (TI_UINT8*)&len); if (status != TI_OK) { return TI_NOK; } pRequest += len; *reqLen += len; #endif /* Get Simple-Config state */ param.paramType = SITE_MGR_SIMPLE_CONFIG_MODE; status = siteMgr_getParam(pCtx->hSiteMgr, ¶m); if (param.content.siteMgrWSCMode.WSCMode == TIWLN_SIMPLE_CONFIG_OFF) { /* insert RSN information elements */ status = rsn_getInfoElement(pCtx->hRsn, pRequest, &len); if (status != TI_OK) { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build RSN IE\n"); return TI_NOK; } pRequest += len; *reqLen += len; } /* Privacy - Used later on HT */ param.paramType = RSN_ENCRYPTION_STATUS_PARAM; status = rsn_getParam(pCtx->hRsn, ¶m); if(status == TI_OK) { eCipherSuite = param.content.rsnEncryptionStatus; } /* insert QoS capability information element */ status = qosMngr_getQosCapabiltyInfeElement(pCtx->hQosMngr,pRequest,&len); if (status != TI_OK) { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build QoS capa IE\n"); return TI_NOK; } pRequest += len; *reqLen += len; /* Primary Site support HT ? */ param.paramType = SITE_MGR_PRIMARY_SITE_HT_SUPPORT; siteMgr_getParam(pCtx->hSiteMgr, ¶m); /* Disallow TKIP with HT Rates: If this is the case - discard HT rates from Association Request */ if((TI_TRUE == param.content.bPrimarySiteHtSupport) && (eCipherSuite != TWD_CIPHER_TKIP)) { status = StaCap_GetHtCapabilitiesIe (pCtx->hStaCap, pRequest, &len); if (status != TI_OK) { return TI_NOK; } pRequest += len; *reqLen += len; } status = qosMngr_assocReqBuild(pCtx->hQosMngr,pRequest,&len); if (status != TI_OK) { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build QoS IE\n"); return TI_NOK; } pRequest += len; *reqLen += len; status = apConn_getVendorSpecificIE(pCtx->hApConn, pRequest, &len); if (status != TI_OK) { TRACE0(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build vendor IE\n"); return TI_NOK; } pRequest += len; *reqLen += len; if (*reqLen>=MAX_ASSOC_MSG_LENGTH) { TRACE1(pCtx->hReport, REPORT_SEVERITY_ERROR, "mlme_assocRequestMsgBuild: failed to build, reqLen = %u\n", *reqLen); return TI_NOK; } return TI_OK; }
/** * Called when the SCR callbacks with a RUN response or if the SCR * returned a RUN response when we requested it. * * @date 05-Jan-2006 */ static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData) { measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData; /* Cryptic: the first struct is the requestHandler request while */ /* the second one is the measurementSRV request */ MeasurementRequest_t * pRequestArr[MAX_NUM_REQ]; TMeasurementRequest request; paramInfo_t *pParam; TI_UINT8 numOfRequestsInParallel; TI_UINT8 requestIndex; TI_UINT32 timePassed; TI_BOOL requestedBeaconMeasurement= TI_FALSE; TI_STATUS status; TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Starting Measurement operation\n"); pParam = (paramInfo_t *)os_memoryAlloc(pMeasurementMgr->hOs, sizeof(paramInfo_t)); if (!pParam) { return TI_NOK; } request.channel = pMeasurementMgr->measuredChannelID; request.startTime = 0; /* ignored by MeasurementSRV for now - for .11k */ request.numberOfTypes = 0; TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Measured Channel = %d\n", pMeasurementMgr->measuredChannelID); pParam->paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES; pParam->content.channelCapabilityReq.channelNum = pMeasurementMgr->measuredChannelID; pParam->content.channelCapabilityReq.scanOption = ACTIVE_SCANNING; if (pMeasurementMgr->measuredChannelID <= MAX_CHANNEL_IN_BAND_2_4) { request.band = RADIO_BAND_2_4_GHZ; pParam->content.channelCapabilityReq.band = RADIO_BAND_2_4_GHZ; } else { request.band = RADIO_BAND_5_0_GHZ; pParam->content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ; } regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, pParam); request.txPowerDbm = pParam->content.channelCapabilityRet.maxTxPowerDbm; request.eTag = SCAN_RESULT_TAG_MEASUREMENT; os_memoryFree(pMeasurementMgr->hOs, pParam, sizeof(paramInfo_t)); TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Querying Request Handler for the next request in the queue\n"); /* Getting the next request/requests from the request handler */ status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, TI_TRUE, pRequestArr, &numOfRequestsInParallel); if (status != TI_OK) { TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_ERROR, ": Failed getting next request from Request Handler\n"); return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr); } /* Save the number of requests in parallel so that once the */ /* measurement operation ends we can get rid of this amount of requests */ /* from the requestHandler */ pMeasurementMgr->currentNumOfRequestsInParallel = numOfRequestsInParallel; for (requestIndex = 0; requestIndex < numOfRequestsInParallel; requestIndex++) { if (pRequestArr[requestIndex]->Type == MSR_TYPE_BEACON_MEASUREMENT) { requestedBeaconMeasurement = TI_TRUE; if (pRequestArr[requestIndex]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE) { TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Beacon Table request encountered, building report now\n"); /* building Report for beacon table request */ pMeasurementMgr->buildReport(pMeasurementMgr, *pRequestArr[requestIndex], NULL); continue; } } /* save the request so we can reference it when results arrive */ pMeasurementMgr->currentRequest[request.numberOfTypes] = pRequestArr[requestIndex]; /* add the measurement type to the request's list */ request.msrTypes[request.numberOfTypes].duration = pRequestArr[requestIndex]->DurationTime; request.msrTypes[request.numberOfTypes].scanMode = pRequestArr[requestIndex]->ScanMode; request.msrTypes[request.numberOfTypes].msrType = pRequestArr[requestIndex]->Type; TRACE3(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ":\n\nMeasurement Request #%d Details: Type = %d, Duration = %d\n\n", request.numberOfTypes+1, request.msrTypes[request.numberOfTypes].msrType, request.msrTypes[request.numberOfTypes].duration); request.numberOfTypes++; } if (requestedBeaconMeasurement == TI_TRUE) { /* build a probe request template and send it to the HAL */ TSetTemplate templateStruct; probeReqTemplate_t probeReqTemplate; TSsid broadcastSSID; templateStruct.ptr = (TI_UINT8 *) &probeReqTemplate; templateStruct.type = PROBE_REQUEST_TEMPLATE; templateStruct.eBand = request.band; templateStruct.uRateMask = RATE_MASK_UNSPECIFIED; broadcastSSID.len = 0; TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Sending probe request template...\n"); buildProbeReqTemplate( pMeasurementMgr->hSiteMgr, &templateStruct, &broadcastSSID, request.band ); #ifdef XCC_MODULE_INCLUDED { /* Insert Radio Mngt Capability IE according XCC4*/ TI_UINT32 len = 0; measurementMgr_radioMngtCapabilityBuild (pMeasurementMgr, templateStruct.ptr + templateStruct.len, (TI_UINT8*)&len); templateStruct.len += len; } #endif TWD_CmdTemplate (pMeasurementMgr->hTWD, &templateStruct, NULL, NULL); } /* Check if the maximum time to wait for the measurement request to */ /* finish has already passed */ timePassed = os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime; if (timePassed > MSR_START_MAX_DELAY) { TRACE2(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Maximum delay to perform measurement operation has passed (%d / %d)\n", MSR_START_MAX_DELAY, (os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime)); pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequestsInParallel, MSR_REJECT_MAX_DELAY_PASSED); return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr); } /* Yalla, start measuring */ TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Finished preparing request. Handing over to MeasurementSRV...\n"); TWD_StartMeasurement (pMeasurementMgr->hTWD, &request, MSR_START_MAX_DELAY - timePassed, NULL, NULL, measurementMgr_MeasurementCompleteCB, pMeasurementMgr); return TI_OK; }