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_establish_notify                     PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Yuxin Zhou, Microsoft Corporation                                   */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function sets the establish notify function pointer to the     */
44 /*    function specified by the application, which is called when the     */
45 /*    handshake connection with the remote TCP host is complete. If a     */
46 /*    NULL pointer is supplied, the establish notify function is disabled.*/
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    socket_ptr                            Pointer to TCP socket         */
51 /*    tcp_establish_notify                  Routine to call when the      */
52 /*                                            connection handshake is     */
53 /*                                            complete socket             */
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_establish_notify(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_establish_notify)(NX_TCP_SOCKET * socket_ptr))76 UINT  _nx_tcp_socket_establish_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_establish_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_establish_notify =  tcp_establish_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_establish_notify);
98 
99     return(NX_NOT_SUPPORTED);
100 
101 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
102 }
103 
104