#[repr(C, packed)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Serialize, Deserialize)]
pub struct AddressResolutionProtocolPacketHeader
{
pub hardware_type: HardwareType,
#[allow(missing_docs)]
pub protocol_type: EtherType,
#[allow(missing_docs)]
pub hardware_address_length: u8,
#[allow(missing_docs)]
pub protocol_address_length: u8,
#[allow(missing_docs)]
pub operation: Operation,
}
impl Display for AddressResolutionProtocolPacketHeader
{
#[inline(always)]
fn fmt(&self, f: &mut Formatter) -> fmt::Result
{
Debug::fmt(self, f)
}
}
impl AddressResolutionProtocolPacketHeader
{
pub(crate) const HeaderSizeU16: u16 = size_of::<Self>() as u16;
#[inline(always)]
pub(crate) fn is_packet_length_too_short(layer_3_length: u16) -> bool
{
layer_3_length < Self::HeaderSizeU16
}
#[inline(always)]
pub(crate) fn is_header_invalid_for_internet_protocol_version_4(&self) -> bool
{
self.is_hardware_type_not_ethernet_2() || self.is_protocol_type_not_internet_protocol_version_4() || self.is_hardware_address_length_not_valid_for_ethernet_2() || self.is_protocol_address_length_not_valid_for_internet_protocol_version_4()
}
#[inline(always)]
fn is_hardware_type_not_ethernet_2(&self) -> bool
{
self.hardware_type.is_not_ethernet_2()
}
#[inline(always)]
fn is_protocol_type_not_internet_protocol_version_4(&self) -> bool
{
self.protocol_type.is_not_internet_protocol_version_4()
}
#[inline(always)]
fn is_hardware_address_length_not_valid_for_ethernet_2(&self) -> bool
{
self.hardware_address_length != MediaAccessControlAddress::SizeU8
}
#[inline(always)]
fn is_protocol_address_length_not_valid_for_internet_protocol_version_4(&self) -> bool
{
self.protocol_address_length != InternetProtocolVersion4HostAddress::SizeU8
}
}