3

I'm creating a parser for /proc/net/tcp, and I would like to know what are all the possible constants for the connection states (fourth column)? I know 0A means LISTENING, but Google results don't give me the rest of the answers I need.

  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
  0: 3500007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000   101        0 21384 1 ffff987636718000 100 0 0 10 0                     
  1: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 78109 1 ffff98762c4dd000 100 0 0 10 0                     
  2: 800AA8C0:B9CC 70FD1EC0:0016 06 00000000:00000000 03:000005EF 00000000     0        0 0 3 ffff987518bb7cf0                                                          
2

The state contants correspond to the entries in the first enum in net/tcp_states.h:

enum {
    TCP_ESTABLISHED = 1,
    TCP_SYN_SENT,
    TCP_SYN_RECV,
    TCP_FIN_WAIT1,
    TCP_FIN_WAIT2,
    TCP_TIME_WAIT,
    TCP_CLOSE,
    TCP_CLOSE_WAIT,
    TCP_LAST_ACK,
    TCP_LISTEN,
    TCP_CLOSING,    /* Now a valid state */
    TCP_NEW_SYN_RECV,

    TCP_MAX_STATES  /* Leave at the end! */
};

The values are currently as follows:

  1. established;
  2. syn sent;
  3. syn received;
  4. fin wait 1;
  5. fin wait 2;
  6. time wait;
  7. close;
  8. close wait;
  9. last acknowledgment;
  10. listening;
  11. closing;
  12. new syn received.

Most of these correspond to states in the TCP/IP state machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.