Struct pnet_packet::vlan::MutableVlanPacket
source · [−]pub struct MutableVlanPacket<'p> { /* private fields */ }
Expand description
A structure enabling manipulation of on the wire packets
Implementations
sourceimpl<'a> MutableVlanPacket<'a>
impl<'a> MutableVlanPacket<'a>
sourcepub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableVlanPacket<'p>>
pub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableVlanPacket<'p>>
Constructs a new MutableVlanPacket. If the provided buffer is less than the minimum required packet size, this will return None.
sourcepub fn owned(packet: Vec<u8>) -> Option<MutableVlanPacket<'static>>
pub fn owned(packet: Vec<u8>) -> Option<MutableVlanPacket<'static>>
Constructs a new MutableVlanPacket. If the provided buffer is less than the minimum required packet size, this will return None. With this constructor the MutableVlanPacket will own its own data and the underlying buffer will be dropped when the MutableVlanPacket is.
sourcepub fn to_immutable<'p>(&'p self) -> VlanPacket<'p>
pub fn to_immutable<'p>(&'p self) -> VlanPacket<'p>
Maps from a MutableVlanPacket to a VlanPacket
sourcepub fn consume_to_immutable(self) -> VlanPacket<'a>
pub fn consume_to_immutable(self) -> VlanPacket<'a>
Maps from a MutableVlanPacket to a VlanPacket 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: &Vlan) -> usize
pub fn packet_size(_packet: &Vlan) -> usize
The size (in bytes) of a Vlan instance when converted into a byte-array
sourcepub fn get_priority_code_point(&self) -> ClassOfService
pub fn get_priority_code_point(&self) -> ClassOfService
Get the value of the priority_code_point field
sourcepub fn get_drop_eligible_indicator(&self) -> u1
pub fn get_drop_eligible_indicator(&self) -> u1
Get the drop_eligible_indicator field.
sourcepub fn get_vlan_identifier(&self) -> u12be
pub fn get_vlan_identifier(&self) -> u12be
Get the vlan_identifier field. This field is always stored big-endian within the struct, but this accessor returns host order.
sourcepub fn get_ethertype(&self) -> EtherType
pub fn get_ethertype(&self) -> EtherType
Get the value of the ethertype field
sourcepub fn set_priority_code_point(&mut self, val: ClassOfService)
pub fn set_priority_code_point(&mut self, val: ClassOfService)
Set the value of the priority_code_point field.
sourcepub fn set_drop_eligible_indicator(&mut self, val: u1)
pub fn set_drop_eligible_indicator(&mut self, val: u1)
Set the drop_eligible_indicator field.
sourcepub fn set_vlan_identifier(&mut self, val: u12be)
pub fn set_vlan_identifier(&mut self, val: u12be)
Set the vlan_identifier field. This field is always stored big-endian within the struct, but this mutator wants host order.
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 MutableVlanPacket<'p>
impl<'p> Debug for MutableVlanPacket<'p>
sourceimpl<'p> FromPacket for MutableVlanPacket<'p>
impl<'p> FromPacket for MutableVlanPacket<'p>
sourcefn from_packet(&self) -> Vlan
fn from_packet(&self) -> Vlan
Converts a wire-format packet to #[packet] struct format.
sourceimpl<'a> MutablePacket for MutableVlanPacket<'a>
impl<'a> MutablePacket for MutableVlanPacket<'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 MutableVlanPacket<'a>
impl<'a> Packet for MutableVlanPacket<'a>
sourceimpl<'a> PacketSize for MutableVlanPacket<'a>
impl<'a> PacketSize for MutableVlanPacket<'a>
sourcefn packet_size(&self) -> usize
fn packet_size(&self) -> usize
Get the calculated size of the packet.
sourceimpl<'p> PartialEq<MutableVlanPacket<'p>> for MutableVlanPacket<'p>
impl<'p> PartialEq<MutableVlanPacket<'p>> for MutableVlanPacket<'p>
sourcefn eq(&self, other: &MutableVlanPacket<'p>) -> bool
fn eq(&self, other: &MutableVlanPacket<'p>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MutableVlanPacket<'p>) -> bool
fn ne(&self, other: &MutableVlanPacket<'p>) -> bool
This method tests for !=
.
impl<'p> StructuralPartialEq for MutableVlanPacket<'p>
Auto Trait Implementations
impl<'p> RefUnwindSafe for MutableVlanPacket<'p>
impl<'p> Send for MutableVlanPacket<'p>
impl<'p> Sync for MutableVlanPacket<'p>
impl<'p> Unpin for MutableVlanPacket<'p>
impl<'p> !UnwindSafe for MutableVlanPacket<'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