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
108
109
110
111
112
113
114
115
116
117
118
121
122
125
126
127
128
129
130
131
132
133
134
135
136
137
138
140
141
142
148
149
150
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
178
179
180
181
182
183
184
185
186
187
192
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
230
231
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
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_igmp.h"
#include "nx_ipv4.h"
#include "nx_packet.h"
#ifndef NX_DISABLE_IPV4...
...
UINT _nx_igmp_interface_report_send(NX_IP *ip_ptr, ULONG group_address, UINT interface_index, UINT is_joining)
{
NX_INTERFACE *nx_interface;
UINT router_alert = 0;
UINT status;
ULONG checksum;
ULONG temp;
NX_PACKET *packet_ptr;
NX_IGMP_HEADER *header_ptr;
#ifndef NX_DISABLE_IGMPV2
if (ip_ptr -> nx_ip_igmp_router_version == NX_IGMP_HOST_VERSION_2)
{
router_alert = 4;
}if (ip_ptr -> nx_ip_igmp_router_version == NX_IGMP_HOST_VERSION_2) { ... }
/* ... */#endif
tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
nx_interface = &ip_ptr -> nx_ip_interface[interface_index];
#ifdef NX_ENABLE_DUAL_PACKET_POOL
status = _nx_packet_allocate(ip_ptr -> nx_ip_auxiliary_packet_pool, &packet_ptr, (ULONG)(NX_IGMP_PACKET + router_alert + NX_IGMP_HEADER_SIZE), TX_NO_WAIT);
if ((status != NX_SUCCESS) && (ip_ptr -> nx_ip_auxiliary_packet_pool != ip_ptr -> nx_ip_default_packet_pool))/* ... */
#endif
{
status = _nx_packet_allocate(ip_ptr -> nx_ip_default_packet_pool, &packet_ptr, (ULONG)(NX_IGMP_PACKET + router_alert + NX_IGMP_HEADER_SIZE), TX_NO_WAIT);
...}
if (status)
{
tx_mutex_put(&(ip_ptr -> nx_ip_protection));
return(status);
}if (status) { ... }
NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
/* ... */
#ifndef NX_DISABLE_IGMP_INFO
if (is_joining == NX_TRUE)
{
ip_ptr -> nx_ip_igmp_reports_sent++;
}if (is_joining == NX_TRUE) { ... }
/* ... */
#endif
/* ... */
packet_ptr -> nx_packet_length = NX_IGMP_HEADER_SIZE;
packet_ptr -> nx_packet_prepend_ptr -= NX_IGMP_HEADER_SIZE;
packet_ptr -> nx_packet_address.nx_packet_interface_ptr = nx_interface;
header_ptr = (NX_IGMP_HEADER *)packet_ptr -> nx_packet_prepend_ptr;
#ifndef NX_DISABLE_IGMPV2
if (ip_ptr -> nx_ip_igmp_router_version == NX_IGMP_HOST_VERSION_1)
{
#endif
/* ... */
header_ptr -> nx_igmp_header_word_0 = (ULONG)(NX_IGMP_VERSION | NX_IGMP_HOST_RESPONSE_TYPE);
header_ptr -> nx_igmp_header_word_1 = group_address;
#ifndef NX_DISABLE_IGMPV2
}if (ip_ptr -> nx_ip_igmp_router_version == NX_IGMP_HOST_VERSION_1) { ... }
else
{
if (is_joining)
{
header_ptr -> nx_igmp_header_word_0 = (ULONG)(NX_IGMP_HOST_V2_JOIN_TYPE);
}if (is_joining) { ... }
else
{
header_ptr -> nx_igmp_header_word_0 = (ULONG)(NX_IGMP_HOST_V2_LEAVE_TYPE);
}else { ... }
header_ptr -> nx_igmp_header_word_1 = group_address;
}else { ... }
#endif
#ifdef NX_ENABLE_INTERFACE_CAPABILITY
if (!(packet_ptr -> nx_packet_address.nx_packet_interface_ptr -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_IGMP_TX_CHECKSUM))
#endif
{
temp = header_ptr -> nx_igmp_header_word_0;
checksum = (temp >> NX_SHIFT_BY_16);
checksum += (temp & NX_LOWER_16_MASK);
temp = header_ptr -> nx_igmp_header_word_1;
checksum += (temp >> NX_SHIFT_BY_16);
checksum += (temp & NX_LOWER_16_MASK);
checksum = (checksum >> NX_SHIFT_BY_16) + (checksum & NX_LOWER_16_MASK);
checksum = (checksum >> NX_SHIFT_BY_16) + (checksum & NX_LOWER_16_MASK);
header_ptr -> nx_igmp_header_word_0 = header_ptr -> nx_igmp_header_word_0 | (~checksum & NX_LOWER_16_MASK);
...}
#ifdef NX_ENABLE_INTERFACE_CAPABILITY
else
{
packet_ptr -> nx_packet_interface_capability_flag |= NX_INTERFACE_CAPABILITY_IGMP_TX_CHECKSUM;
}else { ... }
/* ... */#endif
packet_ptr -> nx_packet_ip_version = NX_IP_VERSION_V4;
NX_CHANGE_ULONG_ENDIAN(header_ptr -> nx_igmp_header_word_0);
NX_CHANGE_ULONG_ENDIAN(header_ptr -> nx_igmp_header_word_1);
if (is_joining == NX_TRUE)
{
_nx_ip_packet_send(ip_ptr, packet_ptr,
group_address,
NX_IP_NORMAL, NX_IGMP_TTL, NX_IP_IGMP, NX_FRAGMENT_OKAY,
group_address);
}if (is_joining == NX_TRUE) { ... }
else
{
_nx_ip_packet_send(ip_ptr, packet_ptr,
NX_ALL_ROUTERS_ADDRESS,
NX_IP_NORMAL, NX_IGMP_TTL, NX_IP_IGMP, NX_FRAGMENT_OKAY,
NX_ALL_ROUTERS_ADDRESS);
}else { ... }
tx_mutex_put(&(ip_ptr -> nx_ip_protection));
return NX_SUCCESS;
}{ ... }
#endif/* ... */