[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-450] PAGING memory fixes
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index 543c65e..2bdb40a 100644 (file)
 
 /* This file contains F1AP message handler functions */
 #include "common_def.h"
+#include "ckw.h"
+#include "ckw.x"
+#include "kwu.h"
+#include "kwu.x"
+#include "lkw.h"
 #include "lrg.h"
 #include "legtp.h"
 #include "lkw.x"
@@ -27,7 +32,9 @@
 #include "du_cfg.h"
 #include "du_app_rlc_inf.h"
 #include "du_mgr_main.h"
+#include "du_mgr.h"
 #include "du_utils.h"
+#include "du_ue_mgr.h"
 #include "RAT-Type.h"
 #include "FeatureSetUplinkPerCC.h"
 #include "FeatureSetDownlinkPerCC.h"
 #include "UPTransportLayerInformation.h"
 #include "GTPTunnel.h"
 #include "SupportedSULFreqBandItem.h"
-#include "du_sys_info_hdl.h"
 #include "du_e2ap_msg_hdl.h"
 #include "du_f1ap_conversions.h"
+#include "CNUEPagingIdentity.h"
+#include "PCCH-Config.h"
+#include "SCS-SpecificCarrier.h"
+#include "FrequencyInfoDL.h"
+#include "DownlinkConfigCommon.h"
+#include "FrequencyInfoUL.h"
+#include "UplinkConfigCommon.h"
+#include "TDD-UL-DL-ConfigCommon.h"
+#include "RACH-ConfigDedicated.h"
+#include "CFRA-SSB-Resource.h"
+#include "BWP-UplinkCommon.h"
+#include "ReconfigurationWithSync.h"
+#include "du_sys_info_hdl.h"
 
 #ifdef O1_ENABLE
 #include "CmInterface.h"
@@ -343,30 +362,6 @@ uint8_t BuildDLNRInfo(NRFreqInfo_t *dlnrfreq)
    return 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)
-{
-   memset(nrcell->buf, 0, nrcell->size);
-   nrcell->buf[4]   = duCfgParam.sib1Params.cellIdentity; 
-   nrcell->bits_unused = 4;
-   return ROK;
-}
-
 /*******************************************************************
  *
  * @brief Builds Nrcgi 
@@ -406,7 +401,7 @@ uint8_t BuildNrcgi(NRCGI_t *nrcgi)
    {
       return RFAILED;
    }
-   BuildNrCellId(&nrcgi->nRCellIdentity);
+   fillBitString(&nrcgi->nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
 
    return ROK;
 }
@@ -2829,8 +2824,8 @@ uint8_t BuildBsrConfig(DuUeCb *ueCb, struct BSR_Config *bsrConfig)
    }
    else
    {
-      bsrConfig->periodicBSR_Timer = ueCb->macUeCfg.macCellGrpCfg.bsrTmrCfg.periodicTimer;
-      bsrConfig->retxBSR_Timer     = ueCb->macUeCfg.macCellGrpCfg.bsrTmrCfg.retxTimer;
+      bsrConfig->periodicBSR_Timer = convertBsrPeriodicTmrValueToEnum(ueCb->macUeCfg.macCellGrpCfg.bsrTmrCfg.periodicTimer);
+      bsrConfig->retxBSR_Timer     = convertBsrRetxTmrValueToEnum(ueCb->macUeCfg.macCellGrpCfg.bsrTmrCfg.retxTimer);
 
       bsrConfig->logicalChannelSR_DelayTimer = NULLP;
       DU_ALLOC(bsrConfig->logicalChannelSR_DelayTimer, sizeof(long));
@@ -3317,12 +3312,20 @@ uint8_t BuildMacLCConfig(LcCfg *lcCfgDb, struct LogicalChannelConfig *macLcConfi
  * ****************************************************************/
 uint8_t BuildRlcBearerToAddModList(DuUeCb *ueCb, struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
 {
-   uint8_t  idx = 0, macLcIdx = 0, elementCnt = 0;
+   uint8_t  idx = 0, lcIdx=0, macLcIdx = 0, elementCnt = 0;
 
    if(ueCb == NULLP)
       elementCnt = 1;
-   else
+   else if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
       elementCnt = ueCb->rlcUeCfg.numLcs;
+   else
+   {
+      for(lcIdx = 0; lcIdx<ueCb->rlcUeCfg.numLcs; lcIdx++)
+      {
+         if(ueCb->rlcUeCfg.rlcLcCfg[lcIdx].isLcAddModRspSent == false)
+            elementCnt++;
+      }
+   }
    rlcBearerList->list.count = elementCnt;
    rlcBearerList->list.size  = elementCnt * sizeof(struct RLC_BearerConfig *);
 
@@ -3345,93 +3348,109 @@ uint8_t BuildRlcBearerToAddModList(DuUeCb *ueCb, struct CellGroupConfigRrc__rlc_
       }
    }
 
-   for(idx=0; idx<rlcBearerList->list.count; idx++)
+   if(ueCb == NULLP)
    {
-      /* Fill Logical channel identity */
-      if(ueCb == NULLP)
-         rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
-      else
-         rlcBearerList->list.array[idx]->logicalChannelIdentity = ueCb->rlcUeCfg.rlcLcCfg[idx].lcId;
-
-      /* Fill Radio Bearer Id and type (DRB/SRB) for this logical channel */
+      idx=0;
+      rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
       DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
       if(!rlcBearerList->list.array[idx]->servedRadioBearer)
+      {     
+         DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
+         return RFAILED;
+      }     
+      rlcBearerList->list.array[idx]->servedRadioBearer->present = RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
+      rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = SRB1_LCID;
+      rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
+
+      /* Fill RLC related Configurations for this Radio Bearer */
+      rlcBearerList->list.array[idx]->rlc_Config = NULLP;
+      DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
+      if(!rlcBearerList->list.array[idx]->rlc_Config)
       {
          DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
          return RFAILED;
       }
-      if(ueCb == NULLP)
+      if(BuildRlcConfig(NULLP, rlcBearerList->list.array[idx]->rlc_Config) != ROK)
       {
-         rlcBearerList->list.array[idx]->servedRadioBearer->present = RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
-         rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = SRB1_LCID;
+         DU_LOG("\nERROR  -->  F1AP : BuildRlcConfig failed");
+         return RFAILED;
       }
-      else
+
+      /* Fill MAC related configurations for this Radio Bearer */
+      rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
+      DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
+      if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
+         return RFAILED;
+      }
+      if(BuildMacLCConfig(NULLP, rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
+      {
+         DU_LOG("\nERROR  -->  F1AP : BuildMacLCConfig failed");
+         return RFAILED;
+      }
+   }
+   else
+   {
+      idx=0;
+      for(lcIdx=0; lcIdx<ueCb->rlcUeCfg.numLcs; lcIdx++)
       {
+         if((ueCb->f1UeDb->actionType != UE_CTXT_CFG_QUERY) && (ueCb->rlcUeCfg.rlcLcCfg[lcIdx].isLcAddModRspSent == true))
+            continue;
+
+         /* Fill Logical channel identity */
+         rlcBearerList->list.array[idx]->logicalChannelIdentity = ueCb->rlcUeCfg.rlcLcCfg[lcIdx].lcId;
+
+         /* Fill Radio Bearer Id and type (DRB/SRB) for this logical channel */
+         DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
+         if(!rlcBearerList->list.array[idx]->servedRadioBearer)
+         {
+            DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
+            return RFAILED;
+         }
          rlcBearerList->list.array[idx]->servedRadioBearer->present = \
-            covertRbTypeFromIntEnumToRrcEnum(ueCb->rlcUeCfg.rlcLcCfg[idx].rbType);
+                                                                      covertRbTypeFromIntEnumToRrcEnum(ueCb->rlcUeCfg.rlcLcCfg[lcIdx].rbType);
          switch(rlcBearerList->list.array[idx]->servedRadioBearer->present)
          {
             case RLC_BearerConfig__servedRadioBearer_PR_srb_Identity: 
-               rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = ueCb->rlcUeCfg.rlcLcCfg[idx].rbId;
+               rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = ueCb->rlcUeCfg.rlcLcCfg[lcIdx].rbId;
                break;
             case RLC_BearerConfig__servedRadioBearer_PR_drb_Identity:
-               rlcBearerList->list.array[idx]->servedRadioBearer->choice.drb_Identity = ueCb->rlcUeCfg.rlcLcCfg[idx].rbId;
+               rlcBearerList->list.array[idx]->servedRadioBearer->choice.drb_Identity = ueCb->rlcUeCfg.rlcLcCfg[lcIdx].rbId;
                break;
             case RLC_BearerConfig__servedRadioBearer_PR_NOTHING:
             default:
                break;
          }
-      }
+         ueCb->rlcUeCfg.rlcLcCfg[lcIdx].isLcAddModRspSent = true;
 
-      rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
+         rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
 
-      /* Fill RLC related Configurations for this Radio Bearer */
-      rlcBearerList->list.array[idx]->rlc_Config = NULLP;
-      DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
-      if(!rlcBearerList->list.array[idx]->rlc_Config)
-      {
-         DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
-         return RFAILED;
-      }
-      if(ueCb == NULLP)
-      {
-         if(BuildRlcConfig(NULLP, rlcBearerList->list.array[idx]->rlc_Config) != ROK)
+         /* Fill RLC related Configurations for this Radio Bearer */
+         rlcBearerList->list.array[idx]->rlc_Config = NULLP;
+         DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
+         if(!rlcBearerList->list.array[idx]->rlc_Config)
          {
-            DU_LOG("\nERROR  -->  F1AP : BuildRlcConfig failed");
+            DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
             return RFAILED;
          }
-      }
-      else
-      {
-         if(BuildRlcConfig(&ueCb->rlcUeCfg.rlcLcCfg[idx], rlcBearerList->list.array[idx]->rlc_Config) != ROK)
+         if(BuildRlcConfig(&ueCb->rlcUeCfg.rlcLcCfg[lcIdx], rlcBearerList->list.array[idx]->rlc_Config) != ROK)
          {
             DU_LOG("\nERROR  -->  F1AP : BuildRlcConfig failed");
             return RFAILED;
          }
-      }
-
-      /* Fill MAC related configurations for this Radio Bearer */
-      rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
-      DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
-      if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
-      {
-         DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
-         return RFAILED;
-      }
 
-      if(ueCb == NULLP)
-      {
-         if(BuildMacLCConfig(NULLP, rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
+         /* Fill MAC related configurations for this Radio Bearer */
+         rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
+         DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
+         if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
          {
-            DU_LOG("\nERROR  -->  F1AP : BuildMacLCConfig failed");
+            DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
             return RFAILED;
          }
-      }
-      else
-      {
          for(macLcIdx = 0; macLcIdx < ueCb->macUeCfg.numLcs; macLcIdx++)
          {
-            if(ueCb->macUeCfg.lcCfgList[macLcIdx].lcId == ueCb->rlcUeCfg.rlcLcCfg[idx].lcId)
+            if(ueCb->macUeCfg.lcCfgList[macLcIdx].lcId == ueCb->rlcUeCfg.rlcLcCfg[lcIdx].lcId)
             {
                if(BuildMacLCConfig(&ueCb->macUeCfg.lcCfgList[macLcIdx], rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
                {
@@ -3441,6 +3460,8 @@ uint8_t BuildRlcBearerToAddModList(DuUeCb *ueCb, struct CellGroupConfigRrc__rlc_
                break;
             }
          }
+
+         idx++;
       }
    }
    return ROK;
@@ -4008,7 +4029,8 @@ elementCnt = pdschCfg->numTimeDomRsrcAlloc;
             DU_LOG("\nERROR  -->  F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
             return RFAILED;
          }
-         *(timeDomAlloc->k0) = *(pdschCfg->timeDomRsrcAllociList[idx].k0);
+         if(pdschCfg->timeDomRsrcAllociList[idx].k0)
+            *(timeDomAlloc->k0) = *(pdschCfg->timeDomRsrcAllociList[idx].k0);
          timeDomAlloc->mappingType = pdschCfg->timeDomRsrcAllociList[idx].mappingType;
          timeDomAlloc->startSymbolAndLength = pdschCfg->timeDomRsrcAllociList[idx].startSymbolAndLength;
       }
@@ -5304,7 +5326,7 @@ uint8_t BuildBWPUlDedPucchCfg(PucchCfg *pucchCfgDb, PUCCH_Config_t *pucchCfg)
    /* Multi CSI */
    if(multiCsiDb && (multiCsiDb->multiCsiResrcListCount != 0))
    {
-      pucchCfg->multi_CSI_PUCCH_ResourceList == NULLP;
+      pucchCfg->multi_CSI_PUCCH_ResourceList = NULLP;
       DU_ALLOC(pucchCfg->multi_CSI_PUCCH_ResourceList, sizeof(struct PUCCH_Config__multi_CSI_PUCCH_ResourceList));
       if(pucchCfg->multi_CSI_PUCCH_ResourceList == NULLP)
       {
@@ -6151,209 +6173,907 @@ uint8_t BuildSpCellCfgDed(DuUeCb *ueCb, ServingCellConfig_t *srvCellCfg)
 
    return ROK;
 }
+
 /*******************************************************************
  *
- * @brief Builds Spcell config 
+ * @brief Fills SCS specific carrier list in DL frequency info
  *
  * @details
  *
- *    Function : BuildSpCellCfg 
+ *    Function : BuildScsSpecificCarrierListDl
  *
- *    Functionality: Builds sp cell config in DuToCuRrcContainer
+ *    Functionality: Fills SCS specific carrier list in DL frequency info
  *
- * @params[in] SpCellConfig_t spCellCfg
+ * @params[in] Pointer to struct FrequencyInfoDL__scs_SpecificCarrierList
  *
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t BuildSpCellCfg(DuUeCb *ueCb, SpCellConfig_t *spCellCfg)
+uint8_t BuildScsSpecificCarrierListDl(struct FrequencyInfoDL__scs_SpecificCarrierList *scsCarrierList)
 {
-   spCellCfg->servCellIndex = NULLP;
-   DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
-   if(!spCellCfg->servCellIndex)
+   uint8_t elementCnt = 0, listIdx = 0;
+   ScsSpecCarrier duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
+
+   elementCnt = ODU_VALUE_ONE;
+   scsCarrierList->list.count = elementCnt;
+   scsCarrierList->list.size = elementCnt * sizeof(SCS_SpecificCarrier_t *);
+
+   DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
+   if(!scsCarrierList->list.array)
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildSpCellCfg");
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for scs carrier list array \
+         in BuildScsSpecificCarrierListDl()");
       return RFAILED;
    }
 
-   if(ueCb == NULLP)
-      *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
-   else
-      *(spCellCfg->servCellIndex) = ueCb->macUeCfg.spCellCfg.servCellIdx;
+   for(listIdx = 0; listIdx < elementCnt; listIdx++)
+   {
+      DU_ALLOC(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
+      if(!scsCarrierList->list.array[listIdx])
+      {    
+         DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for SCS Specific Carrier list array \
+            element in BuildScsSpecificCarrierListDl()");
+         return RFAILED;
+      }    
+   }
 
-   spCellCfg->reconfigurationWithSync = NULLP;
-   spCellCfg->rlf_TimersAndConstants = NULLP;
-   spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
+   listIdx = 0;
+   scsCarrierList->list.array[listIdx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
+   scsCarrierList->list.array[listIdx]->subcarrierSpacing = duScsSpecCarrier.scs;
+   scsCarrierList->list.array[listIdx]->carrierBandwidth = duScsSpecCarrier.scsBw;
 
-   DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
-   if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills DL frequency info in DL config common
+ *
+ * @details
+ *
+ *    Function : BuildFreqInfoDl
+ *
+ *    Functionality: Fills DL frequency info in DL config common
+ *
+ * @params[in] Pointer to DownlinkConfigCommon_t
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildFreqInfoDl(FrequencyInfoDL_t *frequencyInfoDL)
+{
+   uint8_t freqBandIdx = 0, elementCnt = 0;
+   DlCfgCommon  dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
+
+   /* TODO : Fill SSB Absolute Frequency */
+   /*
+      DU_ALLOC(frequencyInfoDL->absoluteFrequencySSB, sizeof(ARFCN_ValueNR_t));
+      if(!frequencyInfoDL->absoluteFrequencySSB)
+      {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for SSB Absolute Frequency in BuildFreqInfoDl()");
+      return RFAILED;
+      }
+      frequencyInfoDL->absoluteFrequencySSB = ?;
+      */
+
+   /* NR Multi Frequency Band List */
+   elementCnt = ODU_VALUE_ONE;
+   frequencyInfoDL->frequencyBandList.list.count = elementCnt;
+   frequencyInfoDL->frequencyBandList.list.size = elementCnt * sizeof(FreqBandIndicatorNR_t *);
+
+   DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, frequencyInfoDL->frequencyBandList.list.size);
+   if(!frequencyInfoDL->frequencyBandList.list.array)
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildSpCellCfg");
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for Frequency Band List array in BuildFreqInfoDl()");
       return RFAILED;
    }
-   *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
 
-   spCellCfg->spCellConfigDedicated = NULLP;
-   DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
-   if(!spCellCfg->spCellConfigDedicated)
+   for(freqBandIdx = 0; freqBandIdx < elementCnt; freqBandIdx++)
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildSpCellCfg");
-      return RFAILED;
+      DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx], sizeof(FreqBandIndicatorNR_t));
+      if(!frequencyInfoDL->frequencyBandList.list.array[freqBandIdx])
+      {
+         DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for frequency band array element in BuildFreqInfoDl()");
+         return RFAILED;
+      }
    }
-   if(BuildSpCellCfgDed(ueCb, spCellCfg->spCellConfigDedicated) != ROK)
+
+   freqBandIdx = 0;
+   *(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx]) = dlCfg.freqBandInd;
+
+   /* TODO : Absolute Frequency to Point A */
+   //frequencyInfoDL->absoluteFrequencyPointA
+
+   /* Subcarrier Spacing specifc carrier List */
+   if((BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList)) != ROK)
    {
-      DU_LOG("\nERROR  -->  F1AP : BuildSpCellCfgDed failed");
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill SCS specific carrier list DL in BuildFreqInfoDl()");
       return RFAILED;
    }
 
    return ROK;
+
 }
 
 /*******************************************************************
  *
- * @brief Builds Phy cell group config 
+ * @brief Fills DL config common in Serving cell config common
  *
  * @details
  *
- *    Function : BuildPhyCellGrpCfg 
+ *    Function : BuildDlConfigCommon
  *
- *    Functionality: Builds Phy cell group config in DuToCuRrcContainer
+ *    Functionality: Fills DL config common in Serving cell config common
  *
- * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg 
+ * @params[in] Pointer to DownlinkConfigCommon_t
  *
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t BuildPhyCellGrpCfg(DuUeCb *ueCb, PhysicalCellGroupConfig_t *phyCellGrpCfg)
+uint8_t BuildDlConfigCommon(DownlinkConfigCommon_t *dlCfgCommon)
 {
-   phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
-   phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
-
-   phyCellGrpCfg->p_NR_FR1 = NULLP;
-   DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
-   if(!phyCellGrpCfg->p_NR_FR1)
+   /* DL Frequency Info */
+   DU_ALLOC(dlCfgCommon->frequencyInfoDL, sizeof(FrequencyInfoDL_t));
+   if(!dlCfgCommon->frequencyInfoDL)
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
+      DU_LOG("\nERROR  --> DU APP : Memory allocation failed for DL frequency info in BuildDlConfigCommon()");
+      return RFAILED;
+   }
+   if((BuildFreqInfoDl(dlCfgCommon->frequencyInfoDL))!= ROK)
+   {
+      DU_LOG("\nERROR  --> DU APP : Failed to fill DL frequency info in BuildDlConfigCommon()");
       return RFAILED;
    }
 
