[Epic-ID: ODUHIGH-462][Task-ID: ODUHIGH-472] Implementation of drx timer
[o-du/l2.git] / src / du_app / du_f1ap_msg_hdl.c
index 0f9450c..d9151a4 100644 (file)
@@ -1513,10 +1513,12 @@ uint8_t BuildAndSendF1SetupReq()
       else
       {
          DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for F1SetupRequest\n");
+#ifdef DEBUG_ASN_PRINT
          for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
          {
             printf("%x",encBuf[ieIdx]);
          }
+#endif
          
          duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize = encBufSize;
          DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, encBufSize);
@@ -2448,10 +2450,12 @@ uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
       else
       {
          DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for DUConfigUpdate\n");
+#ifdef DEBUG_ASN_PRINT
          for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
          {
             printf("%x",encBuf[ieIdx]);
          }
+#endif
       }
       /* Sending msg */
       if(sendF1APMsg() != ROK)
@@ -2649,10 +2653,12 @@ uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb  *ueCb, uint8_t lcId, \
       else
       {
         DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
+#ifdef DEBUG_ASN_PRINT
         for(int i=0; i< encBufSize; i++)
         {
            printf("%x",encBuf[i]);
         }
+#endif
       }
 
       /* Sending  msg  */
@@ -8562,10 +8568,12 @@ uint8_t BuildCellGroupConfigRrc(DuUeCb *ueCb, OCTET_STRING_t *duToCuRrcContainer
       else
       {
          DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
+#ifdef DEBUG_ASN_PRINT
          for(int i=0; i< encBufSize; i++)
          {
             printf("%x",encBuf[i]);
          }
+#endif
       }
 
       duToCuRrcContainer->size = encBufSize;
@@ -8851,10 +8859,12 @@ uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti
 
         DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for Initial UL RRC\
               Message transfer\n");
+#ifdef DEBUG_ASN_PRINT
         for(int i=0; i< encBufSize; i++)
         {
            printf("%x",encBuf[i]);
         }
+#endif
       }
       /* Sending  msg  */
       if(sendF1APMsg() != ROK)
@@ -13396,62 +13406,72 @@ void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t   *ueSetReq)
    {
       for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
       {
-        if(ueSetReq->protocolIEs.list.array[ieIdx])
-        {
-           switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
-           {
-              case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
-                 break;
-              case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
-                 break;
-              case ProtocolIE_ID_id_SpCell_ID:
-                 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
-                 break;
-              case ProtocolIE_ID_id_ServCellIndex:
-                 break;
-              case ProtocolIE_ID_id_SpCellULConfigured:
-                 break;
-              case ProtocolIE_ID_id_CUtoDURRCInformation:
+         if(ueSetReq->protocolIEs.list.array[ieIdx])
+         {
+            switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
+            {
+               case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+                  break;
+               case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+                  break;
+               case ProtocolIE_ID_id_SpCell_ID:
+                  freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
+                  break;
+               case ProtocolIE_ID_id_ServCellIndex:
+                  break;
+               case ProtocolIE_ID_id_SpCellULConfigured:
+                  break;
+               case ProtocolIE_ID_id_CUtoDURRCInformation:
 
-                 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
-                 break;
-              case ProtocolIE_ID_id_SCell_ToBeSetup_List:
+                  freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
+                  break;
+               case ProtocolIE_ID_id_SCell_ToBeSetup_List:
 
-                 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
-                 break;
-              case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
+                  freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
+                  break;
+               case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
 
-                 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
-                 break;
-              case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
+                  freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
+                  break;
+               case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
 
-                 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
-                 break;
-              case ProtocolIE_ID_id_RRCContainer:
-                 {
+                  freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
+                  break;
+               case ProtocolIE_ID_id_RRCContainer:
+                  {
 
-                    if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
-                    {
+                     if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
+                     {
 
-                       free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
-                    }
-                    break;
-                 }
-              case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
-                 break;
-              case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
-                 {
-                    if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
-                    {
-                       free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
-                    }
-                    break;
-                 }
-              default:
-                 DU_LOG("\nERROR  -->  F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
-           } 
-           free(ueSetReq->protocolIEs.list.array[ieIdx]);
-        }
+                        free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
+                     }
+                     break;
+                  }
+               case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
+                  break;
+               case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
+                  {
+                     if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
+                     {
+                        free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
+                     }
+                     break;
+                  }
+#ifdef NR_DRX
+               case ProtocolIE_ID_id_DRXCycle:
+                  {
+                     if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleLength)
+                        free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleLength);
+                     if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleTimer)
+                        free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleTimer);
+                     break;
+                  }
+#endif             
+                default:
+                  DU_LOG("\nERROR  -->  F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
+            } 
+            free(ueSetReq->protocolIEs.list.array[ieIdx]);
+         }
       }
       free(ueSetReq->protocolIEs.list.array);
    }
