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_establish_notify                     PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function sets the establish notify function pointer to the     */
45 /*    function specified by the application, which is called when the     */
46 /*    handshake connection with the remote TCP host is complete. If a     */
47 /*    NULL pointer is supplied, the establish notify function is disabled.*/
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    socket_ptr                            Pointer to TCP socket         */
52 /*    tcp_establish_notify                  Routine to call when the      */
53 /*                                            connection handshake is     */
54 /*                                            complete socket             */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    status                                Completion status             */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*    None                                                                */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    Application Code                                                    */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
73 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_nx_tcp_socket_establish_notify(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_establish_notify)(NX_TCP_SOCKET * socket_ptr))77 UINT  _nx_tcp_socket_establish_notify(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_establish_notify)(NX_TCP_SOCKET *socket_ptr))
78 {
79 #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
80 
81 TX_INTERRUPT_SAVE_AREA
82 
83 
84     /* Disable interrupts.  */
85     TX_DISABLE
86 
87     /* Setup the establish notify function pointer.  */
88     socket_ptr -> nx_tcp_establish_notify =  tcp_establish_notify;
89 
90     /* Restore interrupts.  */
91     TX_RESTORE
92 
93     /* Return successful completion.  */
94     return(NX_SUCCESS);
95 
96 #else /* !NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
97     NX_PARAMETER_NOT_USED(socket_ptr);
98     NX_PARAMETER_NOT_USED(tcp_establish_notify);
99 
100     return(NX_NOT_SUPPORTED);
101 
102 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */
103 }
104 
105