Struct pnet::packet::ethernet::MutableEthernetPacket
source · pub struct MutableEthernetPacket<'p> { /* private fields */ }
Expand description
A structure enabling manipulation of on the wire packets
Implementations§
source§impl<'a> MutableEthernetPacket<'a>
impl<'a> MutableEthernetPacket<'a>
sourcepub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableEthernetPacket<'p>>
pub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableEthernetPacket<'p>>
Constructs a new MutableEthernetPacket. If the provided buffer is less than the minimum required packet size, this will return None.
sourcepub fn owned(packet: Vec<u8>) -> Option<MutableEthernetPacket<'static>>
pub fn owned(packet: Vec<u8>) -> Option<MutableEthernetPacket<'static>>
Constructs a new MutableEthernetPacket. If the provided buffer is less than the minimum required packet size, this will return None. With this constructor the MutableEthernetPacket will own its own data and the underlying buffer will be dropped when the MutableEthernetPacket is.
sourcepub fn to_immutable<'p>(&'p self) -> EthernetPacket<'p>
pub fn to_immutable<'p>(&'p self) -> EthernetPacket<'p>
Maps from a MutableEthernetPacket to a EthernetPacket
sourcepub fn consume_to_immutable(self) -> EthernetPacket<'a>
pub fn consume_to_immutable(self) -> EthernetPacket<'a>
Maps from a MutableEthernetPacket 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 populate(&mut self, packet: &Ethernet)
pub fn populate(&mut self, packet: &Ethernet)
Populates a EthernetPacket using a Ethernet structure
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
sourcepub fn set_destination(&mut self, val: MacAddr)
pub fn set_destination(&mut self, val: MacAddr)
Set the value of the destination field.
sourcepub fn set_source(&mut self, val: MacAddr)
pub fn set_source(&mut self, val: MacAddr)
Set the value of the source field.
sourcepub fn set_ethertype(&mut self, val: EtherType)
pub fn set_ethertype(&mut self, val: EtherType)
Set the value of the ethertype field.
sourcepub fn set_payload(&mut self, vals: &[u8])
pub fn set_payload(&mut self, vals: &[u8])
Set the value of the payload field (copies contents)
Trait Implementations§
source§impl<'p> Debug for MutableEthernetPacket<'p>
impl<'p> Debug for MutableEthernetPacket<'p>
source§impl<'p> FromPacket for MutableEthernetPacket<'p>
impl<'p> FromPacket for MutableEthernetPacket<'p>
source§impl<'a> MutablePacket for MutableEthernetPacket<'a>
impl<'a> MutablePacket for MutableEthernetPacket<'a>
source§fn packet_mut<'p>(&'p mut self) -> &'p mut [u8] ⓘ
fn packet_mut<'p>(&'p mut self) -> &'p mut [u8] ⓘ
source§fn payload_mut<'p>(&'p mut self) -> &'p mut [u8] ⓘ
fn payload_mut<'p>(&'p mut self) -> &'p mut [u8] ⓘ
source§fn clone_from<T>(&mut self, other: &T)where
T: Packet,
fn clone_from<T>(&mut self, other: &T)where
T: Packet,
source§impl<'a> Packet for MutableEthernetPacket<'a>
impl<'a> Packet for MutableEthernetPacket<'a>
source§impl<'a> PacketSize for MutableEthernetPacket<'a>
impl<'a> PacketSize for MutableEthernetPacket<'a>
source§fn packet_size(&self) -> usize
fn packet_size(&self) -> usize
source§impl<'p> PartialEq for MutableEthernetPacket<'p>
impl<'p> PartialEq for MutableEthernetPacket<'p>
source§fn eq(&self, other: &MutableEthernetPacket<'p>) -> bool
fn eq(&self, other: &MutableEthernetPacket<'p>) -> bool
self
and other
values to be equal, and is used
by ==
.