int main(int argc, char **argv) { SCTP_ulpCallbacks terminalUlp; SCTP_InstanceParameters instanceParameters; SCTP_LibraryParameters params; char buffer[2000]; /* initialize the terminal_ulp variable */ terminalUlp.dataArriveNotif = &dataArriveNotif; terminalUlp.sendFailureNotif = &sendFailureNotif; terminalUlp.networkStatusChangeNotif = &networkStatusChangeNotif; terminalUlp.communicationUpNotif = &communicationUpNotif; terminalUlp.communicationLostNotif = &communicationLostNotif; terminalUlp.communicationErrorNotif = &communicationErrorNotif; terminalUlp.restartNotif = &restartNotif; terminalUlp.shutdownCompleteNotif = &shutdownCompleteNotif; terminalUlp.peerShutdownReceivedNotif = &shutdownReceivedNotif; /* handle all command line options */ getArgs(argc, argv); checkArgs(); SCTP_initLibrary(); SCTP_getLibraryParameters(¶ms); params.sendOotbAborts = sendOOTBAborts; params.supportPRSCTP = 1; params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_CRC32C; SCTP_setLibraryParameters(¶ms); sctpInstance=SCTP_registerInstance(localPort, MAXIMUM_NUMBER_OF_IN_STREAMS, MAXIMUM_NUMBER_OF_OUT_STREAMS, noOfLocalAddresses, localAddressList, terminalUlp); /* set the TOS byte */ SCTP_getAssocDefaults((unsigned short)sctpInstance, &instanceParameters); instanceParameters.ipTos = tosByte; instanceParameters.rtoMin = rto_min; instanceParameters.rtoMax = rto_max; instanceParameters.rtoInitial = rto_min; if (myRwndSpecified) instanceParameters.myRwnd = myRwnd; SCTP_setAssocDefaults((unsigned short)sctpInstance, &instanceParameters); SCTP_registerStdinCallback(&stdinCallback, buffer, sizeof(buffer)); associationID=SCTP_associate((unsigned short)sctpInstance, MAXIMUM_NUMBER_OF_OUT_STREAMS, destinationAddress, remotePort, NULL); /* run the event handler forever */ while (1){ SCTP_eventLoop(); } /* this will never be reached */ exit(0); }
int main(int argc, char **argv) { int sctpInstance; SCTP_ulpCallbacks testUlp; SCTP_InstanceParameters instanceParameters; SCTP_LibraryParameters params; unsigned int index; /* initialize ULP data */ for (index=0; index < MAXIMUM_NUMBER_OF_ASSOCIATIONS; index++) { ulpData[index].maximumStreamID = -1; ulpData[index].nrOfReceivedChunks = 0; ulpData[index].nrOfReceivedBytes = 0; ulpData[index].ShutdownReceived = 0; ulpData[index].nrOfSentChunks = 0; ulpData[index].nrOfSentBytes = 0; } /* initialize the echo_ulp variable */ testUlp.dataArriveNotif = &dataArriveNotif; testUlp.sendFailureNotif = &sendFailureNotif; testUlp.networkStatusChangeNotif = &networkStatusChangeNotif; testUlp.communicationUpNotif = &communicationUpNotif; testUlp.communicationLostNotif = &communicationLostNotif; testUlp.communicationErrorNotif = &communicationErrorNotif; testUlp.restartNotif = &restartNotif; testUlp.shutdownCompleteNotif = &shutdownCompleteNotif; testUlp.peerShutdownReceivedNotif = &shutdownReceivedNotif; testUlp.queueStatusChangeNotif = &queueStatusChangeNotif; getArgs(argc, argv); checkArgs(); SCTP_initLibrary(); SCTP_getLibraryParameters(¶ms); params.sendOotbAborts = sendOOTBAborts; /* params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_ADLER32; */ params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_CRC32C; SCTP_setLibraryParameters(¶ms); sctpInstance=SCTP_registerInstance(localPort, MAXIMUM_NUMBER_OF_IN_STREAMS, MAXIMUM_NUMBER_OF_OUT_STREAMS, noOfLocalAddresses, localAddressList, testUlp); /* set the TOS field */ SCTP_getAssocDefaults((unsigned short)sctpInstance, &instanceParameters); instanceParameters.maxSendQueue = SEND_QUEUE_SIZE; instanceParameters.ipTos=tosByte; SCTP_setAssocDefaults((unsigned short)sctpInstance, &instanceParameters); if (startAssociation) { SCTP_associate((unsigned short)sctpInstance, MAXIMUM_NUMBER_OF_OUT_STREAMS, destinationAddress, remotePort, &ulpData[0]); } while (1) { SCTP_eventLoop(); }; /* this will never be reached */ return 0; }