-   if(ueCb == NULLP)
+   /* DL BWP config common */
+   DU_ALLOC(dlCfgCommon->initialDownlinkBWP, sizeof(BWP_DownlinkCommon_t));
+   if(!dlCfgCommon->initialDownlinkBWP)
    {
-      *(phyCellGrpCfg->p_NR_FR1)             = P_NR_FR1;
-      phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
+      DU_LOG("\nERROR  --> DU APP : Memory allocation failed for DL BWP config common in BuildDlConfigCommon()");
+      return RFAILED;
    }
-   else
+   if((BuildBwpDlCommon(dlCfgCommon->initialDownlinkBWP)) != ROK)
    {
-      *(phyCellGrpCfg->p_NR_FR1) = ueCb->macUeCfg.phyCellGrpCfg.pNrFr1;
-      phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = ueCb->macUeCfg.phyCellGrpCfg.pdschHarqAckCodebook;
+      DU_LOG("\nERROR  --> DU APP : Failed to fill DL DWP config common in BuildDlConfigCommon()");
+      return RFAILED;
    }
 
-   phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
-   phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
-   phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
-   phyCellGrpCfg->sp_CSI_RNTI = NULLP;
-   phyCellGrpCfg->cs_RNTI = NULLP;
-   phyCellGrpCfg->ext1 = NULLP;
-   phyCellGrpCfg->ext2 = NULLP;
-
    return ROK;
 }
 
 /*******************************************************************
  *
- * @brief Builds Mac cell group config 
+ * @brief Fills SCS specific carrier list in UL frequency Info
  *
  * @details
  *
- *    Function : BuildMacCellGrpCfg 
+ *    Function : BuildScsSpecificCarrierListUl
  *
- *    Functionality: Builds Mac cell group config in DuToCuRrcContainer
+ *    Functionality: Fills SCS specific carrier list in UL frequency Info
  *
- * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
+ * @params[in] Pointer to struct FrequencyInfoUL__scs_SpecificCarrierList
  *
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t BuildMacCellGrpCfg(DuUeCb *ueCb, MAC_CellGroupConfig_t *macCellGrpCfg)
+uint8_t BuildScsSpecificCarrierListUl(struct FrequencyInfoUL__scs_SpecificCarrierList *scsCarrierList)
 {
-   macCellGrpCfg->drx_Config = NULLP;
-   macCellGrpCfg->schedulingRequestConfig = NULLP;
-   DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
-   if(!macCellGrpCfg->schedulingRequestConfig)
+   uint8_t elementCnt = 0, listIdx = 0; 
+   ScsSpecCarrier   duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
+
+   elementCnt = ODU_VALUE_ONE;
+   scsCarrierList->list.count = elementCnt;
+   scsCarrierList->list.size = elementCnt * sizeof(SCS_SpecificCarrier_t *);
+
+   DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
+   if(!scsCarrierList->list.array)
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
+      DU_LOG("\nERROR  -->  DU APP : SCS Specific Carrier list memory allocation failed");
       return RFAILED;
    }
 
-   if(BuildSchedulingReqConfig(ueCb, macCellGrpCfg->schedulingRequestConfig) != ROK)
+   for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
    {
-      DU_LOG("\nERROR  -->  F1AP : BuildSchedulingReqConfig failed");
-      return RFAILED;
+      DU_ALLOC(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
+      if(!scsCarrierList->list.array[listIdx])
+      {    
+         DU_LOG("\nERROR  -->  DU APP : SCS Specific Carrier list memory allocation failed");
+         return RFAILED;
+      }    
    }
+   listIdx = 0; 
+   scsCarrierList->list.array[listIdx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
+   scsCarrierList->list.array[listIdx]->subcarrierSpacing = duScsSpecCarrier.scs;
+   scsCarrierList->list.array[listIdx]->carrierBandwidth = duScsSpecCarrier.scsBw;
 
-   macCellGrpCfg->bsr_Config = NULLP;
-   DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
-   if(!macCellGrpCfg->bsr_Config)
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills frequency info in UL config common
+ *
+ * @details
+ *
+ *    Function : BuildFreqInfoUl
+ *
+ *    Functionality: Fills frequency info in UL config common
+ *
+ * @params[in] Pointer to FrequencyInfoUL_t
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildFreqInfoUl(FrequencyInfoUL_t *frequencyInfoUL)
+{
+   uint8_t elementCnt = 0, listIdx= 0;
+   UlCfgCommon  ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
+
+   /* NR Multi Frequency Band List */
+   DU_ALLOC(frequencyInfoUL->frequencyBandList, sizeof(MultiFrequencyBandListNR_t));
+   if(!frequencyInfoUL->frequencyBandList)
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for frequency band list in BuildFreqInfoUl()");
       return RFAILED;
    }
 
-   if(BuildBsrConfig(ueCb, macCellGrpCfg->bsr_Config) != ROK)
+   elementCnt = ODU_VALUE_ONE;
+   frequencyInfoUL->frequencyBandList->list.count = elementCnt;
+   frequencyInfoUL->frequencyBandList->list.size = elementCnt * sizeof(FreqBandIndicatorNR_t *);
+
+   DU_ALLOC(frequencyInfoUL->frequencyBandList->list.array, frequencyInfoUL->frequencyBandList->list.size);
+   if(!frequencyInfoUL->frequencyBandList->list.array)
    {
-      DU_LOG("\nERROR  -->  F1AP : BuildBsrConfig failed");
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for frequency band array in BuildFreqInfoUl()");
       return RFAILED;
    }
 
-   macCellGrpCfg->tag_Config = NULLP;
-   DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
-   if(!macCellGrpCfg->tag_Config)
+   for(listIdx = 0; listIdx < elementCnt; listIdx++)
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
-      return RFAILED;
+      DU_ALLOC(frequencyInfoUL->frequencyBandList->list.array[listIdx], sizeof(FreqBandIndicatorNR_t));
+      if(!frequencyInfoUL->frequencyBandList->list.array[listIdx])
+      {
+         DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for frequency band array element in BuildFreqInfoUl()");
+         return RFAILED;
+      }
    }
 
-   if(BuildTagConfig(ueCb, macCellGrpCfg->tag_Config) != ROK)
-   {
-      DU_LOG("\nERROR  -->  F1AP : BuildTagConfig failed");
+   listIdx = 0;
+   *(frequencyInfoUL->frequencyBandList->list.array[listIdx]) = ulCfg.freqBandInd;
+
+   /* TODO : Fill Absolute frequency point A */
+   /*
+      DU_ALLOC(frequencyInfoUL->absoluteFrequencyPointA, sizeof(ARFCN_ValueNR_t));
+      if(!frequencyInfoUL->absoluteFrequencyPointA)
+      {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for absolute frequency point A in BuildFreqInfoUl()");
       return RFAILED;
-   }
+      }
+    *(frequencyInfoUL->absoluteFrequencyPointA) = ?;
+    */
 
-   macCellGrpCfg->phr_Config = NULLP;
-   DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
-   if(!macCellGrpCfg->phr_Config)
+   /* Subcarrier Spacing specifc carrier */
+   if((BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList)) != ROK) 
    {
-      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
+      DU_LOG("\nERROR  --> DU APP : Failed to fill SCS Specific Carrier list UL in BuildFreqInfoUl()");
       return RFAILED;
    }
 
-   if(BuildPhrConfig(ueCb, macCellGrpCfg->phr_Config) != ROK)
+   /* P-MAX */
+   DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
+   if(!frequencyInfoUL->p_Max)
    {
-      DU_LOG("\nERROR  -->  F1AP : BuildPhrConfig failed");
+      DU_LOG("\nERROR  -->  DU APP : UL Frequency Infoo  memory allocation failure");
       return RFAILED;
    }
-
-   macCellGrpCfg->skipUplinkTxDynamic = false;
-   macCellGrpCfg->ext1 = NULLP;
+   *frequencyInfoUL->p_Max = ulCfg.pMax;
 
    return ROK;
 }
