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
104
105
106
107
108
113
114
119
120
121
122
123
124
125
126
127
129
130
131
132
133
134
135
136
137
138
144
145
146
147
148
149
150
151
152
153
157
161
162
163
164
165
168
169
170
171
177
178
179
180
181
182
183
184
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_packet.h"
#include "nx_ip.h"
#include "nx_icmp.h"
#ifdef NX_IPSEC_ENABLE
#include "nx_ipsec.h"
#endif
#ifndef NX_DISABLE_IPV4...
...
VOID _nx_icmpv4_packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
{
NX_ICMPV4_HEADER *header_ptr;
USHORT checksum;
#if defined(NX_DISABLE_ICMPV4_RX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) || defined(NX_IPSEC_ENABLE)
UINT compute_checksum = 1;
#endif
#ifdef TX_ENABLE_EVENT_TRACE
NX_IPV4_HEADER *ip_header_ptr;
#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
header_ptr = (NX_ICMPV4_HEADER *)packet_ptr -> nx_packet_prepend_ptr;
#ifdef NX_DISABLE_ICMPV4_RX_CHECKSUM
compute_checksum = 0;
#endif
#ifdef NX_ENABLE_INTERFACE_CAPABILITY
if (packet_ptr -> nx_packet_address.nx_packet_interface_ptr -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_ICMPV4_RX_CHECKSUM)
{
compute_checksum = 0;
}if (packet_ptr -> nx_packet_address.nx_packet_interface_ptr -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_ICMPV4_RX_CHECKSUM) { ... }
/* ... */#endif
#ifdef NX_IPSEC_ENABLE
if ((packet_ptr -> nx_packet_ipsec_sa_ptr != NX_NULL) && (((NX_IPSEC_SA *)(packet_ptr -> nx_packet_ipsec_sa_ptr)) -> nx_ipsec_sa_encryption_method != NX_CRYPTO_NONE))
{
compute_checksum = 1;
}if ((packet_ptr -> nx_packet_ipsec_sa_ptr != NX_NULL) && (((NX_IPSEC_SA *)(packet_ptr -> nx_packet_ipsec_sa_ptr)) -> nx_ipsec_sa_encryption_method != NX_CRYPTO_NONE)) { ... }
/* ... */#endif
#if defined(NX_DISABLE_ICMPV4_RX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) || defined(NX_IPSEC_ENABLE)
if (compute_checksum)
#endif
{
checksum = _nx_ip_checksum_compute(packet_ptr, NX_IP_ICMP,
(UINT)packet_ptr -> nx_packet_length,
/* ... */
NX_NULL, NX_NULL);
checksum = ((USHORT) ~checksum) & NX_LOWER_16_MASK;
if (checksum)
{
#ifndef NX_DISABLE_ICMP_INFO
ip_ptr -> nx_ip_icmp_invalid_packets++;
ip_ptr -> nx_ip_icmp_checksum_errors++;/* ... */
#endif
_nx_packet_release(packet_ptr);
return;
}if (checksum) { ... }
...}
if (header_ptr -> nx_icmpv4_header_type == NX_ICMP_ECHO_REPLY_TYPE)
{
_nx_icmpv4_process_echo_reply(ip_ptr, packet_ptr);
}if (header_ptr -> nx_icmpv4_header_type == NX_ICMP_ECHO_REPLY_TYPE) { ... }
else if (header_ptr -> nx_icmpv4_header_type == NX_ICMP_ECHO_REQUEST_TYPE)
{
_nx_icmpv4_process_echo_request(ip_ptr, packet_ptr);
}else if (header_ptr -> nx_icmpv4_header_type == NX_ICMP_ECHO_REQUEST_TYPE) { ... }
else
{
#ifndef NX_DISABLE_ICMP_INFO
ip_ptr -> nx_ip_icmp_unhandled_messages++;/* ... */
#endif
#ifdef TX_ENABLE_EVENT_TRACE
ip_header_ptr = (NX_IPV4_HEADER *)packet_ptr -> nx_packet_ip_header;
NX_TRACE_IN_LINE_INSERT(NX_TRACE_INTERNAL_ICMP_RECEIVE, ip_ptr, ip_header_ptr -> nx_ip_header_source_ip, packet_ptr, 0, NX_TRACE_INTERNAL_EVENTS, 0, 0);/* ... */
#endif
_nx_packet_release(packet_ptr);
}else { ... }
}{ ... }
#endif/* ... */