<[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-421]Paging Message: CU_STUB Trigger and...
[o-du/l2.git] / src / cu_stub / cu_stub.c
index c8724d7..1a7fe9c 100644 (file)
 extern StartupConfig g_cfg;
 #endif
 
-/*******************************************************************
- *
- * @brief Fetches pointer to DU Database
- *
- * @details
- *
- *    Function : getDuDb
- *
- *    Functionality:
- *      Searches and returns pointer to DU structure based on DU Id
- *
- * @params[in] DU Id
- * @return Pointer to DU Db
- *
- ******************************************************************/
-DuDb* getDuDb(uint32_t duId)
-{
-   uint8_t duIdx;
-   for(duIdx=0; duIdx < cuCb.numDu; duIdx++)
-   {
-      if(cuCb.duInfo[duIdx].duId == duId)
-         return (&cuCb.duInfo[duIdx]);
-   }
-   return NULLP;
-}
-
-/*******************************************************************
- *
- * @brief Fetches pointer to Cell Cb
- *
- * @details
- *
- *    Function : getCellCb
- *
- *    Functionality:
- *       Searches for a cell within a DU based on NR cell Id
- *       Returns pointer to this cell Cb structure
- *
- * @params[in] Pointer to DU Db
- *             NR Cell ID
- * @return Pointer to cell Cb
- *
- ******************************************************************/
-CuCellCb* getCellCb(DuDb *duDb, uint32_t cellId)
-{
-   uint8_t cellIdx;
-   for(cellIdx=0; cellIdx < duDb->numCells; cellIdx++)
-   {
-      if(duDb->cellCb[cellIdx].nrCellId == cellId)
-         return &(duDb->cellCb[cellIdx]);
-   }
-   return NULLP;
-}
-
 /*******************************************************************
  *
  * @brief Handles SCTP notification 
@@ -204,10 +150,16 @@ void readCuCfg()
    }
    
    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
+   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV4Addr = ipv4_du;
+   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV6Pres = false;
+   
    cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
-
-   cuCb.cuCfgParams.sctpParams.duPort = g_cfg.DU_Port;
-   cuCb.cuCfgParams.sctpParams.cuPort = g_cfg.CU_Port;
+   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuIpAddr.ipV4Addr = ipv4_cu;
+   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuIpAddr.ipV6Pres = false;
+   
+   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duPort = g_cfg.DU_Port;
+   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuPort = g_cfg.CU_Port; 
+   cuCb.cuCfgParams.sctpParams.numDu = 1;
 #else
    cuCb.cuCfgParams.sctpParams.numDu = 0;
    numDu = &cuCb.cuCfgParams.sctpParams.numDu;
@@ -277,14 +229,19 @@ void readCuCfg()
  * ****************************************************************/
 void initiateInterDuHandover(uint32_t sourceDuId, uint32_t targetDuId, uint32_t ueId)
 {
+    uint8_t duIdx = 0;
     DuDb *duDb = NULLP;
     CuUeCb *ueCb = NULLP;
-
-    duDb = getDuDb(sourceDuId);
+   
+    SEARCH_DU_DB(duIdx, sourceDuId, duDb); 
     if(duDb)
        ueCb = &duDb->ueCb[ueId-1];
     if(ueCb)
-       ueCb->state = HANDOVER_IN_PROGRESS;
+    {
+       ueCb->state = UE_HANDOVER_IN_PROGRESS;
+       ueCb->hoInfo.sourceDuId = sourceDuId;
+       ueCb->hoInfo.targetDuId = targetDuId;
+    }
 
     DU_LOG("\nINFO  --> CU_STUB: Inter-DU Handover Started for ueId [%d] from DU ID [%d] to DU ID [%d]", \
           ueId, sourceDuId, targetDuId);
@@ -328,11 +285,11 @@ void *cuConsoleHandler(void *args)
       if(ch == 'd')
       {
 
-      /* Change #if 0 to #if 1 to take input from user */
+         /* Change #if 0 to #if 1 to take input from user */
 #if 0
          DU_LOG("\n EGTP --> : Enter TEID id(1..10) where DL Data to be sent\n");
          scanf("%d",&teId);
-         
+
          if(teId > MAX_TEID || teId < MIN_TEID)
          {
             DU_LOG("\nERROR  -->  EGTP : TEID(%x) OUT Of Range",teId);
@@ -394,6 +351,23 @@ void *cuConsoleHandler(void *args)
 
          initiateInterDuHandover(sourceDuId, targetDuId, ueId);
       }
+      /* Start Idle mode paging when 'p' is received from console input */
+      else if(ch == 'p')
+      {
+         uint64_t sTmsi = 0;
+         uint8_t duId = 0;
+
+         DU_LOG("\nEnter DU ID on which this UE to be pagged");
+         scanf("%d", &duId);
+         DU_LOG("\nEnter 5g-S-TMSI");
+         scanf("%lu", &sTmsi);
+
+         if(BuildAndSendPagingMsg(sTmsi, duId) != ROK)
+         {
+            DU_LOG("\nERROR --> EGTP: Failed to build and send paging message for 5gsTmsi[%lu]\n", sTmsi);   
+         }
+         continue;
+      }
    }
 }
 /**********************************************************************