+
 /*******************************************************************
  *
- * @brief Frees memeory allocated for SearchSpcToAddModList
+ * @brief Fills UL config common in Serving cell config common
  *
  * @details
  *
- *    Function : FreeSearchSpcToAddModList
+ *    Function : BuildUlConfigCommon
  *
- *    Functionality: Deallocating memory of SearchSpcToAddModList
+ *    Functionality: Fills UL config common in Serving cell config common
  *
- * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
+ * @params[in] Pointer to UplinkConfigCommon_t
  *
- * @return void
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildUlConfigCommon(UplinkConfigCommon_t *ulCfgCommon)
+{
+   /* UL Frequency Info */
+   DU_ALLOC(ulCfgCommon->frequencyInfoUL, sizeof(FrequencyInfoUL_t));
+   if(!ulCfgCommon->frequencyInfoUL)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for UL frequency info in BuildUlConfigCommon()");
+      return RFAILED;
+   }
+
+   if((BuildFreqInfoUl(ulCfgCommon->frequencyInfoUL)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill frequency info UL in BuildUlConfigCommon()");
+      return RFAILED;
+   }
+
+   /* UL BWP common */
+   DU_ALLOC(ulCfgCommon->initialUplinkBWP, sizeof(BWP_UplinkCommon_t));
+   if(!ulCfgCommon->initialUplinkBWP)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for initial UL BWP in BuildUlConfigCommon()");
+      return RFAILED;
+   }
+
+   if((BuildBwpUlCommon(ulCfgCommon->initialUplinkBWP)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill BWP UL common in BuildUlConfigCommon()");
+      return RFAILED;
+   }
+
+   /* Time Alignment timer */
+   ulCfgCommon->dummy = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills SSB position in burst in SP cell config common
+ *
+ * @details
+ *
+ *    Function : BuildSsbPosInBurst
+ *
+ *    Functionality: 
+ *       Fills SSB position in burst in SP cell config common
+ *
+ * @params[in] Pointer to struct ServingCellConfigCommon__ssb_PositionsInBurst
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildSsbPosInBurst(struct ServingCellConfigCommon__ssb_PositionsInBurst *ssbPosInBurst)
+{
+   uint8_t bitStringSizeInBytes = 0;
+
+   ssbPosInBurst->present = ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap;
+
+   /* As per spec 38.331,in the definition of ServingCellConfigCommon */
+   bitStringSizeInBytes = 1;
+   ssbPosInBurst->choice.mediumBitmap.size = bitStringSizeInBytes * sizeof(uint8_t);
+
+   DU_ALLOC(ssbPosInBurst->choice.mediumBitmap.buf, ssbPosInBurst->choice.mediumBitmap.size);
+   if(!ssbPosInBurst->choice.mediumBitmap.buf)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory Allocation failed for medium bit map buffer in BuildSsbPosInBurst()");
+      return RFAILED;
+   }
+
+   if((fillBitString(&ssbPosInBurst->choice.mediumBitmap, 0, bitStringSizeInBytes, \
+               duCfgParam.sib1Params.srvCellCfgCommSib.ssbPosInBurst)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill medium bit map in BuildSsbPosInBurst()");
+      return RFAILED;
+   }
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills SP cell config common in Reconfig with Sync
+ *
+ * @details
+ *
+ *    Function : BuildSpCellConfigCommon
+ *
+ *    Functionality: Fills SP cell config common in Reconfig with Sync
+ *
+ * @params[in] Pointer to ServingCellConfigCommon_t
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildSpCellConfigCommon(ServingCellConfigCommon_t *spCellConfigCommon)
+{
+   /* Physical Cell Identity */
+   DU_ALLOC(spCellConfigCommon->physCellId, sizeof(PhysCellId_t));
+   if(!spCellConfigCommon->physCellId)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for physical cell id in BuildSpCellConfigCommon()");
+      return RFAILED;
+   } 
+   *(spCellConfigCommon->physCellId) = NR_PCI;
+
+   /* Downlink Config Common */
+   DU_ALLOC(spCellConfigCommon->downlinkConfigCommon, sizeof(DownlinkConfigCommon_t));
+   if(!spCellConfigCommon->downlinkConfigCommon)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for DL Config Common in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+   if((BuildDlConfigCommon(spCellConfigCommon->downlinkConfigCommon)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill DL config commin in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+
+   /* Uplinlink Config Common */
+   DU_ALLOC(spCellConfigCommon->uplinkConfigCommon, sizeof(UplinkConfigCommon_t));
+   if(!spCellConfigCommon->uplinkConfigCommon)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for UL Config Common in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+   if((BuildUlConfigCommon(spCellConfigCommon->uplinkConfigCommon)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill UL config commin in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+
+   /* Timing Advance offset */
+   DU_ALLOC(spCellConfigCommon->n_TimingAdvanceOffset, sizeof(long));
+   if(!spCellConfigCommon->n_TimingAdvanceOffset)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for Timing Advance Offset in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+   *(spCellConfigCommon->n_TimingAdvanceOffset) = ServingCellConfigCommon__n_TimingAdvanceOffset_n0;
+
+   /* SSB Position In Burst */
+   DU_ALLOC(spCellConfigCommon->ssb_PositionsInBurst, sizeof(struct ServingCellConfigCommon__ssb_PositionsInBurst));
+   if(!spCellConfigCommon->ssb_PositionsInBurst)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for SSB Position In Burst in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+   if((BuildSsbPosInBurst(spCellConfigCommon->ssb_PositionsInBurst)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill SSB Position In Burst in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+
+   /* SSB Periodicity in Serving cell */
+   DU_ALLOC(spCellConfigCommon->ssb_periodicityServingCell, sizeof(long));
+   if(!spCellConfigCommon->ssb_periodicityServingCell)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for SSB Periodicity serving cell in \
+         BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+   *(spCellConfigCommon->ssb_periodicityServingCell) = \
+      convertSsbPeriodicityValueToEnum(duCfgParam.sib1Params.srvCellCfgCommSib.ssbPrdServingCell);
+
+   /* DMRS Type A position */
+   spCellConfigCommon->dmrs_TypeA_Position = convertDmrsTypeAPosValueToEnum(duCfgParam.macCellCfg.dmrsTypeAPos);
+
+   /* SSB subcarrier spacing */
+   DU_ALLOC(spCellConfigCommon->ssbSubcarrierSpacing, sizeof(SubcarrierSpacing_t));
+   if(!spCellConfigCommon->ssbSubcarrierSpacing)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for sub-carrier spacing in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+   *(spCellConfigCommon->ssbSubcarrierSpacing) = duCfgParam.sib1Params.srvCellCfgCommSib.scs;
+
+   /* TDD UL-DL configuration common */
+   DU_ALLOC(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
+   if(!spCellConfigCommon->tdd_UL_DL_ConfigurationCommon)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for TDD UL-DL config common in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+   if((BuildTddUlDlCfgComm(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to fill TDD UL-DL config common in BuildSpCellConfigCommon()");
+      return RFAILED;
+   }
+
+   /* SS PBCH Block Power */
+   spCellConfigCommon->ss_PBCH_BlockPower = duCfgParam.sib1Params.srvCellCfgCommSib.ssPbchBlockPwr;
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills dedicated RACH configuration in Reconfiguration with sync
+ *
+ * @details
+ *
+ *    Function : BuildRecfgWithSync
+ *
+ *    Functionality: 
+ *       Fills dedicated RACH configuration in Reconfiguration with sync
+ *
+ * @params[in] DU UE CB
+ *             Pointer to Rach config dedicated struct
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildRachConfigDedicated(DuUeCb *ueCb, struct ReconfigurationWithSync__rach_ConfigDedicated *rachCfgDed)
+{
+   uint8_t elementCnt = 0, listIdx = 0;
+   CFRA_t *cfra = NULLP;
+   struct CFRA__resources__ssb *ssbResource = NULLP;
+   RachCfgCommon duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
+
+   rachCfgDed->present = ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink;
+
+   /* Uplink */
+   DU_ALLOC(rachCfgDed->choice.uplink, sizeof(RACH_ConfigDedicated_t));
+   if(!rachCfgDed->choice.uplink)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for RACH uplink configuration in BuildRachConfigDedicated()");
+      return RFAILED;
+   }
+
+   /* CFRA : Contention free Random Access */
+   DU_ALLOC(rachCfgDed->choice.uplink->cfra, sizeof(CFRA_t));
+   if(!rachCfgDed->choice.uplink->cfra)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for CFRA in BuildRachConfigDedicated()");
+      return RFAILED;
+   }
+   cfra = rachCfgDed->choice.uplink->cfra;
+
+   /* CFRA occassions */
+   DU_ALLOC(cfra->occasions, sizeof(struct CFRA__occasions));
+   if(!cfra->occasions)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for CFRA occassion in BuildRachConfigDedicated()");
+      return RFAILED;
+   }
+
+   /* CFRA occassions : RACH generic configuration */
+   cfra->occasions->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
+   cfra->occasions->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
+   cfra->occasions->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
+   cfra->occasions->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
+   cfra->occasions->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr;
+   cfra->occasions->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
+   cfra->occasions->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
+   cfra->occasions->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
+
+   /* CFRA occassions : SSB per RACH occasion */
+   DU_ALLOC(cfra->occasions->ssb_perRACH_Occasion, sizeof(long));
+   if(!cfra->occasions->ssb_perRACH_Occasion)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for SSB per RACH occassion in BuildRachConfigDedicated()");
+      return RFAILED;
+   }
+   *(cfra->occasions->ssb_perRACH_Occasion) = convertCFRASsbPerRachOccasionValueToEnum(duCfgParam.macCellCfg.prachCfg.ssbPerRach);
+
+   /* CFRA resource */
+   cfra->resources.present = CFRA__resources_PR_ssb;
+
+   /* CFRA resource : SSB */
+   DU_ALLOC(cfra->resources.choice.ssb, sizeof(struct CFRA__resources__ssb));
+   if(!cfra->resources.choice.ssb)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for CFRA resource - SSB in BuildRachConfigDedicated()");
+      return RFAILED;
+   }
+   ssbResource = cfra->resources.choice.ssb;
+
+   /* CFRA SSB resource list */
+   elementCnt = ueCb->cfraResource.numSsb;
+   ssbResource->ssb_ResourceList.list.count = elementCnt;
+   ssbResource->ssb_ResourceList.list.size = elementCnt * sizeof(CFRA_SSB_Resource_t *);
+
+   DU_ALLOC(ssbResource->ssb_ResourceList.list.array, ssbResource->ssb_ResourceList.list.size);
+   if(!ssbResource->ssb_ResourceList.list.array)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for SSB resource list in BuildRachConfigDedicated()");
+      return RFAILED;
+   }
+
+   for(listIdx = 0; listIdx < elementCnt; listIdx++)
+   {
+      DU_ALLOC(ssbResource->ssb_ResourceList.list.array[listIdx], sizeof(CFRA_SSB_Resource_t));
+      if(!ssbResource->ssb_ResourceList.list.array[listIdx])
+      {
+         DU_LOG("\nERROR  -->  DU APP : Memory allocation failed for SSB resource list element in BuildRachConfigDedicated()");  
+         return RFAILED;
+      }
+      ssbResource->ssb_ResourceList.list.array[listIdx]->ssb = ueCb->cfraResource.ssbResource[listIdx].ssbIdx;
+      ssbResource->ssb_ResourceList.list.array[listIdx]->ra_PreambleIndex = ueCb->cfraResource.ssbResource[listIdx].raPreambleIdx;
+   }
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills reconfiguration with sync in SP cell config
+ *
+ * @details
+ *
+ *    Function : BuildRecfgWithSync
+ *
+ *    Functionality: Fills reconfiguration with sync in SP cell config
+ *
+ * @params[in] DU UE CB
+ *             Pointer to ReconfigurationWithSync_t
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildRecfgWithSync(DuUeCb *ueCb, ReconfigurationWithSync_t *recfgWithSync)
+{
+   /* SP Cell Config Common */  
+   DU_ALLOC(recfgWithSync->spCellConfigCommon, sizeof(ServingCellConfigCommon_t));
+   if(!recfgWithSync->spCellConfigCommon)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for spCellConfigCommon in BuildRecfgWithSync()");
+      return RFAILED;
+   }
+
+   if((BuildSpCellConfigCommon(recfgWithSync->spCellConfigCommon)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to build SpCellConfigCommon in BuildRecfgWithSync()");
+      return RFAILED;
+   }
+
+   /* New UE Identity */
+   recfgWithSync->newUE_Identity = ueCb->crnti;
+
+   /* T304 timer */
+   recfgWithSync->t304 = ReconfigurationWithSync__t304_ms1000;
+
+   /* RACH configuration dedicated */
+   DU_ALLOC(recfgWithSync->rach_ConfigDedicated, sizeof(struct ReconfigurationWithSync__rach_ConfigDedicated));
+   if(!recfgWithSync->rach_ConfigDedicated)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to allocate memory for RACH config dedicated in BuildRecfgWithSync()");
+      return RFAILED;
+   }
+
+   if((BuildRachConfigDedicated(ueCb, recfgWithSync->rach_ConfigDedicated)) != ROK)
+   {
+      DU_LOG("\nERROR  -->  DU APP : Failed to build RACH config dedicated in BuildRecfgWithSync()");
+      return RFAILED;
+   }
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds Spcell config 
+ *
+ * @details
+ *
+ *    Function : BuildSpCellCfg 
+ *
+ *    Functionality: Builds sp cell config in DuToCuRrcContainer
+ *
+ * @params[in] SpCellConfig_t spCellCfg
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildSpCellCfg(DuUeCb *ueCb, SpCellConfig_t *spCellCfg)
+{
+   spCellCfg->servCellIndex = NULLP;
+   DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
+   if(!spCellCfg->servCellIndex)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildSpCellCfg");
+      return RFAILED;
+   }
+
+   if(ueCb == NULLP)
+      *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
+   else
+      *(spCellCfg->servCellIndex) = ueCb->macUeCfg.spCellCfg.servCellIdx;
+
+   spCellCfg->reconfigurationWithSync = NULLP;
+   if(ueCb && (ueCb->ueState == UE_HANDIN_IN_PROGRESS))
+   {
+      DU_ALLOC(spCellCfg->reconfigurationWithSync, sizeof(ReconfigurationWithSync_t));
+      if(!spCellCfg->reconfigurationWithSync)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildSpCellCfg");
+         return RFAILED;
+      }
+
+      if((BuildRecfgWithSync(ueCb, spCellCfg->reconfigurationWithSync)) != ROK)
+      {
+         DU_LOG("\nERROR  -->  F1AP : Building of reconfiguration with sync failed at BuildSpCellCfg");
+         return RFAILED;
+      }
+   }
+
+   spCellCfg->rlf_TimersAndConstants = NULLP;
+   spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
+
+   DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
+   if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildSpCellCfg");
+      return RFAILED;
+   }
+   *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
+
+   spCellCfg->spCellConfigDedicated = NULLP;
+   DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
+   if(!spCellCfg->spCellConfigDedicated)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildSpCellCfg");
+      return RFAILED;
+   }
+   if(BuildSpCellCfgDed(ueCb, spCellCfg->spCellConfigDedicated) != ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : BuildSpCellCfgDed failed");
+      return RFAILED;
+   }
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds Phy cell group config 
+ *
+ * @details
+ *
+ *    Function : BuildPhyCellGrpCfg 
+ *
+ *    Functionality: Builds Phy cell group config in DuToCuRrcContainer
+ *
+ * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg 
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildPhyCellGrpCfg(DuUeCb *ueCb, PhysicalCellGroupConfig_t *phyCellGrpCfg)
+{
+   phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
+   phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
+
+   phyCellGrpCfg->p_NR_FR1 = NULLP;
+   DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
+   if(!phyCellGrpCfg->p_NR_FR1)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
+      return RFAILED;
+   }
+
+   if(ueCb == NULLP)
+   {
+      *(phyCellGrpCfg->p_NR_FR1)             = P_NR_FR1;
+      phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
+   }
+   else
+   {
+      *(phyCellGrpCfg->p_NR_FR1) = ueCb->macUeCfg.phyCellGrpCfg.pNrFr1;
+      phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = ueCb->macUeCfg.phyCellGrpCfg.pdschHarqAckCodebook;
+   }
+
+   phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
+   phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
+   phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
+   phyCellGrpCfg->sp_CSI_RNTI = NULLP;
+   phyCellGrpCfg->cs_RNTI = NULLP;
+   phyCellGrpCfg->ext1 = NULLP;
+   phyCellGrpCfg->ext2 = NULLP;
+
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds Mac cell group config 
+ *
+ * @details
+ *
+ *    Function : BuildMacCellGrpCfg 
+ *
+ *    Functionality: Builds Mac cell group config in DuToCuRrcContainer
+ *
+ * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildMacCellGrpCfg(DuUeCb *ueCb, MAC_CellGroupConfig_t *macCellGrpCfg)
+{
+   macCellGrpCfg->drx_Config = NULLP;
+   macCellGrpCfg->schedulingRequestConfig = NULLP;
+   DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
+   if(!macCellGrpCfg->schedulingRequestConfig)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
+      return RFAILED;
+   }
+
+   if(BuildSchedulingReqConfig(ueCb, macCellGrpCfg->schedulingRequestConfig) != ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : BuildSchedulingReqConfig failed");
+      return RFAILED;
+   }
+
+   macCellGrpCfg->bsr_Config = NULLP;
+   DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
+   if(!macCellGrpCfg->bsr_Config)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
+      return RFAILED;
+   }
+
+   if(BuildBsrConfig(ueCb, macCellGrpCfg->bsr_Config) != ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : BuildBsrConfig failed");
+      return RFAILED;
+   }
+
+   macCellGrpCfg->tag_Config = NULLP;
+   DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
+   if(!macCellGrpCfg->tag_Config)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
+      return RFAILED;
+   }
+
+   if(BuildTagConfig(ueCb, macCellGrpCfg->tag_Config) != ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : BuildTagConfig failed");
+      return RFAILED;
+   }
+
+   macCellGrpCfg->phr_Config = NULLP;
+   DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
+   if(!macCellGrpCfg->phr_Config)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failure in BuildMacCellGrpCfg");
+      return RFAILED;
+   }
+
+   if(BuildPhrConfig(ueCb, macCellGrpCfg->phr_Config) != ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : BuildPhrConfig failed");
+      return RFAILED;
+   }
+
+   macCellGrpCfg->skipUplinkTxDynamic = false;
+   macCellGrpCfg->ext1 = NULLP;
+
+   return ROK;
+}
+/*******************************************************************
+ *
+ * @brief Frees memeory allocated for SearchSpcToAddModList
+ *
+ * @details
+ *
+ *    Function : FreeSearchSpcToAddModList
+ *
+ *    Functionality: Deallocating memory of SearchSpcToAddModList
+ *
+ * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
+ *
+ * @return void
  *
  4221 * ****************************************************************/
 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
