X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fdu_app%2Fdu_sctp.c;h=25bccb37c2de4a90fe2c34232f5aed1ca7be23d7;hb=80a4fa9d0aede180472530cab6efa6acc925424b;hp=8e6bcb7198d20755d2faf5e3e1332e510a1ace26;hpb=8660dd47a5ef27b62300fabf6b027852f1d5d026;p=o-du%2Fl2.git diff --git a/src/du_app/du_sctp.c b/src/du_app/du_sctp.c index 8e6bcb719..25bccb37c 100644 --- a/src/du_app/du_sctp.c +++ b/src/du_app/du_sctp.c @@ -82,7 +82,7 @@ S16 sctpActvTsk(Pst *pst, Buffer *mBuf) { switch(pst->event) { - case EVTSTRTPOLL: + case EVTSTARTPOLL: { sctpSockPoll(); break; @@ -94,6 +94,32 @@ S16 sctpActvTsk(Pst *pst, Buffer *mBuf) SExitTsk(); return ROK; } +/******************************************************************* + * + * @brief Checks the status of the received information + * + * @details + * + * Function : duCheckReqStatus + * + * Functionality: + * Checks the status of the received information + * + * @params[in] Confirm status + * @return ROK - success + * RFAILED - failure + * + ******************************************************************/ +S16 duCheckReqStatus(CmStatus *cfm) +{ + S16 ret = ROK; + if(cfm->status != LCM_PRIM_OK) + { + DU_LOG("\nDU_APP : Failed to process the request successfully"); + ret = RFAILED; + } + RETVALUE(ret); +} /************************************************************************** * @brief Function to configure the Sctp Params during config Request @@ -114,15 +140,18 @@ S16 sctpActvTsk(Pst *pst, Buffer *mBuf) * ***************************************************************************/ -S16 duSctpCfgReq(SctpParams sctpCfg, CmStatus *cfm) +S16 duSctpCfgReq(SctpParams sctpCfg) { + S16 ret = ROK; + CmStatus cfm; + /* Fill F1 Params */ f1Params.destIpAddr.ipV4Pres = sctpCfg.cuIpAddr.ipV4Pres; f1Params.destIpAddr.ipV4Addr = sctpCfg.cuIpAddr.ipV4Addr; f1Params.destPort = sctpCfg.cuPort; f1Params.itfState = DU_SCTP_DOWN; - f1Params.srcPort = sctpCfg.duPort[0]; - f1Params.recvMsgSet = ROK; + f1Params.srcPort = sctpCfg.duPort[F1_INTERFACE]; + f1Params.recvMsgSet = ROK; cmMemset ((U8 *)&f1Params.sockFd, -1, sizeof(CmInetFd)); fillDestNetAddr(&f1Params.destIpNetAddr, &f1Params.destIpAddr); fillAddrLst(&f1Params.destAddrLst, &f1Params.destIpAddr); @@ -132,8 +161,8 @@ S16 duSctpCfgReq(SctpParams sctpCfg, CmStatus *cfm) ricParams.destIpAddr.ipV4Addr = sctpCfg.ricIpAddr.ipV4Addr; ricParams.destPort = sctpCfg.ricPort; ricParams.itfState = DU_SCTP_DOWN; - ricParams.srcPort = sctpCfg.duPort[1]; - ricParams.recvMsgSet = ROK; + ricParams.srcPort = sctpCfg.duPort[E2_INTERFACE]; + ricParams.recvMsgSet = ROK; cmMemset ((U8 *)&ricParams.sockFd, -1, sizeof(CmInetFd)); fillDestNetAddr(&ricParams.destIpNetAddr, &ricParams.destIpAddr); fillAddrLst(&ricParams.destAddrLst, &ricParams.destIpAddr); @@ -145,10 +174,12 @@ S16 duSctpCfgReq(SctpParams sctpCfg, CmStatus *cfm) pollingState = FALSE; /* Fill Cfm Status */ - cfm->status = LCM_PRIM_OK; - cfm->reason = LCM_REASON_NOT_APPL; + cfm.status = LCM_PRIM_OK; + cfm.reason = LCM_REASON_NOT_APPL; - RETVALUE(ROK); + ret = duCheckReqStatus(&cfm); + + RETVALUE(ret); } /******************************************************************* @@ -260,14 +291,14 @@ S16 establishReq(DuSctpDestCb *paramPtr) } if((ret == ROK) & (paramPtr->itfState == DU_SCTP_DOWN)) { - paramPtr->itfState = DU_SCTP_UP; + paramPtr->itfState = DU_SCTP_CONNECTING; } - /* Post the EVTSTRTPOLL Msg */ + /* Post the EVTSTARTPOLL Msg */ if(!pollingState) { pollingState = TRUE; - duFillSctpPst(&pst, EVTSTRTPOLL); + duFillSctpPst(&pst, EVTSTARTPOLL); } RETVALUE(ret); @@ -292,10 +323,12 @@ S16 establishReq(DuSctpDestCb *paramPtr) * *******************************************************************************/ -S16 duSctpAssocReq(U8 itfType, CmStatus *cfm) +S16 duSctpAssocReq(U8 itfType) { S16 ret = ROK; + CmStatus cfm; DuSctpDestCb *paramPtr = NULLP; + if(SGetSBuf(DU_APP_MEM_REGION, DU_POOL, (Data **)¶mPtr, (Size)sizeof(DuSctpDestCb)) != ROK) { printf("\nDU_APP : Failed to allocate memory"); @@ -324,14 +357,15 @@ S16 duSctpAssocReq(U8 itfType, CmStatus *cfm) if(ret != ROK) { DU_LOG("\nSCTP : ASSOC Req Failed."); - cfm->status = LCM_PRIM_NOK; - cfm->reason = LCM_REASON_NOT_APPL; + cfm.status = LCM_PRIM_NOK; + cfm.reason = LCM_REASON_NOT_APPL; } else { - cfm->status = LCM_PRIM_OK; - cfm->reason = LCM_REASON_NOT_APPL; + cfm.status = LCM_PRIM_OK; + cfm.reason = LCM_REASON_NOT_APPL; } + ret = duCheckReqStatus(&cfm); RETVALUE(ret); } @@ -471,7 +505,7 @@ void sendToDuApp(Buffer *mBuf, Event event) * RFAILED - failure * * ****************************************************************/ -S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy) +S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy, U8 *itfState) { Pst pst; @@ -483,23 +517,23 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy) { case CM_INET_SCTP_COMM_UP: DU_LOG("Event : COMMUNICATION UP"); - connUp = TRUE; + *itfState = DU_SCTP_UP; break; case CM_INET_SCTP_COMM_LOST: DU_LOG("Event : COMMUNICATION LOST"); - connUp = FALSE; + *itfState = DU_SCTP_DOWN; break; case CM_INET_SCTP_RESTART: DU_LOG("Event : SCTP RESTART"); - connUp = FALSE; + *itfState = DU_SCTP_DOWN; break; case CM_INET_SCTP_SHUTDOWN_COMP: /* association gracefully shutdown */ DU_LOG("Event : SHUTDOWN COMPLETE"); - connUp = FALSE; + *itfState = DU_SCTP_DOWN; break; case CM_INET_SCTP_CANT_STR_ASSOC: DU_LOG("Event : CANT START ASSOC"); - connUp = FALSE; + *itfState = DU_SCTP_DOWN; break; default: DU_LOG("\nInvalid event"); @@ -518,7 +552,7 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy) break; case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */ DU_LOG("\nSCTP : Shutdown Event notification received\n"); - connUp = FALSE; + *itfState = DU_SCTP_DOWN; exit(0); break; case CM_INET_SCTP_ADAPTATION_INDICATION : @@ -542,7 +576,7 @@ S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy) pst.dstEnt = (Ent)ENTDUAPP; pst.dstInst = (Inst)DU_INST; pst.dstProcId = pst.srcProcId; - pst.event = EVTSCTPNTFY; + pst.event = EVENT_SCTP_NTFY; pst.selector = DU_SELECTOR_LC; pst.pool= DU_POOL; pst.region = DFLT_REGION; @@ -582,13 +616,13 @@ S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, U32 *timeou { U16 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); ret = cmInetSctpRecvMsg(sockFd, &pollParams->addr, &pollParams->port, memInfo, &(pollParams->mBuf), &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy); - if(connUp && ret != ROK) + if(ret != ROK) { DU_LOG("\n SCTP: Failed to receive sctp msg for sockFd[%d]\n", sockFd->fd); recvMsgSet = RFAILED; @@ -601,29 +635,31 @@ S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, U32 *timeou { f1Params.assocId = pollParams->ntfy.u.assocChange.assocId; DU_LOG("\nSCTP : AssocId assigned to F1Params from PollParams [%d]\n", f1Params.assocId); + ret = sctpNtfyHdlr(&pollParams->ntfy, &f1Params.itfState); } else if(pollParams->port == ricParams.destPort) { ricParams.assocId = pollParams->ntfy.u.assocChange.assocId; DU_LOG("\nSCTP : AssocId assigned to ricParams from PollParams [%d]\n", ricParams.assocId); + ret = sctpNtfyHdlr(&pollParams->ntfy, &ricParams.itfState); } else { DU_LOG("\nSCTP : Failed to fill AssocId\n"); - } - ret = sctpNtfyHdlr(&pollParams->ntfy); + RETVALUE(RFAILED); + } if(ret != ROK) { DU_LOG("\nSCTP : Failed to process sctp notify msg\n"); } } - else if(connUp & (pollParams->port == f1Params.destPort)) + else if(f1Params.itfState & (pollParams->port == f1Params.destPort)) { - sendToDuApp(pollParams->mBuf, EVTSCTPDATA); + sendToDuApp(pollParams->mBuf, EVENT_CU_DATA); } - else if(connUp & (pollParams->port == ricParams.destPort)) + else if(ricParams.itfState & (pollParams->port == ricParams.destPort)) { - sendToDuApp(pollParams->mBuf, EVTRICDATA); + sendToDuApp(pollParams->mBuf, EVENT_RIC_DATA); } else