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 #define NX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "nx_api.h"
29 #include "nx_tcp.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nx_tcp_packet_send_ack                             PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function sends an ACK from the specified socket.               */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    socket_ptr                            Pointer to socket             */
49 /*    tx_sequence                           Transmit sequence number      */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _nx_tcp_packet_send_control           Send TCP control packet       */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    _nx_tcp_fast_periodic_processing      Delayed ACK processing        */
62 /*    _nx_tcp_periodic_processing           Regular periodic processing   */
63 /*    _nx_tcp_socket_receive                Packet receive processing     */
64 /*    _nx_tcp_socket_state_ack_check        Socket state ACK processing   */
65 /*    _nx_tcp_socket_state_data_check       Socket state date processing  */
66 /*    _nx_tcp_socket_state_established      Socket state established      */
67 /*                                            processing                  */
68 /*    _nx_tcp_socket_state_fin_wait2        Socket state FIN wait-2       */
69 /*                                            processing                  */
70 /*    _nx_tcp_socket_state_fin_wait1        Socket state FIN wait         */
71 /*                                            processing                  */
72 /*    _nx_tcp_socket_state_syn_sent         Socket state SYN sent         */
73 /*                                            processing                  */
74 /*                                                                        */
75 /*  RELEASE HISTORY                                                       */
76 /*                                                                        */
77 /*    DATE              NAME                      DESCRIPTION             */
78 /*                                                                        */
79 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
80 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
81 /*                                            resulting in version 6.1    */
82 /*                                                                        */
83 /**************************************************************************/
_nx_tcp_packet_send_ack(NX_TCP_SOCKET * socket_ptr,ULONG tx_sequence)84 VOID  _nx_tcp_packet_send_ack(NX_TCP_SOCKET *socket_ptr, ULONG tx_sequence)
85 {
86     _nx_tcp_packet_send_control(socket_ptr, NX_TCP_ACK_BIT, tx_sequence,
87                                 socket_ptr -> nx_tcp_socket_rx_sequence, 0, 0, NX_NULL);
88 
89     /* Setup a new delayed ACK timeout.  */
90     socket_ptr -> nx_tcp_socket_delayed_ack_timeout =  _nx_tcp_ack_timer_rate;
91 }
92 
93