Defines | |
| #define | TCP_STATE_SENT(flags) ( (flags) << 0 ) |
| TCP flags that have been sent in outgoing packets. | |
| #define | TCP_FLAGS_SENT(state) ( ( (state) >> 0 ) & 0xff ) |
| #define | TCP_STATE_ACKED(flags) ( (flags) << 8 ) |
| TCP flags that have been acknowledged by the peer. | |
| #define | TCP_FLAGS_ACKED(state) ( ( (state) >> 8 ) & 0xff ) |
| #define | TCP_STATE_RCVD(flags) ( (flags) << 16 ) |
| TCP flags that have been received from the peer. | |
| #define | TCP_FLAGS_RCVD(state) ( ( (state) >> 16 ) & 0xff ) |
| #define | TCP_FLAGS_SENDING(state) ( TCP_FLAGS_SENT ( state ) & ~TCP_FLAGS_ACKED ( state ) ) |
| TCP flags that are currently being sent in outgoing packets. | |
| #define | TCP_CLOSED TCP_RST |
| CLOSED. | |
| #define | TCP_LISTEN 0 |
| LISTEN. | |
| #define | TCP_SYN_SENT ( TCP_STATE_SENT ( TCP_SYN ) ) |
| SYN_SENT. | |
| #define | TCP_SYN_RCVD |
| SYN_RCVD. | |
| #define | TCP_ESTABLISHED |
| ESTABLISHED. | |
| #define | TCP_FIN_WAIT_1 |
| FIN_WAIT_1. | |
| #define | TCP_FIN_WAIT_2 |
| FIN_WAIT_2. | |
| #define | TCP_CLOSING_OR_LAST_ACK |
| CLOSING / LAST_ACK. | |
| #define | TCP_TIME_WAIT |
| TIME_WAIT. | |
| #define | TCP_CLOSE_WAIT |
| CLOSE_WAIT. | |
| #define | TCP_CAN_SEND_DATA(state) |
| Can send data in current state. | |
| #define | TCP_HAS_BEEN_ESTABLISHED(state) |
| Have ever been fully established. | |
| #define | TCP_CLOSED_GRACEFULLY(state) |
| Have closed gracefully. | |
| #define TCP_STATE_SENT | ( | flags | ) | ( (flags) << 0 ) |
TCP flags that have been sent in outgoing packets.
Definition at line 107 of file tcp.h.
Referenced by tcp_close(), tcp_open(), tcp_rx_ack(), and tcp_rx_syn().
| #define TCP_STATE_ACKED | ( | flags | ) | ( (flags) << 8 ) |
TCP flags that have been acknowledged by the peer.
Note that this applies only to SYN and FIN.
Definition at line 114 of file tcp.h.
Referenced by tcp_close(), tcp_rx_ack(), and tcp_rx_rst().
| #define TCP_STATE_RCVD | ( | flags | ) | ( (flags) << 16 ) |
TCP flags that have been received from the peer.
Note that this applies only to SYN and FIN, and that once SYN has been received, we should always be sending ACK.
Definition at line 122 of file tcp.h.
Referenced by tcp_close(), tcp_rx_fin(), tcp_rx_rst(), and tcp_rx_syn().
| #define TCP_FLAGS_SENDING | ( | state | ) | ( TCP_FLAGS_SENT ( state ) & ~TCP_FLAGS_ACKED ( state ) ) |
TCP flags that are currently being sent in outgoing packets.
Definition at line 126 of file tcp.h.
Referenced by tcp_rx_ack(), and tcp_xmit().
| #define TCP_CLOSED TCP_RST |
CLOSED.
The connection has not yet been used for anything.
Definition at line 133 of file tcp.h.
Referenced by tcp_close(), tcp_expired(), tcp_open(), tcp_rx_rst(), and tcp_state().
| #define TCP_LISTEN 0 |
LISTEN.
Not currently used as a state; we have no support for listening connections. Given a unique value to avoid compiler warnings.
Definition at line 140 of file tcp.h.
Referenced by tcp_state().
| #define TCP_SYN_SENT ( TCP_STATE_SENT ( TCP_SYN ) ) |
SYN_SENT.
SYN has been sent, nothing has yet been received or acknowledged.
Definition at line 146 of file tcp.h.
Referenced by tcp_expired(), and tcp_state().
| #define TCP_SYN_RCVD |
Value:
( TCP_STATE_SENT ( TCP_SYN | TCP_ACK ) | \ TCP_STATE_RCVD ( TCP_SYN ) )
SYN has been sent but not acknowledged, SYN has been received.
Definition at line 152 of file tcp.h.
Referenced by tcp_expired(), and tcp_state().
| #define TCP_ESTABLISHED |
Value:
( TCP_STATE_SENT ( TCP_SYN | TCP_ACK ) | \ TCP_STATE_ACKED ( TCP_SYN ) | \ TCP_STATE_RCVD ( TCP_SYN ) )
SYN has been sent and acknowledged, SYN has been received.
Definition at line 159 of file tcp.h.
Referenced by tcp_expired(), and tcp_state().
| #define TCP_FIN_WAIT_1 |
Value:
( TCP_STATE_SENT ( TCP_SYN | TCP_ACK | TCP_FIN ) | \ TCP_STATE_ACKED ( TCP_SYN ) | \ TCP_STATE_RCVD ( TCP_SYN ) )
SYN has been sent and acknowledged, SYN has been received, FIN has been sent but not acknowledged, FIN has not been received.
RFC 793 shows that we can enter FIN_WAIT_1 without have had SYN acknowledged, i.e. if the application closes the connection after sending and receiving SYN, but before having had SYN acknowledged. However, we have to *pretend* that SYN has been acknowledged anyway, otherwise we end up sending SYN and FIN in the same sequence number slot. Therefore, when we transition from SYN_RCVD to FIN_WAIT_1, we have to remember to set TCP_STATE_ACKED(TCP_SYN) and increment our sequence number.
Definition at line 177 of file tcp.h.
Referenced by tcp_expired(), and tcp_state().
| #define TCP_FIN_WAIT_2 |
Value:
( TCP_STATE_SENT ( TCP_SYN | TCP_ACK | TCP_FIN ) | \ TCP_STATE_ACKED ( TCP_SYN | TCP_FIN ) | \ TCP_STATE_RCVD ( TCP_SYN ) )
SYN has been sent and acknowledged, SYN has been received, FIN has been sent and acknowledged, FIN ha not been received.
Definition at line 186 of file tcp.h.
Referenced by tcp_state().
| #define TCP_CLOSING_OR_LAST_ACK |
Value:
( TCP_STATE_SENT ( TCP_SYN | TCP_ACK | TCP_FIN ) | \ TCP_STATE_ACKED ( TCP_SYN ) | \ TCP_STATE_RCVD ( TCP_SYN | TCP_FIN ) )
SYN has been sent and acknowledged, SYN has been received, FIN has been sent but not acknowledged, FIN has been received.
This state actually encompasses both CLOSING and LAST_ACK; they are identical with the definition of state that we use. I don't *believe* that they need to be distinguished.
Definition at line 199 of file tcp.h.
Referenced by tcp_expired(), and tcp_state().
| #define TCP_TIME_WAIT |
Value:
( TCP_STATE_SENT ( TCP_SYN | TCP_ACK | TCP_FIN ) | \ TCP_STATE_ACKED ( TCP_SYN | TCP_FIN ) | \ TCP_STATE_RCVD ( TCP_SYN | TCP_FIN ) )
SYN has been sent and acknowledged, SYN has been received, FIN has been sent and acknowledged, FIN has been received.
Definition at line 209 of file tcp.h.
Referenced by tcp_expired(), and tcp_state().
| #define TCP_CLOSE_WAIT |
Value:
( TCP_STATE_SENT ( TCP_SYN | TCP_ACK ) | \ TCP_STATE_ACKED ( TCP_SYN ) | \ TCP_STATE_RCVD ( TCP_SYN | TCP_FIN ) )
SYN has been sent and acknowledged, SYN has been received, FIN has been received.
Definition at line 218 of file tcp.h.
Referenced by tcp_expired(), and tcp_state().
| #define TCP_CAN_SEND_DATA | ( | state | ) |
Value:
( ( (state) & ( TCP_STATE_ACKED ( TCP_SYN ) | \ TCP_STATE_SENT ( TCP_FIN ) ) ) \ == TCP_STATE_ACKED ( TCP_SYN ) )
We can send data if and only if we have had our SYN acked and we have not yet sent our FIN.
Definition at line 227 of file tcp.h.
Referenced by tcp_xmit(), and tcp_xmit_win().
| #define TCP_HAS_BEEN_ESTABLISHED | ( | state | ) |
Value:
( ( (state) & ( TCP_STATE_ACKED ( TCP_SYN ) | \ TCP_STATE_RCVD ( TCP_SYN ) ) ) \ == ( TCP_STATE_ACKED ( TCP_SYN ) | TCP_STATE_RCVD ( TCP_SYN ) ) )
We have been fully established if we have both received a SYN and had our own SYN acked.
Definition at line 237 of file tcp.h.
Referenced by tcp_rx_ack().
| #define TCP_CLOSED_GRACEFULLY | ( | state | ) |
Value:
( ( (state) & ( TCP_STATE_ACKED ( TCP_FIN ) | \ TCP_STATE_RCVD ( TCP_FIN ) ) ) \ == ( TCP_STATE_ACKED ( TCP_FIN ) | TCP_STATE_RCVD ( TCP_FIN ) ) )
We have closed gracefully if we have both received a FIN and had our own FIN acked.
Definition at line 247 of file tcp.h.
Referenced by tcp_expired(), and tcp_rx().
1.5.7.1