From: pborla Date: Fri, 8 Sep 2023 08:54:57 +0000 (+0530) Subject: [Epic-ID: ODUHIGH-516][Task-ID: 526] Implementation of ric service query X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=cff10ba79a0f18dcf3aa6675a11b56e8d7ffb6b8;p=o-du%2Fl2.git [Epic-ID: ODUHIGH-516][Task-ID: 526] Implementation of ric service query Change-Id: I039a85ec83c91b3f1e0a3f042a5e4d6f883d698a Signed-off-by: pborla Signed-off-by: lal.harshita Signed-off-by: pborla --- diff --git a/src/du_app/du_cfg.c b/src/du_app/du_cfg.c index 780172611..872a42653 100644 --- a/src/du_app/du_cfg.c +++ b/src/du_app/du_cfg.c @@ -709,7 +709,7 @@ uint8_t readCfg() duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.formatType = REPORT_ACTION_FORMAT_TYPE; memcpy(duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.name, ric_report_style_name, sizeof(ric_report_style_name)); - for(measurementInfoIdx =0; measurementInfoIdxlist.count = duCb.e2apDb.numOfRanFunction; - ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*); - DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size); - if(ranFunctionsList->list.array == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); - return RFAILED; - } - - for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++) + + while(true) { - DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); - if(ranFunctionsList->list.array[ranFuncIdx] == NULLP) - { - DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); - return RFAILED; - } - - ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx]; - ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item; - ranFuncItemIe->criticality = CriticalityE2_ignore; - ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item; - ranFuncItem = &ranFuncItemIe->value.choice.RANfunction_Item; - ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx]; /* RAN function Id*/ ranFuncItem->ranFunctionID = ranFuncDb->id; - + /* RAN Function Revision*/ ranFuncItem->ranFunctionRevision = ranFuncDb->revisionCounter; - + /* RAN function OID*/ ranFuncItem->ranFunctionOID.size = strlen(ranFuncDb->name.serviceModelOID); DU_ALLOC(ranFuncItem->ranFunctionOID.buf, ranFuncItem->ranFunctionOID.size); if(!ranFuncItem->ranFunctionOID.buf) { DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + break; } memcpy(ranFuncItem->ranFunctionOID.buf, ranFuncDb->name.serviceModelOID, ranFuncItem->ranFunctionOID.size); @@ -627,54 +605,54 @@ uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList) if(!ranFuncDefinition) { DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + break; } - + /* RAN function Name */ ranFuncName = &ranFuncDefinition->ranFunction_Name; - + /* RAN function ShortName */ ranFuncName->ranFunction_ShortName.size = strlen(ranFuncDb->name.shortName); DU_ALLOC(ranFuncName->ranFunction_ShortName.buf, ranFuncName->ranFunction_ShortName.size); if(!ranFuncName->ranFunction_ShortName.buf) { DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + break; } memcpy(ranFuncName->ranFunction_ShortName.buf, ranFuncDb->name.shortName, strlen(ranFuncDb->name.shortName)); - + /* RAN function E2SM_OID */ ranFuncName->ranFunction_E2SM_OID.size = strlen(ranFuncDb->name.serviceModelOID); DU_ALLOC(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size); if(!ranFuncName->ranFunction_E2SM_OID.buf) { DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + break; } memcpy(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncDb->name.serviceModelOID, ranFuncName->ranFunction_E2SM_OID.size); - /* RAN function Description */ + /* RAN Function Name Description */ ranFuncName->ranFunction_Description.size = strlen(ranFuncDb->name.description); DU_ALLOC(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size); if(!ranFuncName->ranFunction_Description.buf) { DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + break; } memcpy(ranFuncName->ranFunction_Description.buf, ranFuncDb->name.description, ranFuncName->ranFunction_Description.size); - + /* RIC Event Trigger Style List */ DU_ALLOC(ranFuncDefinition->ric_EventTriggerStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List)); if(!ranFuncDefinition->ric_EventTriggerStyle_List) { DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + break; } - + if(fillRicEventTriggerStyle(ranFuncDb, ranFuncDefinition->ric_EventTriggerStyle_List)!=ROK) { DU_LOG("\nERROR --> E2AP: failed to fill ric event trigger style"); - return RFAILED; + break; } /* RIC Report Style List */ @@ -682,12 +660,12 @@ uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList) if(!ranFuncDefinition->ric_ReportStyle_List) { DU_LOG("\nERROR --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__); - return RFAILED; + break; } if(fillRicReportStyle(ranFuncDb, ranFuncDefinition->ric_ReportStyle_List) != ROK) { DU_LOG("\nERROR --> E2AP: failed to fill ric report style"); - return RFAILED; + break; } /* Encode the F1SetupRequest type as APER */ @@ -711,20 +689,101 @@ uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList) { printf("%x",encBuf[measIeIdx]); } - + ranFunctionDefinition = &ranFuncItem->ranFunctionDefinition; + ranFunctionDefinition->size = encBufSize; + DU_ALLOC(ranFunctionDefinition->buf, encBufSize); + if(ranFunctionDefinition->buf == NULLP) + { + DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer"); + break; + } + memcpy(ranFunctionDefinition->buf, &encBuf, encBufSize); + ret = ROK; + break; } - ranFuncItem->ranFunctionDefinition.size = encBufSize; - DU_ALLOC(ranFuncItem->ranFunctionDefinition.buf, encBufSize); - if(ranFuncItem->ranFunctionDefinition.buf == NULLP) + } + freeE2smKpmRanFunctionDefinition(ranFuncDefinition); + return ret; +} + +/******************************************************************* + * + * @brief Builds Ran function add list based on the procedure code + * + * @details + * + * Function : BuildRanFunctionAddList + * + * Functionality: Building RAN addition addition list + * In case of ProcedureCodeE2_id_E2setup we add all the RAN Function list + * which is present in E2 database. + * In the case of other procedures, we just fill the RAN functions whose ID + * is contained in recvList + * + * @params[in] + * RAN Function list + * Procedure code + * Count of ran functions to be added in the list + * Received list of RAN functions + * + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ + +uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList, uint8_t procedureCode, uint8_t count, uint8_t *recvList) +{ + uint16_t id; + RanFunction *ranFuncDb; + uint8_t ranFuncIdx; + RANfunction_ItemIEs_t *ranFuncItemIe; + + /* For ProcedureCodeE2_id_E2setup, the number of RAN function list items is + * equal to the number of ran function entries stored in the database. + * For any other procedure, the RAN function list count is equal + * to the count of ran functions obtained from the function's caller */ + + if(procedureCode == ProcedureCodeE2_id_E2setup) + ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction; + else + ranFunctionsList->list.count = count; + + ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*); + DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size); + if(ranFunctionsList->list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); + return RFAILED; + } + + for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++) + { + DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); + if(ranFunctionsList->list.array[ranFuncIdx] == NULLP) { - DU_LOG("\nERROR --> F1AP : Memory allocation failed for RAN function definition buffer"); + DU_LOG("\nERROR --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__); return RFAILED; } - memcpy(ranFuncItem->ranFunctionDefinition.buf, &encBuf, encBufSize); + if(procedureCode == ProcedureCodeE2_id_E2setup) + { + /* Getting all of the RAN function's information from DuCb one by one*/ + ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx]; + } + else + { + /* Getting only the RAN function information from DuCb whose Id is + * present in the received array */ + id =recvList[ranFuncIdx]; + ranFuncDb = &duCb.e2apDb.ranFunction[id-1]; + } + ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx]; + ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item; + ranFuncItemIe->criticality = CriticalityE2_ignore; + ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item; + BuildRanFunctionItem(&ranFuncItemIe->value.choice.RANfunction_Item, ranFuncDb); } - freeE2smKpmRanFunctionDefinition(ranFuncDefinition); return ROK; -} +} /******************************************************************* * @@ -977,7 +1036,7 @@ uint8_t BuildAndSendE2SetupReq() e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded; e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_RANfunctions_List; - if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List))!=ROK) + if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List), ProcedureCodeE2_id_E2setup, 0, NULL)!=ROK) { DU_LOG("\nERROR --> E2AP : Failed to create RAN Function"); break; @@ -1026,8 +1085,8 @@ uint8_t BuildAndSendE2SetupReq() break; }while(true); - duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId; - duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; FreeE2SetupReq(e2apMsg); return ret; @@ -1508,9 +1567,11 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg) case ProtocolIE_IDE2_id_TransactionID: { transId = e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; - if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\ - (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode)) - memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo)); + if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\ + (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode)) + { + memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); + } else { DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); @@ -2296,8 +2357,8 @@ uint8_t BuildAndSendE2ResetRequest(E2CauseType failureType, E2Cause failureCause /* In case the message is sent successfully, store the transaction info to * be used when response is received */ - duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId; - duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId; + duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode; ret = ROK; break; @@ -2380,9 +2441,11 @@ uint8_t procResetResponse(E2AP_PDU_t *e2apMsg) { case ProtocolIE_IDE2_id_TransactionID: transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID; - if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) && \ - (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode)) - memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo)); + if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \ + (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode)) + { + memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo)); + } else { DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId); @@ -2473,9 +2536,11 @@ void procE2SetupFailure(E2AP_PDU_t *e2apMsg) case ProtocolIE_IDE2_id_TransactionID: { transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID; - if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\ - (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode)) - memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo)); + 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); @@ -2486,9 +2551,9 @@ void procE2SetupFailure(E2AP_PDU_t *e2apMsg) case ProtocolIE_IDE2_id_TimeToWaitE2: { timerValue = covertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2); - if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR)) == FALSE) + if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR)) == FALSE) { - duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR, timerValue); + duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR, timerValue); } else { diff --git a/src/du_app/du_tmr.c b/src/du_app/du_tmr.c index 3d89d9857..28663d842 100644 --- a/src/du_app/du_tmr.c +++ b/src/du_app/du_tmr.c @@ -47,7 +47,7 @@ bool duChkTmr(PTR cb, int16_t tmrEvnt) { case EVENT_E2_SETUP_TMR: { - if(((E2apDb *)cb)->e2TimersInfo.e2Timers.e2SetupTimer.tmrEvnt == EVENT_E2_SETUP_TMR) + if(((CmTimer *)cb)->tmrEvnt == EVENT_E2_SETUP_TMR) { DU_LOG("\nERROR --> DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt); return TRUE; @@ -75,7 +75,6 @@ bool duChkTmr(PTR cb, int16_t tmrEvnt) void duStartTmr(PTR cb, int16_t tmrEvnt, uint8_t timerValue) { - E2apDb *e2apDb; CmTmrArg arg; arg.wait = 0; @@ -83,10 +82,11 @@ void duStartTmr(PTR cb, int16_t tmrEvnt, uint8_t timerValue) { case EVENT_E2_SETUP_TMR: { - e2apDb = ((E2apDb *)cb); + CmTimer *e2SetupTimer; + e2SetupTimer = ((CmTimer *)cb); TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes); - arg.timers = &e2apDb->e2TimersInfo.e2Timers.e2SetupTimer; + arg.timers = e2SetupTimer; arg.max = MAX_E2_SETUP_TMR; break; } diff --git a/src/ric_stub/ric_e2ap_msg_hdl.c b/src/ric_stub/ric_e2ap_msg_hdl.c index ec6e0db76..6060f9c2d 100644 --- a/src/ric_stub/ric_e2ap_msg_hdl.c +++ b/src/ric_stub/ric_e2ap_msg_hdl.c @@ -38,6 +38,35 @@ #include "RIC-ReportStyle-Item.h" #include "MeasurementInfo-Action-Item.h" +/******************************************************************* + * + * @brief Assigns new transaction id to RIC initiated procedure + * + * @details + * + * Function : assignTransactionId + * + * Functionality: Assigns new transaction id to a RIC initiated + * procedure + * + * @params[in] Region region + * Pool pool + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t assignTransactionId(DuDb *duDb) +{ + uint8_t currTransId = duDb->ricTransIdCounter; + + /* Update to next valid value */ + duDb->ricTransIdCounter++; + if(duDb->ricTransIdCounter == MAX_NUM_TRANSACTION) + duDb->ricTransIdCounter = 0; + + return currTransId; +} /******************************************************************* * @@ -165,9 +194,9 @@ void FreeE2SetupRsp(E2AP_PDU_t *e2apMsg) { for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) { - if(ranFuncAddedList->list.array[arrIdx]) + if(ranFuncAddedList->list.array[ranFuncIdx]) { - RIC_FREE(ranFuncAddedList->list.array[arrIdx], sizeof(RANfunction_ItemIEs_t)); + RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); } } RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size); @@ -290,19 +319,38 @@ uint8_t BuildE2nodeComponentConfigAdditionAck(E2nodeComponentConfigAdditionAck_L * Function : BuildRanFunctionAddedList * * Functionality: Build RAN function added list - * - * @params[in] DuDb *duDb, RANfunctionsID_List_t *ranFuncAddedList + * ->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 + * is present in the recvList + * + * @params[in] + * Stored DU databse + * Count of ran functions to be added in the list + * Received list of RAN functions + * RAN Function list + * Procedure Code * * @return ROK - success * RFAILED - failure * ****************************************************************/ -uint8_t BuildRanFunctionAddedList(DuDb *duDb, RANfunctionsID_List_t *ranFuncAddedList) +uint8_t BuildRanFunctionAddedList(DuDb *duDb, uint8_t count, RanFunction *ranFunToBeAdded, RANfunctionsID_List_t *ranFuncAddedList, uint8_t procedureCode) { uint8_t ranFuncIdx = 0; RANfunctionID_ItemIEs_t *ranFuncAddedItemIe; - - ranFuncAddedList->list.count = duDb->numOfRanFunction; + + /* For ProcedureCodeE2_id_E2setup and ProcedureCodeE2_id_RICserviceQuery, + * the number of RAN function list items is equal to the number of + * ran function entries stored in the database. + * For any other procedure, the RAN function list count is equal + * 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; + else + ranFuncAddedList->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) @@ -319,8 +367,18 @@ uint8_t BuildRanFunctionAddedList(DuDb *duDb, RANfunctionsID_List_t *ranFuncAdde ranFuncAddedItemIe->id = ProtocolIE_IDE2_id_RANfunctionID_Item; ranFuncAddedItemIe->criticality= CriticalityE2_ignore; ranFuncAddedItemIe->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item; - ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID =duDb->ranFunction[ranFuncIdx].id; - ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision=duDb->ranFunction[ranFuncIdx].revisionCounter; + 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; + } + 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; + } } } else @@ -349,6 +407,7 @@ uint8_t BuildRanFunctionAddedList(DuDb *duDb, RANfunctionsID_List_t *ranFuncAdde * RFAILED - failure * * ****************************************************************/ + uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId) { E2AP_PDU_t *e2apMsg = NULL; @@ -381,7 +440,11 @@ uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId) SuccessfulOutcomeE2__value_PR_E2setupResponse; e2SetupRsp = &e2apMsg->choice.successfulOutcome->value.choice.E2setupResponse; - elementCnt = 4; + elementCnt = 3; + /* Fill Accepted RAN function IE If Ran function information is stored in databse */ + if(duDb->numOfRanFunction) + elementCnt++; + e2SetupRsp->protocolIEs.list.count = elementCnt; e2SetupRsp->protocolIEs.list.size = elementCnt * sizeof(E2setupResponseIEs_t*); @@ -428,15 +491,18 @@ uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId) break; } - /* Accepted RAN function Id */ - idx++; - 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, &e2SetupRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionsID_List)!=ROK) + if(duDb->numOfRanFunction) { - DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list"); - break; + /* Accepted RAN function Id */ + idx++; + 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) + { + DU_LOG("\nERROR --> E2AP : Failed to build Ran function added list"); + break; + } } /* E2 Node Component Configuration Addition Acknowledge List*/ @@ -996,7 +1062,7 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t *e2SetupReq) { *duId =e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.GlobalE2node_ID.choice.gNB->gNB_DU_ID->buf[0]; - SEARCH_DU_DB(duIdx, duId, duDb); + SEARCH_DU_DB(duIdx, *duId, duDb); if(duDb == NULLP) { duDb = &ricCb.duInfo[ricCb.numDu]; @@ -1009,6 +1075,7 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t *e2SetupReq) } case ProtocolIE_IDE2_id_RANfunctionsAdded: { + ranFunctionsList = &e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List; if(ranFunctionsList->list.array) @@ -1017,8 +1084,8 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t *e2SetupReq) { ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx]; ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item; - duDb->ranFunction[duDb->numOfRanFunction].id = ranFunItem->ranFunctionID; - duDb->ranFunction[ duDb->numOfRanFunction].revisionCounter = ranFunItem->ranFunctionRevision; + duDb->ranFunction[ranFunItem->ranFunctionID-1].id = ranFunItem->ranFunctionID; + duDb->ranFunction[ranFunItem->ranFunctionID-1].revisionCounter = ranFunItem->ranFunctionRevision; duDb->numOfRanFunction++; } } @@ -1052,6 +1119,7 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t *e2SetupReq) } } } + if(BuildAndSendE2SetupRsp(duDb, transId) !=ROK) { DU_LOG("\nERROR --> E2AP : Failed to build and send E2 setup response"); @@ -1434,6 +1502,203 @@ uint8_t ProcE2ResetReq(uint32_t duId, ResetRequestE2_t *resetReq) return ROK; } +/******************************************************************* + * + * @brief deallocate the memory allocated in building the + * Service Query message + * + * @details + * + * Function : FreeRicServiceQuery + * + * Functionality: deallocate the memory allocated in building + * Ric Service Query message + * + * @params[in] E2AP_PDU_t *e2apMsg + * + * @return void + * ****************************************************************/ + +void FreeRicServiceQuery(E2AP_PDU_t *e2apMsg) +{ + uint8_t arrIdx = 0, ranFuncIdx=0; + RANfunctionsID_List_t *ranFuncAddedList; + RICserviceQuery_t *ricServiceQuery; + + if(e2apMsg) + { + if(e2apMsg->choice.initiatingMessage) + { + ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery; + if(ricServiceQuery->protocolIEs.list.array) + { + for(arrIdx=0; arrIdxprotocolIEs.list.count; arrIdx++) + { + if(ricServiceQuery->protocolIEs.list.array[arrIdx]) + { + switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id) + { + case ProtocolIE_IDE2_id_RANfunctionsAccepted: + { + ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List; + if(ranFuncAddedList->list.array) + { + for(ranFuncIdx=0;ranFuncIdxlist.count; ranFuncIdx++) + { + RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t)); + } + RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size); + } + break; + } + case RICserviceQuery_IEs__value_PR_TransactionID: + { + break; + } + } + RIC_FREE(ricServiceQuery->protocolIEs.list.array[arrIdx], sizeof(RICserviceQuery_IEs_t)); + } + } + RIC_FREE(ricServiceQuery->protocolIEs.list.array, ricServiceQuery->protocolIEs.list.size); + } + RIC_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t)); + } + RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t)); + } +} + +/******************************************************************* + * + * @brief build and send the ric service Query + * + * @details + * + * Function : BuildAndSendRicServiceQuery + * + * Functionality: build and send the ric service Query + * @return ROK - success + * RFAILED - Acknowledge + * + ******************************************************************/ + +uint8_t BuildAndSendRicServiceQuery(DuDb *duDb) +{ + uint8_t arrIdx; + uint8_t elementCnt; + uint8_t ret = RFAILED; + bool memAllocFailed = false; + E2AP_PDU_t *e2apMsg = NULL; + asn_enc_rval_t encRetVal; + RICserviceQuery_t *ricServiceQuery; + + DU_LOG("\nINFO --> E2AP : Building Ric service Query\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_initiatingMessage; + RIC_ALLOC(e2apMsg->choice.initiatingMessage , sizeof(struct InitiatingMessageE2)); + if(e2apMsg->choice.initiatingMessage == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for E2AP-PDU failed"); + break; + } + + e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICserviceQuery; + e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject; + e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICserviceQuery; + ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery; + + elementCnt = 1; + /* Fill Accepted RAN function IE If Ran function information is stored in databse */ + if(duDb->numOfRanFunction) + elementCnt++; + + ricServiceQuery->protocolIEs.list.count = elementCnt; + ricServiceQuery->protocolIEs.list.size = elementCnt * sizeof(RICserviceQuery_IEs_t*); + + RIC_ALLOC(ricServiceQuery->protocolIEs.list.array, ricServiceQuery->protocolIEs.list.size); + if(ricServiceQuery->protocolIEs.list.array == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceQueryIEs failed"); + break; + } + + for(arrIdx=0; arrIdxprotocolIEs.list.array[arrIdx], sizeof(RICserviceQuery_IEs_t)); + if(ricServiceQuery->protocolIEs.list.array[arrIdx] == NULLP) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceQueryIEs failed"); + memAllocFailed = true; + break; + } + } + if(memAllocFailed == true) + { + DU_LOG("\nERROR --> E2AP : Memory allocation for ricServiceQueryIEs failed"); + break; + } + + /* Trans Id */ + arrIdx = 0; + ricServiceQuery->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID; + ricServiceQuery->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject; + ricServiceQuery->protocolIEs.list.array[arrIdx]->value.present = RICserviceQuery_IEs__value_PR_TransactionID; + ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = assignTransactionId(duDb); + + if(duDb->numOfRanFunction) + { + /* Accepted RAN function Id */ + arrIdx++; + 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) + { + DU_LOG("\nERROR --> E2AP : Failed to build Ran function added 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 Query 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 Query\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 of RIC service Query failed"); + break; + } + + ret =ROK; + break; + } + FreeRicServiceQuery(e2apMsg); + return ret; +} + /******************************************************************* * * @brief Handles received E2AP message and sends back response diff --git a/src/ric_stub/ric_e2ap_msg_hdl.h b/src/ric_stub/ric_e2ap_msg_hdl.h index 38c64a0f2..aba63d22e 100644 --- a/src/ric_stub/ric_e2ap_msg_hdl.h +++ b/src/ric_stub/ric_e2ap_msg_hdl.h @@ -55,7 +55,7 @@ void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf); uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId); uint8_t BuildAndSendRicSubscriptionReq(uint32_t duId); uint8_t SendE2APMsg(Region region, Pool pool, uint32_t duId); - +uint8_t BuildAndSendRicServiceQuery(DuDb *duDb); /********************************************************************** End of file **********************************************************************/ diff --git a/src/ric_stub/ric_stub.h b/src/ric_stub/ric_stub.h index 7c6362e79..0bf9680f0 100644 --- a/src/ric_stub/ric_stub.h +++ b/src/ric_stub/ric_stub.h @@ -47,6 +47,7 @@ #define RIC_APP_MEM_REG 1 #define RIC_POOL 1 #define MAX_RAN_FUNCTION 256 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofRANfunctionID */ +#define MAX_NUM_TRANSACTION 256 /* As per, O-RAN WG3 E2AP v3.0, section 9.2.33 */ /* allocate and zero out a static buffer */ #define RIC_ALLOC(_datPtr, _size) \ @@ -105,6 +106,7 @@ typedef struct typedef struct duDb { uint32_t duId; + uint8_t ricTransIdCounter; uint16_t numOfRanFunction; RanFunction ranFunction[MAX_RAN_FUNCTION]; E2NodeComponent e2NodeComponent; @@ -128,6 +130,16 @@ typedef struct cuGlobalCb 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]; +}RicTmpRanFunList; + void readRicCfg(); void cuAppInmsgHdlr(Buffer *mBuf); void sctpNtfyInd(CmInetSctpNotification *ntfy);