[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-434] EGTP connection towards multiple DUs...
[o-du/l2.git] / src / cu_stub / cu_stub_sctp.c
index f4452ac..c74290a 100644 (file)
 
 /* This file contains all SCTP related functionality */
 
-#include <stdio.h> 
+#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 "cu_stub.h"
+#include "cm_inet.h"
+#include "cm_tpt.h"
+
+#include "cm_inet.x"
+#include "cm_tpt.x"
+
 
 /**************************************************************************
  * @brief Task Initiation callback function. 
  * @return ROK     - success
  *         RFAILED - failure
  ***************************************************************************/
-S16 sctpActvInit()
+uint8_t sctpActvInit()
 {
-   DU_LOG("\n\nSCTP : Initializing");
-   connUp = FALSE;
-   assocId = 0;
-   nonblocking = FALSE;
-   sctpCfg = &(cuCfgParams.sctpParams);
+   DU_LOG("\n\nDEBUG  -->  SCTP : Initializing");
+   memset(&sctpCb, 0, sizeof(SctpGlobalCb));
+   sctpCb.sctpCfg = cuCb.cuCfgParams.sctpParams;
    return ROK;
-
 }
 
 /**************************************************************************
@@ -73,132 +78,144 @@ S16 sctpActvInit()
  *         RFAILED - failure
  *
  ***************************************************************************/
-S16 sctpActvTsk(Pst *pst, Buffer *mBuf)
+uint8_t sctpActvTsk(Pst *pst, Buffer *mBuf)
 {
 
 //TODO: TBD
    return ROK;
 }
 
+/**************************************************************************
+ * @brief Function to configure the Sctp Params during config Request
+ *
+ * @details
+ *
+ *      Function : duSctpCfgReq
+ * 
+ *      Functionality:
+ *           This function configures SCTP Params during the config Request
+ *     
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ***************************************************************************/
+
+uint8_t sctpCfgReq()
+{
+   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;
+}
+
+
 /*******************************************************************
  *
- * @brief Opens a non-blocking socket and binds to local address
+ * @brief Fills the address List of the source Ip Address
  *
  * @details
  *
- *    Function : openSctpEndp
+ *    Function : fillAddrLst
  *
  *    Functionality:
- *         Opens a non-blocking socket and binds to local address
+ *       Fills the address List of source Ip Address
  *
- * @params[in] 
+ * @params[in] CmInetNetAddrLst *addrLstPtr, Address List pointer
+ * @params[in] F1IpAddr *srcIpAddr, src Ip Adrress to be filled in the Address List
  * @return ROK     - success
  *         RFAILED - failure
  *
- * ****************************************************************/
-S16 openSctpEndp()
-{
-   U8 ret;
-   U8 numRetry = 0;
-
-   /* Opening a non-blocking SCTP socket */
-   socket_type = CM_INET_STREAM;
-
-   do{
-      ret = cmInetSocket(socket_type, &lstnSockFd, IPPROTO_SCTP);
-      if (ret != ROK)
-      {
-         numRetry++;
-         if(numRetry >= MAX_RETRY)
-         {
-            DU_LOG("\nSCTP : All attempts to open socket failed.");
-            /* Send indication to du_app */
-            RETVALUE(RFAILED);
-         }
-         else
-         {
-            DU_LOG("\nSCTP : Retrying socket opening"); 
-         }
-      }
-      else
-      {
-         DU_LOG("\nSCTP : Socket[%d] open",lstnSockFd.fd);
-         break;
-      }
-   }while(numRetry < MAX_RETRY);
-
-   RETVALUE(ROK);
-} /* End of openSctpEndp */
+ ******************************************************************/
 
+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++;
+   return ROK;
+}
 
-/*******************************************************************
+/******************************************************************************
  *
- * @brief Bind socket to local Ip address and port
+ * @brief Fills the address List of the source Ip Address
  *
  * @details
  *
- *    Function : bindSctpEndp
+ *    Function : fillDestNetAddr
  *
  *    Functionality:
- *      -Bind socket to local Ip address and port
+ *       Fills the address List of destinatoion Ip Address
  *
- * @params[in] 
+ * @params[in] CmInetNetAddr *destAddrPtr, Address List pointer
+ * @params[in] F1IpAddr *dstIpAddr, destIp Address to be filled in the Address List
  * @return ROK     - success
  *         RFAILED - failure
  *
- * ****************************************************************/
-S16 bindSctpEndp()
+ *******************************************************************************/
+uint8_t fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr)
 {
+   /* Filling destination address */
+   destAddrPtr->type = CM_INET_IPV4ADDR_TYPE;
+   destAddrPtr->u.ipv4NetAddr = CM_INET_NTOH_UINT32(dstIpPtr->ipV4Addr);
+   return ROK;
+}
 
