/* This file contains all SCTP related functionality */
-#include <stdio.h>
+#include "common_def.h"
#include "ric_e2ap_msg_hdl.h"
#include "ric_stub_sctp.h"
+#include "ric_stub.h"
+#include "E2AP-PDU.h"
+#include "du_log.h"
CuSctpDestCb ricParams;
-
-/**************************************************************************
- * @brief Task Initiation callback function.
- *
- * @details
- *
- * Function : sctpActvInit
- *
- * Functionality:
- * This function is supplied as one of parameters during SCTP's
- * task registration. SSI will invoke this function once, after
- * it creates and attaches this TAPA Task to a system task.
- *
- * @param[in] Ent entity, the entity ID of this task.
- * @param[in] Inst inst, the instance ID of this task.
- * @param[in] Region region, the region ID registered for memory
- * usage of this task.
- * @param[in] Reason reason.
- * @return ROK - success
- * RFAILED - failure
- ***************************************************************************/
-S16 sctpActvInit()
-{
- DU_LOG("\n\nSCTP : Initializing");
- connUp = FALSE;
- assocId = 0;
- nonblocking = FALSE;
- sctpCfg = cuCfgParams.sctpParams;
- return ROK;
-
-}
-
-/**************************************************************************
- * @brief Task Activation callback function.
- *
- * @details
- *
- * Function : sctpActvTsk
- *
- * Functionality:
- * This function handles all SCTP messages received
- * This API is registered with SSI during the
- * Task Registration of DU APP.
- *
- * @param[in] Pst *pst, Post structure of the primitive.
- * @param[in] Buffer *mBuf, Packed primitive parameters in the
- * buffer.
- * @return ROK - success
- * RFAILED - failure
- *
- ***************************************************************************/
-S16 sctpActvTsk(Pst *pst, Buffer *mBuf)
-{
-
-//TODO: TBD
- return ROK;
-}
+RicSctpParams sctpCfg;
+S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, SctpIpAddr *ipAddr);
+S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, SctpIpAddr *dstIpPtr);
/**************************************************************************
* @brief Function to configure the Sctp Params during config Request
*
* @details
*
- * Function : duSctpCfgReq
+ * Function : sctpCfgReq
*
* Functionality:
* This function configures SCTP Params during the config Request
S16 sctpCfgReq()
{
+ connUp = FALSE;
+ sctpCfg = ricCfgParams.sctpParams;
/* Fill F1 Params */
ricParams.destPort = sctpCfg.duPort;
ricParams.srcPort = sctpCfg.ricPort;
ricParams.bReadFdSet = ROK;
- cmMemset ((U8 *)&ricParams.sockFd, -1, sizeof(CmInetFd));
- cmMemset ((U8 *)&ricParams.lstnSockFd, -1, sizeof(CmInetFd));
+ memset(&ricParams.sockFd, -1, sizeof(CmInetFd));
+ memset(&ricParams.lstnSockFd, -1, sizeof(CmInetFd));
fillDestNetAddr(&ricParams.destIpNetAddr, &sctpCfg.duIpAddr);
- RETVALUE(ROK);
+ return ROK;
}
/*******************************************************************
{
addrLstPtr->count++;
addrLstPtr->addrs[(addrLstPtr->count - 1)].type = CM_INET_IPV4ADDR_TYPE;
- addrLstPtr->addrs[(addrLstPtr->count - 1)].u.ipv4NetAddr = CM_INET_NTOH_U32(ipAddr->ipV4Addr);
+ addrLstPtr->addrs[(addrLstPtr->count - 1)].u.ipv4NetAddr = CM_INET_NTOH_UINT32(ipAddr->ipV4Addr);
- RETVALUE(ROK);
+ return ROK;
}
/******************************************************************************
{
/* Filling destination address */
destAddrPtr->type = CM_INET_IPV4ADDR_TYPE;
- destAddrPtr->u.ipv4NetAddr = CM_INET_NTOH_U32(dstIpPtr->ipV4Addr);
- RETVALUE(ROK);
+ destAddrPtr->u.ipv4NetAddr = CM_INET_NTOH_UINT32(dstIpPtr->ipV4Addr);
+ return ROK;
}
/******************************************************************************
}
else if((ret = cmInetSctpBindx(&ricParams.lstnSockFd, &ricParams.localAddrLst, ricParams.srcPort)) != ROK)
{
- DU_LOG("\nSCTP: Binding failed at CU");
+ DU_LOG("\nSCTP: Binding failed at RIC");
}
else if((ret = sctpAccept(&ricParams.lstnSockFd, &ricParams.peerAddr, &ricParams.sockFd)) != ROK)
{
- DU_LOG("\nSCTP: Unable to accept the connection at CU");
+ DU_LOG("\nSCTP: Unable to accept the connection at RIC");
}
else if(sctpSockPoll() != ROK)
{
DU_LOG("\nSCTP: Polling failed to start at RIC");
}
- RETVALUE(ret);
+ return (ret);
}
/*******************************************************************
*
ret = RFAILED;
}
- RETVALUE(ret);
+ return (ret);
}
/*******************************************************************
* ****************************************************************/
S16 sctpAccept(CmInetFd *lstnSock_Fd, CmInetAddr *peerAddr, CmInetFd *sock_Fd)
{
- U8 ret;
-
- ret = cmInetListen(lstnSock_Fd, 1);;
+ uint8_t ret;
+
+ ret = cmInetListen(lstnSock_Fd, 1);
if (ret != ROK)
{
DU_LOG("\nSCTP : Listening on socket failed");
cmInetClose(lstnSock_Fd);
- RETVALUE(RFAILED);
+ return RFAILED;
}
DU_LOG("\nSCTP : Connecting");
else if(ret != ROK)
{
DU_LOG("\nSCTP : Failed to accept connection");
- RETVALUE(RFAILED);
+ return RFAILED;
}
else
{
}
DU_LOG("\nSCTP : Connection established");
- RETVALUE(ROK);
+ return ROK;
}
/*******************************************************************
}
sctpNtfyInd(ntfy);
- RETVALUE(ROK);
+ return ROK;
}/* End of sctpNtfyHdlr */
/*******************************************************************
* ****************************************************************/
S16 sctpSockPoll()
{
- U16 ret = ROK;
- U32 timeout;
- U32 *timeoutPtr;
- CmInetMemInfo memInfo;
+ uint16_t ret = ROK;
+ uint32_t timeout;
+ uint32_t *timeoutPtr;
+ CmInetMemInfo memInfo;
sctpSockPollParams e2PollParams;
memset(&e2PollParams, 0, sizeof(sctpSockPollParams));
{
if((ret = processPolling(&e2PollParams, &ricParams.sockFd, timeoutPtr, &memInfo)) != ROK)
{
- DU_LOG("\nSCTP : Failed to RecvMsg for E2 at CU \n");
+ DU_LOG("\nSCTP : Failed to RecvMsg for E2 at RIC \n");
}
};
- RETVALUE(ret);
+ return (ret);
}/* End of sctpSockPoll() */
/*******************************************************************
* ****************************************************************/
-S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, U32 *timeoutPtr, CmInetMemInfo *memInfo)
+S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, uint32_t *timeoutPtr, CmInetMemInfo *memInfo)
{
- U16 ret = ROK;
+ uint16_t ret = ROK;
CM_INET_FD_SET(sockFd, &pollParams->readFd);
- ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFds);
+ ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFd);
if(CM_INET_FD_ISSET(sockFd, &pollParams->readFd))
{
CM_INET_FD_CLR(sockFd, &pollParams->readFd);
else if(connUp & (pollParams->port == ricParams.destPort))
{
E2APMsgHdlr(pollParams->mBuf);
- SPutMsg(pollParams->mBuf);
+ ODU_PUT_MSG_BUF(pollParams->mBuf);
}
else
{
- SPutMsg(pollParams->mBuf);
+ ODU_PUT_MSG_BUF(pollParams->mBuf);
}
}
}
- RETVALUE(ROK);
+ return ROK;
}/* End of sctpSockPoll() */
/*******************************************************************
* ****************************************************************/
S16 sctpSend(Buffer *mBuf)
{
- U8 ret;
+ uint8_t ret;
MsgLen len; /* number of actually sent octets */
CmInetMemInfo memInfo;
if(ret != ROK && ret != RWOULDBLOCK)
{
DU_LOG("\nSCTP : Send message failed");
- RETVALUE(RFAILED);
+ return RFAILED;
}
- RETVALUE(ROK);
+ return ROK;
} /* End of sctpSend */
/**********************************************************************
End of file