@@ -6895,6 +7615,357 @@ void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
    }
 }      
 
+/*******************************************************************
+ *
+ * @brief Free SCS specific carrier list in DL frequency info
+ *
+ * @details
+ *
+ *    Function : FreeScsSpecificCarrierListDl
+ *
+ *    Functionality: Free SCS specific carrier list in DL frequency info
+ *
+ * @params[in] Pointer to struct FrequencyInfoDL__scs_SpecificCarrierList
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeScsSpecificCarrierListDl(struct FrequencyInfoDL__scs_SpecificCarrierList *scsCarrierList)
+{
+   uint8_t listIdx = 0;
+
+   if(!scsCarrierList->list.array)
+   {
+      for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
+      {
+         DU_FREE(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
+      }
+      DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief Free DL frequency info in DL config common
+ *
+ * @details
+ *
+ *    Function : FreeFreqInfoDl
+ *
+ *    Functionality: Free DL frequency info in DL config common
+ *
+ * @params[in] Pointer to DownlinkConfigCommon_t
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeFreqInfoDl(FrequencyInfoDL_t *frequencyInfoDL)
+{
+   uint8_t freqBandIdx = 0;
+
+   /* SSB Absolute Frequency */
+   DU_FREE(frequencyInfoDL->absoluteFrequencySSB, sizeof(ARFCN_ValueNR_t));
+
+   /* NR Multi Frequency Band List */
+   if(frequencyInfoDL->frequencyBandList.list.array)
+   {
+      for(freqBandIdx = 0; freqBandIdx < frequencyInfoDL->frequencyBandList.list.count; freqBandIdx++)
+      {
+         DU_FREE(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx], sizeof(FreqBandIndicatorNR_t));
+      }
+      DU_FREE(frequencyInfoDL->frequencyBandList.list.array, frequencyInfoDL->frequencyBandList.list.size);
+   }
+
+   /* Subcarrier Spacing specifc carrier List */
+   FreeScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
+}
+
+/*******************************************************************
+ *
+ * @brief Free DL config common in Serving cell config common
+ *
+ * @details
+ *
+ *    Function : FreeDlConfigCommon
+ *
+ *    Functionality: Free DL config common in Serving cell config common
+ *
+ * @params[in] Pointer to DownlinkConfigCommon_t
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeDlConfigCommon(DownlinkConfigCommon_t *dlCfgCommon)
+{
+   /* DL Frequency Info */
+   if(dlCfgCommon->frequencyInfoDL)
+   {
+      FreeFreqInfoDl(dlCfgCommon->frequencyInfoDL);
+      DU_FREE(dlCfgCommon->frequencyInfoDL, sizeof(FrequencyInfoDL_t));
+   }
+
+   /* DL BWP config common */
+   if(dlCfgCommon->initialDownlinkBWP)
+   {
+      FreeBwpDlCommon(dlCfgCommon->initialDownlinkBWP);
+      DU_FREE(dlCfgCommon->initialDownlinkBWP, sizeof(BWP_DownlinkCommon_t));
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief Free SCS specific carrier list in UL frequency Info
+ *
+ * @details
+ *
+ *    Function : FreeScsSpecificCarrierListUl
+ *
+ *    Functionality: Free SCS specific carrier list in UL frequency Info
+ *
+ * @params[in] Pointer to struct FrequencyInfoUL__scs_SpecificCarrierList
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeScsSpecificCarrierListUl(struct FrequencyInfoUL__scs_SpecificCarrierList *scsCarrierList)
+{
+   uint8_t listIdx = 0;
+
+   if(scsCarrierList->list.array)
+   {
+      for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
+      {
+         DU_FREE(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
+      }
+      DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief Free frequency info in UL config common
+ *
+ * @details
+ *
+ *    Function : FreeFreqInfoUl
+ *
+ *    Functionality: Free frequency info in UL config common
+ *
+ * @params[in] Pointer to FrequencyInfoUL_t
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeFreqInfoUl(FrequencyInfoUL_t *frequencyInfoUL)
+{
+   uint8_t listIdx= 0;
+
+   /* NR Multi Frequency Band List */
+   if(!frequencyInfoUL->frequencyBandList)
+   {
+      if(frequencyInfoUL->frequencyBandList->list.array)
+      {
+         for(listIdx = 0; listIdx < frequencyInfoUL->frequencyBandList->list.count; listIdx++)
+         {
+            DU_FREE(frequencyInfoUL->frequencyBandList->list.array[listIdx], sizeof(FreqBandIndicatorNR_t));
+         }
+         DU_FREE(frequencyInfoUL->frequencyBandList->list.array, frequencyInfoUL->frequencyBandList->list.size);
+      }
+      DU_FREE(frequencyInfoUL->frequencyBandList, sizeof(MultiFrequencyBandListNR_t));
+   }
+
+   /* Absolute frequency point A */
+   DU_FREE(frequencyInfoUL->absoluteFrequencyPointA, sizeof(ARFCN_ValueNR_t));
+
+   /* Subcarrier Spacing specifc carrier */
+   FreeScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
+
+   /* P-MAX */
+   DU_FREE(frequencyInfoUL->p_Max, sizeof(P_Max_t));
+}
+
+/*******************************************************************
+ *
+ * @brief Free UL config common in Serving cell config common
+ *
+ * @details
+ *
+ *    Function : FreeUlConfigCommon
+ *
+ *    Functionality: Free UL config common in Serving cell config common
+ *
+ * @params[in] Pointer to UplinkConfigCommon_t
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeUlConfigCommon(UplinkConfigCommon_t *ulCfgCommon)
+{
+   /* UL Frequency Info */
+   if(ulCfgCommon->frequencyInfoUL)
+   {
+      FreeFreqInfoUl(ulCfgCommon->frequencyInfoUL);
+      DU_FREE(ulCfgCommon->frequencyInfoUL, sizeof(FrequencyInfoUL_t));
+   }
+
+   /* UL BWP common */
+   if(ulCfgCommon->initialUplinkBWP)
+   {
+      FreeBwpUlCommon(ulCfgCommon->initialUplinkBWP);
+      DU_FREE(ulCfgCommon->initialUplinkBWP, sizeof(BWP_UplinkCommon_t));
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief Free SP cell config common in Reconfig with Sync
+ *
+ * @details
+ *
+ *    Function : FreeSpCellConfigCommon
+ *
+ *    Functionality: Free SP cell config common in Reconfig with Sync
+ *
+ * @params[in] Pointer to ServingCellConfigCommon_t
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeSpCellConfigCommon(ServingCellConfigCommon_t *spCellConfigCommon)
+{
+   /* Free Physical cell identity */
+   DU_FREE(spCellConfigCommon->physCellId, sizeof(PhysCellId_t));
+
+   /* Free Downlink Config common */
+   if(spCellConfigCommon->downlinkConfigCommon)
+   {
+      FreeDlConfigCommon(spCellConfigCommon->downlinkConfigCommon);
+      DU_FREE(spCellConfigCommon->downlinkConfigCommon, sizeof(DownlinkConfigCommon_t));
+   }
+
+   /* Free Uplink Config common */
+   if(spCellConfigCommon->uplinkConfigCommon)
+   {
+      FreeUlConfigCommon(spCellConfigCommon->uplinkConfigCommon);
+      DU_FREE(spCellConfigCommon->uplinkConfigCommon, sizeof(UplinkConfigCommon_t));
+   }
+
+   /* Free Timing Advance offset */
+   DU_FREE(spCellConfigCommon->n_TimingAdvanceOffset, sizeof(long));
+
+   /* Free SSB Position in Burst */
+   if(spCellConfigCommon->ssb_PositionsInBurst)
+   {
+      DU_FREE(spCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf, \
+         spCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.size);
+      DU_FREE(spCellConfigCommon->ssb_PositionsInBurst, sizeof(struct ServingCellConfigCommon__ssb_PositionsInBurst));
+   }
+
+   /* Free SSB Periodicity in Serving cell */
+   DU_FREE(spCellConfigCommon->ssb_periodicityServingCell, sizeof(long));
+
+   /* Free SSB subcarrier spacing */
+   DU_FREE(spCellConfigCommon->ssbSubcarrierSpacing, sizeof(SubcarrierSpacing_t));
+
+   /* TDD UL-DL configuration common */
+   DU_FREE(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
+}
+
+/*******************************************************************
+ *
+ * @brief Free dedicated RACH configuration in Reconfiguration with sync
+ *
+ * @details
+ *
+ *    Function : FreeRecfgWithSync
+ *
+ *    Functionality:
+ *       Free dedicated RACH configuration in Reconfiguration with sync
+ *
+ * @params[in] Pinter to Rach config dedicated struct
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeRachConfigDedicated(struct ReconfigurationWithSync__rach_ConfigDedicated *rachCfgDed)
+{
+   uint8_t listIdx = 0;
+   CFRA_t *cfra = NULLP;
+   struct CFRA__resources__ssb *ssbResource = NULLP;
+
+   /* Uplink */
+   if(rachCfgDed->choice.uplink)
+   {
+      /* CFRA : Contention free Random Access */
+      if(rachCfgDed->choice.uplink->cfra)
+      {
+         cfra = rachCfgDed->choice.uplink->cfra;
+
+         /* CFRA occassions */
+         if(cfra->occasions)
+         {
+            /* CFRA occassions : SSB per RACH occasion */
+            DU_FREE(cfra->occasions->ssb_perRACH_Occasion, sizeof(long));
+            DU_FREE(cfra->occasions, sizeof(struct CFRA__occasions));
+         }
+
+         /* CFRA resource */
+         cfra->resources.present = CFRA__resources_PR_ssb;
+
+         /* CFRA resource : SSB */
+         if(cfra->resources.choice.ssb)
+         {
+            ssbResource = cfra->resources.choice.ssb;
+
+            /* CFRA SSB resource list */
+            if(ssbResource->ssb_ResourceList.list.array)
+            {
+               for(listIdx = 0; listIdx < ssbResource->ssb_ResourceList.list.count; listIdx++)
+               {
+                  DU_FREE(ssbResource->ssb_ResourceList.list.array[listIdx], sizeof(CFRA_SSB_Resource_t));
+               }
+               DU_FREE(ssbResource->ssb_ResourceList.list.array, ssbResource->ssb_ResourceList.list.size);
+            }
+            DU_FREE(cfra->resources.choice.ssb, sizeof(struct CFRA__resources__ssb));
+         }
+         DU_FREE(rachCfgDed->choice.uplink->cfra, sizeof(CFRA_t));
+      }
+      DU_FREE(rachCfgDed->choice.uplink, sizeof(RACH_ConfigDedicated_t));
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief Frees reconfiguration with sync in SP cell config
+ *
+ * @details
+ *
+ *    Function : FreeRecfgWithSync
+ *
+ *    Functionality: Fress reconfiguration with sync in SP cell config
+ *
+ * @params[in] Pointer to ReconfigurationWithSync_t
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void FreeRecfgWithSync(ReconfigurationWithSync_t *recfgWithSync)
+{
+   /* Free SP Cell config common */
+   if(recfgWithSync->spCellConfigCommon)
+   {
+      FreeSpCellConfigCommon(recfgWithSync->spCellConfigCommon);
+      DU_FREE(recfgWithSync->spCellConfigCommon, sizeof(ServingCellConfigCommon_t));
+   }
+
+   /* Free Dedicated RACH configuration */
+   if(recfgWithSync->rach_ConfigDedicated)
+   {
+      FreeRachConfigDedicated(recfgWithSync->rach_ConfigDedicated);
+      DU_FREE(recfgWithSync->rach_ConfigDedicated, sizeof(struct ReconfigurationWithSync__rach_ConfigDedicated));
+   }
+}
+
 /*******************************************************************
  *
  * @brief Frees emmory allocated for DUToCURRCContainer 
@@ -6942,11 +8013,46 @@ uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
                macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
                if(rlcConfig)
                {
-                  if(rlcConfig->choice.am)
+                  switch(rlcConfig->present)
                   {
-                     DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
-                     DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t)); 
-                     DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
+                     case RLC_Config_PR_am:
+                        {
+                           if(rlcConfig->choice.am)
+                           {
+                              DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
+                              DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t)); 
+                              DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
+                           }
+                           break;
+                        }
+                     case RLC_Config_PR_um_Bi_Directional:
+                        {
+                           if(rlcConfig->choice.um_Bi_Directional)
+                           {
+                              DU_FREE(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t)); 
+                              DU_FREE(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
+                              DU_FREE(rlcConfig->choice.um_Bi_Directional, sizeof(struct RLC_Config__um_Bi_Directional));
+                           }
+                           break;
+                        }
+                     case RLC_Config_PR_um_Uni_Directional_UL:
+                        {
+                           if(rlcConfig->choice.um_Uni_Directional_UL)
+                           {
+                              DU_FREE(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
+                              DU_FREE(rlcConfig->choice.um_Uni_Directional_UL , sizeof(struct RLC_Config__um_Uni_Directional_UL));
+                           }
+                           break;
+                        }
+                     case RLC_Config_PR_um_Uni_Directional_DL:
+                        {
+                           if(rlcConfig->choice.um_Uni_Directional_DL )
+                           {
+                              DU_FREE(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
+                              DU_FREE(rlcConfig->choice.um_Uni_Directional_DL , sizeof(struct RLC_Config__um_Uni_Directional_DL));
+                           }
+                           break;
+                        }
                   }    
                   DU_FREE(rlcConfig, sizeof(struct RLC_Config));
                }
@@ -6996,6 +8102,7 @@ uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
       }
       if(macCellGrpCfg->bsr_Config)
       {
+         DU_FREE(macCellGrpCfg->bsr_Config->logicalChannelSR_DelayTimer, sizeof(long));
          DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
       }
       tagConfig = macCellGrpCfg->tag_Config;
@@ -7037,61 +8144,74 @@ uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
    spCellCfg = cellGrpCfg->spCellConfig;
    if(spCellCfg)
    {
-      if(spCellCfg->servCellIndex)
+      /* Free serving cell index */
+      DU_FREE(spCellCfg->servCellIndex, sizeof(long));
+
+      /* Free Reconfiguration with sync */
+      if(spCellCfg->reconfigurationWithSync)
+      {
+         FreeRecfgWithSync(spCellCfg->reconfigurationWithSync);
+         DU_FREE(spCellCfg->reconfigurationWithSync, sizeof(ReconfigurationWithSync_t));
+      }
+
+      /* Free rlmInSyncOutOfSyncThreshold */
+      DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
+
+      /* Free SP Cell config dedicated */
+      if(spCellCfg->spCellConfigDedicated)
       {
-         if(spCellCfg->rlmInSyncOutOfSyncThreshold)
+         srvCellCfg = spCellCfg->spCellConfigDedicated;
+
+         /* Free TDD UL-DL config dedicated */
+         DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
+
+         /* Free Initial Downlink BWP */
+         if(srvCellCfg->initialDownlinkBWP)
          {
-            if(spCellCfg->spCellConfigDedicated)
+            dlBwp = srvCellCfg->initialDownlinkBWP;
+
+            /* Free DL BWP PDCCH Config */
+            if(dlBwp->pdcch_Config)
             {
-               srvCellCfg = spCellCfg->spCellConfigDedicated;
-               if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
-               {
-                  if(srvCellCfg->initialDownlinkBWP)
-                  {
-                     dlBwp = srvCellCfg->initialDownlinkBWP;
-                     if(srvCellCfg->firstActiveDownlinkBWP_Id)
-                     {
-                        if(srvCellCfg->defaultDownlinkBWP_Id)
-                        {
-                           if(srvCellCfg->uplinkConfig)
-                           {
-                              if(srvCellCfg->pdsch_ServingCellConfig)
-                              {
-                                 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
-                                 if(pdschCfg->choice.setup)
-                                 {
-                                    DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
-                                    DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
-                                 }
-                                 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
-                                          ServingCellConfig__pdsch_ServingCellConfig));
-                              }  
-                              FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
-                              DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));       
-                           }
-                           DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
-                        }
-                        DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
-                     }
-                     if(dlBwp->pdcch_Config)
-                     {
-                        if(dlBwp->pdsch_Config)
-                        {
-                           FreeBWPDlDedPdschCfg(dlBwp);
-                           DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
-                        }
-                        FreeBWPDlDedPdcchCfg(dlBwp);
-                        DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
-                     }
-                     DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
-                  }
-                  DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
-               }
-               DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
+               FreeBWPDlDedPdcchCfg(dlBwp);
+               DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
+            }
+
+            /* Free DL BWP PDSCH config */
+            if(dlBwp->pdsch_Config)
+            {
+               FreeBWPDlDedPdschCfg(dlBwp);
+               DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
+            }
+            DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
+         }
+
+         /* Free First Active Downlink BWP */
+         DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
+
+         /* Free Default downlink BWP */
+         DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
+
+         /* Free Uplink config */
+         if(srvCellCfg->uplinkConfig)
+         {
+            FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
+            DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t)); 
+         }
+
+         /* Free PDSCH serving cell config */
+         if(srvCellCfg->pdsch_ServingCellConfig)
+         {
+            pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
+            if(pdschCfg->choice.setup)
+            {
+               DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
+               DU_FREE(pdschCfg->choice.setup, sizeof(struct PDSCH_ServingCellConfig));
             }
-            DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
+            DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
          }
-         DU_FREE(spCellCfg->servCellIndex, sizeof(long));
+
+         DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
       }
       DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
    }
