1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   Transmission Control Protocol (TCP)                                 */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "nx_api.h"
28 #include "nx_tcp.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _nx_tcp_socket_disconnect_complete_notify           PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Yuxin Zhou, Microsoft Corporation                                   */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function sets the disconnect complete notify function pointer  */
44 /*    with the function specified by the application, which is called     */
45 /*    when disconnect operation is complete. If a NULL pointer is         */
46 /*    supplied, the disconnect complete notify feature is disabled.       */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    socket_ptr                            Pointer to TCP socket         */
51 /*    tcp_disconnect_complete_notify        Routine to call when the      */
52 /*                                            disconnect is complete      */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Completion status             */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    None                                                                */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Application Code                                                    */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
71 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*                                                                        */
74 /**************************************************************************/
_nx_tcp_socket_disconnect_complete_notify(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_disconnect_complete_notify)(NX_TCP_SOCKET * socket_ptr))75 UINT  _nx_tcp_socket_disconnect_complete_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_disconnect_complete_notify)(NX_TCP_SOCKET *socket_ptr))
76 {
77 #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
78 
79 TX_INTERRUPT_SAVE_AREA
80 
81 
82     /* Disable interrupts.  */
83     TX_DISABLE
84 
85     /* Setup the establish notify function pointer.  */
86     socket_ptr -> nx_tcp_disconnect_complete_notify =  tcp_disconnect_complete_notify;
87 
88     /* Restore interrupts.  */
89     TX_RESTORE
90 
91     /* Return successful completion.  */
92     return(NX_SUCCESS);
93 
94 #else /* !NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
95     NX_PARAMETER_NOT_USED(socket_ptr);
96     NX_PARAMETER_NOT_USED(tcp_disconnect_complete_notify);
97 
98     return(NX_NOT_SUPPORTED);
99 
100 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
101 }
102 
103