Struct pnet::packet::ethernet::EthernetPacket
source · pub struct EthernetPacket<'p> { /* private fields */ }
Expand description
A structure enabling manipulation of on the wire packets
Implementations§
source§impl<'a> EthernetPacket<'a>
impl<'a> EthernetPacket<'a>
sourcepub fn new<'p>(packet: &'p [u8]) -> Option<EthernetPacket<'p>>
pub fn new<'p>(packet: &'p [u8]) -> Option<EthernetPacket<'p>>
Constructs a new EthernetPacket. If the provided buffer is less than the minimum required packet size, this will return None.
sourcepub fn owned(packet: Vec<u8>) -> Option<EthernetPacket<'static>>
pub fn owned(packet: Vec<u8>) -> Option<EthernetPacket<'static>>
Constructs a new EthernetPacket. If the provided buffer is less than the minimum required packet size, this will return None. With this constructor the EthernetPacket will own its own data and the underlying buffer will be dropped when the EthernetPacket is.
sourcepub fn to_immutable<'p>(&'p self) -> EthernetPacket<'p>
pub fn to_immutable<'p>(&'p self) -> EthernetPacket<'p>
Maps from a EthernetPacket to a EthernetPacket
sourcepub fn consume_to_immutable(self) -> EthernetPacket<'a>
pub fn consume_to_immutable(self) -> EthernetPacket<'a>
Maps from a EthernetPacket to a EthernetPacket while consuming the source
sourcepub const fn minimum_packet_size() -> usize
pub const fn minimum_packet_size() -> usize
The minimum size (in bytes) a packet of this type can be. It’s based on the total size of the fixed-size fields.
sourcepub fn packet_size(_packet: &Ethernet) -> usize
pub fn packet_size(_packet: &Ethernet) -> usize
The size (in bytes) of a Ethernet instance when converted into a byte-array
sourcepub fn get_destination(&self) -> MacAddr
pub fn get_destination(&self) -> MacAddr
Get the value of the destination field
sourcepub fn get_source(&self) -> MacAddr
pub fn get_source(&self) -> MacAddr
Get the value of the source field
sourcepub fn get_ethertype(&self) -> EtherType
pub fn get_ethertype(&self) -> EtherType
Get the value of the ethertype field
Trait Implementations§
source§impl<'p> Debug for EthernetPacket<'p>
impl<'p> Debug for EthernetPacket<'p>
source§impl<'p> FromPacket for EthernetPacket<'p>
impl<'p> FromPacket for EthernetPacket<'p>
source§impl<'a> Packet for EthernetPacket<'a>
impl<'a> Packet for EthernetPacket<'a>
source§impl<'a> PacketSize for EthernetPacket<'a>
impl<'a> PacketSize for EthernetPacket<'a>
source§fn packet_size(&self) -> usize
fn packet_size(&self) -> usize
source§impl<'p> PartialEq for EthernetPacket<'p>
impl<'p> PartialEq for EthernetPacket<'p>
source§fn eq(&self, other: &EthernetPacket<'p>) -> bool
fn eq(&self, other: &EthernetPacket<'p>) -> bool
self
and other
values to be equal, and is used
by ==
.