packet_formats::error

Enum IpParseErrorAction

Source
pub enum IpParseErrorAction {
    DiscardPacket,
    DiscardPacketSendIcmp,
    DiscardPacketSendIcmpNoMulticast,
}
Expand description

Action to take when an IP node fails to parse a received IP packet.

These actions are taken from RFC 8200 section 4.2. Although these actions are defined by an IPv6 RFC, IPv4 nodes that fail to parse a received packet will take similar actions.

Variants§

§

DiscardPacket

Discard the packet and do nothing further.

§

DiscardPacketSendIcmp

Discard the packet and send an ICMP response.

§

DiscardPacketSendIcmpNoMulticast

Discard the packet and send an ICMP response if the packet’s destination address was not a multicast address.

Implementations§

Source§

impl IpParseErrorAction

Source

pub fn should_send_icmp<A: IpAddress>(&self, dst_addr: &A) -> bool

Determines whether or not an ICMP message should be sent.

Returns true if the caller should send an ICMP response. The caller should send an ICMP response if an action is set to DiscardPacketSendIcmp, or if an action is set to DiscardPacketSendIcmpNoMulticast and dst_addr (the destination address of the original packet that lead to a parsing error) is not a multicast address.

Source

pub fn should_send_icmp_to_multicast(&self) -> bool

Determines whether or not an ICMP message should be sent even if the original packet’s destination address is a multicast.

Per RFC 1122 section 3.2.2 and RFC 4443 section 2.4, ICMP messages MUST NOT be sent in response to packets destined to a multicast or broadcast address. However, RFC 4443 section 2.4 includes an exception to this rule if certain criteria are met when parsing IPv6 extension header options. should_send_icmp_to_multicast returns true if the criteria are met. See RFC 4443 section 2.4 for more details about the exception.

Trait Implementations§

Source§

impl Clone for IpParseErrorAction

Source§

fn clone(&self) -> IpParseErrorAction

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IpParseErrorAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for IpParseErrorAction

Source§

fn eq(&self, other: &IpParseErrorAction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for IpParseErrorAction

Source§

impl StructuralPartialEq for IpParseErrorAction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.