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
85
86
87
88
89
96
101
102
104
105
106
107
113
114
115
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls.h"
...
...
UINT _nx_secure_tls_session_end(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option)
{
UINT status;
UINT error_return;
UINT send_close_notify;
NX_PACKET *send_packet;
NX_PACKET *tmp_ptr;
tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
while (tls_session -> nx_secure_record_queue_header)
{
tmp_ptr = tls_session -> nx_secure_record_queue_header;
tls_session -> nx_secure_record_queue_header = tmp_ptr -> nx_packet_queue_next;
tmp_ptr -> nx_packet_queue_next = NX_NULL;
nx_secure_tls_packet_release(tmp_ptr);
}while (tls_session -> nx_secure_record_queue_header) { ... }
if (tls_session -> nx_secure_record_decrypted_packet)
{
nx_secure_tls_packet_release(tls_session -> nx_secure_record_decrypted_packet);
tls_session -> nx_secure_record_decrypted_packet = NX_NULL;
}if (tls_session -> nx_secure_record_decrypted_packet) { ... }
/* ... */
send_close_notify = 0;
#ifndef NX_SECURE_TLS_SERVER_DISABLED
if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER)
{
send_close_notify = tls_session -> nx_secure_tls_server_state == NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED;
}if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER) { ... }
/* ... */#endif
#ifndef NX_SECURE_TLS_CLIENT_DISABLED
if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_CLIENT)
{
send_close_notify = tls_session -> nx_secure_tls_client_state == NX_SECURE_TLS_CLIENT_STATE_HANDSHAKE_FINISHED;
}if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_CLIENT) { ... }
/* ... */#endif
if (send_close_notify)
{
tx_mutex_put(&_nx_secure_tls_protection);
status = _nx_secure_tls_packet_allocate(tls_session, tls_session -> nx_secure_tls_packet_pool, &send_packet, wait_option);
if (status != NX_SUCCESS)
{
error_return = status;
status = _nx_secure_tls_session_reset(tls_session);
if(status != NX_SUCCESS)
{
return(status);
}if (status != NX_SUCCESS) { ... }
return(error_return);
}if (status != NX_SUCCESS) { ... }
tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
_nx_secure_tls_send_alert(tls_session, send_packet, NX_SECURE_TLS_ALERT_CLOSE_NOTIFY, NX_SECURE_TLS_ALERT_LEVEL_WARNING);
status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
if (status)
{
nx_secure_tls_packet_release(send_packet);
tx_mutex_put(&_nx_secure_tls_protection);
error_return = status;
status = _nx_secure_tls_session_reset(tls_session);
if(status != NX_SUCCESS)
{
return(status);
}if (status != NX_SUCCESS) { ... }
return(error_return);
}if (status) { ... }
}if (send_close_notify) { ... }
tx_mutex_put(&_nx_secure_tls_protection);
status = _nx_secure_tls_session_reset(tls_session);
return(status);
}{ ... }