[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-533] Implementation of E2 Node Connection... 98/11998/3
authorpborla <pborla@radisys.com>
Thu, 2 Nov 2023 13:34:55 +0000 (19:04 +0530)
committerpborla <pborla@radisys.com>
Fri, 3 Nov 2023 09:58:27 +0000 (15:28 +0530)
Change-Id: Iaec321f43410665453384d32cadf00d180e5faa5
Signed-off-by: pborla <pborla@radisys.com>
src/du_app/du_e2ap_mgr.h
src/du_app/du_e2ap_msg_hdl.c
src/ric_stub/ric_e2ap_msg_hdl.c
src/ric_stub/ric_e2ap_msg_hdl.h
src/ric_stub/ric_stub.h

index df06ada..e2ef117 100644 (file)
@@ -495,6 +495,20 @@ typedef struct
    E2TimersInfo     e2TimersInfo;
 }E2apDb;
 
+typedef struct e2ConnectionItem
+{
+   uint32_t    ipV4Addr;
+   AssocUsage  usage;
+}E2ConnectionItem;
+
+typedef struct e2ConnectionList
+{
+   uint8_t numOfE2ConnectionSetup;
+   E2ConnectionItem setupE2Connection[MAX_TNL_ASSOCIATION];
+   uint8_t numOfE2ConnectionFailedToSetup;
+   E2ConnectionItem failedToSetupE2Connection[MAX_TNL_ASSOCIATION];
+}E2ConnectionList;
+
 uint8_t assignTransactionId();
 ActionInfo *fetchActionInfoFromActionId(uint8_t actionId, RicSubscription *ricSubscriptionInfo);
 RicSubscription *fetchSubsInfoFromRicReqId(RicRequestId ricReqId, RanFunction *ranFuncDb, CmLList **ricSubscriptionNode);
index a1c7d8c..388e2fd 100644 (file)
@@ -8403,6 +8403,434 @@ uint8_t BuildAndSendE2ConnectionUpdateFailure(uint16_t transId, E2FailureCause f
    return ret;
 }
 
