JFLib

netpkt/arp.rs#

Source: lib/netpkt/arp.rs

arp -- the Address Resolution Protocol for IPv4 over Ethernet (RFC 826, 5227)

  ArpView::parse(b)     only htype 1 / ptype 0x0800 / hlen 6 / plen 4 is accepted
  Arp { op, sha, spa, tha, tpa }   request / reply / probe / announce, write, push_onto

A gratuitous ARP has spa == tpa; an ARP probe (RFC 5227) has spa 0.0.0.0.
ARP_LEN: usize = 28
OP_REQUEST: u16 = 1
OP_REPLY: u16 = 2
  • struct ArpView<'a> a received ARP packet for IPv4 over Ethernet

impl<'a> ArpView<'a>

  • fn parse(b: &'a [u8]) -> Option<ArpView<'a>>

  • fn op(&self) -> u16

  • fn sha(&self) -> Mac

  • fn spa(&self) -> Ipv4

  • fn tha(&self) -> Mac

  • fn tpa(&self) -> Ipv4

  • struct Arp an ARP packet to write

    • op: u16
    • sha: Mac
    • spa: Ipv4
    • tha: Mac
    • tpa: Ipv4

impl Arp

  • const LEN: usize = ARP_LEN
  • fn read(v: &ArpView) -> Arp
  • fn request(sha: Mac, spa: Ipv4, tpa: Ipv4) -> Arp "who has tpa? tell spa"
  • fn reply_to(req: &Arp, mac: Mac, ip: Ipv4) -> Arp the answer to a request: mac has ip
  • fn probe(sha: Mac, tpa: Ipv4) -> Arp an RFC 5227 probe: sender address 0.0.0.0
  • fn announce(sha: Mac, ip: Ipv4) -> Arp a gratuitous announcement of the own address
  • fn is_gratuitous(&self) -> bool
  • fn is_probe(&self) -> bool
  • fn write(&self, out: &mut [u8])
  • fn push_onto(&self, p: &mut Pkt)

Source: docs/API.md in the JFLib repository.