Struct zero_packet::datalink::ethernet::EthernetReader
source · pub struct EthernetReader<'a> {
pub bytes: &'a [u8],
/* private fields */
}
Expand description
Reads Ethernet header fields.
Fields§
§bytes: &'a [u8]
Implementations§
source§impl<'a> EthernetReader<'a>
impl<'a> EthernetReader<'a>
sourcepub fn new(bytes: &'a [u8]) -> Result<Self, &'static str>
pub fn new(bytes: &'a [u8]) -> Result<Self, &'static str>
Creates a new EthernetReader
from the given slice.
sourcepub fn calculate_header_len(bytes: &[u8]) -> Result<usize, &'static str>
pub fn calculate_header_len(bytes: &[u8]) -> Result<usize, &'static str>
Calculates the header length of an Ethernet frame.
Depending on the presence of VLAN tagging, the header length may vary.
sourcepub fn is_vlan_tagged(bytes: &[u8]) -> bool
pub fn is_vlan_tagged(bytes: &[u8]) -> bool
Checks if the Ethernet frame is VLAN tagged.
sourcepub fn is_vlan_double_tagged(bytes: &[u8]) -> bool
pub fn is_vlan_double_tagged(bytes: &[u8]) -> bool
Checks if the Ethernet frame is double VLAN tagged (Q-in-Q).
sourcepub fn ethertype(&self) -> u16
pub fn ethertype(&self) -> u16
Returns the EtherType field field.
Indicates which network protocol is encapsulated.
sourcepub fn vlan_tag(&self) -> Option<(u16, u16)>
pub fn vlan_tag(&self) -> Option<(u16, u16)>
Returns the VLAN tag.
Optionally present in the Ethernet frame header.
sourcepub fn double_vlan_tag(&self) -> Option<((u16, u16), (u16, u16))>
pub fn double_vlan_tag(&self) -> Option<((u16, u16), (u16, u16))>
Returns the double VLAN tag (Q-in-Q).
Optionally present in the Ethernet frame header.
sourcepub const fn header_len(&self) -> usize
pub const fn header_len(&self) -> usize
Returns the header length in bytes.
Trait Implementations§
source§impl<'a> Debug for EthernetReader<'a>
impl<'a> Debug for EthernetReader<'a>
source§impl<'a> PartialEq for EthernetReader<'a>
impl<'a> PartialEq for EthernetReader<'a>
source§fn eq(&self, other: &EthernetReader<'a>) -> bool
fn eq(&self, other: &EthernetReader<'a>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<'a> StructuralPartialEq for EthernetReader<'a>
Auto Trait Implementations§
impl<'a> Freeze for EthernetReader<'a>
impl<'a> RefUnwindSafe for EthernetReader<'a>
impl<'a> Send for EthernetReader<'a>
impl<'a> Sync for EthernetReader<'a>
impl<'a> Unpin for EthernetReader<'a>
impl<'a> UnwindSafe for EthernetReader<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more