-   U8 ret;
-   U8 numRetry = 0;
+/******************************************************************************
+ *
+ * @brief Eastablishes the Assoc Req for the received interface type
+ *
+ * @details
+ *
+ *    Function : sctpStartReq
+ *
+ *    Functionality:
+ *       Eastablishes the Assoc Req for the received interface type
+ *
+ * @params[in] DuSctpDestCb *paramPtr
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ *******************************************************************************/
 
-   /* Binding the socket with local address */
-   localAddrLst.count = 1;
-   if(sctpCfg->cuIpAddr.ipV4Pres)
-   {
-      localAddrLst.addrs[0].type = CM_INET_IPV4ADDR_TYPE;
-      localAddrLst.addrs[0].u.ipv4NetAddr = CM_INET_NTOH_U32(sctpCfg->cuIpAddr.ipV4Addr);
-   }
-   else if(sctpCfg->cuIpAddr.ipV6Pres)
-   {
-      localAddrLst.addrs[0].type = CM_INET_IPV6ADDR_TYPE;
-     // CM_INET_COPY_IPV6ADDR(&(localAddrLst.addrs[0].u.ipv6NetAddr),&(sctpCfg->cuIpAddr.ipV6Addr);         
-   }
-   else
-   {
-      localAddrLst.addrs[0].type = CM_INET_IPV4ADDR_TYPE;
-      localAddrLst.addrs[0].u.ipv4NetAddr = 0;
-   } 
+uint8_t sctpStartReq()
+{
+   uint8_t destIdx;
+   uint8_t ret = ROK;
 
-   do{
-      ret = cmInetSctpBindx(&lstnSockFd, &localAddrLst, sctpCfg->cuPort);
-      if (ret != ROK)
+   socket_type = CM_INET_STREAM;
+   for(destIdx=0; destIdx < sctpCb.numDu; destIdx++)
+   {
+      if((ret = cmInetSocket(socket_type, &sctpCb.destCb[destIdx].lstnSockFd, IPPROTO_SCTP) != ROK))
       {
-         numRetry++;
-         if(numRetry >= MAX_RETRY)
-         {
-            DU_LOG("\nSCTP : All attempts to bind socket failed.");
-            cmInetClose(&lstnSockFd);
-            /* Send indication to du_app */
-            RETVALUE(RFAILED);
-         }
-         else
-         {
-            DU_LOG("\nSCTP : Retrying socket binding");
-         }
+         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
+      else if((ret = sctpAccept(&sctpCb.destCb[destIdx])) != ROK)
       {
-         DU_LOG("\nSCTP : Socket bind successful");
-         break;
+         DU_LOG("\nERROR  -->  SCTP: Unable to accept the connection at CU");
       }
-   }while(numRetry < MAX_RETRY);
-
-  RETVALUE(ROK);
-
-} /* End of bindSctpEndp() */
+   }
 
+   if(sctpSockPoll() != ROK)
+   {
+      DU_LOG("\nERROR  -->  SCTP: Polling failed to start at CU");
+   }
+   return (ret);
+}
 /*******************************************************************
  *
  * @brief Sets socket options as per requirement
@@ -215,8 +232,9 @@ S16 bindSctpEndp()
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSetSockOpts()
+uint8_t sctpSetSockOpts(CmInetFd *sock_Fd)
 {
+   S16 ret = ROK;
    CmSctpEvent sctpEvent;
   
    sctpEvent.dataIoEvent          = TRUE;
@@ -228,8 +246,12 @@ S16 sctpSetSockOpts()
    sctpEvent.partialDeliveryEvent = TRUE;
    sctpEvent.adaptationLayerEvent = TRUE;
 
-   cmInetSetOpt(&sockFd, CM_SOCKOPT_LEVEL_SCTP, CM_SOCKOPT_OPT_SCTP_EVENTS, &sctpEvent);
-   RETVALUE(ROK);
+   if((ret = cmInetSetOpt(sock_Fd, CM_SOCKOPT_LEVEL_SCTP, CM_SOCKOPT_OPT_SCTP_EVENTS, &sctpEvent)) != ROK)
+   {
+     ret = RFAILED;
+   }
+  
+   return (ret);
 }
 
 /*******************************************************************
@@ -249,44 +271,43 @@ S16 sctpSetSockOpts()
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpAccept()
+uint8_t sctpAccept(CuSctpDestCb *destCb)
 {
-   U8  ret;
-   CmInetAddr    peerAddr;
-   
-   ret = cmInetListen(&lstnSockFd, 1);;
+   uint8_t  ret;
+
+   ret = cmInetListen(&destCb->lstnSockFd, 1);
    if (ret != ROK)
    {
-      DU_LOG("\nSCTP : Listening on socket failed");
-      cmInetClose(&lstnSockFd);
-      RETVALUE(RFAILED);
+      DU_LOG("\nERROR  -->  SCTP : Listening on socket failed");
+      cmInetClose(&destCb->lstnSockFd);
+      return RFAILED;
    }
    
-   DU_LOG("\nSCTP : Connecting");
+   DU_LOG("\nINFO  -->  SCTP : Connecting");
 
-   while(!connUp)
+   while(!destCb->connUp)
    {
-      ret = cmInetAccept(&lstnSockFd, &peerAddr, &sockFd);
+      ret = cmInetAccept(&destCb->lstnSockFd, &destCb->peerAddr, &destCb->sockFd);
       if (ret == ROKDNA)
       {
          continue;
       }
       else if(ret != ROK)
       {
-         DU_LOG("\nSCTP : Failed to accept connection");
-         RETVALUE(RFAILED);
+         DU_LOG("\nERROR  -->  SCTP : Failed to accept connection");
+         return RFAILED;
       }
       else
       {
-         connUp = TRUE;
-         sctpSetSockOpts();
+         destCb->connUp = TRUE;
+         sctpSetSockOpts(&destCb->sockFd);
          break;
       }
    }
-   DU_LOG("\nSCTP : Connection established");
+   DU_LOG("\nINFO  -->  SCTP : Connection established");
 
-   RETVALUE(ROK);
-}/* End of sctpAccept() */
+   return ROK;
+}
 
 /*******************************************************************
  *
@@ -305,66 +326,67 @@ S16 sctpAccept()
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
+uint8_t sctpNtfyHdlr(CuSctpDestCb *destCb, CmInetSctpNotification *ntfy)
 {
    switch(ntfy->header.nType)
    {
       case CM_INET_SCTP_ASSOC_CHANGE :
-         DU_LOG("\nSCTP : Assoc change notification received");
+         DU_LOG("\nINFO  -->  SCTP : Assoc change notification received");
          switch(ntfy->u.assocChange.state)
          {
             case CM_INET_SCTP_COMM_UP:
-               DU_LOG("Event : COMMUNICATION UP");
-               connUp = TRUE;
+               DU_LOG("DEBUG  -->  Event : COMMUNICATION UP");
+               destCb->connUp = TRUE;
                break;
             case CM_INET_SCTP_COMM_LOST:
-               DU_LOG("Event : COMMUNICATION LOST");
-               connUp = FALSE;
+               DU_LOG("DEBUG  -->  Event : COMMUNICATION LOST");
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_RESTART:
-               DU_LOG("Event : SCTP RESTART");
-               connUp = FALSE;
+               DU_LOG("DEBUG  -->  Event : SCTP RESTART");
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_SHUTDOWN_COMP: /* association gracefully shutdown */
-               DU_LOG("Event : SHUTDOWN COMPLETE");
-               connUp = FALSE;
+               DU_LOG("DEBUG  -->  Event : SHUTDOWN COMPLETE");
+               destCb->connUp = FALSE;
                break;
             case CM_INET_SCTP_CANT_STR_ASSOC:
