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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
126
127
134
135
136
137
138
139
140
141
142
143
144
145
146
147
151
152
153
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
183
192
193
196
201
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
268
269
270
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
300
301
302
308
309
310
311
312
313
314
315
316
317
318
319
320
321
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_packet.h"
#include "nx_ip.h"
#include "nx_ipv6.h"
#include "nx_icmpv6.h"
5 includes
#ifdef FEATURE_NX_IPV6
static const ULONG _nx_ipv6_unspecified_address[4] = {0, 0, 0, 0};
...
VOID _nx_icmpv6_send_ns(NX_IP *ip_ptr,
ULONG *neighbor_IP_address,
INT send_slla,
NXD_IPV6_ADDRESS *outgoing_address,
INT sendUnicast,
ND_CACHE_ENTRY *NDCacheEntry)
{
NX_PACKET *pkt_ptr;
USHORT checksum;
#if defined(NX_DISABLE_ICMPV6_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) || defined(NX_IPSEC_ENABLE)
UINT compute_checksum = 1;
#endif
NX_ICMPV6_ND *nd_ptr;
ULONG *src_address;
ULONG dest_address[4];
NX_IP_DRIVER driver_request;
#ifdef NX_ENABLE_DUAL_PACKET_POOL
if (_nx_packet_allocate(ip_ptr -> nx_ip_auxiliary_packet_pool, &pkt_ptr, NX_IPv6_ICMP_PACKET, NX_NO_WAIT))
{
if (ip_ptr -> nx_ip_auxiliary_packet_pool != ip_ptr -> nx_ip_default_packet_pool)
#endif
{
if (_nx_packet_allocate(ip_ptr -> nx_ip_default_packet_pool, &pkt_ptr, NX_IPv6_ICMP_PACKET, NX_NO_WAIT))
{
return;
}if (_nx_packet_allocate(ip_ptr -> nx_ip_default_packet_pool, &pkt_ptr, NX_IPv6_ICMP_PACKET, NX_NO_WAIT)) { ... }
...}
#ifdef NX_ENABLE_DUAL_PACKET_POOL
else
{
return;
}else { ... }
}/* ... */
if (_nx_packet_allocate(ip_ptr -> nx_ip_auxiliary_packet_pool, &pkt_ptr, NX_IPv6_ICMP_PACKET, NX_NO_WAIT)) { ... }#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, pkt_ptr);
pkt_ptr -> nx_packet_ip_version = NX_IP_VERSION_V6;
pkt_ptr -> nx_packet_length = sizeof(NX_ICMPV6_ND);
if (send_slla)
{
pkt_ptr -> nx_packet_length += 8;
}if (send_slla) { ... }
if ((UINT)(pkt_ptr -> nx_packet_data_end - pkt_ptr -> nx_packet_prepend_ptr) < pkt_ptr -> nx_packet_length)
{
_nx_packet_release(pkt_ptr);
return;
}if ((UINT)(pkt_ptr -> nx_packet_data_end - pkt_ptr -> nx_packet_prepend_ptr) < pkt_ptr -> nx_packet_length) { ... }
pkt_ptr -> nx_packet_append_ptr = pkt_ptr -> nx_packet_prepend_ptr + pkt_ptr -> nx_packet_length;
nd_ptr = (NX_ICMPV6_ND *)(pkt_ptr -> nx_packet_prepend_ptr);
nd_ptr -> nx_icmpv6_nd_header.nx_icmpv6_header_type = NX_ICMPV6_NEIGHBOR_SOLICITATION_TYPE;
nd_ptr -> nx_icmpv6_nd_header.nx_icmpv6_header_code = 0;
nd_ptr -> nx_icmpv6_nd_header.nx_icmpv6_header_checksum = 0;
nd_ptr -> nx_icmpv6_nd_flag = 0;
COPY_IPV6_ADDRESS(neighbor_IP_address, nd_ptr -> nx_icmpv6_nd_targetAddress);
NX_IPV6_ADDRESS_CHANGE_ENDIAN(nd_ptr -> nx_icmpv6_nd_targetAddress);
if (sendUnicast)
{
COPY_IPV6_ADDRESS(neighbor_IP_address, dest_address);
}if (sendUnicast) { ... }
else
{
/* ... */
SET_SOLICITED_NODE_MULTICAST_ADDRESS(dest_address, neighbor_IP_address);
}else { ... }
/* ... */
if (outgoing_address -> nxd_ipv6_address_state == NX_IPV6_ADDR_STATE_VALID)
{
src_address = outgoing_address -> nxd_ipv6_address;
}if (outgoing_address -> nxd_ipv6_address_state == NX_IPV6_ADDR_STATE_VALID) { ... }
else
{
src_address = (ULONG *)_nx_ipv6_unspecified_address;
}else { ... }
pkt_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr = outgoing_address;
NX_ASSERT(outgoing_address -> nxd_ipv6_address_attached != NX_NULL);
if (send_slla)
{
USHORT *mac_addr;
NX_ICMPV6_OPTION *nd_options;
nd_options = (NX_ICMPV6_OPTION *)NX_UCHAR_POINTER_ADD(nd_ptr, sizeof(NX_ICMPV6_ND));
nd_options -> nx_icmpv6_option_type = 1;
nd_options -> nx_icmpv6_option_length = 1;
mac_addr = &nd_options -> nx_icmpv6_option_data;
mac_addr[0] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_msw);
mac_addr[1] = (USHORT)((outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16);
mac_addr[2] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF);
NX_CHANGE_USHORT_ENDIAN(mac_addr[0]);
NX_CHANGE_USHORT_ENDIAN(mac_addr[1]);
NX_CHANGE_USHORT_ENDIAN(mac_addr[2]);
...}
#ifdef NX_DISABLE_ICMPV6_TX_CHECKSUM
compute_checksum = 0;
#endif
#ifdef NX_ENABLE_INTERFACE_CAPABILITY
if (outgoing_address -> nxd_ipv6_address_attached -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_ICMPV6_TX_CHECKSUM)
{
compute_checksum = 0;
}if (outgoing_address -> nxd_ipv6_address_attached -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_ICMPV6_TX_CHECKSUM) { ... }
/* ... */#endif
#if defined(NX_DISABLE_ICMPV6_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) || defined(NX_IPSEC_ENABLE)
if (compute_checksum)
#endif
{
checksum = _nx_ip_checksum_compute(pkt_ptr, NX_PROTOCOL_ICMPV6, (UINT)pkt_ptr -> nx_packet_length, src_address, dest_address);
checksum = (USHORT)(~checksum);
NX_CHANGE_USHORT_ENDIAN(checksum);
nd_ptr -> nx_icmpv6_nd_header.nx_icmpv6_header_checksum = checksum;
...}
#ifdef NX_ENABLE_INTERFACE_CAPABILITY
else
{
pkt_ptr -> nx_packet_interface_capability_flag |= NX_INTERFACE_CAPABILITY_ICMPV6_TX_CHECKSUM;
}else { ... }
/* ... */#endif
if (_nx_ipv6_header_add(ip_ptr, &pkt_ptr, NX_PROTOCOL_ICMPV6, pkt_ptr -> nx_packet_length,
255, src_address, dest_address, NX_NULL) != NX_SUCCESS)
{
return;
}if (_nx_ipv6_header_add(ip_ptr, &pkt_ptr, NX_PROTOCOL_ICMPV6, pkt_ptr -> nx_packet_length, 255, src_address, dest_address, NX_NULL) != NX_SUCCESS) { ... }
driver_request.nx_ip_driver_ptr = ip_ptr;
driver_request.nx_ip_driver_command = NX_LINK_PACKET_SEND;
driver_request.nx_ip_driver_packet = pkt_ptr;
driver_request.nx_ip_driver_interface = outgoing_address -> nxd_ipv6_address_attached;
if (sendUnicast)
{
UCHAR *mac_addr;
mac_addr = NDCacheEntry -> nx_nd_cache_mac_addr;
driver_request.nx_ip_driver_physical_address_msw = ((ULONG)mac_addr[0] << 8) | mac_addr[1];
driver_request.nx_ip_driver_physical_address_lsw =
((ULONG)mac_addr[2] << 24) | ((ULONG)mac_addr[3] << 16) | ((ULONG)mac_addr[4] << 8) | mac_addr[5];
}if (sendUnicast) { ... }
else
{
driver_request.nx_ip_driver_physical_address_msw = 0x00003333;
driver_request.nx_ip_driver_physical_address_lsw = dest_address[3];
}else { ... }
#ifndef NX_DISABLE_IP_INFO
ip_ptr -> nx_ip_total_packets_sent++;
ip_ptr -> nx_ip_total_bytes_sent += pkt_ptr -> nx_packet_length - (ULONG)sizeof(NX_IPV6_HEADER);/* ... */
#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, pkt_ptr);
NX_ASSERT(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_link_driver_entry != NX_NULL);
(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_link_driver_entry)(&driver_request);
}_nx_icmpv6_send_ns (NX_IP *ip_ptr, ULONG *neighbor_IP_address, INT send_slla, NXD_IPV6_ADDRESS *outgoing_address, INT sendUnicast, ND_CACHE_ENTRY *NDCacheEntry) { ... }
/* ... */
#endif