void networkStatusChangeNotif(unsigned int assocID, short destAddrIndex, unsigned short newState, void* ulpDataPtr) { SCTP_AssociationStatus assocStatus; SCTP_PathStatus pathStatus; unsigned short pathID; if (verbose) { sprintf(tstr, "%-8x: Network status change: path %u is now %s\n", assocID, destAddrIndex, ((newState == SCTP_PATH_OK) ? "ACTIVE" : "INACTIVE")); waddstr(statusWin,tstr); wrefresh(statusWin); } /* if the primary path has become inactive */ if ((newState == SCTP_PATH_UNREACHABLE) && (destAddrIndex == 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); getDestinationIPaddr((char *)peeraddr); } } }
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 getDestinationIPaddr(char paddr[SCTP_MAX_IP_LEN]) /*This routine copies the IP address of the primary path into an array paddr */ { SCTP_PathStatus pathStatus; int i, pathID; pathID = sctp_getPrimary(associationID); sctp_getPathStatus(associationID, pathID, &pathStatus); strcpy((char *)paddr, (const char *)pathStatus.destinationAddress); /* refreshes the ncurses window with the new IP address */ mvwaddstr(peerWinStatus, 0, 0, paddr); for (i=strlen(paddr);i<COLS-3;i++) mvwaddch(peerWinStatus,0,i,'-'); wrefresh(peerWinStatus); wrefresh(statusWin); }
int SCTP_getPathStatus(unsigned int associationID, short path_id, SCTP_PathStatus* status) { int result; if ((result = sctp_getPathStatus(associationID, path_id, status)) != 0) { if (result == SCTP_LIBRARY_NOT_INITIALIZED) { fprintf(stderr, "sctp_getP: library not initialized.\n"); } else if (result == SCTP_ASSOC_NOT_FOUND) { fprintf(stderr, ": association not found.\n"); } else if (result == SCTP_PARAMETER_PROBLEM) { fprintf(stderr, ": Path Id invalid.\n"); } else { fprintf(stderr, "sctp_getPathStatus: error value (%i) returned.\n", result); fflush(stderr); } } return result; }
/* 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; }