1
10
13
14
20
21
22
23
24
25
26
27
28
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
131
132
133
134
135
136
137
138
139
140
141
142
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
193
194
196
197
198
199
200
201
207
213
214
215
216
217
218
219
222
223
224
225
226
227
228
229
230
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
287
288
289
290
291
292
294
295
296
298
299
300
301
302
303
304
305
306
307
308
309
310
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
342
343
344
345
346
350
351
352
353
354
355
356
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_packet.h"
#include "nx_ipv6.h"
#include "nx_icmpv6.h"
5 includes
#ifdef FEATURE_NX_IPV6
...
VOID _nx_ipv6_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
{
UINT error;
ULONG delta;
UINT pkt_length;
UCHAR next_header_type;
NX_IPV6_HEADER *ip_header_ptr;
NXD_IPV6_ADDRESS *interface_ipv6_address_next;
NXD_IPV6_ADDRESS *incoming_address = NX_NULL;
#ifndef NX_DISABLE_PACKET_CHAIN
NX_PACKET *before_last_packet;
NX_PACKET *last_packet;/* ... */
#endif
#ifdef NX_ENABLE_IPV6_MULTICAST
INT i = 0;
#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
ip_header_ptr = (NX_IPV6_HEADER *)packet_ptr -> nx_packet_prepend_ptr;
NX_CHANGE_ULONG_ENDIAN(ip_header_ptr -> nx_ip_header_word_1);
pkt_length = (UINT)((ip_header_ptr -> nx_ip_header_word_1 >> 16) + sizeof(NX_IPV6_HEADER));
if (packet_ptr -> nx_packet_length != (ULONG)pkt_length)
{
if (packet_ptr -> nx_packet_length < (ULONG)pkt_length)
{
#ifndef NX_DISABLE_IP_INFO
ip_ptr -> nx_ip_invalid_packets++;
ip_ptr -> nx_ip_receive_packets_dropped++;/* ... */
#endif
_nx_packet_release(packet_ptr);
return;
}if (packet_ptr -> nx_packet_length < (ULONG)pkt_length) { ... }
delta = packet_ptr -> nx_packet_length - pkt_length;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length - delta;
#ifndef NX_DISABLE_PACKET_CHAIN
while (delta)
{
if (packet_ptr -> nx_packet_last == NX_NULL)
{
packet_ptr -> nx_packet_append_ptr = packet_ptr -> nx_packet_append_ptr - delta;
break;
}if (packet_ptr -> nx_packet_last == NX_NULL) { ... }
last_packet = packet_ptr -> nx_packet_last;
if (((ULONG)(last_packet -> nx_packet_append_ptr - last_packet -> nx_packet_prepend_ptr)) > delta)
{
last_packet -> nx_packet_append_ptr = last_packet -> nx_packet_append_ptr - delta;
break;
}if (((ULONG)(last_packet -> nx_packet_append_ptr - last_packet -> nx_packet_prepend_ptr)) > delta) { ... }
else
{
delta = delta - ((ULONG)(last_packet -> nx_packet_append_ptr - last_packet -> nx_packet_prepend_ptr));
before_last_packet = packet_ptr;
while (before_last_packet -> nx_packet_next != last_packet)
{
before_last_packet = before_last_packet -> nx_packet_next;
}while (before_last_packet -> nx_packet_next != last_packet) { ... }
/* ... */
before_last_packet -> nx_packet_next = NX_NULL;
if (packet_ptr != before_last_packet)
{
packet_ptr -> nx_packet_last = before_last_packet;
}if (packet_ptr != before_last_packet) { ... }
else
{
packet_ptr -> nx_packet_last = NX_NULL;
}else { ... }
_nx_packet_release(last_packet);
}else { ... }
}while (delta) { ... }
/* ... */#else
packet_ptr -> nx_packet_append_ptr = packet_ptr -> nx_packet_append_ptr - delta;/* ... */
#endif
}if (packet_ptr -> nx_packet_length != (ULONG)pkt_length) { ... }
NX_CHANGE_ULONG_ENDIAN(ip_header_ptr -> nx_ip_header_word_0);
NX_IPV6_ADDRESS_CHANGE_ENDIAN(ip_header_ptr -> nx_ip_header_destination_ip);
NX_IPV6_ADDRESS_CHANGE_ENDIAN(ip_header_ptr -> nx_ip_header_source_ip);
/* ... */
interface_ipv6_address_next = packet_ptr -> nx_packet_address.nx_packet_interface_ptr -> nxd_interface_ipv6_address_list_head;
while (interface_ipv6_address_next)
{
if (interface_ipv6_address_next -> nxd_ipv6_address_state != NX_IPV6_ADDR_STATE_UNKNOWN)
{
if (CHECK_IPV6_ADDRESSES_SAME(ip_header_ptr -> nx_ip_header_destination_ip,
interface_ipv6_address_next -> nxd_ipv6_address))
{
incoming_address = interface_ipv6_address_next;
break;
}if (CHECK_IPV6_ADDRESSES_SAME(ip_header_ptr -> nx_ip_header_destination_ip, interface_ipv6_address_next -> nxd_ipv6_address)) { ... }
else if (CHECK_IPV6_SOLICITED_NODE_MCAST_ADDRESS(ip_header_ptr -> nx_ip_header_destination_ip,
interface_ipv6_address_next -> nxd_ipv6_address))
{
incoming_address = interface_ipv6_address_next;
break;
}else if (CHECK_IPV6_SOLICITED_NODE_MCAST_ADDRESS(ip_header_ptr -> nx_ip_header_destination_ip, interface_ipv6_address_next -> nxd_ipv6_address)) { ... }
}if (interface_ipv6_address_next -> nxd_ipv6_address_state != NX_IPV6_ADDR_STATE_UNKNOWN) { ... }
interface_ipv6_address_next = interface_ipv6_address_next -> nxd_ipv6_address_next;
}while (interface_ipv6_address_next) { ... }
#ifdef NX_ENABLE_IPV6_MULTICAST
if ((incoming_address == NX_NULL) && ((ip_header_ptr -> nx_ip_header_destination_ip[0] & 0xFF000000) == 0xFF000000))
{
for (i = 0; i < NX_MAX_MULTICAST_GROUPS; i++)
{
if ((ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list == packet_ptr -> nx_packet_address.nx_packet_interface_ptr) &&
(CHECK_IPV6_ADDRESSES_SAME(ip_header_ptr -> nx_ip_header_destination_ip, (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_list))))
{
incoming_address = ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list -> nxd_interface_ipv6_address_list_head;
break;
}if ((ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_interface_list == packet_ptr -> nx_packet_address.nx_packet_interface_ptr) && (CHECK_IPV6_ADDRESSES_SAME(ip_header_ptr -> nx_ip_header_destination_ip, (ip_ptr -> nx_ipv6_multicast_entry[i].nx_ip_mld_join_list)))) { ... }
}for (i = 0; i < NX_MAX_MULTICAST_GROUPS; i++) { ... }
}if ((incoming_address == NX_NULL) && ((ip_header_ptr -> nx_ip_header_destination_ip[0] & 0xFF000000) == 0xFF000000)) { ... }
/* ... */#endif
if (incoming_address == NX_NULL)
{
/* ... */
#ifndef NX_DISABLE_IP_INFO
ip_ptr -> nx_ip_receive_packets_dropped++;/* ... */
#endif
_nx_packet_release(packet_ptr);
return;
}if (incoming_address == NX_NULL) { ... }
packet_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr = incoming_address;
/* ... */
packet_ptr -> nx_packet_prepend_ptr += sizeof(NX_IPV6_HEADER);
packet_ptr -> nx_packet_length -= (ULONG)sizeof(NX_IPV6_HEADER);
packet_ptr -> nx_packet_option_offset = 6;
next_header_type = (UCHAR)((ip_header_ptr -> nx_ip_header_word_1 >> 8) & 0xFF);
/* ... */
packet_ptr -> nx_packet_option_state = (UCHAR)IPV6_BASE_HEADER;
packet_ptr -> nx_packet_destination_header = 0;
#ifndef NX_DISABLE_IP_INFO
ip_ptr -> nx_ip_total_packets_delivered++;
ip_ptr -> nx_ip_total_bytes_received += packet_ptr -> nx_packet_length;/* ... */
#endif
error = _nx_ip_dispatch_process(ip_ptr, packet_ptr, next_header_type);
if (error)
{
_nx_packet_release(packet_ptr);
}if (error) { ... }
return;
}_nx_ipv6_packet_receive (NX_IP *ip_ptr, NX_PACKET *packet_ptr) { ... }
/* ... */
#endif