1
10
13
14
20
21
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
141
142
143
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_dtls.h"
...
...
UINT _nx_secure_dtls_session_send(NX_SECURE_DTLS_SESSION *dtls_session, NX_PACKET *packet_ptr,
NXD_ADDRESS *ip_address, UINT port)
{
#ifdef NX_SECURE_ENABLE_DTLS
UINT status;
tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == 0)
{
NX_SECURE_MEMCPY(&dtls_session -> nx_secure_dtls_remote_ip_address, ip_address, sizeof(NXD_ADDRESS));
dtls_session -> nx_secure_dtls_local_port = port;
}if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == 0) { ... }
else if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version != ip_address -> nxd_ip_version) ||
(dtls_session -> nx_secure_dtls_remote_port != port))
{
tx_mutex_put(&_nx_secure_tls_protection);
return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
}else if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version != ip_address -> nxd_ip_version) || (dtls_session -> nx_secure_dtls_remote_port != port)) { ... }
else if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4)
{
if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 != ip_address -> nxd_ip_address.v4)
{
tx_mutex_put(&_nx_secure_tls_protection);
return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
}if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 != ip_address -> nxd_ip_address.v4) { ... }
}else if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4) { ... }
#ifdef FEATURE_NX_IPV6
else if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) ||
(dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) ||
(dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) ||
(dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3]))
{
tx_mutex_put(&_nx_secure_tls_protection);
return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
}else if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) || (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) || (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) || (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3])) { ... }
/* ... */#endif
status = _nx_secure_dtls_send_record(dtls_session, packet_ptr, NX_SECURE_TLS_APPLICATION_DATA, NX_WAIT_FOREVER);
tx_mutex_put(&_nx_secure_tls_protection);
return(status);/* ... */
#else
NX_PARAMETER_NOT_USED(dtls_session);
NX_PARAMETER_NOT_USED(packet_ptr);
NX_PARAMETER_NOT_USED(ip_address);
NX_PARAMETER_NOT_USED(port);
return(NX_NOT_SUPPORTED);/* ... */
#endif
}{ ... }