Struct etherparse::Icmpv4Slice

source ·
pub struct Icmpv4Slice<'a> { /* private fields */ }
Expand description

A slice containing an ICMPv4 network package.

Struct allows the selective read of fields in the ICMPv4 packet.

Implementations§

Creates a slice containing an ICMPv4 packet.

Errors

The function will return an Err ReadError::UnexpectedEndOfSlice if the given slice is too small.

Decode the header values into an Icmpv4Header struct.

Number of bytes/octets that will be converted into a Icmpv4Header when Icmpv4Slice::header gets called.

Decode the header values (excluding the checksum) into an Icmpv4Type enum.

Returns “type” value in the ICMPv4 header.

Returns “code” value in the ICMPv4 header.

Returns “checksum” value in the ICMPv4 header.

Returns the bytes from position 4 till and including the 8th position in the ICMPv4 header.

These bytes located at th 5th, 6th, 7th and 8th position of the ICMP packet can depending on the ICMPv4 type and code contain additional data.

Returns a slice to the bytes not covered by .header().

The contents of the slice returned by payload() depends on the type and code of the ICMP packet:

.header().icmp_type or .icmp_type()Payload Content
Icmpv4Type::EchoReply
Icmpv4Type::EchoRequest
Data part of the echo message
Icmpv4Type::DestinationUnreachable
Icmpv4Type::Redirect
Icmpv4Type::TimeExceeded
Icmpv4Type::ParameterProblem
Internet Header + 64 bits of Original Data Datagram causing the ICMP message
Icmpv4Type::TimestampRequest
Icmpv4Type::TimestampReply
Nothing
Icmpv4Type::UnknownEverything after the 8th byte/octet of the ICMP packet.

Returns the slice containing the ICMPv4 packet.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.