[Issue-ID : ODUHIGH-486] SCTP Port fix at F1 and E2 interface 93/10293/6
authorlal.harshita <Harshita.Lal@radisys.com>
Fri, 20 Jan 2023 09:06:54 +0000 (14:36 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Mon, 23 Jan 2023 14:05:38 +0000 (19:35 +0530)
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
Change-Id: I05be329b84ec8c0b14e362976ef49f1b15315bec
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
17 files changed:
container-tag.yaml
docs/release-notes.rst
docs/user-guide.rst
releases/container-release-o-du-l2
releases/container-release-o-du-l2-cu-stub
src/cu_stub/cu_stub.c
src/cu_stub/cu_stub.h
src/cu_stub/cu_stub_sctp.c
src/cu_stub/cu_stub_sctp.h
src/du_app/du_cfg.c
src/du_app/du_cfg.h
src/ric_stub/ric_e2ap_msg_hdl.c
src/ric_stub/ric_e2ap_msg_hdl.h
src/ric_stub/ric_stub.c
src/ric_stub/ric_stub.h
src/ric_stub/ric_stub_sctp.c
src/ric_stub/ric_stub_sctp.h

index d047f0a..52a46ac 100644 (file)
@@ -1,4 +1,4 @@
 # The Jenkins job requires a tag to build the Docker image.
 # Global-JJB script assumes this file is in the repo root.
 ---
-tag: 7.0.2
+tag: 7.0.3
index c1103f2..60c7fad 100644 (file)
@@ -19,7 +19,7 @@ Version history
 | **Date**           | **Ver.**           | **Author**         | **Comment**        |
 |                    |                    |                    |                    |
 +--------------------+--------------------+--------------------+--------------------+
-|2022-12-15          | 7.0.1              | Radisys,           | G release          |
+|2022-12-15          | 7.0.2              | Radisys,           | G release          |
 |                    |                    | HCL Technologies   |                    |
 |                    |                    | Ltd.               |                    |
 +--------------------+--------------------+--------------------+--------------------+
@@ -195,24 +195,23 @@ Release Data
 ------------
 G release
 ^^^^^^^^^^
-+--------------------------------------+--------------------------------------+
-| **Project**                          | ODUHIGH                              |
-|                                      |                                      |   
-+--------------------------------------+--------------------------------------+
-| **Repo/commit-ID**                   |o-du/l2/                              |
-|                                      |I504547fae3bb9f137dbcc192ef4360f47ce48|
-|                                      |3f8                                   |
-|                                      |                                      |
-+--------------------------------------+--------------------------------------+
-| **Release designation**              | G release                            |
-|                                      |                                      |   
-+--------------------------------------+--------------------------------------+
-| **Release date**                     |2022-12-05                            |
-|                                      |                                      |   
-+--------------------------------------+--------------------------------------+
-| **Purpose of the delivery**          | G release                            |
-|                                      |                                      |   
-+--------------------------------------+--------------------------------------+
++--------------------------------------+------------------------------------------+
+| **Project**                          | ODUHIGH                                  |
+|                                      |                                          |   
++--------------------------------------+------------------------------------------+
+| **Repo/commit-ID**                   |o-du/l2/                                  |
+|                                      |I05be329b84ec8c0b14e362976ef49f1b15315bec |
+|                                      |                                          |
++--------------------------------------+------------------------------------------+
+| **Release designation**              | G release                                |
+|                                      |                                          |   
++--------------------------------------+------------------------------------------+
+| **Release date**                     |2022-12-05                                |
+|                                      |                                          |   
++--------------------------------------+------------------------------------------+
+| **Purpose of the delivery**          | G release                                |
+|                                      |                                          |   
++--------------------------------------+------------------------------------------+
 
 F release
 ^^^^^^^^^^
index 681d783..e4a1318 100644 (file)
@@ -66,17 +66,17 @@ II. Execution - Using Docker Images
 The call flow between O-DU High and CU Stub can be achieved by executing docker containers.
 
 - Pull the last built docker images:
-    -  docker pull nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2:7.0.2
-    -  docker pull nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2-cu-stub:7.0.2
+    -  docker pull nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2:7.0.3
+    -  docker pull nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2-cu-stub:7.0.3
 
 - Run CU Stub docker:
     - docker run -it --privileged --net=host --entrypoint bash
-      nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2-cu-stub:7.0.2
+      nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2-cu-stub:7.0.3
     - ./cu_stub
 
 - Run ODU docker:
     - docker run -it --privileged --net=host --entrypoint bash
-      nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2:7.0.2
+      nexus3.o-ran-sc.org:10004/o-ran-sc/o-du-l2:7.0.3
     - ./odu
 
 
index 89aa536..1ba8928 100644 (file)
@@ -1,11 +1,11 @@
 ---
 
 distribution_type: container
-container_release_tag: 7.0.2
+container_release_tag: 7.0.3
 container_pull_registry: nexus.o-ran-sc.org:10004
 container_push_registry: nexus.o-ran-sc.org:10002
 project: o-du-l2 
-ref: 48daa5d120883c690b1b80848d23c0be2886b475 
+ref: 2430b6f8a31218e1902bfdf8f96ed479cceb632e
 containers:
 - name: o-du-l2
-version: 7.0.2
+version: 7.0.3
index e73afb4..91e0517 100644 (file)
@@ -1,11 +1,11 @@
 ---
 
 distribution_type: container
-container_release_tag: 7.0.2
+container_release_tag: 7.0.3
 container_pull_registry: nexus.o-ran-sc.org:10004
 container_push_registry: nexus.o-ran-sc.org:10002
 project: o-du-l2 
-ref: 48daa5d120883c690b1b80848d23c0be2886b475 
+ref: 2430b6f8a31218e1902bfdf8f96ed479cceb632e
 containers:
 - name: o-du-l2-cu-stub
-version: 7.0.2
+version: 7.0.3
index a131ce5..c82fcdc 100644 (file)
@@ -150,16 +150,16 @@ void readCuCfg()
    }
    
    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
-   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV4Addr = ipv4_du;
-   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV6Pres = false;
+   cuCb.cuCfgParams.sctpParams.destCb[0].destIpAddr.ipV4Addr = ipv4_du;
+   cuCb.cuCfgParams.sctpParams.destCb[0].destIpAddr.ipV6Pres = false;
    
    cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
-   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuIpAddr.ipV4Addr = ipv4_cu;
-   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuIpAddr.ipV6Pres = false;
+   cuCb.cuCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_cu;
+   cuCb.cuCfgParams.sctpParams.localIpAddr.ipV6Pres = false;
    
-   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duPort = g_cfg.DU_Port;
-   cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuPort = g_cfg.CU_Port; 
-   cuCb.cuCfgParams.sctpParams.numDu = 1;
+   cuCb.cuCfgParams.sctpParams.destCb[0].destPort = g_cfg.DU_Port;
+   cuCb.cuCfgParams.sctpParams.f1SctpPort = g_cfg.CU_Port; 
+   cuCb.cuCfgParams.sctpParams.numDestNode = 1;
    
    cuCb.cuCfgParams.egtpParams.egtpAssoc[0].localIp.ipV4Pres = TRUE;
    cuCb.cuCfgParams.egtpParams.egtpAssoc[0].localIp.ipV4Addr = ipv4_cu;
@@ -173,28 +173,29 @@ void readCuCfg()
    cuCb.cuCfgParams.egtpParams.numDu = 1;
 
 #else
-   cuCb.cuCfgParams.sctpParams.numDu = 0;
+   /* CU IP Address and Port*/
+   memset(&ipv4_du, 0, sizeof(uint32_t));
+   cmInetAddr((S8*)LOCAL_IP_CU, &ipv4_cu);
+   cuCb.cuCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_cu;
+   cuCb.cuCfgParams.sctpParams.localIpAddr.ipV6Pres = false;
+   cuCb.cuCfgParams.sctpParams.f1SctpPort = F1_SCTP_PORT;
+
+   cuCb.cuCfgParams.sctpParams.numDestNode = 0;
    cuCb.cuCfgParams.egtpParams.numDu = 0;
