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 
25 /* Include necessary system files.  */
26 
27 #include "nx_secure_dtls.h"
28 
29 /* Bring in externs for caller checking code.  */
30 
31 NX_SECURE_CALLER_CHECKING_EXTERNS
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _nxe_secure_dtls_session_end                        PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Timothy Stapko, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function checks for errors in the DTLS session end call.       */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    dtls_session                          DTLS session control block    */
50 /*    wait_option                           Indicates how long the caller */
51 /*                                          should wait for the response  */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Completion status             */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    _nx_secure_dtls_session_end           Actual DTLS session end call. */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
70 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_nxe_secure_dtls_session_end(NX_SECURE_DTLS_SESSION * dtls_session,UINT wait_option)74 UINT _nxe_secure_dtls_session_end(NX_SECURE_DTLS_SESSION *dtls_session, UINT wait_option)
75 {
76 #ifdef NX_SECURE_ENABLE_DTLS
77 UINT status;
78 
79     if (dtls_session == NX_NULL)
80     {
81         return(NX_PTR_ERROR);
82     }
83 
84     /* Make sure the session is initialized. */
85     if (dtls_session->nx_secure_dtls_tls_session.nx_secure_tls_id != NX_SECURE_TLS_ID ||
86         !dtls_session -> nx_secure_dtls_session_in_use)
87     {
88         return(NX_SECURE_TLS_SESSION_UNINITIALIZED);
89     }
90 
91     status =  _nx_secure_dtls_session_end(dtls_session, wait_option);
92 
93     /* Return completion status.  */
94     return(status);
95 #else
96     NX_PARAMETER_NOT_USED(dtls_session);
97     NX_PARAMETER_NOT_USED(wait_option);
98 
99     return(NX_NOT_SUPPORTED);
100 #endif /* NX_SECURE_ENABLE_DTLS */
101 }
102 
103