#[repr(C, packed(1))]pub struct ArpPacket {
pub htype: u16,
pub ptype: u16,
pub hlen: u8,
pub plen: u8,
pub operation: u16,
pub sender_mac: [u8; 6],
pub sender_ip: [u8; 4],
pub target_mac: [u8; 6],
pub target_ip: [u8; 4],
}Expand description
ARP packet header (28 bytes)
Fields§
§htype: u16Hardware type (e.g., Ethernet)
ptype: u16Protocol type (e.g., IPv4)
hlen: u8Hardware address length
plen: u8Protocol address length
operation: u16Operation (request/reply)
sender_mac: [u8; 6]Sender hardware address
sender_ip: [u8; 4]Sender protocol address
target_mac: [u8; 6]Target hardware address (zeros in request)
target_ip: [u8; 4]Target protocol address
Implementations§
Source§impl ArpPacket
impl ArpPacket
Sourcepub fn reply(
sender_mac: [u8; 6],
sender_ip: [u8; 4],
target_mac: [u8; 6],
) -> Self
pub fn reply( sender_mac: [u8; 6], sender_ip: [u8; 4], target_mac: [u8; 6], ) -> Self
Create an ARP reply
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Parse ARP packet from bytes
Sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
Check if this is an ARP request
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ArpPacket
impl RefUnwindSafe for ArpPacket
impl Send for ArpPacket
impl Sync for ArpPacket
impl Unpin for ArpPacket
impl UnwindSafe for ArpPacket
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)