-               DU_LOG("Event : CANT START ASSOC");
-               connUp = FALSE;
+               DU_LOG("DEBUG  -->  Event : CANT START ASSOC");
+               destCb->connUp = FALSE;
                break;
             default:
-               DU_LOG("\nInvalid event");
+               DU_LOG("\nERROR  -->  Invalid event");
                break;
          }
          break;
       case CM_INET_SCTP_PEER_ADDR_CHANGE :
-         DU_LOG("\nSCTP : Peer Address Change notificarion received");
+         DU_LOG("\nINFO  -->  SCTP : Peer Address Change notificarion received");
          /* Need to add handler */
          break;
       case CM_INET_SCTP_REMOTE_ERROR :
-         DU_LOG("\nSCTP : Remote Error notification received");
+         DU_LOG("\nINFO  -->  SCTP : Remote Error notification received");
          break;
       case CM_INET_SCTP_SEND_FAILED :
-         DU_LOG("\nSCTP : Send Failed notification received\n");
+         DU_LOG("\nINFO  -->  SCTP : Send Failed notification received\n");
          break;
       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
-         DU_LOG("\nSCTP : Shutdown Event notification received\n");
-         connUp = FALSE;
+         DU_LOG("\nINFO  -->  SCTP : Shutdown Event notification received\n");
+         destCb->connUp = FALSE;
+         exit(0);
          break;
       case CM_INET_SCTP_ADAPTATION_INDICATION :
