[Epic-ID: ODUHIGH-404][Task-ID: ODUHIGH-413] Modification of E2setup request and...
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index 37a0aef..1b52495 100644 (file)
 #include "DLUPTNLInformation-ToBeSetup-Item.h"
 #include "UPTransportLayerInformation.h"
 #include "GTPTunnel.h"
+#include "SupportedSULFreqBandItem.h"
+#include "du_sys_info_hdl.h"
+#include "du_e2ap_msg_hdl.h"
 
 #ifdef O1_ENABLE
 #include "CmInterface.h"
@@ -929,6 +932,89 @@ uint8_t BuildFiveGSTac(Served_Cell_Information_t *servcell)
    servcell->fiveGS_TAC->buf[2] = duCfgParam.srvdCellLst[0].duCellInfo.tac;
    return ROK;  
 }
+
+/*******************************************************************
+ *
+ * @brief fill nr frequency information
+ *
+ * @details
+ *
+ *    Function : fillNrTddInfo 
+ *
+ *    Functionality: fill nr frequency information
+ *
+ * @params[in] NRFreqInfo_t freqInfo
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillNrTddInfo(TDD_Info_t *tddInfo)
+{
+   uint8_t elementCnt = 1, freqBandListIdx = 0, supportedBandIdx = 0;
+   NRFreqInfo_t *freqInfo = NULLP;
+
+   if(tddInfo == NULLP)
+   {
+      DU_LOG("\nERROR  --> DU APP : Null pointer received at fillNrTddInfo");
+      return RFAILED;
+   }
+   
+   freqInfo = &tddInfo->nRFreqInfo;
+   freqInfo->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn; 
+
+   freqInfo->freqBandListNr.list.count = elementCnt; 
+   freqInfo->freqBandListNr.list.size = freqInfo->freqBandListNr.list.count  * sizeof(FreqBandNrItem_t *);
+   DU_ALLOC(freqInfo->freqBandListNr.list.array, freqInfo->freqBandListNr.list.size );
+   if(!freqInfo->freqBandListNr.list.array)
+   {
+      DU_LOG("\nERROR  --> DU APP : Memory allocation failed at fillNrTddInfo");
+      return RFAILED;
+   }
+
+   for(freqBandListIdx = 0; freqBandListIdx<freqInfo->freqBandListNr.list.count; freqBandListIdx++)
+   {
+      DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx],  sizeof(FreqBandNrItem_t ));
+      if(!freqInfo->freqBandListNr.list.array[freqBandListIdx])
+      {
+         DU_LOG("\nERROR  --> DU APP : Memory allocation failed at fillNrTddInfo");
+         return RFAILED;
+      }
+
+      freqInfo->freqBandListNr.list.array[freqBandListIdx]->freqBandIndicatorNr = duCfgParam.srvdCellLst[0].duCellInfo.\
+      f1Mode.mode.tdd.nrFreqInfo.freqBand[0].nrFreqBand;
+      freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count = elementCnt;
+      freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size = freqInfo->freqBandListNr.list.array[freqBandListIdx]->\
+      supportedSULBandList.list.count * sizeof(SupportedSULFreqBandItem_t*);
+
+      DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array,\
+            freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size);
+      if(!freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array)
+      {
+         DU_LOG("\nERROR  --> DU APP : Memory allocation failed at fillNrTddInfo");
+         return RFAILED;
+      }
+
+      for(supportedBandIdx = 0; supportedBandIdx<freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count; supportedBandIdx++)
+      {
+         DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx],\
+               sizeof(SupportedSULFreqBandItem_t));
+         if(!freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx])
+         {
+            DU_LOG("\nERROR  --> DU APP : Memory allocation failed at fillNrTddInfo");
+            return RFAILED;
+         }
+
+         freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx]->freqBandIndicatorNr =\
+         duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[0].sulBand[0];
+      }
+   }
+
+   tddInfo->transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs;
+   tddInfo->transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb;
+
+   return ROK;
+}
+
 /*******************************************************************
  *
  * @brief Builds NR Mode 
@@ -948,38 +1034,63 @@ uint8_t BuildNrMode(NR_Mode_Info_t *mode)
 {
    uint8_t BuildDLNRInforet=0;
    uint8_t BuildULNRInforet=0; 
-   /* FDD Mode */
+   
+#ifdef NR_TDD
+   mode->present = NR_Mode_Info_PR_tDD;
+#else
    mode->present = NR_Mode_Info_PR_fDD;
