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::TcpOption;
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: &[TcpOption::Timestamp { ts_val: 644_726_309, ts_echo_reply: 2_960_127_454 }],
290        },
291        body_range: 32..557,
292    };
293}
294
295/// IPv6 DNS Request Packet.
296///
297/// An Ethernet frame containing an IPv6 packet containing a UDP datagram
298/// containing a DNS request for google.com.
299pub mod dns_request_v6 {
300    #![allow(missing_docs)]
301
302    use super::*;
303    use crate::ip::DscpAndEcn;
304
305    pub const ETHERNET_FRAME: TestPacket<EthernetFrameMetadata> = TestPacket {
306        bytes: &[
307            0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c, 0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02, 0x86, 0xdd,
308            0x60, 0x0e, 0xa5, 0x28, 0x00, 0x3b, 0x11, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
309            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x20, 0x01, 0x48, 0x60,
310            0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0xd9, 0xa1,
311            0x00, 0x35, 0x00, 0x3b, 0x02, 0xf8, 0xa6, 0xd9, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00,
312            0x00, 0x00, 0x00, 0x01, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f,
313            0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
314            0x00, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x08, 0x9f, 0x30, 0xaa, 0x16, 0x63, 0xd2, 0x09,
315            0x25,
316        ],
317        metadata: EthernetFrameMetadata {
318            src_mac: Mac::new([0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02]),
319            dst_mac: Mac::new([0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c]),
320            ethertype: Some(EtherType::Ipv6),
321        },
322        body_range: 14..113,
323    };
324
325    pub const IPV6_PACKET: TestPacket<Ipv6PacketMetadata> = TestPacket {
326        bytes: &[
327            0x60, 0x0e, 0xa5, 0x28, 0x00, 0x3b, 0x11, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
328            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x20, 0x01, 0x48, 0x60,
329            0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0xd9, 0xa1,
330            0x00, 0x35, 0x00, 0x3b, 0x02, 0xf8, 0xa6, 0xd9, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00,
331            0x00, 0x00, 0x00, 0x01, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f,
332            0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
333            0x00, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x08, 0x9f, 0x30, 0xaa, 0x16, 0x63, 0xd2, 0x09,
334            0x25,
335        ],
336        metadata: Ipv6PacketMetadata {
337            dscp_and_ecn: DscpAndEcn::default(),
338            flowlabel: 0xea528,
339            hop_limit: 64,
340            src_ip: Ipv6Addr::from_bytes([
341                0x26, 0x20, 0x00, 0x00, 0x10, 0x00, 0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21,
342                0x92, 0x15,
343            ]),
344            dst_ip: Ipv6Addr::from_bytes([
345                0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
346                0x88, 0x88,
347            ]),
348        },
349        body_range: 40..99,
350    };
351
352    pub const UDP_PACKET: TestPacket<UdpPacketMetadata> = TestPacket {
353        bytes: &[
354            0xd9, 0xa1, 0x00, 0x35, 0x00, 0x3b, 0x02, 0xf8, 0xa6, 0xd9, 0x01, 0x20, 0x00, 0x01,
355            0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03,
356            0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00,
357            0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x08, 0x9f, 0x30, 0xaa, 0x16, 0x63,
358            0xd2, 0x09, 0x25,
359        ],
360        metadata: UdpPacketMetadata { src_port: 55713, dst_port: 53 },
361        body_range: 8..59,
362    };
363}
364
365/// IPv6 TCP SYN Packet.
366///
367/// An Ethernet frame containing an IPv6 packet containing a TCP SYN segment
368/// with an empty body.
369pub mod syn_v6 {
370    #![allow(missing_docs)]
371
372    use super::*;
373
374    use crate::ip::DscpAndEcn;
375    use crate::tcp::options::TcpOption;
376
377    pub const ETHERNET_FRAME: TestPacket<EthernetFrameMetadata> = TestPacket {
378        bytes: &[
379            0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c, 0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02, 0x86, 0xdd,
380            0x60, 0x08, 0xc5, 0x5d, 0x00, 0x28, 0x06, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
381            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x26, 0x07, 0xf8, 0xb0,
382            0x40, 0x05, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x12, 0xa7, 0xac,
383            0x01, 0xbb, 0x1c, 0x68, 0x76, 0x8e, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x70, 0x80,
384            0x72, 0xcf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xa0, 0x04, 0x02, 0x08, 0x0a, 0xe7, 0x50,
385            0x11, 0x57, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07,
386        ],
387        metadata: EthernetFrameMetadata {
388            src_mac: Mac::new([0x6b, 0xc3, 0x31, 0x1c, 0x79, 0x02]),
389            dst_mac: Mac::new([0x0f, 0x41, 0xf1, 0xda, 0xaf, 0x6c]),
390            ethertype: Some(EtherType::Ipv6),
391        },
392        body_range: 14..94,
393    };
394
395    pub const IPV6_PACKET: TestPacket<Ipv6PacketMetadata> = TestPacket {
396        bytes: &[
397            0x60, 0x08, 0xc5, 0x5d, 0x00, 0x28, 0x06, 0x40, 0x26, 0x20, 0x00, 0x00, 0x10, 0x00,
398            0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21, 0x92, 0x15, 0x26, 0x07, 0xf8, 0xb0,
399            0x40, 0x05, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x12, 0xa7, 0xac,
400            0x01, 0xbb, 0x1c, 0x68, 0x76, 0x8e, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x70, 0x80,
401            0x72, 0xcf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xa0, 0x04, 0x02, 0x08, 0x0a, 0xe7, 0x50,
402            0x11, 0x57, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07,
403        ],
404        metadata: Ipv6PacketMetadata {
405            dscp_and_ecn: DscpAndEcn::default(),
406            flowlabel: 0x8c55d,
407            hop_limit: 64,
408            src_ip: Ipv6Addr::from_bytes([
409                0x26, 0x20, 0x00, 0x00, 0x10, 0x00, 0x50, 0x10, 0x69, 0xb4, 0xab, 0xc9, 0x7b, 0x21,
410                0x92, 0x15,
411            ]),
412            dst_ip: Ipv6Addr::from_bytes([
413                0x26, 0x07, 0xf8, 0xb0, 0x40, 0x05, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
414                0x20, 0x12,
415            ]),
416        },
417        body_range: 40..80,
418    };
419
420    pub const TCP_SEGMENT: TestPacket<TcpSegmentMetadata> = TestPacket {
421        bytes: &[
422            0xa7, 0xac, 0x01, 0xbb, 0x1c, 0x68, 0x76, 0x8e, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,
423            0x70, 0x80, 0x72, 0xcf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xa0, 0x04, 0x02, 0x08, 0x0a,
424            0xe7, 0x50, 0x11, 0x57, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07,
425        ],
426        metadata: TcpSegmentMetadata {
427            src_port: 42924,
428            dst_port: 443,
429            ack_num: None,
430            flags: 0x002,
431            seq_num: 0x1c68768e,
432            window_size: 28800,
433            psh: false,
434            rst: false,
435            fin: false,
436            syn: true,
437            options: &[
438                TcpOption::Mss(1440),
439                TcpOption::SackPermitted,
440                TcpOption::Timestamp { ts_val: 3_880_784_215, ts_echo_reply: 0 },
441                TcpOption::WindowScale(7),
442            ],
443        },
444        body_range: 40..40,
445    };
446}
447
448/// An ICMP echo reply in an IP packet in an Ethernet frame.
449pub mod icmp_echo_ethernet {
450    #![allow(missing_docs)]
451
452    pub const REPLY_ETHERNET_FRAME_BYTES: &[u8] = &[
453        0x8c, 0x85, 0x90, 0xc9, 0xc9, 0x00, 0x50, 0xc7, 0xbf, 0x1d, 0xf4, 0xd2, 0x08, 0x00, 0x45,
454        0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x35, 0x01, 0x11, 0x91, 0xac, 0xd9, 0x06, 0x2e,
455        0xc0, 0xa8, 0x00, 0x69, 0x00, 0x00, 0x01, 0x33, 0xb2, 0xa8, 0x00, 0x01, 0x5c, 0x68, 0x5c,
456        0x32, 0x00, 0x03, 0xa8, 0x82, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
457        0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
458        0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
459        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
460    ];
461}
462
463/// An ICMP echo request/response pair.
464///
465/// An IPv4 pair of packets containing ICMPv4 packets.
466pub mod icmp_echo {
467    #![allow(missing_docs)]
468
469    pub const REQUEST_IP_PACKET_BYTES: &[u8] = &[
470        0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0xa2, 0x80, 0x64, 0x4c, 0x3a,
471        0xd0, 0xd8, 0xef, 0x20, 0x1d, 0x08, 0x00, 0xee, 0x2b, 0x25, 0x8e, 0x00, 0x01, 0x21, 0x50,
472        0x24, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xd3, 0xc6, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
473        0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
474        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
475        0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
476    ];
477    pub const RESPONSE_IP_PACKET_BYTES: &[u8] = &[
478        0x45, 0x80, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x39, 0x01, 0xe9, 0x00, 0xd8, 0xef, 0x20,
479        0x1d, 0x64, 0x4c, 0x3a, 0xd0, 0x00, 0x00, 0xf6, 0x2b, 0x25, 0x8e, 0x00, 0x01, 0x21, 0x50,
480        0x24, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xd3, 0xc6, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
481        0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
482        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
483        0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
484    ];
485    pub const ECHO_DATA: &[u8] = &[
486        0x21, 0x50, 0x24, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xd3, 0xc6, 0x0c, 0x00, 0x00, 0x00, 0x00,
487        0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
488        0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
489        0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
490    ];
491    pub const IDENTIFIER: u16 = 9614;
492    pub const SEQUENCE_NUM: u16 = 1;
493}
494
495/// An ICMP echo request/response pair.
496///
497/// An IPv6 pair of packets containing ICMPv6 packets.
498pub mod icmp_echo_v6 {
499    #![allow(missing_docs)]
500
501    pub const REQUEST_IP_PACKET_BYTES: &[u8] = &[
502        0x60, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3a, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
503        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00,
504        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xe3, 0x13, 0x11,
505        0x0d, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
506        0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
507        0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
508        0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
509    ];
510    pub const ECHO_DATA: &[u8] = &[
511        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
512        0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
513        0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
514        0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
515    ];
516    pub const IDENTIFIER: u16 = 0x110d;
517    pub const SEQUENCE_NUM: u16 = 0;
518}
519
520/// An ICMP timestamp request/response pair.
521///
522/// An IPv4 pair of packets containing ICMPv6 packets.
523pub mod icmp_timestamp {
524    #![allow(missing_docs)]
525
526    pub const REQUEST_IP_PACKET_BYTES: &[u8] = &[
527        0x45, 0x00, 0x00, 0x28, 0x8d, 0xff, 0x00, 0x00, 0x80, 0x01, 0x2a, 0xb8, 0xc0, 0xa8, 0x00,
528        0x66, 0xc0, 0xa8, 0x00, 0x67, 0x0d, 0x00, 0x94, 0xe3, 0x39, 0x30, 0x00, 0x00, 0x00, 0xf6,
529        0x23, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
530    ];
531    pub const RESPONSE_IP_PACKET_BYTES: &[u8] = &[
532        0x45, 0x00, 0x00, 0x28, 0x0f, 0x3a, 0x00, 0x00, 0x80, 0x01, 0xa9, 0x7d, 0xc0, 0xa8, 0x00,
533        0x67, 0xc0, 0xa8, 0x00, 0x66, 0x0e, 0x00, 0xab, 0x87, 0x39, 0x30, 0x00, 0x00, 0x00, 0xf6,
534        0x23, 0xf6, 0xfe, 0x2c, 0xf6, 0x00, 0xfe, 0x2c, 0xf6, 0x00,
535    ];
536    pub const IDENTIFIER: u16 = 0x3930;
537    pub const SEQUENCE_NUM: u16 = 0;
538    pub const ORIGIN_TIMESTAMP: u32 = 16_131_062;
539    pub const RX_TX_TIMESTAMP: u32 = 0;
540}
541
542/// An ICMP Destination Unreachable packet.
543///
544/// An IPv4 packet with the first 8 bytes of the original datagram.
545pub mod icmp_dest_unreachable {
546    #![allow(missing_docs)]
547
548    pub const IP_PACKET_BYTES: &[u8] = &[
549        0x45, 0x00, 0x00, 0x38, 0x00, 0x03, 0x00, 0x00, 0xff, 0x01, 0xa3, 0xbd, 0x0a, 0x01, 0x02,
550        0x01, 0x0a, 0x01, 0x02, 0x02, 0x03, 0x01, 0x2e, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
551        0x00, 0x64, 0x00, 0x05, 0x00, 0x00, 0xfe, 0x01, 0xae, 0x8f, 0x0a, 0x01, 0x02, 0x02, 0x01,
552        0x01, 0x01, 0x01, 0x08, 0x00, 0xc6, 0x01, 0x00, 0x01, 0x00, 0x00,
553    ];
554    // First 8 bytes of original datagram.
555    pub const ORIGIN_DATA: &[u8] = &[0x08, 0x00, 0xc6, 0x01, 0x00, 0x01, 0x00, 0x00];
556}
557
558/// An ICMP Redirect packet.
559///
560/// An IPv4 packet with the more preferred gateway address.
561pub mod icmp_redirect {
562    #![allow(missing_docs)]
563
564    use net_types::ip::Ipv4Addr;
565
566    pub const IP_PACKET_BYTES: &[u8] = &[
567        0x45, 0x00, 0x00, 0x38, 0x01, 0x38, 0x00, 0x00, 0xff, 0x01, 0xa5, 0x94, 0x0a, 0x7b, 0x00,
568        0x02, 0x0a, 0x7b, 0x00, 0x01, 0x05, 0x01, 0x13, 0xbe, 0x0a, 0x7b, 0x00, 0x03, 0x45, 0x00,
569        0x00, 0x64, 0x00, 0x05, 0x00, 0x00, 0xfe, 0x01, 0xaa, 0x10, 0x0a, 0x7b, 0x00, 0x01, 0x04,
570        0x04, 0x04, 0x04, 0x08, 0x00, 0xd4, 0xc1, 0x00, 0x01, 0x00, 0x00,
571    ];
572    pub const GATEWAY_ADDR: Ipv4Addr = Ipv4Addr::new([10, 123, 0, 3]);
573}
574
575/// An ICMP Time Exceeded packet.
576///
577/// An IPv4 packet with the first 8 bytes of the original datagram.
578pub mod icmp_time_exceeded {
579    #![allow(missing_docs)]
580
581    pub const IP_PACKET_BYTES: &[u8] = &[
582        0x45, 0x00, 0x00, 0x38, 0x07, 0xcf, 0x00, 0x00, 0x40, 0x01, 0xf1, 0x9a, 0xc0, 0xa8, 0x00,
583        0x01, 0xc0, 0xa8, 0x00, 0x0a, 0x0b, 0x00, 0x74, 0x01, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
584        0x00, 0x34, 0xde, 0x75, 0x00, 0x00, 0x01, 0x11, 0x5c, 0x74, 0xc0, 0xa8, 0x00, 0x0a, 0xac,
585        0xd9, 0x11, 0x44, 0xde, 0x74, 0x82, 0x9b, 0x00, 0x20, 0x1f, 0xce,
586    ];
587    // First 8 bytes of original datagram.
588    pub const ORIGIN_DATA: &[u8] = &[0xde, 0x74, 0x82, 0x9b, 0x00, 0x20, 0x1f, 0xce];
589}
590
591/// An MLD Router Query packet.
592///
593/// An IPv6 packet with the multicast group address, MLD response code and
594/// IP addresses for the IP packet.
595pub mod mld_router_query {
596    #![allow(missing_docs)]
597
598    // from: https://www.cloudshark.org/captures/696d02f3316e
599    use crate::Ipv6Addr;
600
601    #[rustfmt::skip]
602    pub const QUERY: &[u8] = &[
603        // IPv6 Header - Start
604        0x60, 0x00, 0x00, 0x00,
605        0x00, 0x20, 0x00, 0x01,
606        0x00, 0x00, 0x00, 0x00,
607        0x00, 0x00, 0x00, 0x00,
608        0x00, 0x00, 0x00, 0x00,
609        0x00, 0x00, 0x00, 0x00,
610        0xff, 0x02, 0x00, 0x00,
611        0x00, 0x00, 0x00, 0x00,
612        0x00, 0x00, 0x00, 0x00,
613        0x00, 0x00, 0x00, 0x01,
614        // IPv6 Header - End
615        // HopByHopOptions - Start
616        0x3a, 0x00, 0x05, 0x02,
617        0x00, 0x00, 0x01, 0x00,
618        // HopByHopOptions - End
619        // MLD Query V1 - Start
620        0x82, 0x00, 0x7a, 0xc1,
621        0x03, 0xe8, 0x00, 0x00,
622        0x00, 0x00, 0x00, 0x00,
623        0x00, 0x00, 0x00, 0x00,
624        0x00, 0x00, 0x00, 0x00,
625        0x00, 0x00, 0x00, 0x00,
626        // MLD Query V1 - End
627    ];
628
629    pub const HOST_GROUP_ADDRESS: Ipv6Addr = Ipv6Addr::new([0; 8]);
630    pub const MAX_RESP_CODE: u16 = 1000; // 0x03e8
631
632    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0; 8]);
633    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 1]);
634
635    pub const SOURCES: &[Ipv6Addr] = &[
636        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 3]),
637        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 4]),
638    ];
639
640    pub const S_FLAG: bool = false;
641    pub const QRV: u8 = 0;
642    pub const QQIC: u16 = 125;
643
644    #[rustfmt::skip]
645    pub const QUERY_V2: &[u8] = &[
646        // IPv6 Header - Start
647        0x60, 0x00, 0x00, 0x00,
648        0x00, 0x44, 0x00, 0x01,
649        0x00, 0x00, 0x00, 0x00,
650        0x00, 0x00, 0x00, 0x00,
651        0x00, 0x00, 0x00, 0x00,
652        0x00, 0x00, 0x00, 0x00,
653        0xff, 0x02, 0x00, 0x00,
654        0x00, 0x00, 0x00, 0x00,
655        0x00, 0x00, 0x00, 0x00,
656        0x00, 0x00, 0x00, 0x01,
657        // IPv6 Header - End
658        // HopByHopOptions - Start
659        0x3a, 0x00, 0x05, 0x02,
660        0x00, 0x00, 0x01, 0x00,
661        // HopByHopOptions - End
662        // MLD Query V2 - Start
663        0x82, 0x00, 0x7c, 0x11,
664        0x03, 0xe8, 0x00, 0x00,
665
666        0x00, 0x00, 0x00, 0x00,
667        0x00, 0x00, 0x00, 0x00,
668        0x00, 0x00, 0x00, 0x00,
669        0x00, 0x00, 0x00, 0x00,
670
671        0x00, 0x7d, 0x00, 0x02,
672
673        0xff, 0x02, 0x00, 0x00,
674        0x00, 0x00, 0x00, 0x00,
675        0x00, 0x00, 0x00, 0x00,
676        0x00, 0x00, 0x00, 0x03,
677
678        0xff, 0x02, 0x00, 0x00,
679        0x00, 0x00, 0x00, 0x00,
680        0x00, 0x00, 0x00, 0x00,
681        0x00, 0x00, 0x00, 0x04,
682        // MLD Query V2 - End
683    ];
684}
685
686/// An MLD Router Report packet.
687///
688/// An IPv6 packet with the multicast group address, and IP addresses for the IP
689/// packet.
690pub mod mld_router_report {
691    #![allow(missing_docs)]
692
693    use crate::Ipv6Addr;
694    pub const REPORT: &[u8] = &[
695        0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
696        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00,
697        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3a, 0x00, 0x05, 0x02, 0x00,
698        0x00, 0x01, 0x00, 0x83, 0x00, 0x7e, 0xa4, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
699        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
700    ];
701
702    pub const HOST_GROUP_ADDRESS: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 2]);
703
704    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0; 8]);
705    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 1]);
706}
707
708/// An MLD Router Done packet.
709///
710/// An IPv6 packet with the multicast group address, and IP addresses for the IP
711/// packet.
712pub mod mld_router_done {
713    #![allow(missing_docs)]
714
715    use crate::Ipv6Addr;
716    pub const DONE: &[u8] = &[
717        0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
718        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00,
719        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3a, 0x00, 0x05, 0x02, 0x00,
720        0x00, 0x01, 0x00, 0x84, 0x00, 0x7d, 0xa4, 0x00, 0x00, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00,
721        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
722    ];
723
724    pub const HOST_GROUP_ADDRESS: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 2]);
725
726    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0; 8]);
727    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 1]);
728}
729
730/// An MLD Router Report V2 packet.
731///
732/// An IPv6 packet with the multicast group address, and IP addresses for the IP
733/// packet.
734pub mod mld_router_report_v2 {
735    #![allow(missing_docs)]
736
737    use crate::icmp::mld::Mldv2MulticastRecordType;
738    use crate::Ipv6Addr;
739    #[rustfmt::skip]
740    pub const REPORT: &[u8] = &[
741        // IPv6 Header - Start
742        0x60, 0x00, 0x00, 0x00,
743        0x00, 0x44, 0x00, 0x01,
744        0xfe, 0x80, 0x00, 0x00,
745        0x00, 0x00, 0x00, 0x00,
746        0x40, 0x01, 0xc0, 0xff,
747        0xfe, 0xa8, 0x32, 0x68,
748        0xff, 0x02, 0x00, 0x00,
749        0x00, 0x00, 0x00, 0x00,
750        0x00, 0x00, 0x00, 0x00,
751        0x00, 0x00, 0x00, 0x16,
752        // IPv6 Header - End
753        // HopByHopOptions - Start
754        0x3a, 0x00, 0x05, 0x02,
755        0x00, 0x00, 0x01, 0x00,
756        // HopByHopOptions - End
757        // MLD Report V2 - Start
758        0x8f, 0x00, 0x2d, 0x96,
759        0x00, 0x00, 0x00, 0x01,
760
761        // Record Start
762        0x04, 0x00, 0x00, 0x02,
763
764        0xff, 0x02, 0x00, 0x00,
765        0x00, 0x00, 0x00, 0x00,
766        0x00, 0x00, 0x00, 0x00,
767        0x00, 0x00, 0x12, 0x34,
768
769        0xff, 0x02, 0x00, 0x00,
770        0x00, 0x00, 0x00, 0x00,
771        0x00, 0x00, 0x00, 0x00,
772        0x00, 0x00, 0x00, 0x03,
773
774        0xff, 0x02, 0x00, 0x00,
775        0x00, 0x00, 0x00, 0x00,
776        0x00, 0x00, 0x00, 0x00,
777        0x00, 0x00, 0x00, 0x04,
778        // Record End
779        // MLD Report V2 - End
780    ];
781
782    pub const SRC_IP: Ipv6Addr = Ipv6Addr::new([0xfe80, 0, 0, 0, 0x4001, 0xc0ff, 0xfea8, 0x3268]);
783    pub const DST_IP: Ipv6Addr = Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x16]);
784
785    pub const RECORDS_HEADERS: &[(Mldv2MulticastRecordType, Ipv6Addr)] = &[(
786        Mldv2MulticastRecordType::ChangeToExcludeMode,
787        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x1234]),
788    )];
789    pub const RECORDS_SOURCES: &[&[Ipv6Addr]] = &[&[
790        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x0003]),
791        Ipv6Addr::new([0xff02, 0, 0, 0, 0, 0, 0, 0x0004]),
792    ]];
793}
794
795/// IGMPv2 Membership packets.
796pub mod igmpv2_membership {
797    use net_types::ip::Ipv4Addr;
798
799    /// An IGMPv2 Membership Report packet.
800    ///
801    /// An IPv4 packet with the multicast group address, and source IP address
802    /// for the IP packet.
803    // Copied and modified from https://www.cloudshark.org/captures/7d789d000734
804    pub mod report {
805        #![allow(missing_docs)]
806
807        use super::*;
808
809        pub const IP_PACKET_BYTES: &[u8] = &[
810            0x46, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x72, 0xc8, 0xc0, 0xa8,
811            0x01, 0x65, 0xef, 0x01, 0x01, 0x01, 0x94, 0x04, 0x00, 0x00, 0x16, 0x00, 0xf9, 0xfc,
812            0xef, 0x01, 0x01, 0x01,
813        ];
814        pub const SOURCE: Ipv4Addr = Ipv4Addr::new([192, 168, 1, 101]);
815        pub const MULTICAST: Ipv4Addr = Ipv4Addr::new([239, 1, 1, 1]);
816    }
817
818    /// An IGMPv2 Membership Query packet.
819    ///
820    /// An IPv4 packet with the multicast group address, and source IP address
821    /// for the IP packet.
822    pub mod query {
823        #![allow(missing_docs)]
824
825        use super::*;
826
827        pub const IP_PACKET_BYTES: &[u8] = &[
828            0x46, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x73, 0x2c, 0xc0, 0xa8,
829            0x01, 0x01, 0xef, 0x01, 0x01, 0x01, 0x94, 0x04, 0x00, 0x00, 0x11, 0x0a, 0xfe, 0xf2,
830            0xef, 0x01, 0x01, 0x01,
831        ];
832        pub const SOURCE: Ipv4Addr = Ipv4Addr::new([192, 168, 1, 1]);
833        pub const MULTICAST: Ipv4Addr = Ipv4Addr::new([239, 1, 1, 1]);
834    }
835
836    /// An IGMPv2 Membership Leave packet.
837    ///
838    /// An IPv4 packet with the multicast group address, and IP addresses for
839    /// the IP packet.
840    pub mod leave {
841        #![allow(missing_docs)]
842
843        use super::*;
844
845        pub const IP_PACKET_BYTES: &[u8] = &[
846            0x46, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x82, 0xc7, 0xc0, 0xa8,
847            0x01, 0x66, 0xe0, 0x00, 0x00, 0x02, 0x94, 0x04, 0x00, 0x00, 0x17, 0x00, 0xf8, 0xfc,
848            0xef, 0x01, 0x01, 0x01,
849        ];
850        pub const SOURCE: Ipv4Addr = Ipv4Addr::new([192, 168, 1, 102]);
851        pub const DESTINATION: Ipv4Addr = Ipv4Addr::new([224, 0, 0, 2]);
852        pub const MULTICAST: Ipv4Addr = Ipv4Addr::new([239, 1, 1, 1]);
853    }
854}