void networkStatusChangeNotif(unsigned int assocID, short affectedPathID, unsigned short newState, void* ulpDataPtr) { SCTP_AssociationStatus assocStatus; SCTP_PathStatus pathStatus; unsigned short pathID; SCTP_getPathStatus(assocID, affectedPathID, &pathStatus); fprintf(fptr, "%-8x: Network status change: path %u (towards %s) is now %s\n", assocID, affectedPathID, pathStatus.destinationAddress, pathStateName(newState)); fflush(fptr); /* if the primary path has become inactive */ if ((newState == SCTP_PATH_UNREACHABLE) && (affectedPathID == SCTP_getPrimary(assocID))) { /* select a new one */ SCTP_getAssocStatus(assocID, &assocStatus); for (pathID=0; pathID < assocStatus.numberOfAddresses; pathID++){ SCTP_getPathStatus(assocID, pathID, &pathStatus); if (pathStatus.state == SCTP_PATH_OK) break; } /* and use it */ if (pathID < assocStatus.numberOfAddresses) { SCTP_setPrimary(assocID, pathID); } } }
void networkStatusChangeNotif(unsigned int assocID, short destAddrIndex, unsigned short newState, void* ulpDataPtr) { SCTP_AssociationStatus assocStatus; SCTP_PathStatus pathStatus; unsigned short pathID; if (verbose) { fprintf(stdout, "%-8x: Network status change: path %u is now %s\n", assocID, destAddrIndex, pathStateName(newState)); fflush(stdout); } /* if the primary path has become inactive */ if ((newState == SCTP_PATH_UNREACHABLE) && (destAddrIndex == SCTP_getPrimary(assocID))) { /* select a new one */ /* should we have a sctp_get_primary()? */ SCTP_getAssocStatus(assocID, &assocStatus); for (pathID=0; pathID < assocStatus.numberOfAddresses; pathID++){ SCTP_getPathStatus(assocID, pathID, &pathStatus); if (pathStatus.state == SCTP_PATH_OK) break; } /* and use it */ if (pathID < assocStatus.numberOfAddresses) { SCTP_setPrimary(assocID, pathID); } } }
void networkStatusChangeNotif(unsigned int assocID, short destAddrIndex, unsigned short newState, void* ulpDataPtr) { SCTP_AssociationStatus assocStatus; SCTP_PathStatus pathStatus; unsigned short pathID; sctp_getPathStatus(assocID, destAddrIndex , &pathStatus); sprintf(statusInfo, " Association ID =%-8x: Network status change: path %u (towards %s) is now %s\n", assocID, destAddrIndex, pathStatus.destinationAddress, pathStateName(newState)); waddstr(statusWin,statusInfo); wrefresh(statusWin); /* if the primary path has become inactive */ if ((newState == SCTP_PATH_UNREACHABLE) && (destAddrIndex == sctp_getPrimary(assocID))) { sctp_getAssocStatus(assocID, &assocStatus); for (pathID=0; pathID < assocStatus.numberOfAddresses; pathID++) { sctp_getPathStatus(assocID, pathID, &pathStatus); if (pathStatus.state == SCTP_PATH_OK) { break; } } /* and use it */ if (pathID < assocStatus.numberOfAddresses) { sctp_setPrimary(assocID, pathID); } } /* Display functions */ ncurses_display_AssocStatus(assocID); displayPathDetails = 0; ncurses_display_PathStatus(assocID); }
void* communicationUpNotif(unsigned int assocID, int status, unsigned int noOfDestinations, unsigned short noOfInStreams, unsigned short noOfOutStreams, int associationSupportsPRSCTP, void* dummy) { SCTP_PathStatus pathStatus; unsigned int i; if (verbose) { fprintf(stdout, "%-8x: Communication up (%u paths, %u In-Streams, %u Out-Streams)\n", assocID, noOfDestinations, noOfInStreams, noOfOutStreams); fflush(stdout); } if (vverbose) { for (i=0; i < noOfDestinations; i++) { SCTP_getPathStatus(assocID, (unsigned short)i, &pathStatus); fprintf(stdout, "%-8x: Path Status of path %u (towards %s): %s.\n", assocID, i, pathStatus.destinationAddress, pathStateName(pathStatus.state)); SCTP_changeHeartBeat(assocID, (short)i, 1, HBInterval); } } numberOutStreams = noOfOutStreams; return NULL; }
/* This function reads the input from the parameters of the SCTP_PathStatus structure and displays the data on a window of ncurses. */ void ncurses_display_PathStatus(unsigned int assocID) { SCTP_AssociationStatus assocStatus; SCTP_PathStatus pathStatus; unsigned short pathID; unsigned int Rto[SCTP_MAX_NUM_ADDRESSES], HB_Interval[SCTP_MAX_NUM_ADDRESSES]; unsigned int SRTT[SCTP_MAX_NUM_ADDRESSES],RTTVar[SCTP_MAX_NUM_ADDRESSES]; unsigned int SlowStThres[SCTP_MAX_NUM_ADDRESSES], PartBytesAck[SCTP_MAX_NUM_ADDRESSES]; unsigned int CongestWin[SCTP_MAX_NUM_ADDRESSES],CongestWin2[SCTP_MAX_NUM_ADDRESSES]; unsigned int MTU[SCTP_MAX_NUM_ADDRESSES], OutBytesPerAddr[SCTP_MAX_NUM_ADDRESSES]; short State[SCTP_MAX_NUM_ADDRESSES]; char destaddr[SCTP_MAX_NUM_ADDRESSES][SCTP_MAX_IP_LEN]; unsigned char IPTos[SCTP_MAX_NUM_ADDRESSES]; wclear(pathWin); wrefresh(pathWin); sctp_getAssocStatus(assocID, &assocStatus); for (pathID=0; pathID < assocStatus.numberOfAddresses; pathID++) { sctp_getPathStatus(assocID, pathID, &pathStatus); strcpy((char *)destaddr[pathID], (const char *)pathStatus.destinationAddress); State[pathID] = pathStatus.state; Rto[pathID] = pathStatus.rto; HB_Interval[pathID] = pathStatus.heartbeatIntervall; SRTT[pathID] = pathStatus.srtt; RTTVar[pathID] = pathStatus.rttvar; SlowStThres[pathID] = pathStatus.ssthresh; PartBytesAck[pathID] = pathStatus.partialBytesAcked; CongestWin[pathID] = pathStatus.cwnd; CongestWin2[pathID] = pathStatus.cwnd2; MTU[pathID] = pathStatus.mtu; OutBytesPerAddr[pathID] = pathStatus.outstandingBytesPerAddress; IPTos[pathID] = pathStatus.ipTos; if (displayPathDetails == 0) { /* Check if the current path is the primary path */ if (pathID == sctp_getPrimary(assocID)) { sprintf(pathInfo," Primary Path ID : %d, state of path : %s\n", pathID, pathStateName(State[pathID])); waddstr(pathWin,pathInfo); wrefresh(pathWin); } else { sprintf(pathInfo," Path ID : %d, state of path : %s\n", pathID, pathStateName(State[pathID])); waddstr(pathWin,pathInfo); wrefresh(pathWin); } } else if (displayPathDetails == 1) { mvwaddstr(pathWin,0,0,"[Hit Backspace to return to main menu]\n"); wrefresh(pathWin); if (pathID == chosenPath) { sprintf(pathInfo,"\n Path ID : %d, State of path : %s\t\t Destination address : %s\n Heartbeat Interval : %-8u\t\t Retransmisson time(msecs) : %-8d\n Smooth Round Trip time(msecs) : %-8d\t Round Trip time Variations(msecs) : %-8d\n Slow start threshold : %-8d\t\t Congestion Window Size : %-8d\n Outstanding Bytes per Address : %-8d\t Congestion Window Size 2 : %-8d\n Partial bytes acknowledge : %-8d\t\t IP type of service : %x\n MTU : %d bytes\n\n", pathID, pathStateName(State[pathID]), destaddr[pathID],HB_Interval[pathID],Rto[pathID], SRTT[pathID],RTTVar[pathID],SlowStThres[pathID],CongestWin[pathID], OutBytesPerAddr[pathID], CongestWin2[pathID],PartBytesAck[pathID], IPTos[pathID],MTU[pathID]); waddstr(pathWin,pathInfo); wrefresh(pathWin); } } } wrefresh(textWin); displayPathDetails = 0; }