pub struct EthernetFrame<'a> { /* private fields */ }Expand description
Ethernet II frame views. Ethernet II frame views. Ethernet II frame views. A validated immutable borrow of one Ethernet II frame.
The fixed destination, source, and protocol-type header order follows RFC 894. Callers must remove any frame check sequence (FCS) before parsing because every supplied byte after the fixed header is payload.
Implementations§
Source§impl<'a> EthernetFrame<'a>
impl<'a> EthernetFrame<'a>
Source§impl<'a> EthernetFrame<'a>
impl<'a> EthernetFrame<'a>
Sourcepub fn parse(bytes: &'a [u8]) -> Result<Self, ParseError>
pub fn parse(bytes: &'a [u8]) -> Result<Self, ParseError>
Validates and borrows an Ethernet II frame.
The parser rejects inputs shorter than the 14-octet destination/source/type header described by RFC 894. Every remaining supplied octet is exposed unchanged as payload; callers must remove any frame check sequence (FCS) before parsing. No minimum payload length is imposed by this wire view.
Sourcepub fn destination(&self) -> MacAddress
pub fn destination(&self) -> MacAddress
Returns the destination Ethernet address.
RFC 894 places the destination address in the first six octets of the Ethernet header: https://www.rfc-editor.org/rfc/rfc894.
Sourcepub fn source(&self) -> MacAddress
pub fn source(&self) -> MacAddress
Returns the source Ethernet address.
RFC 894 places the source address immediately after the destination address: https://www.rfc-editor.org/rfc/rfc894.
Sourcepub fn ether_type(&self) -> EtherType
pub fn ether_type(&self) -> EtherType
Returns the Ethernet protocol type.
RFC 894 places the two-octet protocol type after the source address and transmits it most-significant octet first: https://www.rfc-editor.org/rfc/rfc894.
Sourcepub fn payload(&self) -> &'a [u8]
pub fn payload(&self) -> &'a [u8]
Returns the payload bytes following the fixed Ethernet II header.
This is the data field after the type field in the RFC 894 Ethernet encapsulation: https://www.rfc-editor.org/rfc/rfc894. The returned slice borrows the input.
Source§impl<'a> EthernetFrame<'a>
impl<'a> EthernetFrame<'a>
Sourcepub fn ipv4(&self) -> Result<Option<Ipv4Packet<'a>>, ParseError>
pub fn ipv4(&self) -> Result<Option<Ipv4Packet<'a>>, ParseError>
Parses IPv4 only for the IPv4 EtherType.
Source§impl<'a> EthernetFrame<'a>
impl<'a> EthernetFrame<'a>
Sourcepub fn ipv6(&self) -> Result<Option<Ipv6Packet<'a>>, ParseError>
pub fn ipv6(&self) -> Result<Option<Ipv6Packet<'a>>, ParseError>
Parses IPv6 only when this frame’s EtherType is IPv6.