+ }
+ if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
+ macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
+ }
+ return ret;
+}
+/*******************************************************************
+ *
+ * @brief Fills Reconfig Cell group Info received by CU
+ *
+ * @details
+ *
+ * Function : extractUeReCfgCellInfo
+ *
+ * Functionality: Fills Reconfig Cell group Info received by CU
+ *
+ * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
+ * MacUeCfg* macUeCfg
+ * @return ROK/RFAILED
+ *
+ * ****************************************************************/
+uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg)
+{
+ uint8_t ret = ROK;
+ MAC_CellGroupConfig_t *macCellGroup = NULLP;
+ PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
+ SpCellConfig_t *spcellCfg = NULLP;
+ ServingCellConfig_t *servCellCfg = NULLP;
+
+ if(cellGrp)
+ {
+ /* Fill MacCell Group Reconfig */
+ if(cellGrp->mac_CellGroupConfig)
+ {
+ macUeCfg->macCellGrpCfgPres = true;
+ macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
+ if(macCellGroup->schedulingRequestConfig)
+ {
+ extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
+ }
+ if(macCellGroup->tag_Config)
+ {
+ extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
+ }
+ if(macCellGroup->bsr_Config)
+ {
+ macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
+ macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
+ if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
+ {
+ macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
+ *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
+ }
+ }
+ if(macCellGroup->phr_Config)
+ {
+ if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
+ {
+ macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
+ if(macCellGroup->phr_Config->choice.setup)
+ {
+ macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
+ macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
+ macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
+ macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
+ macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
+ macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
+ macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
+ macCellGroup->phr_Config->choice.setup->multiplePHR;
+ macUeCfg->macCellGrpCfg.phrCfg.dummy = \
+ macCellGroup->phr_Config->choice.setup->dummy;
+ macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
+ macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
+ macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
+ macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
+ }
+ }
+ }
+ }
+ /* Fill Physical Cell Group Reconfig */
+ if(cellGrp->physicalCellGroupConfig)
+ {
+ macUeCfg->phyCellGrpCfgPres = true;
+ phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
+ if(phyCellGrpCfg->p_NR_FR1)
+ {
+ if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
+ macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
+ }
+ macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
+ }
+ /* Fill SpCell Reconfig */
+ if(cellGrp->spCellConfig)
+ {
+ macUeCfg->spCellCfgPres = true;
+ spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
+ if(spcellCfg->servCellIndex)
+ {
+ macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
+ }
+ /* Fill Serving cell Reconfig info */
+ if(cellGrp->spCellConfig->spCellConfigDedicated)
+ {
+ servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
+ ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
+ }
+ }
+ }
+ }
+ return ret;
+}
+/*******************************************************************
+*
+* @brief free the memory allocated by decoder
+*
+* @details
+*
+* Function : freeAperDecodeNrcgi
+*
+* Functionality: Free Nrcgi values
+*
+* @params[in] NRCGI_t *nrcgi
+* @return void
+*
+* ****************************************************************/
+
+
+void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
+{
+ if(nrcgi->pLMN_Identity.buf != NULLP)
+ {
+ free(nrcgi->pLMN_Identity.buf);
+ }
+ if(nrcgi->nRCellIdentity.buf != NULLP)
+ {
+ free(nrcgi->nRCellIdentity.buf);
+ }
+}
+/*******************************************************************
+*
+* @brief free the memory allocated by decoder
+*
+* @details
+*
+* Function : freeAperDecodeCuToDuInfo
+*
+* Functionality: Free Cu To Du Information
+*
+* @params[in] CUtoDURRCInformation_t *rrcMsg
+* @return void
+*
+* ****************************************************************/
+
+
+void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
+{
+ uint8_t ieIdx =0;
+ uint8_t arrIdx =0;
+
+ if(rrcMsg->uE_CapabilityRAT_ContainerList)
+ {
+ if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
+ free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
+ free(rrcMsg->uE_CapabilityRAT_ContainerList);
+ }
+
+ if(rrcMsg->iE_Extensions)
+ {
+ if(rrcMsg->iE_Extensions->list.array)
+ {
+ for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
+ {
+ if(rrcMsg->iE_Extensions->list.array[ieIdx])
+ {
+ switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_CellGroupConfig:
+ if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
+ {
+ free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
+ }
+ break;
+ default:
+ DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
+ rrcMsg->iE_Extensions->list.array[ieIdx]->id);
+ break;
+ }
+ }
+ }
+ for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
+ {
+ free(rrcMsg->iE_Extensions->list.array[arrIdx]);
+ }
+ free(rrcMsg->iE_Extensions->list.array);
+
+ }
+
+ free(rrcMsg->iE_Extensions);
+ }
+}
+/*******************************************************************
+*
+* @brief free the memory allocated by decoder
+*
+* @details
+*
+* Function : freeAperDecodeSplCellList
+*
+* Functionality: Free Spl Cell List
+ where memory allocated by aper_decoder
+*
+* @params[in] SCell_ToBeSetup_List_t *spCellLst
+* @return void
+*
+* ****************************************************************/
+
+
+void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
+{
+ uint8_t cellIdx =0;
+
+ if(spCellLst->list.array != NULLP)
+ {
+ for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
+ {
+ if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
+ {
+ freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
+ }
+ if(spCellLst->list.array[cellIdx]!=NULLP)
+ {
+ free(spCellLst->list.array[cellIdx]);
+ }
+ }
+ free(spCellLst->list.array);
+ }
+}
+/*******************************************************************
+*
+* @brief free the memory allocated by decoder
+*
+* @details
+*
+* Function : freeAperDecodeSRBSetup
+*
+* Functionality: added free part for the memory allocated by aper_decoder
+*
+* @params[in] SRBs_ToBeSetup_List_t *srbSet
+* @return void
+*
+****************************************************************/
+
+
+void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
+{
+ uint8_t srbIdx =0;
+ if(srbSet->list.array != NULLP)
+ {
+ for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
+ {
+ if(srbSet->list.array[srbIdx]!=NULLP)
+ {
+ free(srbSet->list.array[srbIdx]);
+ }
+ }
+ free(srbSet->list.array);
+ }
+}
+
+/*******************************************************************
+*
+* @brief free the memory allocated by decoder
+*
+* @details
+*
+* Function : freeAperDecodeULTnlInfo
+*
+* Functionality: added free part for the memory allocated by aper_decoder
+*
+* @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
+* @return void
+*
+* ****************************************************************/
+
+
+void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
+{
+ uint8_t ulIdx=0;
+ if(ulInfo->list.array != NULLP)
+ {
+ for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
+ {
+ if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
+ {
+ if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
+ {
+ if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
+ transportLayerAddress.buf != NULLP)
+ {
+ if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
+ !=NULLP)
+ {
+ free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
+ }
+ free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
+ transportLayerAddress.buf);
+ }
+ free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
+ }
+ }
+ if(ulInfo->list.array[ulIdx]!=NULLP)
+ {
+ free(ulInfo->list.array[ulIdx]);
+ }
+ }
+ free(ulInfo->list.array);
+ }
+}
+/*******************************************************************
+*
+* @brief free the memory allocated by decoder
+*
+* @details
+*
+* Function : freeAperDecodeDRBSetup
+*
+* Functionality: free DRBSetup which is allocated by decoder
+*
+* @params[in] DRBs_ToBeSetup_List_t *drbSet
+* @return void
+*
+* ****************************************************************/
+
+void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
+{
+ DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
+ uint8_t flowIdx =0;
+ uint8_t drbIdx =0;
+
+ if(drbSet->list.array != NULLP)
+ {
+ for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
+ {
+ if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
+ {
+ drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
+ if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
+ {
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
+ qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
+ {
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
+ qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
+ {
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
+ qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
+ {
+
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
+ {
+
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
+ {
+
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
+ buf!=NULLP)
+ {
+
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
+ flows_Mapped_To_DRB_List.list.array != NULLP)
+ {
+
+ for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
+ {
+
+ if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
+ {
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
+ qoSFlowLevelQoSParameters.\
+ qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
+ {
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
+ qoSFlowLevelQoSParameters.\
+ qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
+ {
+
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
+ qoSFlowLevelQoSParameters.\
+ qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
+ {
+
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
+ qoSFlowLevelQoSParameters.\
+ qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
+ qoSFlowLevelQoSParameters.\
+ qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
+ qoSFlowLevelQoSParameters.\
+ qoS_Characteristics.choice.non_Dynamic_5QI);
+ }
+ }
+ if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
+ {
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
+ }
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.flows_Mapped_To_DRB_List.list.array);
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
+ DRB_Information.sNSSAI.sD->buf);
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
+
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
+
+ qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
+ qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
+ }
+
+ free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
+ qoS_Characteristics.choice.non_Dynamic_5QI);
+ }
+ free(drbSetItem->qoSInformation.choice.choice_extension);
+ }
+ freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
+ if(drbSetItem->uLConfiguration)
+ {
+ free(drbSetItem->uLConfiguration);
+ }
+ }
+ if(drbSet->list.array[drbIdx]!=NULLP)
+ {
+ free(drbSet->list.array[drbIdx]);
+ }
+ }
+ free(drbSet->list.array);
+ }
+}
+
+
+/*******************************************************************
+ *
+ * @brief builds Mac Cell Cfg
+ *
+ * @details
+ *
+ * Function : procUeReCfgCellInfo
+ *
+ * Functionality: builds Mac Cell Cfg
+ *
+ * @params[in] MacUeCfg pointer
+ * void pointer
+ *
+ * @return void
+ *
+ * ****************************************************************/
+uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfg, void *cellInfo)
+{
+ uint8_t ret = ROK;
+ CellGroupConfigRrc_t *cellGrp = NULLP;
+
+ if(cellInfo)
+ {
+ cellGrp = (CellGroupConfigRrc_t *)cellInfo;
+ ret = extractUeReCfgCellInfo(cellGrp, macUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
+ }
+ if(ret == RFAILED)
+ {
+ freeUeReCfgCellGrpInfo(macUeCfg);
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Filling modulation info in mac ue cfg
+ *
+ * @details
+ *
+ * Function : duFillModulationDetails
+ *
+ * Functionality: Filling modulation info in mac ue cfg
+ *
+ * @params[in] MAC UE Config to be updated
+ * Current UE configuration
+ * UE NR capability from CU
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
+{
+ UE_NR_Capability_t *ueNrCap;
+
+ if(ueCap)
+ ueNrCap = (UE_NR_Capability_t *)ueCap;
+
+ /* Filling DL modulation info */
+ if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
+ ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
+ ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
+ {
+ switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
+ {
+ case ModulationOrder_qpsk:
+ {
+ ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
+ break;
+ }
+ case ModulationOrder_qam16:
+ {
+ ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
+ break;
+ }
+ case ModulationOrder_qam64:
+ {
+ ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
+ ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
+ ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
+ break;
+ }
+ case ModulationOrder_qam256:
+ {
+ ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
+ memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
+ break;
+ }
+ }
+ }
+ else
+ {
+ memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
+ }
+
+ /* Filling UL modulation info */
+ if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
+ ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
+ ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
+ {
+ switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
+ {
+ case ModulationOrder_qpsk:
+ {
+ ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
+ break;
+ }
+ case ModulationOrder_qam16:
+ {
+ ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
+ ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
+ ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
+ break;
+ }
+ case ModulationOrder_qam64:
+ {
+ ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
+ break;
+ }
+ case ModulationOrder_qam256:
+ {
+ ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
+ memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
+ break;
+ }
+ }
+ }
+ else
+ {
+ memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Function to extract cellGrp Info present in cutoDu cont
+ *
+ * @details
+ *
+ * Function : extractCellGrpInfo
+ *
+ * Functionality: Function to extract cellGrp Info present
+ * in cutoDu cont
+ *
+ * @params[in] ProtocolExtensionContainer_4624P16_t pointer
+ *
+ * @return CellGroupConfigRrc_t *
+ *
+ * ****************************************************************/
+
+CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
+ DuUeCfg *ueCfgDb)
+{
+ uint8_t idx2 =0;
+ uint16_t id =0;
+ uint16_t recvBufLen =0;
+ CellGroupConfigRrc_t *cellGrpCfg = NULLP;
+ CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
+ asn_dec_rval_t rval; /* Decoder return value */
+ memset(&rval, 0, sizeof(asn_dec_rval_t));
+
+ if(protocolIeExtn)
+ {
+ for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
+ {
+ extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
+ id = extIeInfo->id;
+ switch(id)
+ {
+ case ProtocolIE_ID_id_CellGroupConfig:
+ {
+ recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
+ /* decoding the CellGroup Buf received */
+ DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
+ if(cellGrpCfg)
+ {
+ memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
+ rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
+ extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
+ if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+ {
+ DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
+ return NULLP;
+ }
+ xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
+ if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
+ return NULLP;
+ }
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
+ break;
+ }
+ }
+ }
+ return cellGrpCfg;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Srb List received by CU
+ *
+ * @details
+ *
+ * Function : procSrbListToSetup
+ *
+ * Functionality: Fills Srb List received by CU
+ *
+ * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
+ * LcCfg pointer
+ * RlcBearerCfg pointer
+ * @return void
+ *
+ * ****************************************************************/
+uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
+{
+ uint8_t ret = ROK;
+
+ /* Filling RLC INFO */
+ procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
+
+ /* Filling MAC INFO */
+ ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, macLcToAdd, NULL);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
+ return ret;
+ }
+ return ret;
+}
+
+
+
+/*******************************************************************
+ *
+ * @brief extract Srb List received by CU
+ *
+ * @details
+ *
+ * Function : extractSrbListToSetup
+ *
+ * Functionality: extract Srb List received by CU
+ * for both MAC and RLC
+ *
+ * @params[in] SRBs_ToBeSetup_Item_t pointer
+ * DuUeCfg pointer
+ * @return ROK/RFAIED
+ *
+ * ****************************************************************/
+
+uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
+{
+ uint8_t ret, srbIdx;
+ SRBs_ToBeSetup_Item_t *srbItem = NULLP;
+
+ if(srbCfg)
+ {
+ for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
+ {
+ srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
+ if(ueCfgDb->numMacLcs > MAX_NUM_LC)
+ {
+ DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
+ ret = RFAILED;
+ break;
+ }
+ if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
+ {
+ DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
+ ret = RFAILED;
+ break;
+ }
+ memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
+ memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
+ ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
+ &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
+ ueCfgDb->numRlcLcs++;
+ ueCfgDb->numMacLcs++;
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
+ break;
+ }
+ }
+ }
+ else
+ ret = RFAILED;
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Drb List received by CU
+ *
+ * @details
+ *
+ * Function : procDrbListToSetup
+ *
+ * Functionality: Fills Drb List received by CU
+ * for both MAC and RLC
+ *
+ * @params[in] SRBs_ToBeSetup_Item_t pointer
+ * LcCfg pointer,
+ * RlcBearerCfg pointer
+ * @return void
+ *
+ * ****************************************************************/
+
+uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
+DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
+{
+
+ if(drbItem != NULLP)
+ {
+ /* Filling RLC INFO */
+ procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
+
+ /* Filling MAC INFO */
+ if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
+ return RFAILED;
+ }
+ }
+ else if(drbSetupModItem != NULLP)
+ {
+ procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
+
+ if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
+ return RFAILED;
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief extract Drb List received by CU
+ *
+ * @details
+ *
+ * Function : extractDrbListToSetup
+ *
+ * Functionality: extract Drb List received by CU
+ * for both MAC and RLC
+ *
+ * @params[in] DRBs_ToBeSetup_Item_t pointer
+ * DuUeCfg pointer
+ * @return ROK/RFAIED
+ *
+ * ****************************************************************/
+
+uint8_t extractDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_List_t *drbCfg,DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
+uint8_t drbCount, DuUeCfg *ueCfgDb)
+{
+ uint8_t ret, drbIdx;
+ DRBs_ToBeSetup_Item_t *drbItem = NULLP;
+ DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
+
+ ret = ROK;
+ if(drbCount > 0)
+ {
+ for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
+ {
+ if(ueCfgDb->numMacLcs > MAX_NUM_LC)
+ {
+ DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetup()");
+ ret = RFAILED;
+ break;
+ }
+ if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
+ {
+ DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetup()");
+ ret = RFAILED;
+ break;
+ }
+ memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
+ memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
+
+ if(drbCfg != NULL)
+ {
+ drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
+ ret = procDrbListToSetup(lcId, drbItem, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
+ &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
+ break;
+ }
+ }
+ else if(drbSetupModCfg != NULL)
+ {
+ drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
+ ret = procDrbListToSetup(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item) ,\
+ &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
+ &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
+ break;
+ }
+ }
+ ueCfgDb->numRlcLcs++;
+ ueCfgDb->numMacLcs++;
+ ueCfgDb->numDrb++;
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
+ break;
+ }
+ }
+ }
+ else
+ ret = RFAILED;
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Function to extract Dl RRC Msg received from CU
+ *
+ * @details
+ *
+ * Function : extractDlRrcMsg
+ *
+ * Functionality: Function to extract Dl RRC Msg received from CU
+ *
+ * @params[in] F1AP message
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
+ F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
+{
+ uint8_t ret = ROK;
+ dlRrcMsg->rrcMsgSize = rrcContainer->size;
+ if(dlRrcMsg->rrcMsgSize > 0)
+ {
+ DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
+ if(!dlRrcMsg->rrcMsgPdu)
+ {
+ DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
+ ret = RFAILED;
+ }
+ else
+ {
+ dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
+ dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
+ dlRrcMsg->srbId = SRB1_LCID;
+ memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
+ }
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Extract UE capability info
+ *
+ * @details
+ *
+ * Function : extractUeCapability
+ *
+ * Functionality: Extract UE capability info and stores in ue Cb
+ *
+ * @params[in] Octet string of UE capability RAT container list
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
+{
+ uint8_t idx;
+ uint16_t recvBufLen;
+ asn_dec_rval_t rval;
+ UE_NR_Capability_t *ueNrCap = NULLP;
+ UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
+
+ /* Decoding UE Capability RAT Container List */
+ recvBufLen = ueCapablityListBuf->size;
+ DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
+ if(!ueCapRatContList)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
+ return NULLP;
+ }
+ memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
+ memset(&rval, 0, sizeof(asn_dec_rval_t));
+ rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
+ ueCapablityListBuf->buf, recvBufLen, 0, 0);
+ if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+ {
+ DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
+ return NULLP;
+ }
+ xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
+
+ /* Free encoded buffer after decoding */
+
+ for(idx = 0; idx < ueCapRatContList->list.count; idx++)
+ {
+ if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
+ {
+ /* Decoding UE NR Capability */
+ recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
+ DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
+ if(!ueNrCap)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
+ DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
+ return NULLP;
+ }
+ memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
+ memset(&rval, 0, sizeof(asn_dec_rval_t));
+ rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
+ ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
+ if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+ {
+ DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
+ return NULLP;
+ }
+ xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
+
+ /* Free encoded buffer after decoding */
+ free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
+ }
+ free(ueCapRatContList->list.array[idx]);
+ }
+
+ /* Free Memory*/
+ free(ueCapRatContList->list.array);
+ DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
+ return ueNrCap;
+}
+
+/*******************************************************************
+*
+* @brief free UE context setup request from CU
+*
+* @details
+*
+* Function : freeAperDecodeF1UeContextSetupReq
+*
+* Functionality: freeing part for the memory allocated by aper_decoder
+*
+* @params[in] F1AP message
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
+{
+ uint8_t ieIdx = 0;
+
+ if(ueSetReq->protocolIEs.list.array != NULLP)
+ {
+ for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
+ {
+ if(ueSetReq->protocolIEs.list.array[ieIdx])
+ {
+ switch(ueSetReq->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_SpCell_ID:
+ freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
+ break;
+ case ProtocolIE_ID_id_ServCellIndex:
+ break;
+ case ProtocolIE_ID_id_SpCellULConfigured:
+ break;
+ case ProtocolIE_ID_id_CUtoDURRCInformation:
+
+ freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
+ break;
+ case ProtocolIE_ID_id_SCell_ToBeSetup_List:
+
+ freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
+ break;
+ case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
+
+ freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
+ break;
+ case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
+
+ freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
+ break;
+ case ProtocolIE_ID_id_RRCContainer:
+ {
+
+ if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
+ {
+
+ free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
+ break;
+ case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
+ {
+ if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
+ {
+ free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
+ }
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
+ }
+ free(ueSetReq->protocolIEs.list.array[ieIdx]);
+ }
+ }
+ free(ueSetReq->protocolIEs.list.array);
+ }
+}
+/*******************************************************************
+ *
+ * @brief Process UE context setup request from CU
+ *
+ * @details
+ *
+ * Function : procF1UeContextSetupReq
+ *
+ * Functionality: Process UE context setup request from CU
+ *
+ * @params[in] F1AP message
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t ret=0, ieIdx=0, ueIdx=0, lcId=0, cellIdx=0;
+ bool ueCbFound = false;
+ uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
+ DuUeCb *duUeCb = NULL;
+ UEContextSetupRequest_t *ueSetReq = NULL;
+ DRBs_ToBeSetup_List_t *drbCfg = NULL;
+
+ ret = ROK;
+
+ ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
+ for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
+ {
+ switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+ {
+ gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
+ break;
+ }
+ case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+ {
+ gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
+ break;
+ }
+ case ProtocolIE_ID_id_ServCellIndex:
+ {
+ cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
+ for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
+ {
+ if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
+ (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
+ {
+ ueCbFound = true;
+ duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
+ DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
+ if(duUeCb->f1UeDb)
+ {
+ memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
+ duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
+ duUeCb->f1UeDb->cellIdx = cellIdx;
+ }
+ else
+ {
+ DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
+ ret = RFAILED;
+ }
+ }
+ else
+ ueCbFound = false;
+
+ }
+ if(!ueCbFound)
+ {
+ DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
+ ret = RFAILED;
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_SpCellULConfigured:
+ /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
+ UL, SUL or UL+SUL for the indicated cell for the UE */
+ break;
+ case ProtocolIE_ID_id_CUtoDURRCInformation:
+ {
+ if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
+ {
+ duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
+ extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
+ uE_CapabilityRAT_ContainerList, duUeCb);
+ }
+ if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
+ {
+ duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
+ value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
+ if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
+ {
+ DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
+ //TODO: Update the failure cause in ue context Setup Response
+ ret = RFAILED;
+ }
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_SCell_ToBeSetup_List:
+ {
+ DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
+ break;
+ }
+ case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
+ {
+ if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
+ &duUeCb->f1UeDb->duUeCfg))
+ {
+ DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
+ //TODO: Update the failure cause in ue context Setup Response
+ ret = RFAILED;
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
+ {
+ lcId = getDrbLcId(&duUeCb->drbBitMap);
+ if(lcId != RFAILED)
+ {
+ drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
+ if(extractDrbListToSetup(lcId, drbCfg, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg))
+ {
+ DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
+ //TODO: Update the failure cause in ue context Setup Response
+ ret = RFAILED;
+ }
+ }
+ else
+ ret = RFAILED;
+ break;
+ }
+ case ProtocolIE_ID_id_RRCContainer:
+ {
+ /* Filling Dl RRC Msg Info */
+ DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
+ if(!duUeCb->f1UeDb->dlRrcMsg)
+ {
+ DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
+ ret = RFAILED;
+ }
+ else
+ {
+ duUeCb->f1UeDb->dlRrcMsgPres = true;
+ memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
+ ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
+ &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
+ {
+ if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
+ {
+ duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
+ }
+ else
+ {
+ DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
+ {
+ /* MaximumBitRate Uplink */
+ bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
+ if(bitRateSize > 0)
+ {
+ DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
+ if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
+ {
+ DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
+ ret = RFAILED;
+ }
+ else
+ {
+ memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
+ memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
+ ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
+ }
+ }
+ else
+ ret = RFAILED;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ if(ret == RFAILED)
+ {
+ /*TODO : Negative case*/
+ // BuildAndSendUeContextSetupRsp(ueIdx, cellId);
+ DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
+ }
+ else
+ ret = duProcUeContextSetupRequest(duUeCb);
+
+ freeAperDecodeF1UeContextSetupReq(ueSetReq);
+ return ret;
+
+}
+/*******************************************************************
+ * @brief Free the memory allocated for Dl Tunnel Info
+ *
+ * @details
+ *
+ * Function : freeDlTnlInfo
+ *
+ * Functionality:
+ * Free the memory allocated for Dl Tunnel Info
+ *
+ * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
+ * @return void
+ *
+ * ****************************************************************/
+
+void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
+{
+ uint8_t arrIdx = 0;
+
+ for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
+ {
+ DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
+ }
+}
+
+/*******************************************************************
+ * @brief Free the memory allocated for DRB setup List
+ *
+ * @details
+ *
+ * Function : freeDrbSetupList
+ *
+ * Functionality:
+ * Free the memory allocated for DRB setup list
+ *
+ * @params[in] DRBs_Setup_List_t *
+ * @return void
+ *
+ * ****************************************************************/
+void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
+{
+ uint8_t arrIdx = 0;
+ DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
+
+ for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
+ {
+ drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
+ freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
+ }
+}
+
+/*******************************************************************
+ * @brief Free the memory allocated for UE Setup response
+ *
+ * @details
+ *
+ * Function : FreeUeContextSetupRsp
+ *
+ * Functionality:
+ * Free the memory allocated for UE Setup response
+ *
+ * @params[in] F1AP PDU for UE setup response
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t idx;
+ UEContextSetupResponse_t *ueSetRsp = NULLP;
+
+ if(f1apMsg)
+ {
+ if(f1apMsg->choice.successfulOutcome)
+ {
+ ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
+ UEContextSetupResponse;
+ if(ueSetRsp->protocolIEs.list.array)
+ {
+ for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
+ {
+ if(ueSetRsp->protocolIEs.list.array[idx])
+ {
+ switch(ueSetRsp->protocolIEs.list.array[idx]->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_DUtoCURRCInformation:
+ {
+ CellGroupConfig_t *cellGrpCfg = NULLP;
+ cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
+ DUtoCURRCInformation.cellGroupConfig;
+ if(cellGrpCfg->buf != NULLP)
+ {
+ DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
+ cellGrpCfg = NULLP;
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_DRBs_Setup_List:
+ {
+ freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
+ ueSetRsp->protocolIEs.list.array[idx]->id);
+ break;
+ }
+ DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
+ sizeof(UEContextSetupResponseIEs_t));
+ }
+ }
+ DU_FREE(ueSetRsp->protocolIEs.list.array, \
+ ueSetRsp->protocolIEs.list.size);
+ }
+ DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
+ }
+ DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Builds Ue context Setup Rsp DU To CU Info
+ *
+ * @details
+ *
+ * Function : EncodeUeCntxtDuToCuInfo
+ *
+ * Functionality: Builds Ue context Setup Rsp DU To CU Info
+ *
+ * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+
+uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
+{
+ asn_enc_rval_t encRetVal;
+
+ xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
+ memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
+ /* Encode results */
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ return RFAILED;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+ }
+ duToCuCellGrp->size = encBufSize;
+ DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
+ if(!duToCuCellGrp->buf)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
+ }
+ memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Dl Gtp tunnel Info
+ *
+ * @details
+ *
+ * Function : fillGtpTunnelforDl
+ *
+ * Functionality: Fills Dl Gtp tunnel Info
+ *
+ * @params[in]
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
+{
+ uint8_t bufSize = 0;
+
+ gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
+ DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
+ if(gtpDl->transportLayerAddress.buf == NULLP)
+ {
+ return RFAILED;
+ }
+ memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
+
+ /*GTP TEID*/
+ gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
+ DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
+ if(gtpDl->gTP_TEID.buf == NULLP)
+ {
+ return RFAILED;
+ }
+ bufSize = 3; /*forming an Octect String*/
+ fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills DL Tunnel Setup List
+ *
+ * @details
+ *
+ * Function : fillDlTnlSetupList
+ *
+ * Functionality: Fills the DL Tunnel Setup List
+ *
+ * @params[in]
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
+{
+ uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
+
+ eleCount = 1;
+ dlTnlInfo->list.count = eleCount;
+ dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
+
+ /* Initialize the DL Tnl Setup List Members */
+ DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
+ if(dlTnlInfo->list.array == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
+ ret = RFAILED;
+ }
+ for(arrIdx=0; arrIdx < eleCount; arrIdx++)
+ {
+ DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
+ if(dlTnlInfo->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
+ return RFAILED;
+ }
+ dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
+ DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
+ if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
+ return RFAILED;
+ }
+ ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
+ tnlCfg->tnlCfg1);
+ if(ret != ROK)
+ break;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills the Drb Setup List for Ue Context Setup Response
+ *
+ * @details
+ *
+ * Function : fillDrbSetupList
+ *
+ * Functionality: Fills the Drb Setup List for Ue Context Setup Response
+ *
+ * @params[in]
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
+{
+ uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
+ DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
+
+ eleCount = ueCfg->numDrb;
+ drbSetupList->list.count = eleCount;
+ drbSetupList->list.size = \
+ (eleCount * sizeof(DRBs_Setup_Item_t *));
+
+ /* Initialize the Drb Setup List Members */
+ DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
+ if(drbSetupList->list.array == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
+ ret = RFAILED;
+ }
+
+ for(arrIdx=0; arrIdx < eleCount; arrIdx++)
+ {
+ DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
+ if(drbSetupList->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
+ return RFAILED;
+ }
+ drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
+ drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
+ drbItemIe->criticality = Criticality_reject;
+ drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
+ drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
+ ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
+ &ueCfg->upTnlInfo[arrIdx]);
+ if(ret != ROK)
+ break;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and sends the UE Setup Response
+ *
+ * @details
+ *
+ * Function : BuildAndSendUeContextSetupRsp
+ *
+ * Functionality: Constructs the UE Setup Response and sends
+ * it to the DU through SCTP.
+ *
+ * @params[in]
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildAndSendUeContextSetupRsp(uint8_t ueIdx, uint8_t cellId)
+{
+ uint8_t idx, ret, cellIdx, elementCnt;
+ uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
+ uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+ F1AP_PDU_t *f1apMsg = NULLP;
+ UEContextSetupResponse_t *ueSetRsp = NULLP;
+ CellGroupConfigRrc_t *cellGrpCfg = NULLP;
+ DuUeCb *ueCb = NULLP;
+
+ DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
+
+ while(true)
+ {
+ DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
+ ret = RFAILED;
+ break;
+ }
+
+ f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
+ DU_ALLOC(f1apMsg->choice.successfulOutcome,
+ sizeof(SuccessfulOutcome_t));
+ if(f1apMsg->choice.successfulOutcome == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
+ ret = RFAILED;
+ break;
+ }
+
+ f1apMsg->choice.successfulOutcome->procedureCode = \
+ ProcedureCode_id_UEContextSetup;
+ f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
+ f1apMsg->choice.successfulOutcome->value.present = \
+ SuccessfulOutcome__value_PR_UEContextSetupResponse;
+
+ ueSetRsp =
+ &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
+ elementCnt = 4;
+ ueSetRsp->protocolIEs.list.count = elementCnt;
+ ueSetRsp->protocolIEs.list.size = \
+ elementCnt * sizeof(UEContextSetupResponse_t *);
+
+ /* Initialize the UESetup members */
+ DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
+ ueSetRsp->protocolIEs.list.size);
+ if(ueSetRsp->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
+ ret = RFAILED;
+ break;
+ }
+
+ for(idx=0; idx<elementCnt; idx++)
+ {
+ DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
+ sizeof(UEContextSetupResponseIEs_t));
+ if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
+ ret = RFAILED;
+ 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];
+
+ idx = 0;
+ /*GNB CU UE F1AP ID*/
+ ueSetRsp->protocolIEs.list.array[idx]->id = \
+ ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+ ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ ueSetRsp->protocolIEs.list.array[idx]->value.present = \
+ UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
+ ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
+
+ /*GNB DU UE F1AP ID*/
+ idx++;
+ ueSetRsp->protocolIEs.list.array[idx]->id = \
+ ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+ ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ ueSetRsp->protocolIEs.list.array[idx]->value.present = \
+ UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
+ ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
+
+
+ /*DUtoCURRC Information */
+ idx++;
+ ueSetRsp->protocolIEs.list.array[idx]->id = \
+ ProtocolIE_ID_id_DUtoCURRCInformation;
+ ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ ueSetRsp->protocolIEs.list.array[idx]->value.present =\
+ UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
+ if(ueCb->f1UeDb)
+ {
+ if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
+ {
+ cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
+ ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
+ choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
+ freeF1UeDb(ueCb->f1UeDb);
+ ueCb->f1UeDb = NULLP;
+ break;
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
+ ret = RFAILED;
+ break;
+ }
+
+ /* Drb Setup List */
+ idx++;
+ ueSetRsp->protocolIEs.list.array[idx]->id = \
+ ProtocolIE_ID_id_DRBs_Setup_List;
+ ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ ueSetRsp->protocolIEs.list.array[idx]->value.present =\
+ UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
+ ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
+ &ueCb->f1UeDb->duUeCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
+ freeF1UeDb(ueCb->f1UeDb);
+ ueCb->f1UeDb = NULLP;
+ break;
+ }
+
+ /* Free UeContext Db created during Ue context Req */
+ freeF1UeDb(ueCb->f1UeDb);
+ ueCb->f1UeDb = NULLP;
+
+ /* TODO: To send Drb list */
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ /* Encode the UE context setup response type as APER */
+ memset((uint8_t *)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 Response 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 Setup 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 Response failed");
+ ret = RFAILED;
+ break;
+ }
+ break;
+ }
+ FreeUeContextSetupRsp(f1apMsg);
+ return ret;
+}/* End of BuildAndSendUeContextSetupRsp */
+/*******************************************************************
+*
+* @brief Build And Send Ue Context Rsp
+*
+* @details
+*
+* Function : BuildAndSendUeCtxtRsp
+*
+* Functionality : Build And Send Ue Context Rsp
+
+* @params[in]
+* @return sucess = ROK
+* failure = RFAILED
+*
+* ****************************************************************/
+uint8_t BuildAndSendUeCtxtRsp(uint8_t ueIdx, uint8_t cellId)
+{
+ uint8_t cellIdx = 0, actionType = 0;
+
+ GET_CELL_IDX(cellId, cellIdx);
+ actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
+
+ switch(actionType)
+ {
+ case UE_CTXT_SETUP:
+ BuildAndSendUeContextSetupRsp(ueIdx, cellId);
+ break;
+ case UE_CTXT_MOD:
+ BuildAndSendUeContextModResp(ueIdx, cellId);
+ break;
+ default:
+ DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
+ break;
+
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief deallocating the memory of F1reset msg
+ *
+ * @details
+ *
+ * Function : FreeF1ResetReq
+ *
+ * Functionality :
+ * - freeing memory of F1reset request msg
+ *
+ * @params[in]
+ * @return void
+ *
+ *
+ * ****************************************************************/
+void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t idx =0 ;
+ Reset_t *f1ResetMsg;
+
+ if(f1apMsg)
+ {
+ if(f1apMsg->choice.initiatingMessage)
+ {
+ f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
+
+ if(f1ResetMsg->protocolIEs.list.array)
+ {
+ for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
+ {
+ if(f1ResetMsg->protocolIEs.list.array[idx])
+ {
+ DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
+ }
+ }
+ DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
+ }
+ DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
+ }
+ DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ }
+}
+/*******************************************************************
+ *
+ * @brief Build and Send F1reset request
+ *
+ * @details
+ *
+ * Function : BuildAndSendF1ResetReq
+ *
+ * Functionality:
+ * - Build and Send F1reset request msg
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildAndSendF1ResetReq()
+{
+ uint8_t elementCnt=0;
+ uint8_t idx=0;
+ uint8_t ret= RFAILED;
+ Reset_t *f1ResetMsg = NULLP;
+ F1AP_PDU_t *f1apMsg = NULLP;
+ asn_enc_rval_t encRetVal;
+ DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
+ do
+ {
+ DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ break;
+ }
+ f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
+ DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
+ if(f1apMsg->choice.initiatingMessage == NULLP)
+ {
+ break;
+ }
+ f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
+ f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
+ f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
+
+ f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
+
+ elementCnt = 3;
+ f1ResetMsg->protocolIEs.list.count = elementCnt;
+ f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
+
+ /* Initialize the F1Setup members */
+ DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
+ if(f1ResetMsg->protocolIEs.list.array == NULLP)
+ {
+ break;
+ }
+ for(idx=0; idx<elementCnt; idx++)
+ {
+ DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
+ if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
+ {
+ break;
+ }
+ }
+
+ /*TransactionID*/
+ idx=0;
+ f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
+ f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
+
+ /*Cause*/
+ idx++;
+ f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
+ f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
+
+ /*Reset Type*/
+ idx++;
+ f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
+ f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
+ f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
+
+ 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 F1Reset structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
+ for(idx=0; idx< encBufSize; idx++)
+ {
+ printf("%x",encBuf[idx]);
+ }
+ }
+
+ if(sendF1APMsg() != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeF1ResetReq(f1apMsg);
+ return ret;
+}
+/*******************************************************************
+ *
+ * @brief Build And Send F1ResetAck
+ *
+ * @details
+ *
+ * Function : BuildAndSendF1ResetAck
+ *
+ * Functionality:
+ * - Build And Send F1ResetRSP
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t idx;
+ ResetAcknowledge_t *f1ResetAck;
+
+ if(f1apMsg)
+ {
+ if(f1apMsg->choice.successfulOutcome)
+ {
+ f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
+
+ if(f1ResetAck->protocolIEs.list.array)
+ {
+ for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
+ {
+ if(f1ResetAck->protocolIEs.list.array[idx])
+ {
+ DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
+ }
+ }
+ DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
+ }
+ DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
+ }
+ DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Build And Send F1ResetAck
+ *
+ * @details
+ *
+ * Function : BuildAndSendF1ResetAck
+ *
+ * Functionality:
+ * - Build And Send F1ResetRSP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildAndSendF1ResetAck()
+{
+ uint8_t idx = 0;
+ uint8_t elementCnt = 0;
+ uint8_t ret = RFAILED;
+ F1AP_PDU_t *f1apMsg = NULL;
+ ResetAcknowledge_t *f1ResetAck = NULLP;
+ asn_enc_rval_t encRetVal;
+ DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
+
+ do{
+ /* Allocate the memory for F1ResetRequest_t */
+ DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
+ 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");
+ break;
+ }
+ f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
+ f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
+ f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
+
+ elementCnt = 1;
+
+ f1ResetAck->protocolIEs.list.count = elementCnt;
+ f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
+
+ DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
+ if(f1ResetAck->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
+ break;
+ }
+
+ for(idx=0; idx<elementCnt; idx++)
+ {
+ DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
+ if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
+ {
+ break;
+ }
+ }
+ /*TransactionID*/
+ idx = 0;
+ f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
+ f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
+ f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
+
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ /* Encode the F1SetupRequest type as UPER */
+ memset(encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
+
+ /* Check encode results */
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+ }
+ /* Sending msg */
+ if(sendF1APMsg() != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
+ break;
+ }
+
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeF1ResetAck(f1apMsg);
+ return ret;
+}
+/******************************************************************
+*
+* @brief free F1 reset msg allocated by aper_decoder
+*
+* @details
+*
+* Function : freeAperDecodeF1ResetMsg
+*
+* Functionality: free F1 reset msg allocated by aper_decoder
+*
+* @params[in] Reset_t *f1ResetMsg
+* @return void
+*
+* ****************************************************************/
+
+void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
+{
+ uint8_t ieIdx =0;
+ if(f1ResetMsg->protocolIEs.list.array)
+ {
+ for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
+ {
+ if(f1ResetMsg->protocolIEs.list.array[ieIdx])
+ {
+ free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
+ }
+ }
+ free(f1ResetMsg->protocolIEs.list.array);
+ }
+}
+
+/******************************************************************
+ *
+ * @brief Processes DL RRC Message Transfer sent by CU
+ *
+ * @details
+ *
+ * Function : procF1ResetReq
+ *
+ * Functionality: Processes DL RRC Message Transfer sent by CU
+ *
+ * @params[in] F1AP_PDU_t ASN decoded F1AP message
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
+{
+ /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
+ uint8_t ieIdx = 0;
+ uint8_t ret = ROK;
+ Reset_t *f1ResetMsg = NULLP;
+
+ DU_LOG("\nINFO --> Processing F1 reset request");
+ f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
+
+ for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
+ {
+ switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_TransactionID:
+ break;
+
+ case ProtocolIE_ID_id_Cause:
+ break;
+
+ case ProtocolIE_ID_id_ResetType:
+ {
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+ ret = BuildAndSendF1ResetAck();
+ DU_LOG("\nINFO --> UE release is not supported for now");
+
+ freeAperDecodeF1ResetMsg(f1ResetMsg);
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief free the RRC delivery report
+ *
+ * @details
+ *
+ * Function : freeRrcDeliveryReport
+ *
+ * Functionality: free the RRC delivery report
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
+{
+ uint8_t idx=0;
+ RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
+
+ if(f1apMsg)
+ {
+ if(f1apMsg->choice.initiatingMessage)
+ {
+ rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
+ if(rrcDeliveryReport->protocolIEs.list.array)
+ {
+ for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
+ idx++)
+ {
+ if(rrcDeliveryReport->protocolIEs.list.array[idx])
+ {
+ DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
+ sizeof(RRCDeliveryReportIEs_t));
+ }
+ }
+ DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
+ rrcDeliveryReport->protocolIEs.list.size);
+ }
+ DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
+ }
+ DU_FREE(f1apMsg,
+ sizeof(F1AP_PDU_t));
+ }
+}
+
+/*******************************************************************
+*
+* @brief Builds and sends the RRC delivery report
+*
+* @details
+*
+* Function : BuildAndSendRrcDeliveryReport
+*
+* Functionality: Builds and sends the RRC delivery report
+*
+* @params[in]
+*
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
+ uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
+{
+ uint8_t ret = RFAILED;
+ uint8_t idx = 0;
+ uint8_t idx1 = 0;
+ uint8_t elementCnt = 0;
+ F1AP_PDU_t *f1apMsg = NULLP;
+ asn_enc_rval_t encRetVal;
+ RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
+
+ do{
+
+ DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
+ DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
+ break;
+ }
+ f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
+ DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
+ if(f1apMsg->choice.initiatingMessage == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
+ break;
+ }
+ f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
+ f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
+ f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
+
+ rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
+ elementCnt = 4;
+ rrcDeliveryReport->protocolIEs.list.count = elementCnt;
+ rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
+
+ /* Initialize the F1Setup members */
+ DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
+ if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
+ break;
+ }
+ for(idx =0 ;idx <elementCnt; idx++)
+ {
+ DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
+ if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
+ {
+ break;
+ }
+ }
+
+ idx1 = 0;
+
+ /*GNB CU UE F1AP ID*/
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
+
+ /*GNB DU UE F1AP ID*/
+ idx1++;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
+
+ /*RRC delivery status*/
+ idx1++;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
+ rrcDelivery->rrcDeliveryStatus.deliveryStatus;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
+ rrcDelivery->rrcDeliveryStatus.triggeringMessage;
+
+ /* SRB ID */
+ idx1++;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
+ rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
+
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ /* Encode the RRC DELIVERY REPORT 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 RRC Delivery Msg structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
+ for(idx=0; idx< encBufSize; idx++)
+ {
+ printf("%x",encBuf[idx]);
+ }
+ }
+
+ /* Sending msg */
+ if(sendF1APMsg() != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
+ break;
+ }
+ ret = ROK;
+ break;
+
+ }while(true);
+
+ freeRrcDeliveryReport(f1apMsg);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes cells to be activated
+ *
+ * @details
+ *
+ * Function : extractCellsToBeActivated
+ *
+ * Functionality:
+ * - Processes cells to be activated list received in F1SetupRsp
+ *
+ * @params[in] void
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
+{
+ uint8_t ret = ROK;
+ uint16_t idx, nci, pci = 0;
+ Cells_to_be_Activated_List_Item_t cell;
+
+ for(idx=0; idx<cellsToActivate.list.count; idx++)
+ {
+ nci = 0;
+ cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
+ bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
+
+ if(cell.nRPCI)
+ {
+ pci = *cell.nRPCI;
+ }
+ ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
+ }
+ return ret;
+}
+/******************************************************************
+*
+* @brief Processes F1 Setup Response allocated by aper_decoder
+*
+* @details
+*
+* Function : freeF1SetupRsp
+*
+* Functionality: free F1 Setup Response allocated by aper_decoder
+*
+* @params[in] F1SetupResponse_t *f1SetRspMsg
+* @return void
+*
+* ****************************************************************/
+
+void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
+{
+ uint8_t ieIdx =0;
+ uint8_t arrIdx =0;
+ Cells_to_be_Activated_List_t *cellToActivate =NULLP;
+ RRC_Version_t *rrcVer =NULLP;
+
+ if(f1SetRspMsg->protocolIEs.list.array)
+ {
+ for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
+ {
+ if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
+ {
+ switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_Cells_to_be_Activated_List:
+ {
+ cellToActivate =
+ &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
+ if(cellToActivate->list.array)
+ {
+ for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
+ {
+ if(cellToActivate->list.array[arrIdx])
+ {
+
+ if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
+ pLMN_Identity.buf)
+ {
+ if(cellToActivate->list.array[0]->value.choice.\
+ Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
+ {
+ free(cellToActivate->list.array[0]->value.choice.\
+ Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
+ }
+
+ free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
+ nRCGI.pLMN_Identity.buf);
+ }
+ free(cellToActivate->list.array[arrIdx]);
+ }
+ }
+ free(cellToActivate->list.array);
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_TransactionID:
+ {
+ break;
+ }
+ case ProtocolIE_ID_id_gNB_CU_Name:
+ {
+ free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
+ break;
+ }
+ case ProtocolIE_ID_id_GNB_CU_RRC_Version:
+ {
+ rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
+ if(rrcVer->latest_RRC_Version.buf)
+ {
+ if(rrcVer->iE_Extensions)
+ {
+ if(rrcVer->iE_Extensions->list.array)
+ {
+ if(rrcVer->iE_Extensions->list.array[0])
+ {
+ if(rrcVer->iE_Extensions->list.\
+ array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
+ {
+ free(rrcVer->iE_Extensions->list.\
+ array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
+ }
+ free(rrcVer->iE_Extensions->list.array[0]);
+ }
+ free(rrcVer->iE_Extensions->list.array);
+ }
+ free(rrcVer->iE_Extensions);
+ }
+ free(rrcVer->latest_RRC_Version.buf);
+ }
+ break;
+
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
+ f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
+ }
+ }
+ free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
+ }
+ }
+ free(f1SetRspMsg->protocolIEs.list.array);
+ }
+}
+/******************************************************************
+ *
+ * @brief Processes F1 Setup Response sent by CU
+ *
+ * @details
+ *
+ * Function : procF1SetupRsp
+ *
+ * Functionality: Processes F1 Setup Response sent by CU
+ *
+ * @params[in] F1AP_PDU_t ASN decoded F1AP message
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t ret = ROK;
+ uint16_t idx =0;
+ F1SetupResponse_t *f1SetRspMsg = NULLP;
+ GNB_CU_Name_t *cuName = NULLP;
+ F1SetupRsp f1SetRspDb;
+ RRC_Version_t *rrcVer =NULLP;
+
+ memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
+
+ DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
+ f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
+
+ for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
+ {
+ switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
+ {
+ case ProtocolIE_ID_id_Cells_to_be_Activated_List:
+ {
+ extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
+ value.choice.Cells_to_be_Activated_List);
+ break;
+ }
+ case ProtocolIE_ID_id_TransactionID:
+ {
+ f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
+ value.choice.TransactionID;
+ break;
+ }
+ case ProtocolIE_ID_id_gNB_CU_Name:
+ {
+ cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
+ value.choice.GNB_CU_Name;
+ strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
+ break;
+ }
+ case ProtocolIE_ID_id_GNB_CU_RRC_Version:
+ {
+ rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
+ strcpy(f1SetRspDb.rrcVersion.rrcVer,
+ (const char*)rrcVer->latest_RRC_Version.buf);
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
+ f1SetRspMsg->protocolIEs.list.array[idx]->id);
+ }
+ duProcF1SetupRsp();
+ }
+
+ freeAperDecodeF1SetupRsp(f1SetRspMsg);
+ return ret;
+}
+/*******************************************************************
+*
+* @brief free GNB DU config update ack
+*
+* @details
+*
+* Function : freeAperDecodeGnbDuAck
+*
+* Functionality: Processes GNB DU config update ack And
+* added free part for the memory allocated by aper_decoder
+*
+* @params[in] F1AP_PDU_t ASN decoded F1AP message
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
+{
+ uint8_t ieIdx = 0;
+
+ if(gnbDuAck->protocolIEs.list.array)
+ {
+ for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
+ {
+ if(gnbDuAck->protocolIEs.list.array[ieIdx])
+ {
+ free(gnbDuAck->protocolIEs.list.array[ieIdx]);
+ }
+ }
+ free(gnbDuAck->protocolIEs.list.array);
+ }
+}
+/*******************************************************************
+*
+* @brief Processes GNB DU config update ack
+*
+* @details
+*
+* Function : procF1GNBDUCfgUpdAck
+*
+* Functionality: added free part for the memory allocated by aper_decoder
+*
+* @params[in] F1AP_PDU_t *f1apMsg
+* @return void
+*
+* ****************************************************************/
+uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t ieIdx;
+ GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
+
+ DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
+ gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
+
+ for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
+ {
+ switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_TransactionID:
+ break;
+ case ProtocolIE_ID_id_Cells_to_be_Activated_List:
+ break;
+ default :
+ DU_LOG("\nERROR --> F1AP: Invalid IE Received: %ld, at procF1GNBDUCfgUpdAck()", \
+ gnbDuAck->protocolIEs.list.array[ieIdx]->id);
+ break;
+ }
+ }
+ duProcGnbDuCfgUpdAckMsg();
+#if 0
+ if(BuildAndSendF1ResetReq() != ROK)
+ {
+ return RFAILED;
+ }
+#endif
+
+ freeAperDecodeGnbDuAck(gnbDuAck);
+ return ROK;
+}
+/******************************************************************
+*
+* @brief free DL RRC Message Transfer allocated by aper_decoder
+*
+* @details
+*
+* Function : freeAperDecodef1DlRrcMsg
+*
+* Functionality: free DL RRC Message Transfer allocated by aper_decoder
+*
+* @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
+{
+ uint8_t ieIdx =0;
+ RRCContainer_t *rrcContainer = NULLP;
+
+ if(f1DlRrcMsg->protocolIEs.list.array)
+ {
+ for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
+ {
+ if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
+ {
+ switch(f1DlRrcMsg->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_SRBID:
+ break;
+ case ProtocolIE_ID_id_RRCContainer:
+ {
+ rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
+ free(rrcContainer->buf);
+ }
+ case ProtocolIE_ID_id_ExecuteDuplication:
+ break;
+ case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
+ break;
+ break;
+ }
+ free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
+ }
+ }
+ free(f1DlRrcMsg->protocolIEs.list.array);
+ }
+}
+/******************************************************************
+ *
+ * @brief Processes DL RRC Message Transfer sent by CU
+ *
+ * @details
+ *
+ * Function : procF1DlRrcMsgTrans
+ *
+ * Functionality: Processes DL RRC Message Transfer sent by CU
+ *
+ * @params[in] F1AP_PDU_t ASN decoded F1AP message
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t idx, ret;
+ DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
+ F1DlRrcMsg dlMsg;
+ memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
+
+ DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
+ f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
+
+ ret = ROK;
+
+ for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
+ {
+ switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
+ {
+ case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+ {
+ dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
+ break;
+ }
+ case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+ {
+ dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
+ break;
+ }
+ case ProtocolIE_ID_id_SRBID:
+ {
+ dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
+ break;
+ }
+ case ProtocolIE_ID_id_ExecuteDuplication:
+ dlMsg.execDup = true;
+ break;
+
+ case ProtocolIE_ID_id_RRCContainer:
+ {
+ if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
+ {
+ dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
+ DU_ALLOC(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
+ if(dlMsg.rrcMsgPdu)
+ {
+ memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
+ dlMsg.rrcMsgSize);
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
+ f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
+ return RFAILED;
+ }
+ break;
+ }
+ case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
+ {
+ dlMsg.deliveryStatRpt = true;
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
+ f1DlRrcMsg->protocolIEs.list.array[idx]->id);
+ }
+ }
+
+ ret = duProcDlRrcMsg(&dlMsg);
+
+ freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
+ return ret;
+}
+/*******************************************************************
+ *
+* @brief Builds the DRB to be Setup Mod list
+*
+* @details
+*
+* Function :
+*
+* Functionality: Constructs the DRB to be Setup Mod list
+*
+* @params[in] DRBs_SetupMod_List_t *drbSet
+*
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
+{
+ uint8_t arrIdx =0;
+ uint8_t drbCnt =0;
+ struct DRBs_SetupMod_ItemIEs *drbItemIe;
+
+ drbCnt = 1;
+ drbSet->list.count = drbCnt;
+ drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
+ DU_ALLOC(drbSet->list.array, drbSet->list.size);
+ if(drbSet->list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
+ return RFAILED;
+ }
+ for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
+ {
+ DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
+ if(drbSet->list.array[arrIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
+ return RFAILED;
+ }
+
+ drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
+ drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
+ drbItemIe->criticality = Criticality_reject;
+ drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
+ drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
+ if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
+ &ueCfg->upTnlInfo[arrIdx])!= ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
+ return RFAILED;
+ }
+
+ }
+
+ return ROK;
+}
+/*******************************************************************
+* @brief Free the memory allocated for DRB setup List
+*
+* @details
+*
+* Function : FreeDrbSetupModList
+*
+* Functionality:
+* Free the memory allocated for DRB setup list
+*
+* @params[in] DRBs_Setup_List_t *
+* @return void
+*
+* ****************************************************************/
+void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
+{
+ uint8_t arrIdx = 0;
+ DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
+
+ for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
+ {
+ drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
+ freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
+ }
+}
+/*******************************************************************
+* @brief Free the memory allocated for UE Context Mod Response
+*
+* @details
+*
+* Function : FreeUeContextModResp
+*
+* Functionality:
+* Free the memory allocated for UE Context Mod Response
+*
+* @params[in] F1AP_PDU_t *f1apMsg
+* @return void
+*
+* ****************************************************************/
+
+void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t ieIdx;
+ UEContextModificationResponse_t *ueContextModifyRes = NULLP;
+ if(f1apMsg)
+ {
+ 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);
+ }