Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
int 
SCTP_getAssocDefaults(unsigned short SCTP_InstanceName, SCTP_InstanceParameters* params)
{
    int result;
    
    if ((result = sctp_getAssocDefaults(SCTP_InstanceName, params)) != 0) {
        fprintf(stderr, "sctp_getAssocDefaults: error value (%i) returned.\n", result);
        fflush(stderr);
    }
    return result;
}