Enum etherparse::Icmpv4Type
source · pub enum Icmpv4Type {
Unknown {
type_u8: u8,
code_u8: u8,
bytes5to8: [u8; 4],
},
EchoReply(IcmpEchoHeader),
DestinationUnreachable(DestUnreachableHeader),
Redirect(RedirectHeader),
EchoRequest(IcmpEchoHeader),
TimeExceeded(TimeExceededCode),
ParameterProblem(ParameterProblemHeader),
TimestampRequest(TimestampMessage),
TimestampReply(TimestampMessage),
}
Expand description
Starting contents of an ICMPv4 packet without the checksum.
Variants§
Unknown
Fields
In case of an unknown ICMP type and code combination is received the
header elements are stored raw in this enum value. The Unknown
value can
also be passed to the Icmpv4Header::write
function to write arbitrary ICMP
packets.
What is part of the header for Icmpv4Type::Unknown
?
For unknown ICMP type & code combination the first 8 bytes are stored
in the Icmpv4Header
and the rest is stored in the payload
(Icmpv4Slice::payload
or PacketHeaders::payload
).
0 1 2 3 4
+---------------------------------------------------------------+ -
| type_u8 | code_u8 | checksum (in Icmpv4Header) | |
+---------------------------------------------------------------+ | part of header & type
| bytes5to8 | ↓
+---------------------------------------------------------------+ -
| | |
... ... ... | part of payload
| | ↓
+---------------------------------------------------------------+ -
EchoReply(IcmpEchoHeader)
Response to an EchoRequest
message (defined in RFC792).
What is part of the header for Icmpv4Type::EchoReply
?
For the Icmpv4Type::EchoReply
type the first 8 bytes/octets of the
ICMP packet are part of the header. This includes the id
and seq
fields. The data part of the ICMP Echo Reply packet is part of the
payload (Icmpv4Slice::payload
or PacketHeaders::payload
)
and not part of the Icmpv4Header
.
0 1 2 3 4
+---------------------------------------------------------------+ -
| 0 | 0 | checksum (in Icmpv4Header) | |
+---------------------------------------------------------------+ | part of header & type
| [value].id | [value].seq | ↓
+---------------------------------------------------------------+ -
| | |
... <data> ... | part of payload
| | ↓
+---------------------------------------------------------------+ -
DestinationUnreachable(DestUnreachableHeader)
Message sent to inform the client that the destination is unreachable for some reason (defined in RFC792).
What is part of the header for Icmpv4Type::DestinationUnreachable
?
For the Icmpv4Type::DestinationUnreachable
type the first 8 bytes/octets
of the ICMP packet are part of the header. This includes the next_hop_mtu
field. The unused
part is not stored and droped. The offending packet
is stored in the payload part of the packet (Icmpv4Slice::payload
or
PacketHeaders::payload
) and is not part of the Icmpv4Header
.
0 1 2 3 4
+---------------------------------------------------------------+ -
| 3 | 0 | checksum (in Icmpv4Header) | |
+---------------------------------------------------------------+ | part of header & type
|[v].next_hop...| <unused> | ↓
+---------------------------------------------------------------+ -
| | |
... Internet Header + 64 bits of Original Data Datagram ... | part of payload
| | ↓
+---------------------------------------------------------------+ -
Redirect(RedirectHeader)
Requests data packets be sent on an alternative route (defined in RFC792).
What is part of the header for Icmpv4Type::Redirect
?
For the Icmpv4Type::Redirect
type the first 8 bytes/octets of the ICMP
packet are part of the header. This includes the gateway_internet_address
field. The offending packet is stored in the payload part of the packet
(Icmpv4Slice::payload
or PacketHeaders::payload
) and is not part of
the Icmpv4Header
.
0 1 2 3 4
+---------------------------------------------------------------+ -
| 5 | [value].code | checksum (in Icmpv4Header) | |
+---------------------------------------------------------------+ | part of header & type
| [value].gateway_internet_address | ↓
+---------------------------------------------------------------+ -
| | |
.. Internet Header + 64 bits of Original Data Datagram ... | part of payload
| | ↓
+---------------------------------------------------------------+ -
EchoRequest(IcmpEchoHeader)
Requesting an EchoReply
from the receiver (defined in RFC792)
What is part of the header for Icmpv4Type::EchoRequest
?
For the Icmpv4Type::EchoRequest
type the first 8 bytes/octets of the
ICMP packet are part of the header. This includes the id
and seq
fields. The data part of the ICMP echo request packet is part of the payload
(Icmpv4Slice::payload
& PacketHeaders::payload
) and not part of the
Icmpv4Header
.
0 1 2 3 4
+---------------------------------------------------------------+ -
| 8 | 0 | checksum (in Icmpv4Header) | |
+---------------------------------------------------------------+ | part of header & type
| [value].id | [value].seq | ↓
+---------------------------------------------------------------+ -
| | |
... <data> ... | part of payload
| | ↓
+---------------------------------------------------------------+ -
TimeExceeded(TimeExceededCode)
Generated when a datagram had to be discarded due to the time to live field reaching zero (defined in RFC792).
What is part of the header for Icmpv4Type::TimeExceeded
?
For the Icmpv4Type::TimeExceeded
type the first 8 bytes/octets of the ICMP
packet are part of the header. The unused
part is not stored and droped.
The offending packet is stored in the payload part of the packet
(Icmpv4Slice::payload
& PacketHeaders::payload
) and is not part of
the Icmpv4Header
.
0 1 2 3 4
+---------------------------------------------------------------+ -
| 11 | [value as u8] | checksum (in Icmpv4Header) | |
+---------------------------------------------------------------+ | part of header & type
| <unused> | ↓
+---------------------------------------------------------------+ -
| | |
... Internet Header + 64 bits of Original Data Datagram ... | part of payload
| | ↓
+---------------------------------------------------------------+ -
ParameterProblem(ParameterProblemHeader)
Sent if there is a problem with a parameter in a received packet.
What is part of the header for Icmpv4Type::ParameterProblem
?
For the Icmpv4Type::ParameterProblem
type the first 8 bytes/octets of the ICMP
packet are part of the header. The unused
part is not stored and droped.
The offending packet is stored in the payload part of the packet
(Icmpv4Slice::payload
& PacketHeaders::payload
) and is not part of
the Icmpv4Header
.
0 1 2 3 4
+---------------------------------------------------------------+ -
| 12 | [v].code_u8() | checksum (in Icmpv4Header) | |
+---------------------------------------------------------------+ | part of header & type
|[value].pointer| <unused> | ↓
+---------------------------------------------------------------+ -
| | |
... Internet Header + 64 bits of Original Data Datagram ... | part of payload
| | ↓
+---------------------------------------------------------------+ -
TimestampRequest(TimestampMessage)
Timestamp is used for time synchronization.
What is part of the header for Icmpv4Type::TimestampRequest
?
For the Icmpv4Type::TimestampRequest
type the entire ICMP packet is
contained within the header. The payload data is empty.
TimestampReply(TimestampMessage)
Anwser to a TimestampRequest
message.
What is part of the header for Icmpv4Type::TimestampReply
?
For the Icmpv4Type::TimestampReply
type the entire ICMP packet is
contained within the header. The payload data is empty.
Implementations§
source§impl Icmpv4Type
impl Icmpv4Type
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Returns the length in bytes/octets of the header of this ICMPv4 message type.
sourcepub fn fixed_payload_size(&self) -> Option<usize>
pub fn fixed_payload_size(&self) -> Option<usize>
If the ICMP type has a fixed size returns the number of bytes that should be present after the header of this type.
sourcepub fn calc_checksum(&self, payload: &[u8]) -> u16
pub fn calc_checksum(&self, payload: &[u8]) -> u16
Calculate the ICMP checksum value.
Trait Implementations§
source§impl Clone for Icmpv4Type
impl Clone for Icmpv4Type
source§fn clone(&self) -> Icmpv4Type
fn clone(&self) -> Icmpv4Type
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more