pub struct packet(/* private fields */);Expand description
A byte sequence representing an ARP packet.
Implementations§
Source§impl arp
impl arp
Sourcepub fn new_unchecked(buffer: &[u8]) -> &arp
pub fn new_unchecked(buffer: &[u8]) -> &arp
Imbue a raw octet buffer with ARP packet structure.
Sourcepub fn new_unchecked_mut(buffer: &mut [u8]) -> &mut arp
pub fn new_unchecked_mut(buffer: &mut [u8]) -> &mut arp
Imbue a mutable octet buffer with ARP packet structure.
Sourcepub fn new_checked(data: &[u8]) -> Result<&arp>
pub fn new_checked(data: &[u8]) -> Result<&arp>
Shorthand for a combination of new_unchecked and check_len.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8]
pub fn as_bytes_mut(&mut self) -> &mut [u8]
Unwrap the packet as a mutable raw byte slice.
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Ensure that no accessor method will panic if called.
Returns Err(Error::Truncated) if the buffer is too short.
The result of this check is invalidated by calling set_hardware_len or set_protocol_len.
Sourcepub fn hardware_type(&self) -> Hardware
pub fn hardware_type(&self) -> Hardware
Return the hardware type field.
Sourcepub fn protocol_type(&self) -> Protocol
pub fn protocol_type(&self) -> Protocol
Return the protocol type field.
Sourcepub fn hardware_len(&self) -> u8
pub fn hardware_len(&self) -> u8
Return the hardware length field.
Sourcepub fn protocol_len(&self) -> u8
pub fn protocol_len(&self) -> u8
Return the protocol length field.
Sourcepub fn source_hardware_addr(&self) -> Address
pub fn source_hardware_addr(&self) -> Address
Return the source hardware address field.
Sourcepub fn source_protocol_addr(&self) -> IpAddress
pub fn source_protocol_addr(&self) -> IpAddress
Return the source protocol address field.
Sourcepub fn target_hardware_addr(&self) -> Address
pub fn target_hardware_addr(&self) -> Address
Return the target hardware address field.
Sourcepub fn target_protocol_addr(&self) -> IpAddress
pub fn target_protocol_addr(&self) -> IpAddress
Return the target protocol address field.
Sourcepub fn set_hardware_type(&mut self, value: Hardware)
pub fn set_hardware_type(&mut self, value: Hardware)
Set the hardware type field.
Sourcepub fn set_protocol_type(&mut self, value: Protocol)
pub fn set_protocol_type(&mut self, value: Protocol)
Set the protocol type field.
Sourcepub fn set_hardware_len(&mut self, value: u8)
pub fn set_hardware_len(&mut self, value: u8)
Set the hardware length field.
Sourcepub fn set_protocol_len(&mut self, value: u8)
pub fn set_protocol_len(&mut self, value: u8)
Set the protocol length field.
Sourcepub fn set_operation(&mut self, value: Operation)
pub fn set_operation(&mut self, value: Operation)
Set the operation field.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.