@@ -7347,7 +8467,8 @@ uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti
 {
    uint8_t   ret;
    uint8_t   elementCnt;
-   uint8_t   ieIdx;
+   uint8_t   ieIdx, cellIdx, ueIdx;
+   DuUeCb    *duUeCb = NULLP;
    asn_enc_rval_t  encRetVal;
    F1AP_PDU_t  *f1apMsg = NULLP;
    InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
@@ -7459,7 +8580,19 @@ uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti
       initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
                                                                 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
 
-      ret = BuildCellGroupConfigRrc(NULLP, &initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
+      for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
+      {
+         for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
+         {
+            if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
+                  (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti == crnti))
+            {
+               duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
+            }
+         }
+      }
+
+      ret = BuildCellGroupConfigRrc(duUeCb, &initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
       if(ret != ROK)
       {
         break;
@@ -8760,8 +9893,13 @@ void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCf
       qosToAdd->u.nonDyn5Qi.avgWindow = \
                                         *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
    }
-   qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
-                                           *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
+
+   if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume)
+   {
+      qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
+                                              *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
+   }
+
    if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
    {
       qosToAdd->u.nonDyn5Qi.priorLevel = \
@@ -9165,8 +10303,8 @@ uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList
      }
      (ueCfgDb->numRlcLcs)++;
      (ueCfgDb->numMacLcs)++;
-         DU_LOG("\nDEBUG  -> DUAPP: extractRlcCfgToAddMod:RBType:%d, DrbID: %d,lcId:%d, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
-                            rbType, rbId, lcId, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs,  ueCfgDb->numDrb);
+     DU_LOG("\nDEBUG  -> DUAPP: extractRlcCfgToAddMod:RBType:%d, DrbID: %d,lcId:%d, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
+        rbType, rbId, lcId, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs,  ueCfgDb->numDrb);
   }
   //TODO: To send the failure cause in UeContextSetupRsp 
   return ROK;
@@ -11093,7 +12231,7 @@ void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
  * @return void 
  *
  * ****************************************************************/
-uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend,MacUeCfg *storedMacUeCfg, void *cellInfo)
+uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend, MacUeCfg *storedMacUeCfg, void *cellInfo)
 {
    uint8_t ret = ROK;
    CellGroupConfigRrc_t *cellGrp = NULLP;
@@ -11133,7 +12271,7 @@ void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
 {
    UE_NR_Capability_t *ueNrCap=NULLP;
 
-   if(!ueCap)
+   if(!ueCap && oldUeCfg)
    {
       memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));     
       memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
@@ -11174,14 +12312,16 @@ void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
             default:
                {
                   DU_LOG("\nERROR  -->  DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
-                  memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
+                  if(oldUeCfg)
+                     memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
                   break;
                }
          }
       }
       else
       {
-         memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
+         if(oldUeCfg)
+            memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
       }
 
       /* Filling UL modulation info */
@@ -11216,40 +12356,40 @@ void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
             default:
                {
                   DU_LOG("\nERROR  -->  DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
-                  memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
+                  if(oldUeCfg)
+                     memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
                   break;
                }
          }
       }
       else
       {
-         memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
+         if(oldUeCfg)
+            memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
       }
    }
 }
 
 /*******************************************************************
  *
- * @brief Function to extract cellGrp Info present in cutoDu cont
+ * @brief Function to extract info from CU to DU RRC container extension
  *
  * @details
  *
- *    Function : extractCellGrpInfo
+ *    Function : extractCuToDuRrcInfoExt
  *
- *    Functionality: Function to extract cellGrp Info present
- *                   in cutoDu cont
+ *    Functionality: Function to extract info from CU to DU RRC container
+ *    extension
  *
  * @params[in] ProtocolExtensionContainer_4624P16_t pointer
  *
- * @return CellGroupConfigRrc_t *
+ * @return ROK
+ *         RFAILED
  *
  * ****************************************************************/
-
-CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
-      DuUeCfg *ueCfgDb)
+uint8_t extractCuToDuRrcInfoExt(ProtocolExtensionContainer_4624P16_t *protocolIeExtn, DuUeCfg *ueCfgDb)
 {
-   uint8_t idx2 =0;
-   uint16_t id =0;
+   uint8_t ieIdx =0;
    uint16_t recvBufLen =0;
    CellGroupConfigRrc_t *cellGrpCfg = NULLP;
    CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
@@ -11258,40 +12398,48 @@ CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *p
 
    if(protocolIeExtn)
    {
-      for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
+      for(ieIdx = 0; ieIdx < protocolIeExtn->list.count; ieIdx++)
       {
-         extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
-        id = extIeInfo->id;
-         switch(id)
+         extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[ieIdx]));
+         switch(extIeInfo->id)
          {
             case ProtocolIE_ID_id_CellGroupConfig:
-            {
-              recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
-              /* decoding the CellGroup Buf received */
-              DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
-              if(cellGrpCfg)
-              {
-                  memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
-                  rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
-                    extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
-                  if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+               {
+                  /* decoding the CellGroup Buf received */
+                  recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
+                  DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
+                  if(cellGrpCfg)
                   {
-                     DU_LOG("\nERROR  -->  F1AP : ASN decode failed at decodeCellGrpCfg()");
-                     return NULLP;
+                     memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
+                     rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
+                           extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
+                     if(rval.code == RC_FAIL || rval.code == RC_WMORE)
+                     {
+                        DU_LOG("\nERROR  -->  F1AP : ASN decode failed at decodeCellGrpCfg()");
+                        return RFAILED;
+                     }
+                     xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
+
+                     if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
+                        return NULLP;
+                     ueCfgDb->cellGrpCfg = cellGrpCfg;
                   }
-                  xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
-                 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
-                    return NULLP;
-              }
-              break;
-            }
+                  break;
+               }
+
+            case ProtocolIE_ID_id_HandoverPreparationInformation:
+               {
+                  DU_LOG("\nINFO -->  F1AP : Received HANDOVER PREPARATION INFO in UE CONTEXT SETUP REQUEST");
+                  break;
+               }
+
             default:
-               DU_LOG("\nERROR  -->  F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
-              break;
+               DU_LOG("\nERROR  -->  F1AP : Invalid IE received CUtoDURRCInformation: %ld at decodeCellGrpCfg()", extIeInfo->id);
+               break;
          }
       }
    }
