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 Secure Component                                                 */
17 /**                                                                       */
18 /**    Datagram Transport Layer Security (DTLS)                           */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SECURE_SOURCE_CODE
24 
25 #include "nx_secure_dtls.h"
26 
27 /**************************************************************************/
28 /*                                                                        */
29 /*  FUNCTION                                               RELEASE        */
30 /*                                                                        */
31 /*    _nxe_secure_dtls_server_session_start               PORTABLE C      */
32 /*                                                           6.1          */
33 /*  AUTHOR                                                                */
34 /*                                                                        */
35 /*    Timothy Stapko, Microsoft Corporation                               */
36 /*                                                                        */
37 /*  DESCRIPTION                                                           */
38 /*                                                                        */
39 /*    This function checks for errors in a DTLS server session start call.*/
40 /*                                                                        */
41 /*  INPUT                                                                 */
42 /*                                                                        */
43 /*    dtls_session                          DTLS control block            */
44 /*    wait_option                           Suspension option             */
45 /*                                                                        */
46 /*  OUTPUT                                                                */
47 /*                                                                        */
48 /*    status                                Completion status             */
49 /*                                                                        */
50 /*  CALLS                                                                 */
51 /*                                                                        */
52 /*    _nx_secure_dtls_server_session_start  Start the DTLS session        */
53 /*                                                                        */
54 /*  CALLED BY                                                             */
55 /*                                                                        */
56 /*    Application Code                                                    */
57 /*                                                                        */
58 /*  RELEASE HISTORY                                                       */
59 /*                                                                        */
60 /*    DATE              NAME                      DESCRIPTION             */
61 /*                                                                        */
62 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
63 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
64 /*                                            resulting in version 6.1    */
65 /*                                                                        */
66 /**************************************************************************/
_nxe_secure_dtls_server_session_start(NX_SECURE_DTLS_SESSION * dtls_session,UINT wait_option)67 UINT _nxe_secure_dtls_server_session_start(NX_SECURE_DTLS_SESSION *dtls_session, UINT wait_option)
68 {
69 #ifdef NX_SECURE_ENABLE_DTLS
70 UINT status;
71 
72     /* Check pointers. */
73     if (dtls_session == NX_NULL)
74     {
75         return(NX_PTR_ERROR);
76     }
77 
78     /* This API requires that the UDP socket already be assigned. */
79     if (dtls_session->nx_secure_dtls_udp_socket == NX_NULL ||
80         (!dtls_session -> nx_secure_dtls_session_in_use) ||
81         dtls_session->nx_secure_dtls_tls_session.nx_secure_tls_id != NX_SECURE_TLS_ID)
82     {
83         return(NX_SECURE_TLS_SESSION_UNINITIALIZED);
84     }
85 
86     /* Call actual function. */
87     status = _nx_secure_dtls_server_session_start(dtls_session, wait_option);
88 
89     return(status);
90 #else
91     NX_PARAMETER_NOT_USED(dtls_session);
92     NX_PARAMETER_NOT_USED(wait_option);
93 
94     return(NX_NOT_SUPPORTED);
95 #endif /* NX_SECURE_ENABLE_DTLS */
96 }
97