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 #include "nx_ipv6.h"
27
28 /**************************************************************************/
29 /* */
30 /* FUNCTION RELEASE */
31 /* */
32 /* _nxe_secure_dtls_session_client_info_get PORTABLE C */
33 /* 6.1 */
34 /* AUTHOR */
35 /* */
36 /* Timothy Stapko, Microsoft Corporation */
37 /* */
38 /* DESCRIPTION */
39 /* */
40 /* This function checks for errors when getting DTLS client info. */
41 /* */
42 /* INPUT */
43 /* */
44 /* dtls_session DTLS session control block */
45 /* client_ip_address Return remote host IP address */
46 /* client_port Return remote host UDP port */
47 /* local_port Return local UDP port */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* status Completion status */
52 /* */
53 /* CALLS */
54 /* */
55 /* _nx_secure_dtls_session_client_info_get */
56 /* Actual function call */
57 /* */
58 /* CALLED BY */
59 /* */
60 /* Application Code */
61 /* */
62 /* RELEASE HISTORY */
63 /* */
64 /* DATE NAME DESCRIPTION */
65 /* */
66 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
67 /* 09-30-2020 Timothy Stapko Modified comment(s), */
68 /* resulting in version 6.1 */
69 /* */
70 /**************************************************************************/
_nxe_secure_dtls_session_client_info_get(NX_SECURE_DTLS_SESSION * dtls_session,NXD_ADDRESS * client_ip_address,UINT * client_port,UINT * local_port)71 UINT _nxe_secure_dtls_session_client_info_get(NX_SECURE_DTLS_SESSION *dtls_session,
72 NXD_ADDRESS *client_ip_address, UINT *client_port, UINT *local_port)
73 {
74 #ifdef NX_SECURE_ENABLE_DTLS
75 NX_UDP_SOCKET *socket_ptr;
76 UINT status;
77
78 /* Check pointers. */
79 if (dtls_session == NX_NULL || client_ip_address == NX_NULL ||
80 client_port == NX_NULL || local_port == NX_NULL)
81 {
82 return(NX_PTR_ERROR);
83 }
84
85 /* Make sure the session is initialized. */
86 if (dtls_session->nx_secure_dtls_tls_session.nx_secure_tls_id != NX_SECURE_TLS_ID)
87 {
88 return(NX_SECURE_TLS_SESSION_UNINITIALIZED);
89 }
90
91 /* Get our UDP socket. */
92 socket_ptr = dtls_session->nx_secure_dtls_udp_socket;
93
94 /* Check UDP socket. */
95 if (socket_ptr == NX_NULL)
96 {
97 return(NX_INVALID_SOCKET);
98 }
99
100 /* Call actual function. */
101 status = _nx_secure_dtls_session_client_info_get(dtls_session, client_ip_address, client_port, local_port);
102
103 return(status);
104 #else
105 NX_PARAMETER_NOT_USED(dtls_session);
106 NX_PARAMETER_NOT_USED(client_ip_address);
107 NX_PARAMETER_NOT_USED(client_port);
108 NX_PARAMETER_NOT_USED(local_port);
109
110 return(NX_NOT_SUPPORTED);
111 #endif /* NX_SECURE_ENABLE_DTLS */
112 }
113
114