21#define TCP_ESTABLISHED 4
22#define TCP_FIN_WAIT_1 5
23#define TCP_FIN_WAIT_2 6
25#define TCP_TIME_WAIT 8
26#define TCP_CLOSE_WAIT 9
27#define TCP_LAST_ACK 10
32#define TCP_FLG_FIN 0x01
33#define TCP_FLG_SYN 0x02
34#define TCP_FLG_RST 0x04
35#define TCP_FLG_PSH 0x08
36#define TCP_FLG_ACK 0x10
37#define TCP_FLG_URG 0x20
42#define TCP_FLG_FLAG 0x3F
44#define TCP_CONNECT_REFUSED (-1)
45#define TCP_CONNECT_RESET (-2)
46#define TCP_CONNECT_CLOSED (-3)
51#define TCP_CONGEST_RECOVER 1
52#define TCP_CONGEST_LOSS 2
53#define TCP_CONGEST_OPEN 3
58#define TCP_CTRL_NO_NAGLE 0x0001
59#define TCP_CTRL_NO_KEEPALIVE 0x0002
60#define TCP_CTRL_NO_WS 0x0004
61#define TCP_CTRL_RCVD_WS 0x0008
62#define TCP_CTRL_NO_TS 0x0010
63#define TCP_CTRL_RCVD_TS 0x0020
64#define TCP_CTRL_SND_TS 0x0040
65#define TCP_CTRL_SND_URG 0x0080
66#define TCP_CTRL_RCVD_URG 0x0100
67#define TCP_CTRL_SND_PSH 0x0200
68#define TCP_CTRL_FIN_SENT 0x0400
69#define TCP_CTRL_FIN_ACKED 0x0800
70#define TCP_CTRL_TIMER_ON 0x1000
71#define TCP_CTRL_RTT_ON 0x2000
72#define TCP_CTRL_ACK_NOW 0x4000
77#define TCP_TIMER_CONNECT 0
78#define TCP_TIMER_REXMIT 1
79#define TCP_TIMER_PROBE 2
80#define TCP_TIMER_KEEPALIVE 3
81#define TCP_TIMER_FINWAIT2 4
82#define TCP_TIMER_2MSL 5
83#define TCP_TIMER_NUMBER 6
86#define TCP_RTT_SHIFT 3
87#define TCP_RTO_MIN TCP_TICK_HZ
88#define TCP_RTO_MAX (TCP_TICK_HZ * 60)
94#define TCP_MAX_LOSS 12
95#define TCP_KEEPALIVE_IDLE_MIN (TCP_TICK_HZ * 60 * 60 * 2)
96#define TCP_KEEPALIVE_PERIOD (TCP_TICK_HZ * 60)
97#define TCP_MAX_KEEPALIVE 8
98#define TCP_FIN_WAIT2_TIME (2 * TCP_TICK_HZ)
99#define TCP_TIME_WAIT_TIME (2 * TCP_TICK_HZ)
100#define TCP_PAWS_24DAY (24 * 24 * 60 * 60 * TCP_TICK_HZ)
101#define TCP_CONNECT_TIME (75 * TCP_TICK_HZ)
107#define TCP_MAX_HEAD 192
112#define TCP_RCV_BUF_SIZE (2 * 1024 * 1024)
113#define TCP_RCV_BUF_SIZE_MIN (8 * 1024)
114#define TCP_SND_BUF_SIZE (2 * 1024 * 1024)
115#define TCP_SND_BUF_SIZE_MIN (8 * 1024)
116#define TCP_BACKLOG 10
117#define TCP_BACKLOG_MIN 5
118#define TCP_MAX_LOSS_MIN 6
119#define TCP_CONNECT_TIME_MIN (60 * TCP_TICK_HZ)
120#define TCP_MAX_KEEPALIVE_MIN 4
121#define TCP_KEEPALIVE_IDLE_MAX (TCP_TICK_HZ * 60 * 60 * 4)
122#define TCP_KEEPALIVE_PERIOD_MIN (TCP_TICK_HZ * 30)
123#define TCP_FIN_WAIT2_TIME_MAX (4 * TCP_TICK_HZ)
124#define TCP_TIME_WAIT_TIME_MAX (60 * TCP_TICK_HZ)
129#define TCP_CONNECTED(state) ((state) > TCP_SYN_RCVD)
131#define TCP_FIN_RCVD(State) \
133 ((State) == TCP_CLOSE_WAIT) || \
134 ((State) == TCP_LAST_ACK) || \
135 ((State) == TCP_CLOSING) || \
136 ((State) == TCP_TIME_WAIT) \
139#define TCP_LOCAL_CLOSED(State) \
141 ((State) == TCP_FIN_WAIT_1) || \
142 ((State) == TCP_FIN_WAIT_2) || \
143 ((State) == TCP_CLOSING) || \
144 ((State) == TCP_TIME_WAIT) || \
145 ((State) == TCP_LAST_ACK) \
151#define TCPSEG_NETBUF(NBuf) ((TCP_SEG *) ((NBuf)->ProtoData))
156#define TCP_SEQ_LT(SeqA, SeqB) ((INT32) ((SeqA) - (SeqB)) < 0)
157#define TCP_SEQ_LEQ(SeqA, SeqB) ((INT32) ((SeqA) - (SeqB)) <= 0)
158#define TCP_SEQ_GT(SeqA, SeqB) ((INT32) ((SeqB) - (SeqA)) < 0)
159#define TCP_SEQ_GEQ(SeqA, SeqB) ((INT32) ((SeqB) - (SeqA)) <= 0)
164#define TCP_SEQ_BETWEEN(b, m, e) ((e) - (b) >= (m) - (b))
169#define TCP_SUB_SEQ(Seq1, Seq2) ((UINT32) ((Seq1) - (Seq2)))
174#define TCP_FLG_ON(Value, Flag) ((BOOLEAN) (((Value) & (Flag)) != 0))
178#define TCP_SET_FLG(Value, Flag) ((Value) |= (Flag))
179#define TCP_CLEAR_FLG(Value, Flag) ((Value) &= ~(Flag))
184#define TCP_PEER_EQUAL(Pa, Pb, Ver) \
185 (((Pa)->Port == (Pb)->Port) && TcpIsIpEqual(&((Pa)->Ip), &((Pb)->Ip), Ver))
191#define TCP_PEER_MATCH(Pa, Pb, Ver) \
193 (((Pb)->Port == 0) || ((Pb)->Port == (Pa)->Port)) && \
194 (TcpIsIpZero (&((Pb)->Ip), Ver) || TcpIsIpEqual (&((Pb)->Ip), &((Pa)->Ip), Ver)) \
197#define TCP_TIMER_ON(Flag, Timer) ((Flag) & (1 << (Timer)))
198#define TCP_SET_TIMER(Flag, Timer) ((Flag) = (UINT16) ((Flag) | (1 << (Timer))))
199#define TCP_CLEAR_TIMER(Flag, Timer) ((Flag) = (UINT16) ((Flag) & (~(1 << (Timer)))))
201#define TCP_TIME_LT(Ta, Tb) ((INT32) ((Ta) - (Tb)) < 0)
202#define TCP_TIME_LEQ(Ta, Tb) ((INT32) ((Ta) - (Tb)) <= 0)
203#define TCP_SUB_TIME(Ta, Tb) ((UINT32) ((Ta) - (Tb)))
205#define TCP_MAX_WIN 0xFFFFU
330 BOOLEAN UseDefaultAddr;
#define TCP_TIMER_NUMBER
The total number of the TCP timer.
struct _TCP_PEER TCP_PEER
UINT32 KeepAlivePeriod
Interval for subsequent keep alive probe.
UINT8 LossTimes
Number of retxmit timeouts in a row.
TCP_SEQNO SndUna
First unacknowledged data.
UINT32 Tick
1 tick = 200ms
UINT8 SndWndScale
Wndscale received from the peer.
TCP_PEER RemoteEnd
Remote endpoint.
TCP_SEQNO LossRecover
Recover point for retxmit.
UINT16 MaxRexmit
The maximum number of retxmit before abort.
UINT8 MaxKeepAlive
Maximum keep alive probe times.
INT32 Error
Soft error status, such as TCP_CONNECT_RESET.
UINT32 RttMeasure
Currently measured RTT in heartbeats.
UINT8 DelayedAck
Number of delayed ACKs.
TCP_SEQNO RcvNxt
Next sequence no to receive.
UINT32 Ssthresh
Slow start threshold.
TCP_CB * Parent
The parent TCP_CB structure.
INT32 NextExpire
Countdown offset for the nearest timer.
TCP_SEQNO Irs
Initial Receiving Sequence.
UINT32 Timer[TCP_TIMER_NUMBER]
When the timer will expire.
UINT16 EnabledTimer
Which timer is currently enabled.
UINT8 RcvWndScale
Wndscale used to scale local buffer.
UINT32 Idle
How long the connection is in idle.
TCP_SEQNO SndWl2
Ack no of last window update.
UINT32 RcvWnd
Window advertised by the local peer.
UINT8 CongestState
The current congestion state(RFC3782).
UINT32 TimeWaitTimeout
The TIME_WAIT timeout.
TCP_SEQNO SndUp
Send urgent point.
BOOLEAN ProbeTimerOn
If TRUE, the probe time is on.
UINT32 RttVar
RTT variance, scaled by 8.
TCP_SEQNO RttSeq
The seq of measured segment now.
UINT16 RcvMss
Max receive segment size.
TCP_SEQNO Recover
Recover point for NewReno.
UINT32 Rto
Current RTO, not scaled.
TCP_SEQNO Iss
Initial Sending Sequence.
UINT32 SndWndMax
Max send window advertised by the peer.
UINT8 State
TCP state, such as SYN_SENT, LISTEN.
TCP_SEQNO SndPsh
Send PUSH point.
UINT32 KeepAliveIdle
Idle time before sending first probe.
LIST_ENTRY RcvQue
Reassemble queue.
UINT16 SndMss
Max send segment size.
TCP_SEQNO SndWl1
Seq number used for last window update.
UINT8 KeepAliveProbes
The number of keep alive probe.
UINT32 FinWait2Timeout
The FIN_WAIT_2 timeout.
UINT16 DupAck
Number of duplicate ACKs.
UINT32 ConnectTimeout
The connect establishment timeout.
UINT32 SRtt
Smoothed RTT, scaled by 8.
SOCKET * Sk
The socket it controlled.
TCP_PEER LocalEnd
Local endpoint.
IP_IO_IP_INFO * IpInfo
Pointer reference to Ip used to send pkt.
LIST_ENTRY List
Back and forward link entry.
UINT32 ProbeTime
The time out value for current window prober.
TCP_SEQNO RcvUp
Urgent point;.
UINT32 TsRecentAge
When this TsRecent is updated.
BOOLEAN RemoteIpZero
RemoteEnd.Ip is ZERO when configured.
TCP_SEQNO RetxmitSeqMax
Max Seq number in previous retransmission.
UINT32 CtrlFlag
Control flags, such as NO_NAGLE.
TCP_SEQNO SndNxt
Next data sequence to send.
UINT32 TsRecent
TsRecent to echo to the remote peer.
UINT32 CWnd
Sender's congestion window.
LIST_ENTRY SndQue
Retxmission queue.
UINT32 SndWnd
Window advertised by the remote peer.
EFI_IP_ADDRESS Ip
IP address, in network byte order.
TCP_PORTNO Port
Port number, in network byte order.
TCP_SEQNO Seq
Starting sequence number.
TCP_SEQNO End
The sequence of the last byte + 1, include SYN/FIN. End-Seq = SEG.LEN.
UINT8 Flag
TCP header flags.
UINT16 Urg
Valid if URG flag is set.
TCP_SEQNO Ack
ACK field in the segment.
UINT32 Wnd
TCP window size field.