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_timed_wait_callback                  PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function sets the timed wait callback function pointer         */
45 /*    to the function specified by the application, which is called when  */
46 /*    it is time to start the timed wait state before a socket can be set */
47 /*    to the closed or listen state.                                      */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    socket_ptr                            Pointer to TCP socket         */
52 /*    tcp_timed_wait_callback               Routine to call to start      */
53 /*                                            timed wait before close     */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    status                                Completion status             */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*    None                                                                */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    Application Code                                                    */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
72 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_nx_tcp_socket_timed_wait_callback(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_timed_wait_callback)(NX_TCP_SOCKET * socket_ptr))76 UINT  _nx_tcp_socket_timed_wait_callback(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_timed_wait_callback)(NX_TCP_SOCKET *socket_ptr))
77 {
78 #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
79 
80 TX_INTERRUPT_SAVE_AREA
81 
82     /* Get mutex protection.  */
83     tx_mutex_get(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
84 
85     /* Disable interrupts.  */
86     TX_DISABLE
87 
88     /* Setup the establish notify function pointer.  */
89     socket_ptr -> nx_tcp_timed_wait_callback =  tcp_timed_wait_callback;
90 
91     /* Restore interrupts.  */
92     TX_RESTORE
93 
94     /* Release protection.  */
95     tx_mutex_put(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection));
96 
97     /* Return successful completion.  */
98     return(NX_SUCCESS);
99 
100 #else /* !NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
101     NX_PARAMETER_NOT_USED(socket_ptr);
102     NX_PARAMETER_NOT_USED(tcp_timed_wait_callback);
103 
104     return(NX_NOT_SUPPORTED);
105 
106 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
107 }
108 
109