コード例 #1
0
int
SCTP_receiveUnacked(unsigned int associationID, unsigned char *buffer, unsigned int *length, unsigned int* tsn,
                    unsigned short *streamID, unsigned short *streamSN,unsigned int* protocolId)
{
    int result;
    unsigned char flags;
    void* ctx;
    
    if ((result = sctp_receiveUnacked(associationID, buffer, length, tsn,
                                      streamID, streamSN, protocolId, &flags, &ctx)) < 0) {

        if (result == SCTP_WRONG_STATE) {
            fprintf(stderr, "SCTP_receiveUnacked: Association is not in state CLOSED. \n");
        }else if (result ==SCTP_ASSOC_NOT_FOUND){
            fprintf(stderr, "SCTP_receiveUnacked: Association not found \n");
        }else if (result == SCTP_NO_CHUNKS_IN_QUEUE){
            /* fprintf(stderr, "SCTP_receiveUnacked: Queue is already empty.\n"); */
        }else if (result == SCTP_LIBRARY_NOT_INITIALIZED){
            fprintf(stderr, "SCTP_receiveUnacked: Library not Initialized \n");
        }else if (result == SCTP_PARAMETER_PROBLEM){
            fprintf(stderr, "SCTP_receiveUnacked: parameter problem, NULL pointer passed ?\n");
        } else {
            fprintf(stderr, "SCTP_receiveUnacked: unknown value (%i) returned.\n", result);
        }
        fflush(stderr);
    }
    return result;
}
コード例 #2
0
ファイル: monitor.c プロジェクト: thilinamh/sctplib
void communicationLostNotif(unsigned int assocID, unsigned short status, void* ulpDataPtr)
{
    unsigned char buffer[SCTP_MAXIMUM_DATA_LENGTH];
    unsigned int bufferLength;
    unsigned short streamID, streamSN;
    unsigned int protoID;
    unsigned int tsn;
    unsigned char flags;
    void* ctx;


    sprintf(statusInfo, " Association ID =%-8x: Communication lost (status %u)\n", assocID, status);
    waddstr(statusWin,statusInfo);
    wrefresh(statusWin);

    return;

    /* retrieve data */
    bufferLength = sizeof(buffer);
    while (sctp_receiveUnsent(assocID, buffer, &bufferLength, &tsn,
                              &streamID, &streamSN, &protoID, &flags, &ctx) >= 0) {
        /* do something with the retrieved data */
        /* after that, reset bufferLength */
        bufferLength = sizeof(buffer);
    }

    bufferLength = sizeof(buffer);
    while (sctp_receiveUnacked(assocID, buffer, &bufferLength, &tsn,
                               &streamID, &streamSN, &protoID, &flags, &ctx) >= 0) {
        /* do something with the retrieved data */
        /* after that, reset bufferLength */
        bufferLength = sizeof(buffer);
    }

    /* delete the association, instace and terminate */
    sctp_deleteAssociation(assocID);
    sctp_unregisterInstance(sctpInstance);
    exit(0);
}
コード例 #3
0
ファイル: chat.c プロジェクト: thilinamh/sctplib
void communicationLostNotif(unsigned int assocID, unsigned short status, void* ulpDataPtr)
{
    unsigned char buffer[SCTP_MAXIMUM_DATA_LENGTH];
    unsigned int bufferLength;
    unsigned short streamID, streamSN;
    unsigned int protoID;
    unsigned int tsn;
    unsigned char flags;
    void * ctx;

    if (verbose) {
        sprintf(tstr, "%-8x: Communication lost (status %u)\n", assocID, status);
        waddstr(statusWin,tstr);
    }
    return;

    /* retrieve data */
    bufferLength = sizeof(buffer);
    while (sctp_receiveUnsent(assocID, buffer, &bufferLength, &tsn,
                              &streamID, &streamSN, &protoID, &flags, &ctx) >= 0){
        /* do something with the retrieved data */
        /* after that, reset bufferLength */
        bufferLength = sizeof(buffer);
    }

    bufferLength = sizeof(buffer);
    while (sctp_receiveUnacked(assocID, buffer, &bufferLength, &tsn,
                               &streamID, &streamSN, &protoID, &flags, &ctx) >= 0){
        /* do something with the retrieved data */
        /* after that, reset bufferLength */
        bufferLength = sizeof(buffer);
    }

    /* delete the association */
    sctp_deleteAssociation(assocID);
}