+#endif   
+   
    if(mode->present == NR_Mode_Info_PR_fDD)
    {
       DU_ALLOC(mode->choice.fDD,sizeof(FDD_Info_t));
       if(mode->choice.fDD == NULLP)
       {
-        return RFAILED;
+         DU_LOG("\nERROR  --> Memory allocation failed in BuildNrMode");
+         return RFAILED;
       }
       BuildULNRInforet = BuildULNRInfo(&mode->choice.fDD->uL_NRFreqInfo);
       if(BuildULNRInforet != ROK)
       {
-        return RFAILED;    
+         DU_LOG("\nERROR  --> Failed to build UlNrFreqInfo");
+         return RFAILED;    
       }
       BuildDLNRInforet = BuildDLNRInfo(&mode->choice.fDD->dL_NRFreqInfo);
       if(BuildDLNRInforet != ROK)
       {
-        return RFAILED;
+         DU_LOG("\nERROR  --> Failed to build DlNrFreqInfo");
+         return RFAILED;
+      }
+      mode->choice.fDD->uL_Transmission_Bandwidth.nRSCS = \
+                                                          duCfgParam.srvdCellLst[0].duCellInfo.\
+                                                          f1Mode.mode.fdd.ulTxBw.nrScs;
+      mode->choice.fDD->uL_Transmission_Bandwidth.nRNRB = \
+                                                          duCfgParam.srvdCellLst[0].duCellInfo.\
+                                                          f1Mode.mode.fdd.ulTxBw.nrb;
+      mode->choice.fDD->dL_Transmission_Bandwidth.nRSCS = \
+                                                          duCfgParam.srvdCellLst[0].duCellInfo.\
+                                                          f1Mode.mode.fdd.dlTxBw.nrScs;
+      mode->choice.fDD->dL_Transmission_Bandwidth.nRNRB = \
+                                                          duCfgParam.srvdCellLst[0].duCellInfo.\
+                                                          f1Mode.mode.fdd.dlTxBw.nrb;
+   }
+   else if(mode->present == NR_Mode_Info_PR_tDD) 
+   {
+      DU_ALLOC(mode->choice.tDD,sizeof(TDD_Info_t));
+      if(mode->choice.tDD == NULLP)
+      {
+         DU_LOG("\nERROR  --> Memory allocation failed in BuildNrMode");
+         return RFAILED;
+      }
+
+      if(fillNrTddInfo(mode->choice.tDD) != ROK)
+      {
+         DU_LOG("\nERROR  --> Failed to fill Nr TDD information");
+         return RFAILED;
       }
+
    }
