Struct etherparse::PacketBuilderStep[][src]

pub struct PacketBuilderStep<LastStep> { /* fields omitted */ }
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).

Examples

With an IPv4 header:

let builder = PacketBuilder::
    ethernet2([1,2,3,4,5,6],
              [7,8,9,10,11,12])
   //payload_len, protocol & checksum will be replaced during write
   .ip(IpHeader::Version4(
       Ipv4Header::new(
           0, //payload_len will be replaced during write
           12, //time_to_live
           IpNumber::Udp, //will be replaced during write
           [0,1,2,3], //source
           [4,5,6,7] //destination
       ),
       Default::default()));

With an IPv6 header:

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]
        },
        Default::default()));

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])
   //payload_len, protocol & checksum will be replaced during write
   .ip(IpHeader::Version4(
        Ipv4Header::new(
            0, //payload_len will be replaced during write
            12, //time_to_live
            IpNumber::Udp, //will be replaced during write
            [0,1,2,3], //source
            [4,5,6,7] //destination
        ),
        Default::default()));
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]
        },
        Default::default()));

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

Performs the conversion.

Performs the conversion.

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.