[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-533] Processing of E2 Connection Update ack 16/12016/5
authorpborla <pborla@radisys.com>
Mon, 6 Nov 2023 04:58:32 +0000 (10:28 +0530)
committerpborla <pborla@radisys.com>
Mon, 6 Nov 2023 09:29:30 +0000 (14:59 +0530)
Change-Id: I686b2dc4db7c105d8955c30140cee3cd9dbd326a
Signed-off-by: pborla <pborla@radisys.com>
src/du_app/du_e2ap_mgr.c
src/du_app/du_e2ap_msg_hdl.c
src/du_app/du_sctp.c
src/ric_stub/ric_e2ap_msg_hdl.c
src/ric_stub/ric_stub_sctp.c

index 0c4b0b3..0956f95 100644 (file)
@@ -1463,7 +1463,6 @@ void removeE2NodeInformation()
    memset(&duCb.e2apDb.ricId, 0, sizeof(GlobalRicId));
    duCb.e2apDb.numOfTNLAssoc = 0;
    memset(&duCb.e2apDb.tnlAssoc, 0, MAX_TNL_ASSOCIATION*sizeof(TNLAssociation));
-   cmInetClose(&ricParams.sockFd);
    memset(&ricParams, 0, sizeof(DuSctpDestCb));
 }
 /**********************************************************************
index 388e2fd..cb805f9 100644 (file)
@@ -26,6 +26,7 @@
 #include "du_e2ap_mgr.h"
 #include "du_e2ap_msg_hdl.h"
 #include "du_cfg.h"
+#include "du_sctp.h"
 #include "du_mgr.h"
 #include "du_mgr_main.h"
 #include "du_utils.h"
@@ -482,7 +483,6 @@ uint8_t BuildAndSendRemovalResponse(uint16_t transId)
    }while(true);
 
    FreeE2RemovalResponse(e2apMsg);
-   removeE2NodeInformation();
    return ret;
 }
 
@@ -8223,8 +8223,10 @@ void ProcE2RemovalResponse(E2AP_PDU_t *e2apMsg)
                   if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) &&\
                         (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.unsuccessfulOutcome->procedureCode))
                   {
-                     removeE2NodeInformation();
+                     DU_LOG("\nINFO  -->  E2AP : Sending request to close the sctp connection");
+                     cmInetClose(&ricParams.sockFd);
                      memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+                     removeE2NodeInformation();
                   }
                   else
                   {
@@ -8905,16 +8907,18 @@ void freeAperDecodingOfE2ConnectionUpdate(E2connectionUpdate_t *connectionUpdate
  *
  * @details
  *
- *    Function : handle2ConnectionModification 
+ *    Function : handleE2ConnectionModification 
  *
  * Functionality: Handling of E2 connection modification Ie
  *
- * @param  E2AP_PDU_t  *e2apMsg
+ * @param 
+ *        E2 Connection update list
+ *        E2 connection list which needs to be filled
  * @return void
  *
  ******************************************************************/
 
-void handle2ConnectionModification(E2connectionUpdate_List_t *connectionUpdateList, E2ConnectionList *connectionInfoList)
+void handleE2ConnectionModification(E2connectionUpdate_List_t *connectionUpdateList, E2ConnectionList *connectionInfoList)
 {
    uint32_t ipAddress=0;
    bool infoFound = false;
@@ -8960,6 +8964,48 @@ void handle2ConnectionModification(E2connectionUpdate_List_t *connectionUpdateLi
    }
 }
 