-         DU_LOG("\nSCTP : Adaptation Indication received\n");
+         DU_LOG("\nINFO  -->  SCTP : Adaptation Indication received\n");
          break;
       case CM_INET_SCTP_PARTIAL_DELIVERY_EVENT:
-         DU_LOG("\nSCTP : Partial Delivery Event received\n");
+         DU_LOG("\nINFO  -->  SCTP : Partial Delivery Event received\n");
          break;
       default:
-         DU_LOG("\nSCTP : Invalid notification type\n");
+         DU_LOG("\nERROR  -->  SCTP : Invalid notification type\n");
          break;
    }
 
    sctpNtfyInd(ntfy);
-   RETVALUE(ROK);
+   return ROK;
 }/* End of sctpNtfyHdlr */
 
 /*******************************************************************
@@ -383,184 +405,167 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSockPoll()
+uint8_t sctpSockPoll()
 {
-   U8   ret;
-   S16  numFds;
-   CmInetFdSet   readFd;
-   U16           port;
-   U32           timeout;           /* timeout for cmInetSelect() */
-   U32           *timeoutPtr;        /* pointer to timeout */
-   U32            flag;
-   Buffer        *mBuf;
+   uint8_t       destIdx;
+   uint16_t      ret = ROK;
+   uint32_t      timeout;
+   uint32_t      *timeoutPtr;
    Buffer        *egtpBuf;
-   MsgLen        bufLen;
    MsgLen        egtpBufLen;
-   CmInetAddr    egtpFromAddr;   /* Egtp data sender address */
-   CmInetMemInfo memInfo;      /* buffer allocation info */
-   CmInetNetAddr addr;
-   CmInetSctpSndRcvInfo   info;
-   CmInetSctpNotification ntfy;
+   CmInetAddr    egtpFromAddr;
+   CmInetMemInfo memInfo;
+   sctpSockPollParams f1PollParams;
+   uint64_t      numMsgRcvd = 0;
 
-   if (sockFd.blocking)
-   {
-      /* blocking */
-      timeoutPtr = NULLP;
-   }
-   else
-   {
-      /* non-blocking */
-      timeout = 0;
-      timeoutPtr = &timeout;
-   }
+   memset(&f1PollParams, 0, sizeof(sctpSockPollParams));
+    
+
+   /* All sockets are non-blocking */
+   timeout = 0;
+   timeoutPtr = &timeout;
    memInfo.region = CU_APP_MEM_REG;
    memInfo.pool   = CU_POOL;
    
