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_socket_window_update_notify_set             PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function sets the window update notify function pointer to the */
45 /*    function specified by the application, which is called whenever     */
46 /*    the specified socket receives a packet indicating an increase in    */
47 /*    window size of the remote host.                                     */
48 /*                                                                        */
49 /*    If a NULL pointer is supplied, the window update notify function is */
50 /*    disabled.                                                           */
51 /*                                                                        */
52 /*  INPUT                                                                 */
53 /*                                                                        */
54 /*    socket_ptr                            Pointer to TCP socket         */
55 /*    tcp_window_udpate_notify              Routine to call when NetX     */
56 /*                                            receives a window update    */
57 /*                                                                        */
58 /*  OUTPUT                                                                */
59 /*                                                                        */
60 /*    status                                Completion status             */
61 /*                                                                        */
62 /*  CALLS                                                                 */
63 /*                                                                        */
64 /*    None                                                                */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application Code                                                    */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
75 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_nx_tcp_socket_window_update_notify_set(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_socket_window_update_notify)(NX_TCP_SOCKET * socket_ptr))79 UINT  _nx_tcp_socket_window_update_notify_set(NX_TCP_SOCKET *socket_ptr,
80                                               VOID (*tcp_socket_window_update_notify)(NX_TCP_SOCKET *socket_ptr))
81 {
82 TX_INTERRUPT_SAVE_AREA
83 
84     /* If trace is enabled, insert this event into the trace buffer.  */
85     NX_TRACE_IN_LINE_INSERT(NX_TRACE_TCP_SOCKET_WINDOW_UPDATE_NOTIFY_SET, socket_ptr, 0, 0, 0, NX_TRACE_TCP_EVENTS, 0, 0);
86 
87     /* Get mutex protection.  */
88     tx_mutex_get(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
89 
90     /* Disable interrupts.  */
91     TX_DISABLE
92 
93     /* Setup the receive notify function pointer.  */
94     socket_ptr -> nx_tcp_socket_window_update_notify =  tcp_socket_window_update_notify;
95 
96     /* Restore interrupts.  */
97     TX_RESTORE
98 
99     /* Release protection.  */
100     tx_mutex_put(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection));
101 
102     /* Return successful completion.  */
103     return(NX_SUCCESS);
104 }
105 
106