Merging changes from ODU_Dev_Bronze_Rel to master 14/2614/1
authorBalaji Shankaran <balaji.shankaran@radisys.com>
Fri, 28 Feb 2020 11:08:16 +0000 (16:38 +0530)
committerBalaji Shankaran <balaji.shankaran@radisys.com>
Fri, 28 Feb 2020 11:08:19 +0000 (16:38 +0530)
Change-Id: I0b6db50c4e3adefbe3e7019bd23d47422a129eb1
Signed-off-by: Balaji Shankaran <balaji.shankaran@radisys.com>
build/common/du_app.mak
src/codec_utils/common/odu_common_codec.h [new file with mode: 0644]
src/du_app/du_cfg.c
src/du_app/du_cfg.h
src/du_app/du_f1ap_msg_hdl.c
src/du_app/du_f1ap_msg_hdl.h
src/du_app/du_sys_info_hdl.c [new file with mode: 0644]
src/du_app/du_sys_info_hdl.h [new file with mode: 0644]

index 3abb064..7c7bb2e 100755 (executable)
@@ -41,6 +41,7 @@ include $(COM_BUILD_DIR)/compile.mak
 I_OPTS+=-I$(ROOT_DIR)/src/mt
 I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/common
 I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/F1AP
+I_OPTS+=-I$(ROOT_DIR)/src/codec_utils/SYSINFO
 
 #-------------------------------------------------------------#
 #Linker macros
diff --git a/src/codec_utils/common/odu_common_codec.h b/src/codec_utils/common/odu_common_codec.h
new file mode 100644 (file)
index 0000000..36f5702
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+#ifndef __ODU_COMMON_CODEC_H__
+#define __ODU_COMMON_CODEC_H__
+
+#include "asn_codecs.h"
+
+#define ENC_BUF_MAX_LEN 200
+#define ENCODE_FAIL -1
+
+char encBuf[ENC_BUF_MAX_LEN];
+int  encBufSize;
+
+
+/*******************************************************************
+ *
+ * @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 */
+
+#endif
+
+/**********************************************************************
+         End of file
+**********************************************************************/
index d619686..4fd8612 100644 (file)
 
 /* This file contains all utility functions */
 #include "du_cfg.h"
+#include "MIB.h"
+#include "PLMN-IdentityInfo.h"
+#include "odu_common_codec.h"
 
 extern DuCfgParams duCfgParam;
+extern char encBuf[ENC_BUF_MAX_LEN];
 
 
 /* Filling Slot configuration as :
@@ -202,6 +206,8 @@ S16 readCfg()
 {
    U8 i,j,k;
    U32 ipv4_du, ipv4_cu;
+       MibParams mib;
+   Sib1Params sib1;    
 
    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
@@ -232,6 +238,32 @@ S16 readCfg()
    duCfgParam.duId = DU_ID;    
    strcpy((char*)duCfgParam.duName,DU_NAME);
 
+   /* Mib Params */
+       mib.sysFrmNum = SYS_FRAME_NUM;
+       mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
+       mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; 
+       mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
+       mib.controlResourceSetZero = CORESET_ZERO;
+       mib.searchSpaceZero = SEARCH_SPACE_ZERO;
+       mib.cellBarred = MIB__cellBarred_barred;
+       mib.intraFreqReselection =
+               MIB__intraFreqReselection_notAllowed;
+       duCfgParam.mibParams = mib;
+
+   /* SIB1 Params */
+       sib1.plmn.mcc[0] = PLMN_MCC0;
+       sib1.plmn.mcc[1] = PLMN_MCC1;
+       sib1.plmn.mcc[2] = PLMN_MCC2;
+       sib1.plmn.mnc[0] = PLMN_MNC0;
+       sib1.plmn.mnc[1] = PLMN_MNC1;
+       sib1.plmn.mnc[2] = PLMN_MNC2;
+       sib1.tac = DU_TAC;
+       sib1.ranac = DU_RANAC;
+       sib1.cellIdentity = CELL_IDENTITY;
+       sib1.cellResvdForOpUse =\ 
+               PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
+       duCfgParam.sib1Params = sib1;
+
    for(i=0; i<DEFAULT_CELLS; i++)
    { 
       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
@@ -357,14 +389,33 @@ S16 readCfg()
          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
       }
 
