pub struct EthernetLayer {
pub index: LayerIndex,
}Expand description
A view into an Ethernet II frame.
Fields§
§index: LayerIndexImplementations§
Source§impl EthernetLayer
impl EthernetLayer
pub const fn new(start: usize, end: usize) -> Self
pub const fn at_start() -> Self
pub const fn at_offset(offset: usize) -> Self
pub fn validate(buf: &[u8], offset: usize) -> Result<(), FieldError>
Sourcepub fn dispatch(buf: &[u8], offset: usize) -> EthernetFrameType
pub fn dispatch(buf: &[u8], offset: usize) -> EthernetFrameType
Dispatch hook: returns appropriate layer type based on type/length field
pub fn dst(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
pub fn src(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
pub fn ethertype(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn set_dst(&self, buf: &mut [u8], mac: MacAddress) -> Result<(), FieldError>
pub fn set_src(&self, buf: &mut [u8], mac: MacAddress) -> Result<(), FieldError>
pub fn set_ethertype( &self, buf: &mut [u8], etype: u16, ) -> Result<(), FieldError>
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
pub fn set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
pub fn set_field_value<V: Into<FieldValue>>( &self, buf: &mut [u8], name: &str, value: V, ) -> Option<Result<(), FieldError>>
pub fn field_names() -> &'static [&'static str]
Sourcepub fn hashret(&self, buf: &[u8]) -> Vec<u8> ⓘ
pub fn hashret(&self, buf: &[u8]) -> Vec<u8> ⓘ
Compute hash for packet matching. Returns type field + payload hash for matching request/response pairs.
Sourcepub fn answers(
&self,
buf: &[u8],
other: &EthernetLayer,
other_buf: &[u8],
) -> bool
pub fn answers( &self, buf: &[u8], other: &EthernetLayer, other_buf: &[u8], ) -> bool
Check if this packet answers another. For Ethernet, this delegates to payload matching.
Sourcepub fn extract_padding<'a>(&self, buf: &'a [u8]) -> (&'a [u8], &'a [u8])
pub fn extract_padding<'a>(&self, buf: &'a [u8]) -> (&'a [u8], &'a [u8])
Extract padding (Ethernet II has no padding concept at this layer)
pub fn payload<'a>(&self, buf: &'a [u8]) -> &'a [u8] ⓘ
pub fn payload_copy(&self, buf: &[u8]) -> Vec<u8> ⓘ
pub fn next_layer(&self, buf: &[u8]) -> Option<LayerKind>
pub fn is_broadcast(&self, buf: &[u8]) -> bool
pub fn is_multicast(&self, buf: &[u8]) -> bool
pub fn is_unicast(&self, buf: &[u8]) -> bool
pub fn header_bytes<'a>(&self, buf: &'a [u8]) -> &'a [u8] ⓘ
pub fn header_copy(&self, buf: &[u8]) -> Vec<u8> ⓘ
Sourcepub fn ethertype_name(&self, buf: &[u8]) -> &'static str
pub fn ethertype_name(&self, buf: &[u8]) -> &'static str
Get EtherType name
Trait Implementations§
Source§impl Clone for EthernetLayer
impl Clone for EthernetLayer
Source§fn clone(&self) -> EthernetLayer
fn clone(&self) -> EthernetLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EthernetLayer
impl Debug for EthernetLayer
Source§impl From<EthernetLayer> for LayerEnum
impl From<EthernetLayer> for LayerEnum
Source§fn from(v: EthernetLayer) -> LayerEnum
fn from(v: EthernetLayer) -> LayerEnum
Converts to this type from the input type.
Source§impl Layer for EthernetLayer
impl Layer for EthernetLayer
Source§fn header_len(&self, _buf: &[u8]) -> usize
fn header_len(&self, _buf: &[u8]) -> usize
Get the header length for this layer
Source§fn answers(&self, buf: &[u8], other: &Self, other_buf: &[u8]) -> bool
fn answers(&self, buf: &[u8], other: &Self, other_buf: &[u8]) -> bool
Check if this packet answers another packet.
Source§fn extract_padding<'a>(&self, buf: &'a [u8]) -> (&'a [u8], &'a [u8])
fn extract_padding<'a>(&self, buf: &'a [u8]) -> (&'a [u8], &'a [u8])
Extract padding from the packet.
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Get the list of field names for this layer
Source§impl LayerDispatch for EthernetLayer
impl LayerDispatch for EthernetLayer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Get the kind of this layer.
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Get the layer index (start/end offsets).
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Get a human-readable summary.
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Get the header length in bytes.
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Get field names for this layer type.
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get a field value by name.
Source§fn dispatch_set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Set a field value by name.
Auto Trait Implementations§
impl Freeze for EthernetLayer
impl RefUnwindSafe for EthernetLayer
impl Send for EthernetLayer
impl Sync for EthernetLayer
impl Unpin for EthernetLayer
impl UnsafeUnpin for EthernetLayer
impl UnwindSafe for EthernetLayer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more