/* This file contains F1AP message handler functions */
+#include "du_mgr.h"
#include "du_mgr_main.h"
-#include "du_cfg.h"
#include "du_cell_mgr.h"
#include "du_f1ap_msg_hdl.h"
+#include "GNB-DU-System-Information.h"
-char encBuf[ENC_BUF_MAX_LEN];
+extern char encBuf[ENC_BUF_MAX_LEN];
extern DuCfgParams duCfgParam;
-/*******************************************************************
- *
- * @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 Builds Uplink Info for NR
dlnrfreq->freqBandListNr.list.array[idx]->supportedSULBandList.list.count = SUL_BAND_COUNT;
RETVALUE(ROK);
}
-/*******************************************************************
- *
- * @brief Builds PLMN ID
- *
- * @details
- *
- * Function : BuildPlmn
- *
- * Functionality: Building the PLMN ID
- *
- * @params[in] PLMNID plmn
- * @return ROK - success
- * RFAILED - failure
- *
- * ****************************************************************/
-
-S16 BuildPlmn(PlmnId plmn, OCTET_STRING_t *plmnid)
-{
- U8 mncCnt;
- plmnid->size = 3;
- DU_ALLOC(plmnid->buf, plmnid->size * sizeof(U8));
- if(plmnid->buf == NULLP)
- {
- RETVALUE(RFAILED);
- }
- mncCnt = 2;
- plmnid->buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0]));
- if(mncCnt == 2)
- {
- plmnid->buf[1] = ((0xf0) | (plmn.mcc[2]));
- plmnid->buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0]));
- }
- else
- {
- plmnid->buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2]));
- plmnid->buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1]));
- }
- RETVALUE(ROK);
-}
-/*******************************************************************
- *
- * @brief Builds NRCell ID
- *
- * @details
- *
- * Function : BuildNrCellId
- *
- * Functionality: Building the NR Cell ID
- *
- * @params[in] BIT_STRING_t *nrcell
- * @return ROK - success
- * RFAILED - failure
- *
- * ****************************************************************/
-S16 BuildNrCellId(BIT_STRING_t *nrcell)
-{
- U8 tmp;
- nrcell->size = 5;
- DU_ALLOC(nrcell->buf, nrcell->size * sizeof(U8));
- if(nrcell->buf == NULLP)
- {
- RETVALUE(RFAILED);
- }
-
- for (tmp = 0 ; tmp < nrcell->size-1; tmp++)
- {
- nrcell->buf[tmp] = 0;
- }
- nrcell->buf[4] = 16;//change this
- nrcell->bits_unused = 4;
- RETVALUE(ROK);
-}
/*******************************************************************
*
* @brief Builds Nrcgi
S16 BuildNrcgi(NRCGI_t *nrcgi)
{
S16 ret;
+ U8 unused = 4;
+ U8 byteSize = 5;
+ U8 val = 16;
+
GNB_DU_Served_Cells_Item_t *srvCellItem;
- ret = BuildPlmn(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
+ /* Allocate Buffer Memory */
+ nrcgi->pLMN_Identity.size = PLMN_SIZE * sizeof(U8);
+ DU_ALLOC(nrcgi->pLMN_Identity.buf, nrcgi->pLMN_Identity.size);
+ ret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
&nrcgi->pLMN_Identity); // Building PLMN function
if(ret != ROK)
{
RETVALUE(RFAILED);
}
/*nrCellIdentity*/
- ret = BuildNrCellId(&nrcgi->nRCellIdentity);
+ //ret = BuildNrCellId(&nrcgi->nRCellIdentity);
+ nrcgi->nRCellIdentity.size = byteSize * sizeof(U8);
+ DU_ALLOC(nrcgi->nRCellIdentity.buf, nrcgi->nRCellIdentity.size);
+ ret = fillBitString(&nrcgi->nRCellIdentity, unused, byteSize, val);
+
if(ret != ROK)
{
DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
RETVALUE(RFAILED);
}
}
- ret = BuildPlmn(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
+ /* Allocate Memory to Buffer */
+ srvplmn->list.array[0]->pLMN_Identity.size = PLMN_SIZE * sizeof(U8);
+ DU_ALLOC(srvplmn->list.array[0]->pLMN_Identity.buf, srvplmn->list.array[0]->pLMN_Identity.size);
+ ret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
&srvplmn->list.array[0]->pLMN_Identity);
if(ret!= ROK)
{
RETVALUE(RFAILED);
}
srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf[0] = \
- duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
+ duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
+
+ /* GNB DU System Information */
+ DU_ALLOC(srvCellItem->gNB_DU_System_Information,
+ sizeof(GNB_DU_System_Information_t));
+ if(!srvCellItem->gNB_DU_System_Information)
+ {
+ DU_LOG("\nF1AP: Memory allocation failure for GNB_DU_System_Information");
+ return RFAILED;
+ }
+ /* MIB */
+ srvCellItem->gNB_DU_System_Information->mIB_message.size =\
+ strlen(duCfgParam.srvdCellLst[0].duSysInfo.mibMsg);
+ 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)
+ {
+ DU_LOG("\nF1AP: Memory allocation failure for mIB message");
+ return RFAILED;
+ }
+ strcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
+ duCfgParam.srvdCellLst[0].duSysInfo.mibMsg);
+
+ /* SIB1 */
+ srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
+ encBufSize;
+ DU_ALLOC(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,
+ srvCellItem->gNB_DU_System_Information->sIB1_message.size);
+ if(!srvCellItem->gNB_DU_System_Information->sIB1_message.buf)
+ {
+ DU_LOG("\nF1AP: Memory allocation failure for SIB1 message");
+ return RFAILED;
+ }
+ for(int x=0; x<srvCellItem->gNB_DU_System_Information->sIB1_message.size; x++)
+ {
+ srvCellItem->gNB_DU_System_Information->sIB1_message.buf[x]=\
+ duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg[x];
+ }
+ /* Free memory */
+ DU_FREE(duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, encBufSize);
+ DU_FREE(duCfgParam.srvdCellLst[0].duSysInfo.mibMsg,
+ strlen(duCfgParam.srvdCellLst[0].duSysInfo.mibMsg));
RETVALUE(ROK);
}
/*******************************************************************
{
SPrntMsg(mBuf, 0,0);
- if(sctpSend(mBuf) != ROK)
+ if(sctpSend(mBuf, F1_INTERFACE) != ROK)
{
DU_LOG("\nF1AP : SCTP Send failed");
SPutMsg(mBuf);
RETVALUE(ROK);
}/* End of BuildAndSendF1SetupReq */
-/*******************************************************************
- *
- * @brief Builds the PLMN Id
- *
- * @details
- *
- * Function : plmnBuild
- *
- * Functionality: Builds the PLMN Id
- *
- * @params[in] PlmnId plmn
- * @params[in] OCTET_STRING_t *octe
- *
- * @return ROK - success
- * RFAILED - failure
- *
- * ****************************************************************/
-void plmnBuild(PlmnId 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 and sends the DUConfigUpdate
RETVALUE(RFAILED);
}
}
- plmnBuild(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
+ buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
&modifyItem->oldNRCGI.pLMN_Identity);
/*nRCellIdentity*/
modifyItem->oldNRCGI.nRCellIdentity.size = 5;
DU_FREE(f1apDuCfg, sizeof(F1AP_PDU_t));
RETVALUE(RFAILED);
}
- plmnBuild(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
+ buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
&modifyItem->served_Cell_Information.nRCGI.pLMN_Identity);
modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size = 5;
DU_ALLOC(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
DU_FREE(f1apDuCfg, sizeof(F1AP_PDU_t));
RETVALUE(RFAILED);
}
- plmnBuild(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.plmn[0],\
+ buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.plmn[0],\
&modifyItem->served_Cell_Information.servedPLMNs.list.array[0]->pLMN_Identity);
DU_ALLOC(modifyItem->served_Cell_Information.servedPLMNs.list.\
array[0]->iE_Extensions,sizeof(struct ProtocolExtensionContainer_4624P3));