*******************************************************************************/
/* This file contains F1AP message handler functions */
-
+#include "common_def.h"
+#include "OCTET_STRING.h"
+#include "BIT_STRING.h"
+#include "odu_common_codec.h"
#include "cu_stub_sctp.h"
#include "cu_f1ap_msg_hdl.h"
-char encBuf[ENC_BUF_MAX_LEN];
-
-/*******************************************************************
- *
- * @brief Writes the encoded chunks into a buffer
- *
- * @details
- *
- * Function : PrepFinalEncBuf
- *
- * Functionality:Fills the encoded buffer
- *
- * @params[in] void *buffer,initial encoded data
- * @params[in] size_t size,size of buffer
- * @params[in] void *encodedBuf,final buffer
- * @return ROK - success
- * RFAILED - failure
- *
- * ****************************************************************/
-static int PrepFinalEncBuf(const void *buffer, size_t size, void *encodedBuf)
-{
- memcpy(encodedBuf + encBufSize, buffer, size);
- encBufSize += size;
- return 0;
-} /* PrepFinalEncBuf */
-
/*******************************************************************
*
* @brief Sends F1 msg over SCTP
* ****************************************************************/
S16 SendF1APMsg(Region region, Pool pool)
{
- Buffer *mBuf;
+ Buffer *mBuf = NULLP;
- if(SGetMsg(region, pool, &mBuf) == ROK)
+ if(ODU_GET_MSG(region, pool, &mBuf) == ROK)
{
- if(SAddPstMsgMult((Data *)encBuf, encBufSize, mBuf) == ROK)
+ if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
{
- SPrntMsg(mBuf, 0,0);
+ ODU_PRINT_MSG(mBuf, 0,0);
if(sctpSend(mBuf) != ROK)
{
DU_LOG("\nF1AP : SCTP Send failed");
- SPutMsg(mBuf);
- RETVALUE(RFAILED);
+ ODU_PUT_MSG(mBuf);
+ return RFAILED;
}
}
else
{
- DU_LOG("\nF1AP : SAddPstMsgMult failed");
- SPutMsg(mBuf);
- RETVALUE(RFAILED);
+ DU_LOG("\nF1AP : ODU_ADD_POST_MSG_MULT failed");
+ ODU_PUT_MSG(mBuf);
+ return RFAILED;
}
- SPutMsg(mBuf);
+ ODU_PUT_MSG(mBuf);
}
else
{
DU_LOG("\nF1AP : Failed to allocate memory");
- RETVALUE(RFAILED);
+ return RFAILED;
}
- RETVALUE(ROK);
+ return ROK;
} /* SendF1APMsg */
-
-void plmnBuildCU(Plmn plmn, OCTET_STRING_t *octe)
-{
- U8 mncCnt;
- mncCnt = 2;
- octe->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0]));
- if(mncCnt == 2)
- {
- octe->buf[1] = ((0xf0) | (plmn.mcc[2]));
- octe->buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0]));
- }
- else
- {
- octe->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2]));
- octe->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1]));
- }
-}
-
/*******************************************************************
*
* @brief Builds NRCell ID
nrcell->buf[4] = 16;
nrcell->bits_unused = 4;
nrcell->size = 5 * sizeof(uint8_t);
- RETVALUE(ROK);
+ return ROK;
}
/********************************************************************
if(f1apMsg == NULLP)
{
DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
- RETVALUE(RFAILED);
+ return RFAILED;
}
f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
{
DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_F1Setup;
DU_LOG("\nF1AP : Memory allocation for F1ResponseIEs failed");
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
for(idx=0; idx<elementCnt; idx++)
CU_FREE(f1apMsg->choice.successfulOutcome, \
sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
}
CU_FREE(f1apMsg->choice.successfulOutcome,\
sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
strcpy((char*)cuName->buf, (char*)cuCfgParams.cuName);
elementCnt * sizeof(F1SetupResponseIEs_t *));
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
for(idy=0; idy<cellCnt; idy++)
{
CU_FREE(f1apMsg->choice.successfulOutcome, \
sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
}
cellToActivate->list.array[0]->id = \
CU_FREE(f1apMsg->choice.successfulOutcome, \
sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
- plmnBuildCU(cuCfgParams.plmn , &cellToActivate->list.array[0]->value.choice.\
+ buildPlmnId(cuCfgParams.plmn , &cellToActivate->list.array[0]->value.choice.\
Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity);
cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
nRCGI.nRCellIdentity.size = 5;
CU_FREE(f1apMsg->choice.successfulOutcome, \
sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
BuildNrCellId(&(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity));
/* RRC Version */
elementCnt * sizeof(F1SetupResponseIEs_t *));
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
/* Need to check RRC Version */
elementCnt * sizeof(F1SetupResponseIEs_t *));
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
rrcVer->iE_Extensions->list.count = 1;
rrcVer->iE_Extensions->list.size = sizeof(struct RRC_Version_ExtIEs *);
elementCnt * sizeof(F1SetupResponseIEs_t *));
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
CU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
sizeof(struct RRC_Version_ExtIEs));
elementCnt * sizeof(F1SetupResponseIEs_t *));
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
rrcVer->iE_Extensions->list.array[0]->id = \
ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
elementCnt * sizeof(F1SetupResponseIEs_t *));
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
Latest_RRC_Version_Enhanced.buf[0] = 0;
{
DU_LOG("\nF1AP : Could not encode F1SetupResponse structure (at %s)\n",\
encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
- RETVALUE(RFAILED);
+ return RFAILED;
}
else
{
if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
{
DU_LOG("\nF1AP : Sending F1 Setup Response failed");
- RETVALUE(RFAILED);
+ return RFAILED;
}
- RETVALUE(ROK);
+ return ROK;
}/* End of BuildAndSendF1SetupRsp */
/*******************************************************************
if(f1apMsg == NULLP)
{
DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
- RETVALUE(RFAILED);
+ return RFAILED;
}
f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
{
DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_gNBDUConfigurationUpdate;
DU_LOG("\nF1AP : Memory allocation for DuUpdateAcknowledgeIEs failed");
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
for(idx=0; idx<elementCnt; idx++)
CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
}
if(enRetVal.encoded == ENCODE_FAIL)
{
DU_LOG("\nF1AP : Could not encode DUConfigUpdateAcknowledge structure (at %s)",enRetVal.failed_type ? enRetVal.failed_type->name : "unknown");
- RETVALUE(RFAILED);
+ return RFAILED;
}
else
{
if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
{
DU_LOG("\nF1AP : Sending GNB-DU Config Update Ack failed");
- RETVALUE(RFAILED);
+ return RFAILED;
}
- RETVALUE(ROK);
+ return ROK;
}/* End of BuildAndSendDUUpdateAck*/
/*******************************************************************
*
- * @brief Builds and sends the DLRRCMessageTransfer
+ * @brief Fills Radio Bearer Config
*
* @details
*
- * Function : BuildAndSendDLRRCMessageTransfer
+ * Function : fillRadioBearerConfig
*
- * Functionality: Constructs the DL RRC Message Transfer and sends
- * it to the CU through SCTP.
+ * Functionality: Fills Radio Bearer Config
*
- * @params[in]
+ * @params[in] SRB_ToAddModList *
*
* @return ROK - success
* RFAILED - failure
*
* ****************************************************************/
-S16 BuildAndSendDLRRCMessageTransfer()
+uint8_t fillRadioBearerConfig(SRB_ToAddModList_t *bearerCfg)
{
- S16 ret;
- U8 elementCnt;
- U8 ieId;
- U8 idx;
- F1AP_PDU_t *f1apMsg = NULL;
- DLRRCMessageTransfer_t *dlRRCMsg;
- asn_enc_rval_t encRetVal; /* Encoder return value */
+ uint8_t elementCnt;
+ uint8_t idx;
+ uint8_t ied;
+ if(bearerCfg != NULLP)
+ {
+ elementCnt = 1;
+ bearerCfg->list.count = elementCnt;
+ bearerCfg->list.size =\
+ elementCnt * sizeof(SRB_ToAddMod_t *);
+ CU_ALLOC(bearerCfg->list.array, bearerCfg->list.size);
+ if(bearerCfg->list.array != NULLP)
+ {
+ for(idx = 0; idx < elementCnt; idx++)
+ {
+ CU_ALLOC(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
+ if(bearerCfg->list.array[idx] == NULLP)
+ {
+ for(ied = 0; ied < idx; ied++)
+ {
+ CU_FREE(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
+ }
+ CU_FREE(bearerCfg->list.array, bearerCfg->list.size);
+ return RFAILED;
+ }
+ }
+ }
+ else
+ {
+ return RFAILED;
+ }
+ idx = 0;
+ bearerCfg->list.array[idx]->srb_Identity = SRB1;
+ }
+ return ROK;
+}
- DU_LOG("\n F1AP : Building DL RRC Message Transfer Message\n");
+/*******************************************************************
+ *
+ * @brief Fills Master CellGroup Info
+ *
+ * @details
+ *
+ * Function : fillMasterCellGroup
+ *
+ * Functionality: Fills Master Cell Group IE
+ *
+ * @params[in] RRCSetup_IEs_t *
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
- CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
- if(f1apMsg == NULLP)
+uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup)
+{
+ uint8_t ret = ROK;
+ masterCellGroup->buf = NULLP;
+ if(f1apMsgDb.duToCuContainer.buf)
{
- DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
- RETVALUE(RFAILED);
+ masterCellGroup->size = f1apMsgDb.duToCuContainer.size;
+ CU_ALLOC(masterCellGroup->buf, masterCellGroup->size);
+ if(masterCellGroup->buf != NULLP)
+ {
+ memcpy(masterCellGroup->buf, f1apMsgDb.duToCuContainer.buf,\
+ masterCellGroup->size);
+ }
+ else
+ {
+ ret = RFAILED;
+ }
}
-
- f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
- CU_ALLOC(f1apMsg->choice.initiatingMessage,
- sizeof(InitiatingMessage_t));
- if(f1apMsg->choice.initiatingMessage == NULLP)
+ else
{
- DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
- CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
- }
+ ret = RFAILED;
+ }
+ return ret;
+}
- f1apMsg->choice.initiatingMessage->procedureCode = \
- ProcedureCode_id_DLRRCMessageTransfer;
- f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
- f1apMsg->choice.initiatingMessage->value.present = \
- InitiatingMessage__value_PR_DLRRCMessageTransfer;
- dlRRCMsg =
- &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
- elementCnt = 3;
- dlRRCMsg->protocolIEs.list.count = elementCnt;
- dlRRCMsg->protocolIEs.list.size = \
- elementCnt * sizeof(DLRRCMessageTransferIEs_t *);
-
- /* Initialize the F1Setup members */
- CU_ALLOC(dlRRCMsg->protocolIEs.list.array, \
- elementCnt * sizeof(DLRRCMessageTransferIEs_t *));
- if(dlRRCMsg->protocolIEs.list.array == NULLP)
- {
- DU_LOG(" F1AP : Memory allocation for DL RRC MessageTransferIEs failed");
- CU_FREE(f1apMsg->choice.initiatingMessage,
- sizeof(InitiatingMessage_t));
- CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
- }
+/*******************************************************************
+ *
+ * @brief Fills RRC setup IE
+ *
+ * @details
+ *
+ * Function : fillRRCSetupIE
+ *
+ * Functionality: Fills RRC Setup IE
+ *
+ * @params[in] RRCSetup_IEs_t *
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
- for(idx=0; idx<elementCnt; idx++)
- {
- CU_ALLOC(dlRRCMsg->protocolIEs.list.array[idx],\
- sizeof(DLRRCMessageTransferIEs_t));
- if(dlRRCMsg->protocolIEs.list.array[idx] == NULLP)
+uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE)
+{
+ uint8_t ret = ROK;
+ if(rrcSetupIE)
+ {
+ CU_ALLOC(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
+ if(rrcSetupIE->radioBearerConfig.srb_ToAddModList != NULLP)
{
- for(ieId=0; ieId<idx; ieId++)
+ ret = fillRadioBearerConfig(rrcSetupIE->radioBearerConfig.srb_ToAddModList);
+ }
+ if(!ret)
+ {
+ ret = fillMasterCellGroup(&rrcSetupIE->masterCellGroup);
+ }
+ else
+ {
+ CU_FREE(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
+ ret = RFAILED;
+ }
+ }
+ return ret;
+}
+/*******************************************************************
+ *
+ * @brief Builds RRC Container IE required for DLRRCMessageTransfer
+ *
+ * @details
+ *
+ * Function : BuildDLRRCContainer
+ *
+ * Functionality: Builds RRC Container IE required for
+ * DLRRCMessageTransfer
+ *
+ * @params[in]
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildDLRRCContainer(RRCContainer_t *rrcContainer)
+{
+ uint8_t ret = ROK;
+ uint16_t idx2;
+ DL_CCCH_Message_t dl_CCCH_Msg;
+ asn_enc_rval_t encRetVal;
+
+ if(rrcContainer != NULLP)
+ {
+ dl_CCCH_Msg.message.present = DL_CCCH_MessageType_PR_c1;
+
+ CU_ALLOC(dl_CCCH_Msg.message.choice.c1 , sizeof(DL_CCCH_MessageType_t));
+ if(dl_CCCH_Msg.message.choice.c1 != NULLP)
+ {
+ dl_CCCH_Msg.message.choice.c1->present = DL_CCCH_MessageType__c1_PR_rrcSetup;
+ CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup, sizeof(RRCSetup_t));
+ if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup != NULLP)
+ {
+ dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier = 0;
+ dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->criticalExtensions.\
+ present = RRCSetup__criticalExtensions_PR_rrcSetup;
+ /* Fill RRC Setup IE */
+ CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
+ criticalExtensions.choice.rrcSetup, sizeof(RRCSetup_IEs_t));
+ if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
+ criticalExtensions.choice.rrcSetup != NULLP)
+ {
+ ret = fillRRCSetupIE(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
+ criticalExtensions.choice.rrcSetup);
+
+ if(!ret)
+ {
+ /* encode DL-CCCH message into RRC Container */
+ xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg);
+ cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
+ encBufSize = 0;
+ encRetVal = aper_encode(&asn_DEF_DL_CCCH_MessageType, 0, &dl_CCCH_Msg, PrepFinalEncBuf, encBuf);
+ /* Encode results */
+ if(encRetVal.encoded == ENCODE_FAIL)
+ {
+ DU_LOG( "\n F1AP : Could not encode RRCContainer (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ return RFAILED;
+ }
+ else
+ {
+ DU_LOG("\n F1AP : Created APER encoded buffer for RRCContainer\n");
+ for(int i = 0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+ rrcContainer->size = encBufSize;
+ CU_ALLOC(rrcContainer->buf, rrcContainer->size);
+ if(rrcContainer->buf != NULLP)
+ {
+ memset(rrcContainer->buf, 0, encBufSize);
+ for(idx2 = 0; idx2 < encBufSize; idx2++)
+ {
+ rrcContainer->buf[idx2] = encBuf[idx2];
+ }
+ }
+ }
+ }
+ else
+ {
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Memory Alloc failed for RRC Setup Msg");
+ ret = RFAILED;
+ }
+ }
+ else
{
- CU_FREE(dlRRCMsg->protocolIEs.list.array[ieId],\
- sizeof(DLRRCMessageTransferIEs_t));
+ DU_LOG("\nF1AP: Memory Alloc failed for RRC Msg");
+ ret = RFAILED;
}
- CU_FREE(dlRRCMsg->protocolIEs.list.array,\
- elementCnt * sizeof(DLRRCMessageTransferIEs_t *));
- CU_FREE(f1apMsg->choice.initiatingMessage,\
- sizeof(InitiatingMessage_t));
- CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Memory Alloc failed for DL Ccch Msg choice");
+ ret = RFAILED;
}
+ }
+ else
+ {
+ DU_LOG("\nF1AP: Memory Alloc failed for DlCcch Msg");
+ ret = RFAILED;
}
+ return ret;
+}
- idx = 0;
-
- /*GNB CU UE F1AP ID*/
- dlRRCMsg->protocolIEs.list.array[idx]->id = \
- ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
- dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
- dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
- DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
- dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
-
- /*GNB DU UE F1AP ID*/
- idx++;
- dlRRCMsg->protocolIEs.list.array[idx]->id = \
- ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
- dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
- dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
- DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
- dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
+/*******************************************************************
+ *
+ * @brief Builds and sends the DLRRCMessageTransfer
+ *
+ * @details
+ *
+ * Function : BuildAndSendDLRRCMessageTransfer
+ *
+ * Functionality: Constructs the DL RRC Message Transfer and sends
+ * it to the CU through SCTP.
+ *
+ * @params[in]
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 BuildAndSendDLRRCMessageTransfer()
+{
+ uint8_t ret = ROK ;
+ uint8_t elementCnt = 0;
+ uint8_t ieId;
+ uint8_t idx;
+ uint16_t idx2;
+ F1AP_PDU_t *f1apMsg = NULLP;
+ DLRRCMessageTransfer_t *dlRRCMsg = NULLP;
+ asn_enc_rval_t encRetVal; /* Encoder return value */
+
+ DU_LOG("\n F1AP : Building DL RRC Message Transfer Message\n");
+
+ CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+ if(f1apMsg == NULLP)
+ {
+ DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
+ return RFAILED;
+ }
- /*SRBID*/
- idx++;
- dlRRCMsg->protocolIEs.list.array[idx]->id = \
- ProtocolIE_ID_id_SRBID;
- dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
- dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
- DLRRCMessageTransferIEs__value_PR_SRBID;
- dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = DL_SRBID;
+ f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
+ CU_ALLOC(f1apMsg->choice.initiatingMessage,
+ sizeof(InitiatingMessage_t));
+ if(f1apMsg->choice.initiatingMessage == NULLP)
+ {
+ DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
+ CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ return RFAILED;
+ }
- /*RRCContainer*/
- //YET TO FILL
+ f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_DLRRCMessageTransfer;
+ f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
+ f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_DLRRCMessageTransfer;
+ dlRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
- xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+ elementCnt = 4;
+ dlRRCMsg->protocolIEs.list.count = elementCnt;
+ dlRRCMsg->protocolIEs.list.size = elementCnt * sizeof(DLRRCMessageTransferIEs_t *);
- /* Encode the F1SetupRequest type as APER */
- cmMemset((U8 *)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( "\n F1AP : Could not encode DL RRC Message Transfer structure (at %s)\n",\
- encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
- RETVALUE(RFAILED);
- }
- else
- {
- DU_LOG("\n F1AP : Created APER encoded buffer for DL RRC Message transfer\n");
- for(int i=0; i< encBufSize; i++)
- {
- printf("%x",encBuf[i]);
- }
- }
+ /* Initialize the F1Setup members */
+ CU_ALLOC(dlRRCMsg->protocolIEs.list.array, dlRRCMsg->protocolIEs.list.size);
+ if(dlRRCMsg->protocolIEs.list.array == NULLP)
+ {
+ DU_LOG(" F1AP : Memory allocation for DL RRC MessageTransferIEs failed");
+ CU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
+ CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
+ return RFAILED;
+ }
- /* Sending msg */
- if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
- {
- DU_LOG("\n F1AP : Sending DL RRC Message Transfer Failed");
- RETVALUE(RFAILED);
- }
+ for(idx=0; idx<elementCnt; idx++)
+ {
+ CU_ALLOC(dlRRCMsg->protocolIEs.list.array[idx], sizeof(DLRRCMessageTransferIEs_t));
+ if(dlRRCMsg->protocolIEs.list.array[idx] == NULLP)
+ {
+ for(ieId=0; ieId<idx; ieId++)
+ {
+ CU_FREE(dlRRCMsg->protocolIEs.list.array[ieId],\
+ sizeof(DLRRCMessageTransferIEs_t));
+ }
+ CU_FREE(dlRRCMsg->protocolIEs.list.array,\
+ dlRRCMsg->protocolIEs.list.size);
+ CU_FREE(f1apMsg->choice.initiatingMessage,\
+ sizeof(InitiatingMessage_t));
+ CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
+ return RFAILED;
+ }
+ }
- RETVALUE(ROK);
+ /* GNB CU UE F1AP ID */
+ idx = 0;
+ dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+ dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
+ DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
+ dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
+
+ /* GNB DU UE F1AP ID */
+ idx++;
+ dlRRCMsg->protocolIEs.list.array[idx]->id = \
+ ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+ dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
+ DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
+ dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
+
+ /* SRBID */
+ idx++;
+ dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_SRBID;
+ dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
+ DLRRCMessageTransferIEs__value_PR_SRBID;
+ dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = SRB1;
+
+ /* RRCContainer */
+ idx++;
+ dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_RRCContainer;
+ dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+ dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
+ DLRRCMessageTransferIEs__value_PR_RRCContainer;
+ BuildDLRRCContainer(&dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer);
+
+ xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+ /* Encode the F1SetupRequest type as APER */
+ cmMemset((U8 *)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( "\n F1AP : Could not encode DL RRC Message Transfer structure (at %s)\n",\
+ encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+ return RFAILED;
+ }
+ else
+ {
+ DU_LOG("\n F1AP : Created APER encoded buffer for DL RRC Message transfer\n");
+ for(int i=0; i< encBufSize; i++)
+ {
+ printf("%x",encBuf[i]);
+ }
+ }
+
+ /* Sending msg */
+ if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
+ {
+ DU_LOG("\n F1AP : Sending DL RRC Message Transfer Failed");
+ return RFAILED;
+ }
+
+ return ROK;
}/* End of BuildAndSendDLRRCMessageTransfer */
if(f1apMsg == NULLP)
{
DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
- RETVALUE(RFAILED);
+ return RFAILED;
}
f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
{
DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
f1apMsg->choice.successfulOutcome->procedureCode = \
CU_FREE(f1apMsg->choice.successfulOutcome,
sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
for(idx=0; idx<elementCnt; idx++)
CU_FREE(f1apMsg->choice.successfulOutcome,\
sizeof(SuccessfulOutcome_t));
CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
- RETVALUE(RFAILED);
+ return RFAILED;
}
}
{
DU_LOG( "\n F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
- RETVALUE(RFAILED);
+ return RFAILED;
}
else
{
if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
{
DU_LOG("\n F1AP : Sending UE Context Setup Request Failed");
- RETVALUE(RFAILED);
+ return RFAILED;
}
- RETVALUE(ROK);
+ return ROK;
}/* End of BuildAndSendUESetRsp */
+
+
+uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t idx;
+ uint8_t ret =ROK;
+ InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
+ DU_LOG("\n filling the required values in DB in procInitULRRCMsg");
+
+ initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
+
+ for(idx=0; idx < initULRRCMsg->protocolIEs.list.count; idx++)
+ {
+ switch(initULRRCMsg->protocolIEs.list.array[idx]->id)
+ {
+ case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+ break;
+ case ProtocolIE_ID_id_NRCGI:
+ break;
+ case ProtocolIE_ID_id_C_RNTI:
+ break;
+ case ProtocolIE_ID_id_RRCContainer:
+ break;
+ case ProtocolIE_ID_id_DUtoCURRCContainer:
+ {
+ if((initULRRCMsg->protocolIEs.list.array[idx]->value.choice\
+ .DUtoCURRCContainer.size > 0) && (initULRRCMsg->protocolIEs\
+ .list.array[idx]->value.choice.DUtoCURRCContainer.buf != NULLP))
+ {
+ DU_LOG("\n Received Du to Cu RRC Container ");
+ f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\
+ .list.array[idx]->value.choice.DUtoCURRCContainer.size;
+ CU_ALLOC(f1apMsgDb.duToCuContainer.buf, \
+ f1apMsgDb.duToCuContainer.size);
+ if(f1apMsgDb.duToCuContainer.buf != NULLP)
+ {
+ memcpy(f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\
+ .list.array[idx]->value.choice.DUtoCURRCContainer.buf, f1apMsgDb\
+ .duToCuContainer.size);
+ }
+ }
+ else
+ {
+ DU_LOG("\n Failed to receive Du to Cu RRC Container ");
+ ret = RFAILED;
+ }
+ break;
+ }
+ default:
+ DU_LOG("\n Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id);
+ break;
+ }
+ }
+ if(!ret)
+ ret = BuildAndSendDLRRCMessageTransfer();
+ return ret;
+}
/*******************************************************************
*
* @brief Handles received F1AP message and sends back response
char *recvBuf;
MsgLen copyCnt;
MsgLen recvBufLen;
- F1AP_PDU_t *f1apMsg;
+ F1AP_PDU_t *f1apMsg = NULLP;
asn_dec_rval_t rval; /* Decoder return value */
F1AP_PDU_t f1apasnmsg ;
DU_LOG("\nF1AP : Received F1AP message buffer");
- SPrntMsg(mBuf, 0,0);
+ ODU_PRINT_MSG(mBuf, 0,0);
/* Copy mBuf into char array to decode it */
- SFndLenMsg(mBuf, &recvBufLen);
- if(SGetSBuf(DFLT_REGION, DFLT_POOL, (Data **)&recvBuf, (Size)recvBufLen) != ROK)
+ ODU_FIND_MSG_LEN(mBuf, &recvBufLen);
+ CU_ALLOC(recvBuf, (Size)recvBufLen);
+
+ if(recvBuf == NULLP)
{
DU_LOG("\nF1AP : Memory allocation failed");
return;
}
- if(SCpyMsgFix(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
+ if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
{
DU_LOG("\nF1AP : Failed while copying %d", copyCnt);
return;
memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
- SPutSBuf(DFLT_REGION, DFLT_POOL, (Data *)recvBuf, (Size)recvBufLen);
+ CU_FREE(recvBuf, (Size)recvBufLen);
+
if(rval.code == RC_FAIL || rval.code == RC_WMORE)
{
DU_LOG("\nF1AP : ASN decode failed");
{
DU_LOG("\nF1AP : F1 setup request received");
BuildAndSendF1SetupRsp();
- break;
+ break;
}
case InitiatingMessage__value_PR_GNBDUConfigurationUpdate:
BuildAndSendDUUpdateAck();
break;
}
-
+ case InitiatingMessage__value_PR_InitialULRRCMessageTransfer:
+ {
+ DU_LOG("\nF1AP : Received InitialULRRCMessageTransfer");
+ procInitULRRCMsg(f1apMsg);
+ break;
+ }
default:
{
DU_LOG("\nF1AP : Invalid type of intiating message [%d]",f1apMsg->choice.initiatingMessage->value.present);