1
10
13
14
20
21
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
89
90
91
92
93
94
95
96
99
100
101
102
103
104
105
106
107
108
111
112
113
114
115
116
117
118
119
120
121
122
123
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
165
166
167
168
169
170
176
182
183
184
185
186
187
188
189
190
191
192
199
200
202
203
204
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_icmp.h"
#include "nx_packet.h"
#include "tx_thread.h"
5 includes
...
...
VOID _nx_icmp_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
{
#ifndef NX_DISABLE_IPV4
TX_INTERRUPT_SAVE_AREA
#ifdef NX_ENABLE_ICMP_ADDRESS_CHECK
NX_IPV4_HEADER *ip_header_ptr;
NX_INTERFACE *interface_ptr;/* ... */
#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
#ifndef NX_DISABLE_ICMP_INFO
ip_ptr -> nx_ip_icmp_total_messages_received++;/* ... */
#endif
#ifndef NX_DISABLE_RX_SIZE_CHECKING
if (packet_ptr -> nx_packet_length < sizeof(NX_ICMP_HEADER))
{
#ifndef NX_DISABLE_ICMP_INFO
ip_ptr -> nx_ip_icmp_invalid_packets++;/* ... */
#endif
_nx_packet_release(packet_ptr);
return;
}if (packet_ptr -> nx_packet_length < sizeof(NX_ICMP_HEADER)) { ... }
/* ... */#endif
#ifdef NX_ENABLE_ICMP_ADDRESS_CHECK
/* ... */
ip_header_ptr = (NX_IPV4_HEADER *)(packet_ptr -> nx_packet_prepend_ptr - sizeof(NX_IPV4_HEADER));
interface_ptr = packet_ptr -> nx_packet_address.nx_packet_interface_ptr;
if (
((ip_header_ptr -> nx_ip_header_destination_ip & NX_IP_CLASS_D_MASK) == NX_IP_CLASS_D_TYPE) ||
(((ip_header_ptr -> nx_ip_header_destination_ip & interface_ptr -> nx_interface_ip_network_mask) == interface_ptr -> nx_interface_ip_network) &&
((ip_header_ptr -> nx_ip_header_destination_ip & ~(interface_ptr -> nx_interface_ip_network_mask)) == ~(interface_ptr -> nx_interface_ip_network_mask))) ||
(ip_header_ptr -> nx_ip_header_destination_ip == interface_ptr -> nx_interface_ip_network) ||
(ip_header_ptr -> nx_ip_header_destination_ip == NX_IP_LIMITED_BROADCAST)
)
{
#ifndef NX_DISABLE_ICMP_INFO
ip_ptr -> nx_ip_icmp_invalid_packets++;/* ... */
#endif
_nx_packet_release(packet_ptr);
return;
}if (/* Check for Multicast address */ ((ip_header_ptr -> nx_ip_header_destination_ip & NX_IP_CLASS_D_MASK) == NX_IP_CLASS_D_TYPE) || /* Check for subnet-directed broadcast */ (((ip_header_ptr -> nx_ip_header_destination_ip & interface_ptr -> nx_interface_ip_network_mask) == interface_ptr -> nx_interface_ip_network) && ((ip_header_ptr -> nx_ip_header_destination_ip & ~(interface_ptr -> nx_interface_ip_network_mask)) == ~(interface_ptr -> nx_interface_ip_network_mask))) || /* Check for local subnet address */ (ip_header_ptr -> nx_ip_header_destination_ip == interface_ptr -> nx_interface_ip_network) || /* Check for limited broadcast */ (ip_header_ptr -> nx_ip_header_destination_ip == NX_IP_LIMITED_BROADCAST)) { ... }
/* ... */#endif
if ((TX_THREAD_GET_SYSTEM_STATE()) || (&(ip_ptr -> nx_ip_thread) != _tx_thread_current_ptr))
{
/* ... */
TX_DISABLE
if (ip_ptr -> nx_ip_icmp_queue_head)
{
packet_ptr -> nx_packet_queue_next = ip_ptr -> nx_ip_icmp_queue_head;
}if (ip_ptr -> nx_ip_icmp_queue_head) { ... }
else
{
packet_ptr -> nx_packet_queue_next = NX_NULL;
}else { ... }
ip_ptr -> nx_ip_icmp_queue_head = packet_ptr;
TX_RESTORE
tx_event_flags_set(&(ip_ptr -> nx_ip_events), NX_IP_ICMP_EVENT, TX_OR);
}if ((TX_THREAD_GET_SYSTEM_STATE()) || (&(ip_ptr -> nx_ip_thread) != _tx_thread_current_ptr)) { ... }
else
{
/* ... */
_nx_icmp_packet_process(ip_ptr, packet_ptr);
}else { ... }
/* ... */#else
NX_PARAMETER_NOT_USED(ip_ptr);
NX_PARAMETER_NOT_USED(packet_ptr);/* ... */
#endif
}{ ... }