Merge "[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-422]F1AP Paging Message Handling at...
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index 5c907be..da89646 100644 (file)
@@ -11920,9 +11920,9 @@ void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t   *ueSetReq)
 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
 {
    int8_t ueIdx = -1;
-   uint8_t  ret=0, ieIdx=0, ieExtIdx = 0, cellIdx=0, servCellIdx = 0;
+   uint8_t  ret=0, ieIdx=0, ieExtIdx = 0, servCellIdx = 0;
    bool ueCbFound = false, hoInProgress = false;
-   uint16_t nrCellId = 0;
+   uint16_t nrCellId = 0,  cellIdx=0;
    uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
    DuUeCb   *duUeCb = NULL;
    UEContextSetupRequest_t   *ueSetReq = NULL;
@@ -12018,6 +12018,7 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
                   duUeCb->f1UeDb = NULL;
                   duUeCb->gnbCuUeF1apId = gnbCuUeF1apId;
                   duUeCb->gnbDuUeF1apId = gnbDuUeF1apId;
+                  GET_CRNTI(duUeCb->crnti, duUeCb->gnbDuUeF1apId);
                   duUeCb->ueState = UE_HANDIN_IN_PROGRESS;
                }
 
@@ -12566,7 +12567,7 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
 
       ueSetRsp =
          &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
-      elementCnt = 4;
+      elementCnt = 5;
       ueSetRsp->protocolIEs.list.count = elementCnt;
       ueSetRsp->protocolIEs.list.size = \
                                         elementCnt * sizeof(UEContextSetupResponse_t *);
@@ -12626,6 +12627,14 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
                                                             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  = \
@@ -12710,12 +12719,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:
@@ -14239,32 +14256,29 @@ uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
          BuildCellGroupConfigRrc(ueCb, &ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCInformation.cellGroupConfig);
       }
 
-      if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_MOD))
+      if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || ((ueCb->f1UeDb->actionType == UE_CTXT_MOD) && (ueCb->f1UeDb->duUeCfg.numDrbSetupMod)))
       { 
-         if(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)
          {
-            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++)
             {
-               for(tnlIdx = 0; tnlIdx < duCb.numTeId; tnlIdx++)
+               if(duCb.upTnlCfg[tnlIdx]->ueId == ueCb->gnbDuUeF1apId)
                {
-                  if(duCb.upTnlCfg[tnlIdx]->ueId == ueCb->gnbDuUeF1apId)
-                  {
-                     memcpy(&ueCb->f1UeDb->duUeCfg.upTnlInfo[ueCb->f1UeDb->duUeCfg.numDrbSetupMod++], duCb.upTnlCfg[tnlIdx], sizeof(UpTnlCfg));
-                  }
+                  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;
          }
       }
 
@@ -15419,7 +15433,7 @@ void freeAperDecodePagingMsg(Paging_t   *paging)
 uint8_t procPagingMsg(F1AP_PDU_t *f1apMsg) 
 {
    uint8_t ieIdx = 0, cellListIdx = 0;
-   uint16_t cellId = 0, cellIdx = 0;
+   uint16_t cellId = 0;
    Paging_t   *paging = NULLP;
    PagingCell_list_t  *pagingCelllist = NULLP;
    PagingCell_ItemIEs_t *pagingCellItemIes = NULLP;
@@ -15448,7 +15462,7 @@ uint8_t procPagingMsg(F1AP_PDU_t *f1apMsg)
                   case ProtocolIE_ID_id_UEIdentityIndexValue:
                      {
                         bitStringToInt(&paging->protocolIEs.list.array[ieIdx]->value.choice.UEIdentityIndexValue.choice.indexLength10,\
-                                         &tmpPagingParam->ueId);
+                                         &tmpPagingParam->pagUeId);
                         break;
                      }
 
@@ -15504,19 +15518,9 @@ uint8_t procPagingMsg(F1AP_PDU_t *f1apMsg)
                                  pagingCellItemIes = (PagingCell_ItemIEs_t *)pagingCelllist->list.array[cellListIdx];
                                  pagingCellItem = &pagingCellItemIes->value.choice.PagingCell_Item;
                                  bitStringToInt(&pagingCellItem->nRCGI.nRCellIdentity, &cellId);
-                                 GET_CELL_IDX(cellId, cellIdx);
-                                 if(duCb.actvCellLst[cellIdx])
-                                 {
-                                    /* fill Ue Paging information*/
-                                    if(FillPagingInfoInCellCb(duCb.actvCellLst[cellIdx], tmpPagingParam)!= ROK)
-                                    {
-                                       DU_LOG("\nERROR  --> DU APP : CellCb:%d not present to fill UE Paging Information",cellIdx);
-                                       continue;
-                                    }
-                                 }
-                                 else
+                                 if(processPagingMsg(cellId, tmpPagingParam) != ROK)
                                  {
-                                    DU_LOG("\nERROR  --> F1AP : CellId:%d Not in Activelist",cellId);
+                                    DU_LOG("\nERROR  --> DU APP : Paging Processing Failed at CellId:%d",cellId);
                                     continue;
                                  }
                               }