[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-414] Support at CU and RIC stub for SCTP... 63/7563/3
authorbarveankit <anbarve@radisys.com>
Mon, 17 Jan 2022 12:09:03 +0000 (17:39 +0530)
committerbarveankit <anbarve@radisys.com>
Tue, 18 Jan 2022 12:03:43 +0000 (17:33 +0530)
Signed-off-by: barveankit <anbarve@radisys.com>
Change-Id: I27dc27c7706a5fc9dc5923456d7c025d02156186
Signed-off-by: barveankit <anbarve@radisys.com>
14 files changed:
src/cu_stub/cu_f1ap_msg_hdl.c
src/cu_stub/cu_f1ap_msg_hdl.h
src/cu_stub/cu_stub.c
src/cu_stub/cu_stub.h
src/cu_stub/cu_stub_egtp.c
src/cu_stub/cu_stub_egtp.h
src/cu_stub/cu_stub_sctp.c
src/cu_stub/cu_stub_sctp.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 b4cc5c1..2317466 100644 (file)
 /* This file contains F1AP message handler functions */
 #include "common_def.h"
 #include "OCTET_STRING.h"
-#include "BIT_STRING.h"
-#include "odu_common_codec.h"
 #include "cu_stub_sctp.h"
+#include "cu_stub_egtp.h"
 #include "cu_f1ap_msg_hdl.h"
-#include "legtp.h"
-/*header files needed for Ue Context Setup */
-#include<ProtocolIE-Field.h>
+#include "cu_stub.h"
+
+#include "BIT_STRING.h"
+#include "odu_common_codec.h"
+#include "ProtocolIE-Field.h"
 #include "ProtocolExtensionField.h"
 #include "ProtocolIE-SingleContainer.h"
 #include "F1AP-PDU.h"
 #include "UPTransportLayerInformation.h"
 #include "GTPTunnel.h"
 #include "QoSInformation.h"
+#include "Cells-to-be-Activated-List.h"
+#include "DL-CCCH-Message.h"
+#include "SRB-ToAddModList.h"
+#include "SRB-ToAddMod.h"
+#include "RRCSetup-IEs.h"
+#include "RRCSetup.h"
+#include "DL-DCCH-Message.h"
+#include "RRCReconfiguration-IEs.h"
+#include "RRCReconfiguration.h"
+#include "DRB-ToAddModList.h"
+#include "DRB-ToAddMod.h"
+#include "SDAP-Config.h"
 
 /* MACRO for CUtoDURRCInformation */
 #define CELL_GRP_ID 1
index 8eb0cb5..35d56db 100644 (file)
 *******************************************************************************/
 
 /* This file contains all F1AP message handler related functionality */
-#include <stdbool.h>
-#include <string.h>
-#include<ProtocolIE-Field.h>
-#include "ProtocolExtensionField.h"
-#include "F1AP-PDU.h"
-#include "Cells-to-be-Activated-List.h"
-#include "DL-CCCH-Message.h"
-#include "SRB-ToAddModList.h"
-#include "SRB-ToAddMod.h"
-#include "RRCSetup-IEs.h"
-#include "RRCSetup.h"
-#include "DL-DCCH-Message.h"
-#include "RRCReconfiguration-IEs.h"
-#include "RRCReconfiguration.h"
-#include "DRB-ToAddModList.h"
-#include "DRB-ToAddMod.h"
-#include "SDAP-Config.h"
-#include "du_log.h"
-#include "cu_stub.h"
-
 #define ENCODE_FAIL -1
 #define TRANS_ID 1
 #define RRC_SIZE 1
index 50ec5fc..9e9d3d2 100644 (file)
 
 /* This functions contains main() for cu_app */
 #include "common_def.h"
-#include "cu_stub.h"
 #include "cu_stub_sctp.h"
 #include "cu_stub_egtp.h"
-#include "du_log.h"
+#include "cu_stub.h"
 
 #ifdef O1_ENABLE
 #include "CmInterface.h"
 #endif
 
-#define CU_ID 1
-#define CU_NAME "ORAN_OAM_CU"
-
-#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
-#define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
-
-#ifndef O1_ENABLE
-
-#define DU_IP_V4_ADDR "192.168.130.81"
-#define CU_IP_V4_ADDR "192.168.130.82"
-#define DU_PORT 38472
-#define CU_PORT 38472 
-
-#endif
-
-#define DU_EGTP_PORT 39001
-#define CU_EGTP_PORT 39002
-#define RRC_VER 0
-#define EXT_RRC_VER 5
-#define PLMN_MCC0 3
-#define PLMN_MCC1 1
-#define PLMN_MCC2 1
-#define PLMN_MNC0 4
-#define PLMN_MNC1 8
-#define PLMN_MNC2 0
 
 #ifdef O1_ENABLE
 
