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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
146
147
148
149
150
151
152
153
154
158
159
163
164
165
166
167
171
172
175
176
177
181
182
196
200
201
207
208
209
210
211
212
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_udp.h"
#include "nx_ipv4.h"
#ifdef FEATURE_NX_IPV6
#include "nx_ipv6.h"
#endif
...
...
UINT _nxd_udp_packet_info_extract(NX_PACKET *packet_ptr, NXD_ADDRESS *ip_address,
UINT *protocol, UINT *port, UINT *interface_index)
{
ULONG *temp_ptr;
UINT source_port;
NX_INTERFACE *nx_interface;
#ifndef NX_DISABLE_IPV4
NX_IPV4_HEADER *ipv4_header;
#endif
#ifdef TX_ENABLE_EVENT_TRACE
ULONG address = 0;
#endif
#ifdef FEATURE_NX_IPV6
NX_IPV6_HEADER *ipv6_header;
#endif
if (ip_address)
{
#ifndef NX_DISABLE_IPV4
if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4)
{
ipv4_header = (NX_IPV4_HEADER *)packet_ptr -> nx_packet_ip_header;
ip_address -> nxd_ip_version = NX_IP_VERSION_V4;
ip_address -> nxd_ip_address.v4 = ipv4_header -> nx_ip_header_source_ip;
#ifdef TX_ENABLE_EVENT_TRACE
address = ip_address -> nxd_ip_address.v4;
#endif
}if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4) { ... }
else/* ... */
#endif
#ifdef FEATURE_NX_IPV6
if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6)
{
ipv6_header = (NX_IPV6_HEADER *)packet_ptr -> nx_packet_ip_header;
ip_address -> nxd_ip_version = NX_IP_VERSION_V6;
COPY_IPV6_ADDRESS(ipv6_header -> nx_ip_header_source_ip, ip_address -> nxd_ip_address.v6);
#ifdef TX_ENABLE_EVENT_TRACE
address = ip_address -> nxd_ip_address.v6[3];
#endif
}else if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6) { ... }
else
#endif
{
return(NX_INVALID_PACKET);
}else { ... }
}if (ip_address) { ... }
temp_ptr = (ULONG *)packet_ptr -> nx_packet_prepend_ptr;
source_port = (UINT)(*(temp_ptr - 2) >> NX_SHIFT_BY_16);
if (port != NX_NULL)
{
*port = source_port;
}if (port != NX_NULL) { ... }
if (protocol != NX_NULL)
{
*protocol = 0x11;
}if (protocol != NX_NULL) { ... }
NX_TRACE_IN_LINE_INSERT(NX_TRACE_UDP_SOURCE_EXTRACT, packet_ptr, address, source_port, 0, NX_TRACE_PACKET_EVENTS, 0, 0);
if (interface_index == NX_NULL)
{
return(NX_SUCCESS);
}if (interface_index == NX_NULL) { ... }
/* ... */
*interface_index = 0xFFFFFFFF;
if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4)
{
nx_interface = packet_ptr -> nx_packet_address.nx_packet_interface_ptr;
}if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4) { ... }
#ifdef FEATURE_NX_IPV6
else if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6)
{
if (packet_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr == NX_NULL)
{
return(NX_SUCCESS);
}if (packet_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr == NX_NULL) { ... }
else
{
nx_interface = packet_ptr -> nx_packet_address.nx_packet_ipv6_address_ptr -> nxd_ipv6_address_attached;
}else { ... }
}else if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6) { ... }
/* ... */#endif
else
{
return(NX_SUCCESS);
}else { ... }
if (nx_interface == NX_NULL)
{
return(NX_SUCCESS);
}if (nx_interface == NX_NULL) { ... }
*interface_index = (UINT)nx_interface -> nx_interface_index;
return(NX_SUCCESS);
}{ ... }