pub struct ArpPacket<T>where
T: AsRef<[u8]>,{ /* private fields */ }
Expand description
A read/write wrapper around an Address Resolution Protocol packet buffer.
Implementations§
§impl<T> Packet<T>where
T: AsRef<[u8]>,
impl<T> Packet<T>where T: AsRef<[u8]>,
pub const fn new_unchecked(buffer: T) -> Packet<T>
pub const fn new_unchecked(buffer: T) -> Packet<T>
Imbue a raw octet buffer with ARP packet structure.
pub fn new_checked(buffer: T) -> Result<Packet<T>, Error>
pub fn new_checked(buffer: T) -> Result<Packet<T>, Error>
Shorthand for a combination of new_unchecked and check_len.
pub fn check_len(&self) -> Result<(), Error>
pub fn check_len(&self) -> Result<(), Error>
Ensure that no accessor method will panic if called.
Returns Err(Error)
if the buffer is too short.
The result of this check is invalidated by calling set_hardware_len or set_protocol_len.
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the packet, returning the underlying buffer.
pub fn hardware_type(&self) -> Hardware
pub fn hardware_type(&self) -> Hardware
Return the hardware type field.
pub fn protocol_type(&self) -> EtherType
pub fn protocol_type(&self) -> EtherType
Return the protocol type field.
pub fn hardware_len(&self) -> u8
pub fn hardware_len(&self) -> u8
Return the hardware length field.
pub fn protocol_len(&self) -> u8
pub fn protocol_len(&self) -> u8
Return the protocol length field.
pub fn source_hardware_addr(&self) -> &[u8]
pub fn source_hardware_addr(&self) -> &[u8]
Return the source hardware address field.
pub fn source_protocol_addr(&self) -> &[u8]
pub fn source_protocol_addr(&self) -> &[u8]
Return the source protocol address field.
pub fn target_hardware_addr(&self) -> &[u8]
pub fn target_hardware_addr(&self) -> &[u8]
Return the target hardware address field.
pub fn target_protocol_addr(&self) -> &[u8]
pub fn target_protocol_addr(&self) -> &[u8]
Return the target protocol address field.
§impl<T> Packet<T>where
T: AsRef<[u8]> + AsMut<[u8]>,
impl<T> Packet<T>where T: AsRef<[u8]> + AsMut<[u8]>,
pub fn set_hardware_type(&mut self, value: Hardware)
pub fn set_hardware_type(&mut self, value: Hardware)
Set the hardware type field.
pub fn set_protocol_type(&mut self, value: EtherType)
pub fn set_protocol_type(&mut self, value: EtherType)
Set the protocol type field.
pub fn set_hardware_len(&mut self, value: u8)
pub fn set_hardware_len(&mut self, value: u8)
Set the hardware length field.
pub fn set_protocol_len(&mut self, value: u8)
pub fn set_protocol_len(&mut self, value: u8)
Set the protocol length field.
pub fn set_operation(&mut self, value: Operation)
pub fn set_operation(&mut self, value: Operation)
Set the operation field.
pub fn set_source_hardware_addr(&mut self, value: &[u8])
pub fn set_source_hardware_addr(&mut self, value: &[u8])
Set the source hardware address field.
Panics
The function panics if value
is not self.hardware_len()
long.
pub fn set_source_protocol_addr(&mut self, value: &[u8])
pub fn set_source_protocol_addr(&mut self, value: &[u8])
Set the source protocol address field.
Panics
The function panics if value
is not self.protocol_len()
long.
pub fn set_target_hardware_addr(&mut self, value: &[u8])
pub fn set_target_hardware_addr(&mut self, value: &[u8])
Set the target hardware address field.
Panics
The function panics if value
is not self.hardware_len()
long.
pub fn set_target_protocol_addr(&mut self, value: &[u8])
pub fn set_target_protocol_addr(&mut self, value: &[u8])
Set the target protocol address field.
Panics
The function panics if value
is not self.protocol_len()
long.