#[repr(C, packed(1))]pub struct EthHdr {
pub dst_addr: [u8; 6],
pub src_addr: [u8; 6],
pub ether_type: u16,
}Expand description
Ethernet header structure that appears at the beginning of every Ethernet frame. This structure represents the standard IEEE 802.3 Ethernet header format.
Fields§
§dst_addr: [u8; 6]Destination MAC address.
src_addr: [u8; 6]Source MAC address.
ether_type: u16Protocol which is encapsulated in the payload of the frame. Indicates what type of data follows the Ethernet header (e.g., IPv4, IPv6, ARP)
Implementations§
Source§impl EthHdr
impl EthHdr
pub const LEN: usize = 14usize
Sourcepub fn ether_type(&self) -> Result<EtherType, u16>
pub fn ether_type(&self) -> Result<EtherType, u16>
Attempts to convert the raw ether_type field into an EtherType enum. Returns either the corresponding EtherType variant or the raw value if unknown.
§Returns
Ok(EtherType)if a known protocol typeErr(u16)if an unknown protocol type (returns the raw value)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EthHdr
impl RefUnwindSafe for EthHdr
impl Send for EthHdr
impl Sync for EthHdr
impl Unpin for EthHdr
impl UnwindSafe for EthHdr
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