@@ -13830,50 +13850,52 @@ void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
    {
       if(f1apMsg->choice.successfulOutcome)
       {
-        ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
-                   UEContextSetupResponse;
-        if(ueSetRsp->protocolIEs.list.array)
-        {
-           for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
-           {
-              if(ueSetRsp->protocolIEs.list.array[idx])
-              {
-                 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
-                 {
-                    case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
-                       break;
-                    case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
-                       break;
-                    case ProtocolIE_ID_id_DUtoCURRCInformation:
-                       {
-                          CellGroupConfig_t *cellGrpCfg = NULLP;
-                          cellGrpCfg  = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
-                                        DUtoCURRCInformation.cellGroupConfig;
-                          if(cellGrpCfg->buf != NULLP)
-                          {
-                             DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
-                             cellGrpCfg = NULLP;
-                          }
-                          break;
-                       }
-                    case ProtocolIE_ID_id_DRBs_Setup_List:
-                       {
+         ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
+                    UEContextSetupResponse;
+         if(ueSetRsp->protocolIEs.list.array)
+         {
+            for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
+            {
+               if(ueSetRsp->protocolIEs.list.array[idx])
+               {
+                  switch(ueSetRsp->protocolIEs.list.array[idx]->id)
+                  {
+                     case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
+                        break;
+                     case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
+                        break;
+                     case ProtocolIE_ID_id_C_RNTI:
+                        break;
+                     case ProtocolIE_ID_id_DUtoCURRCInformation:
+                        {
+                           CellGroupConfig_t *cellGrpCfg = NULLP;
+                           cellGrpCfg  = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
+                                         DUtoCURRCInformation.cellGroupConfig;
+                           if(cellGrpCfg->buf != NULLP)
+                           {
+                              DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
+                              cellGrpCfg = NULLP;
+                           }
+                           break;
+                        }
+                     case ProtocolIE_ID_id_DRBs_Setup_List:
+                        {
                            freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List); 
                            break;
-                       }
-                    default:
-                       DU_LOG("\nERROR  -->  DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
-                       ueSetRsp->protocolIEs.list.array[idx]->id);
-                       break;
-                 }
-                 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
-                       sizeof(UEContextSetupResponseIEs_t));
-              }
-           }
-           DU_FREE(ueSetRsp->protocolIEs.list.array, \
-                 ueSetRsp->protocolIEs.list.size);
-        }
-        DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
+                        }
+                     default:
+                        DU_LOG("\nERROR  -->  DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
+                              ueSetRsp->protocolIEs.list.array[idx]->id);
+                        break;
+                  }
+                  DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
+                        sizeof(UEContextSetupResponseIEs_t));
+               }
+            }
+            DU_FREE(ueSetRsp->protocolIEs.list.array, \
+                  ueSetRsp->protocolIEs.list.size);
+         }
+         DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
       }
       DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
    }
@@ -13914,10 +13936,12 @@ uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfi
    else
    {
       DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
+#ifdef DEBUG_ASN_PRINT
       for(int i=0; i< encBufSize; i++)
       {
         printf("%x",encBuf[i]);
       }
+#endif
    }
    duToCuCellGrp->size = encBufSize;
    DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
@@ -14246,10 +14270,12 @@ uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
       else
       {
          DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UE Context Setup Response\n");
+#ifdef DEBUG_ASN_PRINT
          for(int i=0; i< encBufSize; i++)
          {
             printf("%x",encBuf[i]);
          }
+#endif
       }
 
       /* Sending  msg  */
@@ -14461,10 +14487,12 @@ uint8_t BuildAndSendF1ResetReq()
       else
       {
         DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for F1Reset\n");
+#ifdef DEBUG_ASN_PRINT
         for(idx=0; idx< encBufSize; idx++)
         {
            printf("%x",encBuf[idx]);
         }
+#endif
       }
 
       if(sendF1APMsg() != ROK)
@@ -14614,10 +14642,12 @@ uint8_t BuildAndSendF1ResetAck()
       else
       {
         DU_LOG("\nDUBUG   -->  F1AP : Created APER encoded buffer for F1ResetAck\n");
+#ifdef DEBUG_ASN_PRINT
         for(int i=0; i< encBufSize; i++)
         {
            printf("%x",encBuf[i]);
         }
+#endif
       }
       /* Sending msg */
       if(sendF1APMsg() != ROK)
@@ -14880,10 +14910,12 @@ uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
       else
       {
         DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
+#ifdef DEBUG_ASN_PRINT
         for(idx=0; idx< encBufSize; idx++)
         {
            printf("%x",encBuf[idx]);
         }
+#endif
       }
 
       /* Sending msg */
@@ -15900,10 +15932,12 @@ uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
       else
       {
          DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UE Context Modification Response\n");
+#ifdef DEBUG_ASN_PRINT
          for(int i=0; i< encBufSize; i++)
          {
             printf("%x",encBuf[i]);
          }
+#endif
       }
 
       /* Sending  msg  */
@@ -15918,6 +15952,8 @@ uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
       break;
    }
    FreeUeContextModResp(f1apMsg);
+   //sleep(5);
+   //BuildAndSendDUConfigUpdate(SERV_CELL_TO_DELETE);
    return ret;
 }
 /*******************************************************************
@@ -16338,6 +16374,13 @@ uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
                }
                break;
             }
+#ifdef NR_DRX
+         case ProtocolIE_ID_id_DRXConfigurationIndicator:
+            {
+               duUeCb->f1UeDb->duUeCfg.drxConfigIndicatorRelease = true;
+               break;
+            }
+#endif
               
       }
    }
@@ -16519,10 +16562,12 @@ uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueId)
       else
       {
          DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
+#ifdef DEBUG_ASN_PRINT
          for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
          {
             printf("%x",encBuf[ieIdx]);
          }
+#endif
       }
 
       /* Sending msg */
@@ -16683,10 +16728,12 @@ uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1
       else
       {
          DU_LOG("\nDEBUG   -->  F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
+#ifdef DEBUG_ASN_PRINT
          for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
          {
             printf("%x",encBuf[ieIdx]);
          }
+#endif
       }
 
       /* Sending msg */
@@ -17160,11 +17207,13 @@ void F1APMsgHdlr(Buffer *mBuf)
       return;
    }
 
+#ifdef DEBUG_ASN_PRINT
    printf("\nDEBUG   -->  F1AP : Received flat buffer to be decoded : ");
    for(i=0; i< recvBufLen; i++)
    {
       printf("%x",recvBuf[i]);
    }
+#endif
 
    /* Decoding flat buffer into F1AP messsage */
    f1apMsg = &f1apasnmsg;