-   return cellGrpCfg;
+   return ROK;
 }
 
 /*******************************************************************
@@ -11347,39 +12495,63 @@ uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, R
 
 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
 {
-   uint8_t ret, srbIdx;
+   uint8_t ret = ROK, srbIdx = 0, rlcLcIdx = 0;
    SRBs_ToBeSetup_Item_t *srbItem = NULLP;
+   LcCfg *macLcCtxt = NULLP;
+   RlcBearerCfg *rlcLcCtxt = NULLP;
 
    if(srbCfg)
    {
       for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
       {
+         macLcCtxt = NULL;
+         rlcLcCtxt = NULL;
+
          srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
          if(ueCfgDb->numMacLcs > MAX_NUM_LC)
-        { 
+         
             DU_LOG("\nERROR   -->  F1AP:  MAX LC Reached in MAC");
-           ret = RFAILED;
-           break;
-        }
+            ret = RFAILED;
+            break;
+         }
          if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
-        {
+         {
             DU_LOG("\nERROR   -->  F1AP:  MAX LC Reached in RLC");
-           ret = RFAILED;
-           break;
-        }
-        memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
-        memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
-         ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
-           &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
-        ueCfgDb->numRlcLcs++;
-        ueCfgDb->numMacLcs++;
-         DU_LOG("\nDEBUG --> DUAPP: extractSrbListToSetup: SRBID: %d [RLC,MAC,NumDrb]:[%x,%x,%x]",\
-                            srbItem->sRBID, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs,  ueCfgDb->numDrb);
-        if(ret == RFAILED)
-        {
+            ret = RFAILED;
+            break;
+         }
+
+         for(rlcLcIdx = 0; rlcLcIdx < ueCfgDb->numMacLcs; rlcLcIdx++)
+         {
+            if(ueCfgDb->rlcLcCfg[rlcLcIdx].rbId == srbItem->sRBID && ueCfgDb->rlcLcCfg[rlcLcIdx].rbType == RB_TYPE_SRB)
+            {
+               macLcCtxt = &ueCfgDb->macLcCfg[rlcLcIdx];
+               rlcLcCtxt = &ueCfgDb->rlcLcCfg[rlcLcIdx];
+               break;
+            }
+         }
+         if(!macLcCtxt)
+         {
+            memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
+            macLcCtxt = &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs];
+            ueCfgDb->numMacLcs++;
+         }
+         if(!rlcLcCtxt)
+         {
+            memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
+            rlcLcCtxt = &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs];
+            ueCfgDb->numRlcLcs++;
+         }
+
+         ret = procSrbListToSetup(srbItem, macLcCtxt, rlcLcCtxt);
+
+         DU_LOG("\nDEBUG --> DUAPP: extractSrbListToSetup: SRBID: %ld [RLC,MAC,NumDrb]:[%x,%x,%x]",\
+               srbItem->sRBID, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs,  ueCfgDb->numDrb);
+         if(ret == RFAILED)
+         {
             DU_LOG("\nERROR  -->  F1AP:  Failed at extractSrbListToSetup()");
-           break;
-        }
+            break;
+         }
       }
    }
    else
@@ -11482,16 +12654,23 @@ DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem,
 uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
  DRBs_ToBeModified_List_t *drbModCfg, uint8_t drbCount, DuUeCfg *ueCfgDb, uint32_t *drbBitMap, RlcUeCfg *rlcUeCfg)
 {
-   uint8_t ret, drbIdx = 0, lcId = 0;
+   uint8_t ret = ROK;
+   uint8_t drbIdx = 0, rlcLcIdx = 0;
+   uint8_t drbId = 0, lcId = 0;
    DRBs_ToBeSetup_Item_t *drbItem = NULLP;
    DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
    DRBs_ToBeModified_ItemIEs_t *drbModItem = NULLP;
+   LcCfg *macLcCtxt = NULLP;
+   RlcBearerCfg *rlcLcCtxt = NULLP;
 
    ret = ROK;
    if(drbCount > 0)
    {
       for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
       {
+         macLcCtxt = NULL;
+         rlcLcCtxt = NULL;
+
          if(ueCfgDb->numMacLcs > MAX_NUM_LC)
          { 
             DU_LOG("\nERROR  -->  F1AP :  MAX LC Reached in MAC at extractDrbListToSetupMod()");
@@ -11504,27 +12683,57 @@ uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMo
             ret = RFAILED;
             break;
          }
-         memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
-         memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
 
          if(drbModCfg != NULLP)
          {
             drbModItem = (DRBs_ToBeModified_ItemIEs_t *) drbModCfg->list.array[drbIdx];
-            lcId = fetchLcId(drbModItem->value.choice.DRBs_ToBeModified_Item.dRBID);
+            drbId = drbModItem->value.choice.DRBs_ToBeModified_Item.dRBID;
+         }
+         else if(drbCfg != NULLP)
+            drbId = drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item.dRBID;
+         else if(drbSetupModCfg != NULL)
+         {
+            drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
+            drbId = drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item.dRBID;
+         }
+
+         for(rlcLcIdx = 0; rlcLcIdx < ueCfgDb->numRlcLcs; rlcLcIdx++)
+         {
+            if(ueCfgDb->rlcLcCfg[rlcLcIdx].rbId == drbId && ueCfgDb->rlcLcCfg[rlcLcIdx].rbType == RB_TYPE_DRB)
+            {
+               macLcCtxt = &ueCfgDb->macLcCfg[rlcLcIdx];
+               rlcLcCtxt = &ueCfgDb->rlcLcCfg[rlcLcIdx];
+               break;
+            }
+         }
+         if(!macLcCtxt)
+         {
+            memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
+            macLcCtxt = &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs];
+            ueCfgDb->numMacLcs++;
+         }
+         if(!rlcLcCtxt)
+         {
+            memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
+            rlcLcCtxt = &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs];
+            ueCfgDb->numRlcLcs++;
+         }
+
+         if(drbModCfg != NULLP)
+         {
+            lcId = fetchLcId(drbId);
             if(lcId < MIN_DRB_LCID)
             {
                DU_LOG("\nERROR  --> F1AP : Failed fetching LCID %d in extractDrbListToSetupMod() for Modified List", lcId);
                break;
             } 
             ret = procDrbListToSetupMod(lcId, NULL, NULL, &(drbModItem->value.choice.DRBs_ToBeModified_Item),\
-            &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
-            &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
+            macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
             if(ret == RFAILED)
             {
                DU_LOG("\nERROR  --> F1AP : Failed at extractDrbListToSetupMod() for Modified List");
                break;
             }
-
          }
          else
          {
@@ -11538,8 +12747,7 @@ uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMo
             if(drbCfg != NULL)
             {
                drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
-               ret = procDrbListToSetupMod(lcId, drbItem, NULL, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
-                     &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
+               ret = procDrbListToSetupMod(lcId, drbItem, NULL, NULL, macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
                if(ret == RFAILED)
                {
                   DU_LOG("\nERROR  --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetup List");
@@ -11548,10 +12756,8 @@ uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMo
             }
             else if(drbSetupModCfg != NULL)
             {
-               drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
                ret = procDrbListToSetupMod(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item), NULL,\
-                     &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
-                     &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
+                     macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
                if(ret == RFAILED)
                {
                   DU_LOG("\nERROR  --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetupMod List");
@@ -11560,8 +12766,6 @@ uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMo
                ueCfgDb->numDrbSetupMod++;
             }
          }
-         ueCfgDb->numRlcLcs++;
-         ueCfgDb->numMacLcs++;
          ueCfgDb->numDrb++;
  
          DU_LOG("\nDEBUG --> DUAPP: extractDrbListToSetupMod:lcId:%x ,BitMap:%x, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
@@ -11799,12 +13003,15 @@ void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t   *ueSetReq)
  * ****************************************************************/
 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
 {
-   uint8_t  ret=0, ieIdx=0, ueIdx=0, cellIdx=0;
-   bool ueCbFound = false;
+   int8_t ueIdx = -1;
+   uint8_t  ret=0, ieIdx=0, ieExtIdx = 0, servCellIdx = 0;
+   bool ueCbFound = false, hoInProgress = false;
+   uint16_t nrCellId = 0,  cellIdx=0;
    uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
    DuUeCb   *duUeCb = NULL;
    UEContextSetupRequest_t   *ueSetReq = NULL;
    DRBs_ToBeSetup_List_t *drbCfg = NULL;
+   CUtoDURRCInformation_t *rrcInfo = NULL;
 
    ret = ROK;
 
@@ -11818,80 +13025,139 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
                break;
             }
+
          case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
             {
                gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
                break;
             }
+
+         case ProtocolIE_ID_id_SpCell_ID:
+            {
+               bitStringToInt(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity, &nrCellId);
+
+               GET_CELL_IDX(nrCellId, cellIdx);
+               if(!duCb.actvCellLst[cellIdx])
+               {
+                  DU_LOG("\nERROR  -->  F1AP : Cell Id [%d] not found", nrCellId);
+                  ret = RFAILED;
+               }
+               break;
+            }
+
          case ProtocolIE_ID_id_ServCellIndex:
             {
-               cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
+               servCellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
+               break;
+            }
+
+         case ProtocolIE_ID_id_SpCellULConfigured:
+            {
+               /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL, 
+                  UL, SUL or UL+SUL for the indicated cell for the UE */
+               break;
+            }
+
+         case ProtocolIE_ID_id_CUtoDURRCInformation:
+            {
+               rrcInfo = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation;
+
+               /* Search if UE context is present */
                for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
                {
-                  if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
-                        (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
+                  if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId)
                   {
                      ueCbFound = true;
                      duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
-                     DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
-                     if(duUeCb->f1UeDb)
-                     {
-                        memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
-                        duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
-                        duUeCb->f1UeDb->cellIdx = cellIdx;
-                     }
-                     else
+                     break;
+                  }
+               }
+
+               /* Check if UE Handover scenario */
+               if(rrcInfo->iE_Extensions)
+               {
+                  for(ieExtIdx = 0; ieExtIdx < rrcInfo->iE_Extensions->list.count; ieExtIdx++)
+                  {
+                     if(rrcInfo->iE_Extensions->list.array[ieExtIdx]->id == ProtocolIE_ID_id_HandoverPreparationInformation)
                      {
-                        DU_LOG("\nERROR  -->  F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
-                        ret = RFAILED;
+                        hoInProgress = true;
+                        break;
                      }
-                     break;
                   }
+               }
+               
+               /* If UE context is not present, but UE is in handover */
+               if(!ueCbFound && hoInProgress)
+               {
+                  ueIdx = getFreeBitFromUeBitMap(nrCellId);
+                  if(ueIdx != -1)
+                     gnbDuUeF1apId = ueIdx +1;
                   else
-                     ueCbFound = false;
+                  {
+                     DU_LOG("\nERROR  -->  F1AP : No free UE IDX found in UE bit map of cell Id [%d]", nrCellId);
+                     ret = RFAILED;
+                     break;
+                  }
+                  duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
+                  duUeCb->f1UeDb = NULL;
+                  duUeCb->gnbCuUeF1apId = gnbCuUeF1apId;
+                  duUeCb->gnbDuUeF1apId = gnbDuUeF1apId;
+                  GET_CRNTI(duUeCb->crnti, duUeCb->gnbDuUeF1apId);
+                  duUeCb->ueState = UE_HANDIN_IN_PROGRESS;
+               }
 
+               if(duUeCb)
+               {
+                  DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
+                  if(duUeCb->f1UeDb)
+                  {
+                     memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
+                     duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
+                     duUeCb->f1UeDb->cellIdx = cellIdx;
+                  }
+                  else
+                  {
+                     DU_LOG("\nERROR  -->  F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
+                     ret = RFAILED;
+                     break;
+                  }
                }
-               if(!ueCbFound)
+               else
                {
                   DU_LOG("\nERROR  -->  F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
                   ret = RFAILED;
+                  break;
                }
-               break;
-            }
-         case ProtocolIE_ID_id_SpCellULConfigured:
-            /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL, 
-               UL, SUL or UL+SUL for the indicated cell for the UE */
-            break;
-         case ProtocolIE_ID_id_CUtoDURRCInformation:
-            {
-               if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
+                 
+               /* Extract UE capability info */
+               if(rrcInfo->uE_CapabilityRAT_ContainerList)
                {
-                  duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
-                  extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
-                  uE_CapabilityRAT_ContainerList, duUeCb);
+                  duUeCb->f1UeDb->duUeCfg.ueNrCapability = extractUeCapability(rrcInfo->uE_CapabilityRAT_ContainerList, duUeCb);
                }
-               if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
+
+               /* Extract IE extension */
+               if(rrcInfo->iE_Extensions)
                {
-                  duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
-                        value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
-                  if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
+                  if(extractCuToDuRrcInfoExt(rrcInfo->iE_Extensions, &duUeCb->f1UeDb->duUeCfg) != ROK)
                   {
-                     DU_LOG("\nERROR  -->  F1AP: Failed to extract cell Grp Info");
+                     DU_LOG("\nERROR  -->  F1AP: Failed to extract CU to DU RRC information extension IE");
                      //TODO: Update the failure cause in ue context Setup Response
                      ret = RFAILED;
                   }
                }
                break;
             } 
+
          case ProtocolIE_ID_id_SCell_ToBeSetup_List:
             {
                DU_LOG("\nINFO   -->  DU_APP: Received SCell_ToBeSetup_List but  Not processing the list");
                break;
             }
+
          case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
             {
                if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
-               &duUeCb->f1UeDb->duUeCfg))
+                        &duUeCb->f1UeDb->duUeCfg))
                {
                   DU_LOG("\nERROR  -->  DU APP : Failed at extractSrbListToSetup()");
                   //TODO: Update the failure cause in ue context Setup Response
@@ -11899,18 +13165,20 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                }
                break;
             }
+
          case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
             {
-                  drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
+               drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
 
-                  if(extractDrbListToSetupMod(drbCfg, NULL, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULLP))
-                  {
-                     DU_LOG("\nERROR  -->  DU APP : Failed at extractDrbListToSetupMod()");
-                     //TODO: Update the failure cause in ue context Setup Response
-                     ret = RFAILED;
-                  }
+               if(extractDrbListToSetupMod(drbCfg, NULL, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULLP))
+               {
+                  DU_LOG("\nERROR  -->  DU APP : Failed at extractDrbListToSetupMod()");
+                  //TODO: Update the failure cause in ue context Setup Response
+                  ret = RFAILED;
+               }
                break;
             }
+
          case ProtocolIE_ID_id_RRCContainer:
             {
                /* Filling Dl RRC Msg Info */
@@ -11929,6 +13197,7 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                }         
                break;
             }
+
          case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
             {
                if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
@@ -11941,6 +13210,7 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                }
                break;
             }
+
          case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
             {
                /* MaximumBitRate Uplink */
@@ -11964,19 +13234,23 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                   ret = RFAILED;
                break;
             }
+
          default:
             {
                break;
             }
+      } /* End of switch */
+
+      /* In case of any failure in any IE */
+      if(ret == RFAILED)
+      {
+         // BuildAndSendUeContextSetupRsp(cellId,ueId);
+         DU_LOG("\nERROR  -->  F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()"); 
+         break;
       }
-   }
-   if(ret == RFAILED)
-   {
-      /*TODO : Negative case*/
-      // BuildAndSendUeContextSetupRsp(cellId,ueId);
-      DU_LOG("\nERROR  -->  F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()"); 
-   }
-   else
+   } /* End of for loop of IEs */
+
+   if(ret == ROK)
       ret = duProcUeContextSetupRequest(duUeCb);
 
    freeAperDecodeF1UeContextSetupReq(ueSetReq); 
@@ -12345,7 +13619,6 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
    asn_enc_rval_t  encRetVal;        /* Encoder return value */
    F1AP_PDU_t               *f1apMsg = NULLP;
    UEContextSetupResponse_t *ueSetRsp = NULLP;
-   CellGroupConfigRrc_t     *cellGrpCfg = NULLP;
    DuUeCb                   *ueCb = NULLP;
 
    DU_LOG("\n INFO   -->  F1AP : Building UE Context Setup Response for cellId %d, ueId %d\n", cellId, ueId);
