[Epic-ID: ODUHIGH-516][Task-ID: 526] Implementation of ric service query 82/11782/4
authorpborla <pborla@radisys.com>
Fri, 8 Sep 2023 08:54:57 +0000 (14:24 +0530)
committerpborla <pborla@radisys.com>
Wed, 13 Sep 2023 07:23:08 +0000 (12:53 +0530)
Change-Id: I039a85ec83c91b3f1e0a3f042a5e4d6f883d698a
Signed-off-by: pborla <pborla@radisys.com>
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
Signed-off-by: pborla <pborla@radisys.com>
src/du_app/du_cfg.c
src/du_app/du_cfg.h
src/du_app/du_e2ap_mgr.h
src/du_app/du_e2ap_msg_hdl.c
src/du_app/du_tmr.c
src/ric_stub/ric_e2ap_msg_hdl.c
src/ric_stub/ric_e2ap_msg_hdl.h
src/ric_stub/ric_stub.h

index 7801726..872a426 100644 (file)
@@ -709,7 +709,7 @@ uint8_t readCfg()
          duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.formatType = REPORT_ACTION_FORMAT_TYPE;
          memcpy(duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.name, ric_report_style_name, sizeof(ric_report_style_name));
          
-         for(measurementInfoIdx =0; measurementInfoIdx<NUM_OF_MEASUREMENT_INFO_SUPPORTED; measurementInfoIdx++)
+         for(measurementInfoIdx =0; measurementInfoIdx<NUM_OF_MEASUREMENT_INFO_SUPPORTED(CONFIG_ADD); measurementInfoIdx++)
          {
             measurementInfoLen= strlen(MEASUREMENT_TYPE_NAME[measurementInfoIdx]);
             MeasurementInfoForAction *measurementInfoForAction;
@@ -736,7 +736,8 @@ uint8_t readCfg()
       duCb.e2apDb.ranFunction[ranFuncIdx].ricIndicationHeaderFormat = RIC_INDICATION_HEADER_FORMAT;
       duCb.e2apDb.ranFunction[ranFuncIdx].ricIndicationMessageFormat = RIC_INDICATION_MESSAGE_FORMAT; 
    }
