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