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_disconnect_complete_notify           PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function sets the disconnect complete notify function pointer  */
45 /*    with the function specified by the application, which is called     */
46 /*    when disconnect operation is complete. If a NULL pointer is         */
47 /*    supplied, the disconnect complete notify feature is disabled.       */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    socket_ptr                            Pointer to TCP socket         */
52 /*    tcp_disconnect_complete_notify        Routine to call when the      */
53 /*                                            disconnect is complete      */
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_disconnect_complete_notify(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_disconnect_complete_notify)(NX_TCP_SOCKET * socket_ptr))76 UINT  _nx_tcp_socket_disconnect_complete_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_disconnect_complete_notify)(NX_TCP_SOCKET *socket_ptr))
77 {
78 #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
79 
80 TX_INTERRUPT_SAVE_AREA
81 
82 
83     /* Disable interrupts.  */
84     TX_DISABLE
85 
86     /* Setup the establish notify function pointer.  */
87     socket_ptr -> nx_tcp_disconnect_complete_notify =  tcp_disconnect_complete_notify;
88 
89     /* Restore interrupts.  */
90     TX_RESTORE
91 
92     /* Return successful completion.  */
93     return(NX_SUCCESS);
94 
95 #else /* !NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
96     NX_PARAMETER_NOT_USED(socket_ptr);
97     NX_PARAMETER_NOT_USED(tcp_disconnect_complete_notify);
98 
99     return(NX_NOT_SUPPORTED);
100 
101 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
102 }
103 
104