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
92
96
97
98
99
100
104
105
106
107
114
115
116
117
118
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
150
151
152
154
155
156
157
158
159
160
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls.h"
...
...
UINT _nx_secure_tls_packet_allocate(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET_POOL *pool_ptr,
NX_PACKET **packet_ptr, ULONG wait_option)
{
UINT status;
ULONG packet_type;
USHORT iv_size;
if (tls_session -> nx_secure_tls_tcp_socket -> nx_tcp_socket_connect_ip.nxd_ip_version == NX_IP_VERSION_V4)
{
packet_type = NX_IPv4_TCP_PACKET;
}if (tls_session -> nx_secure_tls_tcp_socket -> nx_tcp_socket_connect_ip.nxd_ip_version == NX_IP_VERSION_V4) { ... }
else
{
packet_type = NX_IPv6_TCP_PACKET;
}else { ... }
status = nx_packet_allocate(pool_ptr, packet_ptr, packet_type, wait_option);
if (status != NX_SUCCESS)
{
return(status);
}if (status != NX_SUCCESS) { ... }
if (((ULONG)((*packet_ptr) -> nx_packet_data_end) - (ULONG)((*packet_ptr) -> nx_packet_prepend_ptr)) <
(NX_SECURE_TLS_RECORD_HEADER_SIZE + 2u))
{
nx_packet_release(*packet_ptr);
*packet_ptr = NX_NULL;
return(NX_SECURE_TLS_PACKET_BUFFER_TOO_SMALL);
...}
(*packet_ptr) -> nx_packet_prepend_ptr += NX_SECURE_TLS_RECORD_HEADER_SIZE;
/* ... */
if (tls_session -> nx_secure_tls_local_session_active)
{
status = _nx_secure_tls_session_iv_size_get(tls_session, &iv_size);
if (status != NX_SUCCESS)
{
nx_packet_release(*packet_ptr);
*packet_ptr = NX_NULL;
return(status);
}if (status != NX_SUCCESS) { ... }
if ((iv_size + 2u) > ((ULONG)((*packet_ptr) -> nx_packet_data_end) - (ULONG)((*packet_ptr) -> nx_packet_prepend_ptr)))
{
nx_packet_release(*packet_ptr);
*packet_ptr = NX_NULL;
return(NX_SECURE_TLS_PACKET_BUFFER_TOO_SMALL);
}if ((iv_size + 2u) > ((ULONG)((*packet_ptr) -> nx_packet_data_end) - (ULONG)((*packet_ptr) -> nx_packet_prepend_ptr))) { ... }
if (iv_size > 0)
{
NX_SECURE_MEMSET((*packet_ptr) -> nx_packet_prepend_ptr, 0, iv_size);
(*packet_ptr) -> nx_packet_prepend_ptr += iv_size;
}if (iv_size > 0) { ... }
}if (tls_session -> nx_secure_tls_local_session_active) { ... }
/* ... */
(*packet_ptr) -> nx_packet_append_ptr = (*packet_ptr) -> nx_packet_prepend_ptr;
(*packet_ptr) -> nx_packet_length = 0;
return(NX_SECURE_TLS_SUCCESS);
}{ ... }