#include "UPTransportLayerInformation.h"
#include "GTPTunnel.h"
-DuCfgParams duCfgParam;
+#ifdef O1_ENABLE
+
+#include "Config.h"
+extern StartupConfig g_cfg;
+
+#endif
+DuCfgParams duCfgParam;
/************************************************************************
*
* @brief Converts enum values into actual value of Poll retransmit timer
* @return Actual value of pollPdu
*
* ****************************************************************/
-int16_t getPollPdu(uint8_t pollPduCfg)
+int32_t getPollPdu(uint8_t pollPduCfg)
{
- int16_t pollPdu;
+ int32_t pollPdu;
switch(pollPduCfg)
{
case PollPDU_p4:
return RFAILED;
}
/* MIB */
- srvCellItem->gNB_DU_System_Information->mIB_message.size =\
- strlen(( char *)duCfgParam.srvdCellLst[0].duSysInfo.mibMsg);
+ srvCellItem->gNB_DU_System_Information->mIB_message.size = duCfgParam.srvdCellLst[0].duSysInfo.mibLen;
DU_ALLOC(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
srvCellItem->gNB_DU_System_Information->mIB_message.size);
if(!srvCellItem->gNB_DU_System_Information->mIB_message.buf)
{
return RFAILED;
}
- strcpy((char *)srvCellItem->gNB_DU_System_Information->mIB_message.buf,
- (char *)duCfgParam.srvdCellLst[0].duSysInfo.mibMsg);
+ memcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf, duCfgParam.srvdCellLst[0].duSysInfo.mibMsg, \
+ srvCellItem->gNB_DU_System_Information->mIB_message.size);
/* SIB1 */
srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
*
* @details
*
- * Function : SendF1APMsg
+ * Function : sendF1APMsg
*
* Functionality: Sends F1 msg over SCTP
*
* RFAILED - failure
*
* ****************************************************************/
-uint8_t SendF1APMsg(Region region, Pool pool)
+uint8_t sendF1APMsg()
{
Buffer *mBuf = NULLP;
- if(ODU_GET_MSG_BUF(region, pool, &mBuf) == ROK)
+ if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
{
if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
{
return RFAILED;
}
return ROK;
-} /* SendF1APMsg */
+} /* sendF1APMsg */
/*******************************************************************
*
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
break;
}
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
break;
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
break;
}
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
ret = RFAILED;
upTnlInfo->drbId = drbId;
upTnlInfo->configType = configType;
+#ifdef O1_ENABLE
+ cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
+#else
cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
+#endif
for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
{
/* 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)
- {
+ }
+ 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)
- {
+ 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)
- {
+ *(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;
- }
- }
- }
+ {
+ 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)
+ {
+ 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));
+ 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()");
- }
- }
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
+ }
+ }
}
}
return ret;
}
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);
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
ret = RFAILED;
}
}
- if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
break;
}
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
break;
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION, DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
break;
}
/* Sending msg */
- if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL) != ROK)
+ if(sendF1APMsg() != ROK)
{
DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
ret = RFAILED;
return ret;
}
/*****************************************************************i
+*
+* @brief Free memory allocated for UE Context Release Request
+*
+* @details
+*
+* Function : FreeUeContextReleaseReq
+*
+* Functionality:
+* - Free memory allocated for UE Context Release Request
+*
+* @params[in] F1AP_PDU_t *f1apMsg
+* @return void
+*
+* *************************************************************/
+void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t ieIdx;
+ UEContextReleaseRequest_t *ueReleaseReq = NULLP;
+
+ if(f1apMsg)
+ {
+ if(f1apMsg->choice.initiatingMessage)
+ {
+ ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
+ if(ueReleaseReq->protocolIEs.list.array)
+ {
+ for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
+ {
+ DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
+ }
+ DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
+ }
+ DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
+ }
+ DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ }
+
+}
+/*****************************************************************i
+*
+* @brief Build and Send UE Context Release Request
+*
+* @details
+*
+* Function : BuildAndSendUeContextReleaseReq
+*
+* Functionality:
+* - Build and Send UE Context Release Request
+*
+* @params[in]
+* @return ROK - success
+* RFAILED - failure
+*
+* *************************************************************/
+uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
+{
+ bool memAllocFail = false;
+ uint8_t ieIdx =0;
+ uint8_t ret = RFAILED;
+ uint16_t cellIdx =0;
+ uint16_t crnti = 0;
+ uint8_t elementCnt = 0;
+ uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
+ uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
+ asn_enc_rval_t encRetVal;
+ F1AP_PDU_t *f1apMsg = NULLP;
+ UEContextReleaseRequest_t *ueReleaseReq = NULLP;
+
+ DU_LOG("\nINFO --> Building the UE Context Release Request");
+ do
+ {
+ DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
+ break;
+ }
+
+ f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
+ DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
+ if(f1apMsg->choice.initiatingMessage == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
+ initiatingMessage");
+ break;
+ }
+ f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
+ f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
+ f1apMsg->choice.initiatingMessage->value.present = \
+ InitiatingMessage__value_PR_UEContextReleaseRequest;
+
+ ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
+
+ elementCnt = 2;
+
+ ueReleaseReq->protocolIEs.list.count = elementCnt;
+ ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
+
+ /* Initialize the F1Setup members */
+ DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
+ if(ueReleaseReq->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
+ break;
+ }
+ for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
+ {
+ DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
+ sizeof(UEContextReleaseRequest_t));
+ if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
+ memAllocFail = true;
+ break;
+ }
+ }
+ if(memAllocFail == true)
+ break;
+
+ /* Fetching Ue Cb Info*/
+ GET_CELL_IDX(cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
+ break;
+ }
+ else
+ {
+ GET_CRNTI(crnti, ueIdx);
+ if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
+ {
+ DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
+ break;
+ }
+ gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
+ gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
+ }
+
+ ieIdx=0;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
+ UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
+
+ ieIdx++;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
+ UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
+ ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
+
+ 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 UEContextReleaseRequest structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ break;
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
+ for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
+ {
+ printf("%x",encBuf[ieIdx]);
+ }
+ }
+
+ /* Sending msg */
+ if(sendF1APMsg() != ROK)
+ {
+ DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
+ break;
+ }
+ ret = ROK;
+ break;
+ }while(true);
+
+ FreeUeContextReleaseReq(f1apMsg);
+ return ret;
+}
+/**************************************************************
*
* @brief Handles received F1AP message and sends back response
*