Struct etherparse::PacketBuilderStep[][src]

pub struct PacketBuilderStep<LastStep> { /* fields omitted */ }

An unfinished packet that is build with the packet builder

Methods

impl PacketBuilderStep<Ethernet2Header>
[src]

Add an ip v4 header

Add an ip header (length, protocol/next_header & checksum fields will be overwritten based on the rest of the packet).

Example IPv4

let builder = PacketBuilder::
    ethernet2([1,2,3,4,5,6],
              [7,8,9,10,11,12])
   .ip(IpHeader::Version4(Ipv4Header{
        header_length: 0, //will be replaced during write
        differentiated_services_code_point: 0,
        explicit_congestion_notification: 0,
        total_length: 0, //will be replaced during write
        identification: 0,
        dont_fragment: true,
        more_fragments: false,
        fragments_offset: 0,
        time_to_live: 12,
        protocol: 0, //will be replaced during write
        header_checksum: 0, //will be replaced during write
        source: [0,1,2,3],
        destination: [4,5,6,7]
    }));

Example IPv6

let builder = PacketBuilder::
    ethernet2([1,2,3,4,5,6],
              [7,8,9,10,11,12])
   .ip(IpHeader::Version6(Ipv6Header{
        traffic_class: 0,
        flow_label: 0,
        payload_length: 0, //will be replaced during write
        next_header: 0, //will be replaced during write
        hop_limit: 4,
        source: [0;16],
        destination: [0;16]
    }));

Add an ip v6 header

Adds a vlan tagging header with the given vlan identifier

Adds a vlan tagging header with the given vlan identifier

Adds two vlan tagging header with the given vlan identifiers (also known as double vlan tagging).

impl PacketBuilderStep<VlanHeader>
[src]

Add an ip header (length, protocol/next_header & checksum fields will be overwritten based on the rest of the packet).

Example IPv4

let builder = PacketBuilder::
    ethernet2([1,2,3,4,5,6],
              [7,8,9,10,11,12])
   .ip(IpHeader::Version4(Ipv4Header{
        header_length: 0, //will be replaced during write
        differentiated_services_code_point: 0,
        explicit_congestion_notification: 0,
        total_length: 0, //will be replaced during write
        identification: 0,
        dont_fragment: true,
        more_fragments: false,
        fragments_offset: 0,
        time_to_live: 12,
        protocol: 0, //will be replaced during write
        header_checksum: 0, //will be replaced during write
        source: [0,1,2,3],
        destination: [4,5,6,7]
    }));

Example IPv6

let builder = PacketBuilder::
    ethernet2([1,2,3,4,5,6],
              [7,8,9,10,11,12])
   .ip(IpHeader::Version6(Ipv6Header{
        traffic_class: 0,
        flow_label: 0,
        payload_length: 0, //will be replaced during write
        next_header: 0, //will be replaced during write
        hop_limit: 4,
        source: [0;16],
        destination: [0;16]
    }));

Add a ip v6 header

Add a ip v4 header

impl PacketBuilderStep<IpHeader>
[src]

impl PacketBuilderStep<UdpHeader>
[src]

Write all the headers and the payload.

Returns the size of the packet when it is serialized

Auto Trait Implementations

impl<LastStep> Send for PacketBuilderStep<LastStep> where
    LastStep: Send

impl<LastStep> Sync for PacketBuilderStep<LastStep> where
    LastStep: Sync