+/*******************************************************************
+ *
+ * @brief fill E2 connection update item
+ *
+ * @details
+ *
+ *    Function : fillE2connectionUpdateItem
+ *
+ *    Functionality: fill E2 connection update item
+ *
+ * @params[in]
+ *    E2connectionUpdate Item to be filled
+ *    Protocol Id
+ *    IP Address
+ *    Usage
+ * @return ROK - success
+ *         RFAILED - failure
+ * ****************************************************************/
+
+uint8_t fillE2connectionUpdateItem(PTR connectionInfo, uint8_t protocolId, uint32_t ipAddress, AssocUsage usage)
+{
+   CauseE2_t *cause=NULLP;
+   TNLusage_t  *tnlUsage=NULLP;
+   E2FailureCause failureCause;
+   TNLinformation_t *tnlInformation = NULLP;
+   E2connectionUpdate_Item_t *connectionModifyItem=NULLP;
+   E2connectionSetupFailed_Item_t *connectionRemoveITem=NULLP;
+
+   switch(protocolId)
+   {
+      case ProtocolIE_IDE2_id_E2connectionUpdate_Item:
+      {
+         connectionModifyItem = (E2connectionUpdate_Item_t*)connectionInfo;
+         tnlInformation = &connectionModifyItem->tnlInformation;
+         tnlUsage = &connectionModifyItem->tnlUsage;
+         break;
+      }
+
+      case ProtocolIE_IDE2_id_E2connectionSetupFailed_Item:
+      {
+         connectionRemoveITem = (E2connectionSetupFailed_Item_t*)connectionInfo;
+         tnlInformation= &connectionRemoveITem->tnlInformation;
+         cause = &connectionRemoveITem->cause;
+         break;
+      }
+      default:
+         return RFAILED;
+   }
+
+   tnlInformation->tnlAddress.size =  4*sizeof(uint8_t);
+   DU_ALLOC(tnlInformation->tnlAddress.buf, tnlInformation->tnlAddress.size);
+   if(!tnlInformation->tnlAddress.buf)
+   {
+      DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+      return RFAILED;
+   }
+
+   tnlInformation->tnlAddress.buf[3] =  ipAddress & 0xFF;
+   tnlInformation->tnlAddress.buf[2] = (ipAddress>> 8) & 0xFF;
+   tnlInformation->tnlAddress.buf[1] = (ipAddress>> 16) & 0xFF;
+   tnlInformation->tnlAddress.buf[0] = (ipAddress>> 24) & 0xFF;
+   tnlInformation->tnlAddress.bits_unused = 0;
+
+   switch(protocolId)
+   {
+      case ProtocolIE_IDE2_id_E2connectionUpdate_Item:
+         {
+            *tnlUsage = usage;
+            break;
+         }
+      case ProtocolIE_IDE2_id_E2connectionSetupFailed_Item:
+         {
+            failureCause.causeType = E2_TRANSPORT;
+            failureCause.cause = E2_TRANSPORT_CAUSE_UNSPECIFIED;
+            fillE2Cause(cause, failureCause);
+            break;
+         }
+      default:
+         return RFAILED;
+   }
+   return ROK;
+}
+
+
+/*******************************************************************
+ *
+ * @brief Build E2 connection modification list
+ *
+ * @details
+ *
+ *    Function :BuildE2ConnectionUpdateList 
+ *
+ *    Functionality: Build E2 connection modification list
+ *
+ * @params[in]
+ *    E2 connection update list to be filled
+ *    Count of E2 connection to be added in the list    
+ *    Received list of E2 connection
+ *
+ * @return ROK - success
+ *         RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2ConnectionUpdateList(E2connectionUpdate_List_t *connectionSetupList, uint8_t count, E2ConnectionItem *tmpConnectionList)
+{
+   uint8_t arrIdx = 0;
+   E2connectionUpdate_ItemIEs_t *connectionSetupItem=NULLP;
+
+   connectionSetupList->list.count = count;
+
+   connectionSetupList->list.size = connectionSetupList->list.count*sizeof(E2connectionUpdate_ItemIEs_t*);
+   DU_ALLOC(connectionSetupList->list.array, connectionSetupList->list.size);
+   if(connectionSetupList->list.array)
+   {
+      for(arrIdx = 0; arrIdx< connectionSetupList->list.count; arrIdx++)
+      {
+         DU_ALLOC(connectionSetupList->list.array[arrIdx], sizeof(E2connectionUpdate_ItemIEs_t));
+         if(connectionSetupList->list.array[arrIdx] == NULLP)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+            return RFAILED;
+         }
+         connectionSetupItem = (E2connectionUpdate_ItemIEs_t*)connectionSetupList->list.array[arrIdx];
+         connectionSetupItem->id = ProtocolIE_IDE2_id_E2connectionUpdate_Item;
+         connectionSetupItem->criticality= CriticalityE2_ignore;
+         connectionSetupItem->value.present = E2connectionUpdate_ItemIEs__value_PR_E2connectionUpdate_Item;
+         if(fillE2connectionUpdateItem((PTR)&connectionSetupItem->value.choice.E2connectionUpdate_Item, ProtocolIE_IDE2_id_E2connectionUpdate_Item,\
+          tmpConnectionList[arrIdx].ipV4Addr, tmpConnectionList[arrIdx].usage) != ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to fill E2 connection update item");
+            return RFAILED;
+         }
+
+      }
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+      return RFAILED;
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Build E2 connection setup failed list
+ *
+ * @details
+ *
+ *    Function : BuildE2ConnectionSetupFailedList
+ *
+ *    Functionality: Build E2 connection setup failed list
+ *
+ * @params[in]
+ *    E2 connection setup failed list to be filled
+ *    Count of E2 connection to be added in the list    
+ *    Received list of E2 connection
+ *
+ * @return ROK - success
+ *         RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2ConnectionSetupFailedList(E2connectionSetupFailed_List_t *setupFailedList, uint8_t count, E2ConnectionItem *tmpConnectionList)
+{
+   uint8_t arrIdx = 0;
+   E2connectionSetupFailed_ItemIEs_t *setupFailedItem=NULLP;
+
+   setupFailedList->list.count = 1;
+
+   setupFailedList->list.size = setupFailedList->list.count*sizeof(E2connectionSetupFailed_ItemIEs_t *);
+   DU_ALLOC(setupFailedList->list.array, setupFailedList->list.size);
+   if(setupFailedList->list.array)
+   {
+      for(arrIdx = 0; arrIdx< setupFailedList->list.count; arrIdx++)
+      {
+         DU_ALLOC(setupFailedList->list.array[arrIdx], sizeof(E2connectionSetupFailed_ItemIEs_t));
+         if(setupFailedList->list.array[arrIdx] == NULLP)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+            return RFAILED;
+         }
+         setupFailedItem = (E2connectionSetupFailed_ItemIEs_t*)setupFailedList->list.array[arrIdx];
+         setupFailedItem->id = ProtocolIE_IDE2_id_E2connectionSetupFailed_Item;
+         setupFailedItem->criticality= CriticalityE2_ignore;
+         setupFailedItem->value.present = E2connectionSetupFailed_ItemIEs__value_PR_E2connectionSetupFailed_Item;
+         if(fillE2connectionUpdateItem((PTR)&setupFailedItem->value.choice.E2connectionSetupFailed_Item, ProtocolIE_IDE2_id_E2connectionSetupFailed_Item,\
+          tmpConnectionList[arrIdx].ipV4Addr, tmpConnectionList[arrIdx].usage) != ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to fill E2 connection failed to update item");
+            return RFAILED;
+         }
+
+      }
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+      return RFAILED;
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Deallocate the memory allocated for E2 Connection
+ * Update ack msg 
+ *
+ * @details
+ *
+ *    Function :FreeE2ConnectionUpdateAcknowledge 
+ *
+ *    Functionality:
+ *       - freeing the memory allocated for E2 Connection
+ * Update ack msg
+ *
+ * @params[in] E2AP_PDU_t *e2apMsg
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+void FreeE2ConnectionUpdateAcknowledge(E2AP_PDU_t *e2apMsg)
+{
+   uint8_t ieIdx =0, arrIdx=0;
+   E2connectionUpdateAcknowledge_t *connectionUpdate = NULLP;
+   E2connectionUpdate_List_t *connectionSetupList = NULLP;
+   E2connectionSetupFailed_List_t *setupFailedList = NULLP;
+
+   if(e2apMsg != NULLP)
+   {
+      if(e2apMsg->choice.successfulOutcome != NULLP)
+      {
+         connectionUpdate = &e2apMsg->choice.successfulOutcome->value.choice.E2connectionUpdateAcknowledge;
+         if(connectionUpdate->protocolIEs.list.array)
+         {
+            for(ieIdx = 0; ieIdx < connectionUpdate->protocolIEs.list.count; ieIdx++)
+            {
+               if(connectionUpdate->protocolIEs.list.array[ieIdx])
+               {
+                  switch(connectionUpdate->protocolIEs.list.array[ieIdx]->id)
+                  {
+                     case ProtocolIE_IDE2_id_TransactionID:
+                        break;
+
+                     case ProtocolIE_IDE2_id_E2connectionSetup:
+                        {
+                           connectionSetupList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List;
+                           if(connectionSetupList->list.array)
+                           {
+                              for(arrIdx = 0; arrIdx < connectionSetupList->list.count; arrIdx++)
+                              {
+                                 DU_FREE(connectionSetupList->list.array[arrIdx], sizeof(E2connectionUpdate_ItemIEs_t));
+                              }
+                              DU_FREE(connectionSetupList->list.array, connectionSetupList->list.size);
+                           }
+                           break;
+                        }
+
+                     case ProtocolIE_IDE2_id_E2connectionSetupFailed:
+                        {
+                           setupFailedList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionSetupFailed_List;
+                           if(setupFailedList->list.array)
+                           {
+                              for(arrIdx = 0; arrIdx < setupFailedList->list.count; arrIdx++)
+                              {
+                                 DU_FREE(setupFailedList->list.array[arrIdx], sizeof(E2connectionSetupFailed_ItemIEs_t));
+                              }
+                              DU_FREE(setupFailedList->list.array, setupFailedList->list.size);
+                           }
+                           break;
+                        }
+                  }
+                  DU_FREE(connectionUpdate->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdateAck_IEs_t));
+               }
+            }
+            DU_FREE(connectionUpdate->protocolIEs.list.array, connectionUpdate->protocolIEs.list.size);
+         }
+         DU_FREE(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+      }
+      DU_FREE(e2apMsg, sizeof(E2AP_PDU_t));
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief Buld and send the E2 Connection Update Acknowledge msg
+ *
+ * @details
+ *
+ *    Function : BuildAndSendE2ConnectionUpdateAcknowledge
+ *
+ *    Functionality:
+ *         - Buld and send the E2 Connection Update Acknowledge Message
+ * @params[in] 
+ *    Trans Id 
+ *    List of E2 connection needs to fill in IE 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t BuildAndSendE2ConnectionUpdateAcknowledge(uint16_t transId,  E2ConnectionList connectionInfoList)
+{
+   uint8_t           ieIdx = 0, elementCnt = 0;
+   uint8_t           ret = RFAILED;
+   E2AP_PDU_t        *e2apMsg = NULLP;
+   asn_enc_rval_t    encRetVal;       
+   E2connectionUpdateAcknowledge_t *e2ConnectionUpdateAcknowledge=NULLP;
+
+   DU_LOG("\nINFO   -->  E2AP : Building E2 Connection Update Acknowledge Message\n");
+   do
+   {
+      DU_ALLOC(e2apMsg, sizeof(E2AP_PDU_t));
+      if(e2apMsg == NULLP)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+         break;
+      }
+      e2apMsg->present = E2AP_PDU_PR_successfulOutcome;
+
+      DU_ALLOC(e2apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcomeE2_t));
+      if(e2apMsg->choice.successfulOutcome == NULLP)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+         break;
+      }
+
+      e2apMsg->choice.successfulOutcome->procedureCode = ProcedureCodeE2_id_E2connectionUpdate;
+      e2apMsg->choice.successfulOutcome->criticality = CriticalityE2_reject;
+      e2apMsg->choice.successfulOutcome->value.present = SuccessfulOutcomeE2__value_PR_E2connectionUpdateAcknowledge;
+      e2ConnectionUpdateAcknowledge = &e2apMsg->choice.successfulOutcome->value.choice.E2connectionUpdateAcknowledge;
+
+      elementCnt = 1;
+      if(connectionInfoList.numOfE2ConnectionSetup)
+         elementCnt++;
+      if(connectionInfoList.numOfE2ConnectionFailedToSetup)
+         elementCnt++;
+
+      e2ConnectionUpdateAcknowledge->protocolIEs.list.count = elementCnt;
+      e2ConnectionUpdateAcknowledge->protocolIEs.list.size = elementCnt * sizeof(E2connectionUpdateAck_IEs_t*);
+      DU_ALLOC(e2ConnectionUpdateAcknowledge->protocolIEs.list.array, e2ConnectionUpdateAcknowledge->protocolIEs.list.size);
+      if(!e2ConnectionUpdateAcknowledge->protocolIEs.list.array)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+         break;
+      }
+
+      for(ieIdx=0; ieIdx < elementCnt; ieIdx++)
+      {
+         DU_ALLOC(e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdateAck_IEs_t));
+         if(!e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx])
+         {
+            DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+            break;
+         }
+      }
+      if(ieIdx < elementCnt)
+         break;
+
+      ieIdx = 0;
+      e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->id =  ProtocolIE_IDE2_id_TransactionID;
+      e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+      e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateAck_IEs__value_PR_TransactionID;
+      e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = transId;
+
+      if(connectionInfoList.numOfE2ConnectionSetup)
+      {
+         ieIdx++;
+         e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->id =  ProtocolIE_IDE2_id_E2connectionSetup;
+         e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+         e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateAck_IEs__value_PR_E2connectionUpdate_List;
+         if(BuildE2ConnectionUpdateList(&e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List, \
+                  connectionInfoList.numOfE2ConnectionSetup, connectionInfoList.setupE2Connection) != ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to send E2 Connection setup list");
+            break;
+         }
+      }
+      
+      if(connectionInfoList.numOfE2ConnectionFailedToSetup)
+      {
+         ieIdx++;
+         e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->id =  ProtocolIE_IDE2_id_E2connectionSetupFailed;
+         e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+         e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdateAck_IEs__value_PR_E2connectionSetupFailed_List;
+         if(BuildE2ConnectionSetupFailedList(&e2ConnectionUpdateAcknowledge->protocolIEs.list.array[ieIdx]->value.choice.E2connectionSetupFailed_List, \
+               connectionInfoList.numOfE2ConnectionFailedToSetup, connectionInfoList.failedToSetupE2Connection) != ROK) 
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to send E2 Connection failed to setup 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);
+      if(encRetVal.encoded == ENCODE_FAIL)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Could not encode E2 connection update acknowledge failure structure (at %s)\n",\
+               encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+         break;
+      }
+      else
+      {
+         DU_LOG("\nDEBUG  -->  E2AP : Created APER encoded buffer for E2 Connection Update Acknowledge \n");
+         for(int i=0; i< encBufSize; i++)
+         {
+            DU_LOG("%x",encBuf[i]);
+         }
+      }
+
+      /* Sending msg */
+      if(SendE2APMsg(DU_APP_MEM_REGION, DU_POOL, encBuf, encBufSize) != ROK)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Failed to send E2 Connection Update Acknowledge");
+         break;
+      }
+
+      ret = ROK;
+      break;
+   }while(true);
+
+   FreeE2ConnectionUpdateAcknowledge(e2apMsg);
+   return ret;
+}
+
 /******************************************************************
  *
  * @brief Deallocation of memory allocated by aper decoder for 
@@ -8424,6 +8852,7 @@ void freeAperDecodingOfE2ConnectionUpdate(E2connectionUpdate_t *connectionUpdate
 {
    uint8_t ieIdx =0, arrIdx=0;
    E2connectionUpdate_List_t *connectionToBeModifyList = NULLP;
+   E2connectionUpdateRemove_List_t *connectionToBeRemoveList = NULLP;
 
    if(connectionUpdate->protocolIEs.list.array)
    {
@@ -8449,6 +8878,19 @@ void freeAperDecodingOfE2ConnectionUpdate(E2connectionUpdate_t *connectionUpdate
                      }
                      break;
                   }
+               case ProtocolIE_IDE2_id_E2connectionUpdateRemove:
+                  {
+                     connectionToBeRemoveList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdateRemove_List;
+                     if(connectionToBeRemoveList->list.array)
+                     {
+                        for(arrIdx= 0; arrIdx< connectionToBeRemoveList->list.count; arrIdx++)
+                        {
+                           free(connectionToBeRemoveList->list.array[arrIdx]);
+                        }
+                        free(connectionToBeRemoveList->list.array);
+                     }
+                     break;
+                  }
             }
             free(connectionUpdate->protocolIEs.list.array[ieIdx]);
          }
@@ -8457,6 +8899,67 @@ void freeAperDecodingOfE2ConnectionUpdate(E2connectionUpdate_t *connectionUpdate
    }
 }
 
+/*******************************************************************
+ *
+ * @brief Handling of E2 connection modification Ie
+ *
+ * @details
+ *
+ *    Function : handle2ConnectionModification 
+ *
+ * Functionality: Handling of E2 connection modification Ie
+ *
+ * @param  E2AP_PDU_t  *e2apMsg
+ * @return void
+ *
+ ******************************************************************/
+
+void handle2ConnectionModification(E2connectionUpdate_List_t *connectionUpdateList, E2ConnectionList *connectionInfoList)
+{
+   uint32_t ipAddress=0;
+   bool infoFound = false;
+   uint8_t arrIdx=0,idx=0, count =0;
+   E2connectionUpdate_ItemIEs_t *connectionModifyItem=NULLP;
+
+   if(connectionUpdateList->list.array)
+   {
+      for(arrIdx = 0; arrIdx < connectionUpdateList->list.count; arrIdx++)
+      {
+         connectionModifyItem= (E2connectionUpdate_ItemIEs_t*)connectionUpdateList->list.array[arrIdx];
+         bitStringToInt(&connectionModifyItem->value.choice.E2connectionUpdate_Item.tnlInformation.tnlAddress, &ipAddress);
+         for(idx=0; idx<duCb.e2apDb.numOfTNLAssoc; idx++)
+         {
+            /* If the TNL information is found in the data base, update the
+             * information in the database */
+            if(duCb.e2apDb.tnlAssoc[idx].destIpAddress.ipV4Addr == ipAddress)
+            {
+               duCb.e2apDb.tnlAssoc[idx].usage = connectionModifyItem->value.choice.E2connectionUpdate_Item.tnlUsage;
+               infoFound = true;
+               break;
+            }
+         }
+         
+         /* If the TNL information is found in the data base, then add the
+          * information in setupE2Connection array else add in failedToSetupE2Connection array */
+         if(infoFound == true)
+         {
+            count =connectionInfoList->numOfE2ConnectionSetup;
+            connectionInfoList->setupE2Connection[count].ipV4Addr =  duCb.e2apDb.tnlAssoc[idx].destIpAddress.ipV4Addr;
+            connectionInfoList->setupE2Connection[count].usage = duCb.e2apDb.tnlAssoc[idx].usage;
+            connectionInfoList->numOfE2ConnectionSetup++;
+         }
+         else
+         {
+            count = connectionInfoList->numOfE2ConnectionFailedToSetup;
+            connectionInfoList->failedToSetupE2Connection[count].ipV4Addr =  ipAddress;
+            connectionInfoList->failedToSetupE2Connection[count].usage = connectionModifyItem->value.choice.E2connectionUpdate_Item.tnlUsage;
+            connectionInfoList->numOfE2ConnectionFailedToSetup++;
+         }
+      }
+
+   }
+}
+
 /*******************************************************************
  *
  * @brief Process e2 connection update received from RIC
@@ -8474,15 +8977,16 @@ void freeAperDecodingOfE2ConnectionUpdate(E2connectionUpdate_t *connectionUpdate
 
 void procE2ConnectionUpdate(E2AP_PDU_t  *e2apMsg)
 {
-   bool invalidTransId = false;
-   uint8_t arrIdx =0, transId =0, count=0;
+   bool invalidTransId = false, connectionFailedToUpdate=false;
+   uint8_t arrIdx =0, transId =0;
    E2FailureCause failureCause;
    E2connectionUpdate_t *connectionUpdate=NULLP;
+   E2ConnectionList connectionInfoList;
 
    DU_LOG("\nINFO   -->  E2AP : E2 connection update received");
    connectionUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2connectionUpdate;
    
-   count = connectionUpdate->protocolIEs.list.count;
+   memset(&connectionInfoList, 0, sizeof(E2ConnectionList));
    for(arrIdx=0; arrIdx<connectionUpdate->protocolIEs.list.count; arrIdx++)
    {
       switch(connectionUpdate->protocolIEs.list.array[arrIdx]->id)
@@ -8492,25 +8996,39 @@ void procE2ConnectionUpdate(E2AP_PDU_t  *e2apMsg)
                transId = connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
                if(transId>255)
                {
+                  failureCause.causeType = E2_PROTOCOL;
+                  failureCause.cause = E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE;
                   invalidTransId = true;
                }
                break;
             }
+
          case ProtocolIE_IDE2_id_E2connectionUpdateModify:
+            {
+               handle2ConnectionModification(&connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2connectionUpdate_List, &connectionInfoList);
+               if((connectionInfoList.numOfE2ConnectionSetup == 0) && (connectionInfoList.numOfE2ConnectionFailedToSetup > 0))
+               {
+                  failureCause.causeType = E2_TRANSPORT;
+                  failureCause.cause = E2_TRANSPORT_CAUSE_UNSPECIFIED;
+                  connectionFailedToUpdate =true;
+               }
+
+               break;
+            }
+
+         case ProtocolIE_IDE2_id_E2connectionUpdateRemove:
             {
                /*TODO*/
                break;
             }
       }
 