-      /*gnb DU System Info */
-      //TODO: uncomment duCfgParam.srvdCellLst[i].duSysInfo.mibMsg;  //to do
-      //TODO: uncomment duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg; //to do
-   }
+      /*gnb DU System Info mib msg*/
+          BuildMibMsg();
+               DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
+                               strlen(encBuf));
+          if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
+               {
+         DU_LOG("\nDU_APP: Memory allocation failure");
+                       return RFAILED;
+               }
+               strcpy(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
+
+      /*gnb DU System Info mib msg*/
+      BuildSib1Msg();
+               DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
+                               encBufSize);
+          if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
+               {
+         DU_LOG("\nDU_APP: Memory allocation failure");
+                       return RFAILED;
+               }
+               for(int x=0; x<encBufSize; x++)
+               {
+                  duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg[x]=\
+                       encBuf[x];
+          }
 
-   /* RRC Version,Extended RRC Version */
-   //TODO: uncomment duCfgParam.rrcVersion.rrcVer; //to do
-   //TODO: uncomment duCfgParam.rrcVersion.extRrcVer; //to do
+   }
 
    if(readClCfg() != ROK)
    {
index 4505daa..25be771 100644 (file)
 #define MAXNUMOFUACPERPLMN 64       /* Maximum number of signalled categories per PLMN */
 #define DEFAULT_CELLS      1        /* Max num of broadcast PLMN ids */
 
+
+/* Macro definitions for MIB/SIB1 */
+#define SYS_FRAME_NUM 0
+#define SPARE 0
+#define SSB_SC_OFFSET 8
+#define CORESET_ZERO 1
+#define SEARCH_SPACE_ZERO 8
+#define DU_RANAC 1
+#define CELL_IDENTITY 1
+
+
 typedef enum
 {
    GNBDU,
@@ -861,6 +872,27 @@ typedef struct schedulerCfg
    U8         maxDlUePerTti;  /*!< Max number of UE in DL per TTI */
 }SchedulerCfg;
 
+typedef struct mibParams
+{
+       uint8_t sysFrmNum;
+       long    subCarrierSpacingCommon;
+       long    ssb_SubcarrierOffset;
+       long    dmrs_TypeA_Position;
+       long    controlResourceSetZero;
+       long    searchSpaceZero;
+       long    cellBarred;
+       long    intraFreqReselection;
+}MibParams;
+
+typedef struct sib1Params
+{
+       PlmnId    plmn;
+       uint8_t   tac;
+       long      ranac;
+       U8        cellIdentity;
+       long      cellResvdForOpUse;
+}Sib1Params;
+
 typedef struct duCfgParams
 {
    F1SctpParams       sctpParams;                    /* SCTP Params */
@@ -873,7 +905,8 @@ typedef struct duCfgParams
    F1DuSrvdCellInfo   srvdCellLst[DU_MAX_CELLS];   /* Serving cell list *///TODO: this must be removed eventually
    F1RrcVersion       rrcVersion;                    /* RRC version */
    ClCellCfg          clCellCfg;                     /* CL cell configuration */
-
+   MibParams          mibParams;                     /* MIB Params */
+       Sib1Params         sib1Params;                    /* SIB1 Params */
 }DuCfgParams;
 
 typedef struct duCellCb
index 2dd414b..a91f059 100644 (file)
 #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 
@@ -861,7 +838,48 @@ S16 BuildServedCellList(GNB_DU_Served_Cells_List_t *duServedCell)
       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) + 1;
