Changeset 37738 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jul 3, 2011 11:41:17 AM (14 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/debug.c
r37724 r37738 34 34 void dump_packet(void *, int); 35 35 #endif 36 37 #ifndef STRINGIFY 38 # define STRINGIFY(x) #x 39 #endif 40 41 static char *g_apszTcpStates[TCP_NSTATES] = 42 { 43 STRINGIFY(TCPS_CLOSED), 44 STRINGIFY(TCPS_LISTEN), 45 STRINGIFY(TCPS_SYN_SENT), 46 STRINGIFY(TCPS_SYN_RECEIVED), 47 STRINGIFY(TCPS_ESTABLISHED), 48 STRINGIFY(TCPS_CLOSE_WAIT), 49 STRINGIFY(TCPS_FIN_WAIT_1), 50 STRINGIFY(TCPS_CLOSING), 51 STRINGIFY(TCPS_LAST_ACK), 52 STRINGIFY(TCPS_FIN_WAIT_2), 53 STRINGIFY(TCPS_TIME_WAIT) 54 }; 36 55 37 56 /* … … 295 314 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SEG[ACK: %x, SEQ: %x, LEN: %x, WND: %x, UP: %x]", 296 315 ti->ti_ack, ti->ti_seq, ti->ti_len, ti->ti_win, ti->ti_urp); 316 return cb; 317 } 318 319 /* 320 * Prints TCP state 321 */ 322 static DECLCALLBACK(size_t) 323 printTcpState(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 324 const char *pszType, void const *pvValue, 325 int cchWidth, int cchPrecision, unsigned fFlags, 326 void *pvUser) 327 { 328 size_t cb = 0; 329 const int idxTcpState = (int)pvValue; 330 char *pszTcpStateName = (idxTcpState >= 0 && idxTcpState < TCP_NSTATES) ? g_apszTcpStates[idxTcpState] : "TCPS_INVALIDE_STATE"; 331 AssertReturn(RTStrCmp(pszType, "tcpstate") == 0, 0); 332 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s", pszTcpStateName); 297 333 return cb; 298 334 } … … 365 401 rc = RTStrFormatTypeRegister("tcpseg793", printTcpSegmentRfc793, NULL); 366 402 AssertRC(rc); 403 rc = RTStrFormatTypeRegister("tcpstate", printTcpState, NULL); 404 AssertRC(rc); 367 405 g_fFormatRegistered = 1; 368 406 } -
trunk/src/VBox/Devices/Network/slirp/debug.h
r34103 r37738 40 40 void sockstats (PNATState); 41 41 42 #ifdef LOG_ENABLED 43 # define TCP_STATE_SWITCH_TO(tp, new_tcp_state) \ 44 do { \ 45 Log2(("%R[tcpcb793] switch to %R[tcpstate] -> %R[tcpstate]\n", (tp), (tp), (tp->t_state) ,(new_tcp_state))); \ 46 if ((tp)->t_socket) \ 47 Log2(("%R[tcpcb793] %R[natsock]\n", (tp), (tp)->t_socket)); \ 48 (tp)->t_state = (new_tcp_state); \ 49 } while(0) 50 #else 51 # define TCP_STATE_SWITCH_TO(tp, new_tcp_state) (tp)->t_state = (new_tcp_state) 42 52 #endif 53 #endif -
trunk/src/VBox/Devices/Network/slirp/tcp_input.c
r37728 r37738 549 549 550 550 tp = sototcpcb(so); 551 tp->t_state = TCPS_LISTEN;551 TCP_STATE_SWITCH_TO(tp, TCPS_LISTEN); 552 552 } 553 553 … … 839 839 so->so_ti = ti; 840 840 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; 841 tp->t_state = TCPS_SYN_RECEIVED;841 TCP_STATE_SWITCH_TO(tp, TCPS_SYN_RECEIVED); 842 842 } 843 843 SOCKET_UNLOCK(so); … … 873 873 tcp_rcvseqinit(tp); 874 874 tp->t_flags |= TF_ACKNOW; 875 tp->t_state = TCPS_SYN_RECEIVED;875 TCP_STATE_SWITCH_TO(tp, TCPS_SYN_RECEIVED); 876 876 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; 877 877 tcpstat.tcps_accepts++; … … 929 929 tcpstat.tcps_connects++; 930 930 soisfconnected(so); 931 tp->t_state = TCPS_ESTABLISHED;931 TCP_STATE_SWITCH_TO(tp, TCPS_ESTABLISHED); 932 932 933 933 /* Do window scaling on this connection? */ … … 949 949 } 950 950 else 951 tp->t_state = TCPS_SYN_RECEIVED;951 TCP_STATE_SWITCH_TO(tp, TCPS_SYN_RECEIVED); 952 952 953 953 trimthenstep6: … … 1171 1171 close: 1172 1172 LogFlowFunc(("close:\n")); 1173 tp->t_state = TCPS_CLOSED;1173 TCP_STATE_SWITCH_TO(tp, TCPS_CLOSED); 1174 1174 tcpstat.tcps_drops++; 1175 1175 tp = tcp_close(pData, tp); … … 1220 1220 goto dropwithreset; 1221 1221 tcpstat.tcps_connects++; 1222 tp->t_state = TCPS_ESTABLISHED;1222 TCP_STATE_SWITCH_TO(tp, TCPS_ESTABLISHED); 1223 1223 /* 1224 1224 * The sent SYN is ack'ed with our sequence number +1 … … 1445 1445 tp->t_timer[TCPT_2MSL] = tcp_maxidle; 1446 1446 } 1447 tp->t_state = TCPS_FIN_WAIT_2;1447 TCP_STATE_SWITCH_TO(tp, TCPS_FIN_WAIT_2); 1448 1448 } 1449 1449 break; … … 1458 1458 if (ourfinisacked) 1459 1459 { 1460 tp->t_state = TCPS_TIME_WAIT;1460 TCP_STATE_SWITCH_TO(tp, TCPS_TIME_WAIT); 1461 1461 tcp_canceltimers(tp); 1462 1462 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; … … 1661 1661 case TCPS_SYN_RECEIVED: 1662 1662 case TCPS_ESTABLISHED: 1663 tp->t_state = TCPS_CLOSE_WAIT;1663 TCP_STATE_SWITCH_TO(tp, TCPS_CLOSE_WAIT); 1664 1664 break; 1665 1665 … … 1669 1669 */ 1670 1670 case TCPS_FIN_WAIT_1: 1671 tp->t_state = TCPS_CLOSING;1671 TCP_STATE_SWITCH_TO(tp, TCPS_CLOSING); 1672 1672 break; 1673 1673 … … 1678 1678 */ 1679 1679 case TCPS_FIN_WAIT_2: 1680 tp->t_state = TCPS_TIME_WAIT;1680 TCP_STATE_SWITCH_TO(tp, TCPS_TIME_WAIT); 1681 1681 tcp_canceltimers(tp); 1682 1682 tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r34103 r37738 225 225 tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; 226 226 tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; 227 tp->t_state = TCPS_CLOSED;227 TCP_STATE_SWITCH_TO(tp, TCPS_CLOSED); 228 228 229 229 so->so_tcpcb = tp; … … 248 248 if (TCPS_HAVERCVDSYN(tp->t_state)) 249 249 { 250 tp->t_state = TCPS_CLOSED;250 TCP_STATE_SWITCH_TO(tp, TCPS_CLOSED); 251 251 (void) tcp_output(pData, tp); 252 252 tcpstat.tcps_drops++; … … 360 360 case TCPS_LISTEN: 361 361 case TCPS_SYN_SENT: 362 tp->t_state = TCPS_CLOSED;362 TCP_STATE_SWITCH_TO(tp, TCPS_CLOSED); 363 363 tp = tcp_close(pData, tp); 364 364 break; … … 366 366 case TCPS_SYN_RECEIVED: 367 367 case TCPS_ESTABLISHED: 368 tp->t_state = TCPS_FIN_WAIT_1;368 TCP_STATE_SWITCH_TO(tp, TCPS_FIN_WAIT_1); 369 369 break; 370 370 371 371 case TCPS_CLOSE_WAIT: 372 tp->t_state = TCPS_LAST_ACK;372 TCP_STATE_SWITCH_TO(tp, TCPS_LAST_ACK); 373 373 break; 374 374 } … … 584 584 tcpstat.tcps_connattempt++; 585 585 586 tp->t_state = TCPS_SYN_SENT;586 TCP_STATE_SWITCH_TO(tp, TCPS_SYN_SENT); 587 587 tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; 588 588 tp->iss = tcp_iss;
Note:
See TracChangeset
for help on using the changeset viewer.