-      if(invalidTransId == true)
+      if(invalidTransId == true || connectionFailedToUpdate ==true)
          break;
    }
    
-   if(invalidTransId == true)
+   if(invalidTransId == true || connectionFailedToUpdate == true)
    {
-      failureCause.causeType = E2_PROTOCOL;
-      failureCause.cause = E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE;
       if(BuildAndSendE2ConnectionUpdateFailure(transId, failureCause) != ROK)
       {
          DU_LOG("\nERROR  -->  E2AP : Failed to build and send E2 connection update failure");
@@ -8518,7 +9036,10 @@ void procE2ConnectionUpdate(E2AP_PDU_t  *e2apMsg)
    }
    else
    {
-      /*TODO*/
+      if(BuildAndSendE2ConnectionUpdateAcknowledge(transId, connectionInfoList) != ROK)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Failed to build and send E2 connection update ack");
+      }
    }
 
    freeAperDecodingOfE2ConnectionUpdate(connectionUpdate);
index bf427f8..75a657c 100644 (file)
@@ -6474,28 +6474,53 @@ void procE2RemovalRequest(uint32_t duId, E2RemovalRequest_t *removalReq)
  *
  * @params[in]
  *    E2connectionUpdate Item to be filled
- *
+ *    Protocol Id
  * @return ROK - success
  *         RFAILED - failure
  * ****************************************************************/
 
