Trait retina_core::protocols::packet::Packet

source ·
pub trait Packet<'a> {
    // Required methods
    fn mbuf(&self) -> &Mbuf;
    fn header_len(&self) -> usize;
    fn next_header_offset(&self) -> usize;
    fn next_header(&self) -> Option<usize>;
    fn parse_from(outer: &'a impl Packet<'a>) -> Result<Self>
       where Self: Sized;

    // Provided method
    fn parse_to<T: Packet<'a>>(&'a self) -> Result<T>
       where Self: Sized { ... }
}
Expand description

Represents a single packet.

Required Methods§

source

fn mbuf(&self) -> &Mbuf

Reference to the underlying packet buffer.

source

fn header_len(&self) -> usize

Offset from the beginning of the header to the start of the payload.

source

fn next_header_offset(&self) -> usize

Offset from the beginning of the packet buffer to the start of the payload.

source

fn next_header(&self) -> Option<usize>

Next level IANA protocol number.

source

fn parse_from(outer: &'a impl Packet<'a>) -> Result<Self>
where Self: Sized,

Parses a Packet from the outer encapsulating Packet’s payload.

Provided Methods§

source

fn parse_to<T: Packet<'a>>(&'a self) -> Result<T>
where Self: Sized,

Parses the Packet’s payload as a new Packet of type T.

Implementors§

source§

impl<'a> Packet<'a> for Mbuf

source§

impl<'a> Packet<'a> for Ethernet<'a>

source§

impl<'a> Packet<'a> for Ipv4<'a>

source§

impl<'a> Packet<'a> for Ipv6<'a>

source§

impl<'a> Packet<'a> for Tcp<'a>

source§

impl<'a> Packet<'a> for Udp<'a>