+
+/*******************************************************************
+*
+* @brief storing slice list in CU database
+*
+* @details
+*
+* Function : buildSliceList
+*
+* Functionality:
+* - storing slice list in CU database
+*
+* @params[in] SliceSupportList_t *sliceSupportList
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t buildSliceList(SliceSupportList_t *sliceSupportList)
+{
+ uint8_t sliceListIdx = 0;
+
+ if(sliceSupportList)
+ {
+ if(sliceSupportList->list.array)
+ {
+ cuCb.numSnssaiSupported = sliceSupportList->list.count;
+ for(sliceListIdx=0; sliceListIdx<sliceSupportList->list.count; sliceListIdx++)
+ {
+ if(sliceSupportList->list.array[sliceListIdx])
+ {
+ CU_ALLOC(cuCb.snssaiList[sliceListIdx], sizeof(Snssai));
+ if(cuCb.snssaiList[sliceListIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> CU_STUB: buildSliceList(): Memory allocation failed");
+ return RFAILED;
+ }
+ if(sliceSupportList->list.array[sliceListIdx]->sNSSAI.sST.buf)
+ {
+ memcpy(&cuCb.snssaiList[sliceListIdx]->sst, sliceSupportList->list.array[sliceListIdx]->\
+ sNSSAI.sST.buf, sliceSupportList->list.array[sliceListIdx]->sNSSAI.sST.size);
+ }
+ if(sliceSupportList->list.array[sliceListIdx]->sNSSAI.sD->size)
+ {
+ memcpy(&cuCb.snssaiList[sliceListIdx]->sd,\
+ sliceSupportList->list.array[sliceListIdx]->sNSSAI.sD->buf,\
+ sliceSupportList->list.array[sliceListIdx]->sNSSAI.sD->size);
+ }
+ }
+ }
+ }
+ }
+ return ROK;
+}
+
+/****************************************************************
+ * @brief Function to process Drb Setup Mod List
+ *
+ * @details
+ *
+ * Function : procDrbSetupModList
+ *
+ * Functionality:
+ * - Function to process DRB Setup Mod List
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t procDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
+{
+ uint8_t arrIdx = 0;
+ uint32_t teId = 0;
+ struct DRBs_SetupMod_ItemIEs *drbItemIe = NULLP;
+
+ if(drbSetupList != NULLP)
+ {
+ for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
+ {
+ drbItemIe = ((struct DRBs_SetupMod_ItemIEs *)drbSetupList->list.array[arrIdx]);
+ if(drbItemIe->value.present == DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item)
+ {
+ /* extracting teId */
+ teId = extractTeId(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
+ if(teId > 0)
+ {
+ if(addDrbTunnels(teId)== ROK)
+ {
+ DU_LOG("\nDEBUG --> EGTP: Tunnel Added for TeId %d", teId);
+ }
+ }
+ else
+ return RFAILED;
+ }
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+*
+* @brief processing of GNB_DU_Served_Cells Plmn list information
+*
+* @details
+*
+* Function : procServedCellPlmnList
+*
+* Functionality:
+* - processing of GNB_DU_Served_Cells Plmn list information for storing
+* SNSSAI list
+*
+* @params[in] F1AP_PDU_t *f1apMsg
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t procServedCellPlmnList(ServedPLMNs_List_t *srvPlmn)
+{
+ uint8_t srvPlmnIdx=0, ieExtensionsLstIdx=0;
+ ProtocolExtensionContainer_4624P3_t **ieExtend;
+
+ if(srvPlmn->list.array)
+ {
+ for(srvPlmnIdx=0; srvPlmnIdx<srvPlmn->list.count; srvPlmnIdx++)
+ {
+ if(srvPlmn->list.array[srvPlmnIdx])
+ {
+ ieExtend = &srvPlmn->list.array[srvPlmnIdx]->iE_Extensions;
+ if(*ieExtend)
+ {
+ if((*ieExtend)->list.array)
+ {
+ for(ieExtensionsLstIdx = 0; ieExtensionsLstIdx<(*ieExtend)->list.count; ieExtensionsLstIdx++)
+ {
+ if((*ieExtend)->list.array[ieExtensionsLstIdx])
+ {
+ switch((*ieExtend)->list.array[ieExtensionsLstIdx]->id )
+ {
+ case ProtocolIE_ID_id_TAISliceSupportList:
+ {
+ if(buildSliceList(&(*ieExtend)->list.array[ieExtensionsLstIdx]->\
+ extensionValue.choice.SliceSupportList) != ROK)
+ {
+ DU_LOG("\nERROR --> CU_STUB: procServedCellPlmnList(): Failed to build slice List");
+ return RFAILED;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return ROK;
+}
+
+/****************************************************************
+ * @brief Function to process Ue Context Modification Response
+ *
+ * @details
+ *
+ * Function : procUeContextModificationResponse
+ *
+ * Functionality:
+ * - Function to process Ue Context Modification Response
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t procUeContextModificationResponse(F1AP_PDU_t *f1apMsg)
+{
+ uint8_t idx, duUeF1apId;
+ UEContextModificationResponse_t *ueCtxtModRsp = NULLP;
+ ueCtxtModRsp = &f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
+
+ for(idx=0; idx < ueCtxtModRsp->protocolIEs.list.count; idx++)
+ {
+ switch(ueCtxtModRsp->protocolIEs.list.array[idx]->id)
+ {
+ case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+ {
+ duUeF1apId = ueCtxtModRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
+ break;
+ }
+ case ProtocolIE_ID_id_DRBs_SetupMod_List:
+ {
+ /* Adding Tunnels for successful DRB */
+ procDrbSetupModList(&ueCtxtModRsp->protocolIEs.list.array[idx]->value.choice.DRBs_SetupMod_List);
+ break;
+
+ }
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+*
+* @brief processing of F1 setup request
+*
+* @details
+*
+* Function : procF1SetupReq
+*
+* Functionality:
+* - processing of F1 setup request
+*
+* @params[in] F1AP_PDU_t *f1apMsg
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+void procF1SetupReq(uint32_t *destDuId, F1AP_PDU_t *f1apMsg)
+{
+ uint8_t ieIdx = 0, plmnidx=0, duIdx = 0, ret=ROK, cellIdx = 0;
+ uint32_t duId, cellId;
+ DuDb *duDb = NULLP;
+ CuCellCb *cellCb = NULLP;
+ BIT_STRING_t nrcellIdentity;
+ F1SetupRequest_t *f1SetupReq = NULLP;
+ GNB_DU_Served_Cells_Item_t *srvCellItem = NULLP;
+ GNB_DU_Served_Cells_List_t *duServedCell = NULLP;
+
+ f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
+ for(ieIdx=0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
+ {
+ switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
+ {
+ case ProtocolIE_ID_id_gNB_DU_ID:
+ {
+ duId = f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0];
+ duDb = getDuDb(duId);
+ if(duDb == NULLP)
+ {
+ duDb = &cuCb.duInfo[cuCb.numDu];
+ memset(duDb, 0, sizeof(DuDb));
+ duDb->duId = duId;
+ cuCb.numDu++;
+ *destDuId = duId;
+ }
+ else
+ return;
+ break;
+ }
+ case ProtocolIE_ID_id_gNB_DU_Name:
+ {
+ strcpy((char *)duDb->duName, (char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf);
+ break;
+ }
+ case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
+ {
+ duServedCell = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
+ if(duServedCell->list.array)
+ {
+ for(plmnidx=0; plmnidx<duServedCell->list.count; plmnidx++)
+ {
+ if(duServedCell->list.array[plmnidx])
+ {
+ switch(duServedCell->list.array[plmnidx]->id)
+ {
+ case ProtocolIE_ID_id_GNB_DU_Served_Cells_Item:
+ {
+ srvCellItem = &duServedCell->list.array[plmnidx]->value.choice.GNB_DU_Served_Cells_Item;
+ ret = procServedCellPlmnList(&srvCellItem->served_Cell_Information.servedPLMNs);
+ memcpy(&nrcellIdentity, &srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity, sizeof(BIT_STRING_t));
+
+ cellId = nrcellIdentity.buf[4] >> nrcellIdentity.bits_unused;
+ cellCb = getCellCb(duDb, cellId);
+ if(cellCb == NULLP)
+ {
+ cellCb = &duDb->cellCb[duDb->numCells];
+ memset(cellCb, 0, sizeof(CuCellCb));
+ cellCb->nrCellId = cellId;
+ duDb->numCells++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if(ret == ROK)
+ {
+ BuildAndSendF1SetupRsp(duId, &nrcellIdentity);
+ }
+ else
+ {
+ DU_LOG("\nERROR --> CU_STUB: procF1SetupReq(): Failed to process F1 setup request");
+ }
+}
+