packet_formats::ipv4

Trait Ipv4Header

Source
pub trait Ipv4Header {
    // Required method
    fn get_header_prefix(&self) -> &HeaderPrefix;

    // Provided methods
    fn dscp_and_ecn(&self) -> DscpAndEcn { ... }
    fn id(&self) -> u16 { ... }
    fn df_flag(&self) -> bool { ... }
    fn mf_flag(&self) -> bool { ... }
    fn fragment_offset(&self) -> FragmentOffset { ... }
    fn fragment_type(&self) -> Ipv4FragmentType { ... }
    fn ttl(&self) -> u8 { ... }
    fn proto(&self) -> Ipv4Proto { ... }
    fn src_ip(&self) -> Ipv4Addr { ... }
    fn dst_ip(&self) -> Ipv4Addr { ... }
    fn builder(&self) -> Ipv4PacketBuilder { ... }
}
Expand description

Provides common access to IPv4 header fields.

Ipv4Header provides access to IPv4 header fields as a common implementation for both Ipv4Packet and Ipv4PacketRaw.

Required Methods§

Source

fn get_header_prefix(&self) -> &HeaderPrefix

Gets a reference to the IPv4 HeaderPrefix.

Provided Methods§

Source

fn dscp_and_ecn(&self) -> DscpAndEcn

The Differentiated Services Code Point (DSCP) and the Explicit Congestion Notification (ECN).

Source

fn id(&self) -> u16

The identification.

Source

fn df_flag(&self) -> bool

The Don’t Fragment (DF) flag.

Source

fn mf_flag(&self) -> bool

The More Fragments (MF) flag.

Source

fn fragment_offset(&self) -> FragmentOffset

The fragment offset.

Source

fn fragment_type(&self) -> Ipv4FragmentType

The fragment type.

p.fragment_type() returns Ipv4FragmentType::InitialFragment if p.fragment_offset() == 0 and Ipv4FragmentType::NonInitialFragment otherwise.

Source

fn ttl(&self) -> u8

The Time To Live (TTL).

Source

fn proto(&self) -> Ipv4Proto

The IP Protocol.

proto returns the Ipv4Proto from the protocol field.

Source

fn src_ip(&self) -> Ipv4Addr

The source IP address.

Source

fn dst_ip(&self) -> Ipv4Addr

The destination IP address.

Source

fn builder(&self) -> Ipv4PacketBuilder

Construct a builder with the same contents as this header.

Implementors§

Source§

impl<B: SplitByteSlice> Ipv4Header for Ipv4Packet<B>

Source§

impl<B: SplitByteSlice> Ipv4Header for Ipv4PacketRaw<B>