+ if(f1apMsg->choice.successfulOutcome)
+ {
+ ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
+ if(ueContextModifyRes->protocolIEs.list.array)
+ {
+ for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
+ {
+ if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
+ {
+ switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+ break;
+ case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+ break;
+ case ProtocolIE_ID_id_DRBs_SetupMod_List:
+ {
+ FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
+ value.choice.DRBs_SetupMod_List));
+ break;
+ }
+ }
+ DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
+ }
+
+ }
+ DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
+ }
+ DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
+ }
+ DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ }
+}
+
+/*****************************************************************i
+*
+* @brief Creating the ue context modifcation response and sending
+*
+* @details
+*
+* Function : BuildAndSendUeContextModResp
+*
+* Functionality:
+* - Creating the ue context modifcation response
+*
+* @params[in]
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t BuildAndSendUeContextModResp(uint8_t ueIdx, uint8_t cellId)
+{
+ uint8_t ieIdx = 0;
+ uint8_t cellIdx =0;
+ uint8_t elementCnt = 0;
+ uint8_t ret = RFAILED;
+ uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
+ uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
+ F1AP_PDU_t *f1apMsg = NULLP;
+ asn_enc_rval_t encRetVal;
+ UEContextModificationResponse_t *ueContextModifyRes = NULLP;
+ DuUeCb *ueCb = NULLP;
+
+ DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
+
+ while(1)
+ {
+ DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
+ break;
+ }
+
+ f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
+
+ DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
+ if(f1apMsg->choice.successfulOutcome == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
+ break;
+ }
+ f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
+ f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
+ f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
+
+ ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
+
+ elementCnt = 3;
+ ueContextModifyRes->protocolIEs.list.count = elementCnt;
+ ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
+
+ /* Initialize the UE context modification members */
+ DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
+ if(ueContextModifyRes->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
+ break;
+ }
+
+ for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
+ {
+ DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
+ if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
+ break;
+ }
+ }
+
+ /* Fetching Ue Cb Info*/
+ GET_CELL_IDX(cellId, cellIdx);
+ gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
+ gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
+ ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
+
+ ieIdx=0;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
+ UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
+
+ ieIdx++;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
+ UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
+
+ ieIdx++;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
+ ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
+ UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
+ if(ueCb->f1UeDb)
+ {
+ ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
+ value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
+ if(ret != ROK)
+ {
+ DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
+ break;
+ }
+ freeF1UeDb(ueCb->f1UeDb);
+ ueCb->f1UeDb = NULLP;
+ }
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ /* Encode the F1SetupRequest type as APER */
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
+
+ /* Encode results */
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ ret = RFAILED;
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(sendF1APMsg() != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
+ ret = RFAILED;
+ break;
+ }
+ break;
+ }
+ FreeUeContextModResp(f1apMsg);
+ return ret;
+
+}
+/*******************************************************************
+ *
+ * @brief Deallocating the memory allocated by the aper decoder
+ * for QOSInfo
+ *
+ * @details
+ *
+ * Function : freeAperDecodeQosInfo
+ *
+ * Functionality: Deallocating the memory allocated for QOSInfo
+ *
+ * @params[in] QoSFlowLevelQoSParameters_t *drbQos
+ *
+ * @return void
+ *
+ * ****************************************************************/
+
+void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
+{
+ if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
+ {
+ if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
+ {
+ if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
+ {
+ free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
+ }
+ free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
+ }
+ free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
+ }
+}
+/*******************************************************************
+ *
+ * @brief Deallocating the memory allocated by the aper decoder
+ * for UlTnlInfoforDrb
+ *
+ * @details
+ *
+ * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
+ *
+ * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
+ *
+ * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
+{
+ uint8_t arrIdx =0;
+
+ if(ulInfo->list.array)
+ {
+ for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
+ {
+ if(ulInfo->list.array[arrIdx])
+ {
+ if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
+ {
+ if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
+ {
+ if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
+ {
+ free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
+ gTP_TEID.buf);
+ }
+ free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
+ transportLayerAddress.buf);
+ }
+ free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
+ }
+ free(ulInfo->list.array[arrIdx]);
+ }
+ }
+ free(ulInfo->list.array);
+ }
+}
+/*******************************************************************
+ *
+ * @brief Deallocating the memory allocated by the aper decoder
+ * for DrbSetupModItem
+ *
+ * @details
+ *
+ * Function : freeAperDecodeDrbSetupModItem
+ *
+ * Functionality: Deallocating memory allocated for DrbSetupModItem
+ *
+ * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
+ *
+ * @return void
+ *
+ * ****************************************************************/
+
+void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
+{
+ uint8_t arrIdx =0;
+ SNSSAI_t *snssai =NULLP;
+ Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
+
+ drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
+ switch(drbItem->qoSInformation.present)
+ {
+ case QoSInformation_PR_NOTHING:
+ break;
+ case QoSInformation_PR_eUTRANQoS:
+ {
+ if(drbItem->qoSInformation.choice.eUTRANQoS)
+ {
+ free(drbItem->qoSInformation.choice.eUTRANQoS);
+ }
+ break;
+ }
+ case QoSInformation_PR_choice_extension:
+ {
+ if(drbItem->qoSInformation.choice.choice_extension)
+ {
+ freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.dRB_QoS);
+ snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
+ if(snssai->sST.buf)
+ {
+ free(snssai->sST.buf);
+ }
+ if(snssai->sD)
+ {
+ if(snssai->sD->buf)
+ {
+ free(snssai->sD->buf);
+ }
+ free(snssai->sD);
+ }
+
+ flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List;
+ if(flowMap->list.array)
+ {
+ for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
+ {
+ if(flowMap->list.array[arrIdx] )
+ {
+ freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
+ free(flowMap->list.array[arrIdx]);
+ }
+ }
+ free(flowMap->list.array);
+ }
+
+ free(drbItem->qoSInformation.choice.choice_extension);
+ }
+ break;
+ }
+
+ }
+ freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
+ if(drbItem->uLConfiguration)
+ {
+ free(drbItem->uLConfiguration);
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocating the memory allocated by the aper decoder
+ * for DrbToBeSetupModList
+ *
+ * @details
+ *
+ * Function : freeAperDecodeDrbToBeSetupModList
+ *
+ * Functionality: Deallocating memory allocated for DrbToBeSetupModList
+ *
+ * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
+ *
+ * @return void
+ *
+ * ****************************************************************/
+
+void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
+{
+ uint8_t arrIdx =0;
+ struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
+
+ if(drbSet->list.array)
+ {
+ for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
+ {
+ if(drbSet->list.array[arrIdx] != NULLP)
+ {
+ if(arrIdx == 0)
+ {
+ drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
+ freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
+ }
+ free(drbSet->list.array[arrIdx]);
+ }
+ }
+ free(drbSet->list.array);
+ }
+
+}
+/*******************************************************************
+ *
+ * @brief Deallocating the memory allocated by the aper decoder
+ * for UeContextModificationReqMsg
+ *
+ * @details
+ *
+ * Function : freeAperDecodeUeContextModificationReqMsg
+ *
+ * Functionality: Deallocating memory allocated for
+ * UeContextModificationReqMsg
+ *
+ * @params[in] UEContextModificationRequest_t *UeContextModifyReq
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
+{
+ uint8_t arrIdx, ieId;
+
+ if(UeContextModifyReq->protocolIEs.list.array)
+ {
+ for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
+ {
+ if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
+ {
+ ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
+ switch(ieId)
+ {
+ case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+ break;
+ case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+ break;
+ case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
+ {
+ freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
+ value.choice.DRBs_ToBeSetupMod_List);
+ break;
+ }
+ }
+ free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
+ }
+ }
+ free(UeContextModifyReq->protocolIEs.list.array);
+ }
+}
+/*******************************************************************
+ *
+ * @brief processing the F1 UeContextModificationReq
+ *
+ * @details
+ *
+ * Function : procF1UeContextModificationReq
+ *
+ * Functionality: processing the F1 UeContextModificationReq
+ *
+ * @params[in] F1AP_PDU_t *f1apMsg
+ *
+ * @return
+ * ****************************************************************/
+uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
+{
+ UEContextModificationRequest_t *ueContextModifyReq = NULLP;
+ uint8_t ret = ROK, ieIdx = 0, lcId =0,cellIdx=0, ueIdx=0;
+ DuUeCb *duUeCb = NULLP;
+ DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
+ uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
+
+ ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
+ for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
+ {
+ switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+ {
+ gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
+ break;
+ }
+ case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+ {
+ gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
+ break;
+ }
+ case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
+ {
+ for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
+ {
+ for(ueIdx = 0; ueIdx < duCb.numUe; ueIdx++)
+ {
+ if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
+ (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
+ {