Skip to content

Commit 689fc6e

Browse files
gtedesco-r7rmcconnell-r7
authored andcommitted
Add a new example of IP fragments over VLAN
In future we should add a vlan type for the VLAN header
1 parent 61fca79 commit 689fc6e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

examples/frag-vlan.rsyn

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import text;
2+
import ipv4;
3+
import dns;
4+
import eth;
5+
import std;
6+
7+
let client = 192.168.238.112;
8+
let server = 142.250.207.36;
9+
let google = 8.8.8.8;
10+
11+
let dns = ipv4::udp::flow(
12+
client/13749,
13+
google/54,
14+
);
15+
16+
let frag = ipv4::frag(
17+
client,
18+
google,
19+
id: 0x2345,
20+
proto: ipv4::proto::UDP,
21+
dns.client_raw_dgram(
22+
dns::hdr(
23+
id: 0x1234,
24+
flags: dns::flags(
25+
opcode: dns::opcode::QUERY,
26+
rd: 1,
27+
),
28+
qdcount: 1,
29+
),
30+
dns::question(
31+
qname: dns::name("www", "google", "com"),
32+
qtype: dns::qtype::A,
33+
qclass: dns::class::IN,
34+
)
35+
)
36+
);
37+
38+
eth::frame(
39+
eth::from_ip(client),
40+
eth::from_ip(google),
41+
ethertype: eth::ethertype::VLAN,
42+
std::be16(0),
43+
std::be16(eth::ethertype::IPV4),
44+
frag.fragment(0, 1, raw: true),
45+
);
46+
eth::frame(
47+
eth::from_ip(client),
48+
eth::from_ip(google),
49+
ethertype: eth::ethertype::VLAN,
50+
std::be16(0),
51+
std::be16(eth::ethertype::IPV4),
52+
frag.tail(1, raw: true),
53+
);

0 commit comments

Comments
 (0)