-uint8_t fillE2connectionUpdateItem(E2connectionUpdate_Item_t *connectionModifyItem)
+uint8_t fillE2connectionUpdateItem(PTR connectionInfo, uint8_t protocolId)
 {
-   connectionModifyItem->tnlInformation.tnlAddress.size =  4*sizeof(uint8_t);
-   RIC_ALLOC(connectionModifyItem->tnlInformation.tnlAddress.buf, \
-         connectionModifyItem->tnlInformation.tnlAddress.size);
-   if(!connectionModifyItem->tnlInformation.tnlAddress.buf)
+   E2connectionUpdateRemove_Item_t *connectionRemoveITem=NULLP;
+   E2connectionUpdate_Item_t *connectionModifyItem=NULLP;
+   TNLinformation_t *tnlInformation = NULLP;
+   TNLusage_t  *tnlUsage=NULLP;
+
+   switch(protocolId)
+   {
+      case ProtocolIE_IDE2_id_E2connectionUpdate_Item:
+      {
+         connectionModifyItem = (E2connectionUpdate_Item_t*)connectionInfo;
+         tnlInformation = &connectionModifyItem->tnlInformation;
+         tnlUsage = &connectionModifyItem->tnlUsage;
+         break;
+      }
+
+      case ProtocolIE_IDE2_id_E2connectionUpdateRemove_Item:
+      {
+         connectionRemoveITem = (E2connectionUpdateRemove_Item_t*)connectionInfo;
+         tnlInformation= &connectionRemoveITem->tnlInformation;
+         break;
+      }
+   }
+   
+   tnlInformation->tnlAddress.size =  4*sizeof(uint8_t);
+   RIC_ALLOC(tnlInformation->tnlAddress.buf, tnlInformation->tnlAddress.size);
+   if(!tnlInformation->tnlAddress.buf)
    {
       DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
       return RFAILED;
    }
-
-   connectionModifyItem->tnlInformation.tnlAddress.buf[0] =  ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr & 0xFF; 
-   connectionModifyItem->tnlInformation.tnlAddress.buf[1] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 8) & 0xFF;
-   connectionModifyItem->tnlInformation.tnlAddress.buf[2] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 16) & 0xFF;
-   connectionModifyItem->tnlInformation.tnlAddress.buf[3] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 24) & 0xFF;
-   connectionModifyItem->tnlInformation.tnlAddress.bits_unused = 0;
-   connectionModifyItem->tnlUsage = TNLusage_support_function; 
+   
+   tnlInformation->tnlAddress.buf[3] =  ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr & 0xFF; 
+   tnlInformation->tnlAddress.buf[2] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 8) & 0xFF;
+   tnlInformation->tnlAddress.buf[1] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 16) & 0xFF;
+   tnlInformation->tnlAddress.buf[0] = (ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr>> 24) & 0xFF;
+   tnlInformation->tnlAddress.bits_unused = 0;
+   if(protocolId == ProtocolIE_IDE2_id_E2connectionUpdate_Item)
+   {
+      *tnlUsage = TNLusage_support_function; 
+   }
    return ROK;
 }
 
