packet_formats/
testdata.rs

1// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5//! Data for testing parsing and serialization.
6//!
7//! This data was obtained by capturing live network traffic.
8
9use net_types::ethernet::Mac;
10use net_types::ip::{Ipv4Addr, Ipv6Addr};
11
12use crate::ethernet::EtherType;
13use crate::ip::{IpProto, Ipv4Proto};
14use crate::ipv4::Ipv4FragmentType;
15use crate::testutil::{
16    EthernetFrameMetadata, Ipv4PacketMetadata, Ipv6PacketMetadata, TcpSegmentMetadata, TestPacket,
17    UdpPacketMetadata,
18};
19
20/// An ARP Broadcast request in an Ethernet frame.
21pub mod arp_request {
22    #![allow(missing_docs)]
23
24    use super::*;
25    use crate::arp::ArpOp;
26
27    pub const ETHERNET_FRAME: TestPacket<EthernetFrameMetadata> = TestPacket {
28        bytes: &[
29            0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x14, 0xab, 0xc5, 0x74, 0x20, 0x34, 0x08, 0x06,
30            0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x14, 0xab, 0xc5, 0x74, 0x20, 0x34,
31            0xac, 0x10, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x10, 0x02, 0x1b,
32            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33            0x00, 0x00, 0x00, 0x00,
34        ],
35        metadata: EthernetFrameMetadata {
36            src_mac: Mac::new([20, 171, 197, 116, 32, 52]),
37            dst_mac: Mac::new([255, 255, 255, 255, 255, 255]),
38            ethertype: Some(EtherType::Arp),
39        },
40        body_range: 14..60,
41    };
42
43    pub const ARP_OPERATION: ArpOp = ArpOp::Request;
44}
45
46/// A DNS request.
47///
48/// An Ethernet frame containing an IPv4 packet containing a UDP packet
49/// containing a DNS request for 0.docs.google.com.
50pub mod dns_request_v4 {
51    #![allow(missing_docs)]
52
53    use crate::ip::DscpAndEcn;
54
55    use super::*;
56
57    pub const ETHERNET_FRAME: TestPacket<EthernetFrameMetadata> = TestPacket {
58        bytes: &[
59            0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c, 0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02, 0x08, 0x00,
60            0x45, 0x00, 0x00, 0x3f, 0x17, 0xf1, 0x00, 0x00, 0x40, 0x11, 0xdf, 0x5c, 0xc0, 0xa8,
61            0x01, 0x0f, 0xc0, 0xa8, 0x01, 0x01, 0x8b, 0x4a, 0x00, 0x35, 0x00, 0x2b, 0x07, 0xf7,
62            0x47, 0xb5, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x30,
63            0x04, 0x64, 0x6f, 0x63, 0x73, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63,
64            0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01,
65        ],
66        metadata: EthernetFrameMetadata {
67            src_mac: Mac::new([0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02]),
68            dst_mac: Mac::new([0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c]),
69            ethertype: Some(EtherType::Ipv4),
70        },
71        body_range: 14..77,
72    };
73
74    pub const IPV4_PACKET: TestPacket<Ipv4PacketMetadata> = TestPacket {
75        bytes: &[
76            0x45, 0x00, 0x00, 0x3f, 0x17, 0xf1, 0x00, 0x00, 0x40, 0x11, 0xdf, 0x5c, 0xc0, 0xa8,
77            0x01, 0x0f, 0xc0, 0xa8, 0x01, 0x01, 0x8b, 0x4a, 0x00, 0x35, 0x00, 0x2b, 0x07, 0xf7,
78            0x47, 0xb5, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x30,
79            0x04, 0x64, 0x6f, 0x63, 0x73, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63,
80            0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01,
81        ],
82        metadata: Ipv4PacketMetadata {
83            dscp_and_ecn: DscpAndEcn::default(),
84            dont_fragment: false,
85            more_fragments: false,
86            fragment_offset: 0,
87            fragment_type: Ipv4FragmentType::InitialFragment,
88            id: 0x17f1,
89            ttl: 64,
90            proto: Ipv4Proto::Proto(IpProto::Udp),
91            src_ip: Ipv4Addr::new([192, 168, 1, 15]),
92            dst_ip: Ipv4Addr::new([192, 168, 1, 1]),
93        },
94        body_range: 20..63,
95    };
96
97    pub const UDP_PACKET: TestPacket<UdpPacketMetadata> = TestPacket {
98        bytes: &[
99            0x8b, 0x4a, 0x00, 0x35, 0x00, 0x2b, 0x07, 0xf7, 0x47, 0xb5, 0x01, 0x00, 0x00, 0x01,
100            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x30, 0x04, 0x64, 0x6f, 0x63, 0x73, 0x06,
101            0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00,
102            0x01,
103        ],
104        metadata: UdpPacketMetadata { src_port: 35658, dst_port: 53 },
105        body_range: 8..43,
106    };
107}
108
109/// A TLS Client Hello message.
110///
111/// An Ethernet frame containing an IPv4 packet containing a TCP segment
112/// containing a TLSv1.2 Client Hello message.
113pub mod tls_client_hello_v4 {
114    #![allow(missing_docs)]
115
116    use super::*;
117
118    use crate::ip::DscpAndEcn;
119    use crate::tcp::options::{TcpOptionsBuilder, TimestampOption};
120
121    pub const ETHERNET_FRAME: TestPacket<EthernetFrameMetadata> = TestPacket {
122        bytes: &[
123            0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c, 0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02, 0x08, 0x00,
124            0x45, 0x00, 0x02, 0x41, 0x00, 0x00, 0x40, 0x00, 0x40, 0x06, 0x4f, 0x11, 0xc0, 0xa8,
125            0x01, 0x0f, 0x68, 0xed, 0xbf, 0x01, 0xc6, 0x54, 0x01, 0xbb, 0x3a, 0x0b, 0xbd, 0x40,
126            0x10, 0x4f, 0xb6, 0xd2, 0x80, 0x18, 0x10, 0x0a, 0x92, 0x13, 0x00, 0x00, 0x01, 0x01,
127            0x08, 0x0a, 0x26, 0x6d, 0xbe, 0x25, 0xb0, 0x6f, 0xf5, 0xde, 0x16, 0x03, 0x01, 0x02,
128            0x08, 0x01, 0x00, 0x02, 0x04, 0x03, 0x03, 0x0f, 0x88, 0xf6, 0x67, 0x08, 0x84, 0x41,
129            0xa3, 0xbf, 0x0b, 0x7c, 0x61, 0xd7, 0x57, 0x58, 0xa9, 0x5e, 0x77, 0xee, 0x0c, 0x5f,
130            0x4a, 0x45, 0xc7, 0xa1, 0xf6, 0x15, 0xb6, 0x56, 0x07, 0xb8, 0x52, 0x20, 0x97, 0x9d,
131            0xfe, 0x16, 0x1d, 0x32, 0x59, 0x74, 0xbd, 0x5a, 0x68, 0xcf, 0xe7, 0x44, 0x48, 0x67,
132            0x87, 0x33, 0xc7, 0x84, 0x1b, 0xf1, 0xee, 0xdd, 0x62, 0x7e, 0x88, 0xd3, 0x80, 0x05,
133            0x36, 0xcd, 0x00, 0x22, 0xba, 0xba, 0x13, 0x01, 0x13, 0x02, 0x13, 0x03, 0xc0, 0x2b,
134            0xc0, 0x2f, 0xc0, 0x2c, 0xc0, 0x30, 0xcc, 0xa9, 0xcc, 0xa8, 0xc0, 0x13, 0xc0, 0x14,
135            0x00, 0x9c, 0x00, 0x9d, 0x00, 0x2f, 0x00, 0x35, 0x00, 0x0a, 0x01, 0x00, 0x01, 0x99,
136            0x2a, 0x2a, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00,
137            0x14, 0x00, 0x00, 0x11, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x73, 0x35, 0x2e, 0x67,
138            0x76, 0x74, 0x33, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x17, 0x00, 0x00, 0x00, 0x23, 0x00,
139            0xda, 0x00, 0x9c, 0x63, 0xc8, 0x43, 0x0e, 0x35, 0x05, 0x52, 0x2f, 0x0e, 0x93, 0xcb,
140            0x36, 0x0d, 0x72, 0x93, 0xab, 0x88, 0xe6, 0xc3, 0x74, 0x7e, 0x9f, 0xd0, 0x48, 0xf8,
141            0x11, 0x0f, 0xab, 0x40, 0x2e, 0x64, 0x43, 0x96, 0xf4, 0xea, 0x37, 0xcb, 0x1b, 0x12,
142            0xf5, 0xa4, 0xbb, 0x41, 0xad, 0x1d, 0x1c, 0x16, 0xb5, 0xea, 0xae, 0x77, 0x4f, 0x83,
143            0x8f, 0xd7, 0x39, 0x02, 0x20, 0xdf, 0xfc, 0x0f, 0xc4, 0x27, 0x75, 0xc6, 0x83, 0xf4,
144            0x9e, 0xcd, 0xea, 0xc2, 0x0e, 0x31, 0x25, 0xdb, 0xdf, 0x43, 0x4b, 0x0a, 0x4b, 0x47,
145            0xdc, 0xd5, 0x6c, 0x60, 0x38, 0xe4, 0x41, 0x25, 0xfa, 0xd9, 0xb0, 0xa3, 0x6f, 0xa1,
146            0x48, 0xca, 0x0d, 0xb0, 0xfb, 0x4e, 0xee, 0xdd, 0xce, 0xd1, 0xc4, 0x0f, 0xf3, 0x20,
147            0xa1, 0x4f, 0x99, 0xd5, 0x56, 0x11, 0xe6, 0x5d, 0x3d, 0x03, 0xc1, 0x8b, 0x64, 0x64,
148            0xf9, 0x69, 0xca, 0xe7, 0x68, 0x81, 0x18, 0xd2, 0xb1, 0x93, 0x0f, 0x06, 0x99, 0xb4,
149            0xc1, 0x76, 0xd8, 0x0d, 0x2f, 0x57, 0x7f, 0xdf, 0x24, 0x60, 0xbd, 0x1d, 0x84, 0x96,
150            0xa5, 0xc3, 0x6b, 0x0c, 0xc2, 0x6f, 0x56, 0x08, 0x4a, 0x6f, 0xc4, 0x5d, 0x62, 0x49,
151            0xd9, 0xfe, 0xee, 0x40, 0x9e, 0xbc, 0x89, 0x3e, 0xb2, 0x6a, 0xe3, 0x41, 0x15, 0xa5,
152            0x85, 0x02, 0xb6, 0x5d, 0xa2, 0xd8, 0x92, 0x41, 0x8a, 0x0c, 0xbd, 0xea, 0x8f, 0x12,
153            0xf1, 0x43, 0x99, 0x9e, 0x17, 0x90, 0xc1, 0xe0, 0xde, 0xb2, 0xc2, 0x40, 0xa3, 0x5f,
154            0x31, 0xab, 0x41, 0x88, 0xb5, 0xe5, 0xd5, 0x54, 0xe5, 0x00, 0x0d, 0x00, 0x14, 0x00,
155            0x12, 0x04, 0x03, 0x08, 0x04, 0x04, 0x01, 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08,
156            0x06, 0x06, 0x01, 0x02, 0x01, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00,
157            0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x0c, 0x02, 0x68, 0x32, 0x08,
158            0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00,
159            0x00, 0x33, 0x00, 0x2b, 0x00, 0x29, 0x9a, 0x9a, 0x00, 0x01, 0x00, 0x00, 0x1d, 0x00,
160            0x20, 0xb8, 0x47, 0xb2, 0xfa, 0xcc, 0xff, 0x2d, 0xf3, 0xf8, 0x12, 0xc1, 0xd9, 0xe7,
161            0x68, 0x72, 0xa1, 0xb2, 0xcd, 0x31, 0x15, 0x8c, 0xad, 0x11, 0xf7, 0x29, 0x8e, 0x3d,
162            0xa8, 0x14, 0x86, 0x37, 0x56, 0x00, 0x2d, 0x00, 0x02, 0x01, 0x01, 0x00, 0x2b, 0x00,
163            0x0b, 0x0a, 0x1a, 0x1a, 0x7f, 0x17, 0x03, 0x03, 0x03, 0x02, 0x03, 0x01, 0x00, 0x0a,
164            0x00, 0x0a, 0x00, 0x08, 0x9a, 0x9a, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x3a, 0x3a,
165            0x00, 0x01, 0x00,
166        ],
167        metadata: EthernetFrameMetadata {
168            src_mac: Mac::new([0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02]),
169            dst_mac: Mac::new([0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c]),
170            ethertype: Some(EtherType::Ipv4),
171        },
172        body_range: 14..591,
173    };
174
175    pub const IPV4_PACKET: TestPacket<Ipv4PacketMetadata> = TestPacket {
176        bytes: &[
177            0x45, 0x00, 0x02, 0x41, 0x00, 0x00, 0x40, 0x00, 0x40, 0x06, 0x4f, 0x11, 0xc0, 0xa8,
178            0x01, 0x0f, 0x68, 0xed, 0xbf, 0x01, 0xc6, 0x54, 0x01, 0xbb, 0x3a, 0x0b, 0xbd, 0x40,
179            0x10, 0x4f, 0xb6, 0xd2, 0x80, 0x18, 0x10, 0x0a, 0x92, 0x13, 0x00, 0x00, 0x01, 0x01,
180            0x08, 0x0a, 0x26, 0x6d, 0xbe, 0x25, 0xb0, 0x6f, 0xf5, 0xde, 0x16, 0x03, 0x01, 0x02,
181            0x08, 0x01, 0x00, 0x02, 0x04, 0x03, 0x03, 0x0f, 0x88, 0xf6, 0x67, 0x08, 0x84, 0x41,
182            0xa3, 0xbf, 0x0b, 0x7c, 0x61, 0xd7, 0x57, 0x58, 0xa9, 0x5e, 0x77, 0xee, 0x0c, 0x5f,
183            0x4a, 0x45, 0xc7, 0xa1, 0xf6, 0x15, 0xb6, 0x56, 0x07, 0xb8, 0x52, 0x20, 0x97, 0x9d,
184            0xfe, 0x16, 0x1d, 0x32, 0x59, 0x74, 0xbd, 0x5a, 0x68, 0xcf, 0xe7, 0x44, 0x48, 0x67,
185            0x87, 0x33, 0xc7, 0x84, 0x1b, 0xf1, 0xee, 0xdd, 0x62, 0x7e, 0x88, 0xd3, 0x80, 0x05,
186            0x36, 0xcd, 0x00, 0x22, 0xba, 0xba, 0x13, 0x01, 0x13, 0x02, 0x13, 0x03, 0xc0, 0x2b,
187            0xc0, 0x2f, 0xc0, 0x2c, 0xc0, 0x30, 0xcc, 0xa9, 0xcc, 0xa8, 0xc0, 0x13, 0xc0, 0x14,
188            0x00, 0x9c, 0x00, 0x9d, 0x00, 0x2f, 0x00, 0x35, 0x00, 0x0a, 0x01, 0x00, 0x01, 0x99,
189            0x2a, 0x2a, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00,
190            0x14, 0x00, 0x00, 0x11, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x73, 0x35, 0x2e, 0x67,
191            0x76, 0x74, 0x33, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x17, 0x00, 0x00, 0x00, 0x23, 0x00,
192            0xda, 0x00, 0x9c, 0x63, 0xc8, 0x43, 0x0e, 0x35, 0x05, 0x52, 0x2f, 0x0e, 0x93, 0xcb,
193            0x36, 0x0d, 0x72, 0x93, 0xab, 0x88, 0xe6, 0xc3, 0x74, 0x7e, 0x9f, 0xd0, 0x48, 0xf8,
194            0x11, 0x0f, 0xab, 0x40, 0x2e, 0x64, 0x43, 0x96, 0xf4, 0xea, 0x37, 0xcb, 0x1b, 0x12,
195            0xf5, 0xa4, 0xbb, 0x41, 0xad, 0x1d, 0x1c, 0x16, 0xb5, 0xea, 0xae, 0x77, 0x4f, 0x83,
196            0x8f, 0xd7, 0x39, 0x02, 0x20, 0xdf, 0xfc, 0x0f, 0xc4, 0x27, 0x75, 0xc6, 0x83, 0xf4,
197            0x9e, 0xcd, 0xea, 0xc2, 0x0e, 0x31, 0x25, 0xdb, 0xdf, 0x43, 0x4b, 0x0a, 0x4b, 0x47,
198            0xdc, 0xd5, 0x6c, 0x60, 0x38, 0xe4, 0x41, 0x25, 0xfa, 0xd9, 0xb0, 0xa3, 0x6f, 0xa1,
199            0x48, 0xca, 0x0d, 0xb0, 0xfb, 0x4e, 0xee, 0xdd, 0xce, 0xd1, 0xc4, 0x0f, 0xf3, 0x20,
200            0xa1, 0x4f, 0x99, 0xd5, 0x56, 0x11, 0xe6, 0x5d, 0x3d, 0x03, 0xc1, 0x8b, 0x64, 0x64,
201            0xf9, 0x69, 0xca, 0xe7, 0x68, 0x81, 0x18, 0xd2, 0xb1, 0x93, 0x0f, 0x06, 0x99, 0xb4,
202            0xc1, 0x76, 0xd8, 0x0d, 0x2f, 0x57, 0x7f, 0xdf, 0x24, 0x60, 0xbd, 0x1d, 0x84, 0x96,
203            0xa5, 0xc3, 0x6b, 0x0c, 0xc2, 0x6f, 0x56, 0x08, 0x4a, 0x6f, 0xc4, 0x5d, 0x62, 0x49,
204            0xd9, 0xfe, 0xee, 0x40, 0x9e, 0xbc, 0x89, 0x3e, 0xb2, 0x6a, 0xe3, 0x41, 0x15, 0xa5,
205            0x85, 0x02, 0xb6, 0x5d, 0xa2, 0xd8, 0x92, 0x41, 0x8a, 0x0c, 0xbd, 0xea, 0x8f, 0x12,
206            0xf1, 0x43, 0x99, 0x9e, 0x17, 0x90, 0xc1, 0xe0, 0xde, 0xb2, 0xc2, 0x40, 0xa3, 0x5f,
207            0x31, 0xab, 0x41, 0x88, 0xb5, 0xe5, 0xd5, 0x54, 0xe5, 0x00, 0x0d, 0x00, 0x14, 0x00,
208            0x12, 0x04, 0x03, 0x08, 0x04, 0x04, 0x01, 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08,
209            0x06, 0x06, 0x01, 0x02, 0x01, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00,
210            0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x0c, 0x02, 0x68, 0x32, 0x08,
211            0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00,
212            0x00, 0x33, 0x00, 0x2b, 0x00, 0x29, 0x9a, 0x9a, 0x00, 0x01, 0x00, 0x00, 0x1d, 0x00,
213            0x20, 0xb8, 0x47, 0xb2, 0xfa, 0xcc, 0xff, 0x2d, 0xf3, 0xf8, 0x12, 0xc1, 0xd9, 0xe7,
214            0x68, 0x72, 0xa1, 0xb2, 0xcd, 0x31, 0x15, 0x8c, 0xad, 0x11, 0xf7, 0x29, 0x8e, 0x3d,
215            0xa8, 0x14, 0x86, 0x37, 0x56, 0x00, 0x2d, 0x00, 0x02, 0x01, 0x01, 0x00, 0x2b, 0x00,
216            0x0b, 0x0a, 0x1a, 0x1a, 0x7f, 0x17, 0x03, 0x03, 0x03, 0x02, 0x03, 0x01, 0x00, 0x0a,
217            0x00, 0x0a, 0x00, 0x08, 0x9a, 0x9a, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x3a, 0x3a,
218            0x00, 0x01, 0x00,
219        ],
220        metadata: Ipv4PacketMetadata {
221            id: 0,
222            dscp_and_ecn: DscpAndEcn::default(),
223            dont_fragment: true,
224            more_fragments: false,
225            fragment_offset: 0,
226            fragment_type: Ipv4FragmentType::InitialFragment,
227            ttl: 64,
228            proto: Ipv4Proto::Proto(IpProto::Tcp),
229            src_ip: Ipv4Addr::new([192, 168, 1, 15]),
230            dst_ip: Ipv4Addr::new([104, 237, 191, 1]),
231        },
232        body_range: 20..577,
233    };
234
235    pub const TCP_SEGMENT: TestPacket<TcpSegmentMetadata> = TestPacket {
236        bytes: &[
237            0xc6, 0x54, 0x01, 0xbb, 0x3a, 0x0b, 0xbd, 0x40, 0x10, 0x4f, 0xb6, 0xd2, 0x80, 0x18,
238            0x10, 0x0a, 0x92, 0x13, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x26, 0x6d, 0xbe, 0x25,
239            0xb0, 0x6f, 0xf5, 0xde, 0x16, 0x03, 0x01, 0x02, 0x08, 0x01, 0x00, 0x02, 0x04, 0x03,
240            0x03, 0x0f, 0x88, 0xf6, 0x67, 0x08, 0x84, 0x41, 0xa3, 0xbf, 0x0b, 0x7c, 0x61, 0xd7,
241            0x57, 0x58, 0xa9, 0x5e, 0x77, 0xee, 0x0c, 0x5f, 0x4a, 0x45, 0xc7, 0xa1, 0xf6, 0x15,
242            0xb6, 0x56, 0x07, 0xb8, 0x52, 0x20, 0x97, 0x9d, 0xfe, 0x16, 0x1d, 0x32, 0x59, 0x74,
243            0xbd, 0x5a, 0x68, 0xcf, 0xe7, 0x44, 0x48, 0x67, 0x87, 0x33, 0xc7, 0x84, 0x1b, 0xf1,
244            0xee, 0xdd, 0x62, 0x7e, 0x88, 0xd3, 0x80, 0x05, 0x36, 0xcd, 0x00, 0x22, 0xba, 0xba,
245            0x13, 0x01, 0x13, 0x02, 0x13, 0x03, 0xc0, 0x2b, 0xc0, 0x2f, 0xc0, 0x2c, 0xc0, 0x30,
246            0xcc, 0xa9, 0xcc, 0xa8, 0xc0, 0x13, 0xc0, 0x14, 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x2f,
247            0x00, 0x35, 0x00, 0x0a, 0x01, 0x00, 0x01, 0x99, 0x2a, 0x2a, 0x00, 0x00, 0xff, 0x01,
248            0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x14, 0x00, 0x00, 0x11, 0x62, 0x65,
249            0x61, 0x63, 0x6f, 0x6e, 0x73, 0x35, 0x2e, 0x67, 0x76, 0x74, 0x33, 0x2e, 0x63, 0x6f,
250            0x6d, 0x00, 0x17, 0x00, 0x00, 0x00, 0x23, 0x00, 0xda, 0x00, 0x9c, 0x63, 0xc8, 0x43,
251            0x0e, 0x35, 0x05, 0x52, 0x2f, 0x0e, 0x93, 0xcb, 0x36, 0x0d, 0x72, 0x93, 0xab, 0x88,
252            0xe6, 0xc3, 0x74, 0x7e, 0x9f, 0xd0, 0x48, 0xf8, 0x11, 0x0f, 0xab, 0x40, 0x2e, 0x64,
253            0x43, 0x96, 0xf4, 0xea, 0x37, 0xcb, 0x1b, 0x12, 0xf5, 0xa4, 0xbb, 0x41, 0xad, 0x1d,
254            0x1c, 0x16, 0xb5, 0xea, 0xae, 0x77, 0x4f, 0x83, 0x8f, 0xd7, 0x39, 0x02, 0x20, 0xdf,
255            0xfc, 0x0f, 0xc4, 0x27, 0x75, 0xc6, 0x83, 0xf4, 0x9e, 0xcd, 0xea, 0xc2, 0x0e, 0x31,
256            0x25, 0xdb, 0xdf, 0x43, 0x4b, 0x0a, 0x4b, 0x47, 0xdc, 0xd5, 0x6c, 0x60, 0x38, 0xe4,
257            0x41, 0x25, 0xfa, 0xd9, 0xb0, 0xa3, 0x6f, 0xa1, 0x48, 0xca, 0x0d, 0xb0, 0xfb, 0x4e,
258            0xee, 0xdd, 0xce, 0xd1, 0xc4, 0x0f, 0xf3, 0x20, 0xa1, 0x4f, 0x99, 0xd5, 0x56, 0x11,
259            0xe6, 0x5d, 0x3d, 0x03, 0xc1, 0x8b, 0x64, 0x64, 0xf9, 0x69, 0xca, 0xe7, 0x68, 0x81,
260            0x18, 0xd2, 0xb1, 0x93, 0x0f, 0x06, 0x99, 0xb4, 0xc1, 0x76, 0xd8, 0x0d, 0x2f, 0x57,
261            0x7f, 0xdf, 0x24, 0x60, 0xbd, 0x1d, 0x84, 0x96, 0xa5, 0xc3, 0x6b, 0x0c, 0xc2, 0x6f,
262            0x56, 0x08, 0x4a, 0x6f, 0xc4, 0x5d, 0x62, 0x49, 0xd9, 0xfe, 0xee, 0x40, 0x9e, 0xbc,
263            0x89, 0x3e, 0xb2, 0x6a, 0xe3, 0x41, 0x15, 0xa5, 0x85, 0x02, 0xb6, 0x5d, 0xa2, 0xd8,
264            0x92, 0x41, 0x8a, 0x0c, 0xbd, 0xea, 0x8f, 0x12, 0xf1, 0x43, 0x99, 0x9e, 0x17, 0x90,
265            0xc1, 0xe0, 0xde, 0xb2, 0xc2, 0x40, 0xa3, 0x5f, 0x31, 0xab, 0x41, 0x88, 0xb5, 0xe5,
266            0xd5, 0x54, 0xe5, 0x00, 0x0d, 0x00, 0x14, 0x00, 0x12, 0x04, 0x03, 0x08, 0x04, 0x04,
267            0x01, 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, 0x02, 0x01, 0x00,
268            0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10,
269            0x00, 0x0e, 0x00, 0x0c, 0x02, 0x68, 0x32, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31,
270            0x2e, 0x31, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, 0x33, 0x00, 0x2b, 0x00, 0x29,
271            0x9a, 0x9a, 0x00, 0x01, 0x00, 0x00, 0x1d, 0x00, 0x20, 0xb8, 0x47, 0xb2, 0xfa, 0xcc,
272            0xff, 0x2d, 0xf3, 0xf8, 0x12, 0xc1, 0xd9, 0xe7, 0x68, 0x72, 0xa1, 0xb2, 0xcd, 0x31,
273            0x15, 0x8c, 0xad, 0x11, 0xf7, 0x29, 0x8e, 0x3d, 0xa8, 0x14, 0x86, 0x37, 0x56, 0x00,
274            0x2d, 0x00, 0x02, 0x01, 0x01, 0x00, 0x2b, 0x00, 0x0b, 0x0a, 0x1a, 0x1a, 0x7f, 0x17,
275            0x03, 0x03, 0x03, 0x02, 0x03, 0x01, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x9a, 0x9a,
276            0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x3a, 0x3a, 0x00, 0x01, 0x00,
277        ],
278        metadata: TcpSegmentMetadata {
279            src_port: 50772,
280            dst_port: 443,
281            seq_num: 0x3a0bbd40,
282            ack_num: Some(0x104fb6d2),
283            flags: 0x018,
284            psh: true,
285            rst: false,
286            syn: false,
287            fin: false,
288            window_size: 4106,
289            options: TcpOptionsBuilder {
290                timestamp: Some(TimestampOption::new(644_726_309, 2_960_127_454)),
291                mss: None,
292                window_scale: None,
293                sack_permitted: false,
294                sack_blocks: None,
295            },
296        },
297        body_range: 32..557,
298    };
299}
300
301/// IPv6 DNS Request Packet.
302///
303/// An Ethernet frame containing an IPv6 packet containing a UDP datagram
304/// containing a DNS request for google.com.
305pub mod dns_request_v6 {
306    #![allow(missing_docs)]
307
308    use super::*;
309    use crate::ip::DscpAndEcn;
310
311    pub const ETHERNET_FRAME: TestPacket<EthernetFrameMetadata> = TestPacket {
312        bytes: &[
313            0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c, 0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02, 0x86, 0xdd,
314            0x60, 0x0e, 0xa5, 0x28, 0x00, 0x3b, 0x11, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
315            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x20, 0x01, 0x48, 0x60,
316            0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0xd9, 0xa1,
317            0x00, 0x35, 0x00, 0x3b, 0x02, 0xf8, 0xa6, 0xd9, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00,
318            0x00, 0x00, 0x00, 0x01, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f,
319            0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
320            0x00, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x08, 0x9f, 0x30, 0xaa, 0x16, 0x63, 0xd2, 0x09,
321            0x25,
322        ],
323        metadata: EthernetFrameMetadata {
324            src_mac: Mac::new([0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02]),
325            dst_mac: Mac::new([0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c]),
326            ethertype: Some(EtherType::Ipv6),
327        },
328        body_range: 14..113,
329    };
330
331    pub const IPV6_PACKET: TestPacket<Ipv6PacketMetadata> = TestPacket {
332        bytes: &[
333            0x60, 0x0e, 0xa5, 0x28, 0x00, 0x3b, 0x11, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
334            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x20, 0x01, 0x48, 0x60,
335            0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0xd9, 0xa1,
336            0x00, 0x35, 0x00, 0x3b, 0x02, 0xf8, 0xa6, 0xd9, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00,
337            0x00, 0x00, 0x00, 0x01, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f,
338            0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
339            0x00, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x08, 0x9f, 0x30, 0xaa, 0x16, 0x63, 0xd2, 0x09,
340            0x25,
341        ],
342        metadata: Ipv6PacketMetadata {
343            dscp_and_ecn: DscpAndEcn::default(),
344            flowlabel: 0xea528,
345            hop_limit: 64,
346            src_ip: Ipv6Addr::from_bytes([
347                0x26, 0x20, 0x00, 0x00, 0x10, 0x00, 0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21,
348                0x92, 0x15,
349            ]),
350            dst_ip: Ipv6Addr::from_bytes([
351                0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
352                0x88, 0x88,
353            ]),
354        },
355        body_range: 40..99,
356    };
357
358    pub const UDP_PACKET: TestPacket<UdpPacketMetadata> = TestPacket {
359        bytes: &[
360            0xd9, 0xa1, 0x00, 0x35, 0x00, 0x3b, 0x02, 0xf8, 0xa6, 0xd9, 0x01, 0x20, 0x00, 0x01,
361            0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03,
362            0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00,
363            0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x08, 0x9f, 0x30, 0xaa, 0x16, 0x63,
364            0xd2, 0x09, 0x25,
365        ],
366        metadata: UdpPacketMetadata { src_port: 55713, dst_port: 53 },
367        body_range: 8..59,
368    };
369}
370
371/// IPv6 TCP SYN Packet.
372///
373/// An Ethernet frame containing an IPv6 packet containing a TCP SYN segment
374/// with an empty body.
375pub mod syn_v6 {
376    #![allow(missing_docs)]
377
378    use super::*;
379
380    use crate::ip::DscpAndEcn;
381    use crate::tcp::options::{TcpOptionsBuilder, TimestampOption};
382
383    pub const ETHERNET_FRAME: TestPacket<EthernetFrameMetadata> = TestPacket {
384        bytes: &[
385            0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c, 0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02, 0x86, 0xdd,
386            0x60, 0x08, 0xc5, 0x5d, 0x00, 0x28, 0x06, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
387            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x26, 0x07, 0xf8, 0xb0,
388            0x40, 0x05, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x12, 0xa7, 0xac,
389            0x01, 0xbb, 0x1c, 0x68, 0x76, 0x8e, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x70, 0x80,
390            0x72, 0xcf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xa0, 0x04, 0x02, 0x08, 0x0a, 0xe7, 0x50,
391            0x11, 0x57, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07,
392        ],
393        metadata: EthernetFrameMetadata {
394            src_mac: Mac::new([0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02]),
395            dst_mac: Mac::new([0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c]),
396            ethertype: Some(EtherType::Ipv6),
397        },
398        body_range: 14..94,
399    };
400
401    pub const IPV6_PACKET: TestPacket<Ipv6PacketMetadata> = TestPacket {
402        bytes: &[
403            0x60, 0x08, 0xc5, 0x5d, 0x00, 0x28, 0x06, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
404            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x26, 0x07, 0xf8, 0xb0,
405            0x40, 0x05, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x12, 0xa7, 0xac,
406            0x01, 0xbb, 0x1c, 0x68, 0x76, 0x8e, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x70, 0x80,
407            0x72, 0xcf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xa0, 0x04, 0x02, 0x08, 0x0a, 0xe7, 0x50,
408            0x11, 0x57, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07,
409        ],
410        metadata: Ipv6PacketMetadata {
411            dscp_and_ecn: DscpAndEcn::default(),
412            flowlabel: 0x8c55d,
413            hop_limit: 64,
414            src_ip: Ipv6Addr::from_bytes([
415                0x26, 0x20, 0x00, 0x00, 0x10, 0x00, 0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21,
416                0x92, 0x15,
417            ]),
418            dst_ip: Ipv6Addr::from_bytes([
419                0x26, 0x07, 0xf8, 0xb0, 0x40, 0x05, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420                0x20, 0x12,
421            ]),
422        },
423        body_range: 40..80,
424    };
425
426    pub const TCP_SEGMENT: TestPacket<TcpSegmentMetadata> = TestPacket {
427        bytes: &[
428            0xa7, 0xac, 0x01, 0xbb, 0x1c, 0x68, 0x76, 0x8e, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,
429            0x70, 0x80, 0x72, 0xcf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xa0, 0x04, 0x02, 0x08, 0x0a,
430            0xe7, 0x50, 0x11, 0x57, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07,
431        ],
432        metadata: TcpSegmentMetadata {
433            src_port: 42924,
434            dst_port: 443,
435            ack_num: None,
436            flags: 0x002,
437            seq_num: 0x1c68768e,
438            window_size: 28800,
439            psh: false,
440            rst: false,
441            fin: false,
442            syn: true,
443            options: TcpOptionsBuilder {
444                mss: Some(1440),
445                sack_permitted: true,
446                timestamp: Some(TimestampOption::new(3_880_784_215, 0)),
447                window_scale: Some(7),
448                sack_blocks: None,
449            },
450        },
451        body_range: 40..40,
452    };
453}
454
455/// An ICMP echo reply in an IP packet in an Ethernet frame.
456pub mod icmp_echo_ethernet {
457    #![allow(missing_docs)]
458
459    pub const REPLY_ETHERNET_FRAME_BYTES: &[u8] = &[
460        0x8c, 0x85, 0x90, 0xc9, 0xc9, 0x00, 0x50, 0xc7, 0xbf, 0x1d, 0xf4, 0xd2, 0x08, 0x00, 0x45,
461        0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x35, 0x01, 0x11, 0x91, 0xac, 0xd9, 0x06, 0x2e,
462        0xc0, 0xa8, 0x00, 0x69, 0x00, 0x00, 0x01, 0x33, 0xb2, 0xa8, 0x00, 0x01, 0x5c, 0x68, 0x5c,
463        0x32, 0x00, 0x03, 0xa8, 0x82, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
464        0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
465        0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
466        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
467    ];
468}
469
470/// An ICMP echo request/response pair.
471///
472/// An IPv4 pair of packets containing ICMPv4 packets.
473pub mod icmp_echo {
474    #![allow(missing_docs)]
475
476    pub const REQUEST_IP_PACKET_BYTES: &[u8] = &[
477        0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0xa2, 0x80, 0x64, 0x4c, 0x3a,
478        0xd0, 0xd8, 0xef, 0x20, 0x1d, 0x08, 0x00, 0xee, 0x2b, 0x25, 0x8e, 0x00, 0x01, 0x21, 0x50,
479        0x24, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xd3, 0xc6, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
480        0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
481        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
482        0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
483    ];
484    pub const RESPONSE_IP_PACKET_BYTES: &[u8] = &[
485        0x45, 0x80, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x39, 0x01, 0xe9, 0x00, 0xd8, 0xef, 0x20,
486        0x1d, 0x64, 0x4c, 0x3a, 0xd0, 0x00, 0x00, 0xf6, 0x2b, 0x25, 0x8e, 0x00, 0x01, 0x21, 0x50,
487        0x24, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xd3, 0xc6, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
488        0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
489        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
490        0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
491    ];
492    pub const ECHO_DATA: &[u8] = &[
493        0x21, 0x50, 0x24, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xd3, 0xc6, 0x0c, 0x00, 0x00, 0x00, 0x00,
494        0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
495        0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
496        0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
497    ];
498    pub const IDENTIFIER: u16 = 9614;
499    pub const SEQUENCE_NUM: u16 = 1;
500}
501
502/// An ICMP echo request/response pair.
503///
504/// An IPv6 pair of packets containing ICMPv6 packets.
505pub mod icmp_echo_v6 {
506    #![allow(missing_docs)]
507
508    pub const REQUEST_IP_PACKET_BYTES: &[u8] = &[
509        0x60, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3a, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
510        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00,
511        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xe3, 0x13, 0x11,
512        0x0d, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
513        0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
514        0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
515        0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
516    ];
517    pub const ECHO_DATA: &[u8] = &[
518        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
519        0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
520        0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
521        0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
522    ];
523    pub const IDENTIFIER: u16 = 0x110d;
524    pub const SEQUENCE_NUM: u16 = 0;
525}
526
527/// An ICMP timestamp request/response pair.
528///
529/// An IPv4 pair of packets containing ICMPv6 packets.
530pub mod icmp_timestamp {
531    #![allow(missing_docs)]
532
533    pub const REQUEST_IP_PACKET_BYTES: &[u8] = &[
534        0x45, 0x00, 0x00, 0x28, 0x8d, 0xff, 0x00, 0x00, 0x80, 0x01, 0x2a, 0xb8, 0xc0, 0xa8, 0x00,
535        0x66, 0xc0, 0xa8, 0x00, 0x67, 0x0d, 0x00, 0x94, 0xe3, 0x39, 0x30, 0x00, 0x00, 0x00, 0xf6,
536        0x23, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
537    ];
538    pub const RESPONSE_IP_PACKET_BYTES: &[u8] = &[
539        0x45, 0x00, 0x00, 0x28, 0x0f, 0x3a, 0x00, 0x00, 0x80, 0x01, 0xa9, 0x7d, 0xc0, 0xa8, 0x00,
540        0x67, 0xc0, 0xa8, 0x00, 0x66, 0x0e, 0x00, 0xab, 0x87, 0x39, 0x30, 0x00, 0x00, 0x00, 0xf6,
541        0x23, 0xf6, 0xfe, 0x2c, 0xf6, 0x00, 0xfe, 0x2c, 0xf6, 0x00,
542    ];
543    pub const IDENTIFIER: u16 = 0x3930;
544    pub const SEQUENCE_NUM: u16 = 0;
545    pub const ORIGIN_TIMESTAMP: u32 = 16_131_062;
546    pub const RX_TX_TIMESTAMP: u32 = 0;
547}
548
549/// An ICMP Destination Unreachable packet.
550///
551/// An IPv4 packet with the first 8 bytes of the original datagram.
552pub mod icmp_dest_unreachable {
553    #![allow(missing_docs)]
554
555    pub const IP_PACKET_BYTES: &[u8] = &[
556        0x45, 0x00, 0x00, 0x38, 0x00, 0x03, 0x00, 0x00, 0xff, 0x01, 0xa3, 0xbd, 0x0a, 0x01, 0x02,
557        0x01, 0x0a, 0x01, 0x02, 0x02, 0x03, 0x01, 0x2e, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
558        0x00, 0x64, 0x00, 0x05, 0x00, 0x00, 0xfe, 0x01, 0xae, 0x8f, 0x0a, 0x01, 0x02, 0x02, 0x01,
559        0x01, 0x01, 0x01, 0x08, 0x00, 0xc6, 0x01, 0x00, 0x01, 0x00, 0x00,
560    ];
561    // First 8 bytes of original datagram.
562    pub const ORIGIN_DATA: &[u8] = &[0x08, 0x00, 0xc6, 0x01, 0x00, 0x01, 0x00, 0x00];
563}
564
565/// An ICMP Redirect packet.
566///
567/// An IPv4 packet with the more preferred gateway address.
568pub mod icmp_redirect {
569    #![allow(missing_docs)]
570
571    use net_types::ip::Ipv4Addr;
572
573    pub const IP_PACKET_BYTES: &[u8] = &[
574        0x45, 0x00, 0x00, 0x38, 0x01, 0x38, 0x00, 0x00, 0xff, 0x01, 0xa5, 0x94, 0x0a, 0x7b, 0x00,
575        0x02, 0x0a, 0x7b, 0x00, 0x01, 0x05, 0x01, 0x13, 0xbe, 0x0a, 0x7b, 0x00, 0x03, 0x45, 0x00,
576        0x00, 0x64, 0x00, 0x05, 0x00, 0x00, 0xfe, 0x01, 0xaa, 0x10, 0x0a, 0x7b, 0x00, 0x01, 0x04,
577        0x04, 0x04, 0x04, 0x08, 0x00, 0xd4, 0xc1, 0x00, 0x01, 0x00, 0x00,
578    ];
579    pub const GATEWAY_ADDR: Ipv4Addr = Ipv4Addr::new([10, 123, 0, 3]);
580}
581
582/// An ICMP Time Exceeded packet.
583///
584/// An IPv4 packet with the first 8 bytes of the original datagram.
585pub mod icmp_time_exceeded {
586    #![allow(missing_docs)]
587
588    pub const IP_PACKET_BYTES: &[u8] = &[
589        0x45, 0x00, 0x00, 0x38, 0x07, 0xcf, 0x00, 0x00, 0x40, 0x01, 0xf1, 0x9a, 0xc0, 0xa8, 0x00,
590        0x01, 0xc0, 0xa8, 0x00, 0x0a, 0x0b, 0x00, 0x74, 0x01, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
591        0x00, 0x34, 0xde, 0x75, 0x00, 0x00, 0x01, 0x11, 0x5c, 0x74, 0xc0, 0xa8, 0x00, 0x0a, 0xac,
592        0xd9, 0x11, 0x44, 0xde, 0x74, 0x82, 0x9b, 0x00, 0x20, 0x1f, 0xce,
593    ];
594    // First 8 bytes of original datagram.
595    pub const ORIGIN_DATA: &[u8] = &[0xde, 0x74, 0x82, 0x9b, 0x00, 0x20, 0x1f, 0xce];
596}
597
598/// An MLD Router Query packet.
599///
600/// An IPv6 packet with the multicast group address, MLD response code and
601/// IP addresses for the IP packet.
602pub mod mld_router_query {
603    #![allow(missing_docs)]
604
605    // from: https://www.cloudshark.org/captures/696d02f3316e
606    use crate::Ipv6Addr;
607
608    #[rustfmt::skip]
609    pub const QUERY: &[u8] = &[
610        // IPv6 Header - Start
611        0x60, 0x00, 0x00, 0x00,
612        0x00, 0x20, 0x00, 0x01,
613        0x00, 0x00, 0x00, 0x00,
614        0x00, 0x00, 0x00, 0x00,
615        0x00, 0x00, 0x00, 0x00,
616        0x00, 0x00, 0x00, 0x00,
617        0xff, 0x02, 0x00, 0x00,
618        0x00, 0x00, 0x00, 0x00,
619        0x00, 0x00, 0x00, 0x00,
620        0x00, 0x00, 0x00, 0x01,
621        // IPv6 Header - End
622        // HopByHopOptions - Start
623        0x3a, 0x00, 0x05, 0x02,
624        0x00, 0x00, 0x01, 0x00,
625        // HopByHopOptions - End
626        // MLD Query V1 - Start
627        0x82, 0x00, 0x7a, 0xc1,
628        0x03, 0xe8, 0x00, 0x00,
629        0x00, 0x00, 0x00, 0x00,
630        0x00, 0x00, 0x00, 0x00,
631        0x00, 0x00, 0x00, 0x00,
632        0x00, 0x00, 0x00, 0x00,
633        // MLD Query V1 - End
634    ];
635
636    pub const HOST_GROUP_ADDRESS: Ipv6Addr = Ipv6Addr::new([0; 8]);
637    pub const MAX_RESP_CODE: u16 = 1000; // 0x03e8
638
639    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0; 8]);
640    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 1]);
641
642    pub const SOURCES: &[Ipv6Addr] = &[
643        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 3]),
644        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 4]),
645    ];
646
647    pub const S_FLAG: bool = false;
648    pub const QRV: u8 = 0;
649    pub const QQIC: u16 = 125;
650
651    #[rustfmt::skip]
652    pub const QUERY_V2: &[u8] = &[
653        // IPv6 Header - Start
654        0x60, 0x00, 0x00, 0x00,
655        0x00, 0x44, 0x00, 0x01,
656        0x00, 0x00, 0x00, 0x00,
657        0x00, 0x00, 0x00, 0x00,
658        0x00, 0x00, 0x00, 0x00,
659        0x00, 0x00, 0x00, 0x00,
660        0xff, 0x02, 0x00, 0x00,
661        0x00, 0x00, 0x00, 0x00,
662        0x00, 0x00, 0x00, 0x00,
663        0x00, 0x00, 0x00, 0x01,
664        // IPv6 Header - End
665        // HopByHopOptions - Start
666        0x3a, 0x00, 0x05, 0x02,
667        0x00, 0x00, 0x01, 0x00,
668        // HopByHopOptions - End
669        // MLD Query V2 - Start
670        0x82, 0x00, 0x7c, 0x11,
671        0x03, 0xe8, 0x00, 0x00,
672
673        0x00, 0x00, 0x00, 0x00,
674        0x00, 0x00, 0x00, 0x00,
675        0x00, 0x00, 0x00, 0x00,
676        0x00, 0x00, 0x00, 0x00,
677
678        0x00, 0x7d, 0x00, 0x02,
679
680        0xff, 0x02, 0x00, 0x00,
681        0x00, 0x00, 0x00, 0x00,
682        0x00, 0x00, 0x00, 0x00,
683        0x00, 0x00, 0x00, 0x03,
684
685        0xff, 0x02, 0x00, 0x00,
686        0x00, 0x00, 0x00, 0x00,
687        0x00, 0x00, 0x00, 0x00,
688        0x00, 0x00, 0x00, 0x04,
689        // MLD Query V2 - End
690    ];
691}
692
693/// An MLD Router Report packet.
694///
695/// An IPv6 packet with the multicast group address, and IP addresses for the IP
696/// packet.
697pub mod mld_router_report {
698    #![allow(missing_docs)]
699
700    use crate::Ipv6Addr;
701    pub const REPORT: &[u8] = &[
702        0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
703        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00,
704        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3a, 0x00, 0x05, 0x02, 0x00,
705        0x00, 0x01, 0x00, 0x83, 0x00, 0x7e, 0xa4, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
706        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
707    ];
708
709    pub const HOST_GROUP_ADDRESS: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 2]);
710
711    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0; 8]);
712    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 1]);
713}
714
715/// An MLD Router Done packet.
716///
717/// An IPv6 packet with the multicast group address, and IP addresses for the IP
718/// packet.
719pub mod mld_router_done {
720    #![allow(missing_docs)]
721
722    use crate::Ipv6Addr;
723    pub const DONE: &[u8] = &[
724        0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
725        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00,
726        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3a, 0x00, 0x05, 0x02, 0x00,
727        0x00, 0x01, 0x00, 0x84, 0x00, 0x7d, 0xa4, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
728        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
729    ];
730
731    pub const HOST_GROUP_ADDRESS: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 2]);
732
733    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0; 8]);
734    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 1]);
735}
736
737/// An MLD Router Report V2 packet.
738///
739/// An IPv6 packet with the multicast group address, and IP addresses for the IP
740/// packet.
741pub mod mld_router_report_v2 {
742    #![allow(missing_docs)]
743
744    use crate::Ipv6Addr;
745    use crate::icmp::mld::Mldv2MulticastRecordType;
746    #[rustfmt::skip]
747    pub const REPORT: &[u8] = &[
748        // IPv6 Header - Start
749        0x60, 0x00, 0x00, 0x00,
750        0x00, 0x44, 0x00, 0x01,
751        0xfe, 0x80, 0x00, 0x00,
752        0x00, 0x00, 0x00, 0x00,
753        0x40, 0x01, 0xc0, 0xff,
754        0xfe, 0xa8, 0x32, 0x68,
755        0xff, 0x02, 0x00, 0x00,
756        0x00, 0x00, 0x00, 0x00,
757        0x00, 0x00, 0x00, 0x00,
758        0x00, 0x00, 0x00, 0x16,
759        // IPv6 Header - End
760        // HopByHopOptions - Start
761        0x3a, 0x00, 0x05, 0x02,
762        0x00, 0x00, 0x01, 0x00,
763        // HopByHopOptions - End
764        // MLD Report V2 - Start
765        0x8f, 0x00, 0x2d, 0x96,
766        0x00, 0x00, 0x00, 0x01,
767
768        // Record Start
769        0x04, 0x00, 0x00, 0x02,
770
771        0xff, 0x02, 0x00, 0x00,
772        0x00, 0x00, 0x00, 0x00,
773        0x00, 0x00, 0x00, 0x00,
774        0x00, 0x00, 0x12, 0x34,
775
776        0xff, 0x02, 0x00, 0x00,
777        0x00, 0x00, 0x00, 0x00,
778        0x00, 0x00, 0x00, 0x00,
779        0x00, 0x00, 0x00, 0x03,
780
781        0xff, 0x02, 0x00, 0x00,
782        0x00, 0x00, 0x00, 0x00,
783        0x00, 0x00, 0x00, 0x00,
784        0x00, 0x00, 0x00, 0x04,
785        // Record End
786        // MLD Report V2 - End
787    ];
788
789    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0xfe80, 0, 0, 0, 0x4001, 0xc0ff, 0xfea8, 0x3268]);
790    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x16]);
791
792    pub const RECORDS_HEADERS: &[(Mldv2MulticastRecordType, Ipv6Addr)] = &[(
793        Mldv2MulticastRecordType::ChangeToExcludeMode,
794        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x1234]),
795    )];
796    pub const RECORDS_SOURCES: &[&[Ipv6Addr]] = &[&[
797        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x0003]),
798        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x0004]),
799    ]];
800}
801
802/// IGMPv2 Membership packets.
803pub mod igmpv2_membership {
804    use net_types::ip::Ipv4Addr;
805
806    /// An IGMPv2 Membership Report packet.
807    ///
808    /// An IPv4 packet with the multicast group address, and source IP address
809    /// for the IP packet.
810    // Copied and modified from https://www.cloudshark.org/captures/7d789d000734
811    pub mod report {
812        #![allow(missing_docs)]
813
814        use super::*;
815
816        pub const IP_PACKET_BYTES: &[u8] = &[
817            0x46, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x72, 0xc8, 0xc0, 0xa8,
818            0x01, 0x65, 0xef, 0x01, 0x01, 0x01, 0x94, 0x04, 0x00, 0x00, 0x16, 0x00, 0xf9, 0xfc,
819            0xef, 0x01, 0x01, 0x01,
820        ];
821        pub const SOURCE: Ipv4Addr = Ipv4Addr::new([192, 168, 1, 101]);
822        pub const MULTICAST: Ipv4Addr = Ipv4Addr::new([239, 1, 1, 1]);
823    }
824
825    /// An IGMPv2 Membership Query packet.
826    ///
827    /// An IPv4 packet with the multicast group address, and source IP address
828    /// for the IP packet.
829    pub mod query {
830        #![allow(missing_docs)]
831
832        use super::*;
833
834        pub const IP_PACKET_BYTES: &[u8] = &[
835            0x46, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x73, 0x2c, 0xc0, 0xa8,
836            0x01, 0x01, 0xef, 0x01, 0x01, 0x01, 0x94, 0x04, 0x00, 0x00, 0x11, 0x0a, 0xfe, 0xf2,
837            0xef, 0x01, 0x01, 0x01,
838        ];
839        pub const SOURCE: Ipv4Addr = Ipv4Addr::new([192, 168, 1, 1]);
840        pub const MULTICAST: Ipv4Addr = Ipv4Addr::new([239, 1, 1, 1]);
841    }
842
843    /// An IGMPv2 Membership Leave packet.
844    ///
845    /// An IPv4 packet with the multicast group address, and IP addresses for
846    /// the IP packet.
847    pub mod leave {
848        #![allow(missing_docs)]
849
850        use super::*;
851
852        pub const IP_PACKET_BYTES: &[u8] = &[
853            0x46, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x82, 0xc7, 0xc0, 0xa8,
854            0x01, 0x66, 0xe0, 0x00, 0x00, 0x02, 0x94, 0x04, 0x00, 0x00, 0x17, 0x00, 0xf8, 0xfc,
855            0xef, 0x01, 0x01, 0x01,
856        ];
857        pub const SOURCE: Ipv4Addr = Ipv4Addr::new([192, 168, 1, 102]);
858        pub const DESTINATION: Ipv4Addr = Ipv4Addr::new([224, 0, 0, 2]);
859        pub const MULTICAST: Ipv4Addr = Ipv4Addr::new([239, 1, 1, 1]);
860    }
861}