#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;
+}
/*******************************************************************
*
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)
{
{
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;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
+ for(ranFuncIdx=0;ranFuncIdx<ranFuncAcceptedList->list.count; ranFuncIdx++)
{
- if(ranFuncAddedList->list.array[arrIdx])
+ if(ranFuncAcceptedList->list.array[ranFuncIdx])
{
- RIC_FREE(ranFuncAddedList->list.array[arrIdx], 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;
}
/*******************************************************************
*
- * @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
+ * is present in the recvList
*
- * @params[in] DuDb *duDb, RANfunctionsID_List_t *ranFuncAddedList
+ * @params[in]
+ * Stored DU databse
+ * Count of ran functions to be accepted 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 BuildRanFunctionAcceptedList(DuDb *duDb, uint8_t count, RanFunction *ranFunAcceptedList, RANfunctionsID_List_t *ranFuncAcceptedList, uint8_t procedureCode)
{
uint8_t ranFuncIdx = 0;
- RANfunctionID_ItemIEs_t *ranFuncAddedItemIe;
-
- ranFuncAddedList->list.count = duDb->numOfRanFunction;
- ranFuncAddedList->list.size = ranFuncAddedList->list.count*sizeof(RANfunctionID_ItemIEs_t*);
- RIC_ALLOC(ranFuncAddedList->list.array, ranFuncAddedList->list.size);
- if(ranFuncAddedList->list.array)
+ 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
+ * 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))
+ ranFuncAcceptedList->list.count = duDb->numOfRanFunction;
+ else
+ ranFuncAcceptedList->list.count = count;
+
+ 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;
- ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID =duDb->ranFunction[ranFuncIdx].id;
- ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision=duDb->ranFunction[ranFuncIdx].revisionCounter;
+ 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 */
+ 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 */
+ ranFuncAcceptedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = ranFunAcceptedList[ranFuncIdx].id;
+ ranFuncAcceptedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= ranFunAcceptedList[ranFuncIdx].revisionCounter;
+ }
}
}
else
* RFAILED - failure
*
* ****************************************************************/
+
uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId)
{
E2AP_PDU_t *e2apMsg = NULL;
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*);
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(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;
+ }
}
/* E2 Node Component Configuration Addition Acknowledge List*/
{
*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];
}
case ProtocolIE_IDE2_id_RANfunctionsAdded:
{
+
ranFunctionsList = &e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List;
if(ranFunctionsList->list.array)
{
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++;
}
}
}
}
}
+
if(BuildAndSendE2SetupRsp(duDb, transId) !=ROK)
{
DU_LOG("\nERROR --> E2AP : Failed to build and send E2 setup response");
}
/*******************************************************************
-*
-* @brief Handles received E2AP message and sends back response
-*
-* @details
-*
-* Function : E2APMsgHdlr
-*
-* Functionality:
-* - Decodes received E2AP control message
-* - Prepares response message, encodes and sends to SCTP
-*
-* @params[in]
-* @return ROK - success
-* RFAILED - failure
-*
-* ****************************************************************/
-void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf)
-{
- int i;
- char *recvBuf;
- MsgLen copyCnt;
- MsgLen recvBufLen;
- E2AP_PDU_t *e2apMsg;
- asn_dec_rval_t rval; /* Decoder return value */
- E2AP_PDU_t e2apasnmsg ;
-
- DU_LOG("\nINFO --> E2AP : Received E2AP message buffer");
- ODU_PRINT_MSG(mBuf, 0,0);
-
- /* Copy mBuf into char array to decode it */
- ODU_GET_MSG_LEN(mBuf, &recvBufLen);
- RIC_ALLOC(recvBuf, (Size)recvBufLen);
+ *
+ * @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
+ * ****************************************************************/
- if(recvBuf == NULLP)
+void FreeRicServiceQuery(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t arrIdx = 0, ranFuncIdx=0;
+ RANfunctionsID_List_t *ranFuncAcceptedList=NULL;
+ RICserviceQuery_t *ricServiceQuery=NULL;
+
+ if(e2apMsg)
{
- DU_LOG("\nERROR --> E2AP : Memory allocation failed");
- return;
+ if(e2apMsg->choice.initiatingMessage)
+ {
+ ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery;
+ if(ricServiceQuery->protocolIEs.list.array)
+ {
+ for(arrIdx=0; arrIdx<ricServiceQuery->protocolIEs.list.count; arrIdx++)
+ {
+ if(ricServiceQuery->protocolIEs.list.array[arrIdx])
+ {
+ switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_RANfunctionsAccepted:
+ {
+ ranFuncAcceptedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List;
+ if(ranFuncAcceptedList->list.array)
+ {
+ for(ranFuncIdx=0;ranFuncIdx<ranFuncAcceptedList->list.count; ranFuncIdx++)
+ {
+ RIC_FREE(ranFuncAcceptedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
+ }
+ RIC_FREE(ranFuncAcceptedList->list.array, ranFuncAcceptedList->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));
}
- if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
+}
+
+/*******************************************************************
+ *
+ * @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)
{
- DU_LOG("\nERROR --> E2AP : Failed while copying %d", copyCnt);
- return;
+ 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; arrIdx<elementCnt; arrIdx++)
+ {
+ RIC_ALLOC(ricServiceQuery->protocolIEs.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(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;
+ }
+ }
+
+ 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;
+}
- DU_LOG("\nDEBUG --> E2AP : Received flat buffer to be decoded : ");
- for(i=0; i< recvBufLen; i++)
+/*******************************************************************
+ *
+ * @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)
{
- DU_LOG("%x",recvBuf[i]);
+ if(e2apMsg->choice.unsuccessfulOutcome)
+ {
+ ricServiceUpdateFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICserviceUpdateFailure;
+ if(ricServiceUpdateFailure->protocolIEs.list.array)
+ {
+ for(arrIdx=0; arrIdx<ricServiceUpdateFailure->protocolIEs.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));
}
+}
- /* Decoding flat buffer into E2AP messsage */
- e2apMsg = &e2apasnmsg;
- memset(e2apMsg, 0, sizeof(E2AP_PDU_t));
+/*******************************************************************
+ *
+ * @brief fill E2 failure cause
+ *
+ * @details
+ *
+ * Function : fillE2FailureCause
+ *
+ * Functionality: fill E2 failure cause
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
- rval = aper_decode(0, &asn_DEF_E2AP_PDU, (void **)&e2apMsg, recvBuf, recvBufLen, 0, 0);
- RIC_FREE(recvBuf, (Size)recvBufLen);
+void fillE2FailureCause(CauseE2_t *cause, CauseE2_PR causePresent, uint8_t reason)
+{
+ cause->present = causePresent;
- if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+ switch(cause->present)
{
- DU_LOG("\nERROR --> E2AP : ASN decode failed");
- return;
+ 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;
}
- DU_LOG("\n");
- xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+}
- switch(e2apMsg->present)
- {
- case E2AP_PDU_PR_initiatingMessage:
- {
- switch(e2apMsg->choice.initiatingMessage->value.present)
- {
- case InitiatingMessageE2__value_PR_E2setupRequest:
- {
- DU_LOG("\nINFO --> E2AP : E2 setup request received");
+/*******************************************************************
+ *
+ * @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; arrIdx<elementCnt; arrIdx++)
+ {
+ RIC_ALLOC(ricServiceFailure->protocolIEs.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<elementCnt)
+ {
+ DU_LOG("\nERROR --> 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; arrIdx<ricServiceUpdateAck->protocolIEs.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;ranFuncIdx<acceptedList->list.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;ranFuncIdx<rejectedList->list.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; arrIdx<elementCnt; arrIdx++)
+ {
+ RIC_ALLOC(ricServiceUpdateAck->protocolIEs.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<elementCnt)
+ {
+ DU_LOG("\nERROR --> 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; arrIdx<ricServiceUpdate->protocolIEs.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;ranFuncIdx<ranFuncList->list.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
+*
+* @details
+*
+* Function : E2APMsgHdlr
+*
+* Functionality:
+* - Decodes received E2AP control message
+* - Prepares response message, encodes and sends to SCTP
+*
+* @params[in]
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf)
+{
+ int i;
+ char *recvBuf;
+ MsgLen copyCnt;
+ MsgLen recvBufLen;
+ E2AP_PDU_t *e2apMsg;
+ asn_dec_rval_t rval; /* Decoder return value */
+ E2AP_PDU_t e2apasnmsg ;
+
+ DU_LOG("\nINFO --> E2AP : Received E2AP message buffer");
+ ODU_PRINT_MSG(mBuf, 0,0);
+
+ /* Copy mBuf into char array to decode it */
+ ODU_GET_MSG_LEN(mBuf, &recvBufLen);
+ RIC_ALLOC(recvBuf, (Size)recvBufLen);
+
+ if(recvBuf == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed");
+ return;
+ }
+ if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed while copying %d", copyCnt);
+ return;
+ }
+
+ DU_LOG("\nDEBUG --> E2AP : Received flat buffer to be decoded : ");
+ for(i=0; i< recvBufLen; i++)
+ {
+ DU_LOG("%x",recvBuf[i]);
+ }
+
+ /* Decoding flat buffer into E2AP messsage */
+ e2apMsg = &e2apasnmsg;
+ memset(e2apMsg, 0, sizeof(E2AP_PDU_t));
+
+ rval = aper_decode(0, &asn_DEF_E2AP_PDU, (void **)&e2apMsg, recvBuf, recvBufLen, 0, 0);
+ RIC_FREE(recvBuf, (Size)recvBufLen);
+
+ if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+ {
+ DU_LOG("\nERROR --> E2AP : ASN decode failed");
+ return;
+ }
+ DU_LOG("\n");
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+
+ switch(e2apMsg->present)
+ {
+ case E2AP_PDU_PR_initiatingMessage:
+ {
+ switch(e2apMsg->choice.initiatingMessage->value.present)
+ {
+ case InitiatingMessageE2__value_PR_E2setupRequest:
+ {
+ DU_LOG("\nINFO --> E2AP : E2 setup request received");
ProcE2SetupReq(duId, &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest);
break;
}
DU_LOG("\nINFO --> E2AP : RIC Indication Acknowledged");
break;
}
+ case InitiatingMessageE2__value_PR_RICserviceUpdate:
+ {
+ DU_LOG("\nINFO --> E2AP : RIC Service update received");
+ ProcRicServiceUpdate(*duId, &e2apMsg->choice.initiatingMessage->value.choice.RICserviceUpdate);
+ break;
+ }
+
default:
{
DU_LOG("\nERROR --> E2AP : Invalid type of intiating message [%d]",e2apMsg->choice.initiatingMessage->value.present);