-   egtpFromAddr.port = egtpCb.dstCb.dstPort;
-   egtpFromAddr.address = egtpCb.dstCb.dstIp;
-
-   CM_INET_FD_ZERO(&readFd);
+   CM_INET_FD_ZERO(&f1PollParams.readFd);
 
    while(1)
    {
       /* Receiving SCTP data */
-      CM_INET_FD_SET(&sockFd, &readFd);
-      ret = cmInetSelect(&readFd, NULLP, timeoutPtr, &numFds);
-      if (CM_INET_FD_ISSET(&sockFd, &readFd))
+      for(destIdx = 0; destIdx < sctpCb.numDu; destIdx++)
       {
-         CM_INET_FD_CLR(&sockFd, &readFd);
-         ret = cmInetSctpRecvMsg(&sockFd, &addr, &port, &memInfo, &mBuf, &bufLen, &info, &flag, &ntfy);
-         if (ret != ROK)
+         if((ret = processPolling(&f1PollParams, &sctpCb.destCb[destIdx], timeoutPtr, &memInfo)) != ROK)
          {
-            DU_LOG("\nSCTP : Failed to receive sctp msg\n");
-         }
-         else
-         {
-            if ((flag & CM_INET_SCTP_MSG_NOTIFICATION) != 0)
-            {
-               ret = sctpNtfyHdlr(&ntfy);
-               if(ret != ROK)
-               {
-                  DU_LOG("\nSCTP : Failed to process sctp notify msg\n");
-               }
-            }
-            else if(connUp) /* If data received */
-            {
-               F1APMsgHdlr(mBuf);
-               SPutMsg(mBuf);
-            }
-            else
-            {
-               SPutMsg(mBuf);
-            }
+            DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for F1 at CU\n");
          }
       }
 
       /* Receiving EGTP data */
-      egtpBufLen = -1;
-      ret = cmInetRecvMsg(&(egtpCb.recvTptSrvr.sockFd), &egtpFromAddr, &memInfo, &egtpBuf, &egtpBufLen, CM_INET_NO_FLAG);
-      if(ret == ROK && egtpBuf != NULLP)
+      for(destIdx = 0; destIdx < egtpCb.numDu; destIdx++)
       {
-         DU_LOG("\nEGTP : Received message \n");
-         SPrntMsg(egtpBuf, 0 ,0);
-         cuEgtpHdlRecvMsg(egtpBuf);
+         
+         egtpFromAddr.port = egtpCb.dstCb[destIdx].dstPort;
+         egtpFromAddr.address = egtpCb.dstCb[destIdx].dstIp;
+         egtpBufLen = -1;
+         ret = cmInetRecvMsg(&(egtpCb.recvTptSrvr.sockFd), &egtpFromAddr, &memInfo, &egtpBuf, &egtpBufLen, CM_INET_NO_FLAG);
+         if(ret == ROK && egtpBuf != NULLP)
+         {
+            DU_LOG("\nINFO  -->  EGTP : Received UL Message [%ld] from DUid %d\n", numMsgRcvd+1, egtpCb.dstCb[destIdx].duId);
+            numMsgRcvd++;
+            //ODU_PRINT_MSG(egtpBuf, 0 ,0);
+            cuEgtpHdlRecvMsg(egtpBuf);
 
+         }
       }
    };
-
-   RETVALUE(ROK);
+   return (ret);
 }/* End of sctpSockPoll() */
 
 /*******************************************************************
  *
- * @brief Send message on SCTP socket
+ * @brief checks for valid readFd and process the InetSctpRecvMsg
+ * during polling 
  *
  * @details
  *
- *    Function : sctpSend 
+ *    Function : processPolling
  *
  *    Functionality:
- *        Send message on SCTP socket
+ *         checks for valid readFd and process the InetSctpRecvMsg
+ *         during polling
+ *
+ * @params[in]  Params required for polling
+ * @params[in]  SockFd for file descriptor
+ * @params[in]  timeoutPtr indicates the timeout value
+ * @params[in]  MemInfo indicates memory region
  *
- * @params[in] 
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 sctpSend(Buffer *mBuf)
-{
-   U8               ret;
-   MsgLen           len;          /* number of actually sent octets */
-   CmInetNetAddr    peerAddr;     /* destination port address */
-   CmInetNetAddr    *dstAddr;
-   CmInetMemInfo    memInfo;                        
-   
-   memInfo.region = CU_APP_MEM_REG;               
-   memInfo.pool   = CU_POOL;
-
-
-   if(sctpCfg->duIpAddr.ipV4Pres)
-   {
-      peerAddr.type = CM_INET_IPV4ADDR_TYPE;
-      peerAddr.u.ipv4NetAddr = CM_INET_NTOH_U32(sctpCfg->duIpAddr.ipV4Addr);
-      dstAddr = &peerAddr;
-   }
-   else if(sctpCfg->duIpAddr.ipV6Pres)
-   {
-      peerAddr.type = CM_INET_IPV6ADDR_TYPE;
-      //CM_INET_COPY_IPV6ADDR(&(primDstAddr.u.ipv6NetAddr),&(sctpCfg->duIpAddr.ipV6Addr);
-      dstAddr = &peerAddr;
-   }
-   else
-   {
-      dstAddr = NULLP;
-   }
 