+
    numDu = 0;
-   while(numDu < MAX_DU_SUPPORTED)
+   while(numDu < NUM_F1_ASSOC)
    {
       /* DU IP Address and Port*/
       memset(&ipv4_du, 0, sizeof(uint32_t));
-      cmInetAddr((S8*)DU_IP_V4_ADDR[numDu], &ipv4_du);
-      cuCb.cuCfgParams.sctpParams.sctpAssoc[numDu].duIpAddr.ipV4Addr = ipv4_du;
-      cuCb.cuCfgParams.sctpParams.sctpAssoc[numDu].duIpAddr.ipV6Pres = false;
-      cuCb.cuCfgParams.sctpParams.sctpAssoc[numDu].duPort = DU_SCTP_PORT[numDu];
-
-      /* CU IP Address and Port*/
-      memset(&ipv4_du, 0, sizeof(uint32_t));
-      cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
-      cuCb.cuCfgParams.sctpParams.sctpAssoc[numDu].cuIpAddr.ipV4Addr = ipv4_cu;
-      cuCb.cuCfgParams.sctpParams.sctpAssoc[numDu].cuIpAddr.ipV6Pres = false;
-      cuCb.cuCfgParams.sctpParams.sctpAssoc[numDu].cuPort = CU_SCTP_PORT_TO_DU[numDu];
+      cmInetAddr((S8*)REMOTE_IP_DU[numDu], &ipv4_du);
+      cuCb.cuCfgParams.sctpParams.destCb[numDu].destIpAddr.ipV4Addr = ipv4_du;
+      cuCb.cuCfgParams.sctpParams.destCb[numDu].destIpAddr.ipV6Pres = false;
+      cuCb.cuCfgParams.sctpParams.destCb[numDu].destPort = F1_SCTP_PORT;
 
       /* EGTP Parameters */
       memset(&ipv4_du, 0, sizeof(uint32_t));
-      cmInetAddr((S8*)DU_IP_V4_ADDR[numDu], &ipv4_du);
+      cmInetAddr((S8*)REMOTE_IP_DU[numDu], &ipv4_du);
       cuCb.cuCfgParams.egtpParams.egtpAssoc[numDu].localIp.ipV4Pres = TRUE;
       cuCb.cuCfgParams.egtpParams.egtpAssoc[numDu].localIp.ipV4Addr = ipv4_cu;
       cuCb.cuCfgParams.egtpParams.egtpAssoc[numDu].localPort = CU_EGTP_PORT[numDu];
@@ -209,7 +210,7 @@ void readCuCfg()
    cuCb.cuCfgParams.egtpParams.currTunnelId = cuCb.cuCfgParams.egtpParams.minTunnelId;
    cuCb.cuCfgParams.egtpParams.maxTunnelId = MAX_TEID;
    cuCb.cuCfgParams.egtpParams.numDu = numDu;
-   cuCb.cuCfgParams.sctpParams.numDu = numDu;
+   cuCb.cuCfgParams.sctpParams.numDestNode = numDu;
 #endif
 
    /*PLMN*/
@@ -294,7 +295,7 @@ uint8_t startDlData()
    
    while(totalNumOfTestFlow)
    {
-      for(duId = 1; duId<=MAX_DU_SUPPORTED; duId++)
+      for(duId = 1; duId <= cuCb.cuCfgParams.egtpParams.numDu; duId++)
       {
          for(teId = 1; teId <= NUM_TUNNEL_TO_PUMP_DATA; teId++)
          {
index f0b851c..9b8c9aa 100644 (file)
 #define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
 
 #ifndef O1_ENABLE
-#define DU_IP_V4_ADDR (char*[]){"192.168.130.81", "192.168.130.83"}
-#define DU_SCTP_PORT (int[]){38472, 38473}
+#define LOCAL_IP_CU "192.168.130.82"
 
-#define CU_IP_V4_ADDR "192.168.130.82"
-#define CU_SCTP_PORT_TO_DU (int[]){38472, 38473}
+#define F1_SCTP_PORT 38472
+#define NUM_F1_ASSOC 1  
+#define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"}
 #endif
 
 #define DU_EGTP_PORT  (int[]){39001, 39002}
 #define CU_EGTP_PORT (int[]){39003, 39004}
 #define RRC_VER 0
 #define EXT_RRC_VER 5
+
 #define PLMN_MCC0 3
 #define PLMN_MCC1 1
 #define PLMN_MCC2 1
index c74290a..285414b 100644 (file)
@@ -102,19 +102,20 @@ uint8_t sctpActvTsk(Pst *pst, Buffer *mBuf)
 
 uint8_t sctpCfgReq()
 {
-   int destIdx;
+   int destIdx = 0, assocIdx = 0;
    
-   for(destIdx=0; destIdx < sctpCb.sctpCfg.numDu; destIdx++)
+   fillAddrLst(&sctpCb.localAddrLst, &sctpCb.sctpCfg.localIpAddr);
+   memset(&sctpCb.f1LstnSockFd, -1, sizeof(CmInetFd));
+
+   for(destIdx=0; destIdx < sctpCb.sctpCfg.numDestNode; destIdx++)
    {
-      sctpCb.destCb[destIdx].destPort = sctpCb.sctpCfg.sctpAssoc[destIdx].duPort;
-      sctpCb.destCb[destIdx].srcPort  = sctpCb.sctpCfg.sctpAssoc[destIdx].cuPort;
-      sctpCb.destCb[destIdx].bReadFdSet = ROK;
-      memset(&sctpCb.destCb[destIdx].sockFd, -1, sizeof(CmInetFd));
-      memset(&sctpCb.destCb[destIdx].lstnSockFd, -1, sizeof(CmInetFd));
-      fillDestNetAddr(&sctpCb.destCb[destIdx].destIpNetAddr, &sctpCb.sctpCfg.sctpAssoc[destIdx].duIpAddr);
-      fillAddrLst(&sctpCb.destCb[destIdx].localAddrLst, &sctpCb.sctpCfg.sctpAssoc[destIdx].cuIpAddr);
+      sctpCb.assocCb[assocIdx].destPort = sctpCb.sctpCfg.destCb[destIdx].destPort;
+      sctpCb.assocCb[assocIdx].bReadFdSet = ROK;
+      memset(&sctpCb.assocCb[assocIdx].sockFd, -1, sizeof(CmInetFd));
+      fillDestNetAddr(&sctpCb.assocCb[assocIdx].destIpNetAddr, &sctpCb.sctpCfg.destCb[destIdx].destIpAddr);
+      assocIdx++;
    }
-   sctpCb.numDu = sctpCb.sctpCfg.numDu;
+   sctpCb.numAssoc = assocIdx;
    return ROK;
 }
 
@@ -189,30 +190,45 @@ uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
 
 uint8_t sctpStartReq()
 {
-   uint8_t destIdx;
+   uint8_t assocIdx;
    uint8_t ret = ROK;
 
    socket_type = CM_INET_STREAM;
-   for(destIdx=0; destIdx < sctpCb.numDu; destIdx++)
+
+   if(sctpCb.numAssoc)
    {
-      if((ret = cmInetSocket(socket_type, &sctpCb.destCb[destIdx].lstnSockFd, IPPROTO_SCTP) != ROK))
+      if((ret = cmInetSocket(socket_type, &sctpCb.f1LstnSockFd, IPPROTO_SCTP) != ROK))
       {
-         DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", sctpCb.destCb[destIdx].lstnSockFd.fd);
+         DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", sctpCb.f1LstnSockFd.fd);
       } 
-      else if((ret = cmInetSctpBindx(&sctpCb.destCb[destIdx].lstnSockFd, &sctpCb.destCb[destIdx].localAddrLst, \
-         sctpCb.destCb[destIdx].srcPort)) != ROK)
+      else if((ret = cmInetSctpBindx(&sctpCb.f1LstnSockFd, &sctpCb.localAddrLst, sctpCb.sctpCfg.f1SctpPort)) != ROK)
       {
          DU_LOG("\nERROR  -->  SCTP: Binding failed at CU");
       }
-      else if((ret = sctpAccept(&sctpCb.destCb[destIdx])) != ROK)
+      else if(ret = cmInetListen(&sctpCb.f1LstnSockFd, 1) != ROK)
       {
-         DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at CU");
+         DU_LOG("\nERROR  -->  SCTP : Listening on socket failed");
+         cmInetClose(&sctpCb.f1LstnSockFd);
+         return RFAILED;
+      }
+      else
+      {
+         for(assocIdx=0; assocIdx < sctpCb.numAssoc; assocIdx++)
+         {
+            if((ret = sctpAccept(&sctpCb.assocCb[assocIdx])) != ROK)
+            {
+               DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at CU");
+            }
+         }
       }
    }
 
-   if(sctpSockPoll() != ROK)
+   if(ret == ROK)
    {
-      DU_LOG("\nERROR  -->  SCTP: Polling failed to start at CU");
+      if(sctpSockPoll() != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCTP: Polling failed to start at CU");
+      }
    }
    return (ret);
 }
@@ -271,23 +287,15 @@ uint8_t sctpSetSockOpts(CmInetFd *sock_Fd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t sctpAccept(CuSctpDestCb *destCb)
+uint8_t sctpAccept(CuSctpAssocCb *assocCb)
 {
    uint8_t  ret;
 
-   ret = cmInetListen(&destCb->lstnSockFd, 1);
-   if (ret != ROK)
-   {
-      DU_LOG("\nERROR  -->  SCTP : Listening on socket failed");
-      cmInetClose(&destCb->lstnSockFd);
-      return RFAILED;
-   }
-   
    DU_LOG("\nINFO  -->  SCTP : Connecting");
 
-   while(!destCb->connUp)
+   while(!assocCb->connUp)
    {
-      ret = cmInetAccept(&destCb->lstnSockFd, &destCb->peerAddr, &destCb->sockFd);
+      ret = cmInetAccept(&sctpCb.f1LstnSockFd, &assocCb->peerAddr, &assocCb->sockFd);
       if (ret == ROKDNA)
       {
          continue;
@@ -299,8 +307,8 @@ uint8_t sctpAccept(CuSctpDestCb *destCb)
       }
       else
       {
-         destCb->connUp = TRUE;
-         sctpSetSockOpts(&destCb->sockFd);
+         assocCb->connUp = TRUE;
+         sctpSetSockOpts(&assocCb->sockFd);
          break;
       }
    }
@@ -326,7 +334,7 @@ uint8_t sctpAccept(CuSctpDestCb *destCb)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t sctpNtfyHdlr(CuSctpDestCb *destCb, CmInetSctpNotification *ntfy)
+uint8_t sctpNtfyHdlr(CuSctpAssocCb *assocCb, CmInetSctpNotification *ntfy)
 {
    switch(ntfy->header.nType)
    {
@@ -336,23 +344,23 @@ uint8_t sctpNtfyHdlr(CuSctpDestCb *destCb, CmInetSctpNotification *ntfy)
          {
             case CM_INET_SCTP_COMM_UP:
                DU_LOG("DEBUG  -->  Event : COMMUNICATION UP");
-               destCb->connUp = TRUE;
+               assocCb->connUp = TRUE;
                break;
             case CM_INET_SCTP_COMM_LOST:
                DU_LOG("DEBUG  -->  Event : COMMUNICATION LOST");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_RESTART:
                DU_LOG("DEBUG  -->  Event : SCTP RESTART");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_SHUTDOWN_COMP: /* association gracefully shutdown */
                DU_LOG("DEBUG  -->  Event : SHUTDOWN COMPLETE");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_CANT_STR_ASSOC:
                DU_LOG("DEBUG  -->  Event : CANT START ASSOC");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             default:
                DU_LOG("\nERROR  -->  Invalid event");
@@ -371,7 +379,7 @@ uint8_t sctpNtfyHdlr(CuSctpDestCb *destCb, CmInetSctpNotification *ntfy)
          break;
       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
          DU_LOG("\nINFO  -->  SCTP : Shutdown Event notification received\n");
-         destCb->connUp = FALSE;
+         assocCb->connUp = FALSE;
          exit(0);
          break;
       case CM_INET_SCTP_ADAPTATION_INDICATION :
@@ -407,7 +415,7 @@ uint8_t sctpNtfyHdlr(CuSctpDestCb *destCb, CmInetSctpNotification *ntfy)
  * ****************************************************************/
 uint8_t sctpSockPoll()
 {
-   uint8_t       destIdx;
+   uint8_t       assocIdx = 0, destIdx = 0;
    uint16_t      ret = ROK;
    uint32_t      timeout;
    uint32_t      *timeoutPtr;
@@ -432,9 +440,9 @@ uint8_t sctpSockPoll()
    while(1)
    {
       /* Receiving SCTP data */
-      for(destIdx = 0; destIdx < sctpCb.numDu; destIdx++)
+      for(assocIdx = 0; assocIdx < sctpCb.numAssoc; assocIdx++)
       {
-         if((ret = processPolling(&f1PollParams, &sctpCb.destCb[destIdx], timeoutPtr, &memInfo)) != ROK)
+         if((ret = processPolling(&f1PollParams, &sctpCb.assocCb[assocIdx], timeoutPtr, &memInfo)) != ROK)
          {
             DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for F1 at CU\n");
          }
@@ -484,33 +492,33 @@ uint8_t sctpSockPoll()
  *
  * ****************************************************************/
 
-uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
+uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpAssocCb *assocCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
 {
    uint16_t ret = ROK;
-   CM_INET_FD_SET(&destCb->sockFd, &pollParams->readFd);
+   CM_INET_FD_SET(&assocCb->sockFd, &pollParams->readFd);
    ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFd);
-   if(CM_INET_FD_ISSET(&destCb->sockFd, &pollParams->readFd))
+   if(CM_INET_FD_ISSET(&assocCb->sockFd, &pollParams->readFd))
    {
-      CM_INET_FD_CLR(&destCb->sockFd, &pollParams->readFd);
-      ret = cmInetSctpRecvMsg(&destCb->sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, \
+      CM_INET_FD_CLR(&assocCb->sockFd, &pollParams->readFd);
+      ret = cmInetSctpRecvMsg(&assocCb->sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, \
          &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy);
-      if(destCb->connUp & (ret != ROK))
+      if(assocCb->connUp & (ret != ROK))
       {
-         destCb->bReadFdSet = RFAILED;
+         assocCb->bReadFdSet = RFAILED;
       }
       else
       {
          if(((pollParams->flag & CM_INET_SCTP_MSG_NOTIFICATION) != 0) && (ret == ROK))
          {
-            ret = sctpNtfyHdlr(destCb, &pollParams->ntfy);
+            ret = sctpNtfyHdlr(assocCb, &pollParams->ntfy);
             if(ret != ROK)
             {
                DU_LOG("\nERROR  -->  SCTP : Failed to process sctp notify msg\n");
             }
          }
-         else if(destCb->connUp & (pollParams->port == destCb->destPort))
+         else if(assocCb->connUp)
          {  
-            F1APMsgHdlr(&destCb->duId, pollParams->mBuf);
+            F1APMsgHdlr(&assocCb->duId, pollParams->mBuf);
             ODU_PUT_MSG_BUF(pollParams->mBuf);
          }
          else
@@ -540,7 +548,7 @@ uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpDestCb *destCb, uin
  * ****************************************************************/
 uint8_t sctpSend(uint32_t duId, Buffer *mBuf)
 {
-   uint8_t          ret = ROK, destIdx = 0;
+   uint8_t          ret = ROK, assocIdx = 0;
    MsgLen           len = 0;          /* number of actually sent octets */
    CmInetMemInfo    memInfo;                        
   
@@ -548,12 +556,12 @@ uint8_t sctpSend(uint32_t duId, Buffer *mBuf)
    memInfo.region = CU_APP_MEM_REG;               
    memInfo.pool   = CU_POOL;
 
-   for(destIdx=0; destIdx < sctpCb.numDu; destIdx++)
+   for(assocIdx=0; assocIdx < sctpCb.numAssoc; assocIdx++)
    {
-      if(sctpCb.destCb[destIdx].duId == duId)
+      if(sctpCb.assocCb[assocIdx].duId == duId)
       {
-         ret = cmInetSctpSendMsg(&sctpCb.destCb[destIdx].sockFd, &sctpCb.destCb[destIdx].destIpNetAddr, \
-                  sctpCb.destCb[destIdx].destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
+         ret = cmInetSctpSendMsg(&sctpCb.assocCb[assocIdx].sockFd, &sctpCb.assocCb[assocIdx].destIpNetAddr, \
+                  sctpCb.assocCb[assocIdx].destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
 
          if(ret != ROK && ret != RWOULDBLOCK)
          {
index ed09e27..548c29a 100644 (file)
@@ -23,7 +23,8 @@
 
 #define MAX_RETRY 5
 #define MAX_IPV6_LEN 16
-#define MAX_DU_SUPPORTED 1
+#define MAX_DU_SUPPORTED 2
+#define MAX_ASSOC_SUPPORTED MAX_DU_SUPPORTED
 
 /* Global variable declaration */
 uint8_t   socket_type;      /* Socket type */
@@ -45,16 +46,13 @@ typedef struct
 {
    uint32_t         duId;
    uint16_t         destPort;         /* DU PORTS */
-   uint16_t         srcPort;
    Bool             bReadFdSet;
    CmInetFd         sockFd;           /* Socket file descriptor */
    CmInetAddr       peerAddr;
-   CmInetFd         lstnSockFd;       /* Listening Socket file descriptor */
    CmInetNetAddrLst destAddrLst;      /* DU Ip address */
-   CmInetNetAddrLst localAddrLst;
    CmInetNetAddr    destIpNetAddr;    /* DU Ip address */ 
    Bool             connUp;           /* Is connection up */
-}CuSctpDestCb;
+}CuSctpAssocCb;
 
 typedef struct ipAddr
 {
@@ -64,25 +62,27 @@ typedef struct ipAddr
  uint8_t   ipV6Addr[MAX_IPV6_LEN];
 }SctpIpAddr;
 
-typedef struct sctpAssocInfo
+typedef struct sctpDestInfo
 {
-   SctpIpAddr  duIpAddr;
-   uint16_t    duPort;
-   SctpIpAddr  cuIpAddr;
-   uint16_t    cuPort;
-}SctpAssocInfo;
+   SctpIpAddr  destIpAddr;
+   uint16_t    destPort;
+}SctpDestInfo;
 
 typedef struct cuSctpParams
 {
-   uint8_t        numDu;
-   SctpAssocInfo  sctpAssoc[MAX_DU_SUPPORTED];
+   SctpIpAddr     localIpAddr;
+   uint16_t       f1SctpPort;
+   uint8_t        numDestNode;
+   SctpDestInfo   destCb[MAX_DU_SUPPORTED];
 }CuSctpParams;
 
 typedef struct
 {
-   CuSctpParams sctpCfg;
-   uint8_t      numDu;
-   CuSctpDestCb destCb[MAX_DU_SUPPORTED]; 
+   CuSctpParams     sctpCfg;
+   CmInetNetAddrLst localAddrLst;
+   CmInetFd         f1LstnSockFd;       /* Listening Socket file descriptor for F1 association */
+   uint8_t          numAssoc;
+   CuSctpAssocCb    assocCb[MAX_ASSOC_SUPPORTED];
 }SctpGlobalCb;
 
 SctpGlobalCb sctpCb;
@@ -96,8 +96,8 @@ uint8_t fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr);
 uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);
 uint8_t sctpSetSockOpts(CmInetFd *sock_Fd);
 uint8_t sctpSockPoll();
-uint8_t sctpAccept(CuSctpDestCb *destCb);
-uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
+uint8_t sctpAccept(CuSctpAssocCb *assocCb);
+uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpAssocCb *assocCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
 #endif
 
 /**********************************************************************
index c8bb7ed..8392ff4 100644 (file)
@@ -444,8 +444,8 @@ uint8_t fillDuPort(uint16_t *duPort)
    duPort[F1_INTERFACE]   = g_cfg.DU_Port;
    duPort[E2_INTERFACE]   = g_cfg.RIC_Port;
 #else
-   duPort[F1_INTERFACE]   = DU_PORT;     /* DU Port idx  0 38472 */
-   duPort[E2_INTERFACE]   = RIC_PORT;    /* RIC Port idx 1 38482 */
+   duPort[F1_INTERFACE]   = F1_SCTP_PORT;     /* DU Port idx  0 38472 */
+   duPort[E2_INTERFACE]   = E2_SCTP_PORT;    /* RIC Port idx 1 38482 */
 #endif
    return ROK;
 }
@@ -699,8 +699,8 @@ uint8_t readCfg()
    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
 
-   duCfgParam.sctpParams.cuPort = CU_PORT;
-   duCfgParam.sctpParams.ricPort = RIC_PORT;
+   duCfgParam.sctpParams.cuPort = F1_SCTP_PORT;
+   duCfgParam.sctpParams.ricPort = E2_SCTP_PORT;
 #endif
 
    fillDuPort(duCfgParam.sctpParams.duPort);
index e4c99f8..2d197b5 100644 (file)
@@ -31,9 +31,9 @@
 #define DU_IP_V4_ADDR "192.168.130.81"
 #define CU_IP_V4_ADDR "192.168.130.82"
 #define RIC_IP_V4_ADDR "192.168.130.80"
-#define DU_PORT 38472
-#define CU_PORT 38472
-#define RIC_PORT 36421
+
+#define F1_SCTP_PORT 38472
+#define E2_SCTP_PORT 36421
 #endif
 
 #define DU_EGTP_PORT  39001
index b810dda..c372278 100644 (file)
@@ -50,7 +50,7 @@
 *
 * ****************************************************************/
 
-uint8_t SendE2APMsg(Region region, Pool pool)
+uint8_t SendE2APMsg(Region region, Pool pool, uint32_t duId)
 {
    Buffer *mBuf;
 
@@ -60,7 +60,7 @@ uint8_t SendE2APMsg(Region region, Pool pool)
       {
          ODU_PRINT_MSG(mBuf, 0,0);
  
-         if(sctpSend(mBuf) != ROK)
+         if(sctpSend(duId, mBuf) != ROK)
          {
             DU_LOG("\nERROR  -->  E2AP : SCTP Send for E2  failed");
             ODU_PUT_MSG_BUF(mBuf);
@@ -109,7 +109,7 @@ uint8_t BuildGlobalRicId(GlobalRIC_ID_t *ricId)
    {
       ricId->pLMN_Identity.size = byteSize * sizeof(uint8_t);
       RIC_ALLOC(ricId->pLMN_Identity.buf,  ricId->pLMN_Identity.size);
-      buildPlmnId(ricCfgParams.plmn , ricId->pLMN_Identity.buf);
+      buildPlmnId(ricCb.ricCfgParams.plmn , ricId->pLMN_Identity.buf);
       /* fill ric Id */
       ricId->ric_ID.size = byteSize * sizeof(uint8_t);
       RIC_ALLOC(ricId->ric_ID.buf, ricId->ric_ID.size);
@@ -245,7 +245,7 @@ uint8_t BuildE2nodeComponentConfigAdditionAck(E2nodeComponentConfigAdditionAck_L
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t BuildAndSendE2SetupRsp(uint8_t duId)
+uint8_t BuildAndSendE2SetupRsp(uint32_t duId)
 {
    E2AP_PDU_t         *e2apMsg = NULL;
    E2setupResponse_t  *e2SetupRsp;
@@ -357,7 +357,7 @@ uint8_t BuildAndSendE2SetupRsp(uint8_t duId)
          } 
       }
 
-      if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL) != ROK)
+      if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duId) != ROK)
       {
          DU_LOG("\nERROR  -->  E2AP : Sending E2 Setup Response failed");      
          break;   
@@ -366,6 +366,7 @@ uint8_t BuildAndSendE2SetupRsp(uint8_t duId)
    }
 
    FreeE2SetupRsp(e2apMsg);
+   BuildAndSendRicSubscriptionReq(duId);
    return ROK;
 }
 
@@ -478,7 +479,7 @@ uint8_t BuildRicSubsDetails(RICsubscriptionDetails_t *subsDetails)
       uint8_t byteSize = 3;
       subsDetails->ricEventTriggerDefinition.size = byteSize * sizeof(uint8_t);
       RIC_ALLOC(subsDetails->ricEventTriggerDefinition.buf,  subsDetails->ricEventTriggerDefinition.size);
-      buildPlmnId(ricCfgParams.plmn, subsDetails->ricEventTriggerDefinition.buf);
+      buildPlmnId(ricCb.ricCfgParams.plmn, subsDetails->ricEventTriggerDefinition.buf);
       elementCnt = 1;
       subsDetails->ricAction_ToBeSetup_List.list.count = elementCnt;
       subsDetails->ricAction_ToBeSetup_List.list.size = \
@@ -512,7 +513,7 @@ uint8_t BuildRicSubsDetails(RICsubscriptionDetails_t *subsDetails)
  *
  ******************************************************************/
 
-uint8_t BuildAndSendRicSubscriptionReq()
+uint8_t BuildAndSendRicSubscriptionReq(uint32_t duId)
 {
 
    E2AP_PDU_t                 *e2apRicMsg = NULL;
@@ -522,7 +523,6 @@ uint8_t BuildAndSendRicSubscriptionReq()
    uint8_t         ieId;
    uint8_t         ret; 
    asn_enc_rval_t  encRetVal;        /* Encoder return value */
-   ricCfgParams.ricSubsStatus = TRUE;
 
    DU_LOG("\nINFO   -->  E2AP : Building RIC Subscription Request\n");
 
@@ -636,7 +636,7 @@ uint8_t BuildAndSendRicSubscriptionReq()
 
 
    /* Sending msg */
-   if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL) != ROK)
+   if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duId) != ROK)
    {
       DU_LOG("\nERROR  -->  E2AP : Sending RIC subscription Request failed");
       return RFAILED;
@@ -645,6 +645,32 @@ uint8_t BuildAndSendRicSubscriptionReq()
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Process RicSubscriptionResponse
+ *
+ * @details
+ *
+ *    Function : ProcRicSubscriptionRsp
+ *
+ * Functionality: Processes RicSubscriptionRsp
+ *
+ * @return ROK     - void
+ *
+ ******************************************************************/
+
+void ProcRicSubscriptionResponse(uint32_t duId)
+{
+   uint8_t duIdx = 0;
+   DuDb *duDb;
+
+   DU_LOG("\nINFO  -->  E2AP : RICsubscriptionResponse Msg Acknowledged");
+
+   SEARCH_DU_DB(duIdx, duId, duDb);
+   if(duDb)
+      duDb->ricSubscribedToDu = true;
+}
+
 /*******************************************************************
  *
  * @brief process the e2setup request 
@@ -660,9 +686,10 @@ uint8_t BuildAndSendRicSubscriptionReq()
  *
  ******************************************************************/
 
-uint8_t ProcE2SetupReq(E2setupRequest_t  *e2SetupReq)
+uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t  *e2SetupReq)
 {
-   uint8_t arrIdx = 0, e2NodeAddListIdx =0;;
+   uint8_t arrIdx = 0, e2NodeAddListIdx =0, duIdx = 0;
+   DuDb    *duDb = NULLP;
    E2nodeComponentConfigAddition_List_t *e2NodeAddList;
    E2nodeComponentConfigAddition_ItemIEs_t *e2NodeAddItem;
 
@@ -686,13 +713,24 @@ uint8_t ProcE2SetupReq(E2setupRequest_t  *e2SetupReq)
                               if(e2NodeAddList->list.array[e2NodeAddListIdx])
                               {
                                  e2NodeAddItem = (E2nodeComponentConfigAddition_ItemIEs_t *) e2NodeAddList->list.array[e2NodeAddListIdx];
-                                 if(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1)
+                                 if(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
+                                    e2nodeComponentInterfaceTypeF1)
                                  {
-                                    if(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.e2nodeComponentInterfaceTypeF1->\
-                                    gNB_DU_ID.buf)
+                                    if(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
+                                       e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf)
                                     {
-                                       if(BuildAndSendE2SetupRsp(e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.choice.\
-                                       e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf[0]) !=ROK)
+                                       *duId = e2NodeAddItem->value.choice.E2nodeComponentConfigAddition_Item.e2nodeComponentID.\
+                                               choice.e2nodeComponentInterfaceTypeF1->gNB_DU_ID.buf[0];
+                                       SEARCH_DU_DB(duIdx, duId, duDb); 
+                                       if(duDb == NULLP)
+                                       {
+                                          duDb = &ricCb.duInfo[ricCb.numDu];
+                                          ricCb.numDu++;
+                                       }
+                                       memset(duDb, 0, sizeof(DuDb));
+                                       duDb->duId = *duId;
+
+                                       if(BuildAndSendE2SetupRsp(*duId) !=ROK)
                                        {
                                            DU_LOG("\nERROR  -->  E2AP : Failed to build and send E2 setup response");
                                            return RFAILED;
@@ -769,7 +807,7 @@ void FreeE2NodeConfigUpdateAck(E2AP_PDU_t *e2apMsg)
  *
  * ****************************************************************/
 
-uint8_t BuildAndSendE2NodeConfigUpdateAck()
+uint8_t BuildAndSendE2NodeConfigUpdateAck(uint32_t duId)
 {
    uint8_t arrIdx = 0,elementCnt = 1;
    uint8_t ret = ROK;
@@ -853,7 +891,7 @@ uint8_t BuildAndSendE2NodeConfigUpdateAck()
 
 
       /* Sending msg */
-      if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL) != ROK)
+      if(SendE2APMsg(RIC_APP_MEM_REG, RIC_POOL, duId) != ROK)
       {
          DU_LOG("\nERROR  -->  E2AP : Failed to send E2 Node config update ack ");
          return RFAILED;
@@ -883,7 +921,7 @@ uint8_t BuildAndSendE2NodeConfigUpdateAck()
 *         RFAILED - failure
 *
 * ****************************************************************/
-void E2APMsgHdlr(Buffer *mBuf)
+void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf)
 {
    int             i;
    char            *recvBuf;
@@ -941,13 +979,13 @@ void E2APMsgHdlr(Buffer *mBuf)
             case InitiatingMessageE2__value_PR_E2setupRequest:
             {
                DU_LOG("\nINFO  -->  E2AP : E2 setup request received");
-               ProcE2SetupReq(&e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest);
+               ProcE2SetupReq(duId, &e2apMsg->choice.initiatingMessage->value.choice.E2setupRequest);
                    break;
             }
             case InitiatingMessageE2__value_PR_E2nodeConfigurationUpdate:
             {
                DU_LOG("\nINFO  -->  E2AP : E2 node config update received");
-               BuildAndSendE2NodeConfigUpdateAck();
+               BuildAndSendE2NodeConfigUpdateAck(*duId);
                break;
             }
             case InitiatingMessageE2__value_PR_RICindication:
@@ -969,7 +1007,7 @@ void E2APMsgHdlr(Buffer *mBuf)
          {
             case SuccessfulOutcomeE2__value_PR_RICsubscriptionResponse:  
             {
-               DU_LOG("\nINFO  -->  E2AP : RICsubscriptionResponse Msg Acknowledged");
+               ProcRicSubscriptionResponse(*duId);
                break;
             }
             default:
@@ -988,10 +1026,6 @@ void E2APMsgHdlr(Buffer *mBuf)
       }
  
     }/* End of switch(e2apMsg->present) */
-
-    if(!ricCfgParams.ricSubsStatus)
-      BuildAndSendRicSubscriptionReq(); 
-       
 } /* End of E2APMsgHdlr */
 
 
index 6f54f0d..15caa79 100644 (file)
 
 
 
-void E2APMsgHdlr(Buffer *mBuf);
-uint8_t BuildAndSendE2SetupRsp(uint8_t duId);
-uint8_t SendE2APMsg(Region , Pool );
+void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf);
+uint8_t BuildAndSendE2SetupRsp(uint32_t duId);
+uint8_t BuildAndSendRicSubscriptionReq(uint32_t duId);
+uint8_t SendE2APMsg(Region region, Pool pool, uint32_t duId);
 
 /**********************************************************************
          End of file
index 200e27d..6903071 100644 (file)
@@ -112,8 +112,8 @@ void readRicCfg()
 
    DU_LOG("\nINFO  --> RIC : Reading RIC configurations");
 
-   ricCfgParams.ricId = RIC_ID;
-   strcpy(ricCfgParams.ricName, RIC_NAME);
+   ricCb.ricCfgParams.ricId = RIC_ID;
+   strcpy(ricCb.ricCfgParams.ricName, RIC_NAME);
 #ifdef O1_ENABLE
    if( getStartupConfigForStub(&g_cfg) != ROK )
    {
@@ -125,45 +125,46 @@ void readRicCfg()
    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr,  &ipv4_du);
    cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
    
-   ricCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV4Addr = ipv4_du;
-   ricCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV6Pres = false;
-   ricCfgParams.sctpParams.sctpAssoc[0].duPort = g_cfg.RIC_Port;
+   ricCb.ricCfgParams.sctpParams.destCb[0].destIpAddr.ipV4Addr = ipv4_du;
+   ricCb.ricCfgParams.sctpParams.destCb[0].destIpAddr.ipV6Pres = false;
+   ricCb.ricCfgParams.sctpParams.destCb[0].destPort = g_cfg.RIC_Port;
 
-   ricCfgParams.sctpParams.sctpAssoc[0].ricIpAddr.ipV4Addr = ipv4_ric;
-   ricCfgParams.sctpParams.sctpAssoc[0].ricIpAddr.ipV6Pres = false;
-   ricCfgParams.sctpParams.sctpAssoc[0].ricPort = g_cfg.RIC_Port;
+   ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_ric;
+   ricCb.ricCfgParams.sctpParams.localIpAddr.ipV6Pres = false;
+   ricCb.ricCfgParams.sctpParams.e2SctpPort = g_cfg.RIC_Port;
 
-   ricCfgParams.sctpParams.numDu = 1;
+   ricCb.ricCfgParams.sctpParams.numDestNode = 1;
 
 #else
-   ricCfgParams.sctpParams.numDu = 0;
-   numDu = &ricCfgParams.sctpParams.numDu;
-   while(*numDu < MAX_DU_SUPPORTED)
+   /* RIC IP Address and Port*/
+   memset(&ipv4_du, 0, sizeof(uint32_t));
+   cmInetAddr((S8*)LOCAL_IP_RIC, &ipv4_ric);
+   ricCb.ricCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_ric;
+   ricCb.ricCfgParams.sctpParams.localIpAddr.ipV6Pres = false;
+   ricCb.ricCfgParams.sctpParams.e2SctpPort = E2_SCTP_PORT;
+
+   ricCb.ricCfgParams.sctpParams.numDestNode = 0;
+   numDu = &ricCb.ricCfgParams.sctpParams.numDestNode;
+   while(*numDu < NUM_E2_ASSOC)
    {   
       /* DU IP Address and Port*/
       memset(&ipv4_du, 0, sizeof(uint32_t));
-      cmInetAddr((S8*)DU_IP_V4_ADDR[*numDu], &ipv4_du);
-      ricCfgParams.sctpParams.sctpAssoc[*numDu].duIpAddr.ipV4Addr = ipv4_du;
-      ricCfgParams.sctpParams.sctpAssoc[*numDu].duIpAddr.ipV6Pres = false;
-      ricCfgParams.sctpParams.sctpAssoc[*numDu].duPort = DU_SCTP_PORT[*numDu];
+      cmInetAddr((S8*)REMOTE_IP_DU[*numDu], &ipv4_du);
+      ricCb.ricCfgParams.sctpParams.destCb[*numDu].destIpAddr.ipV4Addr = ipv4_du;
+      ricCb.ricCfgParams.sctpParams.destCb[*numDu].destIpAddr.ipV6Pres = false;
+      ricCb.ricCfgParams.sctpParams.destCb[*numDu].destPort = E2_SCTP_PORT;
 
-      /* RIC IP Address and Port*/
-      memset(&ipv4_du, 0, sizeof(uint32_t));
-      cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
-      ricCfgParams.sctpParams.sctpAssoc[*numDu].ricIpAddr.ipV4Addr = ipv4_ric;
-      ricCfgParams.sctpParams.sctpAssoc[*numDu].ricIpAddr.ipV6Pres = false;
-      ricCfgParams.sctpParams.sctpAssoc[*numDu].ricPort = RIC_SCTP_PORT_TO_DU[*numDu];
       (*numDu)++;
    }   
 #endif
 
    /*PLMN*/
-   ricCfgParams.plmn.mcc[0] = PLMN_MCC0;
-   ricCfgParams.plmn.mcc[1] = PLMN_MCC1;
-   ricCfgParams.plmn.mcc[2] = PLMN_MCC2;
-   ricCfgParams.plmn.mnc[0] = PLMN_MNC0;
-   ricCfgParams.plmn.mnc[1] = PLMN_MNC1;
-   ricCfgParams.plmn.mnc[2] = PLMN_MNC2;
+   ricCb.ricCfgParams.plmn.mcc[0] = PLMN_MCC0;
+   ricCb.ricCfgParams.plmn.mcc[1] = PLMN_MCC1;
+   ricCb.ricCfgParams.plmn.mcc[2] = PLMN_MCC2;
+   ricCb.ricCfgParams.plmn.mnc[0] = PLMN_MNC0;
+   ricCb.ricCfgParams.plmn.mnc[1] = PLMN_MNC1;
+   ricCb.ricCfgParams.plmn.mnc[2] = PLMN_MNC2;
   
 } /* End of readCuCfg */
 /**********************************************************************
index b41e9c6..a621525 100644 (file)
 #define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
 
 #ifndef O1_ENABLE
-#define DU_IP_V4_ADDR (char*[]){"192.168.130.81", "192.168.130.83"}
-#define DU_SCTP_PORT (int[]){36421, 36422}
+#define LOCAL_IP_RIC "192.168.130.80"
 
-#define RIC_IP_V4_ADDR "192.168.130.80"
-#define RIC_SCTP_PORT_TO_DU (int[]){36421, 36422}
+#define E2_SCTP_PORT 36421
+#define NUM_E2_ASSOC 1
+#define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"}
 #endif
 
 #define RRC_VER 0
    SPutSBuf(RIC_APP_MEM_REG, RIC_POOL,                         \
          (Data *)_datPtr, _size);
 
+#define SEARCH_DU_DB(_duIdx, _duId, _duDb){\
+   _duDb = NULLP; \
+   for(_duIdx=0; _duIdx < ricCb.numDu; _duIdx++)\
+   {\
+      if(ricCb.duInfo[_duIdx].duId == _duId)\
+      {\
+         _duDb =  (&ricCb.duInfo[_duIdx]);\
+         break; \
+     }\
+   }\
+}
+
+typedef struct duDb
+{
+   uint32_t duId;
+   Bool     ricSubscribedToDu;
+}DuDb;
+
 typedef struct ricCfgParams
 {
    uint32_t        ricId;
    char            ricName[RIC_DU_NAME_LEN_MAX];
    RicSctpParams   sctpParams;
    Plmn            plmn;
-   Bool            ricSubsStatus;
 }RicCfgParams;
-RicCfgParams ricCfgParams; //global variable to hold all configs
+
+typedef struct cuGlobalCb
+{
+   RicCfgParams ricCfgParams;
+   uint8_t      numDu;
+   DuDb         duInfo[MAX_DU_SUPPORTED];
+}RicGlobalCb;
+
+RicGlobalCb ricCb;
 
 void readRicCfg();
 void cuAppInmsgHdlr(Buffer *mBuf);
index 662087c..e8737f4 100644 (file)
 
 uint8_t sctpCfgReq()
 {
-   int destIdx;
+   int destIdx = 0, assocIdx = 0;
 
-   sctpCb.sctpCfg = ricCfgParams.sctpParams;   
-   for(destIdx=0; destIdx < sctpCb.sctpCfg.numDu; destIdx++)
+   sctpCb.sctpCfg = ricCb.ricCfgParams.sctpParams;   
+   fillAddrLst(&sctpCb.localAddrLst, &sctpCb.sctpCfg.localIpAddr);
+   memset(&sctpCb.e2LstnSockFd, -1, sizeof(CmInetFd));
+   for(destIdx=0; destIdx < sctpCb.sctpCfg.numDestNode; destIdx++)
    {   
-      sctpCb.destCb[destIdx].destPort = sctpCb.sctpCfg.sctpAssoc[destIdx].duPort;
-      sctpCb.destCb[destIdx].srcPort  = sctpCb.sctpCfg.sctpAssoc[destIdx].ricPort;
-      sctpCb.destCb[destIdx].bReadFdSet = ROK;
-      memset(&sctpCb.destCb[destIdx].sockFd, -1, sizeof(CmInetFd));
-      memset(&sctpCb.destCb[destIdx].lstnSockFd, -1, sizeof(CmInetFd));
-      fillDestNetAddr(&sctpCb.destCb[destIdx].destIpNetAddr, &sctpCb.sctpCfg.sctpAssoc[destIdx].duIpAddr);
-      fillAddrLst(&sctpCb.destCb[destIdx].localAddrLst, &sctpCb.sctpCfg.sctpAssoc[destIdx].ricIpAddr);
-      sctpCb.destCb[destIdx].connUp = false;
+      sctpCb.assocCb[assocIdx].destPort = sctpCb.sctpCfg.destCb[destIdx].destPort;
+      sctpCb.assocCb[assocIdx].bReadFdSet = ROK;
+      memset(&sctpCb.assocCb[assocIdx].sockFd, -1, sizeof(CmInetFd));
+      fillDestNetAddr(&sctpCb.assocCb[assocIdx].destIpNetAddr, &sctpCb.sctpCfg.destCb[destIdx].destIpAddr);
+      sctpCb.assocCb[assocIdx].connUp = false;
+      assocIdx++;
    }   
-   sctpCb.numDu = sctpCb.sctpCfg.numDu;
+   sctpCb.numAssoc = assocIdx;
    return ROK;
 }
 
@@ -130,34 +130,51 @@ uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
 
 uint8_t sctpStartReq()
 {
-   uint8_t destIdx  = 0;
+   uint8_t assocIdx  = 0;
    uint8_t ret = ROK;
 
    socket_type = CM_INET_STREAM;
 
-   for(destIdx=0; destIdx < sctpCb.numDu; destIdx++)
+   if(sctpCb.numAssoc)
    {
-      if((ret = cmInetSocket(socket_type, &sctpCb.destCb[destIdx].lstnSockFd, IPPROTO_SCTP) != ROK))
+
+      if((ret = cmInetSocket(socket_type, &sctpCb.e2LstnSockFd, IPPROTO_SCTP) != ROK))
       {
-         DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", sctpCb.destCb[destIdx].lstnSockFd.fd);
+         DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", sctpCb.e2LstnSockFd.fd);
       } 
-      else if((ret = cmInetSctpBindx(&sctpCb.destCb[destIdx].lstnSockFd, &sctpCb.destCb[destIdx].localAddrLst, \
-         sctpCb.destCb[destIdx].srcPort)) != ROK)
+      else if((ret = cmInetSctpBindx(&sctpCb.e2LstnSockFd, &sctpCb.localAddrLst, sctpCb.sctpCfg.e2SctpPort)) != ROK)
       {
          DU_LOG("\nERROR  -->  SCTP: Binding failed at RIC");
       }
-      else if((ret = sctpAccept(&sctpCb.destCb[destIdx])) != ROK)
+      else if(ret = cmInetListen(&sctpCb.e2LstnSockFd, 1) != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at CU");
+         DU_LOG("\nERROR  -->  SCTP : Listening on socket failed");
+         cmInetClose(&sctpCb.e2LstnSockFd);
+         return RFAILED;
+      }
+      else
       {
-         DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at RIC");
+         for(assocIdx=0; assocIdx < sctpCb.numAssoc; assocIdx++)
+         {
+            if((ret = sctpAccept(&sctpCb.assocCb[assocIdx])) != ROK)
+            {
+               DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at RIC");
+            }
+         }
       }
    }
 
-   if(sctpSockPoll() != ROK)
+   if(ret == ROK)
    {
-      DU_LOG("\nERROR  -->  SCTP: Polling failed to start at RIC");
+      if(sctpSockPoll() != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCTP: Polling failed to start at RIC");
+      }
    }
    return (ret);
 }
+
 /*******************************************************************
  *
  * @brief Sets socket options as per requirement
@@ -213,23 +230,15 @@ uint8_t sctpSetSockOpts(CmInetFd *sock_Fd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t sctpAccept(RicSctpDestCb *destCb)
+uint8_t sctpAccept(RicSctpAssocCb *assocCb)
 {
    uint8_t  ret;
 
-   ret = cmInetListen(&destCb->lstnSockFd, 1);
-   if (ret != ROK)
-   {
-      DU_LOG("\nERROR   -->  SCTP : Listening on socket failed");
-      cmInetClose(&destCb->lstnSockFd);
-      return RFAILED;
-   }
-   
    DU_LOG("\nINFO   -->  SCTP : Connecting");
 
-   while(!destCb->connUp)
+   while(!assocCb->connUp)
    {
-      ret = cmInetAccept(&destCb->lstnSockFd, &destCb->peerAddr, &destCb->sockFd);
+      ret = cmInetAccept(&sctpCb.e2LstnSockFd, &assocCb->peerAddr, &assocCb->sockFd);
       if (ret == ROKDNA)
       {
          continue;
@@ -241,8 +250,8 @@ uint8_t sctpAccept(RicSctpDestCb *destCb)
       }
       else
       {
-         destCb->connUp = TRUE;
-         sctpSetSockOpts(&destCb->sockFd);
+         assocCb->connUp = TRUE;
+         sctpSetSockOpts(&assocCb->sockFd);
          break;
       }
    }
@@ -268,7 +277,7 @@ uint8_t sctpAccept(RicSctpDestCb *destCb)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t sctpNtfyHdlr(RicSctpDestCb *destCb, CmInetSctpNotification *ntfy)
+uint8_t sctpNtfyHdlr(RicSctpAssocCb *assocCb, CmInetSctpNotification *ntfy)
 {
    switch(ntfy->header.nType)
    {
@@ -278,23 +287,23 @@ uint8_t sctpNtfyHdlr(RicSctpDestCb *destCb, CmInetSctpNotification *ntfy)
          {
             case CM_INET_SCTP_COMM_UP:
                DU_LOG("\nINFO   -->  Event : COMMUNICATION UP");
-               destCb->connUp = TRUE;
+               assocCb->connUp = TRUE;
                break;
             case CM_INET_SCTP_COMM_LOST:
                DU_LOG("\nINFO   -->  Event : COMMUNICATION LOST");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_RESTART:
                DU_LOG("\nINFO   -->  Event : SCTP RESTART");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_SHUTDOWN_COMP: /* association gracefully shutdown */
                DU_LOG("\nINFO   -->  Event : SHUTDOWN COMPLETE");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_CANT_STR_ASSOC:
                DU_LOG("\nINFO   -->  Event : CANT START ASSOC");
-               destCb->connUp = FALSE;
+               assocCb->connUp = FALSE;
                break;
             default:
                DU_LOG("\nERROR   -->  Invalid event");
@@ -313,7 +322,7 @@ uint8_t sctpNtfyHdlr(RicSctpDestCb *destCb, CmInetSctpNotification *ntfy)
          break;
       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
          DU_LOG("\nINFO   -->  SCTP : Shutdown Event notification received\n");
-         destCb->connUp = FALSE;
+         assocCb->connUp = FALSE;
          exit(0);
          break;
       case CM_INET_SCTP_ADAPTATION_INDICATION :
@@ -349,7 +358,7 @@ uint8_t sctpNtfyHdlr(RicSctpDestCb *destCb, CmInetSctpNotification *ntfy)
  * ****************************************************************/
 uint8_t sctpSockPoll()
 {
-   uint8_t            destIdx;
+   uint8_t            assocIdx;
    uint16_t           ret = ROK;
    uint32_t           timeout;
    uint32_t           *timeoutPtr;
@@ -370,10 +379,9 @@ uint8_t sctpSockPoll()
    while(1)
    {
       /* Receiving SCTP data */
-      for(destIdx = 0; destIdx < sctpCb.numDu; destIdx++)
+      for(assocIdx = 0; assocIdx < sctpCb.numAssoc; assocIdx++)
       {
-
-         if((ret = processPolling(&e2PollParams, &sctpCb.destCb[destIdx], timeoutPtr, &memInfo)) != ROK)
+         if((ret = processPolling(&e2PollParams, &sctpCb.assocCb[assocIdx], timeoutPtr, &memInfo)) != ROK)
          {
             DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for E2 at RIC \n");
          }
@@ -406,34 +414,34 @@ uint8_t sctpSockPoll()
  * ****************************************************************/
 
  
-uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
+uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpAssocCb *assocCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
 {
    uint16_t ret = ROK;
 
-   CM_INET_FD_SET(&destCb->sockFd, &pollParams->readFd);
+   CM_INET_FD_SET(&assocCb->sockFd, &pollParams->readFd);
    ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFd);
-   if(CM_INET_FD_ISSET(&destCb->sockFd, &pollParams->readFd))
+   if(CM_INET_FD_ISSET(&assocCb->sockFd, &pollParams->readFd))
    {
-      CM_INET_FD_CLR(&destCb->sockFd, &pollParams->readFd);
-      ret = cmInetSctpRecvMsg(&destCb->sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, \
+      CM_INET_FD_CLR(&assocCb->sockFd, &pollParams->readFd);
+      ret = cmInetSctpRecvMsg(&assocCb->sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, \
           &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy);
-      if(destCb->connUp & (ret != ROK))
+      if(assocCb->connUp & (ret != ROK))
       {
-         destCb->bReadFdSet = RFAILED;
+         assocCb->bReadFdSet = RFAILED;
       }
       else
       {
          if(((pollParams->flag & CM_INET_SCTP_MSG_NOTIFICATION) != 0) && (ret == ROK))
          {
-            ret = sctpNtfyHdlr(destCb, &pollParams->ntfy);
+            ret = sctpNtfyHdlr(assocCb, &pollParams->ntfy);
             if(ret != ROK)
             {
                DU_LOG("\nERROR  -->  SCTP : Failed to process sctp notify msg\n");
             }
          }
-         else if(destCb->connUp & (pollParams->port == destCb->destPort))
+         else if(assocCb->connUp)
          {  
-            E2APMsgHdlr(pollParams->mBuf);
+            E2APMsgHdlr(&assocCb->duId, pollParams->mBuf);
             ODU_PUT_MSG_BUF(pollParams->mBuf);
          }
          else
@@ -461,8 +469,9 @@ uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpDestCb *destCb, ui
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t sctpSend(Buffer *mBuf)
+uint8_t sctpSend(uint32_t duId, Buffer *mBuf)
 {
+   uint8_t          assocIdx;
    uint8_t          ret;
    MsgLen           len;          /* number of actually sent octets */
    CmInetMemInfo    memInfo;                        
@@ -470,15 +479,20 @@ uint8_t sctpSend(Buffer *mBuf)
    memInfo.region = RIC_APP_MEM_REG;               
    memInfo.pool   = RIC_POOL;
 
-   ret = cmInetSctpSendMsg(&sctpCb.destCb[0].sockFd, &sctpCb.destCb[0].destIpNetAddr, sctpCb.destCb[0].destPort, &memInfo, \
-      mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
-
-   if(ret != ROK && ret != RWOULDBLOCK)
+   for(assocIdx = 0; assocIdx < sctpCb.numAssoc; assocIdx++)
    {
-      DU_LOG("\nERROR  -->  SCTP : Send message failed");
-      return RFAILED;
-   }
+      if(sctpCb.assocCb[assocIdx].duId == duId)
+      {
+         ret = cmInetSctpSendMsg(&sctpCb.assocCb[assocIdx].sockFd, &sctpCb.assocCb[assocIdx].destIpNetAddr, \
+               sctpCb.assocCb[assocIdx].destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
 
+         if(ret != ROK && ret != RWOULDBLOCK)
+         {
+            DU_LOG("\nERROR  -->  SCTP : Send message failed");
+            return RFAILED;
+         }
+      }
+   }
    return ROK;
 } /* End of sctpSend */
 /**********************************************************************
index 37da878..9f9a8fe 100644 (file)
@@ -23,7 +23,8 @@
 
 #define MAX_RETRY 5
 #define MAX_IPV6_LEN 16
-#define MAX_DU_SUPPORTED 1 
+#define MAX_DU_SUPPORTED 2
+#define MAX_ASSOC_SUPPORTED MAX_DU_SUPPORTED
 
 /* Global variable declaration */
 uint8_t   socket_type;      /* Socket type */
@@ -43,17 +44,15 @@ typedef struct
 
 typedef struct
 {
+   uint32_t              duId;
    uint16_t              destPort;         /* DU PORTS */
-   uint16_t              srcPort;
    bool                  bReadFdSet;
    CmInetFd              sockFd;           /* Socket file descriptor */
    CmInetAddr            peerAddr;
-   CmInetFd              lstnSockFd;       /* Listening Socket file descriptor */
    CmInetNetAddrLst      destAddrLst;      /* DU Ip address */
-   CmInetNetAddrLst      localAddrLst;
    CmInetNetAddr         destIpNetAddr;    /* DU Ip address */ 
    Bool                  connUp;
-}RicSctpDestCb;
+}RicSctpAssocCb;
 
 typedef struct ipAddr
 {
@@ -63,37 +62,39 @@ typedef struct ipAddr
  uint8_t   ipV6Addr[MAX_IPV6_LEN];
 }SctpIpAddr;
 
-typedef struct sctpAssocInfo
+typedef struct sctpDestInfo
 {
-   SctpIpAddr  duIpAddr;
-   uint16_t    duPort;
-   SctpIpAddr  ricIpAddr;
-   uint16_t    ricPort;
-}SctpAssocInfo;
+   SctpIpAddr  destIpAddr;
+   uint16_t    destPort;
+}SctpDestInfo;
 
 typedef struct ricSctpParams
 {
-   uint8_t        numDu;
-   SctpAssocInfo  sctpAssoc[MAX_DU_SUPPORTED];
+   SctpIpAddr     localIpAddr;
+   uint16_t       e2SctpPort;
+   uint8_t        numDestNode;
+   SctpDestInfo   destCb[MAX_DU_SUPPORTED];
 }RicSctpParams;
 
 typedef struct sctpGlobalCb
 {
-   RicSctpParams sctpCfg;
-   uint8_t      numDu;
-   RicSctpDestCb destCb[MAX_DU_SUPPORTED]; 
+   RicSctpParams    sctpCfg;
+   CmInetNetAddrLst localAddrLst;
+   CmInetFd         e2LstnSockFd;       /* Listening Socket file descriptor for E2 association */
+   uint8_t          numAssoc;
+   RicSctpAssocCb   assocCb[MAX_ASSOC_SUPPORTED]; 
 }SctpGlobalCb;
 
 SctpGlobalCb sctpCb;
 
 uint8_t sctpActvInit();
-uint8_t sctpSend(Buffer *mBuf);
+uint8_t sctpSend(uint32_t duId, Buffer *mBuf);
 uint8_t sctpCfgReq();
 uint8_t sctpStartReq();
 uint8_t sctpSetSockOpts(CmInetFd *sock_Fd);
-uint8_t sctpAccept(RicSctpDestCb *destCb);
+uint8_t sctpAccept(RicSctpAssocCb *assocCb);
 uint8_t sctpSockPoll();
-uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
+uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpAssocCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
 uint8_t fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr);
 uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);