int main(int argc, char **argv) { int sctpInstance; SCTP_ulpCallbacks terminalUlp; SCTP_InstanceParameters instanceParameters; sctp_initLibrary(); /* trapping Ctrl-C */ signal(SIGINT, finish); /* trapping Ctrl-backslash */ signal (SIGQUIT, finish); /* 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 = NULL; /* handle all command line options */ getArgs(argc, argv); checkArgs(); if (client) { sctpInstance = sctp_registerInstance(localPort, MAXIMUM_NUMBER_OF_IN_STREAMS, MAXIMUM_NUMBER_OF_OUT_STREAMS, noOfLocalAddresses, localAddressList, terminalUlp); /* set the TOS byte */ sctp_getAssocDefaults(sctpInstance, &instanceParameters); instanceParameters.ipTos=tosByte; sctp_setAssocDefaults(sctpInstance, &instanceParameters); associationID = sctp_associate(sctpInstance, MAXIMUM_NUMBER_OF_OUT_STREAMS, destinationAddress, remotePort, NULL); } sctp_registerUserCallback(fileno(stdin),&stdinCallback, NULL, POLLIN|POLLPRI); /* run the event handler forever */ while (sctp_eventLoop() >= 0); /* this will never be reached */ return 0; }
int SCTP_initLibrary(void) { int result; if ((result = sctp_initLibrary()) != SCTP_SUCCESS) { if (result == SCTP_LIBRARY_ALREADY_INITIALIZED) { fprintf(stderr, "sctp_initLibrary: called muliple times.\n"); } else if (result == SCTP_INSUFFICIENT_PRIVILEGES) { fprintf(stderr, "sctp_initLibrary: could not open raw socket for SCTP. You must have root provileges !\n"); } else if (result == SCTP_SPECIFIC_FUNCTION_ERROR) { fprintf(stderr, "sctp_initLibrary: Unknown error in Adaptation-Module !\n"); } else { fprintf(stderr, "sctp_initLibrary: unknown value (%i) returned.\n", result); } fflush(stderr); exit(result); } return result; }
C_TransSCTP::C_TransSCTP() : C_TransIP() { sctp_initLibrary(); }