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

§type_u8: u8

ICMP type (present in the first byte of the ICMP packet).

§code_u8: u8

ICMP code (present in the 2nd byte of the ICMP packet).

§bytes5to8: [u8; 4]

Bytes located at th 5th, 6th, 7th and 8th position of the ICMP packet.

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§

Returns the length in bytes/octets of the header of this ICMPv4 message type.

If the ICMP type has a fixed size returns the number of bytes that should be present after the header of this type.

Calculate the ICMP checksum value.

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.