+/*******************************************************************
+ *
+ * @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 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;
+ }
+
+ //TODO : Send statistics delete request to MAC
+ 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 Handles received E2AP message and sends back response
+ *
+ * @details
+ *
+ * Function : E2APMsgHdlr
+ *
+ * Functionality:
+ * - Decodes received E2AP control message
+ * - Prepares response message, encodes and sends to SCTP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void E2APMsgHdlr(Buffer *mBuf)
+{
+ int i =0;
+ char *recvBuf = NULLP;
+ MsgLen copyCnt =0;
+ MsgLen recvBufLen =0;
+ E2AP_PDU_t *e2apMsg = NULLP;
+ asn_dec_rval_t rval ={0}; /* Decoder return value */
+ E2AP_PDU_t e2apasnmsg={0} ;
+
+ DU_LOG("\nDEBUG --> E2AP : Received E2AP message buffer");
+ ODU_PRINT_MSG(mBuf, 0,0);
+
+ /* Copy mBuf into char array to decode it */
+ ODU_GET_MSG_LEN(mBuf, &recvBufLen);
+ DU_ALLOC(recvBuf, (Size)recvBufLen);
+
+ if(recvBuf == NULLP)
+ {
+ DU_LOG("\nERROR --> E2AP : Memory allocation failed");
+ return;
+ }
+ if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
+ {
+ DU_LOG("\nERROR --> E2AP : Failed while copying %d", copyCnt);
+ return;
+ }
+
+#ifdef DEBUG_ASN_PRINT
+ printf("\nDEBUG --> E2AP : Received flat buffer to be decoded : ");
+ for(i=0; i< recvBufLen; i++)
+ {
+ printf("%x",recvBuf[i]);
+ }
+#endif
+
+ /* Decoding flat buffer into E2AP messsage */
+ e2apMsg = &e2apasnmsg;
+ memset(e2apMsg, 0, sizeof(E2AP_PDU_t));
+
+ rval = aper_decode(0, &asn_DEF_E2AP_PDU, (void **)&e2apMsg, recvBuf, recvBufLen, 0, 0);
+ DU_FREE(recvBuf, (Size)recvBufLen);
+
+ if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+ {
+ DU_LOG("\nERROR --> E2AP : ASN decode failed");
+ return;
+ }
+ printf("\n");