1
10
13
14
20
21
22
23
24
25
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
99
100
102
103
104
105
106
107
108
117
118
125
126
127
128
129
130
131
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
211
212
213
214
215
216
217
218
219
220
221
...
...
...
#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
#ifndef NX_DISABLE_ICMPV6_ROUTER_SOLICITATION
static const ULONG _nx_ipv6_all_router_address[4] = {0xff020000, 0, 0, 2};
...
UINT _nx_icmpv6_send_rs(NX_IP *ip_ptr, UINT if_index)
{
USHORT *mac_addr;
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_RS *rs_ptr;
NX_ICMPV6_OPTION *rs_options;
if (ip_ptr -> nx_ip_icmpv6_packet_process == NX_NULL)
{
return(NX_NOT_SUCCESSFUL);
}if (ip_ptr -> nx_ip_icmpv6_packet_process == NX_NULL) { ... }
/* ... */
#ifdef NX_ENABLE_DUAL_PACKET_POOL
if (_nx_packet_allocate(ip_ptr -> nx_ip_auxiliary_packet_pool, &pkt_ptr, (NX_ICMP_PACKET + sizeof(NX_ICMPV6_RS) + 8), 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_ICMP_PACKET + sizeof(NX_ICMPV6_RS) + 8), NX_NO_WAIT))
{
return(NX_NOT_SUCCESSFUL);
}if (_nx_packet_allocate(ip_ptr -> nx_ip_default_packet_pool, &pkt_ptr, (NX_ICMP_PACKET + sizeof(NX_ICMPV6_RS) + 8), NX_NO_WAIT)) { ... }
...}
#ifdef NX_ENABLE_DUAL_PACKET_POOL
else
{
return(NX_NOT_SUCCESSFUL);
}else { ... }
}/* ... */
if (_nx_packet_allocate(ip_ptr -> nx_ip_auxiliary_packet_pool, &pkt_ptr, (NX_ICMP_PACKET + sizeof(NX_ICMPV6_RS) + 8), NX_NO_WAIT)) { ... }#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, pkt_ptr);
if (_nxd_ipv6_interface_find(ip_ptr, (ULONG *)_nx_ipv6_all_router_address,
&pkt_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr,
&ip_ptr -> nx_ip_interface[if_index]))
{
_nx_packet_release(pkt_ptr);
return(NX_NOT_SUCCESSFUL);
}if (_nxd_ipv6_interface_find(ip_ptr, (ULONG *)_nx_ipv6_all_router_address, &pkt_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr, &ip_ptr -> nx_ip_interface[if_index])) { ... }
pkt_ptr -> nx_packet_ip_version = NX_IP_VERSION_V6;
pkt_ptr -> nx_packet_length = (sizeof(NX_ICMPV6_RS) + 8);
pkt_ptr -> nx_packet_prepend_ptr -= pkt_ptr -> nx_packet_length;
rs_ptr = (NX_ICMPV6_RS *)(pkt_ptr -> nx_packet_prepend_ptr);
rs_ptr -> nx_icmpv6_rs_icmpv6_header.nx_icmpv6_header_type = NX_ICMPV6_ROUTER_SOLICITATION_TYPE;
rs_ptr -> nx_icmpv6_rs_icmpv6_header.nx_icmpv6_header_code = 0;
rs_ptr -> nx_icmpv6_rs_icmpv6_header.nx_icmpv6_header_checksum = 0;
rs_ptr -> nx_icmpv6_rs_reserved = 0;
rs_options = (NX_ICMPV6_OPTION *)NX_UCHAR_POINTER_ADD(rs_ptr, sizeof(NX_ICMPV6_RS));
rs_options -> nx_icmpv6_option_type = ICMPV6_OPTION_TYPE_SRC_LINK_ADDR;
rs_options -> nx_icmpv6_option_length = 1;
mac_addr = &rs_options -> nx_icmpv6_option_data;
mac_addr[0] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_msw);
mac_addr[1] = (USHORT)((ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0xFFFF0000) >> 16);
mac_addr[2] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].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 (ip_ptr -> nx_ip_interface[if_index].nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_ICMPV6_TX_CHECKSUM)
{
compute_checksum = 0;
}if (ip_ptr -> nx_ip_interface[if_index].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,
pkt_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr -> nxd_ipv6_address,
(ULONG *)_nx_ipv6_all_router_address);
checksum = (USHORT)(~checksum);
NX_CHANGE_USHORT_ENDIAN(checksum);
rs_ptr -> nx_icmpv6_rs_icmpv6_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
_nx_ipv6_packet_send(ip_ptr, pkt_ptr, NX_PROTOCOL_ICMPV6, pkt_ptr -> nx_packet_length, 255,
pkt_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr -> nxd_ipv6_address,
(ULONG *)_nx_ipv6_all_router_address);
return(NX_SUCCESS);
}_nx_icmpv6_send_rs (NX_IP *ip_ptr, UINT if_index) { ... }
/* ... */#endif /* ... */
#endif