1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
// This file is part of network. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/network/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2017 The developers of network. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/network/master/COPYRIGHT.
/// Captures the reason and salient data for dropping with a packet earlier than might be expected.
///
/// This reason is reported immediately before the underlying packet is dropped, at which point all referenced data will no longer exist.
///
/// Salient data is by its nature unlikely to always be completely valid, and should be used only as a source of raw bytes.
#[derive(Debug)]
#[derive(Serialize)]
pub enum InternetProtocolVersion4IncomingNetworkPacketDropReason<ICMPV4INPDR: IncomingNetworkPacketProcessingDropReason, TCPINPDR: IncomingNetworkPacketProcessingDropReason, UDPINPDR: IncomingNetworkPacketProcessingDropReason>
{
/// Packet is too short.
PacketIsTooShort,
/// Header is not version 4.
HeaderIsNot4
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Total Length field is invalid.
TotalLengthInvalid
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Expected total length.
layer_3_length: u16,
},
/// Only occurs if the feature `drop-ipv4-packets-with-do-not-fragment-and-non-zero-identification` is configured.
InvalidFragmentationFlagsOrIdentification
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Internet Control Message Protocol (ICMP) version 4 packets sent over Internet Protocol (IP) version 4 should not be fragmented.
InternetControlMessageProtocolVersion4PacketsShouldNotBeFragmented
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Unsupported layer 4 protocol.
UnsupportedLayer4Protocol
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Unsupported layer 4 protocol.
unsupported_layer_4_protocol: u8,
},
/// Total length field is less than the length of the header.
TotalLengthLessThanHeader
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is configured.
HasOptions
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Only occurs if the feature ``drop-packets-with-ipv4-options-lacking-zero-padding` is configured and the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// The end of the options list was not zero-padded.
OptionsWereNotZeroPadded
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// These options are considered obsolete by RFC 7126 and so are dropped; there is no good reason for an end-host to receive them.
///
/// * Stream Identifier (SID) (Type = 136).
/// * Probe MTU (MTUP) (Type = 11).
/// * Reply MTU (MTUR) (Type = 12).
/// * Traceroute (TR) (Type = 82) (actually as of RFC 6814).
/// * Experimental Access Control (VISA) (Type = 142) (actually as of RFC 6814).
/// * Extended Internet Protocol (EIP) (Type = 145) (actually as of RFC 6814).
/// * Address Extension (ADDEXT) (Type = 147) (actually as of RFC 6814).
/// * Sender Directed Multi-Destination Delivery (SDB) (Type = 149) (actually as of RFC 6814); also known as Selective Directed Broadcast.
/// * Dynamic Packet State (DPS) (Type = 151) (actually as of RFC 6814).
/// * Upstream Multicast Packet (UMP) (Type = 152) (actually as of RFC 6814).
/// * ENCODE (ENCODE) (Type = 15) (actually as of RFC 6814).
OptionIsObsoleteAsOfRfc7126
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// These options are considered threats by RFC 7126 and so are dropped; there is no good reason for an end-host to receive them.
///
/// * Loose Source and Record Route (LSRR or LSR) (Type = 131).
/// * Strict Source and Record Route (SSRR or SSR) (Type = 137).
/// * Record Route (RR) (Type = 7).
/// * Internet Timestamp (TS) (Type = 68).
/// * Router Alert (RTRALT) (Type = 148).
/// * Quick-Start (QS) (Type = 25).
OptionIsThreatAsOfRfc7126
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// The RFC 3692 style Experimental (EXP) options (Type = 30, 94, 158 or 222) as defined in RFC 4727 should not be seen on the internet.
OptionIsExperimental
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// As of RFC 7126 these options are admissable but highly unlikely in modern scenarios.
///
/// * DoD Basic Security (SEC) (Type = 130).
/// * DoD Extended Security (E-SEC) (Type = 133).
/// * Commercial IP Security (CIPSO) (Type = 134).
OptionIsSecurity
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// These are rarely encountered options registered with [IANA](https://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ip-parameters-1) but not deprecated or obsoleted as yet.
///
/// Strictly speaking, we are not supposed to drop them but given they are extremely obscure it seems wise to do so.
///
/// * Experimental Measurement (ZSU) (Type = 10).
/// * Experimental Flow Control (FINN) (Type = 205).
/// * IMI Traffic Descriptor (IMITD) (Type = 144).
/// * (Name not known) (Type = 150) (unassigned but previously in use until 2005).
OptionIsRarelyEncounteredButRegisteredAtIana
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// Checks to see if an unknown option which should not be copied onto fragments is on a fragment.
///
/// There is no good reason to receive data in this situation.
///
/// This is rarely-encountered drop reason, as it only occurs after checking to see if an option kind is acceptable.
OptionShouldNotBePresentOnFragments
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// Checks to see if an unknown option is using a reserved class (1 and 3 are reserved).
///
/// There is no good reason to receive data with this option kind.
///
/// This is rarely-encountered drop reason, as it only occurs after checking to see if an option kind is acceptable.
OptionHasReservedClass
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// Checks to see if an unknown option is actually one with an assigned (or previously assigned) number but with different copy or class bits.
///
/// There is no good reason to receive data with this option kind.
///
/// This is rarely-encountered drop reason, as it only occurs after checking to see if an option kind is acceptable.
OptionIsAssignedOrPreviouslyAssignedWithDifferentCopyOrClassBits
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// Checks to see if an option is a duplicate.
///
/// Duplicates are considered based on the five-bit `number` field of the option_kind.
///
/// This is rarely-encountered drop reason, as it only occurs after checking to see if an option kind is acceptable.
OptionIsDuplicate
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// An option lacks the `length` field.
///
/// This is rarely-encountered drop reason, as it only occurs after checking to see if an option kind is acceptable.
OptionLacksLength
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// An option has a `length` field which is too short.
///
/// This is rarely-encountered drop reason, as it only occurs after checking to see if an option kind is acceptable.
OptionLengthTooShort
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Only occurs if the feature `drop-packets-with-ipv4-options` is *not* configured.
///
/// An option has a `length` field which is too long.
///
/// This is rarely-encountered drop reason, as it only occurs after checking to see if an option kind is acceptable.
OptionLengthTooLong
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Option kind.
option_kind: InternetProtocolVersion4OptionKind,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
///
/// Received a packet which did not have its Internet Protocol (IP) version 4 check sum validated in hardware and which, when calculated in software, was invalid.
InternetProtocolCheckSumWhenCalculatedInSoftwareWasInvalid
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
///
/// Received a packet with a source address that was the same as the destination address.
SourceAndDestinationAddressAreTheSame
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
///
/// Received a packet with a source address that was an invalid unicast address when the protocol was Internet Control Message Protocol (ICMP) or Transmission Control Protocol (TCP).
///
/// This can include the loopback, unspecified ('any'), broadcast and documentation addresses.
SourceAddressNotValidUnicast
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
///
/// Received a packet with a source address that was an invalid unicast address or was not the unspecified (any) address (0.0.0.0) when the protocol was User Datagram Protocol (UDP).
///
/// This can include the loopback, unspecified ('any'), broadcast and documentation addresses.
SourceAddressNotValidUnicastOrUnspecified
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
///
/// Received a packet with a source address that was denied (eg banned, firewalled).
SourceAddressDenied
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
///
/// Received a unicast packet to a destination that isn't us.
UnicastDestinationIsNotUs
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
///
/// Received an ethernet broadcast but the packet's destination address was not broadcast.
EthernetBroadcastNotInternetBroadcast
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
EthernetAddressWasNotUnicast
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
MulticastAddressIsNotMulticast
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
MulticastAddressMismatchesEthernetAddress
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
MulticastAddressDenied
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Occurs during Internet Protocol (IP) version 4 packet processing.
DestinationWasLoopbackOrDocumentationAddress
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
},
/// Wrapper around a problematic Internet Control Message Protocol (ICMP) version 4 packet.
ProblematicInternetControlMessageProtocolVersion4Packet
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Reason
reason: ICMPV4INPDR,
},
/// Wrapper around a problematic Transmission Control Protocol (TCP) packet.
ProblematicTransmissionControlProtocolPacket
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Reason
reason: TCPINPDR,
},
/// Wrapper around a problematic User Datagram Protocol (UDP) packet.
ProblematicUserDatagramProtocolPacket
{
/// Internet Protocol (IP) version 4 packet header.
#[serde(serialize_with = "InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null")]
header: NonNull<InternetProtocolVersion4PacketHeader>,
/// Reason
reason: UDPINPDR,
},
}
impl<ICMPV4INPDR: IncomingNetworkPacketProcessingDropReason, TCPINPDR: IncomingNetworkPacketProcessingDropReason, UDPINPDR: IncomingNetworkPacketProcessingDropReason> IncomingNetworkPacketProcessingDropReason for InternetProtocolVersion4IncomingNetworkPacketDropReason<ICMPV4INPDR, TCPINPDR, UDPINPDR>
{
}
#[allow(non_snake_case)]
#[inline(always)]
fn InternetProtocolVersion4IncomingNetworkPacketDropReason_serialize_non_null<S: Serializer>(to_serialize: &NonNull<InternetProtocolVersion4PacketHeader>, serializer: S) -> Result<S::Ok, S::Error>
{
unsafe { to_serialize.as_ref().serialize(serializer) }
}