Skip to main content

ArpHdr

Struct ArpHdr 

Source
#[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: u8

Hardware address length (HLEN): Length in bytes of a hardware address. Ethernet addresses size is 6.

§plen: u8

Protocol 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

Source

pub const LEN: usize

The size of the ARP header in bytes.

Source

pub fn new() -> Self

Creates a new ArpHdr with all fields initialized to zero. This is an alias for ArpHdr::default().

Source

pub fn htype(&self) -> u16

Returns the hardware type field.

Source

pub fn set_htype(&mut self, htype: u16)

Sets the hardware type field.

§Arguments
  • htype - A 2-byte array representing the hardware type.
Source

pub fn ptype(&self) -> u16

Returns the protocol type field.

Source

pub fn set_ptype(&mut self, ptype: u16)

Sets the protocol type field.

§Arguments
  • ptype - A 2-byte array representing the protocol type.
Source

pub fn hlen(&self) -> u8

Returns the hardware address length field.

Source

pub fn set_hlen(&mut self, hlen: u8)

Sets the hardware address length field.

§Arguments
  • hlen - A u8 value for the hardware address length.
Source

pub fn plen(&self) -> u8

Returns the protocol address length field.

Source

pub fn set_plen(&mut self, plen: u8)

Sets the protocol address length field.

§Arguments
  • plen - A u8 value for the protocol address length.
Source

pub fn oper(&self) -> u16

Returns the operation field.

Source

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).
Source

pub fn sha(&self) -> [u8; 6]

Returns the sender hardware address (SHA) field.

Source

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.
Source

pub fn spa(&self) -> [u8; 4]

Returns the sender protocol address (SPA) field.

Source

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.
Source

pub fn tha(&self) -> [u8; 6]

Returns the target hardware address (THA) field.

Source

pub fn set_tha(&mut self, hardware_address: [u8; 6])

Sets the target hardware address (THA) field.

§Arguments
  • hardware_address - A 6-byte array representing the target’s hardware address.
Source

pub fn tpa(&self) -> [u8; 4]

Returns the target protocol address (TPA) field.

Source

pub fn set_tpa(&mut self, protocol_address: [u8; 4])

Sets the target protocol address (TPA) field.

§Arguments
  • protocol_address - A 4-byte array representing the target’s protocol address.

Trait Implementations§

Source§

impl Clone for ArpHdr

Source§

fn clone(&self) -> ArpHdr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ArpHdr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ArpHdr

Source§

fn default() -> ArpHdr

Returns the “default value” for a type. Read more
Source§

impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for ArpHdr

Source§

const TYPE_META: TypeMeta

Metadata about the type’s serialization. Read more
Source§

type Dst = ArpHdr

Source§

fn read( reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>

Read into dst from reader. Read more
Source§

fn get(reader: impl Reader<'de>) -> Result<Self::Dst, ReadError>

Read Self::Dst from reader into a new Self::Dst.
Source§

impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for ArpHdr

Source§

const TYPE_META: TypeMeta

Metadata about the type’s serialization. Read more
Source§

type Src = ArpHdr

Source§

fn size_of(src: &Self::Src) -> WriteResult<usize>

Get the serialized size of Self::Src. Read more
Source§

fn write(writer: impl Writer, src: &Self::Src) -> WriteResult<()>

Write Self::Src to writer.
Source§

impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for ArpHdr
where 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>,

Like 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>,

Like crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.
Source§

impl Copy for ArpHdr

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'de, T> Deserialize<'de> for T
where T: SchemaRead<'de, Configuration>,

Source§

fn deserialize(src: &'de [u8]) -> Result<Self::Dst, ReadError>

Deserialize the input src bytes into a new Self::Dst.
Source§

fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>

Deserialize the input src bytes into dst.
Source§

impl<'de, T, C> Deserialize<'de, C> for T
where C: Config, T: SchemaRead<'de, C>,

Source§

fn deserialize(src: &'de [u8], config: C) -> Result<Self::Dst, ReadError>

Deserialize the input bytes into a new Self::Dst.
Source§

fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, config: C, ) -> Result<(), ReadError>

Deserialize the input bytes into dst.
Source§

impl<T, C> DeserializeOwned<C> for T
where C: Config, T: SchemaReadOwned<C>,

Source§

fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>

Deserialize from the given Reader into a new Self::Dst.
Source§

fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>

Deserialize from the given Reader into dst.
Source§

impl<T> DeserializeOwned for T

Source§

fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>

Deserialize from the given Reader into a new Self::Dst.
Source§

fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>

Deserialize from the given Reader into dst.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, C> Serialize<C> for T
where C: Config, T: SchemaWrite<C> + ?Sized,

Source§

fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>

Serialize a serializable type into the given Writer.
Source§

fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>

Get the size in bytes of the type when serialized.
Source§

impl<T> Serialize for T

Source§

fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>

Serialize a serializable type into the given byte buffer.
Source§

fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>

Get the size in bytes of the type when serialized.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ZeroCopy for T

Source§

fn from_bytes<'de>(bytes: &'de [u8]) -> Result<&'de Self, ReadError>
where Self: Sized + SchemaRead<'de, Configuration, Dst = Self>,

Get a reference to a type from the given bytes. Read more
Source§

fn from_bytes_mut<'de>(bytes: &'de mut [u8]) -> Result<&'de mut Self, ReadError>
where Self: Sized + SchemaRead<'de, Configuration, Dst = Self>,

Get a mutable reference to a type from the given bytes. Read more
Source§

impl<T, C> SchemaReadOwned<C> for T
where C: ConfigCore, T: for<'de> SchemaRead<'de, C>,