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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
166
167
168
169
170
171
172
173
174
175
176
177
180
181
182
183
184
185
186
187
188
189
190
191
194
195
196
197
198
199
200
201
202
203
204
205
208
209
210
211
212
213
214
215
217
218
219
220
221
222
225
229
230
231
232
233
234
235
236
237
238
239
240
241
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_packet.h"
#include "nx_icmpv4.h"
#ifndef NX_DISABLE_IPV4...
...
UINT _nx_ipv4_option_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
{
NX_IPV4_HEADER *ip_header_ptr;
UCHAR *option_ptr;
ULONG ip_option_length;
#ifndef NX_DISABLE_ICMPV4_ERROR_MESSAGE
ULONG ip_normal_length = 20;
#endif
UINT index = 0;
UCHAR op_type;
UCHAR op_length;
UCHAR op_timestamp_offset;
UCHAR op_timestamp_overflow;
UCHAR op_timestamp_flags;
UINT op_timestamp_counter = 0;
ip_header_ptr = (NX_IPV4_HEADER *)(packet_ptr -> nx_packet_prepend_ptr);
option_ptr = packet_ptr -> nx_packet_prepend_ptr + sizeof(NX_IPV4_HEADER);
ip_option_length = ((((ip_header_ptr -> nx_ip_header_word_0 & NX_IP_LENGTH_MASK) >> 24) - NX_IP_NORMAL_LENGTH) & 0xFF) * (ULONG)sizeof(ULONG);
while (index < ip_option_length)
{
op_type = *option_ptr;
switch (op_type)
{
case NX_IP_OPTION_END:
{
return(NX_TRUE);
...}case NX_IP_OPTION_END:
case NX_IP_OPTION_NO_OPERATION:
{
option_ptr++;
index++;
continue;
...}case NX_IP_OPTION_NO_OPERATION:
case NX_IP_OPTION_INTERNET_TIMESTAMP:
{
op_timestamp_counter++;
if (op_timestamp_counter > 1)
{
#ifndef NX_DISABLE_ICMPV4_ERROR_MESSAGE
NX_ICMPV4_SEND_PARAMETER_PROBLEM(ip_ptr, packet_ptr, NX_ICMP_ZERO_CODE, (ip_normal_length + index + 2));/* ... */
#endif
return(NX_FALSE);
}if (op_timestamp_counter > 1) { ... }
op_length = *(option_ptr + 1);
op_timestamp_offset = *(option_ptr + 2);
op_timestamp_overflow = (*(option_ptr + 3)) >> 4;
op_timestamp_flags = (*(option_ptr + 3)) & 0xF;
if ((op_length < 8) || (op_length > 40) || ((op_length % 4) != 0))
{
#ifndef NX_DISABLE_ICMPV4_ERROR_MESSAGE
NX_ICMPV4_SEND_PARAMETER_PROBLEM(ip_ptr, packet_ptr, NX_ICMP_ZERO_CODE, (ip_normal_length + index + 2));/* ... */
#endif
return(NX_FALSE);
}if ((op_length < 8) || (op_length > 40) || ((op_length % 4) != 0)) { ... }
if ((op_timestamp_offset < 5) || ((op_timestamp_offset % 2) == 0))
{
#ifndef NX_DISABLE_ICMPV4_ERROR_MESSAGE
NX_ICMPV4_SEND_PARAMETER_PROBLEM(ip_ptr, packet_ptr, NX_ICMP_ZERO_CODE, (ip_normal_length + index + 3));/* ... */
#endif
return(NX_FALSE);
}if ((op_timestamp_offset < 5) || ((op_timestamp_offset % 2) == 0)) { ... }
if (op_timestamp_overflow == 15)
{
#ifndef NX_DISABLE_ICMPV4_ERROR_MESSAGE
NX_ICMPV4_SEND_PARAMETER_PROBLEM(ip_ptr, packet_ptr, NX_ICMP_ZERO_CODE, (ip_normal_length + index + 4));/* ... */
#endif
return(NX_FALSE);
}if (op_timestamp_overflow == 15) { ... }
if ((op_timestamp_flags != 0) && (op_timestamp_flags != 1) && (op_timestamp_flags != 3))
{
#ifndef NX_DISABLE_ICMPV4_ERROR_MESSAGE
NX_ICMPV4_SEND_PARAMETER_PROBLEM(ip_ptr, packet_ptr, NX_ICMP_ZERO_CODE, (ip_normal_length + index + 4));/* ... */
#endif
return(NX_FALSE);
}if ((op_timestamp_flags != 0) && (op_timestamp_flags != 1) && (op_timestamp_flags != 3)) { ... }
break;
...}case NX_IP_OPTION_INTERNET_TIMESTAMP:
default:
break;default
}switch (op_type) { ... }
op_length = *(option_ptr + 1);
/* ... */
if ((op_length < 2) || ((index + op_length) > ip_option_length))
{
return(NX_FALSE);
}if ((op_length < 2) || ((index + op_length) > ip_option_length)) { ... }
option_ptr += op_length;
index += op_length;
}while (index < ip_option_length) { ... }
return(NX_TRUE);
}{ ... }
#endif/* ... */