packet_formats::arp

Function peek_arp_types

Source
pub fn peek_arp_types<B: SplitByteSlice>(
    bytes: B,
) -> ParseResult<(ArpHardwareType, ArpNetworkType)>
Expand description

Peek at an ARP header to see what hardware and protocol address types are used.

Since ArpPacket is statically typed with the hardware and protocol address types expected in the header and body, these types must be known ahead of time before calling parse. If multiple different types are valid in a given parsing context, and so the caller cannot know ahead of time which types to use, peek_arp_types can be used to peek at the header first to figure out which static types should be used in a subsequent call to parse.

Note that peek_arp_types only inspects certain fields in the header, and so peek_arp_types succeeding does not guarantee that a subsequent call to parse will also succeed.