-   memset(duCb.e2apDb.e2TransInfo.onGoingTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
+   memset(duCb.e2apDb.e2TransInfo.e2InitTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
+   memset(duCb.e2apDb.e2TransInfo.ricInitTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
    
    /* Mib Params */
    mib.sysFrmNum = SYS_FRAME_NUM;
index 8046e61..b23d6b8 100644 (file)
 #define DRX_SLOT_OFFSET 0
 #endif
 
+/* In case of initial configuration we are supporting only 2 measurement
+ * information RRU.PrbTotDl and RRU.PrbTotUl.
+ * In case of configuration modification we are supporting 3 measurement
+ * information RRU.PrbTotDl, RRU.PrbTotUl and UECNTX.RelReq */
+#define NUM_OF_MEASUREMENT_INFO_SUPPORTED(_configType) \
+   ((_configType == CONFIG_ADD) ? 2 :3)
+
 typedef enum
 {
    GNBDU,
index 9259ae8..c6a6d67 100644 (file)
@@ -44,7 +44,6 @@
 #define REPORT_STYLE_NAME "E2 Node Measurement"
 #define REPORT_STYLE_TYPE 1
 #define REPORT_ACTION_FORMAT_TYPE 1
-#define NUM_OF_MEASUREMENT_INFO_SUPPORTED 2
 #define MEASUREMENT_TYPE_NAME (char*[]) {"RRU.PrbTotDl", "RRU.PrbTotUl"}
 #define RIC_INDICATION_HEADER_FORMAT 1
 #define RIC_INDICATION_MESSAGE_FORMAT 1
@@ -171,9 +170,9 @@ typedef struct
 
 typedef struct e2Transcation
 {
-   uint8_t     transIdCounter;
-   E2TransInfo onGoingTransaction[MAX_NUM_TRANSACTION];
-   /* Any new parameter for transaction handling can be added here in future */
+   uint8_t     transIdCounter; /* counting the total number of DU initiated transaction */
+   E2TransInfo e2InitTransaction[MAX_NUM_TRANSACTION]; /* Storing DU-initiated transactions information */
+   E2TransInfo ricInitTransaction[MAX_NUM_TRANSACTION]; /* Storing RIC-initiated transactions information */
 }E2Transaction;
 
 typedef struct e2Timer
@@ -393,6 +392,22 @@ typedef struct
    E2TimersInfo     e2TimersInfo;
 }E2apDb;
 
+typedef struct
+{
+   uint16_t   id;
+   uint16_t   revisionCounter;
+}RanFuncInfo;
+
+typedef struct
+{
+   uint8_t addCount;
+   uint8_t addArr[MAX_RAN_FUNCTION];
+   uint8_t modCount;
+   uint8_t modArr[MAX_RAN_FUNCTION];
+   uint8_t delCount;
+   RanFuncInfo delArr[MAX_RAN_FUNCTION];
+}E2TmpRanFunList;
+
 uint8_t assignTransactionId();
 uint8_t ResetE2Request(E2ProcedureDirection dir, E2CauseType type, E2Cause cause);
 uint8_t SendE2APMsg(Region region, Pool pool, char *encBuf, int encBufSize);
index d528b51..748608d 100644 (file)
@@ -558,67 +558,45 @@ uint8_t fillRicEventTriggerStyle(RanFunction *ranFuncDb, struct E2SM_KPM_RANfunc
 
 /*******************************************************************
  *
- * @brief Builds Ran function add list
+ * @brief Builds Ran function item
  *
  * @details
  *
- *    Function : BuildRanFunctionAddList 
+ *    Function : BuildRanFunctionItem  
  *
- *    Functionality: Building RAN addition addition list
+ *    Functionality: Building RAN function item
  *
- * @params[in]  RANfunctions_List_t *RANfunctions_List 
+ * @params[in] 
+ *             RAN function item that has to be filled 
+ *             Stored RAN Function information
  * @return ROK     - success
  *         RFAILED - failure
  *
  ******************************************************************/
 
-uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList)
+uint8_t BuildRanFunctionItem(RANfunction_Item_t *ranFuncItem, RanFunction *ranFuncDb)
 {
-   asn_enc_rval_t encRetVal;
-   RanFunction *ranFuncDb;
+   uint8_t ret =RFAILED;
+   RANfunctionDefinition_t  *ranFunctionDefinition;
    RANfunction_Name_t *ranFuncName;
-   uint8_t ranFuncIdx;
-   RANfunction_ItemIEs_t *ranFuncItemIe;
-   RANfunction_Item_t  *ranFuncItem;
+   asn_enc_rval_t encRetVal;
    E2SM_KPM_RANfunction_Description_t *ranFuncDefinition;
-
-   ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction;
-   ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*);
-   DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size);
-   if(ranFunctionsList->list.array == NULLP)
-   {
-      DU_LOG("\nERROR  --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
-      return RFAILED;
-   }
-
-   for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++)
+   
+   while(true)
    {
-      DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
-      if(ranFunctionsList->list.array[ranFuncIdx] == NULLP)
-      {
-         DU_LOG("\nERROR  --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
-         return RFAILED;
-      }
-
-      ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx];
-      ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item;
-      ranFuncItemIe->criticality = CriticalityE2_ignore;
-      ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
-      ranFuncItem = &ranFuncItemIe->value.choice.RANfunction_Item;
-      ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx];   
       /* RAN function Id*/
       ranFuncItem->ranFunctionID = ranFuncDb->id;
-      
+
       /* RAN Function Revision*/
       ranFuncItem->ranFunctionRevision = ranFuncDb->revisionCounter;
-      
+
       /* RAN function OID*/
       ranFuncItem->ranFunctionOID.size = strlen(ranFuncDb->name.serviceModelOID);
       DU_ALLOC(ranFuncItem->ranFunctionOID.buf, ranFuncItem->ranFunctionOID.size);
       if(!ranFuncItem->ranFunctionOID.buf)
       {
          DU_LOG("\nERROR  --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
-         return RFAILED;
+         break;
       }
       memcpy(ranFuncItem->ranFunctionOID.buf, ranFuncDb->name.serviceModelOID, ranFuncItem->ranFunctionOID.size);
 
@@ -627,54 +605,54 @@ uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList)
       if(!ranFuncDefinition)
       {
          DU_LOG("\nERROR  --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
-         return RFAILED;
+         break;
       }
-      
+
       /* RAN function Name */
       ranFuncName = &ranFuncDefinition->ranFunction_Name;
-      
+
       /* RAN function ShortName */
       ranFuncName->ranFunction_ShortName.size = strlen(ranFuncDb->name.shortName); 
       DU_ALLOC(ranFuncName->ranFunction_ShortName.buf,  ranFuncName->ranFunction_ShortName.size);
       if(!ranFuncName->ranFunction_ShortName.buf)
       {
          DU_LOG("\nERROR  --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
-         return RFAILED;
+         break;
       }
       memcpy(ranFuncName->ranFunction_ShortName.buf, ranFuncDb->name.shortName, strlen(ranFuncDb->name.shortName));
-      
+
       /* RAN function E2SM_OID */
       ranFuncName->ranFunction_E2SM_OID.size = strlen(ranFuncDb->name.serviceModelOID);
       DU_ALLOC(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncName->ranFunction_E2SM_OID.size);
       if(!ranFuncName->ranFunction_E2SM_OID.buf)
       {
          DU_LOG("\nERROR  --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
-         return RFAILED;
+         break;
       }
       memcpy(ranFuncName->ranFunction_E2SM_OID.buf, ranFuncDb->name.serviceModelOID, ranFuncName->ranFunction_E2SM_OID.size);
 
-      /* RAN function Description */
+      /* RAN Function Name Description */
       ranFuncName->ranFunction_Description.size = strlen(ranFuncDb->name.description);
       DU_ALLOC(ranFuncName->ranFunction_Description.buf, ranFuncName->ranFunction_Description.size);
       if(!ranFuncName->ranFunction_Description.buf)
       {
          DU_LOG("\nERROR  --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
-         return RFAILED;
+         break;
       }
       memcpy(ranFuncName->ranFunction_Description.buf, ranFuncDb->name.description, ranFuncName->ranFunction_Description.size);
-      
+
       /* RIC Event Trigger Style List */
       DU_ALLOC(ranFuncDefinition->ric_EventTriggerStyle_List, sizeof(struct E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
       if(!ranFuncDefinition->ric_EventTriggerStyle_List)
       {
          DU_LOG("\nERROR  --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
-         return RFAILED;
+         break;
       }
-      
+
       if(fillRicEventTriggerStyle(ranFuncDb, ranFuncDefinition->ric_EventTriggerStyle_List)!=ROK)
       {
          DU_LOG("\nERROR  --> E2AP: failed to fill ric event trigger style");
-         return RFAILED;
+         break;
       }
 
       /* RIC Report Style List */
@@ -682,12 +660,12 @@ uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList)
       if(!ranFuncDefinition->ric_ReportStyle_List)
       {
          DU_LOG("\nERROR  --> E2AP: Memory allocation failed in function %s at %d",__func__,__LINE__);
-         return RFAILED;
+         break;
       }
       if(fillRicReportStyle(ranFuncDb, ranFuncDefinition->ric_ReportStyle_List) != ROK)
       {
          DU_LOG("\nERROR  --> E2AP: failed to fill ric report style");
-         return RFAILED;
+         break;
       }
 
       /* Encode the F1SetupRequest type as APER */
@@ -711,20 +689,101 @@ uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList)
          {
             printf("%x",encBuf[measIeIdx]);
          }
-
+         ranFunctionDefinition = &ranFuncItem->ranFunctionDefinition; 
+         ranFunctionDefinition->size = encBufSize;
+         DU_ALLOC(ranFunctionDefinition->buf, encBufSize);
+         if(ranFunctionDefinition->buf == NULLP)
+         {
+            DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for RAN function definition buffer");
+            break;
+         }
+         memcpy(ranFunctionDefinition->buf, &encBuf, encBufSize);
+         ret = ROK;
+         break;
       }
-      ranFuncItem->ranFunctionDefinition.size = encBufSize;
-      DU_ALLOC(ranFuncItem->ranFunctionDefinition.buf, encBufSize);
-      if(ranFuncItem->ranFunctionDefinition.buf == NULLP)
+   }
+   freeE2smKpmRanFunctionDefinition(ranFuncDefinition);
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds Ran function add list based on the procedure code
+ *
+ * @details
+ *
+ *    Function : BuildRanFunctionAddList 
+ *
+ *    Functionality: Building RAN addition addition list
+ *       In case of ProcedureCodeE2_id_E2setup we add all the RAN Function list
+ *       which is present in E2 database.
+ *       In the case of other procedures, we just fill the RAN functions whose ID 
+ *       is contained in recvList
+ *
+ * @params[in] 
+ *       RAN Function list
+ *       Procedure code
+ *       Count of ran functions to be added in the list
+ *       Received list of RAN functions
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ******************************************************************/
+
+uint8_t BuildRanFunctionAddList(RANfunctions_List_t *ranFunctionsList, uint8_t procedureCode, uint8_t count, uint8_t *recvList)
+{
+   uint16_t id;
+   RanFunction *ranFuncDb;
+   uint8_t ranFuncIdx;
+   RANfunction_ItemIEs_t *ranFuncItemIe;
+   
+   /* For ProcedureCodeE2_id_E2setup, the number of RAN function list items is
+    * equal to the number of ran function entries stored in the database.
+    * For any other procedure, the RAN function list count is equal
+    * to the count of ran functions obtained from the function's caller */
+
+   if(procedureCode == ProcedureCodeE2_id_E2setup)
+      ranFunctionsList->list.count = duCb.e2apDb.numOfRanFunction;
+   else
+      ranFunctionsList->list.count = count;
+
+   ranFunctionsList->list.size = ranFunctionsList->list.count * sizeof(RANfunction_ItemIEs_t*);
+   DU_ALLOC(ranFunctionsList->list.array, ranFunctionsList->list.size);
+   if(ranFunctionsList->list.array == NULLP)
+   {
+      DU_LOG("\nERROR  --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
+      return RFAILED;
+   }
+
+   for(ranFuncIdx = 0; ranFuncIdx< ranFunctionsList->list.count; ranFuncIdx++)
+   {
+      DU_ALLOC(ranFunctionsList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
+      if(ranFunctionsList->list.array[ranFuncIdx] == NULLP)
       {
-         DU_LOG("\nERROR  -->  F1AP : Memory allocation failed for RAN function definition buffer");
+         DU_LOG("\nERROR  --> E2AP: Memory allocation failed in %s at %d",__func__, __LINE__);
          return RFAILED;
       }
-      memcpy(ranFuncItem->ranFunctionDefinition.buf, &encBuf, encBufSize);
+      if(procedureCode == ProcedureCodeE2_id_E2setup) 
+      {
+         /* Getting all of the RAN function's information from DuCb one by one*/
+         ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncIdx];
+      }
+      else
+      {
+         /* Getting only the RAN function information from DuCb whose Id is
+          * present in the received array */
+         id =recvList[ranFuncIdx];
+         ranFuncDb = &duCb.e2apDb.ranFunction[id-1];
+      }
+      ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx];
+      ranFuncItemIe->id = ProtocolIE_IDE2_id_RANfunction_Item;
+      ranFuncItemIe->criticality = CriticalityE2_ignore;
+      ranFuncItemIe->value.present = RANfunction_ItemIEs__value_PR_RANfunction_Item;
+      BuildRanFunctionItem(&ranFuncItemIe->value.choice.RANfunction_Item, ranFuncDb);
    }
-   freeE2smKpmRanFunctionDefinition(ranFuncDefinition);
    return ROK;
-}
+}   
 
 /*******************************************************************
  *
@@ -977,7 +1036,7 @@ uint8_t BuildAndSendE2SetupReq()
       e2SetupReq->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAdded;
       e2SetupReq->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
       e2SetupReq->protocolIEs.list.array[arrIdx]->value.present = E2setupRequestIEs__value_PR_RANfunctions_List;
-      if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List))!=ROK)
+      if(BuildRanFunctionAddList(&(e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List), ProcedureCodeE2_id_E2setup, 0, NULL)!=ROK)      
       {
          DU_LOG("\nERROR  -->  E2AP : Failed to create RAN Function");
          break;
@@ -1026,8 +1085,8 @@ uint8_t BuildAndSendE2SetupReq()
       break;
    }while(true);
 
-   duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
-   duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
+   duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
+   duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
    
    FreeE2SetupReq(e2apMsg);
    return ret;
@@ -1508,9 +1567,11 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg)
          case ProtocolIE_IDE2_id_TransactionID:
             {
                transId = e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
-               if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
-                     (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
-                  memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
+               if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
+                     (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
+               {
+                  memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+               }
                else
                {
                   DU_LOG("\nERROR  -->  E2AP : Invalid transaction id [%d]", transId);
@@ -2296,8 +2357,8 @@ uint8_t BuildAndSendE2ResetRequest(E2CauseType failureType, E2Cause failureCause
 
       /* In case the message is sent successfully, store the transaction info to
        * be used when response is received */
-      duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId = transId;
-      duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
+      duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId = transId;
+      duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode = e2apMsg->choice.initiatingMessage->procedureCode;
 
       ret = ROK;
       break;
@@ -2380,9 +2441,11 @@ uint8_t procResetResponse(E2AP_PDU_t *e2apMsg)
       {
          case ProtocolIE_IDE2_id_TransactionID:
             transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
-            if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) && \
-                  (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
-              memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
+            if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \
+                  (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
+            {
+               memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+            }
             else
             {
                DU_LOG("\nERROR  -->  E2AP : Invalid transaction id [%d]", transId);
@@ -2473,9 +2536,11 @@ void procE2SetupFailure(E2AP_PDU_t *e2apMsg)
          case ProtocolIE_IDE2_id_TransactionID:
          {
             transId = e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
-            if((duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].transactionId == transId) &&\
-            (duCb.e2apDb.e2TransInfo.onGoingTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
-              memset(&duCb.e2apDb.e2TransInfo.onGoingTransaction[transId], 0, sizeof(E2TransInfo));
+            if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
+                  (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
+            {
+               memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+            }
             else
             {
                DU_LOG("\nERROR  -->  E2AP : Invalid transaction id [%d]", transId);
@@ -2486,9 +2551,9 @@ void procE2SetupFailure(E2AP_PDU_t *e2apMsg)
          case ProtocolIE_IDE2_id_TimeToWaitE2:
             {
                timerValue = covertE2WaitTimerEnumToValue(e2SetupFailure->protocolIEs.list.array[arrIdx]->value.choice.TimeToWaitE2);
-               if((duChkTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR)) == FALSE)
+               if((duChkTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR)) == FALSE)
                {
-                  duStartTmr((PTR)&(duCb.e2apDb), EVENT_E2_SETUP_TMR, timerValue);
+                  duStartTmr((PTR)&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), EVENT_E2_SETUP_TMR, timerValue);
                }
                else
                {
index 3d89d98..28663d8 100644 (file)
@@ -47,7 +47,7 @@ bool duChkTmr(PTR cb, int16_t tmrEvnt)
    {
       case EVENT_E2_SETUP_TMR:
       {
-         if(((E2apDb *)cb)->e2TimersInfo.e2Timers.e2SetupTimer.tmrEvnt == EVENT_E2_SETUP_TMR)
+         if(((CmTimer *)cb)->tmrEvnt == EVENT_E2_SETUP_TMR)
          {
              DU_LOG("\nERROR  -->  DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
              return TRUE;
@@ -75,7 +75,6 @@ bool duChkTmr(PTR cb, int16_t tmrEvnt)
 
 void duStartTmr(PTR cb, int16_t tmrEvnt, uint8_t timerValue)
 {
-   E2apDb *e2apDb;
    CmTmrArg arg;
    arg.wait = 0;
    
@@ -83,10 +82,11 @@ void duStartTmr(PTR cb, int16_t tmrEvnt, uint8_t timerValue)
    {
       case EVENT_E2_SETUP_TMR:
       {
-         e2apDb = ((E2apDb *)cb);
+         CmTimer *e2SetupTimer;
+         e2SetupTimer = ((CmTimer *)cb);
          TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes);
 
-         arg.timers = &e2apDb->e2TimersInfo.e2Timers.e2SetupTimer;
+         arg.timers = e2SetupTimer;
          arg.max = MAX_E2_SETUP_TMR;
          break;
       }
index ec6e0db..6060f9c 100644 (file)
 #include "RIC-ReportStyle-Item.h"
 #include "MeasurementInfo-Action-Item.h"
 
+/*******************************************************************
+ *
+ * @brief Assigns new transaction id to RIC initiated procedure
+ *
+ * @details
+ *
+ *    Function : assignTransactionId
+ *
+ *    Functionality: Assigns new transaction id to a RIC initiated
+ *       procedure
+ *
+ * @params[in] Region region
+ *             Pool pool
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t assignTransactionId(DuDb *duDb)
+{
+   uint8_t currTransId = duDb->ricTransIdCounter;
+
+   /* Update to next valid value */
+   duDb->ricTransIdCounter++;
+   if(duDb->ricTransIdCounter == MAX_NUM_TRANSACTION)
+      duDb->ricTransIdCounter = 0;
+
+   return currTransId;
+}
 
 /*******************************************************************
 *
@@ -165,9 +194,9 @@ void FreeE2SetupRsp(E2AP_PDU_t *e2apMsg)
                      {
                         for(ranFuncIdx=0;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
                         {
-                           if(ranFuncAddedList->list.array[arrIdx])
+                           if(ranFuncAddedList->list.array[ranFuncIdx])
                            {
-                              RIC_FREE(ranFuncAddedList->list.array[arrIdx], sizeof(RANfunction_ItemIEs_t));
+                              RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
                            }
                         }
                         RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size);
@@ -290,19 +319,38 @@ uint8_t BuildE2nodeComponentConfigAdditionAck(E2nodeComponentConfigAdditionAck_L
  *    Function : BuildRanFunctionAddedList
  *
  *    Functionality: Build RAN function added list 
- *
- * @params[in] DuDb *duDb, RANfunctionsID_List_t *ranFuncAddedList 
+ *     ->For ProcedureCodeE2_id_E2setup or ProcedureCodeE2_id_RICserviceQuery  
+ *     we add all the RAN Function list which is present in RIC database.
+ *     ->For any other procedures, we just fill the RAN functions whose ID 
+ *     is present in the recvList
+ *
+ * @params[in] 
+ *    Stored DU databse 
+ *    Count of ran functions to be added in the list 
+ *    Received list of RAN functions
+ *    RAN Function list  
+ *    Procedure Code 
  *
  * @return ROK - success
  *         RFAILED - failure
  * ****************************************************************/
 
-uint8_t BuildRanFunctionAddedList(DuDb *duDb, RANfunctionsID_List_t *ranFuncAddedList)
+uint8_t BuildRanFunctionAddedList(DuDb *duDb, uint8_t count, RanFunction *ranFunToBeAdded, RANfunctionsID_List_t *ranFuncAddedList, uint8_t procedureCode)
 {
    uint8_t ranFuncIdx = 0;
    RANfunctionID_ItemIEs_t *ranFuncAddedItemIe;
-
-   ranFuncAddedList->list.count = duDb->numOfRanFunction;
+   
+   /* For ProcedureCodeE2_id_E2setup and ProcedureCodeE2_id_RICserviceQuery, 
+    * the number of RAN function list items is equal to the number of 
+    * ran function entries stored in the database.
+    * For any other procedure, the RAN function list count is equal
+    * to the count of ran functions obtained from the function's caller */
+
+   if((procedureCode == ProcedureCodeE2_id_RICserviceQuery)||(procedureCode == ProcedureCodeE2_id_E2setup))
+      ranFuncAddedList->list.count = duDb->numOfRanFunction;
+   else
+      ranFuncAddedList->list.count = count;
+   
    ranFuncAddedList->list.size = ranFuncAddedList->list.count*sizeof(RANfunctionID_ItemIEs_t*);
    RIC_ALLOC(ranFuncAddedList->list.array, ranFuncAddedList->list.size);
    if(ranFuncAddedList->list.array)
@@ -319,8 +367,18 @@ uint8_t BuildRanFunctionAddedList(DuDb *duDb, RANfunctionsID_List_t *ranFuncAdde
          ranFuncAddedItemIe->id = ProtocolIE_IDE2_id_RANfunctionID_Item;
          ranFuncAddedItemIe->criticality= CriticalityE2_ignore;
          ranFuncAddedItemIe->value.present = RANfunctionID_ItemIEs__value_PR_RANfunctionID_Item;
-         ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID =duDb->ranFunction[ranFuncIdx].id;
-         ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision=duDb->ranFunction[ranFuncIdx].revisionCounter;
+         if((procedureCode == ProcedureCodeE2_id_RICserviceQuery)||(procedureCode == ProcedureCodeE2_id_E2setup))
+         {
+            /* filling the RAN function information with the help of DuDb */
+            ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = duDb->ranFunction[ranFuncIdx].id;
+            ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= duDb->ranFunction[ranFuncIdx].revisionCounter;
+         }
+         else
+         {
+            /* filling the the RAN function information with the help received list of RAN functions */
+            ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionID = ranFunToBeAdded[ranFuncIdx].id;
+            ranFuncAddedItemIe->value.choice.RANfunctionID_Item.ranFunctionRevision= ranFunToBeAdded[ranFuncIdx].revisionCounter;
+         }
       }
    }
    else
@@ -349,6 +407,7 @@ uint8_t BuildRanFunctionAddedList(DuDb *duDb, RANfunctionsID_List_t *ranFuncAdde
  *         RFAILED - failure
  *
  * ****************************************************************/
+
 uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId)
 {
    E2AP_PDU_t         *e2apMsg = NULL;
@@ -381,7 +440,11 @@ uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId)
                                                          SuccessfulOutcomeE2__value_PR_E2setupResponse;
       e2SetupRsp = &e2apMsg->choice.successfulOutcome->value.choice.E2setupResponse;
 
-      elementCnt = 4;
+      elementCnt = 3;
+      /* Fill Accepted RAN function IE If Ran function information is stored in databse */
+      if(duDb->numOfRanFunction)
+         elementCnt++;
+
       e2SetupRsp->protocolIEs.list.count = elementCnt;
       e2SetupRsp->protocolIEs.list.size  = elementCnt * sizeof(E2setupResponseIEs_t*);
 
@@ -428,15 +491,18 @@ uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId)
          break;
       }
       
-      /* Accepted RAN function Id */
-      idx++;
-      e2SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted;
-      e2SetupRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
-      e2SetupRsp->protocolIEs.list.array[idx]->value.present = E2setupResponseIEs__value_PR_RANfunctionsID_List;
-      if(BuildRanFunctionAddedList(duDb, &e2SetupRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionsID_List)!=ROK)
+      if(duDb->numOfRanFunction)
       {
-         DU_LOG("\nERROR  -->  E2AP : Failed to build Ran function added list");
-         break;         
+         /* Accepted RAN function Id */
+         idx++;
+         e2SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted;
+         e2SetupRsp->protocolIEs.list.array[idx]->criticality = CriticalityE2_reject;
+         e2SetupRsp->protocolIEs.list.array[idx]->value.present = E2setupResponseIEs__value_PR_RANfunctionsID_List;
+         if(BuildRanFunctionAddedList(duDb, 0, NULL, &e2SetupRsp->protocolIEs.list.array[idx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_E2setup)!=ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to build Ran function added list");
+            break;         
+         }
       }
 
       /* E2 Node Component Configuration Addition Acknowledge List*/
@@ -996,7 +1062,7 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t  *e2SetupReq)
                         {
                             *duId =e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.GlobalE2node_ID.choice.gNB->gNB_DU_ID->buf[0];
 
-                            SEARCH_DU_DB(duIdx, duId, duDb); 
+                            SEARCH_DU_DB(duIdx, *duId, duDb); 
                             if(duDb == NULLP)
                             {
                                duDb = &ricCb.duInfo[ricCb.numDu];
@@ -1009,6 +1075,7 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t  *e2SetupReq)
                      }
                      case ProtocolIE_IDE2_id_RANfunctionsAdded:
                      {
+                                                               
                         ranFunctionsList = &e2SetupReq->protocolIEs.list.array[arrIdx]->value.choice.RANfunctions_List;
 
                         if(ranFunctionsList->list.array)
@@ -1017,8 +1084,8 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t  *e2SetupReq)
                            {
                               ranFuncItemIe = (RANfunction_ItemIEs_t *) ranFunctionsList->list.array[ranFuncIdx]; 
                               ranFunItem = &ranFuncItemIe->value.choice.RANfunction_Item;
-                              duDb->ranFunction[duDb->numOfRanFunction].id =  ranFunItem->ranFunctionID; 
-                              duDb->ranFunction[ duDb->numOfRanFunction].revisionCounter =  ranFunItem->ranFunctionRevision; 
+                              duDb->ranFunction[ranFunItem->ranFunctionID-1].id = ranFunItem->ranFunctionID;
+                              duDb->ranFunction[ranFunItem->ranFunctionID-1].revisionCounter = ranFunItem->ranFunctionRevision;
                               duDb->numOfRanFunction++;
                            }
                         }
@@ -1052,6 +1119,7 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t  *e2SetupReq)
             }
         }
    }
+   
    if(BuildAndSendE2SetupRsp(duDb, transId) !=ROK)
    {
       DU_LOG("\nERROR  -->  E2AP : Failed to build and send E2 setup response");
@@ -1434,6 +1502,203 @@ uint8_t ProcE2ResetReq(uint32_t duId, ResetRequestE2_t  *resetReq)
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief deallocate the memory allocated in building the
+ *    Service Query message
+ *
+ * @details
+ *
+ *    Function : FreeRicServiceQuery 
+ *
+ *    Functionality: deallocate the memory allocated in building
+ *    Ric Service Query message
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ *
+ * @return void
+ * ****************************************************************/
+
+void FreeRicServiceQuery(E2AP_PDU_t *e2apMsg)
+{
+   uint8_t arrIdx = 0, ranFuncIdx=0;
+   RANfunctionsID_List_t *ranFuncAddedList;
+   RICserviceQuery_t *ricServiceQuery;
+   
+   if(e2apMsg)
+   {
+      if(e2apMsg->choice.initiatingMessage)
+      {
+         ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery;
+         if(ricServiceQuery->protocolIEs.list.array)
+         {
+            for(arrIdx=0; arrIdx<ricServiceQuery->protocolIEs.list.count; arrIdx++)
+            {
+               if(ricServiceQuery->protocolIEs.list.array[arrIdx])
+               {
+                  switch(ricServiceQuery->protocolIEs.list.array[arrIdx]->id)
+                  {
+                     case ProtocolIE_IDE2_id_RANfunctionsAccepted:
+                        {
+                           ranFuncAddedList= &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List;
+                           if(ranFuncAddedList->list.array)
+                           {
+                              for(ranFuncIdx=0;ranFuncIdx<ranFuncAddedList->list.count; ranFuncIdx++)
+                              {
+                                 RIC_FREE(ranFuncAddedList->list.array[ranFuncIdx], sizeof(RANfunction_ItemIEs_t));
+                              }
+                              RIC_FREE(ranFuncAddedList->list.array, ranFuncAddedList->list.size);
+                           }
+                           break;
+                        }
+                     case RICserviceQuery_IEs__value_PR_TransactionID:
+                        {
+                           break;
+                        }
+                  }
+                  RIC_FREE(ricServiceQuery->protocolIEs.list.array[arrIdx], sizeof(RICserviceQuery_IEs_t)); 
+               }
+            }
+            RIC_FREE(ricServiceQuery->protocolIEs.list.array, ricServiceQuery->protocolIEs.list.size);
+         }
+         RIC_FREE(e2apMsg->choice.initiatingMessage, sizeof(InitiatingMessageE2_t));
+      }
+      RIC_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief build and send the ric service Query 
+ *
+ * @details
+ *
+ *    Function : BuildAndSendRicServiceQuery
+ *
+ * Functionality: build and send the ric service Query 
+ * @return ROK     - success
+ *         RFAILED - Acknowledge
+ *
+ ******************************************************************/
+
+uint8_t BuildAndSendRicServiceQuery(DuDb *duDb)
+{
+   uint8_t arrIdx;
+   uint8_t elementCnt;
+   uint8_t ret = RFAILED;
+   bool  memAllocFailed = false;
+   E2AP_PDU_t     *e2apMsg = NULL;
+   asn_enc_rval_t encRetVal;
+   RICserviceQuery_t *ricServiceQuery;
+
+   DU_LOG("\nINFO   -->  E2AP : Building Ric service Query\n");
+   while(true)
+   {
+      RIC_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+      if(e2apMsg == NULLP)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Memory allocation for E2AP-PDU failed");
+         break;
+      }
+      e2apMsg->present =  E2AP_PDU_PR_initiatingMessage;
+      RIC_ALLOC(e2apMsg->choice.initiatingMessage , sizeof(struct InitiatingMessageE2));
+      if(e2apMsg->choice.initiatingMessage == NULLP)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Memory allocation for E2AP-PDU failed");
+         break;
+      }
+
+      e2apMsg->choice.initiatingMessage->procedureCode = ProcedureCodeE2_id_RICserviceQuery;
+      e2apMsg->choice.initiatingMessage->criticality = CriticalityE2_reject;
+      e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_RICserviceQuery;
+      ricServiceQuery = &e2apMsg->choice.initiatingMessage->value.choice.RICserviceQuery;
+
+      elementCnt = 1;
+      /* Fill Accepted RAN function IE If Ran function information is stored in databse */
+      if(duDb->numOfRanFunction)
+         elementCnt++;
+
+      ricServiceQuery->protocolIEs.list.count = elementCnt;
+      ricServiceQuery->protocolIEs.list.size  = elementCnt * sizeof(RICserviceQuery_IEs_t*);
+
+      RIC_ALLOC(ricServiceQuery->protocolIEs.list.array, ricServiceQuery->protocolIEs.list.size);
+      if(ricServiceQuery->protocolIEs.list.array == NULLP)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Memory allocation for ricServiceQueryIEs failed");
+         break;
+      }
+
+      for(arrIdx=0; arrIdx<elementCnt; arrIdx++)
+      {
+         RIC_ALLOC(ricServiceQuery->protocolIEs.list.array[arrIdx], sizeof(RICserviceQuery_IEs_t));
+         if(ricServiceQuery->protocolIEs.list.array[arrIdx] == NULLP)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Memory allocation for ricServiceQueryIEs failed");
+            memAllocFailed = true;
+            break;
+         }
+      }
+      if(memAllocFailed == true)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Memory allocation for ricServiceQueryIEs failed");
+         break;
+      }
+
+      /* Trans Id */
+      arrIdx = 0;
+      ricServiceQuery->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_TransactionID;
+      ricServiceQuery->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+      ricServiceQuery->protocolIEs.list.array[arrIdx]->value.present = RICserviceQuery_IEs__value_PR_TransactionID;
+      ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.TransactionID  = assignTransactionId(duDb);
+      
+      if(duDb->numOfRanFunction)
+      {
+         /* Accepted RAN function Id */
+         arrIdx++;
+         ricServiceQuery->protocolIEs.list.array[arrIdx]->id = ProtocolIE_IDE2_id_RANfunctionsAccepted;
+         ricServiceQuery->protocolIEs.list.array[arrIdx]->criticality = CriticalityE2_reject;
+         ricServiceQuery->protocolIEs.list.array[arrIdx]->value.present = RICserviceQuery_IEs__value_PR_RANfunctionsID_List;
+         if(BuildRanFunctionAddedList(duDb, 0, NULL, &ricServiceQuery->protocolIEs.list.array[arrIdx]->value.choice.RANfunctionsID_List, ProcedureCodeE2_id_RICserviceQuery)!=ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to build Ran function added list");
+            break;         
+         }
+      }
+      
+      xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
+      memset(encBuf, 0, ENC_BUF_MAX_LEN);
+      encBufSize = 0;
+      encRetVal = aper_encode(&asn_DEF_E2AP_PDU, 0, e2apMsg, PrepFinalEncBuf, encBuf);
+
+      /* Check encode results */
+      if(encRetVal.encoded == ENCODE_FAIL)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Could not encode RIC service Query structure (at %s)\n",\
+               encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+         break;
+      }
+      else
+      {
+         DU_LOG("\nDEBUG  -->  E2AP : Created APER encoded buffer for RIC service Query\n");
+         for(int i=0; i< encBufSize; i++)
+         {
+            DU_LOG("%x",encBuf[i]);
+         }
+      }
+
+      if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duDb->duId) != ROK)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Sending of RIC service  Query failed");
+         break;
+      }
+
+      ret =ROK;
+      break;
+   }
+   FreeRicServiceQuery(e2apMsg);
+   return ret;
+}
+
 /*******************************************************************
 *
 * @brief Handles received E2AP message and sends back response  
index 38c64a0..aba63d2 100644 (file)
@@ -55,7 +55,7 @@ void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf);
 uint8_t BuildAndSendE2SetupRsp(DuDb *duDb, uint8_t transId);
 uint8_t BuildAndSendRicSubscriptionReq(uint32_t duId);
 uint8_t SendE2APMsg(Region region, Pool pool, uint32_t duId);
-
+uint8_t BuildAndSendRicServiceQuery(DuDb *duDb);
 /**********************************************************************
          End of file
 **********************************************************************/
index 7c6362e..0bf9680 100644 (file)
@@ -47,6 +47,7 @@
 #define RIC_APP_MEM_REG 1
 #define RIC_POOL 1
 #define MAX_RAN_FUNCTION 256        /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofRANfunctionID */
+#define MAX_NUM_TRANSACTION 256     /* As per, O-RAN WG3 E2AP v3.0, section 9.2.33 */
 
 /* allocate and zero out a static buffer */
 #define RIC_ALLOC(_datPtr, _size)                                \
@@ -105,6 +106,7 @@ typedef struct
 typedef struct duDb
 {
    uint32_t        duId;
+   uint8_t         ricTransIdCounter;
    uint16_t        numOfRanFunction;
    RanFunction     ranFunction[MAX_RAN_FUNCTION];
    E2NodeComponent e2NodeComponent;
@@ -128,6 +130,16 @@ typedef struct cuGlobalCb
 
 RicGlobalCb ricCb;
 
+typedef struct
+{
+   uint8_t numOfRanFunToBeAdded;
+   RanFunction ranFunToBeAdded[MAX_RAN_FUNCTION];
+   uint8_t numOfRanFunToBeModified;
+   RanFunction ranFunToBeModified[MAX_RAN_FUNCTION];
+   uint8_t numOfRanFunTodeleted;
+   RanFunction ranFunToBeDeleted[MAX_RAN_FUNCTION];
+}RicTmpRanFunList;
+
 void readRicCfg();
 void cuAppInmsgHdlr(Buffer *mBuf);
 void sctpNtfyInd(CmInetSctpNotification *ntfy);