pub struct PacketBuilder {}
Helper for building packets.
The packet builder allows the easy construction of a packet from the
ethernet II layer downwards including ipv6, ipv4, the udp header and the
actual payload. The packet builder automatically calculates lengths & checksums
for ip & udp and set type identifiers for ethernetII and ip. This makes it
easy and less error prone to construct custom packets.
let builder = PacketBuilder::
ethernet2([1,2,3,4,5,6],
[7,8,9,10,11,12])
.ipv4([192,168,1,1],
[192,168,1,2],
20)
.udp(21,
1234);
let payload = [1,2,3,4,5,6,7,8];
let mut result = Vec::<u8>::with_capacity(
builder.size(payload.len()));
builder.write(&mut result, &payload).unwrap();
println!("{:?}", result);
Start an packet with an ethernetII header.