arp

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckARPTable

func CheckARPTable(ip net.IP, iface *net.Interface) (net.HardwareAddr, error)

CheckARPTable checks if IP is in the kernel ARP table for the provided interface and returns the corresponding MAC address if found. It supports Linux, Darwin (macOS) and FreeBSD platforms.

func CreateARPRequest

func CreateARPRequest(srcMAC net.HardwareAddr, srcIP, dstIP net.IP) ([]byte, error)

CreateARPRequest creates an ARP request packet as bytes. This function is pure and easily testable.

func Get

func Get(ip net.IP, iface *net.Interface, src net.IP) (net.HardwareAddr, error)

Get retrieves the MAC address for a given IP address. It first checks the kernel ARP table and if not found, sends an ARP request.

func IsARPReplyFor

func IsARPReplyFor(packet gopacket.Packet, targetIP net.IP) (net.HardwareAddr, bool)

IsARPReplyFor checks if the given packet is an ARP reply for the target IP. This function is pure and easily testable.

func RecvARPRequest

func RecvARPRequest(handle *pcap.Handle, arpChan chan net.HardwareAddr, ip net.IP, stop chan struct{}) error

RecvARPRequest listens for ARP requests on the provided handle and sends the MAC address to the channel if the sender IP matches the provided ip

func SendARPRequest

func SendARPRequest(handle *pcap.Handle, srcMAC net.HardwareAddr, srcIP, dstIP net.IP) error

SendARPRequest sends an ARP request to the network using the provided handle

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL