pub struct EthernetFrameMut<'a> { /* private fields */ }Expand description
Ethernet II frame views. Ethernet II frame views. Ethernet II frame views. A validated mutable borrow of one Ethernet II frame.
Its fixed header uses the destination, source, and protocol-type order described by 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> EthernetFrameMut<'a>
impl<'a> EthernetFrameMut<'a>
Sourcepub fn arp_mut(&mut self) -> Result<Option<ArpPacketMut<'_>>, ParseError>
pub fn arp_mut(&mut self) -> Result<Option<ArpPacketMut<'_>>, ParseError>
Parses a mutable ARP payload only when this frame’s EtherType is ARP.
Source§impl<'a> EthernetFrameMut<'a>
impl<'a> EthernetFrameMut<'a>
Sourcepub fn parse(bytes: &'a mut [u8]) -> Result<Self, ParseError>
pub fn parse(bytes: &'a mut [u8]) -> Result<Self, ParseError>
Validates and mutably 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 payload and remains available for independent protocol parsing; callers must remove any frame check sequence (FCS) before parsing.
Sourcepub fn destination(&self) -> MacAddress
pub fn destination(&self) -> MacAddress
Returns the destination Ethernet address.
RFC 894 assigns the first six header octets to the destination address: https://www.rfc-editor.org/rfc/rfc894.
Sourcepub fn source(&self) -> MacAddress
pub fn source(&self) -> MacAddress
Returns the source Ethernet address.
RFC 894 assigns the next six header octets to the source 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 this two-octet, most-significant-octet-first field after the source address: https://www.rfc-editor.org/rfc/rfc894.
Sourcepub fn set_destination(&mut self, address: MacAddress)
pub fn set_destination(&mut self, address: MacAddress)
Replaces the destination Ethernet address.
This writes the first six header octets assigned to the destination address by RFC 894.
Sourcepub fn set_source(&mut self, address: MacAddress)
pub fn set_source(&mut self, address: MacAddress)
Replaces the source Ethernet address.
This writes the six header octets assigned to the source address by RFC 894.
Sourcepub fn set_ether_type(&mut self, ether_type: EtherType)
pub fn set_ether_type(&mut self, ether_type: EtherType)
Replaces the Ethernet protocol type.
This writes the most-significant-octet-first type field specified by RFC 894.
Sourcepub fn payload(&self) -> &[u8]
pub fn payload(&self) -> &[u8]
Returns the payload bytes following the fixed Ethernet II header.
This borrows the data field after the type field in RFC 894’s encapsulation: https://www.rfc-editor.org/rfc/rfc894.
Sourcepub fn payload_mut(&mut self) -> &mut [u8] ⓘ
pub fn payload_mut(&mut self) -> &mut [u8] ⓘ
Returns mutable payload bytes following the fixed Ethernet II header.
This mutably borrows the data field after the type field in RFC 894’s encapsulation: https://www.rfc-editor.org/rfc/rfc894.
Sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Returns all represented frame bytes.
The represented order is destination, source, type, then payload as described by RFC 894.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Returns all represented mutable frame bytes.
The represented order is destination, source, type, then payload as described by RFC 894.
Source§impl<'a> EthernetFrameMut<'a>
impl<'a> EthernetFrameMut<'a>
Sourcepub fn ipv4_mut(&mut self) -> Result<Option<Ipv4PacketMut<'_>>, ParseError>
pub fn ipv4_mut(&mut self) -> Result<Option<Ipv4PacketMut<'_>>, ParseError>
Parses mutable IPv4 only for the IPv4 EtherType.
Source§impl<'a> EthernetFrameMut<'a>
impl<'a> EthernetFrameMut<'a>
Sourcepub fn ipv6_mut(&mut self) -> Result<Option<Ipv6PacketMut<'_>>, ParseError>
pub fn ipv6_mut(&mut self) -> Result<Option<Ipv6PacketMut<'_>>, ParseError>
Parses mutable IPv6 only when this frame’s EtherType is IPv6.