Closed gardc closed 10 months ago
Hi @gardc ,
Etherparse currently does not directly support parsing of ARP packets. But you can get ARP packets by parsing the ethernet header and checking for the ARP ether_type:
use etherparse::{Ethernet2Header, ether_type, ReadError::UnexpectedEndOfSlice};
let (eth_header, eth_payload) = Ethernet2Header::from_slice(eth_packet)?;
if ether_type::ARP == eth.ether_type {
if eth_payload.len() < 8 {
return Err(UnexpectedEndOfSlice(eth_header.header_len()));
}
let arp_opcode = u16::from_be_bytes([eth_payload[6], eth_payload[7]]);
}
Oh ok, thanks for the example!
I'm trying to work with ARP packets, but I can't find any examples or documentation for this. More specifically, I'm trying to get the opcode (1=request, 2=reply) of an ARP packet. Any tips?