+ modCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForModification_List;
+ for(arrIdx = 0; arrIdx < modCfmList->list.count; arrIdx++)
+ {
+ modCfmListItem = (RICaction_ConfirmedForModification_ItemIEs_t *)modCfmList->list.array[arrIdx];
+ actionId = modCfmListItem->value.choice.RICaction_ConfirmedForModification_Item.ricActionID;
+
+ actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb, &actionNode, CONFIG_UNKNOWN);
+ if(!actionDb)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId);
+ }
+ else
+ {
+ actionDb->action = CONFIG_UNKNOWN;
+ /* Further handling can be added here in future once the
+ * use case of this procedure is identified */
+ }
+ actionDb = NULLP;
+ }
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_RICactionsRefusedToBeModified_List:
+ {
+ modRefusedList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeModified_List;
+ for(arrIdx = 0; arrIdx < modRefusedList->list.count; arrIdx++)
+ {
+ modRefusedListItem = (RICaction_RefusedToBeModified_ItemIEs_t *)modRefusedList->list.array[arrIdx];
+ actionId = modRefusedListItem->value.choice.RICaction_RefusedToBeModified_Item.ricActionID;
+ actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb, &actionNode, CONFIG_UNKNOWN);
+ if(!actionDb)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId);
+ }
+ else
+ {
+ /* Spec doesnt mention if in case of failure, DU should retry for modify action
+ * Hence, chaging the action from CONFIG_MOD to CONFIG_UNKNOWN
+ */
+ actionDb->action = CONFIG_UNKNOWN;
+ }
+ actionDb = NULLP;
+ }
+ break;
+ }
+#endif
+
+ case ProtocolIE_IDE2_id_RICactionsConfirmedForRemoval_List:
+ {
+ rmvCfmList = &ricSubsModCfmIe->value.choice.RICactions_ConfirmedForRemoval_List;
+ for(arrIdx = 0; arrIdx < rmvCfmList->list.count; arrIdx++)
+ {
+ rmvCfmListItem = (RICaction_ConfirmedForRemoval_ItemIEs_t *)rmvCfmList->list.array[arrIdx];
+ actionId = rmvCfmListItem->value.choice.RICaction_ConfirmedForRemoval_Item.ricActionID;
+ actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb, &actionNode, CONFIG_UNKNOWN);
+ if(!actionDb)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId);
+ }
+ else
+ {
+ cmLListDelFrm(&ricSubsDb->actionSequence, actionNode);
+ deleteActionSequence(actionNode);
+ actionDb =NULLP;
+ /* Further handling can include :
+ * Deletion of this action from all DU layers
+ */
+ }
+ actionDb = NULLP;
+ }
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_RICactionsRefusedToBeRemoved_List:
+ {
+ rmvFailList = &ricSubsModCfmIe->value.choice.RICactions_RefusedToBeRemoved_List;
+ for(arrIdx = 0; arrIdx < rmvFailList->list.count; arrIdx++)
+ {
+ rmvFailListItem = (RICaction_RefusedToBeRemoved_ItemIEs_t *)rmvFailList->list.array[arrIdx];
+ actionId = rmvFailListItem->value.choice.RICaction_RefusedToBeRemoved_Item.ricActionID;
+ actionDb = fetchActionInfoFromActionId(actionId, ricSubsDb, &actionNode, CONFIG_UNKNOWN);
+ if(!actionDb)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Action ID [%d] not found", __func__, actionId);
+ }
+ else
+ {
+ actionDb->action = CONFIG_UNKNOWN;
+ }
+ actionDb = NULLP;
+ }
+ break;
+ }
+
+ default:
+ break;
+ } /* End of switch for Protocol IE Id */
+
+ if(procFailure)
+ break;
+ } /* End of for loop for Protocol IE list */
+
+ break;
+ }while(true);
+
+ freeAperDecodingOfRicSubsModConfirm(e2apMsg);
+ return;
+}
+
+/******************************************************************
+* @brief Deallocate the memory allocated for E2 Reset Response
+*
+* @details
+*
+* Function : FreeE2ResetResponse
+*
+* Functionality:
+* - freeing the memory allocated for E2ResetResponse
+*
+* @params[in] E2AP_PDU_t *e2apMsg
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+void FreeE2ResetResponse(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0;
+ ResetResponseE2_t *resetResponse;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.successfulOutcome != NULLP)
+ {
+ resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;
+ if(resetResponse->protocolIEs.list.array)
+ {
+ for(ieIdx=0; ieIdx < resetResponse->protocolIEs.list.count; ieIdx++)
+ {
+ if(resetResponse->protocolIEs.list.array[ieIdx])
+ {
+ DU_FREE(resetResponse->protocolIEs.list.array[ieIdx], sizeof(ResetResponseIEs_t));
+ }
+ }
+ DU_FREE(resetResponse->protocolIEs.list.array, resetResponse->protocolIEs.list.size);
+ }
+
+ DU_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ }
+ DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 Reset Response msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendE2ResetResponse
+ *
+ * Functionality:
+ * - Buld and send the E2 Reset Response Message
+ *
+ * @params[in] Trans Id
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildAndSendResetResponse(uint16_t transId)
+{
+ uint8_t ieIdx = 0, elementCnt = 0;
+ uint8_t ret = RFAILED;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ ResetResponseE2_t *resetResponse;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ DU_LOG("\nINFO --> E2AP : Building E2 Reset Response Message\n");
+ do
+ {
+ DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse(): Memory allocation for E2AP-PDU failed");
+ break;
+ }
+ e2apMsg->present = E2AP_PDU_PR_successfulOutcome;
+
+ DU_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ if(e2apMsg->choice.successfulOutcome == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse: Memory allocation failed for successfulOutcome");
+ break;
+ }
+
+ e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_Reset;
+ e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_ResetResponseE2;
+ resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;
+
+ elementCnt = 1;
+ resetResponse->protocolIEs.list.count = elementCnt;
+ resetResponse->protocolIEs.list.size = elementCnt * sizeof(ResetResponseIEs_t *);
+ DU_ALLOC(resetResponse->protocolIEs.list.array, resetResponse->protocolIEs.list.size);
+ if(!resetResponse->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse: Memory allocation failed for protocol IE array");
+ break;
+ }
+
+ for(ieIdx=0; ieIdx < elementCnt; ieIdx++)
+ {
+ DU_ALLOC(resetResponse->protocolIEs.list.array[ieIdx], sizeof(ResetResponseIEs_t));
+ if(!resetResponse->protocolIEs.list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : BuildAndSendResetResponse: Memory allocation failed for protocol IE array element");
+ break;
+ }
+ }
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ resetResponse->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ resetResponse->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ resetResponse->protocolIEs.list.array[ieIdx]->value.present = ResetResponseIEs__value_PR_TransactionID;
+ resetResponse->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 reset 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 Reset Response \n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Reset Response");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeE2ResetResponse(e2apMsg);
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Deallocation of memory allocated by aper decoder for reset req
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfE2ResetReq
+ *
+ * Functionality: Deallocation of memory allocated by aper decoder for
+ * reset req
+ *
+ * @params[in] Pointer to resetReq
+ * @return void
+ *
+ * ****************************************************************/
+void freeAperDecodingOfE2ResetReq(ResetRequestE2_t *resetReq)
+{
+ uint8_t arrIdx=0;
+
+ if(resetReq)
+ {
+ if(resetReq->protocolIEs.list.array)
+ {
+ for(arrIdx=0; arrIdx<resetReq->protocolIEs.list.count; arrIdx++)
+ {
+ if(resetReq->protocolIEs.list.array[arrIdx])
+ {
+ free(resetReq->protocolIEs.list.array[arrIdx]);
+ }
+ }
+ free(resetReq->protocolIEs.list.array);
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Process reset req received from RIC
+ *
+ * @details
+ *
+ * Function : procE2ResetRequest
+ *
+ * Functionality: Process reset req received from RIC
+ *
+ * @param E2AP_PDU_t *e2apMsg
+ * @return void
+ *
+ ******************************************************************/
+
+void procE2ResetRequest(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t arrIdx =0;
+ uint16_t transId =0;
+ uint16_t ranFuncIdx=0;
+ ResetRequestE2_t *resetReq;
+
+ DU_LOG("\nINFO --> E2AP : E2 Reset request received");
+ resetReq = &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2;
+
+ for(arrIdx=0; arrIdx<resetReq->protocolIEs.list.count; arrIdx++)
+ {
+ switch(resetReq->protocolIEs.list.array[arrIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ transId = resetReq->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_CauseE2:
+ {
+ for(ranFuncIdx=0; ranFuncIdx<MAX_RAN_FUNCTION; ranFuncIdx++)
+ {
+ if(duCb.e2apDb.ranFunction[ranFuncIdx].id >0)
+ {
+ deleteRicSubscriptionList(&(duCb.e2apDb.ranFunction[ranFuncIdx].subscriptionList));
+ memset(&(duCb.e2apDb.ranFunction[ranFuncIdx].pendingSubsRspInfo), 0, MAX_PENDING_SUBSCRIPTION_RSP*sizeof(PendingSubsRspInfo));
+ }
+ }
+ break;
+ }
+ }
+ }
+ if(BuildAndSendResetResponse(transId) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build and send reset response");
+ }
+ freeAperDecodingOfE2ResetReq(resetReq);
+}
+
+/*******************************************************************
+ *
+ * @brief Free APER decoding of RIC Subscription Modification Refuse
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfRicSubsModRefuse
+ *
+ * Functionality: Free APER decoding of RIC Subscription
+ * Modification Refuse
+ *
+ * @param E2AP Message PDU
+ * @return void
+ *
+ ******************************************************************/
+void freeAperDecodingOfRicSubsModRefuse(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0;
+ RICsubscriptionModificationRefuse_t *ricSubsModRefuse = NULLP;
+
+ if(e2apMsg && e2apMsg->choice.unsuccessfulOutcome)
+ {
+ ricSubsModRefuse = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionModificationRefuse;
+ if(ricSubsModRefuse->protocolIEs.list.array)
+ {
+ for(ieIdx = 0; ieIdx < ricSubsModRefuse->protocolIEs.list.count; ieIdx++)
+ {
+ if(ricSubsModRefuse->protocolIEs.list.array[ieIdx])
+ free(ricSubsModRefuse->protocolIEs.list.array[ieIdx]);
+ }
+ free(ricSubsModRefuse->protocolIEs.list.array);
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Process RIC Subscription Modification Refuse Message
+ *
+ * @details
+ *
+ * Function : procRicSubscriptionModificationRefuse
+ *
+ * Functionality: Process RIC Subscription Modification Refuse
+ * Message received from RIC.
+ *
+ * @param E2AP Message PDU
+ * @return void
+ *
+ ******************************************************************/
+void procRicSubscriptionModificationRefuse(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx = 0;
+ uint16_t ranFuncId = 0;
+ RicRequestId ricReqId;
+ RICsubscriptionModificationRefuse_t *ricSubsModRefuse = NULLP;
+ RICsubscriptionModificationRefuse_IEs_t *ricSubsModRefuseIe = NULLP;
+ CauseE2_t *cause = NULLP;
+
+ DU_LOG("\nINFO --> E2AP : %s: Received RIC Subscription Modification Refuse", __func__);
+
+ do{
+ if(!e2apMsg)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: E2AP Message is NULL", __func__);
+ break;
+ }
+
+ if(!e2apMsg->choice.unsuccessfulOutcome)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Unsuccessful Outcome in E2AP message is NULL", __func__);
+ break;
+ }
+
+ ricSubsModRefuse = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionModificationRefuse;
+ if(!ricSubsModRefuse->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Array conatining E2AP message IEs is null", __func__);
+ break;
+ }
+
+ for(ieIdx = 0; ieIdx < ricSubsModRefuse->protocolIEs.list.count; ieIdx++)
+ {
+ if(!ricSubsModRefuse->protocolIEs.list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : %s: IE at index [%d] in E2AP message IEs list is null", __func__, ieIdx);
+ break;
+ }
+
+ ricSubsModRefuseIe = ricSubsModRefuse->protocolIEs.list.array[ieIdx];
+ switch(ricSubsModRefuseIe->id)
+ {
+ case ProtocolIE_IDE2_id_RICrequestID:
+ {
+ memset(&ricReqId, 0, sizeof(RicRequestId));
+ ricReqId.requestorId = ricSubsModRefuseIe->value.choice.RICrequestID.ricRequestorID;
+ ricReqId.instanceId = ricSubsModRefuseIe->value.choice.RICrequestID.ricInstanceID;
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_RANfunctionID:
+ {
+ ranFuncId = ricSubsModRefuseIe->value.choice.RANfunctionID;
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_CauseE2:
+ {
+ DU_LOG("\nDEBUG --> E2AP : %s: RIC subscriptiom modification refused for RIC_Requestor_ID [%d] \
+ RIC_Instance_ID [%d] RAN_Function_ID [%d] ", __func__, ricReqId.requestorId, \
+ ricReqId.instanceId, ranFuncId);
+
+ cause = &ricSubsModRefuseIe->value.choice.CauseE2;
+ printE2ErrorCause(cause);
+ }
+
+ default:
+ break;
+ } /* End of switch for Protocol IE Id */
+ } /* End of for loop for Protocol IE list */
+
+ break;
+ }while(true);
+
+ freeAperDecodingOfRicSubsModRefuse(e2apMsg);
+ return;
+}
+
+/*******************************************************************
+ *
+ * @brief Free RIC Subscription Delete Required Message
+ *
+ * @details
+ *
+ * Function : FreeRicSubscriptionDeleteRequired
+ *
+ * Functionality: Free RIC Subscription Delete Required
+ *
+ * @param E2AP Message PDU
+ * @return void
+ *
+ ******************************************************************/
+void FreeRicSubscriptionDeleteRequired(E2AP_PDU_t *e2apMsg, CmLListCp *ricSubsToBeDelList)
+{
+ uint8_t ieIdx = 0, arrIdx = 0;
+ RICsubscriptionDeleteRequired_t *ricSubsDelRqd = NULLP;
+ RICsubscriptionDeleteRequired_IEs_t *ricSubsDelRqdIe = NULLP;
+ RICsubscription_List_withCause_t *ricSubsList = NULLP;
+ CmLList *subsNode = NULLP;
+
+ if(e2apMsg)
+ {
+ if(e2apMsg->choice.initiatingMessage)
+ {
+ ricSubsDelRqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequired;
+ if(ricSubsDelRqd->protocolIEs.list.array)
+ {
+ for(ieIdx = 0; ieIdx < ricSubsDelRqd->protocolIEs.list.count; ieIdx++)
+ {
+ if(ricSubsDelRqd->protocolIEs.list.array[ieIdx])
+ {
+ ricSubsDelRqdIe = ricSubsDelRqd->protocolIEs.list.array[ieIdx];
+ switch(ricSubsDelRqdIe->id)
+ {
+ case ProtocolIE_IDE2_id_RICsubscriptionToBeRemoved:
+ {
+ ricSubsList = &ricSubsDelRqdIe->value.choice.RICsubscription_List_withCause;
+ if(ricSubsList->list.array)
+ {
+ for(arrIdx = 0; arrIdx < ricSubsList->list.count; arrIdx++)
+ {
+ DU_FREE(ricSubsList->list.array[ieIdx], sizeof(RICsubscription_withCause_ItemIEs_t));
+ }
+ DU_FREE(ricSubsList->list.array, ricSubsList->list.size);
+ }
+ break;
+ }
+ }
+ DU_FREE(ricSubsDelRqd->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteRequired_IEs_t));
+ }
+ }
+ DU_FREE(ricSubsDelRqd->protocolIEs.list.array, ricSubsDelRqd->protocolIEs.list.size);
+ }
+ DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
+ }
+ DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));;
+ }
+
+ if(ricSubsToBeDelList)
+ {
+ CM_LLIST_FIRST_NODE(ricSubsToBeDelList, subsNode);
+ while(subsNode)
+ {
+ cmLListDelFrm(ricSubsToBeDelList, subsNode);
+ DU_FREE(subsNode, sizeof(CmLList));
+ CM_LLIST_FIRST_NODE(ricSubsToBeDelList, subsNode);
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Fill list of RIC subscriptions required to be deleted
+ * with the cause of deletion
+ *
+ * @details
+ *
+ * Function : fillRicSubsListWithCause
+ *
+ * Functionality: Fill list of RIC subscriptions required to be
+ * deleted with the cause of deletion
+ *
+ * @param E2AP Message PDU
+ * @return void
+ *
+ ******************************************************************/
+uint8_t fillRicSubsListWithCause(RICsubscription_List_withCause_t *ricSubsList, CmLListCp ricSubsToBeDelList)
+{
+ uint16_t ieIdx = 0;
+ CmLList *subsNode = NULLP;
+ RicSubscription *subsInfo = NULLP;
+ RICsubscription_withCause_ItemIEs_t *subsItemIe = NULLP;
+ RICsubscription_withCause_Item_t *subsItem = NULLP;
+
+ ricSubsList->list.count = ricSubsToBeDelList.count;
+ ricSubsList->list.size = ricSubsList->list.count * sizeof(RICsubscription_withCause_ItemIEs_t *);
+ DU_ALLOC(ricSubsList->list.array, ricSubsList->list.size);
+ if(!ricSubsList->list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ return RFAILED;
+ }
+
+ CM_LLIST_FIRST_NODE(&ricSubsToBeDelList, subsNode);
+ while(subsNode && (ieIdx < ricSubsList->list.count))
+ {
+ subsInfo = (RicSubscription *)subsNode->node;
+ DU_ALLOC(ricSubsList->list.array[ieIdx], sizeof(RICsubscription_withCause_ItemIEs_t));
+ if(!ricSubsList->list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ return RFAILED;
+ }
+
+ subsItemIe = (RICsubscription_withCause_ItemIEs_t *)ricSubsList->list.array[ieIdx];
+ subsItemIe->id = ProtocolIE_IDE2_id_RICsubscription_withCause_Item;
+ subsItemIe->criticality = CriticalityE2_ignore;
+ subsItemIe->value.present = RICsubscription_withCause_ItemIEs__value_PR_RICsubscription_withCause_Item;
+
+ subsItem = & subsItemIe->value.choice.RICsubscription_withCause_Item;
+ subsItem->ricRequestID.ricRequestorID = subsInfo->requestId.requestorId;
+ subsItem->ricRequestID.ricInstanceID = subsInfo->requestId.instanceId;
+ subsItem->ranFunctionID = subsInfo->ranFuncId;
+ fillE2Cause(&subsItem->cause, subsInfo->failureCause);
+
+ ieIdx++;
+ subsNode = subsNode->next;
+ }
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and Send RIC Subscription delete required
+ *
+ * @details
+ *
+ * Function : BuildAndSendRicSubscriptionDeleteRequired
+ *
+ * Functionality: Build and send RIC subscription delete required.
+ * There can be 2 approaches to trigger following. One of these
+ * approaches may/may not be implemented in future:
+ * 1. It can be triggerred immediately when a RIC subscription's
+ * End Time has expired. In this case, only this subscription's
+ * info will be sent in this message.
+ * Since we have not yet added support to execute RIC
+ * Subscription based on Start Time and End Timer, this message is
+ * not triggered anywhere from DU APP yet.
+ * 2. Another approach is to have a periodic timer to check subscription
+ * status running in background.
+ * When RIC Subscription End Time expires, this subscription is
+ * marked to be deleted. Later when this background timer expires,
+ * a RIC Subscription delete required is sent with all the
+ * subscription's info which is marked to be deleted.
+ * The following function is implemented keeping in mind the second
+ * approach.
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+uint8_t BuildAndSendRicSubscriptionDeleteRequired()
+{
+ uint8_t elementCnt = 0, ieIdx = 0, ret = RFAILED;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ RICsubscriptionDeleteRequired_t *ricSubsDelRqd = NULLP;
+ RICsubscriptionDeleteRequired_IEs_t *ricSubsDelRqdIe = NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+ CmLListCp ricSubsToBeDelList;
+
+ while(true)
+ {
+ /* Check if there are any RIC subscriptions to be deleted */
+ cmLListInit(&ricSubsToBeDelList);
+ fetchRicSubsToBeDeleted(&ricSubsToBeDelList);
+ if(ricSubsToBeDelList.count == 0)
+ {
+ DU_LOG("\nDEBUG --> E2AP : %s: No RIC subscriptions are required to be deleted", __func__);
+ return ROK;
+ }
+
+ DU_LOG("\nINFO --> E2AP : Building RIC Subscription Delete Required Message\n");
+
+ DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ break;
+ }
+
+ e2apMsg->present = E2AP_PDU_PR_initiatingMessage;
+ DU_ALLOC(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
+ if(e2apMsg->choice.initiatingMessage == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ break;
+ }
+ e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICsubscriptionDeleteRequired;
+ e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
+ e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICsubscriptionDeleteRequired;
+
+ ricSubsDelRqd = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequired;
+
+ elementCnt = 1;
+ ricSubsDelRqd->protocolIEs.list.count = elementCnt;
+ ricSubsDelRqd->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionDeleteRequired_IEs_t *);
+
+ DU_ALLOC(ricSubsDelRqd->protocolIEs.list.array, ricSubsDelRqd->protocolIEs.list.size);
+ if(ricSubsDelRqd->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for array elements at line %d",__func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx = 0; ieIdx < elementCnt; ieIdx++)
+ {
+ DU_ALLOC(ricSubsDelRqd->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteRequired_IEs_t));
+ if(ricSubsDelRqd->protocolIEs.list.array[ieIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for index [%d] at line %d", \
+ __func__, ieIdx, __LINE__);
+ break;
+ }
+ }
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ ricSubsDelRqdIe = ricSubsDelRqd->protocolIEs.list.array[ieIdx];
+ ricSubsDelRqdIe->id = ProtocolIE_IDE2_id_RICsubscriptionToBeRemoved;
+ ricSubsDelRqdIe->criticality = CriticalityE2_ignore;
+ ricSubsDelRqdIe->value.present = RICsubscriptionDeleteRequired_IEs__value_PR_RICsubscription_List_withCause;
+ if(fillRicSubsListWithCause(&ricSubsDelRqdIe->value.choice.RICsubscription_List_withCause, ricSubsToBeDelList)\
+ != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Failed to fill RIC Subscription list with cause", __func__);
+ break;
+ }
+
+ /* Prints the Msg formed */
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Delete Required Message (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Subscription Delete Required Message \n");
+#ifdef DEBUG_ASN_PRINT
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+#endif
+ }
+
+ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send RIC Susbcription Delete Required Message");
+
+ }
+ ret = ROK;
+ break;
+ }
+
+ FreeRicSubscriptionDeleteRequired(e2apMsg, &ricSubsToBeDelList);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Free RIC Subscription Delete Failure Message
+ *
+ * @details
+ *
+ * Function : FreeRicSubscriptionDeleteFailure
+ *
+ * Functionality: Free RIC Subscription Delete Failure
+ *
+ * @param E2AP Message PDU
+ * @return void
+ *
+ ******************************************************************/
+void FreeRicSubscriptionDeleteFailure(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx = 0;
+ RICsubscriptionDeleteFailure_t *ricSubsDelFailure = NULLP;
+
+ if(e2apMsg)
+ {
+ if(e2apMsg->choice.unsuccessfulOutcome)
+ {
+ ricSubsDelFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionDeleteFailure;
+ if(ricSubsDelFailure->protocolIEs.list.array)
+ {
+ for(ieIdx = 0; ieIdx < ricSubsDelFailure->protocolIEs.list.count; ieIdx++)
+ {
+ DU_FREE(ricSubsDelFailure->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteFailure_IEs_t));
+ }
+ DU_FREE(ricSubsDelFailure->protocolIEs.list.array, ricSubsDelFailure->protocolIEs.list.size);
+ }
+ DU_FREE(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t));
+ }
+ DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));;
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and Send RIC Subscription Delete Failure
+ *
+ * @details
+ *
+ * Function : BuildAndSendRicSubscriptionDeleteFailure
+ *
+ * Functionality: Build and send RIC Subscription Delete Failure.
+ *
+ * @params[in]
+ * Ran Func Id
+ * Ric Req Id
+ * E2 failure cause
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+uint8_t BuildAndSendRicSubscriptionDeleteFailure(uint16_t ranFuncId, RicRequestId requestId, E2FailureCause failureCause)
+{
+ uint8_t elementCnt = 0, ieIdx = 0, ret = RFAILED;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ RICsubscriptionDeleteFailure_t *ricSubsDelFailure = NULLP;
+ RICsubscriptionDeleteFailure_IEs_t *ricSubsDelFailureIe = NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ while(true)
+ {
+ DU_LOG("\nINFO --> E2AP : Building RIC Subscription Delete Failure Message\n");
+
+ DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ break;
+ }
+
+ e2apMsg->present = E2AP_PDU_PR_unsuccessfulOutcome;
+ DU_ALLOC(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t));
+ if(e2apMsg->choice.unsuccessfulOutcome == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ break;
+ }
+ e2apMsg->choice.unsuccessfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscriptionDelete;
+ e2apMsg->choice.unsuccessfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.unsuccessfulOutcome->value.present = UnsuccessfulOutcomeE2__value_PR_RICsubscriptionDeleteFailure;
+
+
+ ricSubsDelFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.RICsubscriptionDeleteFailure;
+
+ elementCnt = 3;
+ ricSubsDelFailure->protocolIEs.list.count = elementCnt;
+ ricSubsDelFailure->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionDeleteFailure_IEs_t *);
+
+ DU_ALLOC(ricSubsDelFailure->protocolIEs.list.array, ricSubsDelFailure->protocolIEs.list.size);
+ if(ricSubsDelFailure->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for array elements at line %d",__func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx = 0; ieIdx < elementCnt; ieIdx++)
+ {
+ DU_ALLOC(ricSubsDelFailure->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteFailure_IEs_t));
+ if(ricSubsDelFailure->protocolIEs.list.array[ieIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for index [%d] at line %d", \
+ __func__, ieIdx, __LINE__);
+ break;
+ }
+ }
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ ricSubsDelFailureIe = ricSubsDelFailure->protocolIEs.list.array[ieIdx];
+ ricSubsDelFailureIe->id = ProtocolIE_IDE2_id_RICrequestID;
+ ricSubsDelFailureIe->criticality = CriticalityE2_reject;
+ ricSubsDelFailureIe->value.present = RICsubscriptionDeleteFailure_IEs__value_PR_RICrequestID;
+ ricSubsDelFailureIe->value.choice.RICrequestID.ricRequestorID= requestId.requestorId;
+ ricSubsDelFailureIe->value.choice.RICrequestID.ricInstanceID = requestId.instanceId;
+
+ ieIdx++;
+ ricSubsDelFailureIe = ricSubsDelFailure->protocolIEs.list.array[ieIdx];
+ ricSubsDelFailureIe->id = ProtocolIE_IDE2_id_RANfunctionID;
+ ricSubsDelFailureIe->criticality = CriticalityE2_reject;
+ ricSubsDelFailureIe->value.present = RICsubscriptionDeleteFailure_IEs__value_PR_RANfunctionID;
+ ricSubsDelFailureIe->value.choice.RANfunctionID = ranFuncId;
+
+ ieIdx++;
+ ricSubsDelFailureIe = ricSubsDelFailure->protocolIEs.list.array[ieIdx];
+ ricSubsDelFailureIe->id = ProtocolIE_IDE2_id_CauseE2;
+ ricSubsDelFailureIe->criticality = CriticalityE2_ignore;
+ ricSubsDelFailureIe->value.present = RICsubscriptionDeleteFailure_IEs__value_PR_CauseE2;
+ fillE2Cause(&ricSubsDelFailureIe->value.choice.CauseE2, failureCause);
+
+ /* Prints the Msg formed */
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Delete Failure Message (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Subscription Delete Failure Message \n");
+#ifdef DEBUG_ASN_PRINT
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+#endif
+ }
+
+ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send RIC Susbcription Delete Failure Message");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }
+
+ FreeRicSubscriptionDeleteFailure(e2apMsg);
+ return ret;
+}
+
+
+/*******************************************************************
+ *
+ * @brief Free RIC Subscription Delete Response Message
+ *
+ * @details
+ *
+ * Function : FreeRicSubscriptionDeleteResponse
+ *
+ * Functionality: Free RIC Subscription Delete Response
+ *
+ * @param E2AP Message PDU
+ * @return void
+ *
+ ******************************************************************/
+void FreeRicSubscriptionDeleteResponse(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx = 0;
+ RICsubscriptionDeleteResponse_t *ricSubsDelRsp = NULLP;
+
+ if(e2apMsg)
+ {
+ if(e2apMsg->choice.successfulOutcome)
+ {
+ ricSubsDelRsp = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionDeleteResponse;
+ if(ricSubsDelRsp->protocolIEs.list.array)
+ {
+ for(ieIdx = 0; ieIdx < ricSubsDelRsp->protocolIEs.list.count; ieIdx++)
+ {
+ DU_FREE(ricSubsDelRsp->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteResponse_IEs_t));
+ }
+ DU_FREE(ricSubsDelRsp->protocolIEs.list.array, ricSubsDelRsp->protocolIEs.list.size);
+ }
+ DU_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ }
+ DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));;
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and Send RIC Subscription delete Response
+ *
+ * @details
+ *
+ * Function : BuildAndSendRicSubscriptionDeleteResponse
+ *
+ * Functionality: Build and send RIC subscription delete Response.
+ *
+ * @params[in]
+ * Ran Func Id
+ * Ric Req Id
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+uint8_t BuildAndSendRicSubscriptionDeleteResponse(uint16_t ranFuncId, RicRequestId requestId)
+{
+ uint8_t elementCnt = 0, ieIdx = 0, ret = RFAILED;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ RICsubscriptionDeleteResponse_t *ricSubsDelRsp = NULLP;
+ RICsubscriptionDeleteResponse_IEs_t *ricSubsDelRspIe = NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ while(true)
+ {
+ DU_LOG("\nINFO --> E2AP : Building RIC Subscription Delete Response Message\n");
+
+ DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+ if(e2apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ break;
+ }
+
+ e2apMsg->present = E2AP_PDU_PR_successfulOutcome;
+ DU_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ if(e2apMsg->choice.successfulOutcome == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation for E2AP-PDU failed at line %d",__func__, __LINE__);
+ break;
+ }
+ e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_RICsubscriptionDelete;
+ e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_RICsubscriptionDeleteResponse;
+
+
+ ricSubsDelRsp = &e2apMsg->choice.successfulOutcome->value.choice.RICsubscriptionDeleteResponse;
+
+ elementCnt = 2;
+ ricSubsDelRsp->protocolIEs.list.count = elementCnt;
+ ricSubsDelRsp->protocolIEs.list.size = elementCnt * sizeof(RICsubscriptionDeleteResponse_IEs_t *);
+
+ DU_ALLOC(ricSubsDelRsp->protocolIEs.list.array, ricSubsDelRsp->protocolIEs.list.size);
+ if(ricSubsDelRsp->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for array elements at line %d",__func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx = 0; ieIdx < elementCnt; ieIdx++)
+ {
+ DU_ALLOC(ricSubsDelRsp->protocolIEs.list.array[ieIdx], sizeof(RICsubscriptionDeleteResponse_IEs_t));
+ if(ricSubsDelRsp->protocolIEs.list.array[ieIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed for index [%d] at line %d", \
+ __func__, ieIdx, __LINE__);
+ break;
+ }
+ }
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ ricSubsDelRspIe = ricSubsDelRsp->protocolIEs.list.array[ieIdx];
+ ricSubsDelRspIe->id = ProtocolIE_IDE2_id_RICrequestID;
+ ricSubsDelRspIe->criticality = CriticalityE2_reject;
+ ricSubsDelRspIe->value.present = RICsubscriptionDeleteResponse_IEs__value_PR_RICrequestID;
+ ricSubsDelRspIe->value.choice.RICrequestID.ricRequestorID= requestId.requestorId;
+ ricSubsDelRspIe->value.choice.RICrequestID.ricInstanceID = requestId.instanceId;
+
+ ieIdx++;
+ ricSubsDelRspIe = ricSubsDelRsp->protocolIEs.list.array[ieIdx];
+ ricSubsDelRspIe->id = ProtocolIE_IDE2_id_RANfunctionID;
+ ricSubsDelRspIe->criticality = CriticalityE2_reject;
+ ricSubsDelRspIe->value.present = RICsubscriptionDeleteResponse_IEs__value_PR_RANfunctionID;
+ ricSubsDelRspIe->value.choice.RANfunctionID = ranFuncId;
+
+ /* Prints the Msg formed */
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode RIC Subscription Delete Response Message (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for RIC Subscription Delete Response Message \n");
+#ifdef DEBUG_ASN_PRINT
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+#endif
+ }
+
+ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send RIC Susbcription Delete Response Message");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }
+
+ FreeRicSubscriptionDeleteResponse(e2apMsg);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Free RIC Subscription Delete Request Message
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfRicSubsDeleteReq
+ *
+ * Functionality: Free RIC Subscription Delete Request
+ *
+ * @param E2AP Message PDU
+ * @return void
+ *
+ ******************************************************************/
+void freeAperDecodingOfRicSubsDeleteReq(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx = 0;
+ RICsubscriptionDeleteRequest_t *ricSubsDelReq = NULLP;
+
+ if(e2apMsg)
+ {
+ if(e2apMsg->choice.initiatingMessage)
+ {
+ ricSubsDelReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequest;
+ if(ricSubsDelReq->protocolIEs.list.array)
+ {
+ for(ieIdx = 0; ieIdx < ricSubsDelReq->protocolIEs.list.count; ieIdx++)
+ {
+ if(ricSubsDelReq->protocolIEs.list.array[ieIdx])
+ {
+ free(ricSubsDelReq->protocolIEs.list.array[ieIdx]);
+ }
+ }
+ free(ricSubsDelReq->protocolIEs.list.array);
+ }
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Process RIC Subscription delete request
+ *
+ * @details
+ *
+ * Function : procRicSubscriptionDeleteRequest
+ *
+ * Functionality: Process RIC subscription delete request.
+ * Fetch RAN Function and RIC subscription to be deleted.
+ * Send statistics delete request to MAC for all action sequence
+ * within this RIC subscription.
+ *
+ * @params[in] E2AP PDU
+ * @return void
+ *
+ ******************************************************************/
+void procRicSubscriptionDeleteRequest(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx = 0;
+ uint16_t ranFuncId = 0;
+ bool procFailure = false;
+ RicRequestId ricReqId;
+ RanFunction *ranFuncDb = NULLP;
+ CmLList *ricSubsNode = NULLP;
+ RicSubscription *ricSubsDb = NULLP;
+ RICsubscriptionDeleteRequest_t *ricSubsDelReq = NULLP;
+ RICsubscriptionDeleteRequest_IEs_t *ricSubsDelReqIe = NULLP;
+
+ DU_LOG("\nINFO --> E2AP : %s: Received RIC Subscription Delete Request", __func__);
+
+ do{
+ if(!e2apMsg)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: E2AP Message is NULL", __func__);
+ break;
+ }
+
+ if(!e2apMsg->choice.initiatingMessage)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Initiating Message in E2AP PDU is NULL", __func__);
+ break;
+ }
+
+ ricSubsDelReq = &e2apMsg->choice.initiatingMessage->value.choice.RICsubscriptionDeleteRequest;
+ if(!ricSubsDelReq->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: Array conatining E2AP message IEs is null", __func__);
+ break;
+ }
+
+ for(ieIdx = 0; ieIdx < ricSubsDelReq->protocolIEs.list.count; ieIdx++)
+ {
+ if(!ricSubsDelReq->protocolIEs.list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : %s: IE at index [%d] in E2AP message IEs list is null", __func__, ieIdx);
+ break;
+ }
+
+ ricSubsDelReqIe = ricSubsDelReq->protocolIEs.list.array[ieIdx];
+ switch(ricSubsDelReqIe->id)
+ {
+ case ProtocolIE_IDE2_id_RICrequestID:
+ {
+ memset(&ricReqId, 0, sizeof(RicRequestId));
+ ricReqId.requestorId = ricSubsDelReqIe->value.choice.RICrequestID.ricRequestorID;
+ ricReqId.instanceId = ricSubsDelReqIe->value.choice.RICrequestID.ricInstanceID;
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_RANfunctionID:
+ {
+ ranFuncId = ricSubsDelReqIe->value.choice.RANfunctionID;
+ ranFuncDb = fetchRanFuncFromRanFuncId(ranFuncId);
+ if(!ranFuncDb)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: RAN Function ID [%d] not found", __func__, ranFuncId);
+ procFailure = true;
+ break;
+ }
+
+ ricSubsDb = fetchSubsInfoFromRicReqId(ricReqId, ranFuncDb, &ricSubsNode);
+ if(!ricSubsDb)
+ {
+ DU_LOG("\nERROR --> E2AP : %s: RIC Subscription not found for Requestor_ID [%d] Instance_ID [%d]",\
+ __func__, ricReqId.requestorId, ricReqId.instanceId);
+ procFailure = true;
+ break;
+ }
+
+ if(BuildAndSendStatsDeleteReq(ricSubsDb, true) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build and send ric subscription delete req to du layers");
+ }
+ break;
+ }
+
+ default:
+ break;
+ } /* End of switch for Protocol IE Id */
+
+ if(procFailure)
+ break;
+ } /* End of for loop for Protocol IE list */
+
+ break;
+ }while(true);
+
+ freeAperDecodingOfRicSubsDeleteReq(e2apMsg);
+ return;
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for E2 node configuration
+ * update ack msg by aper decoder
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfE2NodeConfigUpdateAck
+ *
+ * Functionality:
+ * - Deallocate the memory allocated for E2 node configuration
+ * update ack msg by aper decoder
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+void freeAperDecodingOfE2NodeConfigUpdateAck(E2nodeConfigurationUpdateAcknowledge_t *updateAckMsg)
+{
+ uint8_t arrIdx =0, e2NodeConfigIdx=0;
+ 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;
+
+ E2nodeComponentInterfaceF1_t *f1InterfaceInfo=NULLP;
+ 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)
+ {
+ switch(additionAckItemIte->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.present)
+ {
+ case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1:
+ {
+ f1InterfaceInfo = additionAckItemIte->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1;
+ free(f1InterfaceInfo->gNB_DU_ID.buf);
+ free(f1InterfaceInfo);
+ break;
+ }
+ default:
+ break;
+ }
+ free(additionAckItemIte);
+ }
+ free(additionAckList->list.array);
+ }
+ 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)
+ {
+ switch(updateAckItemIe->value.choice.E2nodeComponentConfigUpdateAck_Item.e2nodeComponentID.present)
+ {
+ case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1:
+ {
+ f1InterfaceInfo = updateAckItemIe->value.choice.E2nodeComponentConfigUpdateAck_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1;
+ free(f1InterfaceInfo->gNB_DU_ID.buf);
+ free(f1InterfaceInfo);
+ break;
+ }
+ default:
+ break;
+ }
+ free(updateAckItemIe);
+ }
+ }
+ free(updateAckList->list.array);
+ }
+ 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)
+ {
+ switch(removalAckItemIe->value.choice.E2nodeComponentConfigRemovalAck_Item.e2nodeComponentID.present)
+ {
+ case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1:
+ {
+ f1InterfaceInfo = removalAckItemIe->value.choice.E2nodeComponentConfigRemovalAck_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1;
+ free(f1InterfaceInfo->gNB_DU_ID.buf);
+ free(f1InterfaceInfo);
+ break;
+ }
+ default:
+ break;
+ }
+ free(removalAckItemIe);
+ }
+ }
+ free(removalAckList->list.array);
+ }
+ break;
+ }
+ }
+ free(updateAckMsg->protocolIEs.list.array[arrIdx]);
+ }
+ }
+ free(updateAckMsg->protocolIEs.list.array);
+ }
+}
+
+/******************************************************************
+ *
+ * @brief Processes the E2 node config update ack msg
+ *
+ * @details
+ *
+ * Function :procE2NodeConfigUpdateAck
+ *
+ * Functionality: Processes the E2 node config update ack msg
+ *
+ * @params[in] E2AP_PDU_t ASN decoded E2AP message
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+void procE2NodeConfigUpdateAck(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t arrIdx =0;
+ uint16_t e2CfgIdx =0;
+ E2nodeConfigurationUpdateAcknowledge_t *e2NodeConfigUpdateAck =NULLP;
+ E2nodeComponentConfigUpdateAck_List_t *e2NodeConfigUpdateAckList=NULLP;
+ E2nodeComponentConfigUpdateAck_ItemIEs_t *e2NodeUpdateAckItem=NULLP;
+ E2nodeComponentConfigRemovalAck_List_t *e2NodeConfigRemovalAckList=NULLP;
+ E2nodeComponentConfigRemovalAck_ItemIEs_t *e2NodeRemovalAckItem=NULLP;
+ E2nodeComponentConfigAdditionAck_List_t *e2NodeConfigAdditionAckList=NULLP;
+ E2nodeComponentConfigAdditionAck_ItemIEs_t *e2NodeAdditionAckItem=NULLP;
+
+ e2NodeConfigUpdateAck = &e2apMsg->choice.successfulOutcome->value.choice.E2nodeConfigurationUpdateAcknowledge;
+
+ if(e2NodeConfigUpdateAck->protocolIEs.list.array)
+ {
+ for(arrIdx =0; arrIdx<e2NodeConfigUpdateAck->protocolIEs.list.count; arrIdx++)
+ {
+ switch(e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
+ {
+ e2NodeConfigAdditionAckList = &e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
+ if(e2NodeConfigAdditionAckList->list.array)
+ {
+ for(e2CfgIdx = 0; e2CfgIdx< e2NodeConfigAdditionAckList->list.count; e2CfgIdx++)
+ {
+ e2NodeAdditionAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeConfigAdditionAckList->list.array[e2CfgIdx];
+ handleE2NodeConfigUpdateAckIes((PTR)&e2NodeAdditionAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item,\
+ ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck);
+ }
+ }
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck:
+ {
+ e2NodeConfigUpdateAckList = &e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigUpdateAck_List;
+ if(e2NodeConfigUpdateAckList->list.array)
+ {
+ for(e2CfgIdx = 0; e2CfgIdx< e2NodeConfigUpdateAckList->list.count; e2CfgIdx++)
+ {
+ e2NodeUpdateAckItem = (E2nodeComponentConfigUpdateAck_ItemIEs_t*) e2NodeConfigUpdateAckList->list.array[e2CfgIdx];
+ handleE2NodeConfigUpdateAckIes((PTR)&e2NodeUpdateAckItem->value.choice.E2nodeComponentConfigUpdateAck_Item,\
+ ProtocolIE_IDE2_id_E2nodeComponentConfigUpdateAck);
+ }
+ }
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck:
+ {
+ e2NodeConfigRemovalAckList = &e2NodeConfigUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigRemovalAck_List;
+ if(e2NodeConfigRemovalAckList->list.array)
+ {
+ for(e2CfgIdx = 0; e2CfgIdx< e2NodeConfigRemovalAckList->list.count; e2CfgIdx++)
+ {
+ e2NodeRemovalAckItem = (E2nodeComponentConfigRemovalAck_ItemIEs_t*) e2NodeConfigRemovalAckList->list.array[e2CfgIdx];
+ handleE2NodeConfigUpdateAckIes((PTR)&e2NodeRemovalAckItem->value.choice.E2nodeComponentConfigRemovalAck_Item,\
+ ProtocolIE_IDE2_id_E2nodeComponentConfigRemovalAck);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ freeAperDecodingOfE2NodeConfigUpdateAck(e2NodeConfigUpdateAck);
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for RemovalRequest msg
+ *
+ * @details
+ *
+ * Function : FreeRemovalRequest
+ *
+ * Functionality:
+ * - freeing the memory allocated for RemovalRequest
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void FreeRemovalRequest(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0;
+ E2RemovalRequest_t *removalReq = NULLP;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.initiatingMessage != NULLP)
+ {
+ removalReq = &e2apMsg->choice.initiatingMessage->value.choice.E2RemovalRequest;
+ if(removalReq->protocolIEs.list.array)
+ {
+ for(ieIdx = 0; ieIdx < removalReq->protocolIEs.list.count; ieIdx++)
+ {
+ DU_FREE(removalReq->protocolIEs.list.array[ieIdx], sizeof(E2RemovalRequestIEs_t));
+ }
+ DU_FREE(removalReq->protocolIEs.list.array, removalReq->protocolIEs.list.size);
+ }
+ DU_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
+ }
+ DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Build and send the removal request msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendRemovalRequest
+ *
+ * Functionality:
+ * - Buld and send the removal request msg to E2 node
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildAndSendRemovalRequest()
+{
+ uint16_t transId = 0;
+ uint8_t ret = RFAILED;
+ uint8_t ieIdx = 0, elementCnt = 0;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ E2RemovalRequest_t *removalReq = NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ DU_LOG("\nINFO --> E2AP : Building Removal Request\n");
+
+ do
+ {
+ DU_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;
+ DU_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_E2removal;
+ e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
+ e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_E2RemovalRequest;
+ removalReq = &e2apMsg->choice.initiatingMessage->value.choice.E2RemovalRequest;
+
+ elementCnt = 1;
+ removalReq->protocolIEs.list.count = elementCnt;
+ removalReq->protocolIEs.list.size = elementCnt * sizeof(E2RemovalRequestIEs_t *);
+
+ DU_ALLOC(removalReq->protocolIEs.list.array, removalReq->protocolIEs.list.size);
+ if(!removalReq->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx = 0; ieIdx < elementCnt; ieIdx++)
+ {
+ DU_ALLOC(removalReq->protocolIEs.list.array[ieIdx], sizeof(E2RemovalRequestIEs_t));
+ if(!removalReq->protocolIEs.list.array[ieIdx])
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+ }
+
+ /* In case of failure */
+ if(ieIdx < elementCnt)
+ break;
+
+ ieIdx = 0;
+ removalReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ removalReq->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ removalReq->protocolIEs.list.array[ieIdx]->value.present = E2RemovalRequestIEs__value_PR_TransactionID;
+ transId = assignTransactionId();
+ removalReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
+
+ /* Prints the Msg formed */
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf,\
+ encBuf);
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> E2AP : Could not encode removal request structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> E2AP : Created APER encoded buffer for removal request\n");
+#ifdef DEBUG_ASN_PRINT
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+#endif
+ }
+ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Sending removal request failed");
+ break;
+ }
+
+
+ ret = ROK;
+ duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
+ duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
+ break;
+ }while(true);
+
+ /* Free all memory */
+ FreeRemovalRequest(e2apMsg);
+
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Deallocation of memory allocated by aper decoder
+ * for Removal failure
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfE2RemovalFailure
+ *
+ * Functionality: Deallocation of memory allocated by aper decoder
+ * for Removal failure
+ *
+ * @params[in] Pointer to removalFailure
+ * @return void
+ *
+ * ****************************************************************/
+void freeAperDecodingOfE2RemovalFailure(E2RemovalFailure_t *removalFailure)
+{
+ uint8_t arrIdx=0;
+
+ if(removalFailure)
+ {
+ if(removalFailure->protocolIEs.list.array)
+ {
+ for(arrIdx=0; arrIdx<removalFailure->protocolIEs.list.count; arrIdx++)
+ {
+ if(removalFailure->protocolIEs.list.array[arrIdx])
+ {
+ free(removalFailure->protocolIEs.list.array[arrIdx]);
+ }
+ }
+ free(removalFailure->protocolIEs.list.array);
+ }
+ }
+}
+
+/******************************************************************
+ *
+ * @brief Processes the E2 removal failure msg
+ *
+ * @details
+ *
+ * Function : procE2RemovalFailure
+ *
+ * Functionality: Processes the E2 removal failure msg
+ *
+ * @params[in]
+ * E2AP_PDU_t *e2apMsg
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void ProcE2RemovalFailure(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx = 0;
+ uint16_t transId=0;
+ CauseE2_t *cause = NULLP;
+ E2RemovalFailure_t *e2RemovalFailure=NULLP;
+
+ e2RemovalFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2RemovalFailure;
+
+ 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;
+ if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
+ (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
+ {
+ memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
+ }
+ break;
+ }
+ case ProtocolIE_IDE2_id_CauseE2:
+ {
+ cause = &e2RemovalFailure->protocolIEs.list.array[ieIdx]->value.choice.CauseE2;
+ printE2ErrorCause(cause);
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%ld]", e2RemovalFailure->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ }
+ freeAperDecodingOfE2RemovalFailure(e2RemovalFailure);
+}
+
+ /******************************************************************
+ *
+ * @brief Deallocation of memory allocated by aper decoder
+ * for Removal failure
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfE2RemovalResponse
+ *
+ * Functionality: Deallocation of memory allocated by aper decoder
+ * for Removal failure
+ *
+ * @params[in] Pointer to removalResponse
+ * @return void
+ *
+ * ****************************************************************/
+ void freeAperDecodingOfE2RemovalResponse(E2RemovalResponse_t *removalResponse)
+ {
+ uint8_t arrIdx=0;
+
+ if(removalResponse)
+ {
+ if(removalResponse->protocolIEs.list.array)
+ {
+ for(arrIdx=0; arrIdx<removalResponse->protocolIEs.list.count; arrIdx++)
+ {
+ if(removalResponse->protocolIEs.list.array[arrIdx])
+ {
+ free(removalResponse->protocolIEs.list.array[arrIdx]);
+ }
+ }
+ free(removalResponse->protocolIEs.list.array);
+ }
+ }
+ }
+
+/*******************************************************************
+ *
+ * @brief process the E2 Removal Response
+ *
+ * @details
+ *
+ * Function : ProcE2RemovalResponse
+ *
+ * Functionality: Process E2 Removal Response
+ *
+ * @params[in]
+ * E2AP_PDU_t *e2apMsg
+ * @return void
+ *
+ ******************************************************************/
+
+void ProcE2RemovalResponse(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx = 0;
+ uint16_t transId=0;
+ E2RemovalResponse_t *removalRsp = NULLP;
+
+ removalRsp = &e2apMsg->choice.successfulOutcome->value.choice.E2RemovalResponse;
+
+ 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:
+ {
+ transId = removalRsp->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
+ if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
+ (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
+ {
+ DU_LOG("\nINFO --> E2AP : Sending request to close the sctp connection");
+ cmInetClose(&ricParams.sockFd);
+ memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+ removeE2NodeInformation();
+ }
+ else
+ {
+ DU_LOG("\nERROR --> E2AP : Invalid transaction id [%d]", transId);
+ }
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%ld]", removalRsp->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ }
+
+ freeAperDecodingOfE2RemovalResponse(removalRsp);
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for E2 Connection Update Failure
+ *
+ * @details
+ *
+ * Function : FreeE2ConnectionUpdateFailure
+ *
+ * Functionality:
+ * - freeing the memory allocated for E2ConnectionUpdateFailure
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void FreeE2ConnectionUpdateFailure(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0;
+ E2connectionUpdateFailure_t *e2ConnectionUpdateFailure=NULLP;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.unsuccessfulOutcome != NULLP)
+ {
+ e2ConnectionUpdateFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2connectionUpdateFailure;
+ if(e2ConnectionUpdateFailure->protocolIEs.list.array)
+ {
+ for(ieIdx=0; ieIdx < e2ConnectionUpdateFailure->protocolIEs.list.count; ieIdx++)
+ {
+ DU_FREE(e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdateFailure_IEs_t));
+ }
+ DU_FREE(e2ConnectionUpdateFailure->protocolIEs.list.array, e2ConnectionUpdateFailure->protocolIEs.list.size);
+ }
+ DU_FREE(e2apMsg->choice.unsuccessfulOutcome, sizeof(UnsuccessfulOutcomeE2_t));
+ }
+ DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 Connection Update Failure msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendE2ConnectionUpdateFailure
+ *
+ * Functionality:
+ * - Buld and send the E2 Connection Update Failure Message
+ * @params[in]
+ * Trans Id
+ * Failure Cause
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildAndSendE2ConnectionUpdateFailure(uint16_t transId, E2FailureCause failureCause)
+{
+ uint8_t ieIdx = 0, elementCnt = 0;
+ uint8_t ret = RFAILED;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ E2connectionUpdateFailure_t *e2ConnectionUpdateFailure=NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ DU_LOG("\nINFO --> E2AP : Building E2 Connection Update Failure Message\n");
+ do
+ {
+ DU_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;
+
+ DU_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_E2connectionUpdate;
+ e2apMsg->choice.unsuccessfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.unsuccessfulOutcome->value.present = UnsuccessfulOutcomeE2__value_PR_E2connectionUpdateFailure;
+ e2ConnectionUpdateFailure = &e2apMsg->choice.unsuccessfulOutcome->value.choice.E2connectionUpdateFailure;
+
+ elementCnt = 2;
+ e2ConnectionUpdateFailure->protocolIEs.list.count = elementCnt;
+ e2ConnectionUpdateFailure->protocolIEs.list.size = elementCnt * sizeof(E2connectionUpdateFailure_IEs_t *);
+ DU_ALLOC(e2ConnectionUpdateFailure->protocolIEs.list.array, e2ConnectionUpdateFailure->protocolIEs.list.size);
+ if(!e2ConnectionUpdateFailure->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx=0; ieIdx < elementCnt; ieIdx++)
+ {
+ DU_ALLOC(e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdateFailure_IEs_t));
+ if(!e2ConnectionUpdateFailure->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;
+ e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateFailure_IEs__value_PR_TransactionID;
+ e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
+
+ /* Cause */
+ ieIdx++;
+ e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_CauseE2;
+ e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_ignore;
+ e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateFailure_IEs__value_PR_CauseE2;
+ fillE2Cause(&e2ConnectionUpdateFailure->protocolIEs.list.array[ieIdx]->value.choice.CauseE2, failureCause);
+
+ 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 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 Connection Update Failure \n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Connection Update Failure");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeE2ConnectionUpdateFailure(e2apMsg);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief fill E2 connection update item
+ *
+ * @details
+ *
+ * Function : fillE2connectionUpdateItem
+ *
+ * Functionality: fill E2 connection update item
+ *
+ * @params[in]
+ * E2connectionUpdate Item to be filled
+ * Protocol Id
+ * IP Address
+ * Usage
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t fillE2connectionUpdateItem(PTR connectionInfo, uint8_t protocolId, uint32_t ipAddress, AssocUsage usage)
+{
+ CauseE2_t *cause=NULLP;
+ TNLusage_t *tnlUsage=NULLP;
+ E2FailureCause failureCause;
+ TNLinformation_t *tnlInformation = NULLP;
+ E2connectionUpdate_Item_t *connectionModifyItem=NULLP;
+ E2connectionSetupFailed_Item_t *connectionRemoveITem=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_E2connectionSetupFailed_Item:
+ {
+ connectionRemoveITem = (E2connectionSetupFailed_Item_t*)connectionInfo;
+ tnlInformation= &connectionRemoveITem->tnlInformation;
+ cause = &connectionRemoveITem->cause;
+ break;
+ }
+ default:
+ return RFAILED;
+ }
+
+ tnlInformation->tnlAddress.size = 4*sizeof(uint8_t);
+ DU_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] = ipAddress & 0xFF;
+ tnlInformation->tnlAddress.buf[2] = (ipAddress>> 8) & 0xFF;
+ tnlInformation->tnlAddress.buf[1] = (ipAddress>> 16) & 0xFF;
+ tnlInformation->tnlAddress.buf[0] = (ipAddress>> 24) & 0xFF;
+ tnlInformation->tnlAddress.bits_unused = 0;
+
+ switch(protocolId)
+ {
+ case ProtocolIE_IDE2_id_E2connectionUpdate_Item:
+ {
+ *tnlUsage = usage;
+ break;
+ }
+ case ProtocolIE_IDE2_id_E2connectionSetupFailed_Item:
+ {
+ failureCause.causeType = E2_TRANSPORT;
+ failureCause.cause = E2_TRANSPORT_CAUSE_UNSPECIFIED;
+ fillE2Cause(cause, failureCause);
+ break;
+ }
+ default:
+ return RFAILED;
+ }
+ return ROK;
+}
+
+
+/*******************************************************************
+ *
+ * @brief Build E2 connection modification list
+ *
+ * @details
+ *
+ * Function :BuildE2ConnectionUpdateList
+ *
+ * Functionality: Build E2 connection modification list
+ *
+ * @params[in]
+ * E2 connection update list to be filled
+ * Count of E2 connection to be added in the list
+ * Received list of E2 connection
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2ConnectionUpdateList(E2connectionUpdate_List_t *connectionSetupList, uint8_t count, E2ConnectionItem *tmpConnectionList)
+{
+ uint8_t arrIdx = 0;
+ E2connectionUpdate_ItemIEs_t *connectionSetupItem=NULLP;
+
+ connectionSetupList->list.count = count;
+
+ connectionSetupList->list.size = connectionSetupList->list.count*sizeof(E2connectionUpdate_ItemIEs_t*);
+ DU_ALLOC(connectionSetupList->list.array, connectionSetupList->list.size);
+ if(connectionSetupList->list.array)
+ {
+ for(arrIdx = 0; arrIdx< connectionSetupList->list.count; arrIdx++)
+ {
+ DU_ALLOC(connectionSetupList->list.array[arrIdx], sizeof(E2connectionUpdate_ItemIEs_t));
+ if(connectionSetupList->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ return RFAILED;
+ }
+ connectionSetupItem = (E2connectionUpdate_ItemIEs_t*)connectionSetupList->list.array[arrIdx];
+ connectionSetupItem->id = ProtocolIE_IDE2_id_E2connectionUpdate_Item;
+ connectionSetupItem->criticality= CriticalityE2_ignore;
+ connectionSetupItem->value.present = E2connectionUpdate_ItemIEs__value_PR_E2connectionUpdate_Item;
+ if(fillE2connectionUpdateItem((PTR)&connectionSetupItem->value.choice.E2connectionUpdate_Item, ProtocolIE_IDE2_id_E2connectionUpdate_Item,\
+ tmpConnectionList[arrIdx].ipV4Addr, tmpConnectionList[arrIdx].usage) != 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 setup failed list
+ *
+ * @details
+ *
+ * Function : BuildE2ConnectionSetupFailedList
+ *
+ * Functionality: Build E2 connection setup failed list
+ *
+ * @params[in]
+ * E2 connection setup failed list to be filled
+ * Count of E2 connection to be added in the list
+ * Received list of E2 connection
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2ConnectionSetupFailedList(E2connectionSetupFailed_List_t *setupFailedList, uint8_t count, E2ConnectionItem *tmpConnectionList)
+{
+ uint8_t arrIdx = 0;
+ E2connectionSetupFailed_ItemIEs_t *setupFailedItem=NULLP;
+
+ setupFailedList->list.count = 1;
+
+ setupFailedList->list.size = setupFailedList->list.count*sizeof(E2connectionSetupFailed_ItemIEs_t *);
+ DU_ALLOC(setupFailedList->list.array, setupFailedList->list.size);
+ if(setupFailedList->list.array)
+ {
+ for(arrIdx = 0; arrIdx< setupFailedList->list.count; arrIdx++)
+ {
+ DU_ALLOC(setupFailedList->list.array[arrIdx], sizeof(E2connectionSetupFailed_ItemIEs_t));
+ if(setupFailedList->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ return RFAILED;
+ }
+ setupFailedItem = (E2connectionSetupFailed_ItemIEs_t*)setupFailedList->list.array[arrIdx];
+ setupFailedItem->id = ProtocolIE_IDE2_id_E2connectionSetupFailed_Item;
+ setupFailedItem->criticality= CriticalityE2_ignore;
+ setupFailedItem->value.present = E2connectionSetupFailed_ItemIEs__value_PR_E2connectionSetupFailed_Item;
+ if(fillE2connectionUpdateItem((PTR)&setupFailedItem->value.choice.E2connectionSetupFailed_Item, ProtocolIE_IDE2_id_E2connectionSetupFailed_Item,\
+ tmpConnectionList[arrIdx].ipV4Addr, tmpConnectionList[arrIdx].usage) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to fill E2 connection failed to 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 E2 Connection
+ * Update ack msg
+ *
+ * @details
+ *
+ * Function :FreeE2ConnectionUpdateAcknowledge
+ *
+ * Functionality:
+ * - freeing the memory allocated for E2 Connection
+ * Update ack msg
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+void FreeE2ConnectionUpdateAcknowledge(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t ieIdx =0, arrIdx=0;
+ E2connectionUpdateAcknowledge_t *connectionUpdate = NULLP;
+ E2connectionUpdate_List_t *connectionSetupList = NULLP;
+ E2connectionSetupFailed_List_t *setupFailedList = NULLP;
+
+ if(e2apMsg != NULLP)
+ {
+ if(e2apMsg->choice.successfulOutcome != NULLP)
+ {
+ connectionUpdate = &e2apMsg->choice.successfulOutcome->value.choice.E2connectionUpdateAcknowledge;
+ 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_E2connectionSetup:
+ {
+ connectionSetupList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List;
+ if(connectionSetupList->list.array)
+ {
+ for(arrIdx = 0; arrIdx < connectionSetupList->list.count; arrIdx++)
+ {
+ DU_FREE(connectionSetupList->list.array[arrIdx], sizeof(E2connectionUpdate_ItemIEs_t));
+ }
+ DU_FREE(connectionSetupList->list.array, connectionSetupList->list.size);
+ }
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_E2connectionSetupFailed:
+ {
+ setupFailedList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionSetupFailed_List;
+ if(setupFailedList->list.array)
+ {
+ for(arrIdx = 0; arrIdx < setupFailedList->list.count; arrIdx++)
+ {
+ DU_FREE(setupFailedList->list.array[arrIdx], sizeof(E2connectionSetupFailed_ItemIEs_t));
+ }
+ DU_FREE(setupFailedList->list.array, setupFailedList->list.size);
+ }
+ break;
+ }
+ }
+ DU_FREE(connectionUpdate->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdateAck_IEs_t));
+ }
+ }
+ DU_FREE(connectionUpdate->protocolIEs.list.array, connectionUpdate->protocolIEs.list.size);
+ }
+ DU_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+ }
+ DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 Connection Update Acknowledge msg
+ *
+ * @details
+ *
+ * Function : BuildAndSendE2ConnectionUpdateAcknowledge
+ *
+ * Functionality:
+ * - Buld and send the E2 Connection Update Acknowledge Message
+ * @params[in]
+ * Trans Id
+ * List of E2 connection needs to fill in IE
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildAndSendE2ConnectionUpdateAcknowledge(uint16_t transId, E2ConnectionList connectionInfoList)
+{
+ uint8_t ieIdx = 0, elementCnt = 0;
+ uint8_t ret = RFAILED;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ asn_enc_rval_t encRetVal;
+ E2connectionUpdateAcknowledge_t *e2ConnectionUpdateAcknowledge=NULLP;
+
+ DU_LOG("\nINFO --> E2AP : Building E2 Connection Update Acknowledge Message\n");
+ do
+ {
+ DU_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;
+
+ DU_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_E2connectionUpdate;
+ e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
+ e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_E2connectionUpdateAcknowledge;
+ e2ConnectionUpdateAcknowledge = &e2apMsg->choice.successfulOutcome->value.choice.E2connectionUpdateAcknowledge;
+
+ elementCnt = 1;
+ if(connectionInfoList.numOfE2ConnectionSetup)
+ elementCnt++;
+ if(connectionInfoList.numOfE2ConnectionFailedToSetup)
+ elementCnt++;
+
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.count = elementCnt;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.size = elementCnt * sizeof(E2connectionUpdateAck_IEs_t*);
+ DU_ALLOC(e2ConnectionUpdateAcknowledge->protocolIEs.list.array, e2ConnectionUpdateAcknowledge->protocolIEs.list.size);
+ if(!e2ConnectionUpdateAcknowledge->protocolIEs.list.array)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+ break;
+ }
+
+ for(ieIdx=0; ieIdx < elementCnt; ieIdx++)
+ {
+ DU_ALLOC(e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdateAck_IEs_t));
+ if(!e2ConnectionUpdateAcknowledge->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;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateAck_IEs__value_PR_TransactionID;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
+
+ if(connectionInfoList.numOfE2ConnectionSetup)
+ {
+ ieIdx++;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_E2connectionSetup;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateAck_IEs__value_PR_E2connectionUpdate_List;
+ if(BuildE2ConnectionUpdateList(&e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List, \
+ connectionInfoList.numOfE2ConnectionSetup, connectionInfoList.setupE2Connection) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Connection setup list");
+ break;
+ }
+ }
+
+ if(connectionInfoList.numOfE2ConnectionFailedToSetup)
+ {
+ ieIdx++;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->id = ProtocolIE_IDE2_id_E2connectionSetupFailed;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+ e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateAck_IEs__value_PR_E2connectionSetupFailed_List;
+ if(BuildE2ConnectionSetupFailedList(&e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.choice.E2connectionSetupFailed_List, \
+ connectionInfoList.numOfE2ConnectionFailedToSetup, connectionInfoList.failedToSetupE2Connection) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Connection failed to setup 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 acknowledge 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 Connection Update Acknowledge \n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ DU_LOG("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to send E2 Connection Update Acknowledge");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeE2ConnectionUpdateAcknowledge(e2apMsg);
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Deallocation of memory allocated by aper decoder for
+ * E2 Connection Update
+ *
+ * @details
+ *
+ * Function :freeAperDecodingOfE2ConnectionUpdate
+ *
+ * Functionality: Deallocation of memory allocated by aper decoder for
+ * E2 Connection Update
+ *
+ * @params[in] Pointer to connectionUpdate
+ * @return void
+ *
+ * ****************************************************************/
+
+void freeAperDecodingOfE2ConnectionUpdate(E2connectionUpdate_t *connectionUpdate)
+{
+ uint8_t ieIdx =0, arrIdx=0;
+ E2connectionUpdate_List_t *connectionToBeModifyList = NULLP;
+ E2connectionUpdateRemove_List_t *connectionToBeRemoveList = NULLP;
+
+ 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++)
+ {
+ free(connectionToBeModifyList->list.array[arrIdx]);
+ }
+ free(connectionToBeModifyList->list.array);
+ }
+ 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++)
+ {
+ free(connectionToBeRemoveList->list.array[arrIdx]);
+ }
+ free(connectionToBeRemoveList->list.array);
+ }
+ break;
+ }
+ }
+ free(connectionUpdate->protocolIEs.list.array[ieIdx]);
+ }
+ }
+ free(connectionUpdate->protocolIEs.list.array);
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Handling of E2 connection modification Ie
+ *
+ * @details
+ *
+ * Function : handleE2ConnectionModification
+ *
+ * Functionality: Handling of E2 connection modification Ie
+ *
+ * @param
+ * E2 Connection update list
+ * E2 connection list which needs to be filled
+ * @return void
+ *
+ ******************************************************************/
+
+void handleE2ConnectionModification(E2connectionUpdate_List_t *connectionUpdateList, E2ConnectionList *connectionInfoList)
+{
+ uint32_t ipAddress=0;
+ bool infoFound = false;
+ uint8_t arrIdx=0,idx=0, count =0;
+ E2connectionUpdate_ItemIEs_t *connectionModifyItem=NULLP;
+
+ if(connectionUpdateList->list.array)
+ {
+ for(arrIdx = 0; arrIdx < connectionUpdateList->list.count; arrIdx++)
+ {
+ connectionModifyItem= (E2connectionUpdate_ItemIEs_t*)connectionUpdateList->list.array[arrIdx];
+ bitStringToInt(&connectionModifyItem->value.choice.E2connectionUpdate_Item.tnlInformation.tnlAddress, &ipAddress);
+ for(idx=0; idx<duCb.e2apDb.numOfTNLAssoc; idx++)
+ {
+ /* If the TNL information is found in the data base, update the
+ * information in the database */
+ if(duCb.e2apDb.tnlAssoc[idx].destIpAddress.ipV4Addr == ipAddress)
+ {
+ duCb.e2apDb.tnlAssoc[idx].usage = connectionModifyItem->value.choice.E2connectionUpdate_Item.tnlUsage;
+ infoFound = true;
+ break;
+ }
+ }
+
+ /* If the TNL information is found in the data base, then add the
+ * information in setupE2Connection array else add in failedToSetupE2Connection array */
+ if(infoFound == true)
+ {
+ count =connectionInfoList->numOfE2ConnectionSetup;
+ connectionInfoList->setupE2Connection[count].ipV4Addr = duCb.e2apDb.tnlAssoc[idx].destIpAddress.ipV4Addr;
+ connectionInfoList->setupE2Connection[count].usage = duCb.e2apDb.tnlAssoc[idx].usage;
+ connectionInfoList->numOfE2ConnectionSetup++;
+ }
+ else
+ {
+ count = connectionInfoList->numOfE2ConnectionFailedToSetup;
+ connectionInfoList->failedToSetupE2Connection[count].ipV4Addr = ipAddress;
+ connectionInfoList->failedToSetupE2Connection[count].usage = connectionModifyItem->value.choice.E2connectionUpdate_Item.tnlUsage;
+ connectionInfoList->numOfE2ConnectionFailedToSetup++;
+ }
+ }
+
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Handling of E2 connection removal Ie
+ *
+ * @details
+ *
+ * Function : handleE2ConnectionRemoval
+ *
+ * Functionality: Handling of E2 connection removal Ie
+ *
+ * @param
+ * E2 Connection removal List
+ * @return void
+ *
+ ******************************************************************/
+
+void handleE2ConnectionRemoval(E2connectionUpdateRemove_List_t *connectionRemovalList)
+{
+ uint32_t ipAddress=0;
+ uint8_t arrIdx=0,idx=0;
+ E2connectionUpdateRemove_ItemIEs_t *connectionRemovalItem=NULLP;
+
+ if(connectionRemovalList->list.array)
+ {
+ for(arrIdx = 0; arrIdx < connectionRemovalList->list.count; arrIdx++)
+ {
+ connectionRemovalItem= (E2connectionUpdateRemove_ItemIEs_t*)connectionRemovalList->list.array[arrIdx];
+ bitStringToInt(&connectionRemovalItem->value.choice.E2connectionUpdateRemove_Item.tnlInformation.tnlAddress, &ipAddress);
+ for(idx=0; idx<duCb.e2apDb.numOfTNLAssoc; idx++)
+ {
+ if(duCb.e2apDb.tnlAssoc[idx].destIpAddress.ipV4Addr == ipAddress)
+ {
+ cmInetClose(&ricParams.sockFd);
+ removeE2NodeInformation();
+ break;
+ }
+ }
+
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Process e2 connection update received from RIC
+ *
+ * @details
+ *
+ * Function : procE2ConnectionUpdate
+ *
+ * Functionality: Process e2 connection update received from RIC
+ *
+ * @param E2AP_PDU_t *e2apMsg
+ * @return void
+ *
+ ******************************************************************/
+
+void procE2ConnectionUpdate(E2AP_PDU_t *e2apMsg)
+{
+ uint8_t arrIdx =0;
+ uint16_t transId =0;
+ bool invalidTransId = false, connectionFailedToUpdate=false;
+ E2FailureCause failureCause;
+ E2ConnectionList connectionInfoList;
+ E2connectionUpdate_t *connectionUpdate=NULLP;
+
+ DU_LOG("\nINFO --> E2AP : E2 connection update received");
+ connectionUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2connectionUpdate;
+
+ memset(&connectionInfoList, 0, sizeof(E2ConnectionList));
+ for(arrIdx=0; arrIdx<connectionUpdate->protocolIEs.list.count; arrIdx++)
+ {
+ switch(connectionUpdate->protocolIEs.list.array[arrIdx]->id)
+ {
+ case ProtocolIE_IDE2_id_TransactionID:
+ {
+ transId = connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
+ if(transId>255)
+ {
+ failureCause.causeType = E2_PROTOCOL;
+ failureCause.cause = E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE;
+ invalidTransId = true;
+ }
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_E2connectionUpdateModify:
+ {
+ handleE2ConnectionModification(&connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2connectionUpdate_List,\
+ &connectionInfoList);
+ if((connectionInfoList.numOfE2ConnectionSetup == 0) && (connectionInfoList.numOfE2ConnectionFailedToSetup > 0))
+ {
+ failureCause.causeType = E2_TRANSPORT;
+ failureCause.cause = E2_TRANSPORT_CAUSE_UNSPECIFIED;
+ connectionFailedToUpdate =true;
+ }
+
+ break;
+ }
+
+ case ProtocolIE_IDE2_id_E2connectionUpdateRemove:
+ {
+ handleE2ConnectionRemoval(&connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2connectionUpdateRemove_List);
+ break;
+ }
+
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Invalid IE received[%ld]",connectionUpdate->protocolIEs.list.array[arrIdx]->id);
+ break;
+ }
+ }
+
+ if(invalidTransId == true || connectionFailedToUpdate ==true)
+ break;
+ }
+
+ if(invalidTransId == true || connectionFailedToUpdate == true)
+ {
+ if(BuildAndSendE2ConnectionUpdateFailure(transId, failureCause) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build and send E2 connection update failure");
+ }
+ }
+ else
+ {
+ if(BuildAndSendE2ConnectionUpdateAcknowledge(transId, connectionInfoList) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed to build and send E2 connection update ack");
+ }
+ }
+
+ freeAperDecodingOfE2ConnectionUpdate(connectionUpdate);
+}
+
+/*******************************************************************
+ *
+ * @brief Free RIC Subscription action to be added list
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfRicSubsActionToBeAdded
+ *
+ * Functionality: Free the RIC Subscription action to be added list
+ *
+ * @params[in] RICactions_ToBeAddedForModification_List_t *subsDetails
+ * @return void
+ *
+ * ****************************************************************/
+void freeAperDecodingOfRicSubsActionToBeAdded(RICactions_ToBeAddedForModification_List_t *subsDetails)
+{
+ uint8_t elementIdx = 0;
+ RICaction_ToBeAddedForModification_ItemIEs_t *addedActionItemIe=NULLP;
+
+ if(subsDetails->list.array)
+ {
+ for(elementIdx = 0; elementIdx < subsDetails->list.count; elementIdx++)
+ {
+ if(subsDetails->list.array[elementIdx])
+ {
+ addedActionItemIe = (RICaction_ToBeAddedForModification_ItemIEs_t*)subsDetails->list.array[elementIdx];
+ free(addedActionItemIe->value.choice.RICaction_ToBeAddedForModification_Item.ricActionDefinition.buf);
+ free(subsDetails->list.array[elementIdx]);
+ }
+ }
+ free(subsDetails->list.array);
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocation of memory allocated by aper decoder for
+ * RIC Subscription action to be removed list
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfRicSubsActionToBeRemoved
+ *
+ * Functionality: Free the RIC Subscription action to be removed list
+ *
+ * @params[in] RICactions_ToBeRemovedForModification_List_t *subsDetails
+ * @return void
+ *
+ * ****************************************************************/
+void freeAperDecodingOfRicSubsActionToBeRemoved(RICactions_ToBeRemovedForModification_List_t *subsDetails)
+{
+ uint8_t elementIdx = 0;
+
+ if(subsDetails->list.array)
+ {
+ for(elementIdx = 0; elementIdx < subsDetails->list.count; elementIdx++)
+ {
+ if(subsDetails->list.array[elementIdx])
+ {
+ free(subsDetails->list.array[elementIdx]);
+ }
+ }
+ free(subsDetails->list.array);
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocation of memory allocated by aper decoder for
+ * RIC Subscription action to be modify
+ *
+ * @details
+ *
+ * Function : freeAperDecodingOfRicSubsActionToBeModified
+ *
+ * Functionality: Free the RIC Subscription action to be modify
+ *
+ * @params[in] RICactions_ToBeModifiedForModification_List_t List
+ * @return void
+ *
+ * ****************************************************************/
+void freeAperDecodingOfRicSubsActionToBeModified(RICactions_ToBeModifiedForModification_List_t *subsDetails)
+{
+ uint8_t elementIdx = 0;
+ RICaction_ToBeModifiedForModification_ItemIEs_t *actionItem = NULLP;
+
+ if(subsDetails->list.array)
+ {
+ for(elementIdx = 0; elementIdx < subsDetails->list.count; elementIdx++)
+ {
+ if(subsDetails->list.array[elementIdx])
+ {
+ actionItem = (RICaction_ToBeModifiedForModification_ItemIEs_t *)subsDetails->list.array[elementIdx];
+ if(actionItem->value.choice.RICaction_ToBeModifiedForModification_Item.ricActionDefinition)
+ {
+ free(actionItem->value.choice.RICaction_ToBeModifiedForModification_Item.ricActionDefinition->buf);
+ free(actionItem->value.choice.RICaction_ToBeModifiedForModification_Item.ricActionDefinition);
+ }
+ free(subsDetails->list.array[elementIdx]);
+ }
+ }
+ free(subsDetails->list.array);
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocation of memory allocated by aper decoder for
+ * RIC Subscription modification Request
+ *
+ * @details
+ *
+ * Function freeAperDecodingOfRicSubsModificationReq
+ *
+ * Functionality : Free RIC Subscription modification Request
+ *
+ * @params[in] E2AP_PDU
+ * @return void
+ *
+ ******************************************************************/
+void freeAperDecodingOfRicSubsModificationReq(E2AP_PDU_t *e2apRicMsg)
+{
+ uint8_t idx = 0;
+ RICsubscriptionModificationRequest_t *ricSubscriptionModReq;
+ RICsubscriptionModificationRequest_IEs_t *ricSubscriptionModReqIe;
+
+ ricSubscriptionModReq = &e2apRicMsg->choice.initiatingMessage->value.choice.RICsubscriptionModificationRequest;
+
+ if(ricSubscriptionModReq->protocolIEs.list.array)
+ {
+ for(idx=0; idx < ricSubscriptionModReq->protocolIEs.list.count; idx++)
+ {
+ if(ricSubscriptionModReq->protocolIEs.list.array[idx])
+ {
+ ricSubscriptionModReqIe = ricSubscriptionModReq->protocolIEs.list.array[idx];
+
+ switch(ricSubscriptionModReq->protocolIEs.list.array[idx]->id)
+ {
+ case ProtocolIE_IDE2_id_RICrequestID:
+ break;
+
+ case ProtocolIE_IDE2_id_RANfunctionID:
+ break;
+
+ case ProtocolIE_IDE2_id_RICactionsToBeRemovedForModification_List:
+ {
+ freeAperDecodingOfRicSubsActionToBeRemoved(&(ricSubscriptionModReqIe->value.choice.RICactions_ToBeRemovedForModification_List));
+ break;
+ }
+ case ProtocolIE_IDE2_id_RICactionsToBeModifiedForModification_List:
+ {
+ freeAperDecodingOfRicSubsActionToBeModified(&(ricSubscriptionModReqIe->value.choice.RICactions_ToBeModifiedForModification_List));
+ break;
+ }
+ case ProtocolIE_IDE2_id_RICactionsToBeAddedForModification_List:
+ {
+ freeAperDecodingOfRicSubsActionToBeAdded(&(ricSubscriptionModReqIe->value.choice.RICactions_ToBeAddedForModification_List));
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> E2AP : Received Invalid Ie [%ld]", ricSubscriptionModReq->protocolIEs.list.array[idx]->id);
+ break;
+ }
+
+ }
+
+ free(ricSubscriptionModReq->protocolIEs.list.array[idx]);
+ }
+ }
+ free(ricSubscriptionModReq->protocolIEs.list.array);
+ }
+}
+/*******************************************************************
+ *
+ * @brief Extract RIC Action to be added
+ *
+ * @details
+ *
+ * Function : extractRicActionToBeAddedForModification
+ *
+ * Functionality : This function :
+ * - [Step -1] Traverse each AddedForModification item indexes.
+ * - [Step -2] Add each action id related information in
+ * RicSubscription Db.
+ * - [Step -3] If failed to store then add action related info in
+ * pending rsp's rejectedActionList.
+ * - [Step -4] Else increment action added count
+ * - [Step -5] If there is even 1 action that can be added,
+ * return ROK, else RFAILED.
+ *
+ * @params[in] RAN Function Database structure
+ * RIC Subscription Info to be added to RAN function
+ * RIC Action To Be AddedForModification List received from RIC
+ * failure Cause
+ * Pending Subs Mod Rsp Info
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+uint8_t extractRicActionToBeAddedForModification(RanFunction *ranFuncDb, RicSubscription *ricSubscriptionInfo, \
+ RICactions_ToBeAddedForModification_List_t *actionList, E2FailureCause *failureCause, PendingSubsModRspInfo *subsModRsp)
+{
+ uint8_t actionAdded=0;
+ CmLList *actionNode = NULLP;
+ uint8_t actionIdx = 0;
+ uint8_t ricActionId = 0;
+ RICaction_ToBeAddedForModification_ItemIEs_t *actionItem = NULLP;
+
+ if(actionList->list.array)
+ {
+ for(actionIdx = 0; actionIdx < actionList->list.count; actionIdx++)
+ {
+ /* Step -1 */
+ actionItem =(RICaction_ToBeAddedForModification_ItemIEs_t *)actionList->list.array[actionIdx];
+ switch(actionItem->id)
+ {
+ case ProtocolIE_IDE2_id_RICaction_ToBeAddedForModification_Item:
+ {
+ /* Step -2 */
+ actionNode = addRicSubsAction(ranFuncDb, (PTR)&actionItem->value.choice.RICaction_ToBeAddedForModification_Item,\
+ &ricSubscriptionInfo->actionSequence, ProtocolIE_IDE2_id_RICaction_ToBeAddedForModification_Item, failureCause);
+
+ if(!actionNode)
+ {
+ /* Step -3 */
+ subsModRsp->addActionStatus.rejectedActionList[subsModRsp->addActionStatus.numOfRejectedActions].id = ricActionId;
+ if(failureCause->causeType == E2_NOTHING)
+ {
+ failureCause->causeType = E2_RIC_REQUEST;
+ failureCause->cause = E2_CONTROL_FAILED_TO_EXECUTE;
+ }
+ memcpy(&subsModRsp->addActionStatus.rejectedActionList[subsModRsp->addActionStatus.numOfRejectedActions].failureCause, \
+ failureCause, sizeof(E2FailureCause));
+ subsModRsp->addActionStatus.numOfRejectedActions++;
+ }
+ else
+ {
+ /* Step -4 */
+ actionAdded++;
+ }
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> E2AP : Invalid IE received in RicAddedForModificationLst:%ld",actionItem->id);
+ break;
+ }
+ }
+ }
+
+ /* Step -5 */
+ if(actionAdded)
+ return ROK;
+
+ if(failureCause->causeType == E2_NOTHING)
+ {
+ failureCause->causeType = E2_RIC_REQUEST;
+ failureCause->cause = E2_ACTION_NOT_SUPPORTED;
+ }
+ return RFAILED;
+}
+
+/*******************************************************************
+ *
+ * @brief Extract RIC Action to be Modified
+ *
+ * @details
+ *
+ * Function : extractRicActionToBeModifiedForModification
+ *
+ * Functionality : This function :
+ * - [Step -1] Traverse each Modification item indexes.
+ * - [Step -2] Find each action id related information in
+ * RicSubscription Db.
+ * - [Step -3] If not found store the action related info in pending
+ * rsp's action rejected.
+ * - [Step -4] If found store the new node in action seq list.
+ * [Step -4.1] If action failed to store, add the action
+ * info in pending subscription rsp's rejected list.
+ * [Step -4.2] If action stored successfully, change the status
+ * of added action to modified because action added as part of
+ * ric subscription modification req.
+ * - [Step -5] If there is even 1 action that can be modified,
+ * return ROK, else RFAILED.
+ *
+ * @params[in] RAN Function Database structure
+ * RIC Subscription Info to be Modified to RAN function
+ * RIC Action To Be ModifiedForModification List received from RIC
+ * failure Cause
+ * Pending Subs Mod Rsp Info
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+uint8_t extractRicActionToBeModifiedForModification(RanFunction *ranFuncDb, RicSubscription *ricSubscriptionInfo, \
+ RICactions_ToBeModifiedForModification_List_t *actionList, E2FailureCause *failureCause, PendingSubsModRspInfo *subsModRsp)
+{
+ uint8_t actionId=0;
+ uint8_t actionIdx = 0;
+ uint8_t actionFound=0;
+ CmLList *actionNode = NULLP;
+ ActionInfo *actionDb = NULLP;
+ RICaction_ToBeModifiedForModification_ItemIEs_t *actionItem = NULLP;
+
+ if(actionList->list.array)
+ {
+ for(actionIdx = 0; actionIdx < actionList->list.count; actionIdx++)
+ {
+ /* [Step -1] */
+ actionItem =(RICaction_ToBeModifiedForModification_ItemIEs_t *)actionList->list.array[actionIdx];
+ switch(actionItem->id)
+ {
+ case ProtocolIE_IDE2_id_RICaction_ToBeModifiedForModification_Item:
+ {
+ /* [Step -2] */
+ actionId=actionItem->value.choice.RICaction_ToBeModifiedForModification_Item.ricActionID;
+ actionDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode, CONFIG_UNKNOWN);
+ if(!actionNode)