Exemple #1
0
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(&params);
    params.sendOotbAborts    = sendOOTBAborts;
    params.supportPRSCTP     = 1;
    params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_CRC32C;
    SCTP_setLibraryParameters(&params);

    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);
}
Exemple #2
0
int main(int argc, char **argv)
{
    SCTP_ulpCallbacks echoUlp;
    /* SCTP_InstanceParameters instanceParameters; */
    SCTP_LibraryParameters params;

    /* initialize the echo_ulp variable */
    echoUlp.dataArriveNotif           = &dataArriveNotif;
    echoUlp.sendFailureNotif          = &sendFailureNotif;
    echoUlp.networkStatusChangeNotif  = &networkStatusChangeNotif;
    echoUlp.communicationUpNotif      = &communicationUpNotif;
    echoUlp.communicationLostNotif    = &communicationLostNotif;
    echoUlp.communicationErrorNotif   = &communicationErrorNotif;
    echoUlp.restartNotif              = &restartNotif;
    echoUlp.shutdownCompleteNotif     = &shutdownCompleteNotif;
    echoUlp.peerShutdownReceivedNotif = &shutdownReceivedNotif;

    /* handle all command line options */
    getArgs(argc, argv);
    checkArgs();

    SCTP_initLibrary();
    SCTP_getLibraryParameters(&params);
    params.sendOotbAborts = sendOOTBAborts;
    /* params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_ADLER32; */
    params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_CRC32C;
    SCTP_setLibraryParameters(&params);

    /* set up the "server" */
    SCTP_registerInstance(ECHO_PORT,
                          MAXIMUM_NUMBER_OF_IN_STREAMS, MAXIMUM_NUMBER_OF_OUT_STREAMS,
                          noOfLocalAddresses, localAddressList,
                          echoUlp);

    /* run the event handler forever */
    while (1) {
        SCTP_eventLoop();
    }

    /* this will never be reached */
    exit(0);
}
Exemple #3
0
int main(int argc, char **argv)
{
    int sctpClientInstance;
    SCTP_ulpCallbacks echoServerUlp, echoClientUlp;
    SCTP_LibraryParameters params;
    unsigned int index, version;


    /* initialize ULP data */
    for (index=0; index < MAXIMUM_NUMBER_OF_ASSOCIATIONS; index++) {
        ulpData[index].maximumStreamID    = -1;
        ulpData[index].nrOfReceivedChunks = 0;
        ulpData[index].nrOfReceivedBytes  = 0;
    }

    /* initialize the echo_ulp variable */
    echoServerUlp.dataArriveNotif          = &serverDataArriveNotif;
    echoServerUlp.sendFailureNotif         = &sendFailureNotif;
    echoServerUlp.networkStatusChangeNotif = &networkStatusChangeNotif;
    echoServerUlp.communicationUpNotif     = &serverCommunicationUpNotif;
    echoServerUlp.communicationLostNotif   = &communicationLostNotif;
    echoServerUlp.communicationErrorNotif  = &communicationErrorNotif;
    echoServerUlp.restartNotif             = &restartNotif;
    echoServerUlp.shutdownCompleteNotif    = &shutdownCompleteNotif;
    echoServerUlp.peerShutdownReceivedNotif = NULL;

    /* initialize the echo_ulp variable */
    echoClientUlp.dataArriveNotif          = &clientDataArriveNotif;
    echoClientUlp.sendFailureNotif         = &sendFailureNotif;
    echoClientUlp.networkStatusChangeNotif = &networkStatusChangeNotif;
    echoClientUlp.communicationUpNotif     = &clientCommunicationUpNotif;
    echoClientUlp.communicationLostNotif   = &communicationLostNotif;
    echoClientUlp.communicationErrorNotif  = &communicationErrorNotif;
    echoClientUlp.restartNotif             = &restartNotif;
    echoClientUlp.shutdownCompleteNotif    = &shutdownCompleteNotif;
    echoClientUlp.peerShutdownReceivedNotif = NULL;

    getArgs(argc, argv);
    checkArgs();

    version = sctp_getLibraryVersion();
    fprintf(fptr, "We are using sctplib version (%u) maj=%u, min=%u\n",
        version, version & 0xFFFF0000, version & 0xFFFF);
    fflush(fptr);

    SCTP_initLibrary();
    SCTP_getLibraryParameters(&params);
    params.sendOotbAborts = 0;
    params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_CRC32C;
    SCTP_setLibraryParameters(&params);


    noOfLocalAddresses = 1;
    strcpy((char *)localAddressList[0], "127.0.0.1");

    SCTP_registerInstance(ECHO_PORT,
                          MAXIMUM_NUMBER_OF_IN_STREAMS, MAXIMUM_NUMBER_OF_OUT_STREAMS,
                          noOfLocalAddresses, localAddressList,
                          echoServerUlp);

    sctpClientInstance = SCTP_registerInstance(CLIENT_PORT,
                                               MAXIMUM_NUMBER_OF_IN_STREAMS, MAXIMUM_NUMBER_OF_OUT_STREAMS,
                                               noOfLocalAddresses, localAddressList,
                                               echoClientUlp);

    strcpy((char *)destinationAddress, "127.0.0.1");


    SCTP_associate(sctpClientInstance, 1, destinationAddress, ECHO_PORT, NULL);

    SCTP_startTimer(deltaT, &measurementTimerRunOffFunction, NULL, NULL);


    /* run the event handler forever */
    while (1) {
        SCTP_eventLoop();
    };

    /* this will never be reached */
    exit(0);
}
Exemple #4
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(&params);
   params.sendOotbAborts = sendOOTBAborts;
   /* params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_ADLER32; */
   params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_CRC32C;
   SCTP_setLibraryParameters(&params);
   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;
}