map tcp state

This commit is contained in:
Doug MacEachern 2005-03-11 04:45:09 +00:00
parent b16072f3cb
commit 533e425c87
1 changed files with 42 additions and 0 deletions

View File

@ -1993,6 +1993,7 @@ static int net_conn_get_tcp(sigar_t *sigar,
for (i = 0; i < tcp->dwNumEntries; i++) { for (i = 0; i < tcp->dwNumEntries; i++) {
sigar_net_connection_t conn; sigar_net_connection_t conn;
int tcp_state;
DWORD state = tcp->table[i].dwState; DWORD state = tcp->table[i].dwState;
if (flags & SIGAR_NETCONN_SERVER) { if (flags & SIGAR_NETCONN_SERVER) {
@ -2019,6 +2020,47 @@ static int net_conn_get_tcp(sigar_t *sigar,
sizeof(conn.remote_address), sizeof(conn.remote_address),
tcp->table[i].dwRemoteAddr); 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); SIGAR_NET_CONNLIST_GROW(connlist);
memcpy(&connlist->data[connlist->number++], memcpy(&connlist->data[connlist->number++],
&conn, sizeof(conn)); &conn, sizeof(conn));