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 /*    _nx_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 starts a DTLS session for a DTLS server. It is        */
40 /*    intended for use with the DTLS Server API - when a DTLS server      */
41 /*    instance invokes the DTLS connection callback, this function is     */
42 /*    used by the application to kick off the DTLS handshake. It may also */
43 /*    be used for single DTLS sessions but note that the UDP socket must  */
44 /*    be initialized and ready for send/receive operations prior to       */
45 /*    calling this service.                                               */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    dtls_session                          DTLS control block            */
50 /*    wait_option                           Suspension option             */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _nx_secure_dtls_session_start         Start the DTLS session        */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    Application Code                                                    */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
69 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_nx_secure_dtls_server_session_start(NX_SECURE_DTLS_SESSION * dtls_session,UINT wait_option)73 UINT _nx_secure_dtls_server_session_start(NX_SECURE_DTLS_SESSION *dtls_session, UINT wait_option)
74 {
75 #ifdef NX_SECURE_ENABLE_DTLS
76 NX_UDP_SOCKET *udp_socket;
77 UINT status;
78 
79     /* Get socket from the session. */
80     udp_socket = dtls_session->nx_secure_dtls_udp_socket;
81 
82     /* Call shared API. */
83     status = _nx_secure_dtls_session_start(dtls_session, udp_socket, NX_FALSE, wait_option);
84 
85     return(status);
86 #else
87     NX_PARAMETER_NOT_USED(dtls_session);
88     NX_PARAMETER_NOT_USED(wait_option);
89 
90     return(NX_NOT_SUPPORTED);
91 #endif /* NX_SECURE_ENABLE_DTLS */
92 }
93 
94