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
92
93
94
95
96
97
99
103
104
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
144
145
146
147
157
158
159
160
161
162
163
164
165
166
167
168
170
171
172
178
179
180
181
182
183
184
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_packet.h"
...
...
VOID _nx_ip_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
{
UCHAR ip_version;
UCHAR version_byte;
#ifndef NX_DISABLE_IP_INFO
ip_ptr -> nx_ip_total_packets_received++;/* ... */
#endif
NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr);
/* ... */
if (packet_ptr -> nx_packet_address.nx_packet_interface_ptr == NX_NULL)
{
packet_ptr -> nx_packet_address.nx_packet_interface_ptr = &(ip_ptr -> nx_ip_interface[0]);
}if (packet_ptr -> nx_packet_address.nx_packet_interface_ptr == NX_NULL) { ... }
/* ... */
version_byte = *(packet_ptr -> nx_packet_prepend_ptr);
ip_version = (version_byte >> 4);
packet_ptr -> nx_packet_ip_version = ip_version;
packet_ptr -> nx_packet_ip_header = packet_ptr -> nx_packet_prepend_ptr;
#ifdef NX_ENABLE_IP_PACKET_FILTER
if (ip_ptr -> nx_ip_packet_filter)
{
if (ip_ptr -> nx_ip_packet_filter((VOID *)(packet_ptr -> nx_packet_prepend_ptr),
NX_IP_PACKET_IN) != NX_SUCCESS)
{
_nx_packet_release(packet_ptr);
return;
}if (ip_ptr -> nx_ip_packet_filter((VOID *)(packet_ptr -> nx_packet_prepend_ptr), NX_IP_PACKET_IN) != NX_SUCCESS) { ... }
}if (ip_ptr -> nx_ip_packet_filter) { ... }
if (ip_ptr -> nx_ip_packet_filter_extended)
{
if (ip_ptr -> nx_ip_packet_filter_extended(ip_ptr, packet_ptr, NX_IP_PACKET_IN) != NX_SUCCESS)
{
_nx_packet_release(packet_ptr);
return;
}if (ip_ptr -> nx_ip_packet_filter_extended(ip_ptr, packet_ptr, NX_IP_PACKET_IN) != NX_SUCCESS) { ... }
}if (ip_ptr -> nx_ip_packet_filter_extended) { ... }
/* ... */#endif
#ifndef NX_DISABLE_IPV4
if (ip_version == NX_IP_VERSION_V4 && ip_ptr -> nx_ipv4_packet_receive)
{
(ip_ptr -> nx_ipv4_packet_receive)(ip_ptr, packet_ptr);
return;
}if (ip_version == NX_IP_VERSION_V4 && ip_ptr -> nx_ipv4_packet_receive) { ... }
/* ... */#endif
#ifdef FEATURE_NX_IPV6
if (ip_version == NX_IP_VERSION_V6 && ip_ptr -> nx_ipv6_packet_receive)
{
(ip_ptr -> nx_ipv6_packet_receive)(ip_ptr, packet_ptr);
return;
}if (ip_version == NX_IP_VERSION_V6 && ip_ptr -> nx_ipv6_packet_receive) { ... }
/* ... */#endif
/* ... */
#ifndef NX_DISABLE_IP_INFO
ip_ptr -> nx_ip_invalid_packets++;
ip_ptr -> nx_ip_receive_packets_dropped++;/* ... */
#endif
_nx_packet_release(packet_ptr);
return;
}{ ... }