arp

package
v0.0.0-...-3cdddeb Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Completed entry (ha valid).
	ATF_COM int32 = 0x02

	// Permanent entry.
	ATF_PERM int32 = 0x04

	// Publish entry.
	ATF_PUBL int32 = 0x08

	// Has requested trailers.
	ATF_USETRAILERS int32 = 0x10

	// Want to use a netmask (only for proxy entries).
	ATF_NETMASK int32 = 0x20

	// Don't answer this addresses.
	ATF_DONTPUB int32 = 0x40

	// Automatically added entry.
	ATF_MAGIC int32 = 0x80
)

ARP Flags values. See net/if_arp.h.

View Source
const (
	ARPHRD_NETROM     uint16 = 0  /* From KA9Q: NET/ROM pseudo. */
	ARPHRD_ETHER      uint16 = 1  /* Ethernet 10/100Mbps.  */
	ARPHRD_EETHER     uint16 = 2  /* Experimental Ethernet.  */
	ARPHRD_AX25       uint16 = 3  /* AX.25 Level 2.  */
	ARPHRD_PRONET     uint16 = 4  /* PROnet token ring.  */
	ARPHRD_CHAOS      uint16 = 5  /* Chaosnet.  */
	ARPHRD_IEEE802    uint16 = 6  /* IEEE 802.2 Ethernet/TR/TB.  */
	ARPHRD_ARCNET     uint16 = 7  /* ARCnet.  */
	ARPHRD_APPLETLK   uint16 = 8  /* APPLEtalk.  */
	ARPHRD_DLCI       uint16 = 15 /* Frame Relay DLCI.  */
	ARPHRD_ATM        uint16 = 19 /* ATM.  */
	ARPHRD_METRICOM   uint16 = 23 /* Metricom STRIP (new IANA id).  */
	ARPHRD_IEEE1394   uint16 = 24 /* IEEE 1394 IPv4 - RFC 2734.  */
	ARPHRD_EUI64      uint16 = 27 /* EUI-64.  */
	ARPHRD_INFINIBAND uint16 = 32 /* InfiniBand.  */

)

ARP protocol HARDWARE identifiers.

Variables

View Source
var (
	BroadcastMAC = net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
	ZeroMAC      = net.HardwareAddr{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
)
View Source
var (
	// Requested IP is not is not in cache.
	ErrNotFound = errors.New("no such device or address")
)

Functions

func DelARPCache

func DelARPCache(entry Entry) error

DelARPCache removes the ARP entry from the kernel's cache.

func SetARPCache

func SetARPCache(entry Entry) error

SetARPCache set the ARP entry in the kernel's cache.

Types

type Entry

type Entry struct {
	IP     net.IP              //
	Type   uint16              //
	Flags  int32               //
	Addr   net.HardwareAddr    // MAC
	Mask   syscall.RawSockaddr // Used in Proxy ARP. Not implemented but returned, somebody maybe find it useful.
	Device *net.Interface      // Entry valid for this interface
}

Represent an ARP entry

func Get

func Get(ip net.IP, timeout time.Duration) (Entry, error)

Get query the kernel's cache first. If the entry is not in the cache, do an ARP request and registers the entry in the cache (if CAP_NET_ADMIN is set).

func GetARPCache

func GetARPCache(ip net.IP, dev *net.Interface) (Entry, error)

GetARPCache look for the entry associated to ip and iface from the kernel's cache. If iface is nil, select the one automatically.

func Request

func Request(ip net.IP, dev *net.Interface, timeout time.Duration) (Entry, error)

Request do an ARP request with raw socket. Returns the MAC associated to ip. If dev is nil, automatically select one. If CAP_NET_ADMIN is set, this function registers the entry to the kernel's ARP cache.

func (Entry) String

func (c Entry) String() string

The string is separated with a \t. The Mask is ignored.

Directories

Path Synopsis
* Example CLI for arp package.
* Example CLI for arp package.

Jump to

Keyboard shortcuts

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