+/*******************************************************************
+ *
+ * @brief Handling of E2 connection removal Ie
+ *
+ * @details
+ *
+ *    Function : handleE2ConnectionRemoval 
+ *
+ * Functionality: Handling of E2 connection removal Ie
+ *
+ * @param  
+ *    E2 Connection removal List 
+ * @return void
+ *
+ ******************************************************************/
+
+void handleE2ConnectionRemoval(E2connectionUpdateRemove_List_t *connectionRemovalList)
+{
+   uint32_t ipAddress=0;
+   uint8_t arrIdx=0,idx=0;
+   E2connectionUpdateRemove_ItemIEs_t *connectionRemovalItem=NULLP;
+
+   if(connectionRemovalList->list.array)
+   {
+      for(arrIdx = 0; arrIdx < connectionRemovalList->list.count; arrIdx++)
+      {
+         connectionRemovalItem= (E2connectionUpdateRemove_ItemIEs_t*)connectionRemovalList->list.array[arrIdx];
+         bitStringToInt(&connectionRemovalItem->value.choice.E2connectionUpdateRemove_Item.tnlInformation.tnlAddress, &ipAddress);
+         for(idx=0; idx<duCb.e2apDb.numOfTNLAssoc; idx++)
+         {
+            if(duCb.e2apDb.tnlAssoc[idx].destIpAddress.ipV4Addr == ipAddress)
+            {
+               cmInetClose(&ricParams.sockFd);
+               removeE2NodeInformation();
+               break;
+            }
+         }
+         
+      }
+   }
+}
+
 /*******************************************************************
  *
  * @brief Process e2 connection update received from RIC
@@ -8977,11 +9023,11 @@ void handle2ConnectionModification(E2connectionUpdate_List_t *connectionUpdateLi
 
 void procE2ConnectionUpdate(E2AP_PDU_t  *e2apMsg)
 {
-   bool invalidTransId = false, connectionFailedToUpdate=false;
    uint8_t arrIdx =0, transId =0;
+   bool invalidTransId = false, connectionFailedToUpdate=false;
    E2FailureCause failureCause;
-   E2connectionUpdate_t *connectionUpdate=NULLP;
    E2ConnectionList connectionInfoList;
+   E2connectionUpdate_t *connectionUpdate=NULLP;
 
    DU_LOG("\nINFO   -->  E2AP : E2 connection update received");
    connectionUpdate = &e2apMsg->choice.initiatingMessage->value.choice.E2connectionUpdate;
@@ -9005,7 +9051,8 @@ void procE2ConnectionUpdate(E2AP_PDU_t  *e2apMsg)
 
          case ProtocolIE_IDE2_id_E2connectionUpdateModify:
             {
-               handle2ConnectionModification(&connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2connectionUpdate_List, &connectionInfoList);
+               handleE2ConnectionModification(&connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2connectionUpdate_List,\
+                     &connectionInfoList);
                if((connectionInfoList.numOfE2ConnectionSetup == 0) && (connectionInfoList.numOfE2ConnectionFailedToSetup > 0))
                {
                   failureCause.causeType = E2_TRANSPORT;
@@ -9018,7 +9065,13 @@ void procE2ConnectionUpdate(E2AP_PDU_t  *e2apMsg)
 
          case ProtocolIE_IDE2_id_E2connectionUpdateRemove:
             {
-               /*TODO*/
+               handleE2ConnectionRemoval(&connectionUpdate->protocolIEs.list.array[arrIdx]->value.choice.E2connectionUpdateRemove_List);
+               break;
+            }
+
+         default:
+            {
+               DU_LOG("\nERROR  -->  E2AP : Invalid IE received[%ld]",connectionUpdate->protocolIEs.list.array[arrIdx]->id);
                break;
             }
       }
index 93cd7dc..efee291 100644 (file)
@@ -571,7 +571,7 @@ void sendToDuApp(Buffer *mBuf, Event event)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t sctpNtfyHdlr(CmInetSctpNotification *ntfy, uint8_t *itfState)
+uint8_t sctpNtfyHdlr(CmInetSctpNotification *ntfy, uint8_t *itfState, uint8_t interface)
 {
    Pst pst;
 
@@ -617,10 +617,21 @@ uint8_t sctpNtfyHdlr(CmInetSctpNotification *ntfy, uint8_t *itfState)
          DU_LOG("\nINFO   -->  SCTP : Send Failed notification received\n");
          break;
       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
-         DU_LOG("\nINFO   -->  SCTP : Shutdown Event notification received\n");
-         *itfState = DU_SCTP_DOWN;
-         exit(0);
-         break;
+         {
+            DU_LOG("\nINFO   -->  SCTP : Shutdown Event notification received\n");
+            *itfState = DU_SCTP_DOWN;
+            switch(interface)
+            {
+               case F1_INTERFACE:
+                  break;
+               case E2_INTERFACE:
+                  removeE2NodeInformation();
+                  break;
+               default:
+                  exit(0);
+            }
+            break;
+         }
       case CM_INET_SCTP_ADAPTATION_INDICATION :
          DU_LOG("\nINFO   -->  SCTP : Adaptation Indication received\n");
          break;
@@ -707,13 +718,13 @@ uint8_t  processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32
             {
                f1Params.assocId = pollParams->ntfy.u.assocChange.assocId;
                DU_LOG("\nDEBUG   -->  SCTP : AssocId assigned to F1Params from PollParams [%d]\n", f1Params.assocId);
-               ret = sctpNtfyHdlr(&pollParams->ntfy, &f1Params.itfState);
+               ret = sctpNtfyHdlr(&pollParams->ntfy, &f1Params.itfState, F1_INTERFACE);
             }
             else if(pollParams->port == ricParams.destPort)
             {
                ricParams.assocId = pollParams->ntfy.u.assocChange.assocId;
                DU_LOG("\nDEBUG   -->  SCTP : AssocId assigned to ricParams from PollParams [%d]\n", ricParams.assocId);
-               ret = sctpNtfyHdlr(&pollParams->ntfy, &ricParams.itfState);
+               ret = sctpNtfyHdlr(&pollParams->ntfy, &ricParams.itfState, E2_INTERFACE);
             }
             else
             {
index 75a657c..061986b 100644 (file)
@@ -5983,6 +5983,36 @@ void ProcE2RemovalFailure(E2RemovalFailure_t *e2RemovalFailure)
       }
    }
 }
