iPXE
|
The TCP state is defined by a combination of the flags that have been sent to the peer, the flags that have been acknowledged by the peer, and the flags that have been received from the peer. More...
Macros | |
#define | TCP_STATE_SENT(flags) ( (flags) << 0 ) |
TCP flags that have been sent in outgoing packets. More... | |
#define | TCP_FLAGS_SENT(state) ( ( (state) >> 0 ) & 0xff ) |
#define | TCP_STATE_ACKED(flags) ( (flags) << 8 ) |
TCP flags that have been acknowledged by the peer. More... | |
#define | TCP_FLAGS_ACKED(state) ( ( (state) >> 8 ) & 0xff ) |
#define | TCP_STATE_RCVD(flags) ( (flags) << 16 ) |
TCP flags that have been received from the peer. More... | |
#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. More... | |
#define | TCP_CLOSED TCP_RST |
CLOSED. More... | |
#define | TCP_LISTEN 0 |
LISTEN. More... | |
#define | TCP_SYN_SENT ( TCP_STATE_SENT ( TCP_SYN ) ) |
SYN_SENT. More... | |
#define | TCP_SYN_RCVD |
SYN_RCVD. More... | |
#define | TCP_ESTABLISHED |
ESTABLISHED. More... | |
#define | TCP_FIN_WAIT_1 |
FIN_WAIT_1. More... | |
#define | TCP_FIN_WAIT_2 |
FIN_WAIT_2. More... | |
#define | TCP_CLOSING_OR_LAST_ACK |
CLOSING / LAST_ACK. More... | |
#define | TCP_TIME_WAIT |
TIME_WAIT. More... | |
#define | TCP_CLOSE_WAIT |
CLOSE_WAIT. More... | |
#define | TCP_CAN_SEND_DATA(state) |
Can send data in current state. More... | |
#define | TCP_HAS_BEEN_ESTABLISHED(state) |
Have ever been fully established. More... | |
#define | TCP_CLOSED_GRACEFULLY(state) |
Have closed gracefully. More... | |
The TCP state is defined by a combination of the flags that have been sent to the peer, the flags that have been acknowledged by the peer, and the flags that have been received from the peer.
#define TCP_FLAGS_SENDING | ( | state | ) | ( TCP_FLAGS_SENT ( state ) & ~TCP_FLAGS_ACKED ( state ) ) |
#define TCP_CLOSED TCP_RST |
#define TCP_LISTEN 0 |
#define TCP_SYN_SENT ( TCP_STATE_SENT ( TCP_SYN ) ) |
#define TCP_SYN_RCVD |
#define TCP_ESTABLISHED |
#define TCP_FIN_WAIT_1 |
FIN_WAIT_1.
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.
#define TCP_FIN_WAIT_2 |
#define TCP_CLOSING_OR_LAST_ACK |
CLOSING / LAST_ACK.
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.
#define TCP_TIME_WAIT |
TIME_WAIT.
SYN has been sent and acknowledged, SYN has been received, FIN has been sent and acknowledged, FIN has been received.
#define TCP_CLOSE_WAIT |
#define TCP_CAN_SEND_DATA | ( | state | ) |
Can send data in current state.
We can send data if and only if we have had our SYN acked and we have not yet sent our FIN.
#define TCP_HAS_BEEN_ESTABLISHED | ( | state | ) |
Have ever been fully established.
We have been fully established if we have both received a SYN and had our own SYN acked.
#define TCP_CLOSED_GRACEFULLY | ( | state | ) |
Have closed gracefully.
We have closed gracefully if we have both received a FIN and had our own FIN acked.