+       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);
 }
 /*******************************************************************
index 96cbeb1..2922d34 100644 (file)
 #include "ss_msg.x"
 
 #include "du_log.h"
+#include "odu_common_codec.h"
 
-#define ENCODE_FAIL -1
 #define TRANS_ID 1
 #define RRC_SIZE 1
-#define ENC_BUF_MAX_LEN 100
 #define SUL_BAND_COUNT 0
 #define UL_SRBID        1
 #define DL_SRBID        0
 #define CRNTI           17017
 #define CELL_INDEX      0
 
-
-
-
-extern char encBuf[ENC_BUF_MAX_LEN];
-int  encBufSize;
-
 void F1APMsgHdlr(Buffer *mBuf);
 S16 BuildAndSendF1SetupReq();
 S16 procGNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg);
diff --git a/src/du_app/du_sys_info_hdl.c b/src/du_app/du_sys_info_hdl.c
new file mode 100644 (file)
index 0000000..fa840f1
--- /dev/null
@@ -0,0 +1,486 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains ASN codec for MIB and SIB1 msgs */
+
+#include "du_sys_info_hdl.h"
+#include "MIB.h"
+#include "SIB1.h"
+#include "PLMN-IdentityInfo.h"
+#include "PLMN-IdentitY.h"
+#include "MCC.h"
+
+extern char encBuf[ENC_BUF_MAX_LEN];
+
+extern DuCfgParams duCfgParam;
+
+/*******************************************************************
+ *
+ * @brief Builds MIB message in Served Cell Info
+ *
+ * @details
+ *
+ *    Function : BuildMibMsg
+ *
+ *    Functionality: Building MIB message in Served Cell Info
+ *
+ * @params[in] GNB_DU_System_Information *gnbDuSysInfo
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+S16 BuildMibMsg()
+{
+       MIB_t          *mibMsg;
+       asn_enc_rval_t encRetVal;        /* Encoder return value */
+
+       DU_ALLOC(mibMsg, sizeof(MIB_t));
+       if(!mibMsg)
+       {
+               DU_LOG("DU APP: MIB msg memory allocation failure");
+               return RFAILED;
+       }
+       mibMsg->systemFrameNumber.size = sizeof(uint8_t);
+       DU_ALLOC(mibMsg->systemFrameNumber.buf, 
+                       mibMsg->systemFrameNumber.size);
+       if(!(mibMsg->systemFrameNumber.buf))
+       {
+               DU_LOG("DU APP: MIB msg memory allocation failure");
+               return RFAILED;
+       }
+
+       *(mibMsg->systemFrameNumber.buf) =
+               duCfgParam.mibParams.sysFrmNum;
+       mibMsg->systemFrameNumber.bits_unused = ODU_VALUE_TWO;
+
+       mibMsg->subCarrierSpacingCommon =\
+               duCfgParam.mibParams.subCarrierSpacingCommon;
+       mibMsg->ssb_SubcarrierOffset =\
+          duCfgParam.mibParams.ssb_SubcarrierOffset;
+       mibMsg->dmrs_TypeA_Position =\
+               duCfgParam.mibParams.dmrs_TypeA_Position;
+       mibMsg->pdcch_ConfigSIB1.controlResourceSetZero = \
+          duCfgParam.mibParams.controlResourceSetZero;
+       mibMsg->pdcch_ConfigSIB1.searchSpaceZero = \
+          duCfgParam.mibParams.searchSpaceZero;
+       mibMsg->cellBarred = duCfgParam.mibParams.cellBarred;
+       mibMsg->intraFreqReselection =
+               duCfgParam.mibParams.intraFreqReselection;
+       mibMsg->spare.size = sizeof(uint8_t);
+       DU_ALLOC(mibMsg->spare.buf,sizeof(uint8_t));
+       if(!mibMsg->spare.buf)
+       {
+               DU_LOG("DU APP: MIB msg memory allocation failure");
+               return RFAILED;
+       }
+       *(mibMsg->spare.buf) = SPARE;
+       mibMsg->spare.bits_unused = ODU_VALUE_SEVEN;
+
+       xer_fprint(stdout, &asn_DEF_MIB, mibMsg);
+       cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
+       encBufSize = 0;
+       encRetVal = aper_encode(&asn_DEF_MIB, 0,
+                                  mibMsg, PrepFinalEncBuf, encBuf);
+       printf("\nencbufSize:%d\n", encBufSize);
+       if(encRetVal.encoded    == -1) 
+       {   
+               DU_LOG("\nDU APP: Could not encode MIB structure(at %s)\n", 
+                               encRetVal.failed_type?\
+                               encRetVal.failed_type->name
+                               :"unknown");
+               return RFAILED;
+       }  
+
+       /* Print encoded buffer */
+       for(int i=0; i< encBufSize; i++)
+       {
+               printf("%x\t",encBuf[i]);
+       } 
+       printf("\n");
+
+       /* Free allocated memory */
+       DU_FREE(mibMsg->systemFrameNumber.buf,
+                       mibMsg->systemFrameNumber.size);
+       DU_FREE(mibMsg->spare.buf, mibMsg->spare.size);
+       DU_FREE(mibMsg, sizeof(MIB_t));
+
+   return ROK;
+
+}
+
+/*******************************************************************
+ *
+ * @brief Builds CellIdentity  within SIB1 message
+ *
+ * @details
+ *
+ *    Function : BuildCellIdentity
+ *
+ *    Functionality: Building RAN area code in SIB1 message 
+ *
+ * @params[in] RAN_AreaCode_t **ranAreaCode 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+S16 BuildCellIdentity(CellIdentity_t  *cellIdentity)
+{
+   cellIdentity->size = ODU_VALUE_FIVE*sizeof(uint8_t);
+       cellIdentity->bits_unused = ODU_VALUE_FOUR;
+
+       DU_ALLOC(cellIdentity->buf, cellIdentity->size);
+       if(!cellIdentity->buf)
+       {   
+               DU_LOG("DU APP: CellIdentity memory allocation failure");
+               return RFAILED;
+       }   
+   *cellIdentity->buf = duCfgParam.sib1Params.cellIdentity;
+
+   return ROK;
+}
+/*******************************************************************
+ *
+ * @brief Builds RANAC within SIB1 message
+ *
+ * @details
+ *
+ *    Function : BuildRanac
+ *
+ *    Functionality: Building RAN area code in SIB1 message 
+ *
+ * @params[in] RAN_AreaCode_t **ranAreaCode 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+S16 BuildRanac(RAN_AreaCode_t **ranAreaCode)
+{
+   RAN_AreaCode_t *ranac;
+   DU_ALLOC(ranac, sizeof(RAN_AreaCode_t));
+       if(!ranac)
+       {   
+               DU_LOG("DU APP: RANAC memory allocation failure");
+               return RFAILED;
+       }   
+   *ranac = duCfgParam.sib1Params.ranac;
+       *ranAreaCode = ranac;
+   return ROK;
+}
+/*******************************************************************
+ *
+ * @brief Builds TAC within SIB1 message
+ *
+ * @details
+ *
+ *    Function : BuildTac
+ *
+ *    Functionality: Building Tracking area code in SIB1 message 
+ *
+ * @params[in] TrackingAreaCode_t **tac 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+S16 BuildTac(TrackingAreaCode_t **trackAreaCode)
+{
+   TrackingAreaCode_t *tac;
+  
+
+   DU_ALLOC(tac, sizeof(TrackingAreaCode_t));
+       if(!tac)
+       {   
+               DU_LOG("DU APP: TAC memory allocation failure");
+               return RFAILED;
+       }   
+
+       tac->size = ODU_VALUE_THREE*sizeof(uint8_t);
+       DU_ALLOC(tac->buf, tac->size);
+       if(!tac->buf)
+       {   
+               DU_LOG("DU APP: TAC memory allocation failure");
+               return RFAILED;
+       }   
+       *(tac->buf) = duCfgParam.sib1Params.tac;
+       tac->bits_unused = ODU_VALUE_ZERO;
+       *trackAreaCode = tac;
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds PLMN list within SIB1 message
+ *
+ * @details
+ *
+ *    Function : BuildPlmnList
+ *
+ *    Functionality: Building PLMN list in SIB1 message 
+ *
+ * @params[in] CellAccessRelatedInfo_t *cellAccessInfo 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+S16 BuildPlmnList(CellAccessRelatedInfo_t *cellAccessInfo)
+{
+   U8                 idx, idx1, idx2;
+       U8                 elementCnt;
+       TrackingAreaCode_t **tac;
+       RAN_AreaCode_t     **ranac;
+       CellIdentity_t     *cellIdentity;
+       struct PLMN_IdentityInfo__plmn_IdentityList
+               *plmnIdInfo;
+
+       DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array,
+                       cellAccessInfo->plmn_IdentityList.list.size);
+       if(!cellAccessInfo->plmn_IdentityList.list.array)
+       {   
+               DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+               return RFAILED;
+       }   
+   elementCnt = cellAccessInfo->plmn_IdentityList.list.count; 
+       for(idx=0; idx<elementCnt; idx++)
+       {   
+               DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array[idx],
+                               sizeof(PLMN_IdentityInfo_t));
+               if(!cellAccessInfo->plmn_IdentityList.list.array[idx])
+               {
+                       DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+                       return RFAILED;
+               }
+       }
+
+       idx = 0;
+       /* PLMN list */
+       elementCnt = ODU_VALUE_ONE;
+
+       plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
+                                        plmn_IdentityList;
+       plmnIdInfo->list.count = elementCnt;
+       plmnIdInfo->list.size  = elementCnt * sizeof(PLMN_IdentitY_t);
+       DU_ALLOC(plmnIdInfo->list.array, plmnIdInfo->list.size);
+       if(!plmnIdInfo->list.array)
+       {
+               DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+               return RFAILED;
+       }
+       for(idx1=0; idx1<elementCnt; idx1++)
+       {
+               DU_ALLOC(plmnIdInfo->list.array[idx1],
+                               sizeof(PLMN_IdentitY_t));
+               if(!(plmnIdInfo->list.array[idx1]))
+               {
+                       DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+                       return RFAILED;
+               }
+       }
+       idx1 = 0;
+       DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc,
+                       sizeof(MCC_t));
+       if(!plmnIdInfo->list.array[idx1]->mcc)
+       {
+               DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+               return RFAILED;
+       }
+
+   elementCnt = ODU_VALUE_THREE;
+       plmnIdInfo->list.array[idx1]->mcc->list.count = elementCnt;
+       plmnIdInfo->list.array[idx1]->mcc->list.size =\
+               elementCnt * sizeof(MCC_MNC_Digit_t);
+       DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array,
+                       plmnIdInfo->list.array[idx1]->mcc->list.size)
+       if(!(plmnIdInfo->list.array[idx1]->mcc->list.array))
+       {
+               DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+               return RFAILED;
+       }
+       for(idx2=0; idx2<elementCnt; idx2++)
+       {
+               DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
+                               sizeof(MCC_MNC_Digit_t));
+               if(!plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])
+               {
+                       DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+                       return RFAILED;
+               }
+               *(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])=\
+                       duCfgParam.sib1Params.plmn.mcc[idx2];
+       }
+       idx2 = 0;
+       plmnIdInfo->list.array[idx1]->mnc.list.count = elementCnt;
+       plmnIdInfo->list.array[idx1]->mnc.list.size =\
+               elementCnt * sizeof(MCC_MNC_Digit_t);
+       DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array,
+                       plmnIdInfo->list.array[idx1]->mnc.list.size);
+       if(!plmnIdInfo->list.array[idx1]->mnc.list.array)
+       {
+               DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+               return RFAILED;
+       }
+       for(idx2=0; idx2<elementCnt; idx2++)
+       {
+               DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
+                               sizeof(MCC_MNC_Digit_t));
+               if(!plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])
+               {
+                       DU_LOG("DU APP: BuildPlmnList memory allocation failure");
+                       return RFAILED;
+               }
+               *(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])=\
+                       duCfgParam.sib1Params.plmn.mnc[idx2];
+       }
+
+   /* Tracking Area Code */
+   tac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
+       BuildTac(tac);
+
+   /* RANAC */
+       ranac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
+       BuildRanac(ranac);
+
+   /* CellIdentity */
+   cellIdentity =\
+       &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
+       BuildCellIdentity(cellIdentity);
+
+       /* cellReservedForOperatorUse */
+       cellAccessInfo->plmn_IdentityList.list.array[idx]->\
+               cellReservedForOperatorUse = \
+               duCfgParam.sib1Params.cellResvdForOpUse;
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds SIB message in Served Cell Info
+ *
+ * @details
+ *
+ *    Function : BuildSib1Msg
+ *
+ *    Functionality: Building SIB message in Served Cell Info
+ *
+ * @params[in] GNB_DU_System_Information *gnbDuSysInfo
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+S16 BuildSib1Msg()
+{
+       SIB1_t                   *sib1Msg;
+       CellAccessRelatedInfo_t  *cellAccessInfo;
+       U8                       elementCnt;
+       U8                       idx, idx1, idx2;
+       asn_enc_rval_t           encRetVal;
+       TrackingAreaCode_t       *tac;
+       RAN_AreaCode_t           *ranac;
+       CellIdentity_t           *cellIdentity;
+       struct PLMN_IdentityInfo__plmn_IdentityList
+               *plmnIdInfo;
+
+       DU_ALLOC(sib1Msg, sizeof(SIB1_t));
+       if(!sib1Msg)
+       {   
+               DU_LOG("DU APP: SIB1 msg memory allocation failure");
+               return RFAILED;
+       }   
+       elementCnt = ODU_VALUE_ONE;
+
+   /* PLMN list */
+       cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
+       cellAccessInfo->plmn_IdentityList.list.count =
+               elementCnt;
+       cellAccessInfo->plmn_IdentityList.list.size
+               = elementCnt * sizeof(PLMN_IdentityInfo_t);
+
+   BuildPlmnList(cellAccessInfo);
+
+   xer_fprint(stdout, &asn_DEF_SIB1, sib1Msg);
+
+       /* Encode the F1SetupRequest type as APER */
+       cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
+       encBufSize = 0;
+       encRetVal = aper_encode(&asn_DEF_SIB1, 0, sib1Msg, PrepFinalEncBuf,\
+                       encBuf);
+       printf("\nencbufSize: %d\n", encBufSize);
+       if(encRetVal.encoded == -1)
+       {
+               DU_LOG("\nDU APP : Could not encode SIB1 structure (at %s)\n",\
+                               encRetVal.failed_type ?
+                               encRetVal.failed_type->name :
+                               "unknown");
+               return RFAILED;
+       }
+       for(int i=0; i< encBufSize; i++)
+       {
+               printf("%x\t",encBuf[i]);
+       }
+       printf("\n");
+
+       /* Free allocated memeory */
+       /* Free PLMN List */
+
+       for(idx=0; idx<cellAccessInfo->plmn_IdentityList.list.count; idx++)
+       {
+               plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
+                                                plmn_IdentityList;
+               for(idx1=0; idx1<plmnIdInfo->list.count; idx1++)
+               {
+                       for(idx2=0; idx2<plmnIdInfo->list.array[idx1]->mnc.list.count; idx2++)
+                       {
+                               DU_FREE(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
+                                               sizeof(MCC_MNC_Digit_t));
+                               DU_FREE(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
+                                               sizeof(MCC_MNC_Digit_t));
+                       }
+                       DU_FREE(plmnIdInfo->list.array[idx1]->mcc->list.array,
+                                       plmnIdInfo->list.array[idx1]->mcc->list.size);
+                       DU_FREE(plmnIdInfo->list.array[idx1]->mnc.list.array,
+                                       plmnIdInfo->list.array[idx1]->mnc.list.size);
+                       DU_FREE(plmnIdInfo->list.array[idx1]->mcc,
+                                       sizeof(MCC_t));
+                       DU_FREE(plmnIdInfo->list.array[idx1],
+                                       sizeof(PLMN_IdentitY_t));
+               }
+               DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx],
+                               sizeof(PLMN_IdentityInfo_t));
+               cellIdentity =\
+                                                 &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
+               DU_FREE(cellIdentity->buf, cellIdentity->size);
+
+               ranac = cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
+               DU_FREE(ranac, sizeof(RAN_AreaCode_t));
+
+               tac = cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
+               DU_FREE(tac->buf, tac->size);
+               DU_FREE(tac, sizeof(TrackingAreaCode_t));
+       }
+       DU_FREE(cellAccessInfo->plmn_IdentityList.list.array,
+                       cellAccessInfo->plmn_IdentityList.list.size);
+
+       DU_FREE(sib1Msg, sizeof(SIB1_t));
+   return ROK;
+
+}
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
diff --git a/src/du_app/du_sys_info_hdl.h b/src/du_app/du_sys_info_hdl.h
new file mode 100644 (file)
index 0000000..8479c56
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+#include "du_mgr.h"
+#include "du_cfg.h"
+#include "du_log.h"
+#include "odu_common_codec.h"
+
+/* Macros */
+#define ODU_VALUE_ZERO 0
+#define ODU_VALUE_ONE 1
+#define ODU_VALUE_TWO 2
+#define ODU_VALUE_THREE 3
+#define ODU_VALUE_FOUR 4
+#define ODU_VALUE_FIVE 5
+#define ODU_VALUE_SEVEN 7
+
+/* Function declarations */
+S16 BuildMibMsg();
+S16 BuildSib1Msg();
+
+/**********************************************************************
+         End of file
+**********************************************************************/