@@ -12355,54 +13628,54 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
       DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
       if(f1apMsg == NULLP)
       {
-        DU_LOG(" ERROR  -->  F1AP : Memory allocation for F1AP-PDU failed");
-        ret = RFAILED;
-        break;
+         DU_LOG(" ERROR  -->  F1AP : Memory allocation for F1AP-PDU failed");
+         ret = RFAILED;
+         break;
       }
 
       f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
       DU_ALLOC(f1apMsg->choice.successfulOutcome,
-           sizeof(SuccessfulOutcome_t));
+            sizeof(SuccessfulOutcome_t));
       if(f1apMsg->choice.successfulOutcome == NULLP)
       {
-        DU_LOG(" ERROR  -->  F1AP : Memory allocation for      F1AP-PDU failed");
-        ret = RFAILED;
-        break;
+         DU_LOG(" ERROR  -->  F1AP : Memory allocation for     F1AP-PDU failed");
+         ret = RFAILED;
+         break;
       }
 
       f1apMsg->choice.successfulOutcome->procedureCode = \
-                                                        ProcedureCode_id_UEContextSetup;
+                                                         ProcedureCode_id_UEContextSetup;
       f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
       f1apMsg->choice.successfulOutcome->value.present = \
-                                                        SuccessfulOutcome__value_PR_UEContextSetupResponse;
+                                                         SuccessfulOutcome__value_PR_UEContextSetupResponse;
 
       ueSetRsp =
-        &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
-      elementCnt = 4;
+         &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
+      elementCnt = 5;
       ueSetRsp->protocolIEs.list.count = elementCnt;
       ueSetRsp->protocolIEs.list.size = \
-                                       elementCnt * sizeof(UEContextSetupResponse_t *);
+                                        elementCnt * sizeof(UEContextSetupResponse_t *);
 
       /* Initialize the UESetup members */
       DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
-           ueSetRsp->protocolIEs.list.size);
+            ueSetRsp->protocolIEs.list.size);
       if(ueSetRsp->protocolIEs.list.array == NULLP)
       {
-        DU_LOG(" ERROR  -->  F1AP : Memory allocation for UE Setup Response failed");
-        ret = RFAILED;
-        break;
+         DU_LOG(" ERROR  -->  F1AP : Memory allocation for UE Setup Response failed");
+         ret = RFAILED;
+         break;
       }
 
       for(idx=0; idx<elementCnt; idx++)
       {
-        DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
-              sizeof(UEContextSetupResponseIEs_t));
-        if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
-        {
-           DU_LOG(" ERROR  -->  F1AP : Memory allocation for UE Setup Response failed");
-           ret = RFAILED;
-           break;
-        }
+         DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
+               sizeof(UEContextSetupResponseIEs_t));
+         if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
+         {
+            DU_LOG(" ERROR  -->  F1AP : Memory allocation for UE Setup Response failed");
+            ret = RFAILED;
+            break;
+         }
       }
       /* Fetching Ue Cb Info*/
       GET_CELL_IDX(cellId, cellIdx);
@@ -12413,61 +13686,48 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
       idx = 0;
       /*GNB CU UE F1AP ID*/
       ueSetRsp->protocolIEs.list.array[idx]->id        = \
-                                                 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+                                                  ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
       ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
       ueSetRsp->protocolIEs.list.array[idx]->value.present = \
-                                                            UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
+                                                             UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
       ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
 
       /*GNB DU UE F1AP ID*/
       idx++;
       ueSetRsp->protocolIEs.list.array[idx]->id        = \
-                                                 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+                                                  ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
       ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
       ueSetRsp->protocolIEs.list.array[idx]->value.present = \
-                                                            UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
+                                                             UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
       ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
 
 
       /*DUtoCURRC Information */
       idx++;
       ueSetRsp->protocolIEs.list.array[idx]->id  = \
-                                                  ProtocolIE_ID_id_DUtoCURRCInformation;
+                                                   ProtocolIE_ID_id_DUtoCURRCInformation;
       ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
       ueSetRsp->protocolIEs.list.array[idx]->value.present =\
-                                                           UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
-      if(ueCb->f1UeDb)
-      {
-         if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
-        {
-           cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
-           ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
-                    choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
-            if(ret == RFAILED)
-           {
-               DU_LOG("\nERROR  -->  F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
-               freeF1UeDb(ueCb->f1UeDb);
-               ueCb->f1UeDb = NULLP;
-               break;
-           }
-         }
-      }
-      else
-      {
-         DU_LOG("\nERROR  -->  F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
-         ret = RFAILED;
-         break;
-      }
+                                                            UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
+      BuildCellGroupConfigRrc(ueCb, &ueSetRsp->protocolIEs.list.array[idx]->value.choice.DUtoCURRCInformation.cellGroupConfig);
+
+      /* CRNTI */
+      idx++;
+      ueSetRsp->protocolIEs.list.array[idx]->id  = ProtocolIE_ID_id_C_RNTI;
+      ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
+      ueSetRsp->protocolIEs.list.array[idx]->value.present = UEContextSetupResponseIEs__value_PR_C_RNTI;
+      ueSetRsp->protocolIEs.list.array[idx]->value.choice.C_RNTI = ueCb->crnti; 
+
 
       /* Drb Setup List */
       idx++;
       ueSetRsp->protocolIEs.list.array[idx]->id  = \
-                                ProtocolIE_ID_id_DRBs_Setup_List;
+                                                   ProtocolIE_ID_id_DRBs_Setup_List;
       ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
       ueSetRsp->protocolIEs.list.array[idx]->value.present =\
-                                UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
+                                                            UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
       ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
-               &ueCb->f1UeDb->duUeCfg);
+            &ueCb->f1UeDb->duUeCfg);
       if(ret == RFAILED)
       {
          DU_LOG("\nERROR  -->  F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
@@ -12476,9 +13736,9 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
          break;
       }
 
-       /* Free UeContext Db created during Ue context Req */
-       freeF1UeDb(ueCb->f1UeDb);
-       ueCb->f1UeDb = NULLP;
+      /* Free UeContext Db created during Ue context Req */
+      freeF1UeDb(ueCb->f1UeDb);
+      ueCb->f1UeDb = NULLP;
 
       /* TODO: To send Drb list */
       xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
@@ -12487,30 +13747,30 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
       memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
       encBufSize = 0;
       encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
-           encBuf);
+            encBuf);
       /* Encode results */
       if(encRetVal.encoded == ENCODE_FAIL)
       {
-        DU_LOG( "\nERROR  -->  F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
-              encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
-        ret = RFAILED;
-        break;
+         DU_LOG( "\nERROR  -->  F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
+               encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+         ret = RFAILED;
+         break;
       }
       else
       {
-        DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UE Context Setup Response\n");
-        for(int i=0; i< encBufSize; i++)
-        {
-           printf("%x",encBuf[i]);
-        }
+         DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UE Context Setup Response\n");
+         for(int i=0; i< encBufSize; i++)
+         {
+            printf("%x",encBuf[i]);
+         }
       }
 
       /* Sending  msg  */
       if(sendF1APMsg() != ROK)
       {
-        DU_LOG("\nERROR  -->  F1AP : Sending UE Context Setup Response failed");
-        ret = RFAILED;
-        break;
+         DU_LOG("\nERROR  -->  F1AP : Sending UE Context Setup Response failed");
+         ret = RFAILED;
+         break;
       }
       break;
    }
@@ -12543,12 +13803,20 @@ uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueId)
    {
       case UE_CTXT_SETUP:
          {
-            BuildAndSendUeContextSetupRsp(cellId,ueId);
+            if((BuildAndSendUeContextSetupRsp(cellId,ueId)) != ROK)
+            {
+               DU_LOG("\nERROR  -->  F1AP : Failed at BuildAndSendUeContextSetupRsp()");
+               return RFAILED;
+            }
             break;
          }
       case UE_CTXT_MOD:
          {
-            BuildAndSendUeContextModRsp(&duCb.actvCellLst[cellIdx]->ueCb[ueId-1]);
+            if((BuildAndSendUeContextModRsp(&duCb.actvCellLst[cellIdx]->ueCb[ueId-1])) != ROK)
+            {
+               DU_LOG("\nERROR  -->  F1AP : Failed at BuildAndSendUeContextModRsp");
+               return RFAILED;
+            }
             break;
          }
       default:
@@ -13469,16 +14737,20 @@ uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
                            {
                               cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
                               bitStringToInt(cellIdentity, &cellId);
+
+                              GET_CELL_IDX(cellId, cellIdx);
+                              if(duCb.actvCellLst[cellIdx] != NULLP)
+                              {
+                                 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
+                              }
                            }
                         }
                      }
 
-                     GET_CELL_IDX(cellId, cellIdx);
                      if(duCb.actvCellLst[cellIdx] != NULLP)
                      {
                         if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
                         {
-                           duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
                            ret = duSendCellDeletReq(cellId);
                            if(ret == RFAILED)
                            {
@@ -13810,6 +15082,13 @@ uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
    struct DRBs_SetupMod_ItemIEs *drbItemIe;
 
    drbCnt = ueCfg->numDrbSetupMod;
+
+   if(!drbCnt)
+   {
+      DU_LOG("\nINFO  -->  F1AP : BuildDrbToBeSetupModList(): No DRB information to avaialble to add");
+      return ROK;
+   }
+
    drbSet->list.count = drbCnt;
    drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
    DU_ALLOC(drbSet->list.array, drbSet->list.size);
@@ -14006,9 +15285,16 @@ uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
       ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
   
       if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
-         elementCnt = 3;
+      {
+         if(ueCb->f1UeDb->duUeCfg.numDrbSetupMod)
+            elementCnt =3;
+         else
+            elementCnt =2;
+      }
       if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
          elementCnt = 5;
+      if(ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE)
+         elementCnt = 2;
       ueContextModifyRes->protocolIEs.list.count = elementCnt;
       ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
 
@@ -14054,27 +15340,30 @@ uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
          BuildCellGroupConfigRrc(ueCb, &ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCInformation.cellGroupConfig);
       }
 
-      ieIdx++;
-      ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
-      ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
-      ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
-                                                                        UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
-      if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
-      {
-         for(tnlIdx = 0; tnlIdx < duCb.numTeId; tnlIdx++)
+      if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || ((ueCb->f1UeDb->actionType == UE_CTXT_MOD) && (ueCb->f1UeDb->duUeCfg.numDrbSetupMod)))
+      { 
+         ieIdx++;
+         ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
+         ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
+         ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
+                                                                           UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
+         if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
          {
-            if(duCb.upTnlCfg[tnlIdx]->ueId == ueCb->gnbDuUeF1apId)
+            for(tnlIdx = 0; tnlIdx < duCb.numTeId; tnlIdx++)
             {
-               memcpy(&ueCb->f1UeDb->duUeCfg.upTnlInfo[ueCb->f1UeDb->duUeCfg.numDrbSetupMod++], duCb.upTnlCfg[tnlIdx], sizeof(UpTnlCfg));
+               if(duCb.upTnlCfg[tnlIdx]->ueId == ueCb->gnbDuUeF1apId)
+               {
+                  memcpy(&ueCb->f1UeDb->duUeCfg.upTnlInfo[ueCb->f1UeDb->duUeCfg.numDrbSetupMod++], duCb.upTnlCfg[tnlIdx], sizeof(UpTnlCfg));
+               }
             }
          }
-      }
-      ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
-               value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
-      if(ret != ROK)
-      {
-         DU_LOG( "\nERROR  -->  F1AP : Failed to build DRB setupmod List ");
-         break;
+         ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
+                  value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
+         if(ret != ROK)
+         {
+            DU_LOG( "\nERROR  -->  F1AP : Failed to build DRB setupmod List ");
+            break;
+         }
       }
 
       if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
@@ -14135,6 +15424,8 @@ uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
          ret = RFAILED;
          break;
       }
+
+      ret = ROK;
       break;
    }
    FreeUeContextModResp(f1apMsg);
@@ -14359,17 +15650,17 @@ void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
  * @return void
  *
  * ****************************************************************/
-void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
+void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *ueContextModifyReq )
 {
    uint8_t arrIdx, ieId;
 
-   if(UeContextModifyReq->protocolIEs.list.array)
+   if(ueContextModifyReq->protocolIEs.list.array)
    {
-      for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
+      for( arrIdx = 0 ; arrIdx<ueContextModifyReq->protocolIEs.list.count ; arrIdx++)
       {
-         if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
+         if(ueContextModifyReq->protocolIEs.list.array[arrIdx])
          {
-            ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
+            ieId = ueContextModifyReq->protocolIEs.list.array[arrIdx]->id;
             switch(ieId)
             {
                case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
@@ -14378,15 +15669,21 @@ void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *U
                   break;
                case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
                   {
-                     freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
+                     freeAperDecodeDrbToBeSetupModList(&ueContextModifyReq->protocolIEs.list.array[arrIdx]->\
                            value.choice.DRBs_ToBeSetupMod_List);
                      break;
                   }
+               case ProtocolIE_ID_id_TransmissionActionIndicator:
+                  break;
+               case ProtocolIE_ID_id_RRCContainer:
+                  {
+                     free(ueContextModifyReq->protocolIEs.list.array[arrIdx]->value.choice.RRCContainer.buf);
+                  }
             }
-            free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
+            free(ueContextModifyReq->protocolIEs.list.array[arrIdx]);
          }
       }
-      free(UeContextModifyReq->protocolIEs.list.array);
+      free(ueContextModifyReq->protocolIEs.list.array);
    }
 }
 /*******************************************************************
@@ -14406,7 +15703,7 @@ void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *U
 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
 {
    UEContextModificationRequest_t *ueContextModifyReq = NULLP;
-   uint8_t  ret = ROK, ieIdx = 0, cellIdx=0, ueIdx=0;
+   uint8_t  ret = ROK, ieIdx = 0, cellIdx=0;
    DuUeCb   *duUeCb = NULLP;
    DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
    DRBs_ToBeModified_List_t *drbModifiedCfg;
@@ -14425,17 +15722,19 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
          case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
             {
                gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
-               for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
+               for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
                {
-                  for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
+                  if(duCb.actvCellLst[cellIdx])
                   {
-                     if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
-                           (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
+                     if((duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbDuUeF1apId == gnbDuUeF1apId)&&\
+                           (duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbCuUeF1apId == gnbCuUeF1apId))
                      {
-                        duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
+                        duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1];
                         if(duUeCb->f1UeDb == NULLP)
                         {
                            DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
+                           duUeCb->f1UeDb->cellIdx = cellIdx;
+                           duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
                         }
                         break;
                      }
@@ -14448,12 +15747,34 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
                }
                break;
             }
+
+         case ProtocolIE_ID_id_RRCContainer:
+            {
+               /* Filling Dl RRC Msg Info */
+               DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
+               if(!duUeCb->f1UeDb->dlRrcMsg)
+               {
+                  DU_LOG("\nERROR  -->  DU APP : procF1UeContextReleaseCommand(): \
+                        Memory allocation failed ");
+                  ret = RFAILED;
+               }
+               else
+               {
+                  duUeCb->f1UeDb->dlRrcMsgPres = true;
+                  memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
+                  ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
+                        &ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
+                        value.choice.RRCContainer);
+               }
+
+               break;
+            }
+
          case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
          case ProtocolIE_ID_id_DRBs_ToBeModified_List:
             {
                if(duUeCb->f1UeDb)
                {
-                  duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
                   if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present ==\
                         UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List)
                   {
@@ -14484,6 +15805,7 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
                }
                break;
             }
