E2AP review changes part1
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index 2dd414b..713db1c 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);
+       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);
 }
 /*******************************************************************
@@ -976,7 +994,7 @@ S16 SendF1APMsg(Region region, Pool pool)
       {
          SPrntMsg(mBuf, 0,0);
  
-         if(sctpSend(mBuf) != ROK)
+         if(sctpSend(mBuf, F1_INTERFACE) != ROK)
          {
             DU_LOG("\nF1AP : SCTP Send failed");
             SPutMsg(mBuf);