Struct pnet_packet::ethernet::MutableEthernetPacket
source · [−]pub struct MutableEthernetPacket<'p> { /* private fields */ }
Expand description
A structure enabling manipulation of on the wire packets
Implementations
sourceimpl<'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
sourceimpl<'p> Debug for MutableEthernetPacket<'p>
impl<'p> Debug for MutableEthernetPacket<'p>
sourceimpl<'p> FromPacket for MutableEthernetPacket<'p>
impl<'p> FromPacket for MutableEthernetPacket<'p>
sourcefn from_packet(&self) -> Ethernet
fn from_packet(&self) -> Ethernet
Converts a wire-format packet to #[packet] struct format.
sourceimpl<'a> MutablePacket for MutableEthernetPacket<'a>
impl<'a> MutablePacket for MutableEthernetPacket<'a>
sourcefn packet_mut<'p>(&'p mut self) -> &'p mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
fn packet_mut<'p>(&'p mut self) -> &'p mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Retreive the underlying, mutable, buffer for the packet.
sourcefn payload_mut<'p>(&'p mut self) -> &'p mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
fn payload_mut<'p>(&'p mut self) -> &'p mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Retreive the mutable payload for the packet.
sourcefn clone_from<T>(&mut self, other: &T) where
T: Packet,
fn clone_from<T>(&mut self, other: &T) where
T: Packet,
Initialize this packet by cloning another.
sourceimpl<'a> Packet for MutableEthernetPacket<'a>
impl<'a> Packet for MutableEthernetPacket<'a>
sourceimpl<'a> PacketSize for MutableEthernetPacket<'a>
impl<'a> PacketSize for MutableEthernetPacket<'a>
sourcefn packet_size(&self) -> usize
fn packet_size(&self) -> usize
Get the calculated size of the packet.
sourceimpl<'p> PartialEq<MutableEthernetPacket<'p>> for MutableEthernetPacket<'p>
impl<'p> PartialEq<MutableEthernetPacket<'p>> for MutableEthernetPacket<'p>
sourcefn eq(&self, other: &MutableEthernetPacket<'p>) -> bool
fn eq(&self, other: &MutableEthernetPacket<'p>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MutableEthernetPacket<'p>) -> bool
fn ne(&self, other: &MutableEthernetPacket<'p>) -> bool
This method tests for !=
.
impl<'p> StructuralPartialEq for MutableEthernetPacket<'p>
Auto Trait Implementations
impl<'p> RefUnwindSafe for MutableEthernetPacket<'p>
impl<'p> Send for MutableEthernetPacket<'p>
impl<'p> Sync for MutableEthernetPacket<'p>
impl<'p> Unpin for MutableEthernetPacket<'p>
impl<'p> !UnwindSafe for MutableEthernetPacket<'p>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more