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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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
136
137
138
139
140
141
142
143
144
145
146
147
148
151
152
153
154
158
159
160
161
162
163
164
169
174
175
176
177
178
179
180
181
182
183
184
188
189
190
191
192
193
194
195
196
197
208
209
210
211
212
213
214
215
216
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_packet.h"
...
...
UINT _nx_packet_data_extract_offset(NX_PACKET *packet_ptr, ULONG offset, VOID *buffer_start, ULONG buffer_length, ULONG *bytes_copied)
{
ULONG remaining_bytes;
UCHAR *source_ptr;
UCHAR *destination_ptr;
ULONG offset_bytes;
#ifndef NX_DISABLE_PACKET_CHAIN
ULONG packet_fragment_length;
#endif
ULONG bytes_to_copy;
NX_PACKET *working_packet_ptr;
working_packet_ptr = packet_ptr;
if (offset >= working_packet_ptr -> nx_packet_length)
{
if (offset == 0)
{
*bytes_copied = 0;
return(NX_SUCCESS);
}if (offset == 0) { ... }
return(NX_PACKET_OFFSET_ERROR);
}if (offset >= working_packet_ptr -> nx_packet_length) { ... }
source_ptr = NX_NULL;
offset_bytes = offset;
#ifndef NX_DISABLE_PACKET_CHAIN
while (working_packet_ptr)
{
packet_fragment_length = (ULONG)((working_packet_ptr -> nx_packet_append_ptr - working_packet_ptr -> nx_packet_prepend_ptr));
if (packet_fragment_length > offset_bytes)
{
source_ptr = working_packet_ptr -> nx_packet_prepend_ptr + offset_bytes;
break;
}if (packet_fragment_length > offset_bytes) { ... }
offset_bytes = offset_bytes - packet_fragment_length;
working_packet_ptr = working_packet_ptr -> nx_packet_next;
}while (working_packet_ptr) { ... }
/* ... */#else
source_ptr = working_packet_ptr -> nx_packet_prepend_ptr + offset_bytes;
/* ... */
#endif
if (source_ptr == NX_NULL)
{
return(NX_PACKET_OFFSET_ERROR);
}if (source_ptr == NX_NULL) { ... }
destination_ptr = buffer_start;
bytes_to_copy = (packet_ptr -> nx_packet_length - offset);
if (bytes_to_copy < buffer_length)
{
*bytes_copied = bytes_to_copy;
remaining_bytes = bytes_to_copy;
}if (bytes_to_copy < buffer_length) { ... }
else
{
*bytes_copied = buffer_length;
remaining_bytes = buffer_length;
}else { ... }
#ifndef NX_DISABLE_PACKET_CHAIN
while (working_packet_ptr && remaining_bytes)
{
#endif
bytes_to_copy = (ULONG)(working_packet_ptr -> nx_packet_append_ptr - source_ptr);
if (remaining_bytes < bytes_to_copy)
{
bytes_to_copy = remaining_bytes;
}if (remaining_bytes < bytes_to_copy) { ... }
memcpy(destination_ptr, source_ptr, bytes_to_copy);
destination_ptr += bytes_to_copy;
remaining_bytes -= bytes_to_copy;
#ifndef NX_DISABLE_PACKET_CHAIN
working_packet_ptr = working_packet_ptr -> nx_packet_next;
if (working_packet_ptr)
{
source_ptr = working_packet_ptr -> nx_packet_prepend_ptr;
}if (working_packet_ptr) { ... }
}/* ... */
while (working_packet_ptr && remaining_bytes) { ... }#endif
NX_TRACE_IN_LINE_INSERT(NX_TRACE_PACKET_DATA_EXTRACT_OFFSET, packet_ptr, buffer_length, *bytes_copied, 0, NX_TRACE_PACKET_EVENTS, 0, 0);
return(NX_SUCCESS);
}{ ... }