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 
26 /* Include necessary system files.  */
27 
28 #include "nx_secure_dtls.h"
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _nx_secure_dtls_client_protocol_version_override    PORTABLE C      */
35 /*                                                           6.1          */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Timothy Stapko, Microsoft Corporation                               */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function overrides the DTLS protocol version to use for the    */
43 /*    DTLS session. This allows for a different version of DTLS to be     */
44 /*    utilized even if a newer version is enabled. For example, to use    */
45 /*    DTLSv1.0 for a specific host but use DTLSv1.2 for all other hosts.  */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    dtls_session                          Pointer to DTLS session       */
50 /*    protocol_version                      Version of TLS to use         */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _nx_secure_tls_session_protocol_version_override                    */
59 /*                                          Override TLS protocol version */
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 /**************************************************************************/
_nx_secure_dtls_client_protocol_version_override(NX_SECURE_DTLS_SESSION * dtls_session,USHORT protocol_version)74 UINT _nx_secure_dtls_client_protocol_version_override(NX_SECURE_DTLS_SESSION *dtls_session,
75                                                       USHORT protocol_version)
76 {
77 #ifdef NX_SECURE_ENABLE_DTLS
78 UINT status;
79 
80     status = _nx_secure_tls_session_protocol_version_override(&(dtls_session -> nx_secure_dtls_tls_session), protocol_version);
81 
82     /* Return completion status.  */
83     return(status);
84 #else
85     NX_PARAMETER_NOT_USED(dtls_session);
86     NX_PARAMETER_NOT_USED(protocol_version);
87 
88     return(NX_NOT_SUPPORTED);
89 #endif
90 }
91 
92