@@ -6519,7 +6544,7 @@ uint8_t fillE2connectionUpdateItem(E2connectionUpdate_Item_t *connectionModifyIt
 uint8_t BuildE2ConnectionModifyList(E2connectionUpdate_List_t *connectionToBeModifyList)
 {
    uint8_t arrIdx = 0;
-   E2connectionUpdate_ItemIEs_t *ConnectionModify=NULL;
+   E2connectionUpdate_ItemIEs_t *connectionModify=NULL;
 
    connectionToBeModifyList->list.count = 1;
  
@@ -6535,11 +6560,67 @@ uint8_t BuildE2ConnectionModifyList(E2connectionUpdate_List_t *connectionToBeMod
             DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
             return RFAILED;
          }
-         ConnectionModify = (E2connectionUpdate_ItemIEs_t*)connectionToBeModifyList->list.array[arrIdx];
-         ConnectionModify->id = ProtocolIE_IDE2_id_E2connectionUpdate_Item;
-         ConnectionModify->criticality= CriticalityE2_ignore;
-         ConnectionModify->value.present = E2connectionUpdate_ItemIEs__value_PR_E2connectionUpdate_Item;
-         if(fillE2connectionUpdateItem(&ConnectionModify->value.choice.E2connectionUpdate_Item) != ROK)
+         connectionModify = (E2connectionUpdate_ItemIEs_t*)connectionToBeModifyList->list.array[arrIdx];
+         connectionModify->id = ProtocolIE_IDE2_id_E2connectionUpdate_Item;
+         connectionModify->criticality= CriticalityE2_ignore;
+         connectionModify->value.present = E2connectionUpdate_ItemIEs__value_PR_E2connectionUpdate_Item;
+         if(fillE2connectionUpdateItem((PTR)&connectionModify->value.choice.E2connectionUpdate_Item, ProtocolIE_IDE2_id_E2connectionUpdate_Item) != ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to fill E2 connection update item");
+            return RFAILED;
+         }
+         
+      }
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+      return RFAILED;
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Build E2 connection remove list
+ *
+ * @details
+ *
+ *    Function : BuildE2ConnectionRemoveList
+ *
+ *    Functionality: Build E2 connection remove list
+ *
+ * @params[in]
+ *    E2 connection remove list to be filled
+ *
+ * @return ROK - success
+ *         RFAILED - failure
+ * ****************************************************************/
+
+uint8_t BuildE2ConnectionRemoveList(E2connectionUpdateRemove_List_t *connectionToBeRemoveList)
+{
+   uint8_t arrIdx = 0;
+   E2connectionUpdateRemove_ItemIEs_t *connectionRemove=NULL;
+
+   connectionToBeRemoveList->list.count = 1;
+   connectionToBeRemoveList->list.size = connectionToBeRemoveList->list.count*sizeof(E2connectionUpdateRemove_ItemIEs_t*);
+   RIC_ALLOC(connectionToBeRemoveList->list.array, connectionToBeRemoveList->list.size);
+   if(connectionToBeRemoveList->list.array)
+   {
+      for(arrIdx = 0; arrIdx< connectionToBeRemoveList->list.count; arrIdx++)
+      {
+         RIC_ALLOC(connectionToBeRemoveList->list.array[arrIdx], sizeof(E2connectionUpdateRemove_ItemIEs_t));
+         if(connectionToBeRemoveList->list.array[arrIdx] == NULLP)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Memory allocation failed in %s at line %d", __func__, __LINE__);
+            return RFAILED;
+         }
+         connectionRemove = (E2connectionUpdateRemove_ItemIEs_t*)connectionToBeRemoveList->list.array[arrIdx];
+         connectionRemove->id = ProtocolIE_IDE2_id_E2connectionUpdateRemove_Item;
+         connectionRemove->criticality= CriticalityE2_ignore;
+         connectionRemove->value.present = E2connectionUpdateRemove_ItemIEs__value_PR_E2connectionUpdateRemove_Item;
+         if(fillE2connectionUpdateItem((PTR)&connectionRemove->value.choice.E2connectionUpdateRemove_Item, ProtocolIE_IDE2_id_E2connectionUpdateRemove_Item) != ROK)
          {
             DU_LOG("\nERROR  -->  E2AP : Failed to fill E2 connection update item");
             return RFAILED;
@@ -6576,6 +6657,7 @@ void FreeE2ConnectionUpdate(E2AP_PDU_t *e2apMsg)
    uint8_t ieIdx =0, arrIdx=0;
    E2connectionUpdate_t  *connectionUpdate = NULLP;
    E2connectionUpdate_List_t *connectionToBeModifyList = NULLP;
+   E2connectionUpdateRemove_List_t *connectionToBeRemoveList = NULLP;
 
    if(e2apMsg != NULLP)
    {
@@ -6606,6 +6688,20 @@ void FreeE2ConnectionUpdate(E2AP_PDU_t *e2apMsg)
                            }
                            break;
                         }
+
+                     case ProtocolIE_IDE2_id_E2connectionUpdateRemove:
+                        {
+                           connectionToBeRemoveList = &connectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdateRemove_List;
+                           if(connectionToBeRemoveList->list.array)
+                           {
+                              for(arrIdx = 0; arrIdx < connectionToBeRemoveList->list.count; arrIdx++)
+                              {
+                                 RIC_FREE(connectionToBeRemoveList->list.array[arrIdx], sizeof(E2connectionUpdateRemove_ItemIEs_t));
+                              }
+                              RIC_FREE(connectionToBeRemoveList->list.array, connectionToBeRemoveList->list.size);
+                           }
+                           break;
+                        }
                   }
                   RIC_FREE(connectionUpdate->protocolIEs.list.array[ieIdx], sizeof(E2connectionUpdate_IEs_t));
                }
@@ -6630,12 +6726,13 @@ void FreeE2ConnectionUpdate(E2AP_PDU_t *e2apMsg)
  *         - Buld and send the E2 Connection Update Message
  * @params[in] 
  *    Du Id
+ *    E2 connection to be modify or delete
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
 
-uint8_t BuildAndSendE2ConnectionUpdate(uint32_t duId)
+uint8_t BuildAndSendE2ConnectionUpdate(uint32_t duId, E2Connection connectionInfo)
 {
    uint8_t ieIdx = 0, elementCnt = 0;
    uint8_t ret = RFAILED, duIdx =0;
@@ -6674,7 +6771,12 @@ uint8_t BuildAndSendE2ConnectionUpdate(uint32_t duId)
       e2apMsg->choice.initiatingMessage->value.present = InitiatingMessageE2__value_PR_E2connectionUpdate;
       e2ConnectionUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2connectionUpdate;
 
-      elementCnt = 2;
+      elementCnt = 1;
+      if(connectionInfo == MODIFY_CONNECTION) 
+         elementCnt++;
+      if(connectionInfo == REMOVE_CONNECTION)
+         elementCnt++;
+
       e2ConnectionUpdate->protocolIEs.list.count = elementCnt;
       e2ConnectionUpdate->protocolIEs.list.size = elementCnt * sizeof(E2connectionUpdate_IEs_t*);
       RIC_ALLOC(e2ConnectionUpdate->protocolIEs.list.array, e2ConnectionUpdate->protocolIEs.list.size);
@@ -6702,14 +6804,30 @@ uint8_t BuildAndSendE2ConnectionUpdate(uint32_t duId)
       e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdate_IEs__value_PR_TransactionID;
       e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = assignTransactionId(duDb);
 
-      ieIdx++;
-      e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->id =  ProtocolIE_IDE2_id_E2connectionUpdateModify;
-      e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
-      e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdate_IEs__value_PR_E2connectionUpdate_List;
-      if(BuildE2ConnectionModifyList(&e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List) != ROK)
+      if(connectionInfo == MODIFY_CONNECTION)
       {
-         DU_LOG("\nERROR  -->  E2AP : Failed to build the connection update modify list");
-         break;
+         ieIdx++;
+         e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->id =  ProtocolIE_IDE2_id_E2connectionUpdateModify;
+         e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+         e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdate_IEs__value_PR_E2connectionUpdate_List;
+         if(BuildE2ConnectionModifyList(&e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List) != ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to build the connection update modify list");
+            break;
+         }
+      }
+      
+      if(connectionInfo == REMOVE_CONNECTION)
+      {
+         ieIdx++;
+         e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->id =  ProtocolIE_IDE2_id_E2connectionUpdateRemove;
+         e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->criticality = CriticalityE2_reject;
+         e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.present = E2connectionUpdate_IEs__value_PR_E2connectionUpdateRemove_List;
+         if(BuildE2ConnectionRemoveList(&e2ConnectionUpdate->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdateRemove_List) != ROK)
+         {
+            DU_LOG("\nERROR  -->  E2AP : Failed to build the connection update modify list");
+            break;
+         }
       }
 
       xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2apMsg);
index 3206172..6c230e9 100644 (file)
@@ -64,7 +64,7 @@ E2NodeComponent *fetchE2NodeComponentInfo(DuDb *duDb, InterfaceType interfaceTyp
 uint8_t handleE2NodeComponentAction(DuDb *duDb, PTR e2NodeCfg, uint8_t protocolId, E2NodeConfigItem *storeCfg);
 uint8_t BuildAndSendE2NodeConfigUpdateAck(DuDb *duDb, uint8_t transId,  E2NodeConfigList *e2NodeList);
 uint8_t BuildAndSendConnectionUpdate(uint32_t duId);
-
+uint8_t BuildAndSendE2ConnectionUpdate(uint32_t duId, E2Connection connectionInfo);
 /**********************************************************************
          End of file
 **********************************************************************/
index 3885d5b..0b282de 100644 (file)
    }\
 }
 
+typedef enum
+{
+   ADD_CONNECTION,
+   MODIFY_CONNECTION,
+   REMOVE_CONNECTION
+}E2Connection;
+
 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26 */
 typedef enum
 {