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 /**    Datagram Transport Layer Security (DTLS)                           */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define NX_SECURE_SOURCE_CODE
23 
24 #include "nx_secure_dtls.h"
25 
26 /**************************************************************************/
27 /*                                                                        */
28 /*  FUNCTION                                               RELEASE        */
29 /*                                                                        */
30 /*    _nx_secure_dtls_server_notify_set                   PORTABLE C      */
31 /*                                                           6.1          */
32 /*  AUTHOR                                                                */
33 /*                                                                        */
34 /*    Timothy Stapko, Microsoft Corporation                               */
35 /*                                                                        */
36 /*  DESCRIPTION                                                           */
37 /*                                                                        */
38 /*    This function assigns the optional notification callback routines   */
39 /*    for errors and disconnect events to a DTLS session. These callbacks */
40 /*    can be used to monitor errors (and timeouts) during a DTLS          */
41 /*    handshake and when DTLS connections are closed.                     */
42 /*                                                                        */
43 /*  INPUT                                                                 */
44 /*                                                                        */
45 /*    server_ptr                            DTLS server control block     */
46 /*    disconnect_notify                     DTLS disconnect callback      */
47 /*    error_notify                          DTLS error callback           */
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_dtls_server_notify_set(NX_SECURE_DTLS_SERVER * server_ptr,UINT (* disconnect_notify)(NX_SECURE_DTLS_SESSION * dtls_session),UINT (* error_notify)(NX_SECURE_DTLS_SESSION * dtls_session,UINT error_code))70 UINT _nx_secure_dtls_server_notify_set(NX_SECURE_DTLS_SERVER *server_ptr,
71                                        UINT (*disconnect_notify)(NX_SECURE_DTLS_SESSION *dtls_session),
72                                        UINT (*error_notify)(NX_SECURE_DTLS_SESSION *dtls_session, UINT error_code))
73 
74 
75 {
76 #ifdef NX_SECURE_ENABLE_DTLS
77 
78     /* Assign callbacks. */
79     server_ptr->nx_secure_dtls_disconnect_notify = disconnect_notify;
80     server_ptr->nx_secure_dtls_error_notify = error_notify;
81 
82     return(NX_SUCCESS);
83 #else
84     NX_PARAMETER_NOT_USED(server_ptr);
85     NX_PARAMETER_NOT_USED(disconnect_notify);
86     NX_PARAMETER_NOT_USED(error_notify);
87 
88     return(NX_NOT_SUPPORTED);
89 #endif /* NX_SECURE_ENABLE_DTLS */
90 }
91 
92