@@ -160,10 +134,14 @@ uint8_t tst()
 
 void readCuCfg()
 {
+   uint8_t  *numDu;
    uint32_t ipv4_du, ipv4_cu;
 
    DU_LOG("\nDEBUG  -->  CU_STUB : Reading CU configurations");
 
+   cuCfgParams.cuId = CU_ID;
+   strcpy(cuCfgParams.cuName, CU_NAME);
+
 #ifdef O1_ENABLE
    if( getStartupConfigForStub(&g_cfg) != ROK )
    {
@@ -178,22 +156,27 @@ void readCuCfg()
    cuCfgParams.sctpParams.duPort = g_cfg.DU_Port;
    cuCfgParams.sctpParams.cuPort = g_cfg.CU_Port;
 #else
-   cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
-   cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
-   cuCfgParams.sctpParams.duPort = DU_PORT;
-   cuCfgParams.sctpParams.cuPort = CU_PORT;
-#endif
-    
-   cuCfgParams.cuId = CU_ID;
-   strcpy(cuCfgParams.cuName, CU_NAME);
-   /* DU IP Address and Port*/
-   cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
-   cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
+   cuCfgParams.sctpParams.numDu = 0;
+   numDu = &cuCfgParams.sctpParams.numDu;
+   while(*numDu < MAX_DU_SUPPORTED)
+   {
+      /* DU IP Address and Port*/
+      memset(&ipv4_du, 0, sizeof(uint32_t));
+      cmInetAddr((S8*)DU_IP_V4_ADDR[*numDu], &ipv4_du);
+      cuCfgParams.sctpParams.sctpAssoc[*numDu].duIpAddr.ipV4Addr = ipv4_du;
+      cuCfgParams.sctpParams.sctpAssoc[*numDu].duIpAddr.ipV6Pres = false;
+      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);
+      cuCfgParams.sctpParams.sctpAssoc[*numDu].cuIpAddr.ipV4Addr = ipv4_cu;
+      cuCfgParams.sctpParams.sctpAssoc[*numDu].cuIpAddr.ipV6Pres = false;
+      cuCfgParams.sctpParams.sctpAssoc[*numDu].cuPort = CU_SCTP_PORT_TO_DU[*numDu];
+      (*numDu)++;
+   }
 
-   /* CU IP Address and Port*/
-   cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
-   cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false;
+#endif
 
    /*PLMN*/
    cuCfgParams.plmn.mcc[0] = PLMN_MCC0;
index 2bfaabf..8063561 100644 (file)
 #ifndef __CU_MGR_MAIN_H__
 #define __CU_MGR_MAIN_H__
 
-#define MAX_IPV6_LEN 16
+#define CU_ID 1
+#define CU_NAME "ORAN_OAM_CU"
+
+#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
+#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 CU_IP_V4_ADDR "192.168.130.82"
+#define CU_SCTP_PORT_TO_DU (int[]){38472, 38473}
+#endif
+
+#define DU_EGTP_PORT 39001
+#define CU_EGTP_PORT 39002
+#define RRC_VER 0
+#define EXT_RRC_VER 5
+#define PLMN_MCC0 3
+#define PLMN_MCC1 1
+#define PLMN_MCC2 1
+#define PLMN_MNC0 4
+#define PLMN_MNC1 8
+#define PLMN_MNC2 0
+
 #define CU_DU_NAME_LEN_MAX 30      /* Max length of CU/DU name string */
 
 #define CU_APP_MEM_REG 1
 #define CU_POOL 1
-#define MAX_DU_PORT 2
-#define DU_PORT 38472
+
 #define MAX_NUM_OF_SLICE 1024 /* As per the spec 38.473, maxnoofSliceItems = 1024*/
 
-/*VALID Tunnel ID*/
-#define MIN_TEID 1   /*[Spec 29.281,Sec 5.1]: All Zero TEIDs are never assigned for setting up GTP-U Tunnel*/
-#define MAX_TEID MAX_NUM_DRB * MAX_NUM_UE /*[Spec 29.281]: Max limit is not mentioned but as per GTP-U Header Format, TEID occupies 4 octets */
 /* allocate and zero out a static buffer */
 
 #define CU_ALLOC(_datPtr, _size)                             \
    SPutSBuf(CU_APP_MEM_REG, CU_POOL,                         \
          (Data *)_datPtr, _size);
 
-typedef struct ipAddr
-{
- Bool      ipV4Pres;
- uint32_t  ipV4Addr;
- Bool      ipV6Pres;
- uint8_t   ipV6Addr[MAX_IPV6_LEN];
-}SctpIpAddr;
-
 typedef struct RrcVersion
 {
   uint8_t    rrcVer;     /* Latest RRC Version */
   uint32_t   extRrcVer;  /* Latest RRC version extended */
 }RrcVersion;
 
-typedef struct egtpParams
-{
-   SctpIpAddr  localIp;
-   uint16_t    localPort;
-   SctpIpAddr  destIp;
-   uint16_t    destPort;
-   uint32_t    currTunnelId;
-   uint32_t    minTunnelId;
-   uint32_t    maxTunnelId;
-}EgtpParams;
-
-typedef struct CuSctpParams
-{
-   SctpIpAddr  duIpAddr;
-   uint16_t    duPort;
-   SctpIpAddr  cuIpAddr;
-   uint16_t    cuPort;
-}CuSctpParams;
-
 typedef struct cuCfgParams
 {
    uint32_t         cuId;
index cb3c5c8..8561e43 100644 (file)
 /* This file contains all EGTP related functionality */
 
 #include "common_def.h"
+#include "OCTET_STRING.h"
+#include "cu_stub_sctp.h"
 #include "cu_f1ap_msg_hdl.h"
 #include "cu_stub_egtp.h"
-#include "du_log.h"
+#include "cu_stub.h"
+#include "cm_inet.h"
+#include "cm_tpt.h"
+#include "cm_inet.x"
+#include "cm_tpt.x"
 
-/* Global variable declaration */
-EgtpGlobalCb egtpCb;
 /**************************************************************************
  * @brief Task Initiation callback function. 
  *
index fb79204..0ca75fc 100644 (file)
 #ifndef __CU_STUB_EGTP_H__
 #define __CU_STUB_EGTP_H__
 
-#include "cu_stub.h"
-#include "cm_inet.h"
-#include "cm_tpt.h"
-#include "cm_inet.x"
-#include "cm_tpt.x"
-
 #define EGTP_DFLT_PORT 2152
 #define EGTP_TNL_MGMT_ADD 1
 #define EGTP_TNL_MGMT_MOD 2
 #define EGTP_MASK_BIT7                   0x40
 #define EGTP_MASK_BIT8                   0x80
 
+/*VALID Tunnel ID*/
+#define MIN_TEID 1   /*[Spec 29.281,Sec 5.1]: All Zero TEIDs are never assigned for setting up GTP-U Tunnel*/
+#define MAX_TEID MAX_NUM_DRB * MAX_NUM_UE /*[Spec 29.281]: Max limit is not mentioned but as per GTP-U Header Format, TEID occupies 4 octets */
+
 #define NUM_TUNNEL_TO_PUMP_DATA 9
 #define NUM_DL_PACKETS 1
 
@@ -121,6 +118,17 @@ typedef struct egtpDstCb
    CmHashListCp  teIdLst;        /* Tunnel Id list for this destination */
 }EgtpDstCb;
 
+typedef struct egtpParams
+{
+   SctpIpAddr  localIp;
+   uint16_t    localPort;
+   SctpIpAddr  destIp;
+   uint16_t    destPort;
+   uint32_t    currTunnelId;
+   uint32_t    minTunnelId;
+   uint32_t    maxTunnelId;
+}EgtpParams;
+
 typedef struct egtpGlobalCb
 {
    EgtpParams   egtpCfg;         /* EGTP configuration */
index fc0fe3b..66ec535 100644 (file)
 /* This file contains all SCTP related functionality */
 
 #include "common_def.h" 
+#include "OCTET_STRING.h"
 #include "cu_f1ap_msg_hdl.h"
 #include "cu_stub_sctp.h"
 #include "cu_stub_egtp.h"
-#include "du_log.h"
+#include "cu_stub.h"
+#include "cm_inet.h"
+#include "cm_tpt.h"
+
+#include "cm_inet.x"
+#include "cm_tpt.x"
+
 
-CuSctpDestCb f1Params;
 /**************************************************************************
  * @brief Task Initiation callback function. 
  *
@@ -45,15 +51,12 @@ CuSctpDestCb f1Params;
  * @return ROK     - success
  *         RFAILED - failure
  ***************************************************************************/
-S16 sctpActvInit()
+uint8_t sctpActvInit()
 {
    DU_LOG("\n\nDEBUG  -->  SCTP : Initializing");
-   connUp = FALSE;
-   assocId = 0;
-   nonblocking = FALSE;
-   sctpCfg = cuCfgParams.sctpParams;
+   memset(&sctpCb, 0, sizeof(SctpGlobalCb));
+   sctpCb.sctpCfg = cuCfgParams.sctpParams;
    return ROK;
-
 }
 
 /**************************************************************************
@@ -75,7 +78,7 @@ S16 sctpActvInit()
  *         RFAILED - failure
  *
  ***************************************************************************/
-S16 sctpActvTsk(Pst *pst, Buffer *mBuf)
+uint8_t sctpActvTsk(Pst *pst, Buffer *mBuf)
 {
 
 //TODO: TBD
@@ -97,17 +100,21 @@ S16 sctpActvTsk(Pst *pst, Buffer *mBuf)
  *
  ***************************************************************************/
 
-S16 sctpCfgReq()
+uint8_t sctpCfgReq()
 {
-
-/* Fill F1 Params */
-   f1Params.destPort             = sctpCfg.duPort;
-   f1Params.srcPort              = sctpCfg.cuPort;
-   f1Params.bReadFdSet           = ROK;
-   memset(&f1Params.sockFd, -1, sizeof(CmInetFd));
-   memset(&f1Params.lstnSockFd, -1, sizeof(CmInetFd));
-   fillDestNetAddr(&f1Params.destIpNetAddr, &sctpCfg.duIpAddr);
-
+   int destIdx;
+   
+   for(destIdx=0; destIdx < sctpCb.sctpCfg.numDu; 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.numDu = sctpCb.sctpCfg.numDu;
    return ROK;
 }
 
@@ -130,12 +137,11 @@ S16 sctpCfgReq()
  *
  ******************************************************************/
 
-S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr)
+uint8_t fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr)
 { 
+   addrLstPtr->addrs[addrLstPtr->count].type = CM_INET_IPV4ADDR_TYPE;
+   addrLstPtr->addrs[addrLstPtr->count].u.ipv4NetAddr = CM_INET_NTOH_UINT32(ipAddr->ipV4Addr);
    addrLstPtr->count++;
-   addrLstPtr->addrs[(addrLstPtr->count - 1)].type = CM_INET_IPV4ADDR_TYPE;
-   addrLstPtr->addrs[(addrLstPtr->count - 1)].u.ipv4NetAddr = CM_INET_NTOH_UINT32(ipAddr->ipV4Addr);
-
    return ROK;
 }
 
@@ -156,7 +162,7 @@ S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr)
  *         RFAILED - failure
  *
  *******************************************************************************/
-S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
+uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
 {
    /* Filling destination address */
    destAddrPtr->type = CM_INET_IPV4ADDR_TYPE;
@@ -181,25 +187,30 @@ S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
  *
  *******************************************************************************/
 
-S16 sctpStartReq()
+uint8_t sctpStartReq()
 {
-   S16 ret = ROK;
-   socket_type = CM_INET_STREAM;
-   fillAddrLst(&f1Params.localAddrLst, &sctpCfg.cuIpAddr);
+   uint8_t destIdx;
+   uint8_t ret = ROK;
 
-   if((ret = cmInetSocket(socket_type, &f1Params.lstnSockFd, IPPROTO_SCTP) != ROK))
-   {
-      DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", f1Params.lstnSockFd.fd);
-   } 
-   else if((ret = cmInetSctpBindx(&f1Params.lstnSockFd, &f1Params.localAddrLst, f1Params.srcPort)) != ROK)
-   {
-      DU_LOG("\nERROR  -->  SCTP: Binding failed at CU");
-   }
-   else if((ret = sctpAccept(&f1Params.lstnSockFd, &f1Params.peerAddr, &f1Params.sockFd)) != ROK)
+   socket_type = CM_INET_STREAM;
+   for(destIdx=0; destIdx < sctpCb.numDu; destIdx++)
    {
-      DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at CU");
+      if((ret = cmInetSocket(socket_type, &sctpCb.destCb[destIdx].lstnSockFd, IPPROTO_SCTP) != ROK))
+      {
+         DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", sctpCb.destCb[destIdx].lstnSockFd.fd);
+      } 
+      else if((ret = cmInetSctpBindx(&sctpCb.destCb[destIdx].lstnSockFd, &sctpCb.destCb[destIdx].localAddrLst, \
+         sctpCb.destCb[destIdx].srcPort)) != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCTP: Binding failed at CU");
+      }
+      else if((ret = sctpAccept(&sctpCb.destCb[destIdx])) != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at CU");
+      }
    }
-   else if(sctpSockPoll() != ROK)
+
+   if(sctpSockPoll() != ROK)
    {
       DU_LOG("\nERROR  -->  SCTP: Polling failed to start at CU");
    }
@@ -221,7 +232,7 @@ S16 sctpStartReq()
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSetSockOpts(CmInetFd *sock_Fd)
+uint8_t sctpSetSockOpts(CmInetFd *sock_Fd)
 {
    S16 ret = ROK;
    CmSctpEvent sctpEvent;
@@ -260,23 +271,23 @@ S16 sctpSetSockOpts(CmInetFd *sock_Fd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd)
+uint8_t sctpAccept(CuSctpDestCb *destCb)
 {
    uint8_t  ret;
 
-   ret = cmInetListen(lstnSock_Fd, 1);
+   ret = cmInetListen(&destCb->lstnSockFd, 1);
    if (ret != ROK)
    {
       DU_LOG("\nERROR  -->  SCTP : Listening on socket failed");
-      cmInetClose(lstnSock_Fd);
+      cmInetClose(&destCb->lstnSockFd);
       return RFAILED;
    }
    
    DU_LOG("\nINFO  -->  SCTP : Connecting");
 
-   while(!connUp)
+   while(!destCb->connUp)
    {
-      ret = cmInetAccept(lstnSock_Fd, peerAddr, sock_Fd);
+      ret = cmInetAccept(&destCb->lstnSockFd, &destCb->peerAddr, &destCb->sockFd);
       if (ret == ROKDNA)
       {
          continue;
@@ -288,8 +299,8 @@ S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd)
       }
       else
       {
-         connUp = TRUE;
-         sctpSetSockOpts(sock_Fd);
+         destCb->connUp = TRUE;
+         sctpSetSockOpts(&destCb->sockFd);
          break;
       }
    }
@@ -315,7 +326,7 @@ S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
+uint8_t sctpNtfyHdlr(CuSctpDestCb *destCb, CmInetSctpNotification *ntfy)
 {
    switch(ntfy->header.nType)
    {
@@ -325,23 +336,23 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
          {
             case CM_INET_SCTP_COMM_UP:
                DU_LOG("DEBUG  -->  Event : COMMUNICATION UP");
-               connUp = TRUE;
+               destCb->connUp = TRUE;
                break;
             case CM_INET_SCTP_COMM_LOST:
                DU_LOG("DEBUG  -->  Event : COMMUNICATION LOST");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_RESTART:
                DU_LOG("DEBUG  -->  Event : SCTP RESTART");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_SHUTDOWN_COMP: /* association gracefully shutdown */
                DU_LOG("DEBUG  -->  Event : SHUTDOWN COMPLETE");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_CANT_STR_ASSOC:
                DU_LOG("DEBUG  -->  Event : CANT START ASSOC");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             default:
                DU_LOG("\nERROR  -->  Invalid event");
@@ -360,7 +371,7 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
          break;
       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
          DU_LOG("\nINFO  -->  SCTP : Shutdown Event notification received\n");
-         connUp = FALSE;
+         destCb->connUp = FALSE;
          exit(0);
          break;
       case CM_INET_SCTP_ADAPTATION_INDICATION :
@@ -394,8 +405,9 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSockPoll()
+uint8_t sctpSockPoll()
 {
+   uint8_t       destIdx;
    uint16_t      ret = ROK;
    uint32_t      timeout;
    uint32_t      *timeoutPtr;
@@ -411,17 +423,9 @@ S16 sctpSockPoll()
    egtpFromAddr.port = egtpCb.dstCb.dstPort;
    egtpFromAddr.address = egtpCb.dstCb.dstIp;
 
-   if(f1Params.sockFd.blocking)
-   {
-      /* blocking */
-      timeoutPtr = NULLP;
-   }
-   else
-   {
-      /* non-blocking */
-      timeout = 0;
-      timeoutPtr = &timeout;
-   }
+   /* All sockets are non-blocking */
+   timeout = 0;
+   timeoutPtr = &timeout;
    memInfo.region = CU_APP_MEM_REG;
    memInfo.pool   = CU_POOL;
    
@@ -429,9 +433,13 @@ S16 sctpSockPoll()
 
    while(1)
    {
-      if((ret = processPolling(&f1PollParams, &f1Params.sockFd, timeoutPtr, &memInfo)) != ROK)
+      /* Receiving SCTP data */
+      for(destIdx = 0; destIdx < sctpCb.numDu; destIdx++)
       {
-         DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for F1 at CU\n");
+         if((ret = processPolling(&f1PollParams, &sctpCb.destCb[destIdx], timeoutPtr, &memInfo)) != ROK)
+         {
+            DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for F1 at CU\n");
+         }
       }
 
       /* Receiving EGTP data */
@@ -472,30 +480,31 @@ S16 sctpSockPoll()
  *
  * ****************************************************************/
 
-S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
+uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
 {
    uint16_t ret = ROK;
-   CM_INET_FD_SET(sockFd, &pollParams->readFd);
+   CM_INET_FD_SET(&destCb->sockFd, &pollParams->readFd);
    ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFd);
-   if(CM_INET_FD_ISSET(sockFd, &pollParams->readFd))
+   if(CM_INET_FD_ISSET(&destCb->sockFd, &pollParams->readFd))
    {
-      CM_INET_FD_CLR(sockFd, &pollParams->readFd);
-      ret = cmInetSctpRecvMsg(sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy);
-      if(connUp & (ret != ROK))
+      CM_INET_FD_CLR(&destCb->sockFd, &pollParams->readFd);
+      ret = cmInetSctpRecvMsg(&destCb->sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, \
+         &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy);
+      if(destCb->connUp & (ret != ROK))
       {
-         f1Params.bReadFdSet = RFAILED;
+         destCb->bReadFdSet = RFAILED;
       }
       else
       {
          if(((pollParams->flag & CM_INET_SCTP_MSG_NOTIFICATION) != 0) && (ret == ROK))
          {
-            ret = sctpNtfyHdlr(&pollParams->ntfy);
+            ret = sctpNtfyHdlr(destCb, &pollParams->ntfy);
             if(ret != ROK)
             {
                DU_LOG("\nERROR  -->  SCTP : Failed to process sctp notify msg\n");
             }
          }
-         else if(connUp & (pollParams->port == f1Params.destPort))
+         else if(destCb->connUp & (pollParams->port == destCb->destPort))
          {  
             F1APMsgHdlr(pollParams->mBuf);
             ODU_PUT_MSG_BUF(pollParams->mBuf);
@@ -525,7 +534,7 @@ S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32_t *t
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSend(Buffer *mBuf)
+uint8_t sctpSend(Buffer *mBuf)
 {
    uint8_t          ret = ROK;
    MsgLen           len = 0;          /* number of actually sent octets */
@@ -535,7 +544,8 @@ S16 sctpSend(Buffer *mBuf)
    memInfo.region = CU_APP_MEM_REG;               
    memInfo.pool   = CU_POOL;
 
-   ret = cmInetSctpSendMsg(&f1Params.sockFd, &f1Params.destIpNetAddr, f1Params.destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
+   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)
    {
index 8cb7456..9845f29 100644 (file)
 #ifndef __CU_SCTP_H__
 #define __CU_SCTP_H__
 
-#include "cu_stub.h"
-#include "cm_inet.h"
-#include "cm_tpt.h"
-
-#include "cm_inet.x"
-#include "cm_tpt.x"
-
 #define MAX_RETRY 5
+#define MAX_IPV6_LEN 16
+#define MAX_DU_SUPPORTED 1
 
 /* Global variable declaration */
 uint8_t   socket_type;      /* Socket type */
-Bool nonblocking;      /* Blocking/Non-blocking socket */
-Bool connUp;           /* Is connection up */
-int  assocId;          /* Assoc Id of connected assoc */
-  
-CuSctpParams sctpCfg;            /* SCTP configurations at DU */
 
 typedef struct
 {
@@ -62,19 +52,51 @@ typedef struct
    CmInetNetAddrLst destAddrLst;      /* DU Ip address */
    CmInetNetAddrLst localAddrLst;
    CmInetNetAddr    destIpNetAddr;    /* DU Ip address */ 
+   Bool             connUp;           /* Is connection up */
 }CuSctpDestCb;
 
-S16 sctpActvInit();
-S16 sctpStartReq();
-S16 sctpSend(Buffer *mBuf);
-S16 sctpCfgReq();
+typedef struct ipAddr
+{
+ Bool      ipV4Pres;
+ uint32_t  ipV4Addr;
+ Bool      ipV6Pres;
+ uint8_t   ipV6Addr[MAX_IPV6_LEN];
+}SctpIpAddr;
+
+typedef struct sctpAssocInfo
+{
+   SctpIpAddr  duIpAddr;
+   uint16_t    duPort;
+   SctpIpAddr  cuIpAddr;
+   uint16_t    cuPort;
+}SctpAssocInfo;
+
+typedef struct CuSctpParams
+{
+   uint8_t        numDu;
+   SctpAssocInfo  sctpAssoc[MAX_DU_SUPPORTED];
+}CuSctpParams;
+
+typedef struct
+{
+   CuSctpParams sctpCfg;
+   uint8_t      numDu;
+   CuSctpDestCb destCb[MAX_DU_SUPPORTED]; 
+}SctpGlobalCb;
+
+SctpGlobalCb sctpCb;
+
+uint8_t sctpActvInit();
+uint8_t sctpStartReq();
+uint8_t sctpSend(Buffer *mBuf);
+uint8_t sctpCfgReq();
 
-S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr);
-S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);
-S16 sctpSetSockOpts(CmInetFd *sock_Fd);
-S16 sctpSockPoll();
-S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd);
-S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
+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);
 #endif
 
 /**********************************************************************
index 851fb5d..72a992a 100644 (file)
@@ -21,8 +21,8 @@
 #include "OCTET_STRING.h"
 #include "BIT_STRING.h"
 #include "odu_common_codec.h"
-#include "ric_stub.h"
 #include "ric_stub_sctp.h"
+#include "ric_stub.h"
 #include "ric_e2ap_msg_hdl.h"
 #include "GlobalE2node-gNB-ID.h"
 #include "ProtocolIE-FieldE2.h"
index c34b6a2..47ebf52 100644 (file)
@@ -30,7 +30,6 @@
 #define CRNTI           17017
 #define CELL_INDEX      0
 
-
 /* allocate and zero out a static buffer */
 #define RIC_ALLOC(_datPtr, _size)                                \
 {                                                               \
index 0f36cb5..429dc46 100644 (file)
 
 /* This functions contains main() for ric_app */
 #include "common_def.h"
-#include "ric_stub.h"
 #include "ric_stub_sctp.h"
-#include "du_log.h"
+#include "ric_stub.h"
 
 #ifdef O1_ENABLE
 #include "CmInterface.h"
 #endif
 
-#define RIC_ID 1
-#define RIC_NAME "ORAN_OAM_RIC"
-
-#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
-#define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
-
-#ifndef O1_ENABLE
-
-#define DU_IP_V4_ADDR "192.168.130.81"
-#define RIC_IP_V4_ADDR "192.168.130.80"
-#define DU_PORT 36421
-#define RIC_PORT 36421
-
-#endif
-
-#define RRC_VER 0
-#define EXT_RRC_VER 5
-#define PLMN_MCC0 3
-#define PLMN_MCC1 1
-#define PLMN_MCC2 1
-#define PLMN_MNC0 4
-#define PLMN_MNC1 8
-#define PLMN_MNC2 0
-
 #ifdef O1_ENABLE
 extern StartupConfig g_cfg;
 #endif
@@ -130,10 +105,13 @@ uint8_t tst()
 
 void readRicCfg()
 {
+   uint8_t *numDu;
    uint32_t ipv4_du, ipv4_ric;
 
    DU_LOG("\nINFO  --> RIC : Reading RIC configurations");
 
+   ricCfgParams.ricId = RIC_ID;
+   strcpy(ricCfgParams.ricName, RIC_NAME);
 #ifdef O1_ENABLE
    if( getStartupConfigForStub(&g_cfg) != ROK )
    {
@@ -148,23 +126,26 @@ void readRicCfg()
    ricCfgParams.sctpParams.duPort = g_cfg.RIC_Port;
    ricCfgParams.sctpParams.ricPort = g_cfg.RIC_Port;
 #else
-   cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
-   cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
-
-   ricCfgParams.sctpParams.duPort = DU_PORT;
-   ricCfgParams.sctpParams.ricPort = RIC_PORT;
+   ricCfgParams.sctpParams.numDu = 0;
+   numDu = &ricCfgParams.sctpParams.numDu;
+   while(*numDu < MAX_DU_SUPPORTED)
+   {   
+      /* 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];
+
+      /* 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
-    
-   ricCfgParams.ricId = RIC_ID;
-   strcpy(ricCfgParams.ricName, RIC_NAME);
-   /* DU IP Address and Port*/
-   ricCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
-   ricCfgParams.sctpParams.duIpAddr.ipV6Pres = false;
-
-   /* RIC IP Address and Port*/
-   ricCfgParams.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
-   ricCfgParams.sctpParams.ricIpAddr.ipV6Pres = false;
 
    /*PLMN*/
    ricCfgParams.plmn.mcc[0] = PLMN_MCC0;
index 566f070..bb7f095 100644 (file)
 #ifndef __RIC_MGR_MAIN_H__
 #define __RIC_MGR_MAIN_H__
 
-#define MAX_IPV6_LEN 16
+#define RIC_ID 1
+#define RIC_NAME "ORAN_OAM_RIC"
+
+#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
+#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 RIC_IP_V4_ADDR "192.168.130.80"
+#define RIC_SCTP_PORT_TO_DU (int[]){36421, 36422}
+#endif
+
+#define RRC_VER 0
+#define EXT_RRC_VER 5
+#define PLMN_MCC0 3
+#define PLMN_MCC1 1
+#define PLMN_MCC2 1
+#define PLMN_MNC0 4
+#define PLMN_MNC1 8
+#define PLMN_MNC2 0
+
 #define RIC_DU_NAME_LEN_MAX 30      /* Max length of RIC/DU name string */
 
 #define RIC_APP_MEM_REG 1
    SPutSBuf(RIC_APP_MEM_REG, RIC_POOL,                         \
          (Data *)_datPtr, _size);
 
-typedef struct ipAddr
-{
- bool ipV4Pres;
- uint32_t  ipV4Addr;
- bool ipV6Pres;
- uint8_t   ipV6Addr[MAX_IPV6_LEN];
-}SctpIpAddr;
-
-typedef struct RicSctpParams
-{
-   SctpIpAddr  duIpAddr;
-   uint16_t         duPort;
-   SctpIpAddr  ricIpAddr;
-   uint16_t         ricPort;
-}RicSctpParams;
-
 typedef struct ricCfgParams
 {
    uint32_t             ricId;
index 679c43e..662087c 100644 (file)
 /* This file contains all SCTP related functionality */
 
 #include "common_def.h"
-#include "ric_e2ap_msg_hdl.h"
 #include "ric_stub_sctp.h"
 #include "ric_stub.h"
+#include "ric_e2ap_msg_hdl.h"
 #include "E2AP-PDU.h"
-#include "du_log.h"
 
-CuSctpDestCb ricParams;
-RicSctpParams sctpCfg;
-S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr);
-S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);
 /**************************************************************************
  * @brief Function to configure the Sctp Params during config Request
  *
@@ -44,19 +39,23 @@ S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);
  *
  ***************************************************************************/
 
-S16 sctpCfgReq()
+uint8_t sctpCfgReq()
 {
-   connUp = FALSE;
-   sctpCfg = ricCfgParams.sctpParams;
-
-/* Fill F1 Params */
-   ricParams.destPort             = sctpCfg.duPort;
-   ricParams.srcPort              = sctpCfg.ricPort;
-   ricParams.bReadFdSet           = ROK;
-   memset(&ricParams.sockFd, -1, sizeof(CmInetFd));
-   memset(&ricParams.lstnSockFd, -1, sizeof(CmInetFd));
-   fillDestNetAddr(&ricParams.destIpNetAddr, &sctpCfg.duIpAddr);
+   int destIdx;
 
+   sctpCb.sctpCfg = ricCfgParams.sctpParams;   
+   for(destIdx=0; destIdx < sctpCb.sctpCfg.numDu; 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.numDu = sctpCb.sctpCfg.numDu;
    return ROK;
 }
 
@@ -78,11 +77,11 @@ S16 sctpCfgReq()
  *
  ******************************************************************/
 
-S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr)
+uint8_t fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr)
 { 
+   addrLstPtr->addrs[addrLstPtr->count].type = CM_INET_IPV4ADDR_TYPE;
+   addrLstPtr->addrs[addrLstPtr->count].u.ipv4NetAddr = CM_INET_NTOH_UINT32(ipAddr->ipV4Addr);
    addrLstPtr->count++;
-   addrLstPtr->addrs[(addrLstPtr->count - 1)].type = CM_INET_IPV4ADDR_TYPE;
-   addrLstPtr->addrs[(addrLstPtr->count - 1)].u.ipv4NetAddr = CM_INET_NTOH_UINT32(ipAddr->ipV4Addr);
 
    return ROK;
 }
@@ -104,7 +103,7 @@ S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr)
  *         RFAILED - failure
  *
  *******************************************************************************/
-S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
+uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
 {
    /* Filling destination address */
    destAddrPtr->type = CM_INET_IPV4ADDR_TYPE;
@@ -129,25 +128,31 @@ S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
  *
  *******************************************************************************/
 
-S16 sctpStartReq()
+uint8_t sctpStartReq()
 {
-   S16 ret = ROK;
+   uint8_t destIdx  = 0;
+   uint8_t ret = ROK;
+
    socket_type = CM_INET_STREAM;
-   fillAddrLst(&ricParams.localAddrLst, &sctpCfg.ricIpAddr);
 
-   if((ret = cmInetSocket(socket_type, &ricParams.lstnSockFd, IPPROTO_SCTP) != ROK))
-   {
-      DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", ricParams.lstnSockFd.fd);
-   } 
-   else if((ret = cmInetSctpBindx(&ricParams.lstnSockFd, &ricParams.localAddrLst, ricParams.srcPort)) != ROK)
+   for(destIdx=0; destIdx < sctpCb.numDu; destIdx++)
    {
-      DU_LOG("\nERROR  -->  SCTP: Binding failed at RIC");
-   }
-   else if((ret = sctpAccept(&ricParams.lstnSockFd, &ricParams.peerAddr, &ricParams.sockFd)) != ROK)
-   {
-      DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at RIC");
+      if((ret = cmInetSocket(socket_type, &sctpCb.destCb[destIdx].lstnSockFd, IPPROTO_SCTP) != ROK))
+      {
+         DU_LOG("\nERROR  -->  SCTP : Socket[%d] coudnt open for listening", sctpCb.destCb[destIdx].lstnSockFd.fd);
+      } 
+      else if((ret = cmInetSctpBindx(&sctpCb.destCb[destIdx].lstnSockFd, &sctpCb.destCb[destIdx].localAddrLst, \
+         sctpCb.destCb[destIdx].srcPort)) != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCTP: Binding failed at RIC");
+      }
+      else if((ret = sctpAccept(&sctpCb.destCb[destIdx])) != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at RIC");
+      }
    }
-   else if(sctpSockPoll() != ROK)
+
+   if(sctpSockPoll() != ROK)
    {
       DU_LOG("\nERROR  -->  SCTP: Polling failed to start at RIC");
    }
@@ -169,7 +174,7 @@ S16 sctpStartReq()
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSetSockOpts(CmInetFd *sock_Fd)
+uint8_t sctpSetSockOpts(CmInetFd *sock_Fd)
 {
    S16 ret = ROK;
    CmSctpEvent sctpEvent;
@@ -208,23 +213,23 @@ S16 sctpSetSockOpts(CmInetFd *sock_Fd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd)
+uint8_t sctpAccept(RicSctpDestCb *destCb)
 {
    uint8_t  ret;
 
-   ret = cmInetListen(lstnSock_Fd, 1);
+   ret = cmInetListen(&destCb->lstnSockFd, 1);
    if (ret != ROK)
    {
       DU_LOG("\nERROR   -->  SCTP : Listening on socket failed");
-      cmInetClose(lstnSock_Fd);
+      cmInetClose(&destCb->lstnSockFd);
       return RFAILED;
    }
    
    DU_LOG("\nINFO   -->  SCTP : Connecting");
 
-   while(!connUp)
+   while(!destCb->connUp)
    {
-      ret = cmInetAccept(lstnSock_Fd, peerAddr, sock_Fd);
+      ret = cmInetAccept(&destCb->lstnSockFd, &destCb->peerAddr, &destCb->sockFd);
       if (ret == ROKDNA)
       {
          continue;
@@ -236,8 +241,8 @@ S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd)
       }
       else
       {
-         connUp = TRUE;
-         sctpSetSockOpts(sock_Fd);
+         destCb->connUp = TRUE;
+         sctpSetSockOpts(&destCb->sockFd);
          break;
       }
    }
@@ -263,7 +268,7 @@ S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
+uint8_t sctpNtfyHdlr(RicSctpDestCb *destCb, CmInetSctpNotification *ntfy)
 {
    switch(ntfy->header.nType)
    {
@@ -273,23 +278,23 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
          {
             case CM_INET_SCTP_COMM_UP:
                DU_LOG("\nINFO   -->  Event : COMMUNICATION UP");
-               connUp = TRUE;
+               destCb->connUp = TRUE;
                break;
             case CM_INET_SCTP_COMM_LOST:
                DU_LOG("\nINFO   -->  Event : COMMUNICATION LOST");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_RESTART:
                DU_LOG("\nINFO   -->  Event : SCTP RESTART");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_SHUTDOWN_COMP: /* association gracefully shutdown */
                DU_LOG("\nINFO   -->  Event : SHUTDOWN COMPLETE");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_CANT_STR_ASSOC:
                DU_LOG("\nINFO   -->  Event : CANT START ASSOC");
-               connUp = FALSE;
+               destCb->connUp = FALSE;
                break;
             default:
                DU_LOG("\nERROR   -->  Invalid event");
@@ -308,7 +313,7 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
          break;
       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
          DU_LOG("\nINFO   -->  SCTP : Shutdown Event notification received\n");
-         connUp = FALSE;
+         destCb->connUp = FALSE;
          exit(0);
          break;
       case CM_INET_SCTP_ADAPTATION_INDICATION :
@@ -342,8 +347,9 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSockPoll()
+uint8_t sctpSockPoll()
 {
+   uint8_t            destIdx;
    uint16_t           ret = ROK;
    uint32_t           timeout;
    uint32_t           *timeoutPtr;
@@ -352,18 +358,9 @@ S16 sctpSockPoll()
 
    memset(&e2PollParams, 0, sizeof(sctpSockPollParams));
     
-   if(ricParams.sockFd.blocking)
-   {
-      /* blocking */
-      timeoutPtr = NULLP;
-   }
-   else
-   {
-      /* non-blocking */
-      timeout = 0;
-      timeoutPtr = &timeout;
-   }
-
+   /* All sockets are non-blocking */
+   timeout = 0;
+   timeoutPtr = &timeout;
    memInfo.region = RIC_APP_MEM_REG;
    memInfo.pool   = RIC_POOL;
 
@@ -372,9 +369,14 @@ S16 sctpSockPoll()
    DU_LOG("\nINFO  -->  SCTP : Polling started at RIC\n");
    while(1)
    {
-      if((ret = processPolling(&e2PollParams, &ricParams.sockFd, timeoutPtr, &memInfo)) != ROK)
+      /* Receiving SCTP data */
+      for(destIdx = 0; destIdx < sctpCb.numDu; destIdx++)
       {
-         DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for E2 at RIC \n");
+
+         if((ret = processPolling(&e2PollParams, &sctpCb.destCb[destIdx], timeoutPtr, &memInfo)) != ROK)
+         {
+            DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for E2 at RIC \n");
+         }
       }
    };
    return (ret);
@@ -404,30 +406,32 @@ S16 sctpSockPoll()
  * ****************************************************************/
 
  
-S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
+uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
 {
    uint16_t ret = ROK;
-   CM_INET_FD_SET(sockFd, &pollParams->readFd);
+
+   CM_INET_FD_SET(&destCb->sockFd, &pollParams->readFd);
    ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFd);
-   if(CM_INET_FD_ISSET(sockFd, &pollParams->readFd))
+   if(CM_INET_FD_ISSET(&destCb->sockFd, &pollParams->readFd))
    {
-      CM_INET_FD_CLR(sockFd, &pollParams->readFd);
-      ret = cmInetSctpRecvMsg(sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy);
-      if(connUp & (ret != ROK))
+      CM_INET_FD_CLR(&destCb->sockFd, &pollParams->readFd);
+      ret = cmInetSctpRecvMsg(&destCb->sockFd, &pollParams->addr, &pollParams->port, memInfo, &pollParams->mBuf, \
+          &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy);
+      if(destCb->connUp & (ret != ROK))
       {
-         ricParams.bReadFdSet = RFAILED;
+         destCb->bReadFdSet = RFAILED;
       }
       else
       {
          if(((pollParams->flag & CM_INET_SCTP_MSG_NOTIFICATION) != 0) && (ret == ROK))
          {
-            ret = sctpNtfyHdlr(&pollParams->ntfy);
+            ret = sctpNtfyHdlr(destCb, &pollParams->ntfy);
             if(ret != ROK)
             {
                DU_LOG("\nERROR  -->  SCTP : Failed to process sctp notify msg\n");
             }
          }
-         else if(connUp & (pollParams->port == ricParams.destPort))
+         else if(destCb->connUp & (pollParams->port == destCb->destPort))
          {  
             E2APMsgHdlr(pollParams->mBuf);
             ODU_PUT_MSG_BUF(pollParams->mBuf);
@@ -457,7 +461,7 @@ S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32_t *t
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSend(Buffer *mBuf)
+uint8_t sctpSend(Buffer *mBuf)
 {
    uint8_t          ret;
    MsgLen           len;          /* number of actually sent octets */
@@ -466,7 +470,8 @@ S16 sctpSend(Buffer *mBuf)
    memInfo.region = RIC_APP_MEM_REG;               
    memInfo.pool   = RIC_POOL;
 
-   ret = cmInetSctpSendMsg(&ricParams.sockFd, &ricParams.destIpNetAddr, ricParams.destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
+   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)
    {
index fd72abb..37da878 100644 (file)
 
 #ifndef __RIC_SCTP_H__
 #define __RIC_SCTP_H__
+
 #define MAX_RETRY 5
+#define MAX_IPV6_LEN 16
+#define MAX_DU_SUPPORTED 1 
 
 /* Global variable declaration */
 uint8_t   socket_type;      /* Socket type */
-bool      nonblocking;      /* Blocking/Non-blocking socket */
-bool      connUp;           /* Is connection up */
-int       assocId;          /* Assoc Id of connected assoc */
   
 typedef struct
 {
@@ -52,16 +52,50 @@ typedef struct
    CmInetNetAddrLst      destAddrLst;      /* DU Ip address */
    CmInetNetAddrLst      localAddrLst;
    CmInetNetAddr         destIpNetAddr;    /* DU Ip address */ 
-}CuSctpDestCb;
+   Bool                  connUp;
+}RicSctpDestCb;
+
+typedef struct ipAddr
+{
+ bool ipV4Pres;
+ uint32_t  ipV4Addr;
+ bool ipV6Pres;
+ uint8_t   ipV6Addr[MAX_IPV6_LEN];
+}SctpIpAddr;
+
+typedef struct sctpAssocInfo
+{
+   SctpIpAddr  duIpAddr;
+   uint16_t    duPort;
+   SctpIpAddr  ricIpAddr;
+   uint16_t    ricPort;
+}SctpAssocInfo;
+
+typedef struct ricSctpParams
+{
+   uint8_t        numDu;
+   SctpAssocInfo  sctpAssoc[MAX_DU_SUPPORTED];
+}RicSctpParams;
+
+typedef struct sctpGlobalCb
+{
+   RicSctpParams sctpCfg;
+   uint8_t      numDu;
+   RicSctpDestCb destCb[MAX_DU_SUPPORTED]; 
+}SctpGlobalCb;
+
+SctpGlobalCb sctpCb;
 
-S16 sctpActvInit();
-S16 sctpSend(Buffer *mBuf);
-S16 sctpCfgReq();
-S16 sctpStartReq();
-S16 sctpSetSockOpts(CmInetFd *sock_Fd);
-S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd);
-S16 sctpSockPoll();
-S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
+uint8_t sctpActvInit();
+uint8_t sctpSend(Buffer *mBuf);
+uint8_t sctpCfgReq();
+uint8_t sctpStartReq();
+uint8_t sctpSetSockOpts(CmInetFd *sock_Fd);
+uint8_t sctpAccept(RicSctpDestCb *destCb);
+uint8_t sctpSockPoll();
+uint8_t processPolling(sctpSockPollParams *pollParams, RicSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo);
+uint8_t fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr);
+uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);
 
 #endif