+/*******************************************************************
+ *
+ * @brief Delete E2 component node list
+ *
+ * @details
+ *
+ *    Function : deleteE2ComponentNodeList 
+ *
+ * Functionality: Delete E2 component node  list
+ *
+ * @params[in] E2 component node list
+ * @return void
+
+ *
+ ******************************************************************/
+
+void deleteE2ComponentNodeList(CmLListCp *componentList)
+{
+   E2NodeComponent *cfgInfo = NULLP;
+   CmLList *e2ComponentNode = NULLP;
+
+   CM_LLIST_FIRST_NODE(componentList, e2ComponentNode);
+   while(e2ComponentNode)
+   {
+      cfgInfo = (E2NodeComponent*)e2ComponentNode->node;
+      cmLListDelFrm(componentList, e2ComponentNode);
+      memset(cfgInfo, 0, sizeof(E2NodeComponent));
+      CM_LLIST_FIRST_NODE(componentList, e2ComponentNode);
+   }
+}
 
 /*******************************************************************
  *
@@ -6014,8 +6044,7 @@ void deleteE2NodeInfo(DuDb *duDb)
          deleteRicSubscriptionList(&ranFuncDb->subscriptionList);
       }
    }
-
-   cmInetClose(&sctpCb.e2LstnSockFd);
+   deleteE2ComponentNodeList(&duDb->e2NodeComponent);
 }
 
 /*******************************************************************
@@ -6067,8 +6096,10 @@ void ProcE2RemovalResponse(uint32_t duId, E2RemovalResponse_t *removalRsp)
          {
             case ProtocolIE_IDE2_id_TransactionID:
                {
+                  DU_LOG("\nINFO  -->  E2AP : Sending request to close the sctp connection");
+                  cmInetClose(&sctpCb.e2LstnSockFd);
                   deleteE2NodeInfo(duDb);
-                  break;
+                  exit(0);
                }
             default:
                {
@@ -6401,7 +6432,6 @@ uint8_t BuildAndSendRemovalResponse(uint32_t duId, uint16_t transId)
    }while(true);
 
    FreeE2RemovalResponse(e2apMsg);
-   deleteE2NodeInfo(duDb);
    return ret;
 }
 
@@ -6927,6 +6957,114 @@ void ProcE2connectionUpdateFailure(E2connectionUpdateFailure_t *updateFailure)
    }
 }
 
+/*******************************************************************
+ *
+ * @brief process the E2 Connection update ack
+ *
+ * @details
+ *
+ *    Function : ProcE2ConnectionUpdateAck 
+ *
+ * Functionality: Process E2 Connection update ack 
+ *
+ * @params[in] 
+ *       du Id
+ *       Pointer to Connection update ack 
+ * @return void
+ *
+ ******************************************************************/
+
+void ProcE2ConnectionUpdateAck(uint32_t duId, E2connectionUpdateAcknowledge_t *connectionUpdateAck)
+{
+   uint16_t transId =0;
+   uint32_t ipAddress=0;
+   DuDb *duDb = NULLP;
+   uint8_t ieIdx = 0, duIdx =0, arrIdx=0;
+   E2connectionUpdate_Item_t *connectionSetupItem=NULLP;
+   E2connectionUpdate_ItemIEs_t *connectionSetupItemIe=NULLP;
+   E2connectionUpdate_List_t *connectionSetupList=NULLP;
+   E2connectionSetupFailed_Item_t *setupFailedItem =NULLP;
+   E2connectionSetupFailed_List_t *setupFailedList=NULLP;
+   E2connectionSetupFailed_ItemIEs_t *setupFailedItemIe =NULLP;
+
+   SEARCH_DU_DB(duIdx, duId, duDb);
+   if(duDb == NULLP)
+   {
+      DU_LOG("\nERROR  -->  E2AP : duDb is not present for duId %d",duId);
+      return;
+   }
+
+   if(!connectionUpdateAck)
+   {
+      DU_LOG("\nERROR  -->  E2AP : connectionUpdateAck pointer is null"); 
+      return;
+   }
+
+   if(!connectionUpdateAck->protocolIEs.list.array)      
+   {
+      DU_LOG("\nERROR  -->  E2AP : connectionUpdateAck array pointer is null");
+      return;
+   }
+
+   for(ieIdx=0; ieIdx < connectionUpdateAck->protocolIEs.list.count; ieIdx++)
+   {
+      if(connectionUpdateAck->protocolIEs.list.array[ieIdx])
+      {
+         switch(connectionUpdateAck->protocolIEs.list.array[ieIdx]->id)
+         {
+            case ProtocolIE_IDE2_id_TransactionID:
+               {
+                  transId = connectionUpdateAck->protocolIEs.list.array[arrIdx]->value.choice.TransactionID;
+                  if(transId>255)
+                  {
+                     DU_LOG("\nERROR  -->  E2AP : Received invalid trans id %d ",transId);
+                     return;
+                  }
+                  break;
+               }
+            case ProtocolIE_IDE2_id_E2connectionSetup:
+               {
+                  connectionSetupList=&connectionUpdateAck->protocolIEs.list.array[ieIdx]->value.choice.E2connectionUpdate_List;
+                  if(connectionSetupList->list.array)
+                  {
+                     for(arrIdx = 0; arrIdx< connectionSetupList->list.count; arrIdx++)
+                     {
+                        connectionSetupItemIe = (E2connectionUpdate_ItemIEs_t*)connectionSetupList->list.array[arrIdx];
+                        connectionSetupItem = &connectionSetupItemIe->value.choice.E2connectionUpdate_Item;
+                        bitStringToInt(&connectionSetupItem->tnlInformation.tnlAddress, &ipAddress);
+                        if(ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr == ipAddress)
+                        {
+                            ricCb.ricCfgParams.sctpParams.usage = connectionSetupItem->tnlUsage;
+                        }
+                     }
+                  }
+                  break;
+               }
+
+            case ProtocolIE_IDE2_id_E2connectionSetupFailed:
+               {
+                  setupFailedList=&connectionUpdateAck->protocolIEs.list.array[ieIdx]->value.choice.E2connectionSetupFailed_List;
+                  if(setupFailedList->list.array)
+                  {
+                     for(arrIdx = 0; arrIdx< setupFailedList->list.count; arrIdx++)
+                     {
+                        setupFailedItemIe = (E2connectionSetupFailed_ItemIEs_t*)setupFailedList->list.array[arrIdx];
+                        setupFailedItem = &setupFailedItemIe->value.choice.E2connectionSetupFailed_Item;
+                        printE2ErrorCause(&setupFailedItem->cause);
+                     }
+                  }
+                  break;
+               }
+            default:
+               {
+                  DU_LOG("\nERROR  -->  E2AP : Received Invalid Ie [%ld]", connectionUpdateAck->protocolIEs.list.array[ieIdx]->id);
+                  break;
+               }
+         }
+      }
+   }
+}
+
 /*******************************************************************
 *
 * @brief Handles received E2AP message and sends back response  
@@ -7085,6 +7223,11 @@ void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf)
                      ProcE2RemovalResponse(*duId, &e2apMsg->choice.successfulOutcome->value.choice.E2RemovalResponse);
                      break;
                   }
+               case SuccessfulOutcomeE2__value_PR_E2connectionUpdateAcknowledge:
+                  {
+                     ProcE2ConnectionUpdateAck(*duId, &e2apMsg->choice.successfulOutcome->value.choice.E2connectionUpdateAcknowledge);
+                     break;
+                  }
                default:
                   {
                      DU_LOG("\nERROR  -->  E2AP : Invalid type of successfulOutcome message [%d]", \
index e8737f4..6c76ecb 100644 (file)
@@ -323,6 +323,7 @@ uint8_t sctpNtfyHdlr(RicSctpAssocCb *assocCb, CmInetSctpNotification *ntfy)
       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
          DU_LOG("\nINFO   -->  SCTP : Shutdown Event notification received\n");
          assocCb->connUp = FALSE;
+         deleteE2NodeInfo(&ricCb.duInfo[0]);
          exit(0);
          break;
       case CM_INET_SCTP_ADAPTATION_INDICATION :