/** * @brief parses the received Association Response frame * @details * @param[in] pu8Buffer The Association Response frame to be parsed * @param[out] ppstrConnectRespInfo pointer to pointer to the structure containing the parsed Association Response Info * @return Error code indicating success/failure * @note * @author mabubakr * @date 2 Apr 2012 * @version 1.0 */ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, tstrConnectRespInfo **ppstrConnectRespInfo) { s32 s32Error = 0; tstrConnectRespInfo *pstrConnectRespInfo = NULL; u16 u16AssocRespLen = 0; u8 *pu8IEs = NULL; u16 u16IEsLen = 0; pstrConnectRespInfo = kzalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL); if (!pstrConnectRespInfo) return -ENOMEM; /* u16AssocRespLen = pu8Buffer[0]; */ u16AssocRespLen = (u16)u32BufferLen; /* get the status code */ pstrConnectRespInfo->u16ConnectStatus = get_asoc_status(pu8Buffer); if (pstrConnectRespInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE) { /* get the capability */ pstrConnectRespInfo->u16capability = get_assoc_resp_cap_info(pu8Buffer); /* get the Association ID */ pstrConnectRespInfo->u16AssocID = get_asoc_id(pu8Buffer); /* get the Information Elements */ pu8IEs = &pu8Buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); pstrConnectRespInfo->pu8RespIEs = kmemdup(pu8IEs, u16IEsLen, GFP_KERNEL); if (!pstrConnectRespInfo->pu8RespIEs) return -ENOMEM; pstrConnectRespInfo->u16RespIEsLen = u16IEsLen; } *ppstrConnectRespInfo = pstrConnectRespInfo; return s32Error; }
s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, struct connect_resp_info **ret_connect_resp_info) { struct connect_resp_info *connect_resp_info = NULL; u16 assoc_resp_len = 0; u8 *ies = NULL; u16 ies_len = 0; connect_resp_info = kzalloc(sizeof(*connect_resp_info), GFP_KERNEL); if (!connect_resp_info) return -ENOMEM; assoc_resp_len = (u16)buffer_len; connect_resp_info->status = get_asoc_status(buffer); if (connect_resp_info->status == SUCCESSFUL_STATUSCODE) { connect_resp_info->capability = get_assoc_resp_cap_info(buffer); connect_resp_info->assoc_id = get_asoc_id(buffer); ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; ies_len = assoc_resp_len - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); connect_resp_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); if (!connect_resp_info->ies) { kfree(connect_resp_info); return -ENOMEM; } connect_resp_info->ies_len = ies_len; } *ret_connect_resp_info = connect_resp_info; return 0; }