E2AP review changes part1
[o-du/l2.git] / src / du_app / du_sctp.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /* This file contains all SCTP related functionality */
20
21 #include <stdio.h> 
22 #include "du_sctp.h"
23 #include "lsctp.h"
24
25
26 /**************************************************************************
27  * @brief Task Initiation callback function. 
28  *
29  * @details
30  *
31  *     Function : sctpActvInit 
32  *    
33  *     Functionality:
34  *             This function is supplied as one of parameters during SCTP's 
35  *             task registration. SSI will invoke this function once, after
36  *             it creates and attaches this TAPA Task to a system task.
37  *     
38  * @param[in]  Ent entity, the entity ID of this task.     
39  * @param[in]  Inst inst, the instance ID of this task.
40  * @param[in]  Region region, the region ID registered for memory 
41  *              usage of this task.
42  * @param[in]  Reason reason.
43  * @return ROK     - success
44  *         RFAILED - failure
45  ***************************************************************************/
46 S16 sctpActvInit(Ent entity, Inst inst, Region region, Reason reason)
47 {
48    DU_LOG("\n\nSCTP : Initializing");
49    SSetProcId(DU_PROC);
50    connUp = FALSE;
51    f1Params.assocId = -1;
52    ricParams.assocId = -1;
53    nonblocking = FALSE;
54    return ROK;
55
56 }
57
58 /**************************************************************************
59  * @brief Task Activation callback function. 
60  *
61  * @details
62  *
63  *      Function : sctpActvTsk 
64  * 
65  *      Functionality:
66  *           This function handles all SCTP messages received
67  *           This API is registered with SSI during the 
68  *           Task Registration of DU APP.
69  *     
70  * @param[in]  Pst     *pst, Post structure of the primitive.     
71  * @param[in]  Buffer *mBuf, Packed primitive parameters in the
72  *  buffer.
73  * @return ROK     - success
74  *         RFAILED - failure
75  *
76  ***************************************************************************/
77 S16 sctpActvTsk(Pst *pst, Buffer *mBuf)
78 {
79    switch(pst->srcEnt)
80    {
81       case ENTDUAPP:
82          {
83             switch(pst->event)
84             {
85                case EVTSTARTPOLL:
86                {
87                   sctpSockPoll();
88                   break;
89                } 
90             }
91             break;
92          }
93    }
94    SExitTsk();
95    return ROK;
96 }
97 /*******************************************************************
98  *
99  * @brief Checks the status of the received information
100  *
101  * @details
102  *
103  *    Function : duCheckReqStatus
104  *
105  *    Functionality:
106  *       Checks the status of the received information
107  *
108  * @params[in] Confirm status
109  * @return ROK     - success
110  *         RFAILED - failure
111  *
112  ******************************************************************/
113 S16 duCheckReqStatus(CmStatus *cfm)
114 {
115    S16 ret = ROK;
116    if(cfm->status != LCM_PRIM_OK)
117    {
118       DU_LOG("\nDU_APP : Failed to process the request successfully");
119       ret = RFAILED;
120    }
121    RETVALUE(ret); 
122 }
123
124 /**************************************************************************
125  * @brief Function to configure the Sctp Params during config Request
126  *
127  * @details
128  *
129  *      Function : duSctpCfgReq
130  * 
131  *      Functionality:
132  *           This function configures SCTP Params during the config Request
133  *     
134  * @param[in]  SctpParams sctpCfg, common structure which has all the configuration
135  * @param[in]  CmStatus cfm, Builds the cfm status and reason
136  *  buffer.
137  *
138  * @return ROK     - success
139  *         RFAILED - failure
140  *
141  ***************************************************************************/
142
143 S16 duSctpCfgReq(SctpParams sctpCfg)
144 {
145    S16 ret = ROK;
146         CmStatus cfm;
147
148 /* Fill F1 Params */
149    f1Params.destIpAddr.ipV4Pres  = sctpCfg.cuIpAddr.ipV4Pres;
150    f1Params.destIpAddr.ipV4Addr  = sctpCfg.cuIpAddr.ipV4Addr;
151    f1Params.destPort             = sctpCfg.cuPort;
152    f1Params.itfState             = DU_SCTP_DOWN;
153    f1Params.srcPort              = sctpCfg.duPort[F1_INTERFACE];
154    f1Params.recvMsgSet           = ROK;
155    cmMemset ((U8 *)&f1Params.sockFd, -1, sizeof(CmInetFd));
156    fillDestNetAddr(&f1Params.destIpNetAddr, &f1Params.destIpAddr);
157    fillAddrLst(&f1Params.destAddrLst, &f1Params.destIpAddr);
158
159 /* Fill RIC Params */
160    ricParams.destIpAddr.ipV4Pres = sctpCfg.ricIpAddr.ipV4Pres;
161    ricParams.destIpAddr.ipV4Addr = sctpCfg.ricIpAddr.ipV4Addr;
162    ricParams.destPort            = sctpCfg.ricPort;
163    ricParams.itfState            = DU_SCTP_DOWN;
164    ricParams.srcPort             = sctpCfg.duPort[E2_INTERFACE];
165    ricParams.recvMsgSet          = ROK;
166    cmMemset ((U8 *)&ricParams.sockFd, -1, sizeof(CmInetFd));
167    fillDestNetAddr(&ricParams.destIpNetAddr, &ricParams.destIpAddr);
168    fillAddrLst(&ricParams.destAddrLst, &ricParams.destIpAddr);
169
170 /* Fill AddressList */
171    fillAddrLst(&localAddrLst, &sctpCfg.duIpAddr);
172
173 /* Set polling to FALSE */
174    pollingState = FALSE;  
175
176 /* Fill Cfm Status */
177    cfm.status = LCM_PRIM_OK;
178    cfm.reason = LCM_REASON_NOT_APPL;
179
180    ret = duCheckReqStatus(&cfm);
181
182    RETVALUE(ret);
183 }
184
185 /*******************************************************************
186  *
187  * @brief Fills the address List of the source Ip Address
188  *
189  * @details
190  *
191  *    Function : fillAddrLst
192  *
193  *    Functionality:
194  *       Fills the address List of source Ip Address
195  *
196  * @params[in] CmInetNetAddrLst *addrLstPtr, Address List pointer
197  * @params[in] F1IpAddr *srcIpAddr, src Ip Adrress to be filled in the Address List
198  *
199  * @return ROK     - success
200  *         RFAILED - failure
201  *
202  ******************************************************************/
203
204 S16 fillAddrLst(CmInetNetAddrLst *addrLstPtr, F1IpAddr *ipAddr)
205
206    addrLstPtr->count++;
207    addrLstPtr->addrs[(addrLstPtr->count - 1)].type = CM_INET_IPV4ADDR_TYPE;
208    addrLstPtr->addrs[(addrLstPtr->count - 1)].u.ipv4NetAddr = CM_INET_NTOH_U32(ipAddr->ipV4Addr);
209
210    RETVALUE(ROK);
211 }
212
213 /******************************************************************************
214  *
215  * @brief Fills the address List of the source Ip Address
216  *
217  * @details
218  *
219  *    Function : fillDestNetAddr
220  *
221  *    Functionality:
222  *       Fills the address List of destinatoion Ip Address
223  *
224  * @params[in] CmInetNetAddr *destAddrPtr, Address List pointer
225  * @params[in] F1IpAddr *dstIpAddr, destIp Address to be filled in the Address List
226  *
227  * @return ROK     - success
228  *         RFAILED - failure
229  *
230  *******************************************************************************/
231 S16 fillDestNetAddr(CmInetNetAddr *destAddrPtr, F1IpAddr *dstIpPtr)
232 {
233    /* Filling destination address */
234    destAddrPtr->type = CM_INET_IPV4ADDR_TYPE;
235    destAddrPtr->u.ipv4NetAddr = CM_INET_NTOH_U32(dstIpPtr->ipV4Addr);
236    RETVALUE(ROK);
237 }
238
239 /******************************************************************************
240  *
241  * @brief Establishes the Assoc Req for the received interface type
242  *
243  * @details
244  *
245  *    Function : establishAssocReq
246  *
247  *    Functionality:
248  *       Eastablishes the Assoc Req for the received interface type
249  *
250  * @params[in] DuSctpDestCb *paramPtr
251  *
252  * @return ROK     - success
253  *         RFAILED - failure
254  *
255  *******************************************************************************/
256
257 S16 establishReq(DuSctpDestCb *paramPtr)
258 {
259    Pst pst;
260    S16 ret = ROK;
261    socket_type = CM_INET_STREAM;
262
263    if((ret = cmInetSocket(socket_type, &paramPtr->sockFd, IPPROTO_SCTP)) != ROK)
264    {
265       DU_LOG("\nSCTP : Failed while opening a socket in ODU");
266    } 
267    else if((ret = cmInetSctpBindx(&paramPtr->sockFd, &localAddrLst, paramPtr->srcPort)) != ROK)
268    {
269       DU_LOG("\nSCTP:  Failed during Binding in ODU");
270    }
271    else if((ret = sctpSetSockOpts(&paramPtr->sockFd)) != ROK)
272    {
273       DU_LOG("\nSCTP : Failed to set Socket Opt in ODU");
274    }     
275    else
276    { 
277       if(ret != ROK)
278       {
279          DU_LOG("\nSCTP : Failed while establishing Req at DU");
280          ret = RFAILED;
281       }
282       else 
283       {
284          ret = cmInetSctpConnectx(&paramPtr->sockFd, &paramPtr->destIpNetAddr, &paramPtr->destAddrLst, paramPtr->destPort);
285          /* 115 error_code indicates that Operation is in progress and hence ignored if SctpConnect failed due to this */
286          if(ret == 18)             
287          {
288            ret = ROK; 
289          }
290       }
291    }
292    if((ret == ROK) & (paramPtr->itfState == DU_SCTP_DOWN))
293    {
294       paramPtr->itfState = DU_SCTP_UP;
295    }
296
297    /* Post the EVTSTARTPOLL Msg */
298    if(!pollingState)
299    {
300       pollingState = TRUE;
301       duFillSctpPst(&pst, EVTSTARTPOLL);
302    }
303    
304    RETVALUE(ret);
305 }
306
307 /******************************************************************************
308  *
309  * @brief Processes the assoc Req for the received interface type
310  *
311  * @details
312  *
313  *    Function : duSctpAssocReq
314  *
315  *    Functionality:
316  *       Processes the Assoc Req for the received interface type
317  *
318  * @params[in] itfType interface Type, 
319  * @params[in] cfm , represents the status of request
320  * 
321  * @return ROK     - success
322  *         RFAILED - failure
323  *
324  *******************************************************************************/
325
326 S16 duSctpAssocReq(U8 itfType)
327 {
328    S16 ret = ROK;
329         CmStatus cfm;
330    DuSctpDestCb *paramPtr = NULLP;
331
332    if(SGetSBuf(DU_APP_MEM_REGION, DU_POOL, (Data **)&paramPtr, (Size)sizeof(DuSctpDestCb)) != ROK)
333    {
334       printf("\nDU_APP : Failed to allocate memory");
335       RETVALUE(RFAILED);
336    }
337    switch(itfType)
338    {
339       case F1_INTERFACE:
340       {
341          paramPtr = &f1Params;
342          ret = establishReq(paramPtr);
343          break;
344       }
345       case E2_INTERFACE:
346       {
347          paramPtr = &ricParams;
348          ret = establishReq(paramPtr);
349          break;
350       }
351       default:
352       {
353          DU_LOG("\nSCTP : Invalid Interface Type");
354          break;
355       }
356    }  
357    if(ret != ROK)
358    { 
359       DU_LOG("\nSCTP : ASSOC Req Failed.");
360       cfm.status = LCM_PRIM_NOK;
361       cfm.reason = LCM_REASON_NOT_APPL;
362    }
363    else
364    {
365       cfm.status = LCM_PRIM_OK;
366       cfm.reason = LCM_REASON_NOT_APPL;
367    }
368    ret = duCheckReqStatus(&cfm);
369
370    RETVALUE(ret);
371 }
372 /*******************************************************************
373  *
374  * @brief  Fills Pst struct for ENTSCTP
375  *
376  * @details
377  *
378  *    Function : duFillSctpPst
379  *
380  *    Functionality:
381  *       Fills Pst struct for ENTSCTP
382  *
383  * @params[in] 
384  * @return ROK     - success
385  *         RFAILED - failure
386  *
387  * ****************************************************************/
388 S16 duFillSctpPst(Pst *pst, Event event)
389 {
390    Buffer *mBuf;
391    if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
392    {
393       printf("\nDU_APP : Failed to allocate memory");
394       RETVALUE(RFAILED);
395    }
396    cmMemset((U8 *)pst, 0, sizeof(Pst));
397    pst->srcEnt = (Ent)ENTDUAPP;
398    pst->srcInst = (Inst)DU_INST;
399    pst->srcProcId = DU_PROC;
400    pst->dstEnt = (Ent)ENTSCTP;
401    pst->dstInst = (Inst)SCTP_INST;
402    pst->dstProcId = pst->srcProcId;
403    pst->event = event;
404    pst->selector = DU_SELECTOR_LC;
405    pst->pool= DU_POOL;
406    SPstTsk(pst, mBuf); 
407
408    RETVALUE(ROK);
409 }
410
411 /*******************************************************************
412  *
413  * @brief Sets socket options as per requirement
414  *
415  * @details
416  *
417  *    Function : sctpSetSockOpts
418  *
419  *    Functionality: 
420  *       Sets socket options as per requirement
421  *
422  * @params[in] sock_Fd  determines the sockFd to be set
423  * @return ROK     - success
424  *         RFAILED - failure
425  *
426  * ****************************************************************/
427 S16 sctpSetSockOpts(CmInetFd *sock_Fd)
428 {
429     S16 ret = ROK;
430     CmSctpEvent sctpEvent;
431
432    sctpEvent.dataIoEvent          = TRUE;
433    sctpEvent.associationEvent     = TRUE;
434    sctpEvent.addressEvent         = TRUE;
435    sctpEvent.sendFailureEvent     = TRUE;
436    sctpEvent.peerErrorEvent       = TRUE;
437    sctpEvent.shutdownEvent        = TRUE;
438    sctpEvent.partialDeliveryEvent = TRUE;
439    sctpEvent.adaptationLayerEvent = TRUE;
440
441    if((ret = cmInetSetOpt(sock_Fd, CM_SOCKOPT_LEVEL_SCTP, CM_SOCKOPT_OPT_SCTP_EVENTS, &sctpEvent) != ROK))
442    {
443      ret = RFAILED;
444    }
445
446    RETVALUE(ret);
447 }
448
449 /*******************************************************************
450  *
451  * @brief Post received data/notification to DU APP 
452  *
453  * @details
454  *
455  *    Function : sendToDuApp 
456  *
457  *    Functionality:
458  *         Post received data/notification to DU APP
459  *
460  * @params[in]  Message buffer
461  *              Message event
462  *
463  * @return ROK     - success
464  *         RFAILED - failure
465  *
466  * ****************************************************************/
467 void sendToDuApp(Buffer *mBuf, Event event)
468 {
469    Pst pst;
470    DU_LOG("\nSCTP : Forwarding received message to duApp");
471    SPrntMsg(mBuf, 0, 0);
472
473
474    cmMemset((U8 *)&(pst), 0, sizeof(Pst));
475    pst.srcEnt = (Ent)ENTSCTP;
476    pst.srcInst = (Inst)SCTP_INST;
477    pst.srcProcId = DU_PROC;
478    pst.dstEnt = (Ent)ENTDUAPP;
479    pst.dstInst = (Inst)DU_INST;
480    pst.dstProcId = pst.srcProcId;
481    pst.event = event;
482    pst.selector = DU_SELECTOR_LC;
483    pst.pool= DU_POOL;
484    pst.region = DFLT_REGION;
485
486    if (SPstTsk(&pst, mBuf) != ROK)
487    {
488       DU_LOG("\nSCTP : SPstTsk failed in duReadCfg");
489    }
490 }
491
492 /*******************************************************************
493  *
494  * @brief Handles an SCTP notification message
495  *
496  * @Sending *
497  *    Function : sctpNtfyHdlr
498  *
499  *    Functionality:
500  *      Handles an SCTP notification message
501  *
502  * @params[in] Notify message
503  *
504  * @return ROK     - success
505  *         RFAILED - failure
506  *
507  * ****************************************************************/
508 S16 sctpNtfyHdlr(CmInetSctpNotification *ntfy)
509 {
510    Pst pst;
511
512    switch(ntfy->header.nType)
513    {
514       case CM_INET_SCTP_ASSOC_CHANGE :
515          DU_LOG("\nSCTP : Assoc change notification received");
516          switch(ntfy->u.assocChange.state)
517          {
518             case CM_INET_SCTP_COMM_UP:
519                DU_LOG("Event : COMMUNICATION UP");
520                connUp = TRUE;
521                break;
522             case CM_INET_SCTP_COMM_LOST:
523                DU_LOG("Event : COMMUNICATION LOST");
524                connUp = FALSE;
525                break;
526             case CM_INET_SCTP_RESTART:
527                DU_LOG("Event : SCTP RESTART");
528                connUp = FALSE;
529                break;
530             case CM_INET_SCTP_SHUTDOWN_COMP: /* association gracefully shutdown */
531                DU_LOG("Event : SHUTDOWN COMPLETE");
532                connUp = FALSE;
533                break;
534             case CM_INET_SCTP_CANT_STR_ASSOC:
535                DU_LOG("Event : CANT START ASSOC");
536                connUp = FALSE;
537                break;
538             default:
539                DU_LOG("\nInvalid event");
540                break;
541          }
542          break;
543       case CM_INET_SCTP_PEER_ADDR_CHANGE :
544          DU_LOG("\nSCTP : Peer Address Change notificarion received");
545          /* Need to add handler */
546          break;
547       case CM_INET_SCTP_REMOTE_ERROR :
548          DU_LOG("\nSCTP : Remote Error notification received");
549          break;
550       case CM_INET_SCTP_SEND_FAILED :
551          DU_LOG("\nSCTP : Send Failed notification received\n");
552          break;
553       case CM_INET_SCTP_SHUTDOWN_EVENT : /* peer socket gracefully closed */
554          DU_LOG("\nSCTP : Shutdown Event notification received\n");
555          connUp = FALSE;
556          exit(0);
557          break;
558       case CM_INET_SCTP_ADAPTATION_INDICATION :
559          DU_LOG("\nSCTP : Adaptation Indication received\n");
560          break;
561       case CM_INET_SCTP_PARTIAL_DELIVERY_EVENT:
562          DU_LOG("\nSCTP : Partial Delivery Event received\n");
563          break;
564       default:
565          DU_LOG("\nSCTP : Invalid sctp notification type\n");
566          break;
567    }
568
569    /* Pack notification and send to APP */
570    DU_LOG("\nSCTP : Forwarding received message to duApp");
571     
572    cmMemset((U8 *)&(pst), 0, sizeof(Pst));
573    pst.srcEnt = (Ent)ENTSCTP;
574    pst.srcInst = (Inst)SCTP_INST;
575    pst.srcProcId = DU_PROC;
576    pst.dstEnt = (Ent)ENTDUAPP;
577    pst.dstInst = (Inst)DU_INST;
578    pst.dstProcId = pst.srcProcId;
579    pst.event = EVTSCTPNTFY;
580    pst.selector = DU_SELECTOR_LC;
581    pst.pool= DU_POOL;
582    pst.region = DFLT_REGION;
583    
584    if(cmPkSctpNtfy(&pst, ntfy) != ROK)
585    {
586       DU_LOG("\nSCTP : Failed to pack SCTP notification");
587       RETVALUE(RFAILED);
588    }
589    RETVALUE(ROK);
590 }
591
592 /*******************************************************************
593  *
594  * @brief checks for valid readFd and process the InetSctpRecvMsg
595  * during polling 
596  *
597  * @details
598  *
599  *    Function : processPolling
600  *
601  *    Functionality:
602  *         checks for valid readFd and process the InetSctpRecvMsg
603  *         during polling
604  *
605  * @params[in]  Params required for polling
606  * @params[in]  SockFd for file descriptor
607  * @params[in]  timeoutPtr indicates the timeout value
608  * @params[in]  MemInfo, recvMsgSet
609  *
610  * @return ROK     - success
611  *         RFAILED - failure
612  *
613  * ****************************************************************/
614
615 S16 processPolling(sctpSockPollParams *pollParams, CmInetFd *sockFd, U32 *timeoutPtr, CmInetMemInfo *memInfo, Bool recvMsgSet)
616 {
617    U16 ret = ROK;
618    CM_INET_FD_SET(sockFd, &pollParams->readFd);
619    ret = cmInetSelect(&pollParams->readFd, NULLP, timeoutPtr, &pollParams->numFds);
620    if(CM_INET_FD_ISSET(sockFd, &pollParams->readFd))
621    {
622       CM_INET_FD_CLR(sockFd, &pollParams->readFd);
623       ret = cmInetSctpRecvMsg(sockFd, &pollParams->addr, &pollParams->port, memInfo, &(pollParams->mBuf), &pollParams->bufLen, &pollParams->info, &pollParams->flag, &pollParams->ntfy);
624         
625       if(connUp && ret != ROK)
626       {
627          DU_LOG("\n SCTP: Failed to receive sctp msg for sockFd[%d]\n", sockFd->fd);
628          recvMsgSet = RFAILED;
629       }
630       else
631       {
632          if((((pollParams->flag & CM_INET_SCTP_MSG_NOTIFICATION) != 0)) && ret == ROK)
633          {
634             if(pollParams->port == f1Params.destPort)
635             {
636                f1Params.assocId = pollParams->ntfy.u.assocChange.assocId;
637                DU_LOG("\nSCTP : AssocId assigned to F1Params from PollParams [%d]\n", f1Params.assocId);
638             }
639             else if(pollParams->port == ricParams.destPort)
640             {
641                ricParams.assocId = pollParams->ntfy.u.assocChange.assocId;
642                DU_LOG("\nSCTP : AssocId assigned to ricParams from PollParams [%d]\n", ricParams.assocId);
643             }
644             else
645             {
646                DU_LOG("\nSCTP : Failed to fill AssocId\n");
647             }  
648             ret = sctpNtfyHdlr(&pollParams->ntfy);
649             if(ret != ROK)
650             {
651                DU_LOG("\nSCTP : Failed to process sctp notify msg\n");
652             }
653          }
654          else if(connUp & (pollParams->port == f1Params.destPort))
655          {  
656             sendToDuApp(pollParams->mBuf, EVTSCTPDATA);
657          }
658          else if(connUp & (pollParams->port == ricParams.destPort))
659          {  
660             sendToDuApp(pollParams->mBuf, EVTRICDATA);
661          }
662
663          else
664          {
665             SPutMsg(pollParams->mBuf);
666          }
667       }
668   }
669   RETVALUE(ROK);
670 }
671 /*******************************************************************
672  *
673  * @brief Receives message on the socket
674  *
675  * @details
676  *
677  *    Function : sctpSockPoll
678  *
679  *    Functionality:
680  *      Receives message on the socket
681  *
682  * @params[in] 
683  * @return ROK     - success
684  *         RFAILED - failure
685  *
686  * ****************************************************************/
687 S16 sctpSockPoll()
688 {
689    U16 ret       = ROK;
690    U32           timeout;
691    U32           *timeout_Ptr;
692    CmInetMemInfo memInfo;
693    sctpSockPollParams f1PollParams, e2PollParams;
694
695    memset(&f1PollParams, 0, sizeof(sctpSockPollParams));
696    memset(&e2PollParams, 0, sizeof(sctpSockPollParams));
697
698    if (f1Params.sockFd.blocking & ricParams.sockFd.blocking)
699    {
700       /* blocking */
701       timeout_Ptr = NULLP;
702    }
703    else
704    {
705       /* non-blocking */
706       timeout = 0;
707       timeout_Ptr = &timeout;
708    }
709    memInfo.region = DU_APP_MEM_REGION;
710    memInfo.pool   = DU_POOL;
711
712    CM_INET_FD_ZERO(&f1PollParams.readFd);
713    CM_INET_FD_ZERO(&e2PollParams.readFd);
714
715    DU_LOG("\nSCTP : Polling started at DU\n");
716    while(1)
717    {
718       if(f1Params.itfState)
719       {
720          if((ret = processPolling(&f1PollParams, &f1Params.sockFd, timeout_Ptr, &memInfo, f1Params.recvMsgSet)) != ROK)
721          {
722             DU_LOG("\nSCTP : Failed to RecvMsg for F1\n");
723          }
724       }
725       if(ricParams.itfState)
726       {
727          if((ret = processPolling(&e2PollParams, &ricParams.sockFd, timeout_Ptr, &memInfo, ricParams.recvMsgSet)) != ROK)
728          {
729             DU_LOG("\nSCTP : Failed to RecvMsg for E2\n");
730          }
731       }
732    };
733    RETVALUE(ret);
734 }/* End of sctpSockPoll() */
735
736 /*******************************************************************
737  *
738  * @brief Send message on SCTP socket
739  *
740  * @details
741  *
742  *    Function : sctpSend 
743  *
744  *    Functionality:
745  *        Send message on SCTP socket
746  *
747  * @params[in] 
748  * @return ROK     - success
749  *         RFAILED - failure
750  *
751  * ****************************************************************/
752 S16 sctpSend(Buffer *mBuf, U8 itfType)
753 {
754    U8               ret;
755    MsgLen           len;          /* number of actually sent octets */
756    CmInetMemInfo    memInfo;                        
757    
758    memInfo.region = DU_APP_MEM_REGION;               
759    memInfo.pool   = DU_POOL;
760
761    if(itfType == F1_INTERFACE)
762    {
763       DU_LOG("\nSCTP : sending the message to DuApp");
764       ret = cmInetSctpSendMsg(&f1Params.sockFd, &f1Params.destIpNetAddr, f1Params.destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
765    }
766
767    if(itfType == E2_INTERFACE)
768    {
769       DU_LOG("\nSCTP : sending the message to ric");
770       ret = cmInetSctpSendMsg(&ricParams.sockFd, &ricParams.destIpNetAddr, ricParams.destPort, &memInfo, mBuf, &len, 0, FALSE, 0, 0/*SCT_PROTID_NONE*/, RWOULDBLOCK);
771    }
772
773    if(ret != ROK && ret != RWOULDBLOCK)
774    {
775       DU_LOG("\nSCTP : Failed sending the message");
776       RETVALUE(RFAILED);
777    }
778
779    RETVALUE(ROK);
780 } /* End of sctpSend */
781
782 /**********************************************************************
783          End of file
784 **********************************************************************/