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 Secure Component                                                 */
16 /**                                                                       */
17 /**    Transport Layer Security (TLS)                                     */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SECURE_SOURCE_CODE
23 
24 
25 #include "nx_secure_tls.h"
26 
27 /**************************************************************************/
28 /*                                                                        */
29 /*  FUNCTION                                               RELEASE        */
30 /*                                                                        */
31 /*    _nx_secure_tls_session_server_callback_set          PORTABLE C      */
32 /*                                                           6.1          */
33 /*  AUTHOR                                                                */
34 /*                                                                        */
35 /*    Timothy Stapko, Microsoft Corporation                               */
36 /*                                                                        */
37 /*  DESCRIPTION                                                           */
38 /*                                                                        */
39 /*    This function sets up a callback function pointer that TLS will     */
40 /*    invoke when the TLS server receives a ClientHello message from the  */
41 /*    remote host. The callback allows the application to handle any TLS  */
42 /*    extensions that might require additional input or decision making.  */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    tls_session                           TLS control block             */
47 /*    func_ptr                              Pointer to callback function  */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    status                                Completion status             */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    Application Code                                                    */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
66 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
67 /*                                            resulting in version 6.1    */
68 /*                                                                        */
69 /**************************************************************************/
_nx_secure_tls_session_server_callback_set(NX_SECURE_TLS_SESSION * tls_session,ULONG (* func_ptr)(NX_SECURE_TLS_SESSION * tls_session,NX_SECURE_TLS_HELLO_EXTENSION * extensions,UINT num_extensions))70 UINT _nx_secure_tls_session_server_callback_set(NX_SECURE_TLS_SESSION *tls_session,
71                                                 ULONG (*func_ptr)(NX_SECURE_TLS_SESSION *tls_session,
72                                                                   NX_SECURE_TLS_HELLO_EXTENSION *extensions,
73                                                                   UINT num_extensions))
74 {
75     /* Set the function pointer in the TLS session. */
76     tls_session -> nx_secure_tls_session_server_callback = func_ptr;
77 
78     return(NX_SUCCESS);
79 }
80 
81