+
          case ProtocolIE_ID_id_GNB_DUConfigurationQuery:
             {
                DU_LOG("\nINFO  -->  DU APP : Received GNB DU Configuration Query in UE Context Modification Request from CU");
@@ -14493,10 +15815,45 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
                }
                break;
             }
+
+         case ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator:
+            {
+               if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.RRCReconfigurationCompleteIndicator == \
+                  RRCReconfigurationCompleteIndicator_true)
+               {
+                  duUeCb->f1UeDb->actionType = UE_CTXT_RRC_RECFG_COMPLETE;
+               }
+               break;
+            }
+         case ProtocolIE_ID_id_TransmissionActionIndicator:
+            {
+               if(duUeCb->f1UeDb)
+               {
+                  if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.TransmissionActionIndicator  == TransmissionActionIndicator_stop)
+                  {
+                     duUeCb->f1UeDb->duUeCfg.dataTransmissionAction = STOP_TRANSMISSION; 
+                  }
+                  else 
+                  {
+                     duUeCb->f1UeDb->duUeCfg.dataTransmissionAction = RESTART_TRANSMISSION; 
+                  }
+               }
+               break;
+            }
+
+         case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
+            {
+               if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
+               {
+                  duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
+               }
+               break;
+            }
+              
       }
    }
 
-   if(ret != RFAILED)
+   if(ret != RFAILED) 
    {
       ret = duProcUeContextModReq(duUeCb);
    }
@@ -14853,9 +16210,9 @@ uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1
       break;
    }while(true);
    
-   if(ret == ROK && (duCb.actvCellLst[cellId-1]->numActvUes == 0))
+   if((ret == ROK) && (duCb.actvCellLst[cellId-1]) && (duCb.actvCellLst[cellId-1]->cellStatus == DELETION_IN_PROGRESS) 
+         && (duCb.actvCellLst[cellId-1]->numActvUes == 0))
    {
-      duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
       ret = duSendCellDeletReq(cellId);
       if(ret != ROK)
       {
@@ -14939,8 +16296,8 @@ void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
 {
    uint8_t  ieIdx=0, ret=ROK, ueIdx=0;
-   uint16_t cellIdx =0;
-   bool ueIdxFound;
+   uint16_t cellIdx =0, cellId = 0;
+   bool ueIdxFound = false;
    uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
    DuUeCb   *duUeCb = NULLP;
    UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
@@ -14971,51 +16328,15 @@ uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
 
                case ProtocolIE_ID_id_Cause:
                   {
-                     break;
-                  }
-
-               case ProtocolIE_ID_id_RRCContainer:
-                  {
-                     for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
+                     for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
                      {
                         for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
                         {
-                           if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
+                           if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
                                  (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
                            {
+                              cellId = duCb.actvCellLst[cellIdx]->cellId;
                               duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
-                              DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
-                              if(duUeCb->f1UeDb)
-                              {
-                                 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
-                                 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
-                                 duUeCb->f1UeDb->cellIdx = cellIdx;
-                                 /* Filling Dl RRC Msg Info */
-                                 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
-                                 if(!duUeCb->f1UeDb->dlRrcMsg)
-                                 {
-                                    DU_LOG("\nERROR  -->  DU APP : procF1UeContextReleaseCommand(): \
-                                    Memory allocation failed ");
-                                    ret = RFAILED;
-                                 }
-                                 else
-                                 {
-                                    duUeCb->f1UeDb->dlRrcMsgPres = true;
-                                    memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
-                                    ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
-                                          &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
-                                          value.choice.RRCContainer);
-                                 }
-
-                              }
-                              else
-                              {
-                                 DU_LOG("\nERROR  -->  DU APP : procF1UeContextReleaseCommand(): \
-                                 Memory allocation failed ");
-                                 ret = RFAILED;
-
-                              }
-
                               ueIdxFound = true;
                               break;
                            }
@@ -15025,13 +16346,51 @@ uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
                            break;
                         }
                      }
+                     
                      if(!ueIdxFound)
                      {
-                        DU_LOG("\nERROR  -->  F1AP: DuUeCb is not found at procF1UeContextReleaseCommand()");
+                        DU_LOG("\nERROR  -->  F1AP: procF1UeContextReleaseCommand(): Ue Information is not available");
                         ret = RFAILED;
                      }
+                     break;
+                  }
+
+               case ProtocolIE_ID_id_RRCContainer:
+                  {
+                     if(ueIdxFound == true)  
+                     {
+                        DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
+                        if(duUeCb->f1UeDb)
+                        {
+                           memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
+                           duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
+                           duUeCb->f1UeDb->cellIdx = cellIdx;
+                           /* Filling Dl RRC Msg Info */
+                           DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
+                           if(!duUeCb->f1UeDb->dlRrcMsg)
+                           {
+                              DU_LOG("\nERROR  -->  DU APP : procF1UeContextReleaseCommand(): \
+                                    Memory allocation failed ");
+                              ret = RFAILED;
+                           }
+                           else
+                           {
+                              duUeCb->f1UeDb->dlRrcMsgPres = true;
+                              memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
+                              ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
+                                    &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
+                                    value.choice.RRCContainer);
+                           }
 
+                        }
+                        else
+                        {
+                           DU_LOG("\nERROR  -->  DU APP : procF1UeContextReleaseCommand(): \
+                                 Memory allocation failed ");
+                           ret = RFAILED;
 
+                        }
+                     }
                      break;
                   }
                default :
@@ -15044,11 +16403,231 @@ uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
    }
    if(ret != RFAILED)
    {
-      duProcUeContextReleaseCommand(duUeCb);
+      duProcUeContextReleaseCommand(cellId, duUeCb);
    }
    freeAperDecodeUeContextReleaseCommand(f1apMsg);
    return ret;
 }
+
+/**************************************************************
+ *
+ * @brief free the memory allocated by aper decoder for paging
+ *
+ * @details
+ *
+ *    Function : freeAperDecodePagingMsg
+ *
+ *    Functionality:
+ *         - free the memory allocated by aper decoder for
+ *         the paging f1ap msg
+ *
+ * @params[in] Paging_t   *paging
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ****************************************************************/
+void freeAperDecodePagingMsg(Paging_t   *paging)
+{
+   uint8_t ieIdx, cellIdx;
+   PagingCell_ItemIEs_t *pagingCellItemIes;
+   PagingCell_Item_t *pagingCellItem;
+   PagingCell_list_t  *pagingCelllist;
+
+   if(paging)
+   {
+      if(paging->protocolIEs.list.array)
+      {
+         for(ieIdx=0 ; ieIdx<paging->protocolIEs.list.count; ieIdx++)
+         {
+            if(paging->protocolIEs.list.array[ieIdx])
+            {
+               switch(paging->protocolIEs.list.array[ieIdx]->id)
+               {
+                  case ProtocolIE_ID_id_UEIdentityIndexValue:
+                     {
+                        free(paging->protocolIEs.list.array[ieIdx]->value.choice.UEIdentityIndexValue.choice.indexLength10.buf);
+                        break;
+                     }
+                  case ProtocolIE_ID_id_PagingIdentity:
+                     {
+                        if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.present == PagingIdentity_PR_cNUEPagingIdentity)
+                        {
+                           if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity)
+                           {
+                              if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity->present == \
+                                    CNUEPagingIdentity_PR_fiveG_S_TMSI)
+                              {
+                                 free(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity->choice.fiveG_S_TMSI.buf);
+                              }
+                              free(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity);
+                           }
+                        }
+                        break;
+                     }
+                  case ProtocolIE_ID_id_PagingCell_List:
+                     {
+                        pagingCelllist = &paging->protocolIEs.list.array[ieIdx]->value.choice.PagingCell_list;
+                        if(pagingCelllist->list.array)
+                        {
+                           for(cellIdx = 0; cellIdx < pagingCelllist->list.count; cellIdx++)
+                           {
+                              if(pagingCelllist->list.array[cellIdx])
+                              {
+                                 pagingCellItemIes = (PagingCell_ItemIEs_t *)pagingCelllist->list.array[cellIdx];
+                                 if(pagingCellItemIes->id == ProtocolIE_ID_id_PagingCell_Item)
+                                 {
+                                    pagingCellItem = &pagingCellItemIes->value.choice.PagingCell_Item;
+                                    free(pagingCellItem->nRCGI.pLMN_Identity.buf);
+                                    free(pagingCellItem->nRCGI.nRCellIdentity.buf);
+                                 }
+                                 free(pagingCelllist->list.array[cellIdx]);
+                              }
+                           }
+                           free(pagingCelllist->list.array);
+                        }
+                        break;
+                     }
+               }
+               free(paging->protocolIEs.list.array[ieIdx]);
+            }
+         }
+         free(paging->protocolIEs.list.array);
+
+      }
+   }
+}
+
+/**************************************************************
+ *
+ * @brief processing the paging f1ap msg received from CU 
+ *
+ * @details
+ *
+ *    Function : procPagingMsg
+ *
+ *    Functionality:
+ *         - processing the paging f1ap msg received from CU
+ *
+ * @params[in] F1AP_PDU_t *f1apMsg
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ *
+ ****************************************************************/
+uint8_t procPagingMsg(F1AP_PDU_t *f1apMsg) 
+{
+   uint8_t ieIdx = 0, cellListIdx = 0;
+   uint16_t cellId = 0;
+   Paging_t   *paging = NULLP;
+   PagingCell_list_t  *pagingCelllist = NULLP;
+   PagingCell_ItemIEs_t *pagingCellItemIes = NULLP;
+   PagingCell_Item_t *pagingCellItem = NULLP;
+   DuPagingMsg *tmpPagingParam = NULLP;
+
+   DU_LOG("\nINFO  --> DU APP : Processing the Paging Message");
+   paging = &f1apMsg->choice.initiatingMessage->value.choice.Paging;
+   if(paging)
+   {
+      if(paging->protocolIEs.list.array)
+      {
+         DU_ALLOC(tmpPagingParam, sizeof(DuPagingMsg));
+         if(tmpPagingParam == NULLP)
+         {
+            DU_LOG("\nERROR  --> DU APP : Memory Allocation Failure in procPagingMsg");
+            freeAperDecodePagingMsg(paging);
+            return RFAILED;
+         }
+         for(ieIdx=0 ; ieIdx<paging->protocolIEs.list.count; ieIdx++)
+         {
+            if(paging->protocolIEs.list.array[ieIdx])
+            {
+               switch(paging->protocolIEs.list.array[ieIdx]->id)
+               {
+                  case ProtocolIE_ID_id_UEIdentityIndexValue:
+                     {
+                        bitStringToInt(&paging->protocolIEs.list.array[ieIdx]->value.choice.UEIdentityIndexValue.choice.indexLength10,\
+                                         &tmpPagingParam->pagUeId);
+                        break;
+                     }
+
+                  case ProtocolIE_ID_id_PagingIdentity:
+                     {
+                        switch(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.present)
+                        {
+                           case PagingIdentity_PR_cNUEPagingIdentity: 
+                              {
+                                 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity)  
+                                 {
+                                    bitStringToInt(&paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.\
+                                          cNUEPagingIdentity->choice.fiveG_S_TMSI, &tmpPagingParam->sTmsi);
+
+                                 }
+                                 break;
+                              }
+                            case PagingIdentity_PR_rANUEPagingIdentity:
+                               {
+                                  /*TODO: This Identifier is specific to RAN Initiated Paging – Connected Mode Paging*/
+                                  break;
+                               }
+                            default:
+                               {
+                                  DU_LOG("ERROR  -->  DU APP: Invalid UE Paging Identity, Skipping this Paging Message:");
+                                  continue;
+                               }
+                        }
+                     }
+
+                  case ProtocolIE_ID_id_PagingDRX:
+                     {
+                        tmpPagingParam->pagingDrxPres = TRUE;
+                        tmpPagingParam->pagingDrx = convertPagingCycleEnumToValue(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingDRX);
+                        break;
+                     }
+
+                  case ProtocolIE_ID_id_PagingPriority:
+                     {
+                        tmpPagingParam->pagPriority = paging->protocolIEs.list.array[ieIdx]->value.choice.PagingPriority;
+                        break;
+                     }
+
+                  case ProtocolIE_ID_id_PagingCell_List:
+                     {
+                        pagingCelllist = &paging->protocolIEs.list.array[ieIdx]->value.choice.PagingCell_list; 
+                        if(pagingCelllist->list.array)
+                        {
+                           for(cellListIdx = 0; cellListIdx < pagingCelllist->list.count; cellListIdx++)
+                           {
+                              if(pagingCelllist->list.array[cellListIdx])
+                              {
+                                 pagingCellItemIes = (PagingCell_ItemIEs_t *)pagingCelllist->list.array[cellListIdx];
+                                 pagingCellItem = &pagingCellItemIes->value.choice.PagingCell_Item;
+                                 bitStringToInt(&pagingCellItem->nRCGI.nRCellIdentity, &cellId);
+                                 if(processPagingMsg(cellId, tmpPagingParam) != ROK)
+                                 {
+                                    DU_LOG("\nERROR  --> DU APP : Paging Processing Failed at CellId:%d",cellId);
+                                    continue;
+                                 }
+                              }
+                           }
+                        }
+                        break;
+                     }
+                   default:
+                     {
+                         DU_LOG("\nERROR  --> F1AP : Incorrect Paging IE option");
+                         break;
+                     }
+               }
+            }
+         }
+      }
+   }
+   DU_FREE(tmpPagingParam, sizeof(DuPagingMsg));
+   freeAperDecodePagingMsg(paging);
+  
+   return ROK;
+}
+
 /**************************************************************
  *
  * @brief Handles received F1AP message and sends back response  
@@ -15177,6 +16756,11 @@ void F1APMsgHdlr(Buffer *mBuf)
                       procF1UeContextReleaseCommand(f1apMsg);
                       break;
                   }
+               case InitiatingMessage__value_PR_Paging:
+                  {
+                     procPagingMsg(f1apMsg);
+                     break;
+                  }
                default:
                   {
                      DU_LOG("\nERROR  -->  F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",