1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Component                                                        */
17 /**                                                                       */
18 /**   Transmission Control Protocol (TCP)                                 */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  COMPONENT DEFINITION                                   RELEASE        */
27 /*                                                                        */
28 /*    nx_tcp.h                                            PORTABLE C      */
29 /*                                                           6.1.9        */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    Yuxin Zhou, Microsoft Corporation                                   */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*    This file defines the NetX Transmission Control Protocol component, */
37 /*    including all data types and external references.  It is assumed    */
38 /*    that nx_api.h and nx_port.h have already been included.             */
39 /*                                                                        */
40 /*  RELEASE HISTORY                                                       */
41 /*                                                                        */
42 /*    DATE              NAME                      DESCRIPTION             */
43 /*                                                                        */
44 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
45 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
46 /*                                            resulting in version 6.1    */
47 /*  08-02-2021     Yuxin Zhou               Modified comment(s), and      */
48 /*                                            supported TCP/IP offload,   */
49 /*                                            resulting in version 6.1.8  */
50 /*  10-15-2021     Yuxin Zhou               Modified comment(s), included */
51 /*                                            necessary header file,      */
52 /*                                            resulting in version 6.1.9  */
53 /*                                                                        */
54 /**************************************************************************/
55 
56 #ifndef NX_TCP_H
57 #define NX_TCP_H
58 
59 #include "nx_api.h"
60 
61 
62 /* Define TCP constants.  */
63 
64 #define NX_TCP_ID                       ((ULONG)0x54435020)
65 
66 
67 /* Define the TCP header typical size.  */
68 
69 #define NX_TCP_HEADER_SIZE              ((ULONG)0x50000000) /* Typical 5 word TCP header    */
70 #define NX_TCP_SYN_HEADER               ((ULONG)0x70000000) /* SYN header with MSS option   */
71 #define NX_TCP_HEADER_SHIFT             28                  /* Shift down to pickup length  */
72 #define NX_TCP_SYN_OPTION_SIZE          8                   /* 8 bytes of TCP SYN option    */
73 #define NX_TCP_SYN_SIZE                 (NX_TCP_SYN_OPTION_SIZE + sizeof(NX_TCP_HEADER))
74 
75 
76 /* Define the TCP header control fields.  */
77 
78 #define NX_TCP_CONTROL_MASK             ((ULONG)0x00170000) /* ACK, RST, SYN, and FIN bits  */
79 #define NX_TCP_URG_BIT                  ((ULONG)0x00200000) /* Urgent data bit              */
80 #define NX_TCP_ACK_BIT                  ((ULONG)0x00100000) /* Acknowledgement bit          */
81 #define NX_TCP_PSH_BIT                  ((ULONG)0x00080000) /* Push bit                     */
82 #define NX_TCP_RST_BIT                  ((ULONG)0x00040000) /* Reset bit                    */
83 #define NX_TCP_SYN_BIT                  ((ULONG)0x00020000) /* Sequence bit                 */
84 #define NX_TCP_FIN_BIT                  ((ULONG)0x00010000) /* Finish bit                   */
85 
86 
87 /* Define the MSS option for the TCP header.  */
88 
89 #define NX_TCP_MSS_OPTION               ((ULONG)0x02040000) /* Maximum Segment Size option  */
90 #ifdef NX_ENABLE_TCP_WINDOW_SCALING
91 #define NX_TCP_RWIN_OPTION              ((ULONG)0x03030000) /* 24 bits, so NOP, 0x3, 0x3, scale value  */
92 #endif /* NX_ENABLE_TCP_WINDOW_SCALING */
93 #define NX_TCP_MSS_SIZE                 1460                /* Maximum Segment Size         */
94 #define NX_TCP_OPTION_END               ((ULONG)0x01010100) /* NOPs and end of TCP options  */
95 #define NX_TCP_EOL_KIND                 0x00                /* EOL option kind              */
96 #define NX_TCP_NOP_KIND                 0x01                /* NOP option kind              */
97 #define NX_TCP_MSS_KIND                 0x02                /* MSS option kind              */
98 #ifdef NX_ENABLE_TCP_WINDOW_SCALING
99 #define NX_TCP_RWIN_KIND                0x03                /* RWIN option kind             */
100 #endif /* NX_ENABLE_TCP_WINDOW_SCALING */
101 
102 
103 /* Define constants for the optional TCP keepalive Timer.  To enable this
104    feature, the TCP source must be compiled with NX_ENABLE_TCP_KEEPALIVE
105    defined.  */
106 
107 #ifndef NX_TCP_KEEPALIVE_INITIAL
108 #define NX_TCP_KEEPALIVE_INITIAL        7200        /* Number of seconds for initial */
109 #endif                                              /*   keepalive expiration, the   */
110                                                     /*   default is 2 hours (120 min)*/
111 #ifndef NX_TCP_KEEPALIVE_RETRY
112 #define NX_TCP_KEEPALIVE_RETRY          75          /* After initial expiration,     */
113 #endif                                              /*   retry every 75 seconds      */
114 
115 #ifndef NX_TCP_KEEPALIVE_RETRIES
116 #define NX_TCP_KEEPALIVE_RETRIES        10          /* Retry a maximum of 10 times   */
117 #endif
118 
119 #ifndef NX_TCP_MAXIMUM_TX_QUEUE
120 #define NX_TCP_MAXIMUM_TX_QUEUE         20          /* Maximum number of transmit    */
121 #endif                                              /*   packets queued              */
122 
123 #ifndef NX_TCP_MAXIMUM_RETRIES
124 #define NX_TCP_MAXIMUM_RETRIES          10          /* Maximum number of transmit    */
125 #endif                                              /*   retries allowed             */
126 
127 #ifndef NX_TCP_RETRY_SHIFT
128 #define NX_TCP_RETRY_SHIFT              0           /* Shift that is applied to      */
129 #endif                                              /*   last timeout for back off,  */
130                                                     /*   i.e. a value of zero means  */
131                                                     /*   constant timeouts, a value  */
132                                                     /*   of 1 causes each successive */
133                                                     /*   be multiplied by two, etc.  */
134 
135 #ifndef NX_TCP_MAXIMUM_SEGMENT_LIFETIME
136 #define NX_TCP_MAXIMUM_SEGMENT_LIFETIME 120         /* Number of seconds for maximum */
137 #endif                                              /* segment lifetime, the         */
138                                                     /* default is 2 minutes (120s)   */
139 
140 
141 /* Define the maximum receive queue depth for TCP socket. */
142 #ifdef NX_ENABLE_LOW_WATERMARK
143 #ifndef NX_TCP_MAXIMUM_RX_QUEUE
144 #define NX_TCP_MAXIMUM_RX_QUEUE         20
145 #endif /* NX_TCP_MAXIMUM_RX_QUEUE */
146 #endif /* NX_ENABLE_LOW_WATERMARK */
147 
148 /* Define the rate for the TCP fast periodic timer.  This timer is used to process
149    delayed ACKs and packet re-transmission.  Hence, it must have greater resolution
150    than the 200ms delayed ACK requirement.  By default, the fast periodic timer is
151    setup on a 100ms periodic.  The number supplied is used to divide the
152    NX_IP_PERIODIC_RATE value to actually derive the ticks.  Dividing
153    by 10 yields a 100ms base periodic.  */
154 
155 #ifndef NX_TCP_FAST_TIMER_RATE
156 #define NX_TCP_FAST_TIMER_RATE          10
157 #endif
158 
159 
160 /* Define the rate for the TCP delayed ACK timer, which by default is 200ms.  The
161    number supplied is used to divide the NX_IP_PERIODIC_RATE value to
162    actually derive the ticks.  Dividing by 5 yields a 200ms periodic.  */
163 
164 #ifndef NX_TCP_ACK_TIMER_RATE
165 #define NX_TCP_ACK_TIMER_RATE           5
166 #endif
167 
168 /* Define the rate for the TCP retransmit timer, which by default is set to
169    one second.  The number supplied is used to divide the NX_IP_PERIODIC_RATE
170    value to actually derive the ticks.  Dividing by 1 yields a 1 second periodic.  */
171 
172 #ifndef NX_TCP_TRANSMIT_TIMER_RATE
173 #define NX_TCP_TRANSMIT_TIMER_RATE      1
174 #endif
175 
176 /* Define the value of the TCP minimum acceptable MSS for the host to accept the connection,
177    which by default is 128.  */
178 
179 #ifndef NX_TCP_MSS_MINIMUM
180 #define NX_TCP_MSS_MINIMUM              128
181 #endif
182 
183 
184 /* Define Basic TCP packet header data type.  This will be used to
185    build new TCP packets and to examine incoming packets into NetX.  */
186 
187 typedef  struct NX_TCP_HEADER_STRUCT
188 {
189 
190     /* Define the first 32-bit word of the TCP header.  This word contains
191        the following information:
192 
193             bits 31-16  TCP 16-bit source port number
194             bits 15-0   TCP 16-bit destination port number
195      */
196     ULONG nx_tcp_header_word_0;
197 
198     /* Define the second word of the TCP header.  This word contains
199        the following information:
200 
201             bits 31-0   TCP 32-bit sequence number
202      */
203     ULONG nx_tcp_sequence_number;
204 
205     /* Define the third word of the TCP header.  This word contains
206        the following information:
207 
208             bits 31-0   TCP 32-bit acknowledgment number
209      */
210     ULONG nx_tcp_acknowledgment_number;
211 
212     /* Define the fourth 32-bit word of the TCP header.  This word contains
213        the following information:
214 
215             bits 31-28  TCP 4-bit header length
216             bits 27-22  TCP 6-bit reserved field
217             bit  21     TCP Urgent bit (URG)
218             bit  20     TCP Acknowledgement bit (ACK)
219             bit  19     TCP Push bit (PSH)
220             bit  18     TCP Reset connection bit (RST)
221             bit  17     TCP Synchronize sequence numbers bit (SYN)
222             bit  16     TCP Sender has reached the end of its byte stream (FIN)
223             bits 15-0   TCP 16-bit window size
224      */
225     ULONG nx_tcp_header_word_3;
226 
227     /* Define the fifth 32-bit word of the TCP header.  This word contains
228        the following information:
229 
230             bits 31-16  TCP 16-bit TCP checksum
231             bits 15-0   TCP 16-bit TCP urgent pointer
232      */
233     ULONG nx_tcp_header_word_4;
234 } NX_TCP_HEADER;
235 
236 
237 /* Define TCP component API function prototypes.  */
238 
239 UINT _nxd_tcp_client_socket_connect(NX_TCP_SOCKET *socket_ptr, NXD_ADDRESS *server_ip, UINT server_port, ULONG wait_option);
240 UINT _nxd_tcp_socket_peer_info_get(NX_TCP_SOCKET *socket_ptr, NXD_ADDRESS *peer_ip_address, ULONG *peer_port);
241 UINT _nx_tcp_client_socket_bind(NX_TCP_SOCKET *socket_ptr, UINT port, ULONG wait_option);
242 UINT _nx_tcp_client_socket_connect(NX_TCP_SOCKET *socket_ptr, ULONG server_ip, UINT server_port, ULONG wait_option);
243 UINT _nx_tcp_client_socket_port_get(NX_TCP_SOCKET *socket_ptr, UINT *port_ptr);
244 UINT _nx_tcp_client_socket_unbind(NX_TCP_SOCKET *socket_ptr);
245 UINT _nx_tcp_enable(NX_IP *ip_ptr);
246 UINT _nx_tcp_free_port_find(NX_IP *ip_ptr, UINT port, UINT *free_port_ptr);
247 UINT _nx_tcp_info_get(NX_IP *ip_ptr, ULONG *tcp_packets_sent, ULONG *tcp_bytes_sent,
248                       ULONG *tcp_packets_received, ULONG *tcp_bytes_received,
249                       ULONG *tcp_invalid_packets, ULONG *tcp_receive_packets_dropped,
250                       ULONG *tcp_checksum_errors, ULONG *tcp_connections,
251                       ULONG *tcp_disconnections, ULONG *tcp_connections_dropped,
252                       ULONG *tcp_retransmit_packets);
253 UINT _nx_tcp_server_socket_accept(NX_TCP_SOCKET *socket_ptr, ULONG wait_option);
254 UINT _nx_tcp_server_socket_listen(NX_IP *ip_ptr, UINT port, NX_TCP_SOCKET *socket_ptr, UINT listen_queue_size,
255                                   VOID (*tcp_listen_callback)(NX_TCP_SOCKET *socket_ptr, UINT port));
256 UINT _nx_tcp_server_socket_relisten(NX_IP *ip_ptr, UINT port, NX_TCP_SOCKET *socket_ptr);
257 UINT _nx_tcp_server_socket_unaccept(NX_TCP_SOCKET *socket_ptr);
258 UINT _nx_tcp_server_socket_unlisten(NX_IP *ip_ptr, UINT port);
259 UINT _nx_tcp_socket_create(NX_IP *ip_ptr, NX_TCP_SOCKET *socket_ptr, CHAR *name,
260                            ULONG type_of_service, ULONG fragment, UINT time_to_live, ULONG window_size,
261                            VOID (*tcp_urgent_data_callback)(NX_TCP_SOCKET *socket_ptr),
262                            VOID (*tcp_disconnect_callback)(NX_TCP_SOCKET *socket_ptr));
263 UINT _nx_tcp_socket_delete(NX_TCP_SOCKET *socket_ptr);
264 UINT _nx_tcp_socket_disconnect(NX_TCP_SOCKET *socket_ptr, ULONG wait_option);
265 UINT _nx_tcp_socket_info_get(NX_TCP_SOCKET *socket_ptr, ULONG *tcp_packets_sent, ULONG *tcp_bytes_sent,
266                              ULONG *tcp_packets_received, ULONG *tcp_bytes_received,
267                              ULONG *tcp_retransmit_packets, ULONG *tcp_packets_queued,
268                              ULONG *tcp_checksum_errors, ULONG *tcp_socket_state,
269                              ULONG *tcp_transmit_queue_depth, ULONG *tcp_transmit_window,
270                              ULONG *tcp_receive_window);
271 UINT _nx_tcp_socket_mss_get(NX_TCP_SOCKET *socket_ptr, ULONG *mss);
272 UINT _nx_tcp_socket_mss_peer_get(NX_TCP_SOCKET *socket_ptr, ULONG *peer_mss);
273 UINT _nx_tcp_socket_mss_set(NX_TCP_SOCKET *socket_ptr, ULONG mss);
274 UINT _nx_tcp_socket_receive(NX_TCP_SOCKET *socket_ptr, NX_PACKET **packet_ptr, ULONG wait_option);
275 UINT _nx_tcp_socket_receive_notify(NX_TCP_SOCKET *socket_ptr,
276                                    VOID (*tcp_receive_notify)(NX_TCP_SOCKET *socket_ptr));
277 UINT _nx_tcp_socket_window_update_notify_set(NX_TCP_SOCKET *socket_ptr,
278                                              VOID (*tcp_windows_update_notify)(NX_TCP_SOCKET *socket_ptr));
279 UINT _nx_tcp_socket_send(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr, ULONG wait_option);
280 UINT _nx_tcp_socket_send_internal(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr, ULONG wait_option);
281 UINT _nx_tcp_socket_state_wait(NX_TCP_SOCKET *socket_ptr, UINT desired_state, ULONG wait_option);
282 UINT _nx_tcp_socket_transmit_configure(NX_TCP_SOCKET *socket_ptr, ULONG max_queue_depth, ULONG timeout,
283                                        ULONG max_retries, ULONG timeout_shift);
284 UINT _nx_tcp_socket_queue_depth_notify_set(NX_TCP_SOCKET *socket_ptr,  VOID (*tcp_socket_queue_depth_notify)(NX_TCP_SOCKET *socket_ptr));
285 UINT _nx_tcp_socket_establish_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_establish_notify)(NX_TCP_SOCKET *socket_ptr));
286 UINT _nx_tcp_socket_disconnect_complete_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_disconnect_complete_notify)(NX_TCP_SOCKET *socket_ptr));
287 UINT _nx_tcp_socket_timed_wait_callback(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_timed_wait_callback)(NX_TCP_SOCKET *socket_ptr));
288 UINT _nx_tcp_socket_receive_queue_max_set(NX_TCP_SOCKET *socket_ptr, UINT receive_queue_maximum);
289 #ifdef NX_ENABLE_TCPIP_OFFLOAD
290 /* Define the direct TCP packet receive processing. This is used with TCP/IP offload feature.  */
291 VOID _nx_tcp_socket_driver_packet_receive(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr);
292 
293 /* Define the direct TCP established processing.  This is used with TCP/IP offload feature.  */
294 UINT _nx_tcp_socket_driver_establish(NX_TCP_SOCKET *socket_ptr, NX_INTERFACE *interface_ptr, UINT remote_port);
295 UINT _nx_tcp_server_socket_driver_listen(NX_IP *ip_ptr, UINT port, NX_TCP_SOCKET *socket_ptr);
296 #endif /* NX_ENABLE_TCPIP_OFFLOAD */
297 
298 /* Define TCP component internal function prototypes.  */
299 VOID _nx_tcp_cleanup_deferred(TX_THREAD *thread_ptr NX_CLEANUP_PARAMETER);
300 VOID _nx_tcp_client_bind_cleanup(TX_THREAD *thread_ptr NX_CLEANUP_PARAMETER);
301 VOID _nx_tcp_deferred_cleanup_check(NX_IP *ip_ptr);
302 VOID _nx_tcp_fast_periodic_processing(NX_IP *ip_ptr);
303 VOID _nx_tcp_socket_retransmit(NX_IP *ip_ptr, NX_TCP_SOCKET *socket_ptr, UINT need_fast_retransmit);
304 VOID _nx_tcp_connect_cleanup(TX_THREAD *thread_ptr NX_CLEANUP_PARAMETER);
305 VOID _nx_tcp_disconnect_cleanup(TX_THREAD *thread_ptr NX_CLEANUP_PARAMETER);
306 VOID _nx_tcp_initialize(VOID);
307 UINT _nx_tcp_mss_option_get(UCHAR *option_ptr, ULONG option_area_size, ULONG *mss);
308 #ifdef NX_ENABLE_TCP_WINDOW_SCALING
309 UINT _nx_tcp_window_scaling_option_get(UCHAR *option_ptr, ULONG option_area_size, ULONG *window_scale);
310 #endif /* NX_ENABLE_TCP_WINDOW_SCALING */
311 VOID _nx_tcp_no_connection_reset(NX_IP *ip_ptr, NX_PACKET *packet_ptr, NX_TCP_HEADER *tcp_header_ptr);
312 VOID _nx_tcp_packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr);
313 VOID _nx_tcp_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr);
314 VOID _nx_tcp_packet_send_ack(NX_TCP_SOCKET *socket_ptr, ULONG tx_sequence);
315 VOID _nx_tcp_packet_send_fin(NX_TCP_SOCKET *socket_ptr, ULONG tx_sequence);
316 VOID _nx_tcp_packet_send_rst(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *header_ptr);
317 VOID _nx_tcp_packet_send_syn(NX_TCP_SOCKET *socket_ptr, ULONG tx_sequence);
318 VOID _nx_tcp_packet_send_probe(NX_TCP_SOCKET *socket_ptr, ULONG tx_sequence, UCHAR data);
319 VOID _nx_tcp_packet_send_control(NX_TCP_SOCKET *socket_ptr, ULONG control_bits, ULONG tx_sequence,
320                                  ULONG ack_number, ULONG option_word_1, ULONG option_word_2, UCHAR *data);
321 VOID _nx_tcp_periodic_processing(NX_IP *ip_ptr);
322 VOID _nx_tcp_queue_process(NX_IP *ip_ptr);
323 VOID _nx_tcp_receive_cleanup(TX_THREAD *thread_ptr NX_CLEANUP_PARAMETER);
324 UINT _nx_tcp_socket_bytes_available(NX_TCP_SOCKET *socket_ptr, ULONG *bytes_available);
325 VOID _nx_tcp_socket_connection_reset(NX_TCP_SOCKET *socket_ptr);
326 VOID _nx_tcp_socket_packet_process(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr);
327 UINT _nx_tcp_socket_peer_info_get(NX_TCP_SOCKET *socket_ptr, ULONG *peer_ip_address, ULONG *peer_port);
328 
329 VOID _nx_tcp_socket_receive_queue_flush(NX_TCP_SOCKET *socket_ptr);
330 UINT _nx_tcp_socket_state_ack_check(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tcp_header_ptr);
331 VOID _nx_tcp_socket_state_closing(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tcp_header_ptr);
332 UINT _nx_tcp_socket_state_data_check(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr);
333 VOID _nx_tcp_socket_state_data_trim_front(NX_PACKET *packet_ptr, ULONG amount);
334 VOID _nx_tcp_socket_state_data_trim(NX_PACKET *packet_ptr, ULONG amount);
335 VOID _nx_tcp_socket_state_established(NX_TCP_SOCKET *socket_ptr);
336 VOID _nx_tcp_socket_state_fin_wait1(NX_TCP_SOCKET *socket_ptr);
337 VOID _nx_tcp_socket_state_fin_wait2(NX_TCP_SOCKET *socket_ptr);
338 VOID _nx_tcp_socket_state_last_ack(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tcp_header_ptr);
339 VOID _nx_tcp_socket_state_syn_sent(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tcp_header_ptr, NX_PACKET *packet_ptr);
340 VOID _nx_tcp_socket_state_syn_received(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tcp_header_ptr);
341 VOID _nx_tcp_socket_state_transmit_check(NX_TCP_SOCKET *socket_ptr);
342 VOID _nx_tcp_socket_thread_resume(TX_THREAD **suspension_list_head, UINT status);
343 VOID _nx_tcp_socket_thread_suspend(TX_THREAD **suspension_list_head, VOID (*suspend_cleanup)(TX_THREAD * NX_CLEANUP_PARAMETER), NX_TCP_SOCKET *socket_ptr, TX_MUTEX *mutex_ptr, ULONG wait_option);
344 VOID _nx_tcp_socket_transmit_queue_flush(NX_TCP_SOCKET *socket_ptr);
345 VOID _nx_tcp_socket_block_cleanup(NX_TCP_SOCKET *socket_ptr);
346 VOID _nx_tcp_transmit_cleanup(TX_THREAD *thread_ptr NX_CLEANUP_PARAMETER);
347 
348 
349 /* Define error checking shells for TCP API services.  These are only referenced by the
350    application.  */
351 
352 UINT _nxde_tcp_client_socket_connect(NX_TCP_SOCKET *socket_ptr, NXD_ADDRESS *server_ip, UINT server_port, ULONG wait_option);
353 UINT _nxde_tcp_socket_peer_info_get(NX_TCP_SOCKET *socket_ptr, NXD_ADDRESS *peer_ip_address, ULONG *peer_port);
354 UINT _nxe_tcp_client_socket_bind(NX_TCP_SOCKET *socket_ptr, UINT port, ULONG wait_option);
355 UINT _nxe_tcp_client_socket_connect(NX_TCP_SOCKET *socket_ptr, ULONG server_ip, UINT server_port, ULONG wait_option);
356 UINT _nxe_tcp_client_socket_port_get(NX_TCP_SOCKET *socket_ptr, UINT *port_ptr);
357 UINT _nxe_tcp_client_socket_unbind(NX_TCP_SOCKET *socket_ptr);
358 UINT _nxe_tcp_enable(NX_IP *ip_ptr);
359 UINT _nxe_tcp_free_port_find(NX_IP *ip_ptr, UINT port, UINT *free_port_ptr);
360 UINT _nxe_tcp_info_get(NX_IP *ip_ptr, ULONG *tcp_packets_sent, ULONG *tcp_bytes_sent,
361                        ULONG *tcp_packets_received, ULONG *tcp_bytes_received,
362                        ULONG *tcp_invalid_packets, ULONG *tcp_receive_packets_dropped,
363                        ULONG *tcp_checksum_errors, ULONG *tcp_connections,
364                        ULONG *tcp_disconnections, ULONG *tcp_connections_dropped,
365                        ULONG *tcp_retransmit_packets);
366 UINT _nxe_tcp_server_socket_accept(NX_TCP_SOCKET *socket_ptr, ULONG wait_option);
367 UINT _nxe_tcp_server_socket_listen(NX_IP *ip_ptr, UINT port, NX_TCP_SOCKET *socket_ptr, UINT listen_queue_size,
368                                    VOID (*tcp_listen_callback)(NX_TCP_SOCKET *socket_ptr, UINT port));
369 UINT _nxe_tcp_server_socket_relisten(NX_IP *ip_ptr, UINT port, NX_TCP_SOCKET *socket_ptr);
370 UINT _nxe_tcp_server_socket_unaccept(NX_TCP_SOCKET *socket_ptr);
371 UINT _nxe_tcp_server_socket_unlisten(NX_IP *ip_ptr, UINT port);
372 UINT _nxe_tcp_socket_bytes_available(NX_TCP_SOCKET *socket_ptr, ULONG *bytes_available);
373 UINT _nxe_tcp_socket_create(NX_IP *ip_ptr, NX_TCP_SOCKET *socket_ptr, CHAR *name,
374                             ULONG type_of_service, ULONG fragment, UINT time_to_live, ULONG window_size,
375                             VOID (*tcp_urgent_data_callback)(NX_TCP_SOCKET *socket_ptr),
376                             VOID (*tcp_disconnect_callback)(NX_TCP_SOCKET *socket_ptr),
377                             UINT tcp_socket_size);
378 UINT _nxe_tcp_socket_delete(NX_TCP_SOCKET *socket_ptr);
379 UINT _nxe_tcp_socket_disconnect(NX_TCP_SOCKET *socket_ptr, ULONG wait_option);
380 UINT _nxe_tcp_socket_info_get(NX_TCP_SOCKET *socket_ptr, ULONG *tcp_packets_sent, ULONG *tcp_bytes_sent,
381                               ULONG *tcp_packets_received, ULONG *tcp_bytes_received,
382                               ULONG *tcp_retransmit_packets, ULONG *tcp_packets_queued,
383                               ULONG *tcp_checksum_errors, ULONG *tcp_socket_state,
384                               ULONG *tcp_transmit_queue_depth, ULONG *tcp_transmit_window,
385                               ULONG *tcp_receive_window);
386 UINT _nxe_tcp_socket_mss_get(NX_TCP_SOCKET *socket_ptr, ULONG *mss);
387 UINT _nxe_tcp_socket_mss_peer_get(NX_TCP_SOCKET *socket_ptr, ULONG *peer_mss);
388 UINT _nxe_tcp_socket_mss_set(NX_TCP_SOCKET *socket_ptr, ULONG mss);
389 UINT _nxe_tcp_socket_peer_info_get(NX_TCP_SOCKET *socket_ptr, ULONG *peer_ip_address, ULONG *peer_port);
390 UINT _nxe_tcp_socket_receive(NX_TCP_SOCKET *socket_ptr, NX_PACKET **packet_ptr, ULONG wait_option);
391 UINT _nxe_tcp_socket_receive_notify(NX_TCP_SOCKET *socket_ptr,
392                                     VOID (*tcp_receive_notify)(NX_TCP_SOCKET *socket_ptr));
393 UINT _nxe_tcp_socket_send(NX_TCP_SOCKET *socket_ptr, NX_PACKET **packet_ptr_ptr, ULONG wait_option);
394 UINT _nxe_tcp_socket_state_wait(NX_TCP_SOCKET *socket_ptr, UINT desired_state, ULONG wait_option);
395 UINT _nxe_tcp_socket_transmit_configure(NX_TCP_SOCKET *socket_ptr, ULONG max_queue_depth, ULONG timeout,
396                                         ULONG max_retries, ULONG timeout_shift);
397 UINT _nxe_tcp_socket_window_update_notify_set(NX_TCP_SOCKET *socket_ptr,
398                                               VOID (*tcp_socket_window_update_notify)(NX_TCP_SOCKET *socket_ptr));
399 UINT _nxe_tcp_socket_receive_queue_max_set(NX_TCP_SOCKET *socket_ptr, UINT receive_queue_maximum);
400 UINT _nxe_tcp_socket_establish_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_establish_notify)(NX_TCP_SOCKET *socket_ptr));
401 UINT _nxe_tcp_socket_disconnect_complete_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_disconnect_complete_notify)(NX_TCP_SOCKET *socket_ptr));
402 UINT _nxe_tcp_socket_queue_depth_notify_set(NX_TCP_SOCKET *socket_ptr,  VOID (*tcp_socket_queue_depth_notify)(NX_TCP_SOCKET *socket_ptr));
403 UINT _nxe_tcp_socket_timed_wait_callback(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_timed_wait_callback)(NX_TCP_SOCKET *socket_ptr));
404 
405 
406 /* TCP component data declarations follow.  */
407 
408 /* Determine if the initialization function of this component is including
409    this file.  If so, make the data definitions really happen.  Otherwise,
410    make them extern so other functions in the component can access them.  */
411 
412 /*lint -e767 suppress different definitions.  */
413 #ifdef NX_TCP_INIT
414 #define TCP_DECLARE
415 #else
416 #define TCP_DECLARE extern
417 #endif
418 /*lint +e767 enable checking for different definitions.  */
419 
420 /* Define global data for the TCP component.  */
421 
422 /* Define the actual number of ticks for the fast periodic timer.  */
423 
424 TCP_DECLARE ULONG           _nx_tcp_fast_timer_rate;
425 
426 /* Define the actual number of ticks for the delayed ACK timer.  */
427 
428 TCP_DECLARE ULONG           _nx_tcp_ack_timer_rate;
429 
430 /* Define the actual number of ticks for the retransmit timer.  */
431 
432 TCP_DECLARE ULONG           _nx_tcp_transmit_timer_rate;
433 
434 /* Define the actual number of ticks for the 2MSL(Maximum Segment Lifetime) timer.  */
435 
436 TCP_DECLARE ULONG           _nx_tcp_2MSL_timer_rate;
437 
438 
439 #endif
440 
441