From: lal.harshita Date: Thu, 21 Sep 2023 03:29:52 +0000 (+0530) Subject: [Epic-ID: ODUHIGH-516][Task-ID: 526] Implementation of ric service update Ack and... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=2ba58cd78e409ae234aac627914f954e6aa8b1ff;p=o-du%2Fl2.git [Epic-ID: ODUHIGH-516][Task-ID: 526] Implementation of ric service update Ack and Failure Change-Id: I07fbf87b87324e9188a6d806928c3bfcd434fa73 Signed-off-by: lal.harshita Signed-off-by: pborla --- diff --git a/src/du_app/du_e2ap_msg_hdl.c b/src/du_app/du_e2ap_msg_hdl.c index 49586c523..d7a98bd29 100644 --- a/src/du_app/du_e2ap_msg_hdl.c +++ b/src/du_app/du_e2ap_msg_hdl.c @@ -2968,7 +2968,7 @@ uint8_t BuildAndSendRicServiceUpdate(RicServiceUpdate serviceUpdate) void procRicServiceQuery(E2AP_PDU_t *e2apMsg) { ConfigType action; - uint8_t arrIdx =0, ranFuncIdx=0,tmpIdx=0; + uint16_t arrIdx =0, ranFuncIdx=0,tmpIdx=0; uint16_t id,revisionCcounter; bool tmpArray[MAX_RAN_FUNCTION] = {false}; RICserviceQuery_t *ricServiceQuery=NULL; @@ -3051,6 +3051,7 @@ void procRicServiceQuery(E2AP_PDU_t *e2apMsg) ricUpdate.recvRanFuncList.numOfRanFunToBeAdded++; } } + if(BuildAndSendRicServiceUpdate(ricUpdate)!= ROK) { DU_LOG("\nERROR --> E2AP : Failed to build and send ric service update message"); diff --git a/src/ric_stub/ric_e2ap_msg_hdl.c b/src/ric_stub/ric_e2ap_msg_hdl.c index 5eebc63ac..18b987629 100644 --- a/src/ric_stub/ric_e2ap_msg_hdl.c +++ b/src/ric_stub/ric_e2ap_msg_hdl.c @@ -170,11 +170,11 @@ uint8_t BuildGlobalRicId(GlobalRIC_ID_t *ricId) void FreeE2SetupRsp(E2AP_PDU_t *e2apMsg) { uint8_t arrIdx = 0, e2NodeConfigIdx=0, ranFuncIdx=0; - RANfunctionsID_List_t *ranFuncAddedList; - E2setupResponse_t *e2SetupRsp; - E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItemIe; - E2nodeComponentConfigAdditionAck_List_t *e2NodeConfigAdditionAckList; - E2nodeComponentInterfaceF1_t *f1InterfaceInfo; + RANfunctionsID_List_t *ranFuncAcceptedList=NULL; + E2setupResponse_t *e2SetupRsp=NULL; + E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAddAckItemIe=NULL; + E2nodeComponentConfigAdditionAck_List_t *e2NodeConfigAdditionAckList=NULL; + E2nodeComponentInterfaceF1_t *f1InterfaceInfo=NULL; if(e2apMsg) { @@ -189,17 +189,17 @@ void FreeE2SetupRsp(E2AP_PDU_t *e2apMsg) { case ProtocolIE_IDE2_id_RANfunctionsAccepted: { - ranFuncAddedList= &e2SetupRsp->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; - if(ranFuncAddedList->list.array) + ranFuncAcceptedList= &e2SetupRsp->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(ranFuncAcceptedList->list.array) { - for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) { - if(ranFuncAddedList->list.array[ranFuncIdx]) + if(ranFuncAcceptedList->list.array[ranFuncIdx]) { - RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); + RIC_FREE(ranFuncAcceptedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); } } - RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size); + RIC_FREE(ranFuncAcceptedList->list.array, ranFuncAcceptedList->list.size); } break; } @@ -312,13 +312,13 @@ uint8_t BuildE2nodeComponentConfigAdditionAck(E2nodeComponentConfigAdditionAck_L /******************************************************************* * - * @brief Build RAN function added list + * @brief Build RAN function accepted list * * @details * - * Function : BuildRanFunctionAddedList + * Function : BuildRanFunctionAcceptedList * - * Functionality: Build RAN function added list + * Functionality: Build RAN function accepted list * ->For ProcedureCodeE2_id_E2setup or ProcedureCodeE2_id_RICserviceQuery * we add all the RAN Function list which is present in RIC database. * ->For any other procedures, we just fill the RAN functions whose ID @@ -326,7 +326,7 @@ uint8_t BuildE2nodeComponentConfigAdditionAck(E2nodeComponentConfigAdditionAck_L * * @params[in] * Stored DU databse - * Count of ran functions to be added in the list + * Count of ran functions to be accepted in the list * Received list of RAN functions * RAN Function list * Procedure Code @@ -335,10 +335,10 @@ uint8_t BuildE2nodeComponentConfigAdditionAck(E2nodeComponentConfigAdditionAck_L * RFAILED - failure * ****************************************************************/ -uint8_t BuildRanFunctionAddedList(DuDb *duDb, uint8_t count, RanFunction *ranFunToBeAdded, RANfunctionsID_List_t *ranFuncAddedList, uint8_t procedureCode) +uint8_t BuildRanFunctionAcceptedList(DuDb *duDb, uint8_t count, RanFunction *ranFunAcceptedList, RANfunctionsID_List_t *ranFuncAcceptedList, uint8_t procedureCode) { uint8_t ranFuncIdx = 0; - RANfunctionID_ItemIEs_t *ranFuncAddedItemIe; + RANfunctionID_ItemIEs_t *ranFuncAcceptedItemIe=NULL; /* For ProcedureCodeE2_id_E2setup and ProcedureCodeE2_id_RICserviceQuery, * the number of RAN function list items is equal to the number of @@ -347,37 +347,37 @@ uint8_t BuildRanFunctionAddedList(DuDb *duDb, uint8_t count, RanFunction *ranFun * to the count of ran functions obtained from the function's caller */ if((procedureCode == ProcedureCodeE2_id_RICserviceQuery)||(procedureCode == ProcedureCodeE2_id_E2setup)) - ranFuncAddedList->list.count = duDb->numOfRanFunction; + ranFuncAcceptedList->list.count = duDb->numOfRanFunction; else - ranFuncAddedList->list.count = count; + ranFuncAcceptedList->list.count = count; - ranFuncAddedList->list.size = ranFuncAddedList->list.count*sizeof(RANfunctionID_ItemIEs_t*); - RIC_ALLOC(ranFuncAddedList->list.array, ranFuncAddedList->list.size); - if(ranFuncAddedList->list.array) + ranFuncAcceptedList->list.size = ranFuncAcceptedList->list.count*sizeof(RANfunctionID_ItemIEs_t*); + RIC_ALLOC(ranFuncAcceptedList->list.array, ranFuncAcceptedList->list.size); + if(ranFuncAcceptedList->list.array) { - for(ranFuncIdx = 0; ranFuncIdx< ranFuncAddedList->list.count; ranFuncIdx++) + for(ranFuncIdx = 0; ranFuncIdx< ranFuncAcceptedList->list.count; ranFuncIdx++) { - RIC_ALLOC(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); - if(ranFuncAddedList->list.array[ranFuncIdx] == NULLP) + RIC_ALLOC(ranFuncAcceptedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); + if(ranFuncAcceptedList->list.array[ranFuncIdx] == NULLP) { DU_LOG("\nERROR --> E2AP : Memory allocation for RAN function added list array item"); return RFAILED; } - ranFuncAddedItemIe = (RANfunctionID_ItemIEs_t*)ranFuncAddedList->list.array[ranFuncIdx]; - ranFuncAddedItemIe->id = ProtocolIE_IDE2_id_RANfunctionID_Item; - ranFuncAddedItemIe->criticality= CriticalityE2_ignore; - ranFuncAddedItemIe->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item; + ranFuncAcceptedItemIe = (RANfunctionID_ItemIEs_t*)ranFuncAcceptedList->list.array[ranFuncIdx]; + ranFuncAcceptedItemIe->id = ProtocolIE_IDE2_id_RANfunctionID_Item; + ranFuncAcceptedItemIe->criticality= CriticalityE2_ignore; + ranFuncAcceptedItemIe->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item; if((procedureCode == ProcedureCodeE2_id_RICserviceQuery)||(procedureCode == ProcedureCodeE2_id_E2setup)) { /* filling the RAN function information with the help of DuDb */ - ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = duDb->ranFunction[ranFuncIdx].id; - ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= duDb->ranFunction[ranFuncIdx].revisionCounter; + ranFuncAcceptedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = duDb->ranFunction[ranFuncIdx].id; + ranFuncAcceptedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= duDb->ranFunction[ranFuncIdx].revisionCounter; } else { /* filling the the RAN function information with the help received list of RAN functions */ - ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = ranFunToBeAdded[ranFuncIdx].id; - ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= ranFunToBeAdded[ranFuncIdx].revisionCounter; + ranFuncAcceptedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = ranFunAcceptedList[ranFuncIdx].id; + ranFuncAcceptedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= ranFunAcceptedList[ranFuncIdx].revisionCounter; } } } @@ -498,7 +498,7 @@ uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId) e2SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted; e2SetupRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject; e2SetupRsp->protocolIEs.list.array[idx]->value.present = E2setupResponseIEs__value_PR_RANfunctionsID_List; - if(BuildRanFunctionAddedList(duDb, 0, NULL, &e2SetupRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_E2setup)!=ROK) + if(BuildRanFunctionAcceptedList(duDb, 0, NULL, &e2SetupRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_E2setup)!=ROK) { DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list"); break; @@ -1522,8 +1522,8 @@ uint8_t ProcE2ResetReq(uint32_t duId, ResetRequestE2_t *resetReq) void FreeRicServiceQuery(E2AP_PDU_t *e2apMsg) { uint8_t arrIdx = 0, ranFuncIdx=0; - RANfunctionsID_List_t *ranFuncAddedList; - RICserviceQuery_t *ricServiceQuery; + RANfunctionsID_List_t *ranFuncAcceptedList=NULL; + RICserviceQuery_t *ricServiceQuery=NULL; if(e2apMsg) { @@ -1540,14 +1540,14 @@ void FreeRicServiceQuery(E2AP_PDU_t *e2apMsg) { case ProtocolIE_IDE2_id_RANfunctionsAccepted: { - ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; - if(ranFuncAddedList->list.array) + ranFuncAcceptedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(ranFuncAcceptedList->list.array) { - for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) { - RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); + RIC_FREE(ranFuncAcceptedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); } - RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size); + RIC_FREE(ranFuncAcceptedList->list.array, ranFuncAcceptedList->list.size); } break; } @@ -1658,7 +1658,7 @@ uint8_t BuildAndSendRicServiceQuery(DuDb *duDb) ricServiceQuery->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted; ricServiceQuery->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; ricServiceQuery->protocolIEs.list.array[arrIdx]->value.present = RICserviceQuery_IEs__value_PR_RANfunctionsID_List; - if(BuildRanFunctionAddedList(duDb, 0, NULL, &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_RICserviceQuery)!=ROK) + if(BuildRanFunctionAcceptedList(duDb, 0, NULL, &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_RICserviceQuery)!=ROK) { DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list"); break; @@ -1699,6 +1699,684 @@ uint8_t BuildAndSendRicServiceQuery(DuDb *duDb) return ret; } +/******************************************************************* + * + * @brief deallocate the memory allocated in RicServiceUpdateFailure + * + * @details + * + * Function : FreeRicServiceUpdateFailure + * + * Functionality: deallocate the memory allocated in RicServiceUpdatefailure + * + * @params[in] E2AP_PDU_t *e2apMsg + * + * @return void + * ****************************************************************/ + +void FreeRicServiceUpdateFailure(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx = 0; + RICserviceUpdateFailure_t *ricServiceUpdateFailure=NULL; + + if(e2apMsg) + { + if(e2apMsg->choice.unsuccessfulOutcome) + { + ricServiceUpdateFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICserviceUpdateFailure; + if(ricServiceUpdateFailure->protocolIEs.list.array) + { + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + RIC_FREE(ricServiceUpdateFailure->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdateFailure_IEs_t)); + } + RIC_FREE(ricServiceUpdateFailure->protocolIEs.list.array, ricServiceUpdateFailure->protocolIEs.list.size); + } + RIC_FREE(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t)); + } + RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t)); + } +} + +/******************************************************************* + * + * @brief fill E2 failure cause + * + * @details + * + * Function : fillE2FailureCause + * + * Functionality: fill E2 failure cause + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +void fillE2FailureCause(CauseE2_t *cause, CauseE2_PR causePresent, uint8_t reason) +{ + cause->present = causePresent; + + switch(cause->present) + { + case CauseE2_PR_ricRequest: + cause->choice.ricRequest = reason; + break; + case CauseE2_PR_ricService: + cause->choice.ricService = reason; + break; + case CauseE2_PR_e2Node: + cause->choice.e2Node = reason; + break; + case CauseE2_PR_transport: + cause->choice.transport = reason; + break; + case CauseE2_PR_protocol: + cause->choice.protocol = reason; + break; + case CauseE2_PR_misc: + cause->choice.misc = reason; + break; + default: + cause->choice.misc = CauseE2Misc_unspecified; + break; + } +} + +/******************************************************************* + * + * @brief build and send the ric service update failure + * + * @details + * + * Function : BuildAndSendRicServiceUpdateFailure + * + * Functionality: build and send the ric service update failure + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +uint8_t BuildAndSendRicServiceUpdateFailure(uint32_t duId, int8_t transId, CauseE2_PR causePresent, uint8_t reason) +{ + + E2AP_PDU_t *e2apMsg = NULL; + asn_enc_rval_t encRetVal; + uint8_t ret = RFAILED; + uint8_t arrIdx=0; + uint8_t elementCnt=0; + RICserviceUpdateFailure_t *ricServiceFailure=NULL; + + DU_LOG("\nINFO --> E2AP : Building Ric service update failure\n"); + while(true) + { + RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; + } + e2apMsg->present = E2AP_PDU_PR_unsuccessfulOutcome; + RIC_ALLOC(e2apMsg->choice.unsuccessfulOutcome , sizeof(struct UnsuccessfulOutcomeE2)); + if(e2apMsg->choice.unsuccessfulOutcome == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; + } + + e2apMsg->choice.unsuccessfulOutcome->procedureCode = ProcedureCodeE2_id_RICserviceUpdate; + e2apMsg->choice.unsuccessfulOutcome->criticality = CriticalityE2_reject; + e2apMsg->choice.unsuccessfulOutcome->value.present = UnsuccessfulOutcomeE2__value_PR_RICserviceUpdateFailure; + ricServiceFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICserviceUpdateFailure; + + elementCnt = 3; + ricServiceFailure->protocolIEs.list.count = elementCnt; + ricServiceFailure->protocolIEs.list.size = elementCnt * sizeof(RICserviceUpdateFailure_IEs_t *); + + RIC_ALLOC(ricServiceFailure->protocolIEs.list.array, ricServiceFailure->protocolIEs.list.size); + if(ricServiceFailure->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceFailureIEs failed"); + break; + } + + for(arrIdx=0; arrIdxprotocolIEs.list.array[arrIdx], sizeof(RICserviceUpdateFailure_IEs_t)); + if(ricServiceFailure->protocolIEs.list.array[arrIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceFailureIEs failed"); + break; + } + } + if(arrIdx E2AP : Memory allocation for ricServiceFailureIEs failed"); + break; + } + + /* Trans Id */ + arrIdx = 0; + ricServiceFailure->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; + ricServiceFailure->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceFailure->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdateFailure_IEs__value_PR_TransactionID; + ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; + + arrIdx++; + ricServiceFailure->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_CauseE2; + ricServiceFailure->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceFailure->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdateFailure_IEs__value_PR_CauseE2; + fillE2FailureCause(&ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.CauseE2, causePresent, reason); + + arrIdx++; + ricServiceFailure->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TimeToWaitE2; + ricServiceFailure->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_ignore; + ricServiceFailure->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdateFailure_IEs__value_PR_TimeToWaitE2; + ricServiceFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2 = TimeToWaitE2_v5s; + + 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); + + /* Check encode results */ + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> E2AP : Could not encode RIC service update failure structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC service update Failure\n"); + for(int i=0; i< encBufSize; i++) + { + DU_LOG("%x",encBuf[i]); + } + } + + if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duId) != ROK) + { + DU_LOG("\nERROR --> E2AP : Sending RIC service update failed"); + break; + } + ret = ROK; + break; + } + + FreeRicServiceUpdateFailure(e2apMsg); + return ret; +} + + +/******************************************************************* + * + * @brief deallocate the memory allocated in RicServiceUpdateAck( + * + * @details + * + * Function : FreeRicServiceUpdateAck + * + * Functionality: deallocate the memory allocated in RicServiceUpdateAck + * + * @params[in] E2AP_PDU_t *e2apMsg + * + * @return void + * ****************************************************************/ + +void FreeRicServiceUpdateAck(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx = 0, ranFuncIdx=0; + RANfunctionsID_List_t *acceptedList=NULL; + RICserviceUpdateAcknowledge_t *ricServiceUpdateAck=NULL; + RANfunctionsIDcause_List_t *rejectedList=NULL; + + if(e2apMsg) + { + if(e2apMsg->choice.successfulOutcome) + { + ricServiceUpdateAck = &e2apMsg->choice.successfulOutcome->value.choice.RICserviceUpdateAcknowledge; + if(ricServiceUpdateAck->protocolIEs.list.array) + { + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + if(ricServiceUpdateAck->protocolIEs.list.array[arrIdx]) + { + switch(ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_RANfunctionsAccepted: + { + acceptedList= &ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(acceptedList->list.array) + { + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + { + RIC_FREE(acceptedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); + } + RIC_FREE(acceptedList->list.array, acceptedList->list.size); + } + break; + } + + case ProtocolIE_IDE2_id_RANfunctionsRejected: + { + rejectedList= &ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsIDcause_List; + if(rejectedList->list.array) + { + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + { + RIC_FREE(rejectedList->list.array[ranFuncIdx], sizeof(RANfunctionIDcause_ItemIEs_t)); + } + RIC_FREE(rejectedList->list.array, rejectedList->list.size); + } + break; + } + } + RIC_FREE(ricServiceUpdateAck->protocolIEs.list.array[arrIdx], sizeof(RICserviceUpdateAcknowledge_IEs_t)); + } + } + RIC_FREE(ricServiceUpdateAck->protocolIEs.list.array, ricServiceUpdateAck->protocolIEs.list.size); + } + RIC_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t)); + } + RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t)); + } +} + +/******************************************************************* + * + * @brief Build RAN function rejected list + * + * @details + * + * Function : BuildRanFunctionRejectedList + * + * Functionality: Build RAN function rejected list + * + * @params[in] + * Count of ran functions to be rejected in the list + * Received list of RAN functions + * + * @return ROK - success + * RFAILED - failure + * ****************************************************************/ + +uint8_t BuildRanFunctionRejectedList(uint8_t count, RanFunction *ranFunRejectedList, RANfunctionsIDcause_List_t *ranFuncRejectedList) +{ + uint8_t ranFuncIdx = 0; + RANfunctionIDcause_ItemIEs_t *ranFuncRejectedItemIe=NULL; + + ranFuncRejectedList->list.count = count; + + ranFuncRejectedList->list.size = ranFuncRejectedList->list.count*sizeof(RANfunctionIDcause_ItemIEs_t*); + RIC_ALLOC(ranFuncRejectedList->list.array, ranFuncRejectedList->list.size); + if(ranFuncRejectedList->list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for RAN function rejected list array"); + return RFAILED; + } + + for(ranFuncIdx = 0; ranFuncIdx< ranFuncRejectedList->list.count; ranFuncIdx++) + { + RIC_ALLOC(ranFuncRejectedList->list.array[ranFuncIdx], sizeof(RANfunctionIDcause_ItemIEs_t)); + if(ranFuncRejectedList->list.array[ranFuncIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for RAN function rejected list array item"); + return RFAILED; + } + ranFuncRejectedItemIe = (RANfunctionIDcause_ItemIEs_t*)ranFuncRejectedList->list.array[ranFuncIdx]; + ranFuncRejectedItemIe->id = ProtocolIE_IDE2_id_RANfunctionID_Item; + ranFuncRejectedItemIe->criticality= CriticalityE2_ignore; + ranFuncRejectedItemIe->value.present = RANfunctionIDcause_ItemIEs__value_PR_RANfunctionIDcause_Item; + ranFuncRejectedItemIe->value.choice.RANfunctionIDcause_Item.ranFunctionID = ranFunRejectedList[ranFuncIdx].id; + fillE2FailureCause(&ranFuncRejectedItemIe->value.choice.RANfunctionIDcause_Item.cause, CauseE2_PR_ricService,\ + CauseE2RICservice_ran_function_not_supported); + } + + return ROK; +} + +/******************************************************************* + * + * @brief build and send the ric service update Acknowledge + * + * @details + * + * Function : BuildAndSendRicServiceUpdateAcknowledge + * + * Functionality: build and send the ric service update Acknowledge + * @return ROK - success + * RFAILED - Acknowledge + * + ******************************************************************/ + +uint8_t BuildAndSendRicServiceUpdateAcknowledge(DuDb *duDb, int8_t transId, RicTmpRanFunList ricRanFuncList) +{ + E2AP_PDU_t *e2apMsg = NULL; + asn_enc_rval_t encRetVal; + uint8_t arrIdx=0, elementCnt=0, ret=RFAILED;; + RICserviceUpdateAcknowledge_t *ricServiceUpdateAck=NULL; + + DU_LOG("\nINFO --> E2AP : Building Ric service update Acknowledge\n"); + while(true) + { + RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t)); + if(e2apMsg == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; + } + e2apMsg->present = E2AP_PDU_PR_successfulOutcome; + RIC_ALLOC(e2apMsg->choice.successfulOutcome , sizeof(struct SuccessfulOutcomeE2)); + if(e2apMsg->choice.successfulOutcome == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; + } + + e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_RICserviceUpdate; + e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject; + e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_RICserviceUpdateAcknowledge; + ricServiceUpdateAck = &e2apMsg->choice.successfulOutcome->value.choice.RICserviceUpdateAcknowledge; + + elementCnt = 1; + if(ricRanFuncList.numOfRanFunAccepted) + elementCnt++; + if(ricRanFuncList.numOfRanFuneRejected) + elementCnt++; + + + ricServiceUpdateAck->protocolIEs.list.count = elementCnt; + ricServiceUpdateAck->protocolIEs.list.size = elementCnt * sizeof(RICserviceUpdateAcknowledge_IEs_t*); + + RIC_ALLOC(ricServiceUpdateAck->protocolIEs.list.array, ricServiceUpdateAck->protocolIEs.list.size); + if(ricServiceUpdateAck->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceUpdateAckIEs failed"); + break; + } + + for(arrIdx=0; arrIdxprotocolIEs.list.array[arrIdx], sizeof(RICserviceUpdateAcknowledge_IEs_t)); + if(ricServiceUpdateAck->protocolIEs.list.array[arrIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceUpdateAckIEs failed"); + break; + } + } + if(arrIdx E2AP : Memory allocation for ricServiceUpdateAckIEs failed"); + break; + } + + /* Trans Id */ + arrIdx = 0; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdateAcknowledge_IEs__value_PR_TransactionID; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId; + + if(ricRanFuncList.numOfRanFunAccepted) + { + /* Accepted RAN function List */ + arrIdx++; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdateAcknowledge_IEs__value_PR_RANfunctionsID_List; + if(BuildRanFunctionAcceptedList(duDb, ricRanFuncList.numOfRanFunAccepted, ricRanFuncList.ranFunAcceptedList,\ + &ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_RICserviceUpdate)!=ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list"); + break; + } + } + + if(ricRanFuncList.numOfRanFuneRejected) + { + /* RAN Functions Rejected List */ + arrIdx++; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsRejected; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.present = RICserviceUpdateAcknowledge_IEs__value_PR_RANfunctionsIDcause_List; + if(BuildRanFunctionRejectedList(ricRanFuncList.numOfRanFuneRejected, ricRanFuncList.ranFunRejectedList, \ + &ricServiceUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsIDcause_List)!=ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to build Ran function rejected list"); + break; + } + } + + + 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); + + /* Check encode results */ + if(encRetVal.encoded == ENCODE_FAIL) + { + DU_LOG("\nERROR --> E2AP : Could not encode RIC service update Acknowledge structure (at %s)\n",\ + encRetVal.failed_type ? encRetVal.failed_type->name : "unknown"); + break; + } + else + { + DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC service update Acknowledge\n"); + for(int i=0; i< encBufSize; i++) + { + DU_LOG("%x",encBuf[i]); + } + } + + if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duDb->duId) != ROK) + { + DU_LOG("\nERROR --> E2AP : Sending RIC service update ack failed"); + break; + } + ret =ROK; + break; + } + FreeRicServiceUpdateAck(e2apMsg); + return ret; +} + +/******************************************************************* + * + * @brief process the RIC service update + * + * @details + * + * Function : ProcRicserviceUpdate + * + * Functionality: process the RIC service update + * + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +void ProcRicServiceUpdate(uint32_t duId, RICserviceUpdate_t *ricServiceUpdate) +{ + RicTmpRanFunList ricRanFuncList; + DuDb *duDb = NULLP; + int8_t transId =-1; + uint8_t duIdx = 0, elementCnt =0, arrIdx = 0; + uint16_t ranFuncIdx = 0, failedRanFuncCount=0, recvdRanFuncCount=0; + RANfunction_ItemIEs_t *ranFuncItemIe =NULL; + RANfunction_Item_t *ranFuncItem =NULL; + RANfunctionID_Item_t *ranFuncIdItem=NULL; + RANfunctions_List_t *ranFuncList=NULL; + RANfunctionsID_List_t *deleteList=NULL; + RANfunctionID_ItemIEs_t *delRanFuncItem=NULL; + + SEARCH_DU_DB(duIdx, duId, duDb); + if(duDb == NULLP) + { + DU_LOG("\nERROR --> E2AP : duDb is not present for duId %d",duId); + return; + } + memset(&ricRanFuncList, 0, sizeof(RicTmpRanFunList)); + + if(!ricServiceUpdate) + { + DU_LOG("\nERROR --> E2AP : ricServiceUpdate pointer is null"); + return; + } + + if(!ricServiceUpdate->protocolIEs.list.array) + { + DU_LOG("\nERROR --> E2AP : ricServiceUpdate array pointer is null"); + return; + } + elementCnt = ricServiceUpdate->protocolIEs.list.count; + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + if(!ricServiceUpdate->protocolIEs.list.array[arrIdx]) + { + DU_LOG("\nERROR --> E2AP : ricServiceUpdate array idx %d pointer is null",arrIdx); + return; + } + + switch(ricServiceUpdate->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_TransactionID: + { + transId = ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; + + if(transId < 0 || transId > 255) + { + DU_LOG("\nERROR --> E2AP : Received invalid transId %d",transId); + return; + } + break; + } + + case ProtocolIE_IDE2_id_RANfunctionsAdded: + { + ranFuncList = &ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List; + + if(ranFuncList->list.array) + { + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + { + ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFuncList->list.array[ranFuncIdx]; + ranFuncItem = &ranFuncItemIe->value.choice.RANfunction_Item; + + /* Adding the ran function in temporary list */ + ricRanFuncList.ranFunAcceptedList[ricRanFuncList.numOfRanFunAccepted].id = ranFuncItem->ranFunctionID; + ricRanFuncList.ranFunAcceptedList[ricRanFuncList.numOfRanFunAccepted].revisionCounter = ranFuncItem->ranFunctionRevision; + ricRanFuncList.numOfRanFunAccepted++; + + /* Adding the new ran function in DB*/ + duDb->ranFunction[ranFuncItem->ranFunctionID-1].id = ranFuncItem->ranFunctionID; + duDb->ranFunction[ranFuncItem->ranFunctionID-1].revisionCounter = ranFuncItem->ranFunctionRevision; + duDb->numOfRanFunction++; + + /* Calculating total number of ran fuctions which are received for addition */ + recvdRanFuncCount++; + } + } + break; + } + + case ProtocolIE_IDE2_id_RANfunctionsModified: + { + + ranFuncList = &ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List; + if(ranFuncList->list.array) + { + for(ranFuncIdx = 0; ranFuncIdx< ranFuncList->list.count; ranFuncIdx++) + { + ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFuncList->list.array[ranFuncIdx]; + ranFuncItem = &ranFuncItemIe->value.choice.RANfunction_Item; + if(duDb->ranFunction[ranFuncItem->ranFunctionID-1].id != ranFuncItem->ranFunctionID) + { + /* Calculating total number of ran fuctions which are not present */ + failedRanFuncCount++; + + /* Adding the ran function in temporary list */ + ricRanFuncList.ranFunRejectedList[ricRanFuncList.numOfRanFuneRejected].id = ranFuncItem->ranFunctionID; + ricRanFuncList.numOfRanFuneRejected++; + } + else + { + + /* Adding the ran function in temporary list */ + ricRanFuncList.ranFunAcceptedList[ricRanFuncList.numOfRanFunAccepted].id = ranFuncItem->ranFunctionID; + ricRanFuncList.ranFunAcceptedList[ricRanFuncList.numOfRanFunAccepted].revisionCounter = ranFuncItem->ranFunctionRevision; + ricRanFuncList.numOfRanFunAccepted++; + + /* Updating the new ran function in DB*/ + duDb->ranFunction[ranFuncItem->ranFunctionID-1].revisionCounter = ranFuncItem->ranFunctionRevision; + } + /* Calculating total number of ran fuctions which are received for modification */ + recvdRanFuncCount++; + } + } + break; + } + case ProtocolIE_IDE2_id_RANfunctionsDeleted: + { + + deleteList = &ricServiceUpdate->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(deleteList->list.array) + { + for(ranFuncIdx = 0; ranFuncIdx< deleteList->list.count; ranFuncIdx++) + { + delRanFuncItem = (RANfunctionID_ItemIEs_t*) deleteList->list.array[ranFuncIdx]; + ranFuncIdItem = &delRanFuncItem->value.choice.RANfunctionID_Item; + if(duDb->ranFunction[ranFuncIdItem->ranFunctionID-1].id != ranFuncIdItem->ranFunctionID) + { + /* Calculating total number of ran fuctions which are not present */ + failedRanFuncCount++; + + /* Adding the ran function in temporary list */ + ricRanFuncList.ranFunRejectedList[ricRanFuncList.numOfRanFuneRejected].id = ranFuncItem->ranFunctionID; + ricRanFuncList.numOfRanFuneRejected++; + } + else + { + memset(&duDb->ranFunction[ranFuncIdItem->ranFunctionID-1], 0, sizeof(RanFunction)); + duDb->numOfRanFunction--; + } + + /* Calculating total number of ran fuctions which are received for deletion */ + recvdRanFuncCount++; + } + } + break; + } + + default: + { + DU_LOG("\nERROR --> E2AP : IE [%ld] is not supported",ricServiceUpdate->protocolIEs.list.array[arrIdx]->id); + break; + } + } + } + + /* Sending RIC Service Update Failed if all RAN Functions received fail or if any IE processing fails + * Else sending RIC Service Update Acknowledge */ + if((elementCnt > arrIdx) ||((recvdRanFuncCount > 0) && (recvdRanFuncCount == failedRanFuncCount))) + { + if(BuildAndSendRicServiceUpdateFailure(duDb->duId, transId, CauseE2_PR_misc, CauseE2Misc_unspecified) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to build and send RIC service update Failure"); + return; + } + } + else + { + if(BuildAndSendRicServiceUpdateAcknowledge(duDb, transId, ricRanFuncList) != ROK) + { + DU_LOG("\nERROR --> E2AP : Failed to build and send RIC service update acknowledge"); + return; + } + } +} + + /******************************************************************* * * @brief Handles received E2AP message and sends back response @@ -1797,6 +2475,7 @@ void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf) case InitiatingMessageE2__value_PR_RICserviceUpdate: { DU_LOG("\nINFO --> E2AP : RIC Service update received"); + ProcRicServiceUpdate(*duId, &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate); break; } diff --git a/src/ric_stub/ric_stub.h b/src/ric_stub/ric_stub.h index 0bf9680f0..045282087 100644 --- a/src/ric_stub/ric_stub.h +++ b/src/ric_stub/ric_stub.h @@ -132,12 +132,10 @@ RicGlobalCb ricCb; typedef struct { - uint8_t numOfRanFunToBeAdded; - RanFunction ranFunToBeAdded[MAX_RAN_FUNCTION]; - uint8_t numOfRanFunToBeModified; - RanFunction ranFunToBeModified[MAX_RAN_FUNCTION]; - uint8_t numOfRanFunTodeleted; - RanFunction ranFunToBeDeleted[MAX_RAN_FUNCTION]; + uint8_t numOfRanFunAccepted; + RanFunction ranFunAcceptedList[MAX_RAN_FUNCTION]; + uint8_t numOfRanFuneRejected; + RanFunction ranFunRejectedList[MAX_RAN_FUNCTION]; }RicTmpRanFunList; void readRicCfg();