#[repr(C)]pub struct ArpHdr {
pub htype: [u8; 2],
pub ptype: [u8; 2],
pub hlen: u8,
pub plen: u8,
pub oper: [u8; 2],
pub sha: [u8; 6],
pub spa: [u8; 4],
pub tha: [u8; 6],
pub tpa: [u8; 4],
}Expand description
Represents an Address Resolution Protocol (ARP) header.
The ARP header is typically found after the Ethernet header and is used to map a network protocol address (like an IPv4 address) to a hardware address (like a MAC address).
Fields§
§htype: [u8; 2]Hardware type (HTYPE): Specifies the network link protocol type. E.g., Ethernet is 1.
ptype: [u8; 2]Protocol type (PTYPE): Specifies the internetwork protocol for which the ARP request is intended. For IPv4, this has the value 0x0800.
hlen: u8Hardware address length (HLEN): Length in bytes of a hardware address. Ethernet addresses size is 6.
plen: u8Protocol address length (PLEN): Length in bytes of a logical address. IPv4 addresses size is 4.
oper: [u8; 2]Operation (OPER): Specifies the operation that the sender is performing: 1 for request, 2 for reply.
sha: [u8; 6]Sender hardware address (SHA): The hardware address of the sender.
spa: [u8; 4]Sender protocol address (SPA): The protocol address of the sender.
tha: [u8; 6]Target hardware address (THA): The hardware address of the intended receiver. This field is ignored in an ARP request.
tpa: [u8; 4]Target protocol address (TPA): The protocol address of the intended receiver.
Implementations§
Source§impl ArpHdr
impl ArpHdr
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ArpHdr with all fields initialized to zero.
This is an alias for ArpHdr::default().
Sourcepub fn set_hlen(&mut self, hlen: u8)
pub fn set_hlen(&mut self, hlen: u8)
Sets the hardware address length field.
§Arguments
hlen- A u8 value for the hardware address length.
Sourcepub fn set_plen(&mut self, plen: u8)
pub fn set_plen(&mut self, plen: u8)
Sets the protocol address length field.
§Arguments
plen- A u8 value for the protocol address length.
Sourcepub fn set_oper(&mut self, oper: u16)
pub fn set_oper(&mut self, oper: u16)
Sets the operation field.
§Arguments
oper- A 2-byte array representing the operation (e.g., request or reply).
Sourcepub fn set_sha(&mut self, hardware_address: [u8; 6])
pub fn set_sha(&mut self, hardware_address: [u8; 6])
Sets the sender hardware address (SHA) field.
§Arguments
hardware_address- A 6-byte array representing the sender’s hardware address.
Sourcepub fn set_spa(&mut self, protocol_address: [u8; 4])
pub fn set_spa(&mut self, protocol_address: [u8; 4])
Sets the sender protocol address (SPA) field.
§Arguments
protocol_address- A 4-byte array representing the sender’s protocol address.
Trait Implementations§
Source§impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for ArpHdr
impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for ArpHdr
Source§impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for ArpHdr
impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for ArpHdr
Source§impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for ArpHdrwhere
for<'_wincode_internal, '_wincode_internal, '_wincode_internal> [u8; 2]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> [u8; 6]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> [u8; 4]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> Assert<{ _ }>: IsTrue,
impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for ArpHdrwhere
for<'_wincode_internal, '_wincode_internal, '_wincode_internal> [u8; 2]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> [u8; 6]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> [u8; 4]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> Assert<{ _ }>: IsTrue,
Source§fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes, but allows the caller to provide a custom configuration.Source§fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.impl Copy for ArpHdr
Auto Trait Implementations§
impl Freeze for ArpHdr
impl RefUnwindSafe for ArpHdr
impl Send for ArpHdr
impl Sync for ArpHdr
impl Unpin for ArpHdr
impl UnsafeUnpin for ArpHdr
impl UnwindSafe for ArpHdr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
Source§impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
Source§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T, C> Serialize<C> for T
impl<T, C> Serialize<C> for T
Source§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Writer.