Go to the documentation of this file.
35 #include "net_config.h"
40 #define TCP_SUPPORT ENABLED
41 #elif (TCP_SUPPORT != ENABLED && TCP_SUPPORT != DISABLED)
42 #error TCP_SUPPORT parameter is not valid
46 #ifndef TCP_TICK_INTERVAL
47 #define TCP_TICK_INTERVAL 100
48 #elif (TCP_TICK_INTERVAL < 10)
49 #error TCP_TICK_INTERVAL parameter is not valid
54 #define TCP_MAX_MSS 1430
55 #elif (TCP_MAX_MSS < 536)
56 #error TCP_MAX_MSS parameter is not valid
61 #define TCP_MIN_MSS 64
62 #elif (TCP_MIN_MSS < 1)
63 #error TCP_MIN_MSS parameter is not valid
67 #ifndef TCP_DEFAULT_TX_BUFFER_SIZE
68 #define TCP_DEFAULT_TX_BUFFER_SIZE 2860
69 #elif (TCP_DEFAULT_TX_BUFFER_SIZE < 536)
70 #error TCP_DEFAULT_TX_BUFFER_SIZE parameter is not valid
74 #ifndef TCP_MAX_TX_BUFFER_SIZE
75 #define TCP_MAX_TX_BUFFER_SIZE 22880
76 #elif (TCP_MAX_TX_BUFFER_SIZE < 536)
77 #error TCP_MAX_TX_BUFFER_SIZE parameter is not valid
81 #ifndef TCP_DEFAULT_RX_BUFFER_SIZE
82 #define TCP_DEFAULT_RX_BUFFER_SIZE 2860
83 #elif (TCP_DEFAULT_RX_BUFFER_SIZE < 536)
84 #error TCP_DEFAULT_RX_BUFFER_SIZE parameter is not valid
88 #ifndef TCP_MAX_RX_BUFFER_SIZE
89 #define TCP_MAX_RX_BUFFER_SIZE 22880
90 #elif (TCP_MAX_RX_BUFFER_SIZE < 536)
91 #error TCP_MAX_RX_BUFFER_SIZE parameter is not valid
95 #ifndef TCP_DEFAULT_SYN_QUEUE_SIZE
96 #define TCP_DEFAULT_SYN_QUEUE_SIZE 4
97 #elif (TCP_DEFAULT_SYN_QUEUE_SIZE < 1)
98 #error TCP_DEFAULT_SYN_QUEUE_SIZE parameter is not valid
102 #ifndef TCP_MAX_SYN_QUEUE_SIZE
103 #define TCP_MAX_SYN_QUEUE_SIZE 16
104 #elif (TCP_MAX_SYN_QUEUE_SIZE < 1)
105 #error TCP_MAX_SYN_QUEUE_SIZE parameter is not valid
109 #ifndef TCP_MAX_RETRIES
110 #define TCP_MAX_RETRIES 5
111 #elif (TCP_MAX_RETRIES < 1)
112 #error TCP_MAX_RETRIES parameter is not valid
116 #ifndef TCP_INITIAL_RTO
117 #define TCP_INITIAL_RTO 1000
118 #elif (TCP_INITIAL_RTO < 100)
119 #error TCP_INITIAL_RTO parameter is not valid
124 #define TCP_MIN_RTO 1000
125 #elif (TCP_MIN_RTO < 100)
126 #error TCP_MIN_RTO parameter is not valid
131 #define TCP_MAX_RTO 60000
132 #elif (TCP_MAX_RTO < 1000)
133 #error TCP_MAX_RTO parameter is not valid
137 #ifndef TCP_SECURE_ISN_SUPPORT
138 #define TCP_SECURE_ISN_SUPPORT DISABLED
139 #elif (TCP_SECURE_ISN_SUPPORT != ENABLED && TCP_SECURE_ISN_SUPPORT != DISABLED)
140 #error TCP_SECURE_ISN_SUPPORT parameter is not valid
144 #ifndef TCP_CONGEST_CONTROL_SUPPORT
145 #define TCP_CONGEST_CONTROL_SUPPORT ENABLED
146 #elif (TCP_CONGEST_CONTROL_SUPPORT != ENABLED && TCP_CONGEST_CONTROL_SUPPORT != DISABLED)
147 #error TCP_CONGEST_CONTROL_SUPPORT parameter is not valid
151 #ifndef TCP_FAST_RETRANSMIT_THRES
152 #define TCP_FAST_RETRANSMIT_THRES 3
153 #elif (TCP_FAST_RETRANSMIT_THRES < 1)
154 #error TCP_FAST_RETRANSMIT_THRES parameter is not valid
158 #ifndef TCP_INITIAL_WINDOW
159 #define TCP_INITIAL_WINDOW 3
160 #elif (TCP_INITIAL_WINDOW < 1)
161 #error TCP_INITIAL_WINDOW parameter is not valid
165 #ifndef TCP_LOSS_WINDOW
166 #define TCP_LOSS_WINDOW 1
167 #elif (TCP_LOSS_WINDOW < 1)
168 #error TCP_LOSS_WINDOW parameter is not valid
172 #ifndef TCP_DEFAULT_PROBE_INTERVAL
173 #define TCP_DEFAULT_PROBE_INTERVAL 1000
174 #elif (TCP_DEFAULT_PROBE_INTERVAL < 100)
175 #error TCP_DEFAULT_PROBE_INTERVAL parameter is not valid
179 #ifndef TCP_MAX_PROBE_INTERVAL
180 #define TCP_MAX_PROBE_INTERVAL 60000
181 #elif (TCP_MAX_PROBE_INTERVAL < 1000)
182 #error TCP_MAX_PROBE_INTERVAL parameter is not valid
186 #ifndef TCP_OVERRIDE_TIMEOUT
187 #define TCP_OVERRIDE_TIMEOUT 500
188 #elif (TCP_OVERRIDE_TIMEOUT < 100)
189 #error TCP_OVERRIDE_TIMEOUT parameter is not valid
193 #ifndef TCP_FIN_WAIT_2_TIMER
194 #define TCP_FIN_WAIT_2_TIMER 4000
195 #elif (TCP_FIN_WAIT_2_TIMER < 1000)
196 #error TCP_FIN_WAIT_2_TIMER parameter is not valid
200 #ifndef TCP_2MSL_TIMER
201 #define TCP_2MSL_TIMER 4000
202 #elif (TCP_2MSL_TIMER < 0)
203 #error TCP_2MSL_TIMER parameter is not valid
207 #ifndef TCP_KEEP_ALIVE_SUPPORT
208 #define TCP_KEEP_ALIVE_SUPPORT DISABLED
209 #elif (TCP_KEEP_ALIVE_SUPPORT != ENABLED && TCP_KEEP_ALIVE_SUPPORT != DISABLED)
210 #error TCP_KEEP_ALIVE_SUPPORT parameter is not valid
214 #ifndef TCP_DEFAULT_KEEP_ALIVE_IDLE
215 #define TCP_DEFAULT_KEEP_ALIVE_IDLE 60000
216 #elif (TCP_DEFAULT_KEEP_ALIVE_IDLE < 1000)
217 #error TCP_DEFAULT_KEEP_ALIVE_IDLE parameter is not valid
221 #ifndef TCP_DEFAULT_KEEP_ALIVE_INTERVAL
222 #define TCP_DEFAULT_KEEP_ALIVE_INTERVAL 15000
223 #elif (TCP_DEFAULT_KEEP_ALIVE_INTERVAL < 1000)
224 #error TCP_DEFAULT_KEEP_ALIVE_INTERVAL parameter is not valid
228 #ifndef TCP_DEFAULT_KEEP_ALIVE_PROBES
229 #define TCP_DEFAULT_KEEP_ALIVE_PROBES 5
230 #elif (TCP_DEFAULT_KEEP_ALIVE_PROBES < 1)
231 #error TCP_DEFAULT_KEEP_ALIVE_PROBES parameter is not valid
235 #ifndef TCP_SACK_SUPPORT
236 #define TCP_SACK_SUPPORT DISABLED
237 #elif (TCP_SACK_SUPPORT != ENABLED && TCP_SACK_SUPPORT != DISABLED)
238 #error TCP_SACK_SUPPORT parameter is not valid
242 #ifndef TCP_MAX_SACK_BLOCKS
243 #define TCP_MAX_SACK_BLOCKS 4
244 #elif (TCP_MAX_SACK_BLOCKS < 1)
245 #error TCP_MAX_SACK_BLOCKS parameter is not valid
249 #define TCP_MAX_HEADER_LENGTH 60
251 #define TCP_DEFAULT_MSS 536
254 #define TCP_CMP_SEQ(a, b) ((int32_t) ((a) - (b)))
326 #if defined(__CCRX__)
328 #elif defined(__CWCC__) || defined(_WIN32)
329 #pragma pack(push, 1)
343 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
374 #if defined(__CCRX__)
376 #elif defined(__CWCC__) || defined(_WIN32)
408 #if (TCP_SACK_SUPPORT == ENABLED)
460 uint16_t remotePort);
Retransmission queue item.
#define TCP_MAX_HEADER_LENGTH
uint8_t header[TCP_MAX_HEADER_LENGTH]
error_t tcpReceive(Socket *socket, uint8_t *data, size_t size, size_t *received, uint_t flags)
Receive data from a connected socket.
TcpCongestState
TCP congestion states.
TcpFlags
TCP control flags.
struct _TcpSynQueueItem * next
@ TCP_OPTION_WINDOW_SCALE_FACTOR
TcpOptionKind
TCP option types.
@ TCP_OPTION_SACK_PERMITTED
Structure describing a chunk of data.
error_t tcpListen(Socket *socket, uint_t backlog)
Place a socket in the listening state.
#define TCP_MAX_RX_BUFFER_SIZE
struct _TcpQueueItem * next
TcpState tcpGetState(Socket *socket)
Get the current state of the TCP FSM.
@ TCP_CONGEST_STATE_LOSS_RECOVERY
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
struct _TcpSynQueueItem TcpSynQueueItem
SYN queue item.
error_t tcpAbort(Socket *socket)
Abort an existing TCP connection.
@ TCP_CONGEST_STATE_RECOVERY
uint16_t tcpGetDynamicPort(void)
Get an ephemeral port number.
struct _TcpQueueItem TcpQueueItem
Retransmission queue item.
#define TCP_MAX_TX_BUFFER_SIZE
uint32_t systime_t
System time.
IpPseudoHeader pseudoHeader
IPv4 and IPv6 common routines.
typedef __packed_struct
TCP header.
error_t tcpSetInitialRto(NetInterface *interface, systime_t initialRto)
Set TCP initial retransmission timeout.
error_t tcpInit(void)
TCP related initialization.
error_t tcpConnect(Socket *socket, const IpAddr *remoteIpAddr, uint16_t remotePort)
Establish a TCP connection.
@ TCP_OPTION_MAX_SEGMENT_SIZE
Socket * tcpAccept(Socket *socket, IpAddr *clientIpAddr, uint16_t *clientPort)
Permit an incoming connection attempt on a TCP socket.
error_t tcpShutdown(Socket *socket, uint_t how)
Shutdown gracefully reception, transmission, or both.
Socket * tcpKillOldestConnection(void)
Kill the oldest socket in the TIME-WAIT state.
error_t tcpSend(Socket *socket, const uint8_t *data, size_t length, size_t *written, uint_t flags)
Send data to a connected socket.