/** * * mainSec_config * * \b Description: * * Init main security state machine state machine * * \b ARGS: * * none * * \b RETURNS: * * TI_OK on success, TI_NOK otherwise. * * \sa */ TI_STATUS mainSec_unload(mainSec_t *pMainSec) { TI_STATUS status; if (pMainSec == NULL) { return TI_NOK; } status = mainKeys_unload(pMainSec->pMainKeys); if (status != TI_OK) { /* report failure but don't stop... */ TRACE0(pMainSec->hReport, REPORT_SEVERITY_ERROR, "MAIN_SEC_SM: Error releasing Main Keys SM memory \n"); } status = fsm_Unload(pMainSec->hOs, pMainSec->pMainSecSm); if (status != TI_OK) { /* report failure but don't stop... */ TRACE0(pMainSec->hReport, REPORT_SEVERITY_ERROR, "MAIN_SEC_SM: Error releasing FSM memory \n"); } status = externalSec_Destroy (pMainSec->pExternalSec); if (status != TI_OK) { /* report failure but don't stop... */ TRACE0(pMainSec->hReport, REPORT_SEVERITY_ERROR, "MAIN_SEC_SM: Error releasing External Security SM memory \n"); } os_memoryFree(pMainSec->hOs, pMainSec, sizeof(mainSec_t)); return TI_OK; }
/** * * mainSec_config * * \b Description: * * Init main security state machine state machine * * \b ARGS: * * none * * \b RETURNS: * * OK on success, NOK otherwise. * * \sa */ TI_STATUS mainSec_unload(mainSec_t *pMainSec) { TI_STATUS status; if (pMainSec == NULL) { return NOK; } status = mainKeys_unload(pMainSec->pMainKeys); if (status != OK) { /* report failure but don't stop... */ WLAN_REPORT_ERROR(pMainSec->hReport, RSN_MODULE_LOG, ("MAIN_SEC_SM: Error releasing Main Keys SM memory \n")); } status = fsm_Unload(pMainSec->hOs, pMainSec->pMainSecSm); if (status != OK) { /* report failure but don't stop... */ WLAN_REPORT_ERROR(pMainSec->hReport, RSN_MODULE_LOG, ("MAIN_SEC_SM: Error releasing FSM memory \n")); } os_memoryFree(pMainSec->hOs, pMainSec, sizeof(mainSec_t)); return OK; }
/** * * mainSec_create * * \b Description: * * Allocate memory for the main security context, and create all the rest of the needed contexts. * * \b ARGS: * * I - hOs - OS handle for OS operations. * * \b RETURNS: * * pointer to main security context. If failed, returns NULL. * * \sa */ mainSec_t* mainSec_create(TI_HANDLE hOs) { mainSec_t *pHandle; TI_STATUS status; /* allocate association context memory */ pHandle = (mainSec_t*)os_memoryAlloc(hOs, sizeof(mainSec_t)); if (pHandle == NULL) { return NULL; } os_memoryZero(hOs, pHandle, sizeof(mainSec_t)); /* allocate memory for association state machine */ status = fsm_Create(hOs, &pHandle->pMainSecSm, MAIN_SEC_MAX_NUM_STATES, MAIN_SEC_MAX_NUM_EVENTS); if (status != TI_OK) { os_memoryFree(hOs, pHandle, sizeof(mainSec_t)); return NULL; } pHandle->pMainKeys = mainKeys_create(hOs); if (pHandle->pMainKeys == NULL) { fsm_Unload(hOs, pHandle->pMainSecSm); os_memoryFree(hOs, pHandle, sizeof(mainSec_t)); return NULL; } pHandle->pKeyParser = pHandle->pMainKeys->pKeyParser; pHandle->hOs = hOs; /* created only for external security mode */ pHandle->pExternalSec = externalSec_create(hOs); if (pHandle->pExternalSec == NULL) { fsm_Unload(hOs, pHandle->pMainSecSm); mainKeys_unload(pHandle->pMainKeys); os_memoryFree(hOs, pHandle, sizeof(mainSec_t)); return NULL; } return pHandle; }
/** * * mainSec_config * * \b Description: * * Init main security state machine state machine * * \b ARGS: * * none * * \b RETURNS: * * TI_OK on success, TI_NOK otherwise. * * \sa */ TI_STATUS mainSec_unload(mainSec_t *pMainSec) { TI_STATUS status; if (pMainSec == NULL) { return TI_NOK; } status = mainKeys_unload(pMainSec->pMainKeys); status = fsm_Unload(pMainSec->hOs, pMainSec->pMainSecSm); status = externalSec_Destroy (pMainSec->pExternalSec); os_memoryFree(pMainSec->hOs, pMainSec, sizeof(mainSec_t)); return TI_OK; }