Struct pnet_packet::sll::MutableSLLPacket
source · pub struct MutableSLLPacket<'p> { /* private fields */ }
Expand description
A structure enabling manipulation of on the wire packets
Implementations§
source§impl<'a> MutableSLLPacket<'a>
impl<'a> MutableSLLPacket<'a>
sourcepub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableSLLPacket<'p>>
pub fn new<'p>(packet: &'p mut [u8]) -> Option<MutableSLLPacket<'p>>
Constructs a new MutableSLLPacket. If the provided buffer is less than the minimum required packet size, this will return None.
sourcepub fn owned(packet: Vec<u8>) -> Option<MutableSLLPacket<'static>>
pub fn owned(packet: Vec<u8>) -> Option<MutableSLLPacket<'static>>
Constructs a new MutableSLLPacket. If the provided buffer is less than the minimum required packet size, this will return None. With this constructor the MutableSLLPacket will own its own data and the underlying buffer will be dropped when the MutableSLLPacket is.
sourcepub fn to_immutable<'p>(&'p self) -> SLLPacket<'p>
pub fn to_immutable<'p>(&'p self) -> SLLPacket<'p>
Maps from a MutableSLLPacket to a SLLPacket
sourcepub fn consume_to_immutable(self) -> SLLPacket<'a>
pub fn consume_to_immutable(self) -> SLLPacket<'a>
Maps from a MutableSLLPacket to a SLLPacket 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: &SLL) -> usize
pub fn packet_size(_packet: &SLL) -> usize
The size (in bytes) of a SLL instance when converted into a byte-array
sourcepub fn get_packet_type(&self) -> u16be
pub fn get_packet_type(&self) -> u16be
Get the packet_type field. This field is always stored big-endian within the struct, but this accessor returns host order.
sourcepub fn get_link_layer_address_type(&self) -> u16be
pub fn get_link_layer_address_type(&self) -> u16be
Get the link_layer_address_type field. This field is always stored big-endian within the struct, but this accessor returns host order.
sourcepub fn get_link_layer_address_len(&self) -> u16be
pub fn get_link_layer_address_len(&self) -> u16be
Get the link_layer_address_len field. This field is always stored big-endian within the struct, but this accessor returns host order.
sourcepub fn get_link_layer_address_raw(&self) -> &[u8] ⓘ
pub fn get_link_layer_address_raw(&self) -> &[u8] ⓘ
Get the raw &u8 value of the link_layer_address field, without copying
sourcepub fn get_link_layer_address(&self) -> Vec<u8>
pub fn get_link_layer_address(&self) -> Vec<u8>
Get the value of the link_layer_address field (copies contents)
sourcepub fn get_protocol(&self) -> EtherType
pub fn get_protocol(&self) -> EtherType
Get the value of the protocol field
sourcepub fn set_packet_type(&mut self, val: u16be)
pub fn set_packet_type(&mut self, val: u16be)
Set the packet_type field. This field is always stored big-endian within the struct, but this mutator wants host order.
sourcepub fn set_link_layer_address_type(&mut self, val: u16be)
pub fn set_link_layer_address_type(&mut self, val: u16be)
Set the link_layer_address_type field. This field is always stored big-endian within the struct, but this mutator wants host order.
sourcepub fn set_link_layer_address_len(&mut self, val: u16be)
pub fn set_link_layer_address_len(&mut self, val: u16be)
Set the link_layer_address_len field. This field is always stored big-endian within the struct, but this mutator wants host order.
sourcepub fn get_link_layer_address_raw_mut(&mut self) -> &mut [u8] ⓘ
pub fn get_link_layer_address_raw_mut(&mut self) -> &mut [u8] ⓘ
Get the raw &mut u8 value of the link_layer_address field, without copying
sourcepub fn set_link_layer_address(&mut self, vals: &[u8])
pub fn set_link_layer_address(&mut self, vals: &[u8])
Set the value of the link_layer_address field (copies contents)
sourcepub fn set_protocol(&mut self, val: EtherType)
pub fn set_protocol(&mut self, val: EtherType)
Set the value of the protocol 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 MutableSLLPacket<'p>
impl<'p> Debug for MutableSLLPacket<'p>
source§impl<'p> FromPacket for MutableSLLPacket<'p>
impl<'p> FromPacket for MutableSLLPacket<'p>
source§impl<'a> MutablePacket for MutableSLLPacket<'a>
impl<'a> MutablePacket for MutableSLLPacket<'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 MutableSLLPacket<'a>
impl<'a> Packet for MutableSLLPacket<'a>
source§impl<'a> PacketSize for MutableSLLPacket<'a>
impl<'a> PacketSize for MutableSLLPacket<'a>
source§fn packet_size(&self) -> usize
fn packet_size(&self) -> usize
source§impl<'p> PartialEq<MutableSLLPacket<'p>> for MutableSLLPacket<'p>
impl<'p> PartialEq<MutableSLLPacket<'p>> for MutableSLLPacket<'p>
source§fn eq(&self, other: &MutableSLLPacket<'p>) -> bool
fn eq(&self, other: &MutableSLLPacket<'p>) -> bool
self
and other
values to be equal, and is used
by ==
.