1
10
13
14
20
21
22
23
24
25
26
27
28
29
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
101
102
103
104
108
109
110
114
115
116
117
118
119
122
123
124
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
150
151
152
153
154
155
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
201
202
203
204
205
206
207
208
209
210
211
212
213
215
216
218
219
220
221
222
223
224
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_ipv6.h"
#include "nx_packet.h"
#include "nx_icmpv6.h"
5 includes
#if defined(FEATURE_NX_IPV6) && !defined(NX_DISABLE_FRAGMENTATION)
...
UINT _nx_ipv6_process_fragment_option(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
{
TX_INTERRUPT_SAVE_AREA
NX_IPV6_HEADER_FRAGMENT_OPTION *fragment_option;
NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
#ifndef NX_DISABLE_IP_INFO
ip_ptr -> nx_ip_total_fragments_received++;
/* ... */
#endif
if (!ip_ptr -> nx_ip_fragment_assembly)
{
return(NX_OPTION_HEADER_ERROR);
}if (!ip_ptr -> nx_ip_fragment_assembly) { ... }
if (packet_ptr -> nx_packet_length < sizeof(NX_IPV6_HEADER_FRAGMENT_OPTION))
{
return(NX_OPTION_HEADER_ERROR);
}if (packet_ptr -> nx_packet_length < sizeof(NX_IPV6_HEADER_FRAGMENT_OPTION)) { ... }
fragment_option = (NX_IPV6_HEADER_FRAGMENT_OPTION *)packet_ptr -> nx_packet_prepend_ptr;
/* ... */
NX_CHANGE_USHORT_ENDIAN(fragment_option -> nx_ipv6_header_fragment_option_offset_flag);
/* ... */
if (fragment_option -> nx_ipv6_header_fragment_option_offset_flag & 0x0001)
{
NX_IPV6_HEADER *ip_header;
ULONG payload_length;
ip_header = (NX_IPV6_HEADER *)packet_ptr -> nx_packet_ip_header;
payload_length = ip_header -> nx_ip_header_word_1 >> 16;
if ((payload_length & 0xFFF8) != payload_length)
{
#ifndef NX_DISABLE_ICMPV6_ERROR_MESSAGE
NX_CHANGE_USHORT_ENDIAN(fragment_option -> nx_ipv6_header_fragment_option_offset_flag);
NX_ICMPV6_SEND_PARAMETER_PROBLEM(ip_ptr, packet_ptr, 0, 4);/* ... */
#endif
return(NX_OPTION_HEADER_ERROR);
}if ((payload_length & 0xFFF8) != payload_length) { ... }
...}
else if ((fragment_option -> nx_ipv6_header_fragment_option_offset_flag & 0xFFF8) == 0)
{
return(NX_CONTINUE);
}else if ((fragment_option -> nx_ipv6_header_fragment_option_offset_flag & 0xFFF8) == 0) { ... }
if (((fragment_option -> nx_ipv6_header_fragment_option_offset_flag & 0xFFF8) + packet_ptr -> nx_packet_length -
sizeof(NX_IPV6_HEADER_FRAGMENT_OPTION)) > 65535)
{
#ifndef NX_DISABLE_ICMPV6_ERROR_MESSAGE
NX_CHANGE_USHORT_ENDIAN(fragment_option -> nx_ipv6_header_fragment_option_offset_flag);
NX_ICMPV6_SEND_PARAMETER_PROBLEM(ip_ptr, packet_ptr, 0,
(ULONG)((packet_ptr -> nx_packet_prepend_ptr - packet_ptr -> nx_packet_ip_header) + 2));/* ... */
#endif
return(NX_OPTION_HEADER_ERROR);
}if (((fragment_option -> nx_ipv6_header_fragment_option_offset_flag & 0xFFF8) + packet_ptr -> nx_packet_length - sizeof(NX_IPV6_HEADER_FRAGMENT_OPTION)) > 65535) { ... }
TX_DISABLE
if (ip_ptr -> nx_ip_received_fragment_head)
{
(ip_ptr -> nx_ip_received_fragment_tail) -> nx_packet_queue_next = packet_ptr;
packet_ptr -> nx_packet_queue_next = NX_NULL;
ip_ptr -> nx_ip_received_fragment_tail = packet_ptr;
}if (ip_ptr -> nx_ip_received_fragment_head) { ... }
else
{
/* ... */
ip_ptr -> nx_ip_received_fragment_head = packet_ptr;
ip_ptr -> nx_ip_received_fragment_tail = packet_ptr;
packet_ptr -> nx_packet_queue_next = NX_NULL;
}else { ... }
NX_PACKET_DEBUG(NX_PACKET_IP_FRAGMENT_QUEUE, __LINE__, packet_ptr);
TX_RESTORE
#ifndef NX_FRAGMENT_IMMEDIATE_ASSEMBLY
tx_event_flags_set(&(ip_ptr -> nx_ip_events), NX_IP_UNFRAG_EVENT, TX_OR);/* ... */
#else
(ip_ptr -> nx_ip_fragment_assembly)(ip_ptr);/* ... */
#endif
return(NX_SUCCESS);
}_nx_ipv6_process_fragment_option (NX_IP *ip_ptr, NX_PACKET *packet_ptr) { ... }
/* ... */
#endif