1
10
13
14
20
21
22
23
24
25
26
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
86
87
88
89
90
91
92
93
97
98
99
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
133
134
136
140
141
142
143
144
145
146
147
148
149
150
151
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
172
173
174
175
176
180
181
184
185
186
187
188
189
190
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_packet.h"
...
...
UINT _nx_packet_data_adjust(NX_PACKET *packet_ptr, ULONG header_size)
{
ULONG available_size;
ULONG shift_size;
#ifndef NX_DISABLE_PACKET_CHAIN
UINT status;
ULONG append_size;
UCHAR *data_start;
NX_PACKET *work_ptr;/* ... */
#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
if (((ALIGN_TYPE)packet_ptr -> nx_packet_data_end - (ALIGN_TYPE)packet_ptr -> nx_packet_data_start) < header_size)
{
return(NX_UNDERFLOW);
}if (((ALIGN_TYPE)packet_ptr -> nx_packet_data_end - (ALIGN_TYPE)packet_ptr -> nx_packet_data_start) < header_size) { ... }
if (((ALIGN_TYPE)packet_ptr -> nx_packet_prepend_ptr - (ALIGN_TYPE)packet_ptr -> nx_packet_data_start) >= header_size)
{
return(NX_SUCCESS);
}if (((ALIGN_TYPE)packet_ptr -> nx_packet_prepend_ptr - (ALIGN_TYPE)packet_ptr -> nx_packet_data_start) >= header_size) { ... }
available_size = (ULONG)(((ALIGN_TYPE)packet_ptr -> nx_packet_prepend_ptr - (ALIGN_TYPE)packet_ptr -> nx_packet_data_start) +
((ALIGN_TYPE)packet_ptr -> nx_packet_data_end - (ALIGN_TYPE)packet_ptr -> nx_packet_append_ptr));
if (available_size >= header_size)
{
shift_size = (ULONG)((ALIGN_TYPE)packet_ptr -> nx_packet_append_ptr - (ALIGN_TYPE)packet_ptr -> nx_packet_prepend_ptr);
memmove(packet_ptr -> nx_packet_data_start + header_size, packet_ptr -> nx_packet_prepend_ptr, shift_size);
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_data_start + header_size;
packet_ptr -> nx_packet_append_ptr = packet_ptr -> nx_packet_prepend_ptr + shift_size;
}if (available_size >= header_size) { ... }
else
{
#ifndef NX_DISABLE_PACKET_CHAIN
/* ... */
/* ... */
if (header_size & 1)
{
return(NX_NOT_SUPPORTED);
}if (header_size & 1) { ... }
append_size = header_size - available_size;
data_start = packet_ptr -> nx_packet_append_ptr - append_size;
status = _nx_packet_allocate(packet_ptr -> nx_packet_pool_owner, &work_ptr, 0, NX_NO_WAIT);
if (status)
{
return(status);
}if (status) { ... }
memcpy(work_ptr -> nx_packet_prepend_ptr, data_start, append_size);
work_ptr -> nx_packet_append_ptr = (UCHAR *)((ALIGN_TYPE)work_ptr -> nx_packet_prepend_ptr + append_size);
shift_size = (ULONG)(((ALIGN_TYPE)packet_ptr -> nx_packet_append_ptr - (ALIGN_TYPE)packet_ptr -> nx_packet_prepend_ptr) - append_size);
memmove(packet_ptr -> nx_packet_data_start + header_size, packet_ptr -> nx_packet_prepend_ptr, shift_size);
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_data_start + header_size;
packet_ptr -> nx_packet_append_ptr = packet_ptr -> nx_packet_prepend_ptr + shift_size;
/* ... */
work_ptr -> nx_packet_next = packet_ptr -> nx_packet_next;
packet_ptr -> nx_packet_next = work_ptr;
if (packet_ptr -> nx_packet_last == NX_NULL)
{
packet_ptr -> nx_packet_last = work_ptr;
}if (packet_ptr -> nx_packet_last == NX_NULL) { ... }
/* ... */#else
return(NX_UNDERFLOW);/* ... */
#endif
}else { ... }
return(NX_SUCCESS);
}{ ... }