+
+/*******************************************************************
+ *
+ * @brief Initiates inter DU handover
+ *
+ * @details
+ *
+ * Function : initiateInterDuHandover
+ *
+ * Functionality: Initiates the first procedure of inter-DU
+ * handover i.eG GNB-DU configuration query to source DU
+ *
+ * @params[in] Source DU Id
+ * Target DU Id
+ * UE Id to be handed off
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void initiateInterDuHandover(uint32_t sourceDuId, uint32_t targetDuId, uint32_t ueId)
+{
+ uint8_t duIdx = 0;
+ DuDb *duDb = NULLP;
+ CuUeCb *ueCb = NULLP;
+
+ SEARCH_DU_DB(duIdx, sourceDuId, duDb);
+ if(duDb)
+ ueCb = &duDb->ueCb[ueId-1];
+ if(ueCb)
+ {
+ 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);
+ BuildAndSendUeContextModificationReq(sourceDuId, ueCb, QUERY_CONFIG);
+}
+
+/*******************************************************************
+ *
+ * @brief Handles Console input
+ *
+ * @details
+ *
+ * Function : cuConsoleHandler
+ *
+ * Functionality: Handles Console input
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void *cuConsoleHandler(void *args)
+{
+ char ch;
+ uint32_t teId = 0;
+ uint32_t duId;
+ uint8_t ret = ROK;
+ uint8_t cnt = 0;
+ EgtpTeIdCb *teidCb = NULLP;
+
+ while(true)
+ {
+ ch = getchar();
+ /* Send DL user data to CU when user enters 'd' on console */
+ if(ch == 'd')
+ {
+
+ /* 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);
+ printf("\n");
+ continue;
+ }
+ /* Start Pumping data from CU to DU */
+ DU_LOG("\nDEBUG --> EGTP: Sending DL User Data(teId:%d)\n",teId);
+
+ cnt =0;
+ while(cnt < NUM_DL_PACKETS)
+ {
+ ret = cuEgtpDatReq(teId);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> EGTP: Issue with teid=%d\n",teId);
+ break;
+ }
+ cnt++;
+ }
+#else
+
+ /* This variable is taken for sending specific number of downlink data packet.
+ * Presently the code is supporting total 4500 data packets trasfer for 3 UEs only with sleep(1).
+ * If you wants to pump data for 3 UE change the following macro values
+ * NUM_TUNNEL_TO_PUMP_DATA = 9, NUM_DL_PACKETS = 1.
+ * totalDataPacket = totalNumOfTestFlow * NUM_TUNNEL_TO_PUMP_DATA * NUM_DL_PACKETS
+ * totalDataPacket = [500*9*1] */
+ int32_t totalNumOfTestFlow = 2;
+
+ while(totalNumOfTestFlow)
+ {
+ for(duId = 1; duId<=MAX_DU_SUPPORTED; duId++)
+ {
+ for(teId = 1; teId <= NUM_TUNNEL_TO_PUMP_DATA; teId++)
+ {
+ teidCb = NULLP;
+ cmHashListFind(&(egtpCb.dstCb[duId-1].teIdLst), (uint8_t *)&(teId), sizeof(uint32_t), 0, (PTR *)&teidCb);
+ if(teidCb)
+ {
+ cnt =0;
+ DU_LOG("\nDEBUG --> EGTP: Sending DL User Data(duId %d, teId:%d)\n", duId, teId);
+ while(cnt < NUM_DL_PACKETS)
+ {
+ ret = cuEgtpDatReq(duId, teId);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> EGTP: Issue with teid=%d\n",teId);
+ break;
+ }
+ /* TODO : sleep(1) will be removed later once we will be able to
+ * support the continuous data pack transfer */
+ sleep(1);
+ cnt++;
+ }
+ }
+ else
+ {
+ DU_LOG("\nDEBUG --> EGTP: TunnelId Not Found for (duId %d, teId:%d)\n", duId, teId);
+ }
+ }
+ }
+ totalNumOfTestFlow--;
+ }
+#endif
+ continue;
+ }
+
+ /* Start Handover procedure towards DU when 'h' is received from console input */
+ else if(ch == 'h')
+ {
+ uint32_t sourceDuId, targetDuId, ueId;
+
+ DU_LOG("\nEnter Source DU ID for Inter-DU Handover");
+ scanf("%d", &sourceDuId);
+ DU_LOG("\nEnter Target DU ID for Inter-DU Handover");
+ scanf("%d", &targetDuId);
+ DU_LOG("\nEnter DU UE F1AP ID to be handed over");
+ scanf("%d", &ueId);
+
+ 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;
+ }
+ }
+}