Header

Enum Header 

Source
pub enum Header<'a> {
Show 27 variants Ethernet(EtherHeaderVlan<'a>), Sll(&'a SllHeader), Sllv2(&'a Sllv2Header), Null(&'a NullHeader), Ipv4(Ipv4HeaderOpt<'a>), Ipv6(Ipv6HeaderExt<'a>), Arp(ArpHeaderFull<'a>), Tcp(TcpHeaderOpt<'a>), Udp(&'a UdpHeader), Sctp(&'a SctpHeader), Icmp(&'a IcmpHeader), Icmp6(&'a Icmp6Header), Vxlan(&'a VxlanHeader), Geneve(GeneveHeaderOpt<'a>), Gre(GreHeaderOpt<'a>), Mpls(MplsLabelStack<'a>), Teredo(Box<TeredoPacket<'a>>), Gtpv1(Gtpv1HeaderOpt<'a>), Gtpv2(Gtpv2HeaderOpt<'a>), L2tpv2(L2tpv2HeaderOpt<'a>), L2tpv3(L2tpv3SessionHeaderCookie<'a>), Nvgre(&'a NvgreHeader), Pbb(PbbHeader<'a>), Stt(SttPacket<'a>), Pptp(PptpGreHeaderOpt<'a>), Ipip(IpipTunnel<'a>), Unknown { proto: UnknownProto, data: &'a [u8], },
}
Expand description

Enum wrapper for all supported packet headers

This enum provides a unified way to handle different protocol headers when iterating through a packet’s protocol stack.

Variants§

§

Ethernet(EtherHeaderVlan<'a>)

Ethernet II header (possibly with VLAN tags)

§

Sll(&'a SllHeader)

Linux cooked capture v1 header

§

Sllv2(&'a Sllv2Header)

Linux cooked capture v2 header

§

Null(&'a NullHeader)

BSD Null/Loopback header

§

Ipv4(Ipv4HeaderOpt<'a>)

IPv4 header with options

§

Ipv6(Ipv6HeaderExt<'a>)

IPv6 header with extension headers

§

Arp(ArpHeaderFull<'a>)

ARP header with addresses

§

Tcp(TcpHeaderOpt<'a>)

TCP header with options

§

Udp(&'a UdpHeader)

UDP header

§

Sctp(&'a SctpHeader)

SCTP header

§

Icmp(&'a IcmpHeader)

ICMPv4 header

§

Icmp6(&'a Icmp6Header)

ICMPv6 header

§

Vxlan(&'a VxlanHeader)

VXLAN tunnel header

§

Geneve(GeneveHeaderOpt<'a>)

Geneve tunnel header with options

§

Gre(GreHeaderOpt<'a>)

GRE tunnel header with options

§

Mpls(MplsLabelStack<'a>)

MPLS label stack

§

Teredo(Box<TeredoPacket<'a>>)

Teredo tunnel (parsed packet includes auth/origin indicators) Boxed to reduce Header enum size (TeredoPacket is 96 bytes)

§

Gtpv1(Gtpv1HeaderOpt<'a>)

GTPv1 header with options

§

Gtpv2(Gtpv2HeaderOpt<'a>)

GTPv2 header with options

§

L2tpv2(L2tpv2HeaderOpt<'a>)

L2TPv2 header with options

§

L2tpv3(L2tpv3SessionHeaderCookie<'a>)

L2TPv3 session header with cookie

§

Nvgre(&'a NvgreHeader)

NVGRE header (Network Virtualization using GRE)

§

Pbb(PbbHeader<'a>)

PBB header (Provider Backbone Bridge / MAC-in-MAC)

§

Stt(SttPacket<'a>)

STT packet (Stateless Transport Tunneling)

§

Pptp(PptpGreHeaderOpt<'a>)

PPTP GRE header with options

§

Ipip(IpipTunnel<'a>)

IP-in-IP tunnel (IPIP, SIT, IP4in6, IP6Tnl)

§

Unknown

Unknown/unsupported protocol

Contains the protocol identifier and the remaining unparsed data.

Fields

§proto: UnknownProto

The protocol that couldn’t be parsed

§data: &'a [u8]

The remaining unparsed data

Implementations§

Source§

impl<'a> Header<'a>

Source

pub fn name(&self) -> &'static str

Returns the name of the protocol

Returns true if this is a link layer header

Source

pub fn is_network_layer(&self) -> bool

Returns true if this is a network layer header

Source

pub fn is_transport_layer(&self) -> bool

Returns true if this is a transport layer header

Source

pub fn is_tunnel(&self) -> bool

Returns true if this is a tunnel header

Source

pub fn is_unknown(&self) -> bool

Returns true if this is an unknown protocol

Trait Implementations§

Source§

impl Debug for Header<'_>

Source§

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

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

impl Display for Header<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Header<'a>

§

impl<'a> RefUnwindSafe for Header<'a>

§

impl<'a> Send for Header<'a>

§

impl<'a> Sync for Header<'a>

§

impl<'a> Unpin for Header<'a>

§

impl<'a> UnwindSafe for Header<'a>

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> 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> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.