-   mode->choice.fDD->uL_Transmission_Bandwidth.nRSCS = \
-                                                      duCfgParam.srvdCellLst[0].duCellInfo.\
-                                                      f1Mode.mode.fdd.ulTxBw.nrScs;
-   mode->choice.fDD->uL_Transmission_Bandwidth.nRNRB = \
-                                                      duCfgParam.srvdCellLst[0].duCellInfo.\
-                                                      f1Mode.mode.fdd.ulTxBw.nrb;
-   mode->choice.fDD->dL_Transmission_Bandwidth.nRSCS = \
-                                                      duCfgParam.srvdCellLst[0].duCellInfo.\
-                                                      f1Mode.mode.fdd.dlTxBw.nrScs;
-   mode->choice.fDD->dL_Transmission_Bandwidth.nRNRB = \
-                                                      duCfgParam.srvdCellLst[0].duCellInfo.\
-                                                      f1Mode.mode.fdd.dlTxBw.nrb;
+
    return ROK;
 }
 /*******************************************************************
@@ -1443,6 +1554,90 @@ void FreeRrcVer(RRC_Version_t *rrcVer)
       DU_FREE(rrcVer->latest_RRC_Version.buf,rrcVer->latest_RRC_Version.size);
    }
 }
+
+/*******************************************************************
+ *
+ * @brief Deallocating memory of TDD NrFreqInfo 
+ *
+ * @details
+ *
+ *    Function : freeTddNrFreqInfo 
+ *
+ *    Functionality: freeTddNrFreqInfo 
+ *
+ * @params[in]  F1AP_PDU_t *f1apDuCfg
+ *
+ * @return ROK     - void
+ *
+ * ****************************************************************/
+void freeTddNrFreqInfo(NRFreqInfo_t *freqInfo)
+{
+   uint8_t freqBandListIdx = 0, supportedBandIdx = 0;
+
+   if(freqInfo->freqBandListNr.list.array)
+   {
+      for(freqBandListIdx = 0; freqBandListIdx<freqInfo->freqBandListNr.list.count; freqBandListIdx++)
+      {
+         if(freqInfo->freqBandListNr.list.array[freqBandListIdx])
+         {
+            if(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array)
+            {
+               for(supportedBandIdx = 0; supportedBandIdx<freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count; supportedBandIdx++)
+               {
+                  DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx],\
+                        sizeof(SupportedSULFreqBandItem_t));
+               }
+               DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array,\
+                     freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size);
+
+            }
+            DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx],  sizeof(FreqBandNrItem_t ));
+         }
+      }
+      DU_FREE(freqInfo->freqBandListNr.list.array, freqInfo->freqBandListNr.list.size );
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocating memory allocated for Nr fdd frequencey mode 
+ *
+ * @details
+ *
+ *    Function : freeFddNrFreqInfo 
+ *
+ *    Functionality:Free memory allocated for Nr fdd frequencey mode 
+ *
+ * @params[in]  
+ *
+ * @return ROK     - void
+ *
+ * ****************************************************************/
+void freeFddNrFreqInfo(FDD_Info_t *fDD)
+{
+   uint8_t arrIdx =0;
+
+   if(fDD != NULLP)
+   {
+      if(fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
+      {
+         DU_FREE(fDD->uL_NRFreqInfo.freqBandListNr.list.\
+               array[arrIdx], sizeof(FreqBandNrItem_t));
+         DU_FREE(fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
+               fDD->uL_NRFreqInfo.freqBandListNr.list.size);
+      }
+
+      if(fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
+      {
+         DU_FREE(fDD->dL_NRFreqInfo.freqBandListNr.list.\
+               array[arrIdx], sizeof(FreqBandNrItem_t));
+         DU_FREE(fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
+               fDD->dL_NRFreqInfo.freqBandListNr.list.size);
+      }
+      DU_FREE(fDD,sizeof(FDD_Info_t));
+   }
+}
+
 /*******************************************************************
  *
  * @brief  deallocating the memory of function BuildAndSendF1SetupReq()
@@ -1500,71 +1695,62 @@ void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell)
                      if(servedPlmnItem->iE_Extensions->list.array[0] != NULLP)
                      {
                         if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
-                        SliceSupportList.list.array != NULLP)
+                              SliceSupportList.list.array != NULLP)
                         {
                            for(sliceIdx =0; sliceIdx<servedPlmnItem->iE_Extensions->list.array[0]->\
-                           extensionValue.choice.SliceSupportList.list.count; sliceIdx++)
+                                 extensionValue.choice.SliceSupportList.list.count; sliceIdx++)
                            {
                               if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
-                              SliceSupportList.list.array[sliceIdx] != NULLP)
+                                    SliceSupportList.list.array[sliceIdx] != NULLP)
                               {
                                  sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[0]->\
-                                 extensionValue.choice.SliceSupportList.list.array[sliceIdx];
+                                                    extensionValue.choice.SliceSupportList.list.array[sliceIdx];
 
                                  DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sizeof(uint8_t));
 
                                  if(sliceSupportItem->sNSSAI.sD != NULLP)
                                  {
                                     DU_FREE(sliceSupportItem->sNSSAI.sD->buf,\
-                                    sliceSupportItem->sNSSAI.sD->size);
+                                          sliceSupportItem->sNSSAI.sD->size);
                                     DU_FREE(sliceSupportItem->sNSSAI.sD, sizeof(OCTET_STRING_t));
                                  }
 
                                  DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.\
-                                 choice.SliceSupportList.list.array[sliceIdx], sizeof(SliceSupportItem_t));
+                                       choice.SliceSupportList.list.array[sliceIdx], sizeof(SliceSupportItem_t));
                               }
                            }
                            DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
-                           SliceSupportList.list.array, servedPlmnItem->iE_Extensions->list.array[0]->\
-                           extensionValue.choice.SliceSupportList.list.size);
+                                 SliceSupportList.list.array, servedPlmnItem->iE_Extensions->list.array[0]->\
+                                 extensionValue.choice.SliceSupportList.list.size);
                         }
                         DU_FREE(servedPlmnItem->iE_Extensions->list.array[0],\
-                        sizeof(ServedPLMNs_ItemExtIEs_t));
+                              sizeof(ServedPLMNs_ItemExtIEs_t));
                      }
                      DU_FREE(servedPlmnItem->iE_Extensions->list.array,\
-                     extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
+                           extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
                   }
                   DU_FREE(servedPlmnItem->iE_Extensions, sizeof(ProtocolExtensionContainer_4624P3_t));
                }
                DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx],\
-               sizeof(ServedPLMNs_Item_t));
+                     sizeof(ServedPLMNs_Item_t));
             }
             DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array,\
-            sizeof(ServedPLMNs_Item_t *));
+                  sizeof(ServedPLMNs_Item_t *));
          }
 
-         if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
+         if(srvCellItem->served_Cell_Information.nR_Mode_Info.present == NR_Mode_Info_PR_fDD)
          {
-            if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.\
-                  freqBandListNr.list.array != NULLP)
-            {
-               DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->\
-               uL_NRFreqInfo.freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
-               DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->\
-               uL_NRFreqInfo.freqBandListNr.list.array,sizeof(FreqBandNrItem_t*));
-            }
-
-            if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
-                  freqBandListNr.list.array)
+            freeFddNrFreqInfo(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD);
+         }
+         else   
+         {
+            if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD != NULLP)
             {
-               DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
-                     freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
-               DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
-                     freqBandListNr.list.array,sizeof(FreqBandNrItem_t *));
+               freeTddNrFreqInfo(&srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD->nRFreqInfo);
+               DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
             }
-            DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
          }
-
+         
          DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
                srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
 
@@ -1812,24 +1998,33 @@ uint8_t BuildAndSendF1SetupReq()
       /* Encode results */
       if(encRetVal.encoded == ENCODE_FAIL)
       {
-        DU_LOG("\nERROR  -->  F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
-              encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
-        break;
+         DU_LOG("\nERROR  -->  F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
+               encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+         break;
       }
       else
       {
-        DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for F1SetupRequest\n");
-        for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
-        {
-           printf("%x",encBuf[ieIdx]);
-        }
+         DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for F1SetupRequest\n");
+         for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
+         {
+            printf("%x",encBuf[ieIdx]);
+         }
+         
+         duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize = encBufSize;
+         DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, encBufSize);
+         if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
+         {
+             DU_LOG("\nERROR  -->  F1AP : Memory allocation failed to store the encoding of f1setup req");
+             return RFAILED;
+         }
+         memcpy(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, &encBuf, duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize);
       }
 
       /* Sending msg */
       if(sendF1APMsg() != ROK)
       {
-        DU_LOG("\nERROR  -->  F1AP : Sending F1 Setup request failed");
-        break;
+         DU_LOG("\nERROR  -->  F1AP : Sending F1 Setup request failed");
+         break;
       }
 
       ret=ROK;
@@ -1931,27 +2126,19 @@ void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
       DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
          modifyItem->served_Cell_Information.servedPLMNs.list.size);
    }
-
-   if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
+   
+   if(modifyItem->served_Cell_Information.nR_Mode_Info.present == NR_Mode_Info_PR_fDD)
    {
-      if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
-      {
-         DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
-               array[arrIdx], sizeof(FreqBandNrItem_t));
-         DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
-               modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
-      }
-
-      if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
+      freeFddNrFreqInfo(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD);
+   }  
+   else
+   {
+      if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD)
       {
-         DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.\
-             array[arrIdx], sizeof(FreqBandNrItem_t));
-         DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
-               modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
+         freeTddNrFreqInfo(&modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD->nRFreqInfo);
+         DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
       }