-   ret = cmInetSctpSendMsg(&sockFd, dstAddr, sctpCfg->duPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
-   if(ret != ROK && ret != RWOULDBLOCK)
+uint8_t processPolling(sctpSockPollParams *pollParams, CuSctpDestCb *destCb, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
+{
+   uint16_t ret = ROK;
+   CM_INET_FD_SET(&destCb->sockFd, &pollParams->readFd);
+   ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFd);
+   if(CM_INET_FD_ISSET(&destCb->sockFd, &pollParams->readFd))
    {
-      DU_LOG("\nSCTP : Send message failed");
-      RETVALUE(RFAILED);
-   }
-
-   RETVALUE(ROK);
-} /* End of sctpSend */
+      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))
+      {
+         destCb->bReadFdSet = RFAILED;
+      }
+      else
+      {
+         if(((pollParams->flag & CM_INET_SCTP_MSG_NOTIFICATION) != 0) && (ret == ROK))
+         {
+            ret = sctpNtfyHdlr(destCb, &pollParams->ntfy);
+            if(ret != ROK)
+            {
+               DU_LOG("\nERROR  -->  SCTP : Failed to process sctp notify msg\n");
+            }
+         }
+         else if(destCb->connUp & (pollParams->port == destCb->destPort))
+         {  
+            F1APMsgHdlr(&destCb->duId, pollParams->mBuf);
+            ODU_PUT_MSG_BUF(pollParams->mBuf);
+         }
+         else
+         {
+            ODU_PUT_MSG_BUF(pollParams->mBuf);
+         }
+      } 
+  }
+  return ROK;
+}/* End of sctpSockPoll() */
 
 /*******************************************************************
  *
- * @brief Start SCTP at CU
+ * @brief Send message on SCTP socket
  *
  * @details
  *
- *    Function : sctpStartReq
+ *    Function : sctpSend 
  *
  *    Functionality:
- *         Start SCTP at CU
+ *        Send message on SCTP socket
  *
- * @params[in]
+ * @params[in] 
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
-void sctpStartReq()
+uint8_t sctpSend(uint32_t duId, Buffer *mBuf)
 {
-   if(openSctpEndp() != ROK)
-   {
-      DU_LOG("\nSCTP : Failed while opening socket");
-   }
-   else if(bindSctpEndp() != ROK)
-   {
-      DU_LOG("\nSCTP : Failed while binding socket");
-   }
-   else if(sctpAccept() != ROK)
-   {
-      DU_LOG("\nSCTP : Failed while accepting connection");
-   }
-   else if(sctpSockPoll() != ROK)
+   uint8_t          ret = ROK, destIdx = 0;
+   MsgLen           len = 0;          /* number of actually sent octets */
+   CmInetMemInfo    memInfo;                        
+  
+   memset(&memInfo , 0, sizeof(CmInetMemInfo));
+   memInfo.region = CU_APP_MEM_REG;               
+   memInfo.pool   = CU_POOL;
+
+   for(destIdx=0; destIdx < sctpCb.numDu; destIdx++)
    {
-      DU_LOG("\nSCTP : Failed while polling");
+      if(sctpCb.destCb[destIdx].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);
+
+         if(ret != ROK && ret != RWOULDBLOCK)
+         {
+            DU_LOG("\nERROR  -->  SCTP : Send message failed");
+            return RFAILED;
+         }
+         return ROK;
+      }
    }
-} /* End of sctpAssocReq */
+   DU_LOG("\nERROR  -->  SCTP : DU ID [%d] not found in SCTP DestCb list. Failed to send message", duId);
+   return RFAILED;
+} /* End of sctpSend */
 
 /**********************************************************************
          End of file