X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fdu_app%2Fdu_e2ap_msg_hdl.c;h=1c8843aa1781665a75948a4ebbee30115d7d1e14;hb=76d2662c441ac10d75d004698ae6ca6a61814d72;hp=a8ea182a387e201f710e60ead57c9e4327fb5283;hpb=bd928523f61aead825b448daee545b8455e8daee;p=o-du%2Fl2.git diff --git a/src/du_app/du_e2ap_msg_hdl.c b/src/du_app/du_e2ap_msg_hdl.c index a8ea182a3..1c8843aa1 100644 --- a/src/du_app/du_e2ap_msg_hdl.c +++ b/src/du_app/du_e2ap_msg_hdl.c @@ -108,6 +108,300 @@ void fillE2Cause(CauseE2_t *e2Cause, E2FailureCause failureCause) } } +/******************************************************************* + * + * @brief Free the ErrorIndication Message + * + * @details + * + * Function : FreeRicIndication + * + * Functionality: Free the ErrorIndication Message + * + * @params[in] + * E2AP_PDU is to freed + * @return void + * + ******************************************************************/ +void FreeErrorIndication(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx = 0; + ErrorIndicationE2_t *errorIndicationMsg= NULLP; + + if(e2apMsg != NULLP) + { + if(e2apMsg->choice.initiatingMessage != NULLP) + { + errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2; + if(errorIndicationMsg!= NULLP) + { + if(errorIndicationMsg->protocolIEs.list.array != NULLP) + { + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + DU_FREE(errorIndicationMsg->protocolIEs.list.array[arrIdx],sizeof(ErrorIndicationE2_t)); + } + DU_FREE(errorIndicationMsg->protocolIEs.list.array,errorIndicationMsg->protocolIEs.list.size); + } + } + DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + } + DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); + } +} + +/******************************************************************* + * + * @brief Builds and Send the ErrorIndication Message + * + * @details + * + * Function : BuildAndSendErrorIndication + * + * Functionality:Fills the ErrorIndication Message + * + * @params[in] + * Trans id + * Ric req id + * Ran function id + * Cause of failure + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +uint8_t BuildAndSendErrorIndication(int8_t transId, RicRequestId requestId, uint16_t ranFuncId, E2FailureCause failureCause) +{ + uint8_t elementCnt =0, arrIdx=0, ret = RFAILED; + E2AP_PDU_t *e2apMsg = NULLP; + ErrorIndicationE2_t *errorIndicationMsg=NULLP; + asn_enc_rval_t encRetVal; /* Encoder return value */ + + while(true) + { + DU_LOG("\nINFO --> E2AP : Building Error Indication Message\n"); + + DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__); + break; + } + + e2apMsg->present = E2AP_PDU_PR_initiatingMessage; + DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + if(e2apMsg->choice.initiatingMessage == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed in %s at line %d",__func__, __LINE__); + break; + } + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_ErrorIndicationE2; + e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_ErrorIndicationE2; + + errorIndicationMsg = &e2apMsg->choice.initiatingMessage->value.choice.ErrorIndicationE2; + + /* Element count is 2 for TransactionID/RICrequestID and Cause. + * If the RAN function id is present, the count will be increased.*/ + elementCnt = 2; + if(ranFuncId>0) + { + elementCnt++; + } + + errorIndicationMsg->protocolIEs.list.count = elementCnt; + errorIndicationMsg->protocolIEs.list.size = elementCnt * sizeof(ErrorIndicationE2_IEs_t*); + + /* Initialize the E2Setup members */ + DU_ALLOC(errorIndicationMsg->protocolIEs.list.array, errorIndicationMsg->protocolIEs.list.size); + if(errorIndicationMsg->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed for array elements in %s at line %d",__func__, __LINE__); + break; + } + + for(arrIdx = 0; arrIdx < elementCnt; (arrIdx)++) + { + DU_ALLOC(errorIndicationMsg->protocolIEs.list.array[arrIdx], sizeof(ErrorIndicationE2_IEs_t)); + if(errorIndicationMsg->protocolIEs.list.array[arrIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed for array [%d] elements in %s at line %d", arrIdx, __func__, __LINE__); + break; + } + } + if(arrIdx < elementCnt) + break; + + arrIdx = 0; + + if(transId >=0 && transId<=255) + { + /* TransactionID */ + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_TransactionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; + } + else + { + /* RICrequestID */ + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RICrequestID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RICrequestID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricRequestorID = requestId.requestorId; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RICrequestID.ricInstanceID = requestId.instanceId; + } + + if(ranFuncId>0) + { + /* RAN Function ID */ + arrIdx++; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_RANfunctionID; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionID = ranFuncId; + } + + /* Cause */ + arrIdx++; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_CauseE2; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_ignore; + errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.present = ErrorIndicationE2_IEs__value_PR_CauseE2; + fillE2Cause(&errorIndicationMsg->protocolIEs.list.array[arrIdx]->value.choice.CauseE2, failureCause); + + /* Prints the Msg formed */ + xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg); + memset(encBuf, 0, ENC_BUF_MAX_LEN); + encBufSize = 0; + encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\ + encBuf); + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> E2AP : Could not encode Error Indication Message (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for Error Indication Message \n"); +#ifdef DEBUG_ASN_PRINT + for(int i=0; i< encBufSize; i++) + { + printf("%x",encBuf[i]); + } +#endif + } + + if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK) + { + DU_LOG("\nINFO --> E2AP : Sending Error Indication Message"); + + } + ret = ROK; + break; + } + FreeErrorIndication(e2apMsg); + return ret; +} + +/****************************************************************** + * + * @brief Deallocation of memory allocated by aper decoder for e2 + * Config Update Failure + * + * @details + * + * Function : freeAperDecodingOfE2Node Config UpdateFailure + * + * Functionality: Deallocation of memory allocated by aper decoder + * for e2 Config Update Failure + * + * @params[in] E2nodeConfigurationUpdateFailure_t to be deallocated + * @return void + * + * ****************************************************************/ + +void freeAperDecodingOfE2NodeConfigUpdateFailure(E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail) +{ + uint8_t arrIdx =0; + + if(e2NodeCfgUpdFail) + { + if(e2NodeCfgUpdFail->protocolIEs.list.array) + { + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + if(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]) + { + free(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]); + } + } + free(e2NodeCfgUpdFail->protocolIEs.list.array); + } + } +} + +/****************************************************************** + * + * @brief Processes E2 Node Config Update Failure sent by RIC + * + * @details + * + * Function : procE2NodeConfigUpdateFailure + * + * Functionality: Processes E2 Node Config Update failure sent by RIC + * + * @params[in] E2AP_PDU_t ASN decoded E2AP message + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void procE2NodeConfigUpdateFailure(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx =0, transId =0, timerValue=0; + E2nodeConfigurationUpdateFailure_t *e2NodeCfgUpdFail=NULL; + + DU_LOG("\nINFO --> E2AP : E2 Node Config Update failure received"); + e2NodeCfgUpdFail = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2nodeConfigurationUpdateFailure; + + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + switch(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + { + transId = e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ + (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) + { + memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); + } + else + { + DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); + } + break; + } + case ProtocolIE_IDE2_id_TimeToWaitE2: + { + timerValue = convertE2WaitTimerEnumToValue(e2NodeCfgUpdFail->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); + if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR)) == FALSE) + { + duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_NODE_CONFIG_UPDATE_TMR, timerValue); + } + else + { + DU_LOG("\nERROR --> E2AP : EVENT_E2_NODE_CONFIG_UPDATE_TMR timer is already running"); + } + break; + } + } + } + + freeAperDecodingOfE2NodeConfigUpdateFailure(e2NodeCfgUpdFail); +} + /******************************************************************* * * @brief Builds Global gNodeB Params @@ -186,39 +480,143 @@ uint8_t BuildGlobalgNBId(GlobalE2node_gNB_ID_t *gNbId) return ret; } -/****************************************************************** +/******************************************************************* * - * @brief Search E2 node component with the help of action type + * @brief fill the E2 node config information * * @details * - * Function : searchE2NodeComponentInfo + * Function : fillE2NodeConfig * - * Functionality: Search E2 node component with the help of action type + * Functionality: fill E2 node config information * - * @params[in] uint8_t componentActionType - * @return CmLList + * @params[in] + * Pointer to e2NodeCfg to be filled + * E2 Node Component information + * Type of configuration + * @return ROK - success + * RFAILED - failure * - * ****************************************************************/ + ******************************************************************/ -CmLList *searchE2NodeComponentInfo(InterfaceType interfaceType, uint8_t componentActionType) +uint8_t fillE2NodeConfig(PTR e2NodeCfg, E2NodeComponent *e2NodeComponentInfo, ConfigType configType) { - E2NodeComponent *e2NodeComponentInfo; - CmLList *node; + E2nodeComponentInterfaceType_t *interfaceType=NULLP; + E2nodeComponentID_t *componentID =NULLP; + E2nodeComponentConfiguration_t *configuration=NULLP; + E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL; + E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL; + E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL; + + switch(configType) + { + case CONFIG_ADD: + { + e2NodeAddItem = (E2nodeComponentConfigAddition_Item_t*)e2NodeCfg; + interfaceType = &e2NodeAddItem->e2nodeComponentInterfaceType; + componentID = &e2NodeAddItem->e2nodeComponentID; + configuration = &e2NodeAddItem->e2nodeComponentConfiguration; + break; + } + case CONFIG_MOD: + { + e2NodeUpdateItem = (E2nodeComponentConfigUpdate_Item_t *) e2NodeCfg; + interfaceType = &e2NodeUpdateItem->e2nodeComponentInterfaceType; + componentID = &e2NodeUpdateItem->e2nodeComponentID; + configuration = &e2NodeUpdateItem->e2nodeComponentConfiguration; + break; + } + case CONFIG_DEL: + { + e2NodeRemovalItem = (E2nodeComponentConfigRemoval_Item_t*) e2NodeCfg; + interfaceType = &e2NodeRemovalItem->e2nodeComponentInterfaceType; + componentID = &e2NodeRemovalItem->e2nodeComponentID; + break; + } + default: + { + DU_LOG("\nERROR --> E2AP : Configuration type %d does not supported ", configType); + return RFAILED; + } + } + /* E2nodeComponentInterfaceType */ + *interfaceType = convertInterfaceToE2ComponentInterfaceType(e2NodeComponentInfo->interfaceType); + + /* We now only support the F1 interface out of these interfaces + * (NG,XN,E1,F1,W1,S1,X2), therefore only the F1 component identifier was filled in. */ + + if(*interfaceType == F1) + { + /* E2 Node Component ID */ + componentID->present = E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1; + DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1,sizeof(E2nodeComponentInterfaceF1_t)); + if(componentID->choice.e2nodeComponentInterfaceTypeF1 == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); + return RFAILED; + } + componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size = sizeof(uint8_t); + DU_ALLOC(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\ + componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); + + if(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); + return RFAILED; + } + memcpy(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, &e2NodeComponentInfo->componentId,\ + componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); + } + + if(configType == CONFIG_DEL) + { + /* We don't need to fill out the E2 Node Component Request and Response + * information in the case of CONFIG_DEL, therefore returning ROK from here. */ + return ROK; + } - if(duCb.e2apDb.e2NodeComponentList.count) + /* E2 Node Component Request Part */ + if(e2NodeComponentInfo->componentRequestPart) { - CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node); - while(node) + configuration->e2nodeComponentRequestPart.size = e2NodeComponentInfo->reqBufSize ; + DU_ALLOC(configuration->e2nodeComponentRequestPart.buf,\ + configuration->e2nodeComponentRequestPart.size); + if(configuration->e2nodeComponentRequestPart.buf == NULLP) { - e2NodeComponentInfo = (E2NodeComponent*)node->node; - if((e2NodeComponentInfo->interfaceType == interfaceType) && (e2NodeComponentInfo->componentActionType == componentActionType)) - break; - else - node = node->next; + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); + return RFAILED; + } + + memcpy(configuration->e2nodeComponentRequestPart.buf,\ + e2NodeComponentInfo->componentRequestPart, configuration->\ + e2nodeComponentRequestPart.size); + } + else + { + DU_LOG("\nERROR --> E2AP: componentRequestPart is null "); + return RFAILED; + } + + /* E2 Node Component Response Part */ + if(e2NodeComponentInfo->componentResponsePart) + { + configuration->e2nodeComponentResponsePart.size = e2NodeComponentInfo->rspBufSize; + DU_ALLOC(configuration->e2nodeComponentResponsePart.buf, configuration->e2nodeComponentResponsePart.size); + if(configuration->e2nodeComponentResponsePart.buf == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at line %d",__func__,__LINE__); + return RFAILED; } + memcpy(configuration->e2nodeComponentResponsePart.buf, e2NodeComponentInfo->componentResponsePart, configuration->\ + e2nodeComponentResponsePart.size); } - return node; + else + { + DU_LOG("\nERROR --> E2AP: componentResponsePart is null"); + return RFAILED; + } + + return ROK; } /******************************************************************* @@ -231,21 +629,36 @@ CmLList *searchE2NodeComponentInfo(InterfaceType interfaceType, uint8_t componen * * Functionality: Building E2 node config addition list * - * @params[in] E2nodeComponentConfigAddition_List_t *e2NodeAddList + * @params[in] + * E2nodeComponentConfigAddition_List_t to be filled + * Procedure Code + * Count of E2 node to be added in the list + * Received list of E2 node configuration + * * @return ROK - success * RFAILED - failure * ******************************************************************/ -uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAddList) +uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAddList, uint8_t procedureCode, uint16_t count, E2NodeConfigItem *e2NodeList) { uint8_t arrIdx = 0; - CmLList *node; - E2NodeComponent *e2NodeComponentInfo; - E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItemIe; - E2nodeComponentConfigAddition_Item_t *e2NodeAddItem; + CmLList *node =NULL; + E2NodeComponent *e2NodeComponentInfo=NULL; + E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItemIe=NULL; + E2nodeComponentConfigAddition_Item_t *e2NodeAddItem=NULL; + + + /* For ProcedureCodeE2_id_E2setup, the number of E2 node configuration list items is + * equal to the number of E2 node configuration entries stored in the database. + * For any other procedure, the E2 node configuration list count is equal + * to the count of E2 node configuration obtained from the function's caller */ + + if(procedureCode == ProcedureCodeE2_id_E2setup) + e2NodeAddList->list.count = duCb.e2apDb.e2NodeComponentList.count; + else + e2NodeAddList->list.count = count; - e2NodeAddList->list.count = 1; e2NodeAddList->list.size = e2NodeAddList->list.count * sizeof(E2nodeComponentConfigAddition_ItemIEs_t *); DU_ALLOC(e2NodeAddList->list.array, e2NodeAddList->list.size); if(e2NodeAddList->list.array == NULLP) @@ -262,93 +675,190 @@ uint8_t BuildE2NodeConfigAddList(E2nodeComponentConfigAddition_List_t *e2NodeAdd DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); return RFAILED; } + + if(procedureCode == ProcedureCodeE2_id_E2setup) + { + /* Getting all of the E2 node configuration's information from DuCb one by one*/ + if(arrIdx == 0) + { + CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node); + } + else + { + node = node->next; + } + if(!node) + { + DU_LOG("\nERROR --> E2AP : E2 node component list node is null"); + return RFAILED; + } + e2NodeComponentInfo = (E2NodeComponent*)node->node; + } + else + { + /* Getting only those E2 node configuration from DuCb whose interface + * and action type is present in the received array */ + e2NodeComponentInfo = fetchE2NodeComponentInfo(e2NodeList[arrIdx].interface, e2NodeList[arrIdx].actionType, &node); + } + + if(!e2NodeComponentInfo) + { + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return RFAILED; + } + + e2NodeAddItemIe = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[arrIdx]; + e2NodeAddItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition_Item; + e2NodeAddItemIe->criticality = CriticalityE2_reject; + e2NodeAddItemIe->value.present = E2nodeComponentConfigAddition_ItemIEs__value_PR_E2nodeComponentConfigAddition_Item; + e2NodeAddItem = &e2NodeAddItemIe->value.choice.E2nodeComponentConfigAddition_Item; + if(fillE2NodeConfig((PTR)e2NodeAddItem, e2NodeComponentInfo, CONFIG_ADD) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); + return RFAILED; + } } - - node = searchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD); - if(!node) + return ROK; +} + +/******************************************************************* + * + * @brief Builds E2 node config update list + * + * @details + * + * Function : BuildE2NodeConfigUpdateList + * + * Functionality: Building E2 node config update list + * + * @params[in] + * E2nodeComponentConfigUpdate_List_t to be filled + * Count of E2 node to be update in the list + * Received list of E2 node configuration + * + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +uint8_t BuildE2NodeConfigUpdateList(E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList, uint16_t count, E2NodeConfigItem *updateE2Node) +{ + uint8_t arrIdx = 0; + CmLList *node =NULL; + E2NodeComponent *e2NodeComponentInfo =NULL; + E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItemIe =NULL; + E2nodeComponentConfigUpdate_Item_t *e2NodeUpdateItem =NULL; + + e2NodeUpdateList->list.count = count; + e2NodeUpdateList->list.size = e2NodeUpdateList->list.count * sizeof(E2nodeComponentConfigUpdate_ItemIEs_t *); + DU_ALLOC(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size); + if(e2NodeUpdateList->list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__); + return RFAILED; + } + + for(arrIdx = 0; arrIdx< e2NodeUpdateList->list.count; arrIdx++) + { + DU_ALLOC(e2NodeUpdateList->list.array[arrIdx], sizeof(E2nodeComponentConfigUpdate_ItemIEs_t)); + if(e2NodeUpdateList->list.array[arrIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigUpdateList %d",__LINE__); + return RFAILED; + } + + e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface, updateE2Node[arrIdx].actionType, &node); + if(!e2NodeComponentInfo) + { + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return RFAILED; + } + + e2NodeUpdateItemIe = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[arrIdx]; + e2NodeUpdateItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate_Item; + e2NodeUpdateItemIe->criticality = CriticalityE2_reject; + e2NodeUpdateItemIe->value.present = E2nodeComponentConfigUpdate_ItemIEs__value_PR_E2nodeComponentConfigUpdate_Item; + e2NodeUpdateItem = &e2NodeUpdateItemIe->value.choice.E2nodeComponentConfigUpdate_Item; + + if(fillE2NodeConfig((PTR)e2NodeUpdateItem, e2NodeComponentInfo, CONFIG_MOD) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); + return RFAILED; + } + + } + return ROK; + +} + + +/******************************************************************* + * + * @brief Builds E2 node config remove list + * + * @details + * + * Function :BuildE2NodeConfigRemoveList + * + * Functionality: Building E2 node config remove list + * + * @params[in] + * E2nodeComponentConfigRemoval_List_t to be filled + * Count of E2 node to be remove in the list + * Received list of E2 node configuration + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +uint8_t BuildE2NodeConfigRemoveList(E2nodeComponentConfigRemoval_List_t *e2NodeRemoveList, uint16_t count, E2NodeConfigItem *updateE2Node) +{ + uint8_t arrIdx = 0; + CmLList *node=NULL; + E2NodeComponent *e2NodeComponentInfo=NULL; + E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItemIe=NULL; + E2nodeComponentConfigRemoval_Item_t *e2NodeRemovalItem=NULL; + + e2NodeRemoveList->list.count = count; + e2NodeRemoveList->list.size = e2NodeRemoveList->list.count * sizeof(E2nodeComponentConfigRemoval_ItemIEs_t *); + DU_ALLOC(e2NodeRemoveList->list.array, e2NodeRemoveList->list.size); + if(e2NodeRemoveList->list.array == NULLP) { - DU_LOG("\nERROR --> E2AP : Received e2NodeComponentInfo is null"); + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__); return RFAILED; } - e2NodeComponentInfo = (E2NodeComponent*)node->node; - - arrIdx = 0; - e2NodeAddItemIe = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[arrIdx]; - e2NodeAddItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition_Item; - e2NodeAddItemIe->criticality = CriticalityE2_reject; - e2NodeAddItemIe->value.present = E2nodeComponentConfigAddition_ItemIEs__value_PR_E2nodeComponentConfigAddition_Item; - e2NodeAddItem = &e2NodeAddItemIe->value.choice.E2nodeComponentConfigAddition_Item; - - /* E2nodeComponentInterfaceType */ - e2NodeAddItem->e2nodeComponentInterfaceType = E2nodeComponentInterfaceType_f1; - /* E2 Node Component Request Part */ - if(e2NodeComponentInfo->componentRequestPart) + for(arrIdx = 0; arrIdx< e2NodeRemoveList->list.count; arrIdx++) { - e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.size = e2NodeComponentInfo->reqBufSize ; - DU_ALLOC(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\ - e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.size); - if(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf == NULLP) + DU_ALLOC(e2NodeRemoveList->list.array[arrIdx], sizeof(E2nodeComponentConfigRemoval_ItemIEs_t)); + if(e2NodeRemoveList->list.array[arrIdx] == NULLP) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); + DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigRemoveList %d",__LINE__); return RFAILED; } - memcpy(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentRequestPart.buf,\ - e2NodeComponentInfo->componentRequestPart, e2NodeAddItem->e2nodeComponentConfiguration.\ - e2nodeComponentRequestPart.size); - } - else - { - DU_LOG("\nERROR --> E2AP: componentRequestPart is null "); - return RFAILED; - } + e2NodeComponentInfo= fetchE2NodeComponentInfo(updateE2Node[arrIdx].interface, updateE2Node[arrIdx].actionType, &node); + if(!e2NodeComponentInfo) + { + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return RFAILED; + } + e2NodeRemovalItemIe = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemoveList->list.array[arrIdx]; + e2NodeRemovalItemIe->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval_Item; + e2NodeRemovalItemIe->criticality = CriticalityE2_reject; + e2NodeRemovalItemIe->value.present = E2nodeComponentConfigRemoval_ItemIEs__value_PR_E2nodeComponentConfigRemoval_Item; + e2NodeRemovalItem = &e2NodeRemovalItemIe->value.choice.E2nodeComponentConfigRemoval_Item; - /* E2 Node Component Response Part */ - if(e2NodeComponentInfo->componentResponsePart) - { - e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.size = e2NodeComponentInfo->rspBufSize; - DU_ALLOC(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf, \ - e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.size); - if(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf == NULLP) + if(fillE2NodeConfig((PTR)e2NodeRemovalItem, e2NodeComponentInfo, CONFIG_DEL) != ROK) { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); + DU_LOG("\nERROR --> E2AP : Failed to fill the E2 node configuration"); return RFAILED; } - memcpy(e2NodeAddItem->e2nodeComponentConfiguration.e2nodeComponentResponsePart.buf, \ - e2NodeComponentInfo->componentResponsePart, e2NodeAddItem->e2nodeComponentConfiguration.\ - e2nodeComponentResponsePart.size); - } - else - { - DU_LOG("\nERROR --> E2AP: componentResponsePart is null"); - return RFAILED; - } - - /* E2 Node Component ID */ - e2NodeAddItem->e2nodeComponentID.present = E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1; - DU_ALLOC(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1,\ - sizeof(E2nodeComponentInterfaceF1_t)); - if(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1 == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); - return RFAILED; - } - e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size = sizeof(uint8_t); - DU_ALLOC(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf,\ - e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); - if(e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf == NULLP) - { - DU_LOG("\nERROR -->list. E2AP: Memory allocation failed for BuildE2NodeConfigAddList %d",__LINE__); - return RFAILED; } - e2NodeAddItem->e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf[arrIdx] = e2NodeComponentInfo->componentId; return ROK; - } - /******************************************************************* * * @brief deallocation of E2SM_KPM_RANfunction_Description_t @@ -1109,7 +1619,7 @@ uint8_t BuildAndSendE2SetupReq() e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition; e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_E2nodeComponentConfigAddition_List; - if(BuildE2NodeConfigAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List))!=ROK) + if(BuildE2NodeConfigAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List), ProcedureCodeE2_id_E2setup, 0, NULL)!=ROK) { DU_LOG("\nERROR --> E2AP : Failed to create E2 Node config list"); break; @@ -1528,13 +2038,13 @@ uint8_t BuildAndSendRicSubscriptionRsp(PendingSubsRspInfo *subsRspInfo) /****************************************************************** * - * @brief Deallocation of memory allocated bu aper decoder for e2 setup response + * @brief Deallocation of memory allocated by aper decoder for e2 setup response * * @details * * Function : freeAperDecodingOfE2SetupRsp * - * Functionality: Deallocation of memory allocated bu aper decoder for e2 + * Functionality: Deallocation of memory allocated by aper decoder for e2 * setup response * * @params[in] E2setupResponse_t *e2SetRspMsg; @@ -1611,13 +2121,16 @@ void freeAperDecodingOfE2SetupRsp(E2setupResponse_t *e2SetRspMsg) * RFAILED - failure * * ****************************************************************/ + uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg) { - uint8_t arrIdx =0, transId=0; + uint8_t arrIdx =0, transId=0, idx=0; uint32_t recvBufLen; - E2setupResponse_t *e2SetRspMsg; - CmLList *node; - E2NodeComponent *e2NodeComponentInfo; + E2setupResponse_t *e2SetRspMsg=NULL; + CmLList *node=NULL; + E2NodeComponent *e2NodeComponentInfo=NULL; + E2nodeComponentConfigAdditionAck_List_t *e2NodeCfgAckList=NULL; + E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItem=NULL; DU_LOG("\nINFO --> E2AP : E2 Setup Response received"); duCb.e2Status = TRUE; //Set E2 status as true @@ -1656,7 +2169,37 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg) } case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck: + { + e2NodeCfgAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List; + for(idx =0; idx list.count; idx++) + { + e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeCfgAckList->list.array[idx]; + switch(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.present) + { + case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1: + { + e2NodeComponentInfo = fetchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD, &node); + if(!e2NodeComponentInfo) + { + DU_LOG("\nERROR --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__); + return RFAILED; + } + else + { + cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node); + DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize); + DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize); + DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent)); + DU_FREE(node, sizeof(CmLList)); + } + break; + } + default: + break; + } + } break; + } default: DU_LOG("\nERROR --> E2AP : Invalid IE received in E2SetupRsp:%ld", @@ -1665,24 +2208,12 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg) } } freeAperDecodingOfE2SetupRsp(e2SetRspMsg); - - node = searchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD); - if(!node) + + if(duSendE2NodeConfigurationUpdate() != ROK) { - DU_LOG("\nERROR --> E2AP : Received e2NodeComponentInfo is null"); + DU_LOG("\nERROR --> E2AP : Failed to send E2 node config update"); return RFAILED; } - else - { - e2NodeComponentInfo = (E2NodeComponent*)node->node; - cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node); - DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize); - DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize); - DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent)); - DU_FREE(node, sizeof(CmLList)); - } - - BuildAndSendE2NodeConfigUpdate(); return ROK; } @@ -2296,41 +2827,40 @@ uint8_t procRicSubscriptionRequest(E2AP_PDU_t *e2apMsg) ranFuncId = ricSubsReq->protocolIEs.list.array[idx]->value.choice.RANfunctionID; /* Validating RAN Function id */ - if(duCb.e2apDb.ranFunction[ranFuncId-1].id == ranFuncId) - { - ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncId-1]; - - if(ranFuncDb->numPendingSubsRsp >= MAX_PENDING_SUBSCRIPTION_RSP) - { - failureCause.causeType = E2_RIC_REQUEST; - failureCause.cause = E2_FUNCTION_RESOURCE_LIMIT; - ret = RFAILED; - break; - } - - DU_ALLOC(ricSubscriptionInfo, sizeof(RicSubscription)); - if(!ricSubscriptionInfo) - { - DU_LOG("\nERROR --> E2AP : Memory allocation failed for ricSubscriptionInfo"); - failureCause.causeType = E2_MISCELLANEOUS; - failureCause.cause = E2_MISCELLANEOUS_CAUSE_UNSPECIFIED; - ret = RFAILED; - break; - } - ricSubscriptionInfo->requestId.requestorId = ricReqId.requestorId; - ricSubscriptionInfo->requestId.instanceId = ricReqId.instanceId; + ranFuncDb = fetchRanFuncFromRanFuncId(ranFuncId); - memset(&ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp], 0, sizeof(PendingSubsRspInfo)); - memcpy(&ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp].requestId, - &ricReqId, sizeof(RicRequestId)); - ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp].ranFuncId = ranFuncId; - } - else + if(!ranFuncDb) { failureCause.causeType = E2_RIC_REQUEST; failureCause.cause = E2_RAN_FUNCTION_ID_INVALID; ret = RFAILED; + break; + } + + if(ranFuncDb->numPendingSubsRsp >= MAX_PENDING_SUBSCRIPTION_RSP) + { + failureCause.causeType = E2_RIC_REQUEST; + failureCause.cause = E2_FUNCTION_RESOURCE_LIMIT; + ret = RFAILED; + break; + } + + DU_ALLOC(ricSubscriptionInfo, sizeof(RicSubscription)); + if(!ricSubscriptionInfo) + { + DU_LOG("\nERROR --> E2AP : Memory allocation failed for ricSubscriptionInfo"); + failureCause.causeType = E2_MISCELLANEOUS; + failureCause.cause = E2_MISCELLANEOUS_CAUSE_UNSPECIFIED; + ret = RFAILED; + break; } + ricSubscriptionInfo->requestId.requestorId = ricReqId.requestorId; + ricSubscriptionInfo->requestId.instanceId = ricReqId.instanceId; + + memset(&ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp], 0, sizeof(PendingSubsRspInfo)); + memcpy(&ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp].requestId, + &ricReqId, sizeof(RicRequestId)); + ranFuncDb->pendingSubsRspInfo[ranFuncDb->numPendingSubsRsp].ranFuncId = ranFuncId; break; } @@ -2856,6 +3386,60 @@ uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo) return ret; } +/******************************************************************* + * + * @brief free e2 node component configuration req and rsp + * + * @details + * + * Function : freeE2NodeComponentConfiguration + * + * Functionality: + * - free e2 node component configuration req and rsp + * + * @params[in] E2nodeComponentConfiguration_t *e2nodeComponentConfiguration + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void freeE2NodeComponentConfiguration(E2nodeComponentConfiguration_t *e2nodeComponentConfiguration) +{ + /* Free E2 Node Component Request Part */ + DU_FREE(e2nodeComponentConfiguration->e2nodeComponentRequestPart.buf, e2nodeComponentConfiguration->e2nodeComponentRequestPart.size); + + /* Free E2 Node Component Response Part */ + DU_FREE(e2nodeComponentConfiguration->e2nodeComponentResponsePart.buf, e2nodeComponentConfiguration->e2nodeComponentResponsePart.size); + +} + +/******************************************************************* + * + * @brief free e2 node component component identifier + * + * @details + * + * Function : freeE2NodeComponentIdentifier + * + * Functionality: + * - free e2 node component component identifier + * + * @params[in] E2nodeComponentID_t *componentID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void freeE2NodeComponentIdentifier(E2nodeComponentID_t *componentID) +{ + if(componentID->choice.e2nodeComponentInterfaceTypeF1) + { + DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf, componentID->choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.size); + DU_FREE(componentID->choice.e2nodeComponentInterfaceTypeF1, sizeof(E2nodeComponentInterfaceF1_t)); + } + +} + /******************************************************************* * * @brief Deallocate the memory allocated for E2nodeConfigurationUpdate msg @@ -2872,10 +3456,17 @@ uint8_t BuildAndSendRicIndication(RicSubscription *ricSubscriptionInfo) * RFAILED - failure * * ****************************************************************/ + void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg) { - uint8_t arrIdx =0; - E2nodeConfigurationUpdate_t *e2NodeConfigUpdate; + uint8_t arrIdx =0, e2NodeUpdateListIdx=0, e2NodeRemovalListIdx=0, e2NodeAddListIdx=0; + E2nodeConfigurationUpdate_t *e2NodeConfigUpdate =NULL; + E2nodeComponentConfigUpdate_List_t *e2NodeUpdateList =NULL; + E2nodeComponentConfigUpdate_ItemIEs_t *e2NodeUpdateItem =NULL; + E2nodeComponentConfigRemoval_List_t *e2NodeRemovalList =NULL; + E2nodeComponentConfigRemoval_ItemIEs_t *e2NodeRemovalItem =NULL; + E2nodeComponentConfigAddition_List_t *e2NodeAddList =NULL; + E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem =NULL; if(e2apMsg != NULLP) { @@ -2886,7 +3477,70 @@ void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg) { for(arrIdx = 0; arrIdx < e2NodeConfigUpdate->protocolIEs.list.count; arrIdx++) { - DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t)); + if(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]) + { + + switch(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + break; + + case ProtocolIE_IDE2_id_E2nodeComponentConfigAddition: + { + e2NodeAddList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List; + if(e2NodeAddList->list.array) + { + for(e2NodeAddListIdx = 0; e2NodeAddListIdx< e2NodeAddList->list.count; e2NodeAddListIdx++) + { + e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx]; + + freeE2NodeComponentConfiguration(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentConfiguration); + freeE2NodeComponentIdentifier(&e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID); + DU_FREE(e2NodeAddItem, sizeof(E2nodeComponentConfigAddition_ItemIEs_t)); + } + DU_FREE(e2NodeAddList->list.array, e2NodeAddList->list.size); + } + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate: + { + e2NodeUpdateList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List; + if(e2NodeUpdateList->list.array) + { + for(e2NodeUpdateListIdx = 0; e2NodeUpdateListIdx< e2NodeUpdateList->list.count; e2NodeUpdateListIdx++) + { + e2NodeUpdateItem = (E2nodeComponentConfigUpdate_ItemIEs_t *) e2NodeUpdateList->list.array[e2NodeUpdateListIdx]; + + freeE2NodeComponentConfiguration(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentConfiguration); + freeE2NodeComponentIdentifier(&e2NodeUpdateItem->value.choice.E2nodeComponentConfigUpdate_Item.e2nodeComponentID); + DU_FREE(e2NodeUpdateItem, sizeof(E2nodeComponentConfigUpdate_ItemIEs_t)); + } + DU_FREE(e2NodeUpdateList->list.array, e2NodeUpdateList->list.size); + } + break; + } + case ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval: + { + e2NodeRemovalList = &e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List; + if(e2NodeRemovalList->list.array) + { + for(e2NodeRemovalListIdx = 0; e2NodeRemovalListIdx< e2NodeRemovalList->list.count; e2NodeRemovalListIdx++) + { + e2NodeRemovalItem = (E2nodeComponentConfigRemoval_ItemIEs_t *) e2NodeRemovalList->list.array[e2NodeRemovalListIdx]; + + freeE2NodeComponentIdentifier(&e2NodeRemovalItem->value.choice.E2nodeComponentConfigRemoval_Item.e2nodeComponentID); + DU_FREE(e2NodeRemovalItem, sizeof(E2nodeComponentConfigRemoval_ItemIEs_t)); + } + DU_FREE(e2NodeRemovalList->list.array, e2NodeRemovalList->list.size); + } + break; + } + + default: + break; + } + DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdate_IEs_t)); + } } DU_FREE(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size); } @@ -2913,13 +3567,13 @@ void FreeE2NodeConfigUpdate(E2AP_PDU_t *e2apMsg) * * ****************************************************************/ -uint8_t BuildAndSendE2NodeConfigUpdate() +uint8_t BuildAndSendE2NodeConfigUpdate(E2NodeConfigList *e2NodeList) { - uint8_t arrIdx = 0,elementCnt = 1; - uint8_t ret = ROK; - E2AP_PDU_t *e2apMsg = NULLP; - E2nodeConfigurationUpdate_t *e2NodeConfigUpdate = NULLP; + uint8_t ret = RFAILED; + uint8_t arrIdx = 0,elementCnt = 0, transId=0; + E2AP_PDU_t *e2apMsg = NULLP; asn_enc_rval_t encRetVal; /* Encoder return value */ + E2nodeConfigurationUpdate_t *e2NodeConfigUpdate = NULLP; DU_LOG("\nINFO --> E2AP : Building E2 Node config update\n"); do @@ -2930,25 +3584,31 @@ uint8_t BuildAndSendE2NodeConfigUpdate() DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); break; } + e2apMsg->present = E2AP_PDU_PR_initiatingMessage; DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); if(e2apMsg->choice.initiatingMessage == NULLP) { DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); - DU_FREE(e2apMsg, sizeof(E2AP_PDU_t)); - return RFAILED; + break; } e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2nodeConfigurationUpdate; e2apMsg->choice.initiatingMessage->value.present = \ InitiatingMessageE2__value_PR_E2nodeConfigurationUpdate; e2NodeConfigUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2nodeConfigurationUpdate; + + elementCnt =1; + if(e2NodeList->addE2NodeCount) + elementCnt++; + if(e2NodeList->updateE2NodeCount) + elementCnt++; + if(e2NodeList->removeE2NodeCount) + elementCnt++; e2NodeConfigUpdate->protocolIEs.list.count = elementCnt; e2NodeConfigUpdate->protocolIEs.list.size = elementCnt * sizeof(E2nodeConfigurationUpdate_IEs_t*); - /* Initialize the Ric Indication members */ - DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array, \ - e2NodeConfigUpdate->protocolIEs.list.size); + DU_ALLOC(e2NodeConfigUpdate->protocolIEs.list.array, e2NodeConfigUpdate->protocolIEs.list.size); if(e2NodeConfigUpdate->protocolIEs.list.array == NULLP) { DU_LOG("\nERROR --> E2AP : Memory allocation for e2NodeConfigUpdate failed"); @@ -2965,22 +3625,67 @@ uint8_t BuildAndSendE2NodeConfigUpdate() break; } } + + if(arrIdxprotocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_TransactionID; - e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = TRANS_ID; + transId = assignTransactionId(); + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; + + if(e2NodeList->addE2NodeCount) + { + arrIdx++; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAddition; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigAddition_List; + if(BuildE2NodeConfigAddList(&(e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAddition_List),\ + ProcedureCodeE2_id_E2nodeConfigurationUpdate, e2NodeList->addE2NodeCount, e2NodeList->addE2Node)!=ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to create E2 Node config list"); + break; + } + } + + if(e2NodeList->updateE2NodeCount) + { + arrIdx++; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdate; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigUpdate_List; + if(BuildE2NodeConfigUpdateList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdate_List,\ + e2NodeList->updateE2NodeCount, e2NodeList->updateE2Node) != ROK) + { + + DU_LOG("\nERROR --> E2AP : Failed to update the E2 node configuration"); + break; + } + } + + if(e2NodeList->removeE2NodeCount) + { + arrIdx++; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemoval; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdate_IEs__value_PR_E2nodeComponentConfigRemoval_List; + if(BuildE2NodeConfigRemoveList(&e2NodeConfigUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemoval_List,\ + e2NodeList->removeE2NodeCount, e2NodeList->removeE2Node) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to remove the E2 node configuration"); + break; + } + } /* Prints the Msg formed */ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg); memset(encBuf, 0, ENC_BUF_MAX_LEN); encBufSize = 0; - encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\ - encBuf); + encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf); if(encRetVal.encoded == ENCODE_FAIL) { DU_LOG("\nERROR --> E2AP : Could not encode E2nodeConfigurationUpdate structure (at %s)\n",\ @@ -3000,9 +3705,13 @@ uint8_t BuildAndSendE2NodeConfigUpdate() if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize)) { DU_LOG("\nERROR --> E2AP : Sending E2 node config update failed"); - return RFAILED; + break; } + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + memcpy(&duCb.e2apDb.e2TimersInfo.e2Timers.e2NodeConfigUpdate.configList, e2NodeList, sizeof(E2NodeConfigList)); + ret = ROK; break; }while(true); @@ -3286,13 +3995,13 @@ uint8_t procResetResponse(E2AP_PDU_t *e2apMsg) /****************************************************************** * - * @brief Deallocation of memory allocated bu aper decoder for e2 setup Failure + * @brief Deallocation of memory allocated by aper decoder for e2 setup Failure * * @details * * Function : freeAperDecodingOfE2SetupFailure * - * Functionality: Deallocation of memory allocated bu aper decoder for e2 + * Functionality: Deallocation of memory allocated by aper decoder for e2 * setup Failure * * @params[in] E2setupFailure_t *e2SetupFailure; @@ -3362,7 +4071,7 @@ void procE2SetupFailure(E2AP_PDU_t *e2apMsg) } case ProtocolIE_IDE2_id_TimeToWaitE2: { - timerValue = covertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); + timerValue = convertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR)) == FALSE) { duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR, timerValue); @@ -3381,13 +4090,13 @@ void procE2SetupFailure(E2AP_PDU_t *e2apMsg) } /****************************************************************** * - * @brief Deallocation of memory allocated bu aper decoder for RIC service Query + * @brief Deallocation of memory allocated by aper decoder for RIC service Query * * @details * * Function : freeAperDecodingOfRicServiceQuery * - * Functionality: Deallocation of memory allocated bu aper decoder for RIC + * Functionality: Deallocation of memory allocated by aper decoder for RIC * service Query * * @params[in] RICserviceQuery_t *ricServiceQuery; @@ -4084,7 +4793,7 @@ void procRicServiceUpdateFailure(E2AP_PDU_t *e2apMsg) } case ProtocolIE_IDE2_id_TimeToWaitE2: { - timerValue = covertE2WaitTimerEnumToValue(ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); + timerValue = convertE2WaitTimerEnumToValue(ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR)) == FALSE) { duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer), EVENT_RIC_SERVICE_UPDATE_TMR, timerValue); @@ -4106,6 +4815,71 @@ void procRicServiceUpdateFailure(E2AP_PDU_t *e2apMsg) freeAperDecodingOfRicServiceUpdateFailure(ricServiceFailure); } +/****************************************************************** + * + * @brief DU Send E2 Node Configuration Update + * + * @details + * + * Function : duSendE2NodeConfigurationUpdate + * + * Functionality: DU Send E2 Node Configuration Update + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t duSendE2NodeConfigurationUpdate() +{ + E2NodeConfigList e2NodeList; + CmLList *node =NULL; + E2NodeComponent *e2NodeComponentInfo=NULL; + + memset(&e2NodeList, 0, sizeof(E2NodeConfigList)); + CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, node); + while(node) + { + e2NodeComponentInfo = (E2NodeComponent*)node->node; + + if(e2NodeComponentInfo->componentRequestPart && e2NodeComponentInfo->componentResponsePart) + { + switch(e2NodeComponentInfo->componentActionType) + { + case E2_NODE_COMPONENT_ADD: + { + e2NodeList.addE2Node[e2NodeList.addE2NodeCount].interface = e2NodeComponentInfo->interfaceType; + e2NodeList.addE2Node[e2NodeList.addE2NodeCount].actionType = e2NodeComponentInfo->componentActionType; + e2NodeList.removeE2NodeCount++; + break; + } + case E2_NODE_COMPONENT_UPDATE: + { + e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].interface = e2NodeComponentInfo->interfaceType; + e2NodeList.updateE2Node[e2NodeList.updateE2NodeCount].actionType = e2NodeComponentInfo->componentActionType; + e2NodeList.updateE2NodeCount++; + break; + + } + case E2_NODE_COMPONENT_DEL: + { + e2NodeList.removeE2Node[e2NodeList.removeE2NodeCount].interface = e2NodeComponentInfo->interfaceType; + e2NodeList.removeE2Node[e2NodeList.removeE2NodeCount].actionType = e2NodeComponentInfo->componentActionType; + e2NodeList.removeE2NodeCount++; + break; + } + } + } + node = node->next; + } + + if(BuildAndSendE2NodeConfigUpdate(&e2NodeList) !=ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to build and send e2 node config update message to RIC_stub"); + return RFAILED; + } + return ROK; +} /******************************************************************* * * @brief Handles received E2AP message and sends back response @@ -4185,6 +4959,16 @@ void E2APMsgHdlr(Buffer *mBuf) procE2SetupFailure(e2apMsg); break; } + case UnsuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateFailure: + { + procE2NodeConfigUpdateFailure(e2apMsg); + break; + } + case UnsuccessfulOutcomeE2__value_PR_RICserviceUpdateFailure: + { + procRicServiceUpdateFailure(e2apMsg); + break; + } default: { DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_unsuccessfulOutcome [%d]",\ @@ -4248,6 +5032,11 @@ void E2APMsgHdlr(Buffer *mBuf) procRicServiceQuery(e2apMsg); break; } + case InitiatingMessageE2__value_PR_ErrorIndicationE2: + { + DU_LOG("\nINFO --> E2AP : Error indication received"); + break; + } default: { DU_LOG("\nERROR --> E2AP : Invalid type of E2AP_PDU_PR_initiatingMessage [%d]",\