-      DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD,sizeof(FDD_Info_t));
    }
-
    DU_FREE(modifyItem->served_Cell_Information.measurementTimingConfiguration.buf,\
       modifyItem->served_Cell_Information.measurementTimingConfiguration.size);
 }
@@ -2221,64 +2408,70 @@ uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
  *
  *    Functionality: Fills Nr Fdd Info required in ServCellInfo IE
  *
- * @params[in] Pointer to NR_Mode_Info_t *
+ * @params[in] FDD_Info_t *fDD
  *
  * @return ROK     - success
  *         RFAILED - failure
  *
  *****************************************************************/
 
-uint8_t fillNrFddInfo(NR_Mode_Info_t *nrFdd)
+uint8_t fillNrFddInfo(FDD_Info_t *fDD)
 {
-   nrFdd->choice.fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
+   fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
       f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
-   nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
-   nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
-   DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
-        array, nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
-   if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
+   fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
+   fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
+   DU_ALLOC(fDD->uL_NRFreqInfo.freqBandListNr.list.\
+        array, fDD->uL_NRFreqInfo.freqBandListNr.list.size);
+   if(fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
    {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillNrFddInfo");
       return RFAILED;
    }
-   DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
+
+   DU_ALLOC(fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
       sizeof(FreqBandNrItem_t));
-   if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
+   if(fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
    {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillNrFddInfo");
       return RFAILED;
    }
-   nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
+   
+   fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
       duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
       freqBand[0].nrFreqBand;
-   nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
-   nrFdd->choice.fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
+   fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
+   fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
       dlNrFreqInfo.nrArfcn;
-   nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
-   nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
-   DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,nrFdd->\
-        choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
-   if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
+   fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
+   fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
+   DU_ALLOC(fDD->dL_NRFreqInfo.freqBandListNr.list.array, fDD->dL_NRFreqInfo.freqBandListNr.list.size);
+   if(fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
    {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillNrFddInfo");
       return RFAILED;
    }
-   DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0],\
-        sizeof(FreqBandNrItem_t));
-   if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
+   
+   DU_ALLOC(fDD->dL_NRFreqInfo.freqBandListNr.list.array[0],  sizeof(FreqBandNrItem_t));
+   if(fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
    {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillNrFddInfo");
       return RFAILED;
    }
-   nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
+
+   fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
       duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
       freqBand[0].nrFreqBand;
-   nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
+   fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
    
    /*Transmission Bandwidth*/
-   nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
+   fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
       f1Mode.mode.fdd.ulTxBw.nrScs;
-   nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
+   fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
       f1Mode.mode.fdd.ulTxBw.nrb;
-   nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
+   fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
       f1Mode.mode.fdd.dlTxBw.nrScs;
-   nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
+   fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
       f1Mode.mode.fdd.dlTxBw.nrb;
 
    return ROK;
@@ -2303,7 +2496,7 @@ uint8_t fillNrFddInfo(NR_Mode_Info_t *nrFdd)
 
 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
 {
-   uint8_t tmp, ieIdx, ieListCnt;
+   uint8_t ieIdx, ieListCnt;
 
    /*nRCGI*/
    srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
@@ -2311,6 +2504,7 @@ uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
         srvCellInfo->nRCGI.pLMN_Identity.size);
    if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
    {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillServedCellInfo");
       return RFAILED;
    }
    buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
@@ -2319,17 +2513,12 @@ uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
    DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
         srvCellInfo->nRCGI.nRCellIdentity.size);
    if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
-   {
+   {   
+      DU_LOG("\nERROR  --> Memory allocation failed in fillServedCellInfo");
       return RFAILED;
    }
-   for (tmp = 0 ; tmp < srvCellInfo->\
-        nRCGI.nRCellIdentity.size-1 ; tmp++)
-   {
-      srvCellInfo->nRCGI.nRCellIdentity.buf[tmp] = 0;
-   }
-   srvCellInfo->nRCGI.nRCellIdentity.buf[4] = duCfgParam.sib1Params.cellIdentity;
-   srvCellInfo->nRCGI.nRCellIdentity.bits_unused =4;
-
+   
+   fillBitString(&srvCellInfo->nRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
    /*nRPCI*/
    srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
 
@@ -2337,36 +2526,55 @@ uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
    ieListCnt = 1;
    srvCellInfo->servedPLMNs.list.count = ieListCnt;
    srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
-   DU_ALLOC(srvCellInfo->servedPLMNs.list.array,\
-        srvCellInfo->servedPLMNs.list.size);
+   DU_ALLOC(srvCellInfo->servedPLMNs.list.array, srvCellInfo->servedPLMNs.list.size);
    if(srvCellInfo->servedPLMNs.list.array == NULLP)
    {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillServedCellInfo");
       return RFAILED;
    }
    for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
    {
-      DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx],\
-           sizeof(ServedPLMNs_Item_t));
+      DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx], sizeof(ServedPLMNs_Item_t));
       if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
       {
-        return RFAILED;
+         DU_LOG("\nERROR  --> Memory allocation failed in fillServedCellInfo");
+         return RFAILED;
       }
    }
    if(fillServedPlmns(&srvCellInfo->servedPLMNs))
    {
+      DU_LOG("\nERROR  --> Failed to fill Served Plmn info");
       return RFAILED;
    }
 
