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 #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
32 /* Bring in externs for caller checking code.  */
33 
34 NX_CALLER_CHECKING_EXTERNS
35 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
36 
37 
38 /**************************************************************************/
39 /*                                                                        */
40 /*  FUNCTION                                               RELEASE        */
41 /*                                                                        */
42 /*    _nxe_tcp_socket_timed_wait_callback                 PORTABLE C      */
43 /*                                                           6.1          */
44 /*  AUTHOR                                                                */
45 /*                                                                        */
46 /*    Yuxin Zhou, Microsoft Corporation                                   */
47 /*                                                                        */
48 /*  DESCRIPTION                                                           */
49 /*                                                                        */
50 /*    This function performs error checking for the timed wait callback   */
51 /*    service.                                                            */
52 /*                                                                        */
53 /*  INPUT                                                                 */
54 /*                                                                        */
55 /*    socket_ptr                            Pointer to TCP socket         */
56 /*    tcp_timed_wait_callback               Routine to call to start      */
57 /*                                            timed wait before close     */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    status                                Completion status             */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _nx_tcp_socket_timed_wait_callback    Actual timed wait callback    */
66 /*                                            service                     */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
77 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
_nxe_tcp_socket_timed_wait_callback(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_timed_wait_callback)(NX_TCP_SOCKET * socket_ptr))81 UINT  _nxe_tcp_socket_timed_wait_callback(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_timed_wait_callback)(NX_TCP_SOCKET *socket_ptr))
82 {
83 #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
84 
85 UINT status;
86 
87 
88     /* Check for invalid input pointers.  */
89     if ((socket_ptr == NX_NULL) || (socket_ptr -> nx_tcp_socket_id != NX_TCP_ID))
90     {
91         return(NX_PTR_ERROR);
92     }
93 
94     /* Check for invalid input pointers.  */
95     if (tcp_timed_wait_callback == NX_NULL)
96     {
97         return(NX_PTR_ERROR);
98     }
99 
100     /* Check to see if TCP is enabled.  */
101     if (!(socket_ptr -> nx_tcp_socket_ip_ptr) -> nx_ip_tcp_packet_receive)
102     {
103         return(NX_NOT_ENABLED);
104     }
105 
106     /* Check for appropriate caller.  */
107     NX_INIT_AND_THREADS_CALLER_CHECKING
108 
109     /* Call the actual service. */
110     status = _nx_tcp_socket_timed_wait_callback(socket_ptr, tcp_timed_wait_callback);
111 
112     /* Return completion status.  */
113     return(status);
114 
115 #else /* !NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
116     NX_PARAMETER_NOT_USED(socket_ptr);
117     NX_PARAMETER_NOT_USED(tcp_timed_wait_callback);
118 
119     return(NX_NOT_SUPPORTED);
120 
121 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
122 }
123 
124