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 Debug for EthernetReader<'_>
impl Debug for EthernetReader<'_>
Source§impl<'a> ParseReader<'a> for EthernetReader<'a>
impl<'a> ParseReader<'a> for EthernetReader<'a>
Source§impl<'a> PartialEq for EthernetReader<'a>
impl<'a> PartialEq for EthernetReader<'a>
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