+#ifndef NR_TDD
    /*nR Mode Info with FDD*/
    srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
-   DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD,\
-         sizeof(FDD_Info_t));
+   DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
    if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
    {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillServedCellInfo");
       return RFAILED;
    }
-   if(fillNrFddInfo(&srvCellInfo->nR_Mode_Info))
+   if(fillNrFddInfo(srvCellInfo->nR_Mode_Info.choice.fDD))
+   {
+       DU_LOG("\nERROR  --> Failed to fill the Nr FDD information");
+      return RFAILED;
+   }
+#else
+   srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_tDD;   
+   DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
+   if(srvCellInfo->nR_Mode_Info.choice.tDD == NULLP)
+   {
+      DU_LOG("\nERROR  --> Memory allocation failed in fillServedCellInfo");
       return RFAILED;
+   }
+   if(fillNrTddInfo(srvCellInfo->nR_Mode_Info.choice.tDD) != ROK)
+   {
+      DU_LOG("\nERROR  --> Failed to fill the Nr TDD information");
+      return RFAILED;
+   }
+#endif
 
    /*Measurement timing Config*/
    srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
@@ -2401,8 +2609,6 @@ uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
 
 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
 {
-   uint8_t ieIdx;
-
    /*pLMN_Identity*/
    modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
    DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
@@ -2421,12 +2627,7 @@ uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
    {
       return RFAILED;
    }
-   for(ieIdx = 0; ieIdx < modifyItem->oldNRCGI.nRCellIdentity.size-1; ieIdx++)
-   {
-      modifyItem->oldNRCGI.nRCellIdentity.buf[ieIdx] = 0;
-   }
-   modifyItem->oldNRCGI.nRCellIdentity.buf[4] = duCfgParam.sib1Params.cellIdentity;
-   modifyItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
+   fillBitString(&modifyItem->oldNRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
 
    if(fillServedCellInfo(&modifyItem->served_Cell_Information))
       return RFAILED;
@@ -2501,7 +2702,6 @@ uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
  *****************************************************************/
 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
 {
-   uint8_t arrIdx;
    Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
    
    deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
@@ -2530,12 +2730,7 @@ uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe
       DU_LOG("ERROR  --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
       return RFAILED;
    }
-   for(arrIdx = 0; arrIdx < deleteItem->oldNRCGI.nRCellIdentity.size-1; arrIdx++)
-   {
-      deleteItem->oldNRCGI.nRCellIdentity.buf[arrIdx] = 0;
-   }
-   deleteItem->oldNRCGI.nRCellIdentity.buf[4] = duCfgParam.sib1Params.cellIdentity;
-   deleteItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
+   fillBitString(&deleteItem->oldNRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
    return ROK;
 } 
 /*******************************************************************
@@ -10465,7 +10660,7 @@ 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, lcId = 0;
+   uint8_t ret, drbIdx = 0, lcId = 0;
    DRBs_ToBeSetup_Item_t *drbItem = NULLP;
    DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
    DRBs_ToBeModified_ItemIEs_t *drbModItem = NULLP;
@@ -10540,6 +10735,7 @@ uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMo
                   DU_LOG("\nERROR  --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetupMod List");
                   break;
                }
+               ueCfgDb->numDrbSetupMod++;
             }
          }
          ueCfgDb->numRlcLcs++;
@@ -10955,7 +11151,7 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
    if(ret == RFAILED)
    {
       /*TODO : Negative case*/
-      // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
+      // BuildAndSendUeContextSetupRsp(cellId,ueId);
       DU_LOG("\nERROR  -->  F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()"); 
    }
    else
@@ -11313,13 +11509,13 @@ uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
  *    Functionality: Constructs the UE Setup Response and sends
  *                   it to the DU through SCTP.
  *
- * @params[in] uint8_t cellId,uint8_t ueIdx
+ * @params[in] uint8_t cellId,uint8_t ueId
  *
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
+uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
 {
    uint8_t   idx, ret, cellIdx, elementCnt;
    uint32_t  gnbCuUeF1apId;   /* gNB-CU UE F1AP Id */
@@ -11330,7 +11526,7 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
    CellGroupConfigRrc_t     *cellGrpCfg = NULLP;
    DuUeCb                   *ueCb = NULLP;
 
-   DU_LOG("\n INFO   -->  F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
+   DU_LOG("\n INFO   -->  F1AP : Building UE Context Setup Response for cellId %d, ueId %d\n", cellId, ueId);
 
    while(true)
    {
@@ -11388,9 +11584,9 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
       }
       /* Fetching Ue Cb Info*/
       GET_CELL_IDX(cellId, cellIdx);
-      gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
-      gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
-      ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
+      gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
+      gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
+      ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
 
       idx = 0;
       /*GNB CU UE F1AP ID*/
@@ -11514,23 +11710,23 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
 *         failure = RFAILED
 *
 * ****************************************************************/
-uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
+uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueId)
 {
    uint8_t cellIdx = 0, actionType = 0; 
 
    GET_CELL_IDX(cellId, cellIdx);
-   actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
+   actionType = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].f1UeDb->actionType;
 
    switch(actionType)
    {
       case UE_CTXT_SETUP:
          {
-            BuildAndSendUeContextSetupRsp(cellId,ueIdx);
+            BuildAndSendUeContextSetupRsp(cellId,ueId);
             break;
          }
       case UE_CTXT_MOD:
          {
-            BuildAndSendUeContextModRsp(cellId, ueIdx);
+            BuildAndSendUeContextModRsp(cellId, ueId);
             break;
          }
       default:
@@ -12290,7 +12486,7 @@ void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
+uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
 {
    uint8_t ret = ROK;
    uint16_t idx =0;
@@ -12342,6 +12538,21 @@ uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
    }
    
    freeAperDecodeF1SetupRsp(f1SetRspMsg);
+
+   duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize = recvBufLen;
+   DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize);
+   if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Memory allocation failed to store the buf of F1setup response");
+      return RFAILED;
+   }
+   memcpy(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, recvBuf, recvBufLen);
+   
+   if(BuildAndSendE2SetupReq() != ROK)
+   {
+      DU_LOG("\nERROR  -->  F1AP : Failed to build and send E2 setup request ");
+      return RFAILED;
+   }
    return ret;
 }
 /*******************************************************************
@@ -12465,7 +12676,7 @@ uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
                               }
 
                               crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
-                              GET_UE_IDX(crnti,ueId);
+                              GET_UE_ID(crnti,ueId);
                               /* Sending Ue Context release request only for maximum supporting UEs */
                               ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
                               if(ret == RFAILED)
@@ -12723,7 +12934,7 @@ uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
    uint8_t drbCnt =0;
    struct DRBs_SetupMod_ItemIEs *drbItemIe;
 
-   drbCnt = 1;
+   drbCnt = ueCfg->numDrbSetupMod;
    drbSet->list.count = drbCnt;
    drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
    DU_ALLOC(drbSet->list.array, drbSet->list.size);
@@ -12850,12 +13061,12 @@ void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
 *    Functionality:
 *         - Creating the ue context modifcation response 
 *
-* @params[in] uint8_t cellId,uint8_t ueIdx
+* @params[in] uint8_t cellId,uint8_t ueId
 * @return ROK     - success
 *         RFAILED - failure
 *
 * ****************************************************************/
-uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
+uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueId)
 {
    uint8_t   ieIdx = 0;
    uint8_t   cellIdx =0;
@@ -12917,9 +13128,9 @@ uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
 
       /* Fetching Ue Cb Info*/
       GET_CELL_IDX(cellId, cellIdx);
-      gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
-      gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
-      ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
+      gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
+      gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
+      ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
 
       ieIdx=0;
       ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
@@ -13314,7 +13525,7 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
                            {
                               drbModifiedCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
                               choice.DRBs_ToBeModified_List;
-                              if(extractDrbListToSetupMod(NULL, NULL, drbModifiedCfg, drbSetupModCfg->list.count,\
+                              if(extractDrbListToSetupMod(NULL, NULL, drbModifiedCfg, drbModifiedCfg->list.count,\
                                  &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, &duUeCb->rlcUeCfg))
                               {
                                  DU_LOG("\nERROR  -->  DU APP : Failed at extractDrbListToSetupMod() for DrbModifiedList");
@@ -13397,7 +13608,7 @@ void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
 *         RFAILED - failure
 *
 * *************************************************************/
-uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
+uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueId)
 {
    bool memAllocFail = false;
    uint8_t ieIdx =0;
@@ -13471,14 +13682,14 @@ uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
       }
       else
       {
-         GET_CRNTI(crnti, ueIdx);
-         if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
+         GET_CRNTI(crnti, ueId);
+         if(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].crnti != crnti)
          {
             DU_LOG("\nERROR  -->  F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
             break;
          }
-         gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
-         gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
+         gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
+         gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
       }
 
       ieIdx=0; 
@@ -13942,7 +14153,6 @@ void F1APMsgHdlr(Buffer *mBuf)
    memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
 
    rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
-   DU_FREE(recvBuf, (Size)recvBufLen);
 
    if(rval.code == RC_FAIL || rval.code == RC_WMORE)
    {
@@ -13966,7 +14176,7 @@ void F1APMsgHdlr(Buffer *mBuf)
                case SuccessfulOutcome__value_PR_F1SetupResponse:
                   {                            
 #ifndef ODU_TEST_STUB
-                     procF1SetupRsp(f1apMsg);
+                     procF1SetupRsp(f1apMsg, recvBufLen, recvBuf);
 #endif
                      break;
                   }
@@ -14035,7 +14245,8 @@ void F1APMsgHdlr(Buffer *mBuf)
          free(f1apMsg);
 
    }/* End of switch(f1apMsg->present) */
-
+   
+   DU_FREE(recvBuf, (Size)recvBufLen);
 } /* End of F1APMsgHdlr */
 
 /**********************************************************************