diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 364ceef9..d0fb63c2 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -1993,6 +1993,7 @@ static int net_conn_get_tcp(sigar_t *sigar, for (i = 0; i < tcp->dwNumEntries; i++) { sigar_net_connection_t conn; + int tcp_state; DWORD state = tcp->table[i].dwState; if (flags & SIGAR_NETCONN_SERVER) { @@ -2019,6 +2020,47 @@ static int net_conn_get_tcp(sigar_t *sigar, sizeof(conn.remote_address), tcp->table[i].dwRemoteAddr); + switch (state) { + case MIB_TCP_STATE_CLOSED: + tcp_state = SIGAR_TCP_CLOSE; + break; + case MIB_TCP_STATE_LISTEN: + tcp_state = SIGAR_TCP_LISTEN; + break; + case MIB_TCP_STATE_SYN_SENT: + tcp_state = SIGAR_TCP_SYN_SENT; + break; + case MIB_TCP_STATE_SYN_RCVD: + tcp_state = SIGAR_TCP_SYN_RECV; + break; + case MIB_TCP_STATE_ESTAB: + tcp_state = SIGAR_TCP_ESTABLISHED; + break; + case MIB_TCP_STATE_FIN_WAIT1: + tcp_state = SIGAR_TCP_FIN_WAIT1; + break; + case MIB_TCP_STATE_FIN_WAIT2: + tcp_state = SIGAR_TCP_FIN_WAIT2; + break; + case MIB_TCP_STATE_CLOSE_WAIT: + tcp_state = SIGAR_TCP_CLOSE_WAIT; + break; + case MIB_TCP_STATE_CLOSING: + tcp_state = SIGAR_TCP_CLOSING; + break; + case MIB_TCP_STATE_LAST_ACK: + tcp_state = SIGAR_TCP_LAST_ACK; + break; + case MIB_TCP_STATE_TIME_WAIT: + tcp_state = SIGAR_TCP_TIME_WAIT; + break; + case MIB_TCP_STATE_DELETE_TCB: + default: + tcp_state = SIGAR_TCP_ESTABLISHED; /*XXX*/ + break; + } + + /* XXX conn.state = tcp_state */ SIGAR_NET_CONNLIST_GROW(connlist); memcpy(&connlist->data[connlist->number++], &conn, sizeof(conn));