pub struct PacketBuilderStep<LastStep> { /* private fields */ }
Expand description

An unfinished packet that is build with the packet builder

Implementations§

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).

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

Write all the headers and the payload.

Returns the size of the packet when it is serialized

Set ns flag (ECN-nonce - concealment protection; experimental: see RFC 3540)

Set fin flag (No more data from sender)

Set the syn flag (synchronize sequence numbers)

Sets the rst flag (reset the connection)

Sets the psh flag (push function)

Sets the ack flag and the acknowledgment_number.

Set the urg flag & the urgent pointer field.

The urgent pointer points to the sequence number of the octet following the urgent data.

Sets ece flag (ECN-Echo, RFC 3168)

Set cwr flag (Congestion Window Reduced)

This flag is set by the sending host to indicate that it received a TCP segment with the ECE flag set and had responded in congestion control mechanism (added to header by RFC 3168).

Set the tcp options of the header.

Set the tcp options of the header (setting the bytes directly).

Write all the headers and the payload.

Returns the size of the packet when it is serialized

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.