- sa_family_t la_family;
- U8 error;
-
-
- /* Getting the transport address for local host name */
- if(sctpCfg->duIpAddr.ipV4Pres)
- {
- if(getSockAddr(sctpCfg->duIpAddr.ipV4Addr, sctpCfg->duPort, TRUE, TRUE) != ROK )
- {
- printf("\nUnable to get local address");
- RETVALUE(RFAILED);
- }
- la_family = AF_INET;
- }
- else
- {
- if(getSockAddr(sctpCfg->duIpAddr.ipV6Addr, sctpCfg->duPort, FALSE, TRUE) != ROK )
- {
- printf("\nUnable to get local address");
- RETVALUE(RFAILED);
- }
- la_family = AF_INET6;
- }
-
- socket_type = SOCK_STREAM;
-
- /* Creating new end point */
- sockFd = socket(la_family, socket_type, IPPROTO_SCTP);
- if (sockFd < 0)
- {
- printf("\n Failed to create socket %s", strerror(errno));
- RETVALUE(RFAILED);
- }
-
- /* Binding socket to local address and port */
- error = bind(sockFd, &local_addr.sa, la_len);
- if(error != 0)
- {
- printf("\n Failed to bind to socket. Error [%s]", strerror(errno));
- RETVALUE(RFAILED);
- }
-
- /* Setting socket as non-blocking*/
- error = fcntl(sockFd, F_SETFL, O_NONBLOCK);
- if (error != 0)
- {
- printf("\n Failed to set socket as non blocking. Error [%s]", strerror(errno));
- RETVALUE(RFAILED);
- }
- else
- {
- nonblocking = TRUE;
- }
-
- RETVALUE(ROK);
+ CmSctpEvent sctpEvent;
+
+ sctpEvent.dataIoEvent = TRUE;
+ sctpEvent.associationEvent = TRUE;
+ sctpEvent.addressEvent = TRUE;
+ sctpEvent.sendFailureEvent = TRUE;
+ sctpEvent.peerErrorEvent = TRUE;
+ sctpEvent.shutdownEvent = TRUE;
+ sctpEvent.partialDeliveryEvent = TRUE;
+ sctpEvent.adaptationLayerEvent = TRUE;
+
+ cmInetSetOpt(&sockFd, CM_SOCKOPT_LEVEL_SCTP, CM_SOCKOPT_OPT_SCTP_EVENTS, &sctpEvent);
+ RETVALUE(ROK);