+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for E2nodeConfigurationUpdate msg
+ *
+ * @details
+ *
+ * Function : FreeE2NodeConfigUpdate
+ *
+ * Functionality:
+ * - freeing the memory allocated for E2nodeConfigurationUpdate
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+void FreeE2NodeConfigUpdateAck(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t arrIdx =0, e2NodeConfigIdx=0;
+ E2nodeConfigurationUpdateAcknowledge_t *updateAckMsg=NULL;
+ E2nodeComponentConfigUpdateAck_ItemIEs_t *updateAckItemIe=NULL;
+ E2nodeComponentConfigUpdateAck_List_t *updateAckList=NULL;
+ E2nodeComponentConfigRemovalAck_ItemIEs_t *removalAckItemIe=NULL;
+ E2nodeComponentConfigRemovalAck_List_t *removalAckList=NULL;
+ E2nodeComponentConfigAdditionAck_ItemIEs_t *additionAckItemIte=NULL;
+ E2nodeComponentConfigAdditionAck_List_t *additionAckList=NULL;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.successfulOutcome != NULLP)
+ {
+ updateAckMsg = &e2apMsg->choice.successfulOutcome->value.choice.E2nodeConfigurationUpdateAcknowledge;
+ if(updateAckMsg->protocolIEs.list.array != NULLP)
+ {
+ for(arrIdx = 0; arrIdx < updateAckMsg->protocolIEs.list.count; arrIdx++)
+ {
+ if(updateAckMsg->protocolIEs.list.array[arrIdx])
+ {
+ switch(updateAckMsg->protocolIEs.list.array[arrIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
+ {
+ additionAckList =&updateAckMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
+ if(additionAckList->list.array)
+ {
+ for(e2NodeConfigIdx=0; e2NodeConfigIdx<additionAckList->list.count; e2NodeConfigIdx++)
+ {
+ additionAckItemIte = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) additionAckList->list.array[e2NodeConfigIdx];
+ if(additionAckItemIte)
+ {
+ freeE2NodeConfigItem(ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck,\
+ (PTR)&additionAckItemIte->value.choice.E2nodeComponentConfigAdditionAck_Item);
+ RIC_FREE(additionAckItemIte, sizeof(E2nodeComponentConfigAdditionAck_ItemIEs_t));
+ }
+ }
+ RIC_FREE(additionAckList->list.array, additionAckList->list.size);
+ }
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck:
+ {
+ updateAckList =&updateAckMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdateAck_List;
+ if(updateAckList->list.array)
+ {
+ for(e2NodeConfigIdx=0; e2NodeConfigIdx<updateAckList->list.count; e2NodeConfigIdx++)
+ {
+ updateAckItemIe = (E2nodeComponentConfigUpdateAck_ItemIEs_t*) updateAckList->list.array[e2NodeConfigIdx];
+ if(updateAckItemIe)
+ {
+ freeE2NodeConfigItem(ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck,\
+ (PTR)&updateAckItemIe->value.choice.E2nodeComponentConfigUpdateAck_Item);
+ RIC_FREE(updateAckItemIe, sizeof(E2nodeComponentConfigUpdateAck_ItemIEs_t));
+ }
+ }
+ RIC_FREE(updateAckList->list.array, updateAckList->list.size);
+ }
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck:
+ {
+ removalAckList =&updateAckMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemovalAck_List;
+ if(removalAckList->list.array)
+ {
+ for(e2NodeConfigIdx=0; e2NodeConfigIdx<removalAckList->list.count; e2NodeConfigIdx++)
+ {
+ removalAckItemIe = (E2nodeComponentConfigRemovalAck_ItemIEs_t*) removalAckList->list.array[e2NodeConfigIdx];
+ if(removalAckItemIe)
+ {
+ freeE2NodeConfigItem(ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck,\
+ (PTR)&removalAckItemIe->value.choice.E2nodeComponentConfigRemovalAck_Item);
+ RIC_FREE(removalAckItemIe, sizeof(E2nodeComponentConfigRemovalAck_ItemIEs_t));
+ }
+ }
+ RIC_FREE(removalAckList->list.array, removalAckList->list.size);
+ }
+ break;
+ }
+ }
+ RIC_FREE(updateAckMsg->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdateAcknowledge_IEs_t));
+ }
+ }
+ RIC_FREE(updateAckMsg->protocolIEs.list.array, updateAckMsg->protocolIEs.list.size);
+ }
+ RIC_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ }
+ RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Build E2node Component config Removal ack list
+ *
+ * @details
+ *
+ * Function : BuildE2nodeComponentConfigRemovalAck
+ *
+ * Functionality: Build the e2 node remove ack
+ *
+ * @params[in]
+ * E2nodeComponentConfigRemovalAck_List_t to be filled
+ * Count of e2 node to be removed
+ * list of e2 node cfg to be removed
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2nodeComponentConfigRemovalAck(E2nodeComponentConfigRemovalAck_List_t *e2NodeConfigRemovalAckList,\
+uint16_t removalE2NodeCount, E2NodeConfigItem *removaldE2Node)
+{
+ uint8_t arrIdx = 0;
+ E2nodeComponentConfigRemovalAck_ItemIEs_t *e2NodeRemovalAckItem=NULL;
+
+ /* Filling the e2 node config removal ack list */
+ e2NodeConfigRemovalAckList->list.count = removalE2NodeCount;
+ e2NodeConfigRemovalAckList->list.size = e2NodeConfigRemovalAckList->list.count * sizeof(E2nodeComponentConfigRemovalAck_ItemIEs_t*);
+ RIC_ALLOC(e2NodeConfigRemovalAckList->list.array, e2NodeConfigRemovalAckList->list.size);
+ if(e2NodeConfigRemovalAckList->list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2nodeComponentConfigRemovalAck %d",__LINE__);
+ return RFAILED;
+ }
+
+ for(arrIdx = 0; arrIdx< e2NodeConfigRemovalAckList->list.count; arrIdx++)
+ {
+ RIC_ALLOC(e2NodeConfigRemovalAckList->list.array[arrIdx], sizeof(E2nodeComponentConfigRemovalAck_ItemIEs_t));
+ if(e2NodeConfigRemovalAckList->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2nodeComponentConfigRemovalAck %d",__LINE__);
+ return RFAILED;
+ }
+ e2NodeRemovalAckItem = (E2nodeComponentConfigRemovalAck_ItemIEs_t*) e2NodeConfigRemovalAckList->list.array[arrIdx];
+ e2NodeRemovalAckItem->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck_Item;
+ e2NodeRemovalAckItem->criticality = CriticalityE2_reject;
+ e2NodeRemovalAckItem->value.present = E2nodeComponentConfigRemovalAck_ItemIEs__value_PR_E2nodeComponentConfigRemovalAck_Item;
+
+ /* Filling the e2 node config removal ack item */
+ fillE2NodeConfigAck((PTR)&e2NodeRemovalAckItem->value.choice.E2nodeComponentConfigRemovalAck_Item, ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck,\
+ &removaldE2Node[arrIdx].componentInfo, removaldE2Node[arrIdx].isSuccessful);
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Build E2node Component config update ack list
+ *
+ * @details
+ *
+ * Function : BuildE2nodeComponentConfigUpdateAck
+ *
+ * Functionality: Build E2node Component config update ack list
+ *
+ * @params[in]
+ * E2nodeComponentConfigUpdateAck_List to be filled
+ * Count of e2 node to be update
+ * list of e2 node cfg to be update
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2nodeComponentConfigUpdateAck(E2nodeComponentConfigUpdateAck_List_t *e2NodeConfigUpdateAckList,\
+uint16_t updatedE2NodeCount, E2NodeConfigItem *updatedE2Node)
+{
+ uint8_t arrIdx = 0;
+ E2nodeComponentConfigUpdateAck_ItemIEs_t *e2NodeUpdateAckItem=NULL;
+
+ /* Filling the e2 node config update ack list */
+ e2NodeConfigUpdateAckList->list.count = updatedE2NodeCount;
+ e2NodeConfigUpdateAckList->list.size = e2NodeConfigUpdateAckList->list.count * sizeof(E2nodeComponentConfigUpdateAck_ItemIEs_t*);
+ RIC_ALLOC(e2NodeConfigUpdateAckList->list.array, e2NodeConfigUpdateAckList->list.size);
+ if(e2NodeConfigUpdateAckList->list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2nodeComponentConfigUpdateAck %d",__LINE__);
+ return RFAILED;
+ }
+
+ for(arrIdx = 0; arrIdx< e2NodeConfigUpdateAckList->list.count; arrIdx++)
+ {
+ RIC_ALLOC(e2NodeConfigUpdateAckList->list.array[arrIdx], sizeof(E2nodeComponentConfigUpdateAck_ItemIEs_t));
+ if(e2NodeConfigUpdateAckList->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP: Memory allocation failed for BuildE2nodeComponentConfigUpdateAck %d",__LINE__);
+ return RFAILED;
+ }
+ e2NodeUpdateAckItem = (E2nodeComponentConfigUpdateAck_ItemIEs_t*) e2NodeConfigUpdateAckList->list.array[arrIdx];
+ e2NodeUpdateAckItem->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck_Item;
+ e2NodeUpdateAckItem->criticality = CriticalityE2_reject;
+ e2NodeUpdateAckItem->value.present = E2nodeComponentConfigUpdateAck_ItemIEs__value_PR_E2nodeComponentConfigUpdateAck_Item;
+
+ /* Filling the e2 node config update ack item */
+ fillE2NodeConfigAck((PTR)&e2NodeUpdateAckItem->value.choice.E2nodeComponentConfigUpdateAck_Item, ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck,\
+ &updatedE2Node[arrIdx].componentInfo, updatedE2Node[arrIdx].isSuccessful);
+
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 node config update ack msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendE2NodeConfigUpdateAck
+ *
+ * Functionality:
+ * - Buld and send the E2 node config update ack msg
+ * @params[in]
+ * DU databse
+ * transId
+ * list of E2 node cfg which needs to fill in IEs
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildAndSendE2NodeConfigUpdateAck(DuDb *duDb, uint8_t transId, E2NodeConfigList *e2NodeList)
+{
+ uint8_t ret = RFAILED;
+ uint8_t arrIdx = 0,elementCnt = 0;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ asn_enc_rval_t encRetVal;
+ E2nodeConfigurationUpdateAcknowledge_t *e2NodeConfigUpdateAck = NULLP;
+
+ DU_LOG("\nINFO --> E2AP : Building E2 Node config update Ack Message\n");
+ do
+ {
+ RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__,__LINE__);
+ break;
+ }
+ e2apMsg->present = E2AP_PDU_PR_successfulOutcome;
+ RIC_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ if(e2apMsg->choice.successfulOutcome == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__,__LINE__);
+ break;
+ }
+
+ e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_E2nodeConfigurationUpdate;
+ e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_E2nodeConfigurationUpdateAcknowledge;
+ e2NodeConfigUpdateAck = &e2apMsg->choice.successfulOutcome->value.choice.E2nodeConfigurationUpdateAcknowledge;
+
+ elementCnt =1;
+ if(e2NodeList->addedE2NodeCount)
+ elementCnt++;
+ if(e2NodeList->updatedE2NodeCount)
+ elementCnt++;
+ if(e2NodeList->removedE2NodeCount)
+ elementCnt++;
+
+ e2NodeConfigUpdateAck->protocolIEs.list.count = elementCnt;
+ e2NodeConfigUpdateAck->protocolIEs.list.size = elementCnt * sizeof(E2nodeConfigurationUpdateAcknowledge_IEs_t*);
+ RIC_ALLOC(e2NodeConfigUpdateAck->protocolIEs.list.array, e2NodeConfigUpdateAck->protocolIEs.list.size);
+ if(e2NodeConfigUpdateAck->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__,__LINE__);
+ break;
+ }
+
+ for(arrIdx =0; arrIdx<elementCnt; arrIdx++)
+ {
+ RIC_ALLOC(e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx], sizeof(E2nodeConfigurationUpdateAcknowledge_IEs_t));
+ if(e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx] == NULLP)
+ {
+
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__,__LINE__);
+ break;
+ }
+ }
+
+ if(arrIdx<elementCnt)
+ break;
+
+ arrIdx = 0;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdateAcknowledge_IEs__value_PR_TransactionID;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.TransactionID = transId;
+
+ if(e2NodeList->addedE2NodeCount)
+ {
+ arrIdx++;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdateAcknowledge_IEs__value_PR_E2nodeComponentConfigAdditionAck_List;
+ if(BuildE2nodeComponentConfigAdditionAck(&e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List,\
+ e2NodeList->addedE2NodeCount, e2NodeList->addedE2Node)!=ROK)
+
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build E2Node Component config addition ack list");
+ break;
+ }
+ }
+ if(e2NodeList->updatedE2NodeCount)
+ {
+ arrIdx++;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdateAcknowledge_IEs__value_PR_E2nodeComponentConfigUpdateAck_List;
+ if(BuildE2nodeComponentConfigUpdateAck(&e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdateAck_List,\
+ e2NodeList->updatedE2NodeCount, e2NodeList->updatedE2Node)!=ROK)
+
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build E2Node Component config update ack list");
+ break;
+ }
+ }
+ if(e2NodeList->removedE2NodeCount)
+ {
+ arrIdx++;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+ e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.present = E2nodeConfigurationUpdateAcknowledge_IEs__value_PR_E2nodeComponentConfigRemovalAck_List;
+ if(BuildE2nodeComponentConfigRemovalAck(&e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemovalAck_List,\
+ e2NodeList->removedE2NodeCount, e2NodeList->removedE2Node)!=ROK)
+
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build E2Node Component config removal ack 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);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode E2 Node config update ack structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2 Node config update ack \n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+
+ /* Sending msg */
+ if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duDb->duId) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Node config update ack ");
+ break;
+ }
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeE2NodeConfigUpdateAck(e2apMsg);
+ return ret;
+}
+
+
+/******************************************************************
+ *
+ * @brief Processes the E2 removal failure msg
+ *
+ * @details
+ *
+ * Function : procE2RemovalFailure
+ *
+ * Functionality: Processes the E2 removal failure msg
+ *
+ * @params[in]
+ * E2 Removal Failure information
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void ProcE2RemovalFailure(E2RemovalFailure_t *e2RemovalFailure)
+{
+ uint8_t ieIdx = 0, transId=0;
+ CauseE2_t *cause = NULLP;
+
+ if(!e2RemovalFailure)
+ {
+ DU_LOG("\nERROR --> E2AP : e2RemovalFailure pointer is null");
+ return;
+ }
+
+ if(!e2RemovalFailure->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : e2RemovalFailure array pointer is null");
+ return;
+ }
+
+ for(ieIdx=0; ieIdx < e2RemovalFailure->protocolIEs.list.count; ieIdx++)
+ {
+ if(e2RemovalFailure->protocolIEs.list.array[ieIdx])
+ {
+ switch(e2RemovalFailure->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ transId = e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
+ DU_LOG("\nERROR --> E2AP : Received transID %d", transId);
+ break;
+ }
+ case ProtocolIE_IDE2_id_CauseE2:
+ {
+ cause = &e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.choice.CauseE2;
+ printE2ErrorCause(cause);
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%d]", e2RemovalFailure->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ }
+}
+/*******************************************************************
+ *
+ * @brief Delete E2 component node list
+ *
+ * @details
+ *
+ * Function : deleteE2ComponentNodeList
+ *
+ * Functionality: Delete E2 component node list
+ *
+ * @params[in] E2 component node list
+ * @return void
+
+ *
+ ******************************************************************/
+
+void deleteE2ComponentNodeList(CmLListCp *componentList)
+{
+ E2NodeComponent *cfgInfo = NULLP;
+ CmLList *e2ComponentNode = NULLP;
+
+ CM_LLIST_FIRST_NODE(componentList, e2ComponentNode);
+ while(e2ComponentNode)
+ {
+ cfgInfo = (E2NodeComponent*)e2ComponentNode->node;
+ cmLListDelFrm(componentList, e2ComponentNode);
+ memset(cfgInfo, 0, sizeof(E2NodeComponent));
+ CM_LLIST_FIRST_NODE(componentList, e2ComponentNode);
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief process the E2 node information from ric db
+ *
+ * @details
+ *
+ * Function : deleteE2NodeInfo
+ *
+ * Functionality: process the E2 node information from ric db
+ *
+ * @params[in]
+ * du Id
+ *
+ * @return void
+ *
+ ******************************************************************/
+void deleteE2NodeInfo(DuDb *duDb)
+{
+ uint16_t ranFuncIdx =0;
+ RanFunction *ranFuncDb=NULLP;
+
+ DU_LOG("\nINFO --> E2AP : Removing all the E2 node information");
+ for(ranFuncIdx = 0; ranFuncIdx < MAX_RAN_FUNCTION; ranFuncIdx++)
+ {
+ ranFuncDb = &duDb->ranFunction[ranFuncIdx];
+ if(ranFuncDb->id > 0)
+ {
+ deleteRicSubscriptionList(&ranFuncDb->subscriptionList);
+ }
+ }
+ deleteE2ComponentNodeList(&duDb->e2NodeComponent);
+}
+
+/*******************************************************************
+ *
+ * @brief process the E2 Removal Response
+ *
+ * @details
+ *
+ * Function : ProcE2RemovalResponse
+ *
+ * Functionality: Process E2 Removal Response
+ *
+ * @params[in]
+ * du Id
+ * Pointer to removal response
+ * @return void
+ *
+ ******************************************************************/
+
+void ProcE2RemovalResponse(uint32_t duId, E2RemovalResponse_t *removalRsp)
+{
+ uint8_t ieIdx = 0, duIdx =0;
+ DuDb *duDb = NULLP;
+
+ SEARCH_DU_DB(duIdx, duId, duDb);
+ if(duDb == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : duDb is not present for duId %d",duId);
+ return;
+ }
+
+ if(!removalRsp)
+ {
+ DU_LOG("\nERROR --> E2AP : removalRsp pointer is null");
+ return;
+ }
+
+ if(!removalRsp->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : removalRsp array pointer is null");
+ return;
+ }
+
+ for(ieIdx=0; ieIdx < removalRsp->protocolIEs.list.count; ieIdx++)
+ {
+ if(removalRsp->protocolIEs.list.array[ieIdx])
+ {
+ switch(removalRsp->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ DU_LOG("\nINFO --> E2AP : Sending request to close the sctp connection");
+ cmInetClose(&sctpCb.e2LstnSockFd);
+ deleteE2NodeInfo(duDb);
+ exit(0);
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%ld]", removalRsp->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ }
+}
+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for E2 Removal Failure
+ *
+ * @details
+ *
+ * Function : FreeE2RemovalFailure
+ *
+ * Functionality:
+ * - freeing the memory allocated for E2RemovalFailure
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return void
+ *
+ * ****************************************************************/
+void FreeE2RemovalFailure(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0;
+ E2RemovalFailure_t *e2RemovalFailure=NULLP;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.unsuccessfulOutcome != NULLP)
+ {
+ e2RemovalFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2RemovalFailure;
+ if(e2RemovalFailure->protocolIEs.list.array)
+ {
+ for(ieIdx=0; ieIdx < e2RemovalFailure->protocolIEs.list.count; ieIdx++)
+ {
+ if(e2RemovalFailure->protocolIEs.list.array[ieIdx])
+ {
+ RIC_FREE(e2RemovalFailure->protocolIEs.list.array[ieIdx], sizeof(E2RemovalFailureIEs_t));
+ }
+ }
+ RIC_FREE(e2RemovalFailure->protocolIEs.list.array, e2RemovalFailure->protocolIEs.list.size);
+ }
+ RIC_FREE(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t));
+ }
+ RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 Removal Failure msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendE2RemovalFailure
+ *
+ * Functionality:
+ * - Buld and send the E2 Removal Failure Message
+ * @params[in]
+ * DU Id
+ * Trans Id
+ * Type of failure
+ * Cause of failure
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildAndSendRemovalFailure(uint32_t duId, uint16_t transId, CauseE2_PR causePresent, uint8_t reason)
+{
+ uint8_t ieIdx = 0, elementCnt = 0;
+ uint8_t ret = RFAILED;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ E2RemovalFailure_t *e2RemovalFailure=NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ DU_LOG("\nINFO --> E2AP : Building E2 Removal Failure Message\n");
+ do
+ {
+ RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+ e2apMsg->present = E2AP_PDU_PR_unsuccessfulOutcome;
+
+ RIC_ALLOC(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t));
+ if(e2apMsg->choice.unsuccessfulOutcome == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ e2apMsg->choice.unsuccessfulOutcome->procedureCode = ProcedureCodeE2_id_E2removal;
+ e2apMsg->choice.unsuccessfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.unsuccessfulOutcome->value.present = UnsuccessfulOutcomeE2__value_PR_E2RemovalFailure;
+ e2RemovalFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2RemovalFailure;
+
+ elementCnt = 2;
+ e2RemovalFailure->protocolIEs.list.count = elementCnt;
+ e2RemovalFailure->protocolIEs.list.size = elementCnt * sizeof(E2RemovalFailureIEs_t *);
+ RIC_ALLOC(e2RemovalFailure->protocolIEs.list.array, e2RemovalFailure->protocolIEs.list.size);
+ if(!e2RemovalFailure->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx=0; ieIdx < elementCnt; ieIdx++)
+ {
+ RIC_ALLOC(e2RemovalFailure->protocolIEs.list.array[ieIdx], sizeof(E2RemovalFailureIEs_t));
+ if(!e2RemovalFailure->protocolIEs.list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+ }
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ e2RemovalFailure->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ e2RemovalFailure->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.present = E2RemovalFailureIEs__value_PR_TransactionID;
+ e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
+
+ /* Cause */
+ ieIdx++;
+ e2RemovalFailure->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2;
+ e2RemovalFailure->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore;
+ e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.present = ErrorIndicationE2_IEs__value_PR_CauseE2;
+ fillE2FailureCause(&e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.choice.CauseE2, causePresent, reason);
+
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode E2 removal failure structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2 Removal Failure \n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duId) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Removal Failure");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeE2RemovalFailure(e2apMsg);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for E2 Removal Response
+ *
+ * @details
+ *
+ * Function : FreeE2RemovalResponse
+ *
+ * Functionality:
+ * - freeing the memory allocated for E2RemovalResponse
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void FreeE2RemovalResponse(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0;
+ E2RemovalResponse_t *e2RemovalResponse=NULLP;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.successfulOutcome != NULLP)
+ {
+ e2RemovalResponse = &e2apMsg->choice.successfulOutcome->value.choice.E2RemovalResponse;
+ if(e2RemovalResponse->protocolIEs.list.array)
+ {
+ for(ieIdx=0; ieIdx < e2RemovalResponse->protocolIEs.list.count; ieIdx++)
+ {
+ if(e2RemovalResponse->protocolIEs.list.array[ieIdx])
+ {
+ RIC_FREE(e2RemovalResponse->protocolIEs.list.array[ieIdx], sizeof(E2RemovalResponseIEs_t));
+ }
+ }
+ RIC_FREE(e2RemovalResponse->protocolIEs.list.array, e2RemovalResponse->protocolIEs.list.size);
+ }
+ RIC_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ }
+ RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 Removal Response msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendE2RemovalResponse
+ *
+ * Functionality:
+ * - Buld and send the E2 Removal Response Message
+ * @params[in]
+ * Du Id
+ * Trans Id
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildAndSendRemovalResponse(uint32_t duId, uint16_t transId)
+{
+ uint8_t ieIdx = 0, elementCnt = 0;
+ uint8_t ret = RFAILED, duIdx =0;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ DuDb *duDb = NULLP;
+ E2RemovalResponse_t *e2RemovalResponse=NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ DU_LOG("\nINFO --> E2AP : Building E2 Removal Response Message\n");
+ do
+ {
+ SEARCH_DU_DB(duIdx, duId, duDb);
+ if(duDb == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : duDb is not present for duId %d",duId);
+ return;
+ }
+
+ RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+ e2apMsg->present = E2AP_PDU_PR_successfulOutcome;
+
+ RIC_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ if(e2apMsg->choice.successfulOutcome == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_E2removal;
+ e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_E2RemovalResponse;
+ e2RemovalResponse = &e2apMsg->choice.successfulOutcome->value.choice.E2RemovalResponse;
+
+ elementCnt = 1;
+ e2RemovalResponse->protocolIEs.list.count = elementCnt;
+ e2RemovalResponse->protocolIEs.list.size = elementCnt * sizeof(E2RemovalResponseIEs_t *);
+ RIC_ALLOC(e2RemovalResponse->protocolIEs.list.array, e2RemovalResponse->protocolIEs.list.size);
+ if(!e2RemovalResponse->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx=0; ieIdx < elementCnt; ieIdx++)
+ {
+ RIC_ALLOC(e2RemovalResponse->protocolIEs.list.array[ieIdx], sizeof(E2RemovalResponseIEs_t));
+ if(!e2RemovalResponse->protocolIEs.list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+ }
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ e2RemovalResponse->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ e2RemovalResponse->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2RemovalResponse->protocolIEs.list.array[ieIdx]->value.present = E2RemovalResponseIEs__value_PR_TransactionID;
+ e2RemovalResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
+
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode E2 removal response structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2 Removal Response \n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duId) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Removal Response");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeE2RemovalResponse(e2apMsg);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Process Removal req received from RIC
+ *
+ * @details
+ *
+ * Function : procE2RemovalRequest
+ *
+ * Functionality: Process Removal req received from RIC
+ *
+ * @param
+ * DU id
+ * E2 Removal Request
+ * @return void
+ *
+ ******************************************************************/
+
+void procE2RemovalRequest(uint32_t duId, E2RemovalRequest_t *removalReq)
+{
+ uint8_t arrIdx =0;
+ uint16_t transId =0;
+
+ DU_LOG("\nINFO --> E2AP : E2 Removal request received");
+
+ for(arrIdx=0; arrIdx<removalReq->protocolIEs.list.count; arrIdx++)
+ {
+ switch(removalReq->protocolIEs.list.array[arrIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ transId = removalReq->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Invalid IE recevied [%d]", transId);
+ break;
+ }
+ }
+ }
+
+ if(transId>=0 && transId<=255)
+ {
+ if(BuildAndSendRemovalResponse(duId, transId) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build and send Removal response");
+ }
+ }
+ else
+ {
+ if(BuildAndSendRemovalFailure(duId, transId, CauseE2_PR_protocol, CauseE2Protocol_abstract_syntax_error_falsely_constructed_message) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build and send Removal response");
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief fill E2 connection update item
+ *
+ * @details
+ *
+ * Function : fillE2connectionUpdateItem
+ *
+ * Functionality: fill E2 connection update item
+ *
+ * @params[in]
+ * E2connectionUpdate Item to be filled
+ * Protocol Id
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t fillE2connectionUpdateItem(PTR connectionInfo, uint8_t protocolId)
+{
+ E2connectionUpdateRemove_Item_t *connectionRemoveITem=NULLP;
+ E2connectionUpdate_Item_t *connectionModifyItem=NULLP;
+ TNLinformation_t *tnlInformation = NULLP;
+ TNLusage_t *tnlUsage=NULLP;
+
+ switch(protocolId)
+ {
+ case ProtocolIE_IDE2_id_E2connectionUpdate_Item:
+ {
+ connectionModifyItem = (E2connectionUpdate_Item_t*)connectionInfo;
+ tnlInformation = &connectionModifyItem->tnlInformation;
+ tnlUsage = &connectionModifyItem->tnlUsage;
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_E2connectionUpdateRemove_Item:
+ {
+ connectionRemoveITem = (E2connectionUpdateRemove_Item_t*)connectionInfo;
+ tnlInformation= &connectionRemoveITem->tnlInformation;
+ break;
+ }
+ }
+
+ tnlInformation->tnlAddress.size = 4*sizeof(uint8_t);
+ RIC_ALLOC(tnlInformation->tnlAddress.buf, tnlInformation->tnlAddress.size);
+ if(!tnlInformation->tnlAddress.buf)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ return RFAILED;
+ }
+
+ tnlInformation->tnlAddress.buf[3] = ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr & 0xFF;
+ tnlInformation->tnlAddress.buf[2] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 8) & 0xFF;
+ tnlInformation->tnlAddress.buf[1] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 16) & 0xFF;
+ tnlInformation->tnlAddress.buf[0] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 24) & 0xFF;
+ tnlInformation->tnlAddress.bits_unused = 0;
+ if(protocolId == ProtocolIE_IDE2_id_E2connectionUpdate_Item)
+ {
+ *tnlUsage = TNLusage_support_function;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Build E2 connection modification list
+ *
+ * @details
+ *
+ * Function : BuildE2ConnectionModifyList
+ *
+ * Functionality: Build E2 connection modification list
+ *
+ * @params[in]
+ * E2 connection modification list to be filled
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2ConnectionModifyList(E2connectionUpdate_List_t *connectionToBeModifyList)
+{
+ uint8_t arrIdx = 0;
+ E2connectionUpdate_ItemIEs_t *connectionModify=NULL;
+
+ connectionToBeModifyList->list.count = 1;
+
+ connectionToBeModifyList->list.size = connectionToBeModifyList->list.count*sizeof(E2connectionUpdate_ItemIEs_t*);
+ RIC_ALLOC(connectionToBeModifyList->list.array, connectionToBeModifyList->list.size);
+ if(connectionToBeModifyList->list.array)
+ {
+ for(arrIdx = 0; arrIdx< connectionToBeModifyList->list.count; arrIdx++)
+ {
+ RIC_ALLOC(connectionToBeModifyList->list.array[arrIdx], sizeof(E2connectionUpdate_ItemIEs_t));
+ if(connectionToBeModifyList->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ return RFAILED;
+ }
+ connectionModify = (E2connectionUpdate_ItemIEs_t*)connectionToBeModifyList->list.array[arrIdx];
+ connectionModify->id = ProtocolIE_IDE2_id_E2connectionUpdate_Item;
+ connectionModify->criticality= CriticalityE2_ignore;
+ connectionModify->value.present = E2connectionUpdate_ItemIEs__value_PR_E2connectionUpdate_Item;
+ if(fillE2connectionUpdateItem((PTR)&connectionModify->value.choice.E2connectionUpdate_Item, ProtocolIE_IDE2_id_E2connectionUpdate_Item) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to fill E2 connection update item");
+ return RFAILED;
+ }
+
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Build E2 connection remove list
+ *
+ * @details
+ *
+ * Function : BuildE2ConnectionRemoveList
+ *
+ * Functionality: Build E2 connection remove list
+ *
+ * @params[in]
+ * E2 connection remove list to be filled
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2ConnectionRemoveList(E2connectionUpdateRemove_List_t *connectionToBeRemoveList)
+{
+ uint8_t arrIdx = 0;
+ E2connectionUpdateRemove_ItemIEs_t *connectionRemove=NULL;
+
+ connectionToBeRemoveList->list.count = 1;
+
+ connectionToBeRemoveList->list.size = connectionToBeRemoveList->list.count*sizeof(E2connectionUpdateRemove_ItemIEs_t*);
+ RIC_ALLOC(connectionToBeRemoveList->list.array, connectionToBeRemoveList->list.size);
+ if(connectionToBeRemoveList->list.array)
+ {
+ for(arrIdx = 0; arrIdx< connectionToBeRemoveList->list.count; arrIdx++)
+ {
+ RIC_ALLOC(connectionToBeRemoveList->list.array[arrIdx], sizeof(E2connectionUpdateRemove_ItemIEs_t));
+ if(connectionToBeRemoveList->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ return RFAILED;
+ }
+ connectionRemove = (E2connectionUpdateRemove_ItemIEs_t*)connectionToBeRemoveList->list.array[arrIdx];
+ connectionRemove->id = ProtocolIE_IDE2_id_E2connectionUpdateRemove_Item;
+ connectionRemove->criticality= CriticalityE2_ignore;
+ connectionRemove->value.present = E2connectionUpdateRemove_ItemIEs__value_PR_E2connectionUpdateRemove_Item;
+ if(fillE2connectionUpdateItem((PTR)&connectionRemove->value.choice.E2connectionUpdateRemove_Item, ProtocolIE_IDE2_id_E2connectionUpdateRemove_Item) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to fill E2 connection update item");
+ return RFAILED;
+ }
+
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for E2ConnectionUpdate msg
+ *
+ * @details
+ *
+ * Function : FreeE2ConnectionUpdate
+ *
+ * Functionality:
+ * - freeing the memory allocated for E2ConnectionUpdate
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void FreeE2ConnectionUpdate(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0, arrIdx=0;
+ E2connectionUpdate_t *connectionUpdate = NULLP;
+ E2connectionUpdate_List_t *connectionToBeModifyList = NULLP;
+ E2connectionUpdateRemove_List_t *connectionToBeRemoveList = NULLP;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.initiatingMessage != NULLP)
+ {
+ connectionUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2connectionUpdate;
+ if(connectionUpdate->protocolIEs.list.array)
+ {
+ for(ieIdx = 0; ieIdx < connectionUpdate->protocolIEs.list.count; ieIdx++)
+ {
+ if(connectionUpdate->protocolIEs.list.array[ieIdx])
+ {
+ switch(connectionUpdate->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ break;
+
+ case ProtocolIE_IDE2_id_E2connectionUpdateModify:
+ {
+ connectionToBeModifyList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List;
+ if(connectionToBeModifyList->list.array)
+ {
+ for(arrIdx = 0; arrIdx < connectionToBeModifyList->list.count; arrIdx++)
+ {
+ RIC_FREE(connectionToBeModifyList->list.array[arrIdx], sizeof(E2connectionUpdate_ItemIEs_t));
+ }
+ RIC_FREE(connectionToBeModifyList->list.array, connectionToBeModifyList->list.size);
+ }
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_E2connectionUpdateRemove:
+ {
+ connectionToBeRemoveList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdateRemove_List;
+ if(connectionToBeRemoveList->list.array)
+ {
+ for(arrIdx = 0; arrIdx < connectionToBeRemoveList->list.count; arrIdx++)
+ {
+ RIC_FREE(connectionToBeRemoveList->list.array[arrIdx], sizeof(E2connectionUpdateRemove_ItemIEs_t));
+ }
+ RIC_FREE(connectionToBeRemoveList->list.array, connectionToBeRemoveList->list.size);
+ }
+ break;
+ }
+ }
+ RIC_FREE(connectionUpdate->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdate_IEs_t));
+ }
+ }
+ RIC_FREE(connectionUpdate->protocolIEs.list.array, connectionUpdate->protocolIEs.list.size);
+ }
+ RIC_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
+ }
+ RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 Connection Update msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendE2ConnectionUpdate
+ *
+ * Functionality:
+ * - Buld and send the E2 Connection Update Message
+ * @params[in]
+ * Du Id
+ * E2 connection to be modify or delete
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildAndSendE2ConnectionUpdate(uint32_t duId, E2Connection connectionInfo)
+{
+ uint8_t ieIdx = 0, elementCnt = 0;
+ uint8_t ret = RFAILED, duIdx =0;
+ DuDb *duDb = NULLP;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ E2connectionUpdate_t *e2ConnectionUpdate=NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ DU_LOG("\nINFO --> E2AP : Building E2 Connection Update Message\n");
+ do
+ {
+ SEARCH_DU_DB(duIdx, duId, duDb);
+ if(duDb == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : duDb is not present for duId %d",duId);
+ return RFAILED;
+ }
+
+ RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+ e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
+
+ RIC_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
+ if(e2apMsg->choice.initiatingMessage == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_E2connectionUpdate;
+ e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
+ e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_E2connectionUpdate;
+ e2ConnectionUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2connectionUpdate;
+
+ elementCnt = 1;
+ if(connectionInfo == MODIFY_CONNECTION)
+ elementCnt++;
+ if(connectionInfo == REMOVE_CONNECTION)
+ elementCnt++;
+
+ e2ConnectionUpdate->protocolIEs.list.count = elementCnt;
+ e2ConnectionUpdate->protocolIEs.list.size = elementCnt * sizeof(E2connectionUpdate_IEs_t*);
+ RIC_ALLOC(e2ConnectionUpdate->protocolIEs.list.array, e2ConnectionUpdate->protocolIEs.list.size);
+ if(!e2ConnectionUpdate->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx=0; ieIdx < elementCnt; ieIdx++)
+ {
+ RIC_ALLOC(e2ConnectionUpdate->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdate_IEs_t));
+ if(!e2ConnectionUpdate->protocolIEs.list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+ }
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdate_IEs__value_PR_TransactionID;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = assignTransactionId(duDb);
+
+ if(connectionInfo == MODIFY_CONNECTION)
+ {
+ ieIdx++;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_E2connectionUpdateModify;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdate_IEs__value_PR_E2connectionUpdate_List;
+ if(BuildE2ConnectionModifyList(&e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build the connection update modify list");
+ break;
+ }
+ }
+
+ if(connectionInfo == REMOVE_CONNECTION)
+ {
+ ieIdx++;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_E2connectionUpdateRemove;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdate_IEs__value_PR_E2connectionUpdateRemove_List;
+ if(BuildE2ConnectionRemoveList(&e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdateRemove_List) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build the connection update modify 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);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode E2 connection update structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for E2 Connection Update \n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duId) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Connection Update");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeE2ConnectionUpdate(e2apMsg);
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Processes the E2 connection update failure msg
+ *
+ * @details
+ *
+ * Function : procE2connectionUpdateFailure
+ *
+ * Functionality: Processes the E2 connection update failure msg
+ *
+ * @params[in]
+ * E2 connection update failure information
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void ProcE2connectionUpdateFailure(E2connectionUpdateFailure_t *updateFailure)
+{
+ uint8_t ieIdx = 0;
+ uint16_t transId=0;
+ CauseE2_t *cause = NULLP;
+
+ if(!updateFailure)
+ {
+ DU_LOG("\nERROR --> E2AP : updateFailure pointer is null");
+ return;
+ }
+
+ if(!updateFailure->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : updateFailure array pointer is null");
+ return;
+ }
+
+ for(ieIdx=0; ieIdx < updateFailure->protocolIEs.list.count; ieIdx++)
+ {
+ if(updateFailure->protocolIEs.list.array[ieIdx])
+ {
+ switch(updateFailure->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ transId = updateFailure->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
+ DU_LOG("\nERROR --> E2AP : Received transID %d", transId);
+ break;
+ }
+ case ProtocolIE_IDE2_id_CauseE2:
+ {
+ cause = &updateFailure->protocolIEs.list.array[ieIdx]->value.choice.CauseE2;
+ printE2ErrorCause(cause);
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%d]", updateFailure->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief process the E2 Connection update ack
+ *
+ * @details
+ *
+ * Function : ProcE2ConnectionUpdateAck
+ *
+ * Functionality: Process E2 Connection update ack
+ *
+ * @params[in]
+ * du Id
+ * Pointer to Connection update ack
+ * @return void
+ *
+ ******************************************************************/
+
+void ProcE2ConnectionUpdateAck(uint32_t duId, E2connectionUpdateAcknowledge_t *connectionUpdateAck)
+{
+ uint16_t transId =0;
+ uint32_t ipAddress=0;
+ DuDb *duDb = NULLP;
+ uint8_t ieIdx = 0, duIdx =0, arrIdx=0;
+ E2connectionUpdate_Item_t *connectionSetupItem=NULLP;
+ E2connectionUpdate_ItemIEs_t *connectionSetupItemIe=NULLP;
+ E2connectionUpdate_List_t *connectionSetupList=NULLP;
+ E2connectionSetupFailed_Item_t *setupFailedItem =NULLP;
+ E2connectionSetupFailed_List_t *setupFailedList=NULLP;
+ E2connectionSetupFailed_ItemIEs_t *setupFailedItemIe =NULLP;
+
+ SEARCH_DU_DB(duIdx, duId, duDb);
+ if(duDb == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : duDb is not present for duId %d",duId);
+ return;
+ }
+
+ if(!connectionUpdateAck)
+ {
+ DU_LOG("\nERROR --> E2AP : connectionUpdateAck pointer is null");
+ return;
+ }
+
+ if(!connectionUpdateAck->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : connectionUpdateAck array pointer is null");
+ return;
+ }
+
+ for(ieIdx=0; ieIdx < connectionUpdateAck->protocolIEs.list.count; ieIdx++)
+ {
+ if(connectionUpdateAck->protocolIEs.list.array[ieIdx])
+ {
+ switch(connectionUpdateAck->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ transId = connectionUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
+ if(transId>255)
+ {
+ DU_LOG("\nERROR --> E2AP : Received invalid trans id %d ",transId);
+ return;
+ }
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2connectionSetup:
+ {
+ connectionSetupList=&connectionUpdateAck->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List;
+ if(connectionSetupList->list.array)
+ {
+ for(arrIdx = 0; arrIdx< connectionSetupList->list.count; arrIdx++)
+ {
+ connectionSetupItemIe = (E2connectionUpdate_ItemIEs_t*)connectionSetupList->list.array[arrIdx];
+ connectionSetupItem = &connectionSetupItemIe->value.choice.E2connectionUpdate_Item;
+ bitStringToInt(&connectionSetupItem->tnlInformation.tnlAddress, &ipAddress);
+ if(ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr == ipAddress)
+ {
+ ricCb.ricCfgParams.sctpParams.usage = connectionSetupItem->tnlUsage;
+ }
+ }
+ }
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_E2connectionSetupFailed:
+ {
+ setupFailedList=&connectionUpdateAck->protocolIEs.list.array[ieIdx]->value.choice.E2connectionSetupFailed_List;
+ if(setupFailedList->list.array)
+ {
+ for(arrIdx = 0; arrIdx< setupFailedList->list.count; arrIdx++)
+ {
+ setupFailedItemIe = (E2connectionSetupFailed_ItemIEs_t*)setupFailedList->list.array[arrIdx];
+ setupFailedItem = &setupFailedItemIe->value.choice.E2connectionSetupFailed_Item;
+ printE2ErrorCause(&setupFailedItem->cause);
+ }
+ }
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%ld]", connectionUpdateAck->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ }
+}
+
+/******************************************************************
+ *
+ * @brief Processes the Ric Subs delete failure msg
+ *
+ * @details
+ *
+ * Function : procRicSubsDeleteFailure
+ *
+ * Functionality: Processes the Ric Subs delete failure msg
+ *
+ * @params[in]
+ * Ric Subs delete failure information
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void ProcRicSubsDeleteFailure(RICsubscriptionDeleteFailure_t *ricSubsDeleteFail)
+{
+ uint8_t ieIdx = 0;
+ uint16_t ranFuncId=0;
+ CauseE2_t *cause = NULLP;
+ RICrequestID_t ricRequestID;
+
+ if(!ricSubsDeleteFail)
+ {
+ DU_LOG("\nERROR --> E2AP : ricSubsDeleteFail pointer is null");
+ return;
+ }
+
+ if(!ricSubsDeleteFail->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : ricSubsDeleteFail array pointer is null");
+ return;
+ }
+
+ for(ieIdx=0; ieIdx < ricSubsDeleteFail->protocolIEs.list.count; ieIdx++)
+ {
+ if(ricSubsDeleteFail->protocolIEs.list.array[ieIdx])
+ {
+ switch(ricSubsDeleteFail->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_RICrequestID:
+ {
+ memcpy(&ricSubsDeleteFail->protocolIEs.list.array[ieIdx]->value.choice.RICrequestID, &ricRequestID, sizeof(RICrequestID_t));
+ DU_LOG("\nERROR --> E2AP : Received RicReqId %ld and InstanceId %ld", ricRequestID.ricRequestorID, ricRequestID.ricInstanceID);
+ break;
+ }
+ case ProtocolIE_IDE2_id_RANfunctionID:
+ {
+ ranFuncId = ricSubsDeleteFail->protocolIEs.list.array[ieIdx]->value.choice.RANfunctionID;
+ DU_LOG("\nERROR --> E2AP : Received ranfuncId %d", ranFuncId);
+ break;
+ }
+ case ProtocolIE_IDE2_id_CauseE2:
+ {
+ cause = &ricSubsDeleteFail->protocolIEs.list.array[ieIdx]->value.choice.CauseE2;
+ printE2ErrorCause(cause);
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%ld]", ricSubsDeleteFail->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ }
+}
+
+
+/******************************************************************
+ *
+ * @brief Processes the Ric Subs delete rsp msg
+ *
+ * @details
+ *
+ * Function : ProcRicSubsDeleteRsp
+ *
+ * Functionality: Processes the Ric Subs delete rsp msg
+ *
+ * @params[in]
+ * Ric Subs delete rsp information
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void ProcRicSubsDeleteRsp(uint32_t duId, RICsubscriptionDeleteResponse_t *ricSubsDeleteRsp)
+{
+ uint8_t ieIdx = 0;
+ uint8_t duIdx= 0;
+ uint16_t ranFuncId=0;
+ RanFunction *ranFuncDb = NULLP;
+ RicRequestId ricReqId;
+ DuDb *duDb = NULLP;
+ RicSubscription *ricSubs = NULLP;
+ CmLList *ricSubsNode = NULLP;
+
+ SEARCH_DU_DB(duIdx, duId, duDb);
+ if(duDb == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : duDb is not present for duId %d",duId);
+ return;
+ }
+
+ if(!ricSubsDeleteRsp)
+ {
+ DU_LOG("\nERROR --> E2AP : ricSubsDeleteRsp pointer is null");
+ return;
+ }
+
+ if(!ricSubsDeleteRsp->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : ricSubsDeleteRsp array pointer is null");
+ return;
+ }
+ for(ieIdx=0; ieIdx < ricSubsDeleteRsp->protocolIEs.list.count; ieIdx++)
+ {
+ if(ricSubsDeleteRsp->protocolIEs.list.array[ieIdx])
+ {
+ switch(ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_RICrequestID:
+ {
+ ricReqId.requestorId = ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->value.choice.RICrequestID.ricRequestorID;
+ ricReqId.instanceId = ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->value.choice.RICrequestID.ricInstanceID;
+ break;
+ }
+ case ProtocolIE_IDE2_id_RANfunctionID:
+ {
+ ranFuncId = ricSubsDeleteRsp->protocolIEs.list.array[ieIdx]->value.choice.RANfunctionID;
+ ranFuncDb = fetchRanFuncFromRanFuncId(duDb, ranFuncId);
+ if(!ranFuncDb)
+ {
+ DU_LOG("\nERROR --> E2AP : Invalid Ran Function id %d received",ranFuncId);
+ return;
+ }
+
+ ricSubs = fetchSubsInfoFromRicReqId(ricReqId, ranFuncDb, &ricSubsNode);
+ if(ricSubs)
+ {
+ deleteRicSubscriptionNode(ricSubsNode);
+ DU_LOG("\nINFO --> E2AP : Ric subscription node deleted successfully");
+ }
+ else
+ {
+ DU_LOG("\nERROR --> E2AP : Ric subscription node is not present ");
+ return;
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+/*******************************************************************
+*
+* @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;