int SCTP_receive(unsigned int associationID, unsigned short streamID, unsigned char *buffer, unsigned int *length, unsigned short* streamSN, unsigned int * tsn, unsigned int flags) { int result; if ((result = sctp_receive(associationID, streamID, buffer, length, streamSN, tsn, flags))!=0) { if (result == SCTP_LIBRARY_NOT_INITIALIZED) { fprintf(stderr, "sctp_receive: library not initialized.\n"); } else if (result == SCTP_ASSOC_NOT_FOUND) { fprintf(stderr, "sctp_receive: association not found.\n"); } else if (result == SCTP_MODULE_NOT_FOUND) { fprintf(stderr, "sctp_receive: internal error.\n"); } else if (result == SCTP_SPECIFIC_FUNCTION_ERROR) { /* fprintf(stderr, "sctp_receive: NO DATA AVAILABLE.\n"); */ } else if (result == SCTP_PARAMETER_PROBLEM) { fprintf(stderr, "sctp_receive: parameter problem (Null-Pointers, PathID ?)\n"); } fflush(stderr); } return result; }
void dataArriveNotif(unsigned int assocID, unsigned int streamID, unsigned int len, unsigned short streamSN,unsigned int TSN, unsigned int protoID, unsigned int unordered, void* ulpDataPtr) { unsigned char chunk[SCTP_MAXIMUM_DATA_LENGTH]; unsigned int length; unsigned int tsn; unsigned short ssn; if (vverbose) { sprintf(tstr, "%-8x: Data arrived (%u bytes on stream %u, %s)\n", assocID, len, streamID, (unordered==SCTP_ORDERED_DELIVERY)?"ordered":"unordered"); waddstr(statusWin,tstr); wrefresh(statusWin); } /* read it */ length = sizeof(chunk); sctp_receive(assocID, streamID, chunk, &length, &ssn, &tsn, SCTP_MSG_DEFAULT); if (!(len>length)) { chunk[len] = 0; } waddstr(peerWin, (char *)chunk); wrefresh(peerWin); }
void dataArriveNotif(unsigned int assocID, unsigned short streamID, unsigned int len, unsigned short streamSN,unsigned int TSN, unsigned int protoID, unsigned int unordered, void* ulpDataPtr) { char chunk[SCTP_MAXIMUM_DATA_LENGTH + 1]; unsigned int length; int i; unsigned int InstreamID_position = 0; unsigned int tsn; unsigned short ssn; sprintf(statusInfo, " Association ID =%-8x: Data arrived (%u bytes on stream %u, %s)\n", assocID, len, streamID, (unordered==SCTP_ORDERED_DELIVERY)?"ordered":"unordered"); waddstr(statusWin,statusInfo); wrefresh(statusWin); /* read it */ length = SCTP_MAXIMUM_DATA_LENGTH; sctp_receive(assocID, streamID, (unsigned char *)chunk, &length, &ssn, &tsn, SCTP_MSG_DEFAULT); chunk[length]=0; /* and display it */ sprintf(receivedInfo, " Data received : %s", chunk); waddstr(receivedWin,receivedInfo); wrefresh(receivedWin); /* Stores the stream Id into the structure statusUpdate each time a data arrives */ for (i=0; i <statusUpdate.noOfInStreams; i++) { if (statusUpdate.InstreamIDList[i] == -1) { statusUpdate.InstreamIDList[i] = streamID; InstreamID_position = i; } else if (statusUpdate.InstreamIDList[i] != -1 && statusUpdate.InstreamIDList[i] != streamID) { statusUpdate.InstreamIDList[i] = streamID; InstreamID_position = i; } else if (statusUpdate.InstreamIDList[i] == streamID) { InstreamID_position = i; } } /* Update the current position of the InstreamIDList array */ currInstreamID = InstreamID_position; /* Display the Association details */ ncurses_display_AssocStatus(assocID); if (!periodicRefresh) { /* Display the primary path details by default when data arrive */ displayPathDetails = 1; chosenPath = sctp_getPrimary(assocID); ncurses_display_PathStatus(assocID); } }