arp

package
v0.0.0-...-d996040 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame struct {
	// contains filtered or unexported fields
}

Frame encapsulates the raw data of an ARP packet and provides methods for manipulating, validating and retrieving fields and payload data. See RFC826.

func NewFrame

func NewFrame(buf []byte) (Frame, error)

NewARPFrame returns a ARPFrame with data set to buf. An error is returned if the buffer size is smaller than 28 (IPv4 min size). Users should still call [ARPFrame.ValidateSize] before working with payload/options of frames to avoid panics.

func (Frame) ClearHeader

func (afrm Frame) ClearHeader()

ClearHeader zeros out the fixed(non-variable) header contents.

func (Frame) Clip

func (afrm Frame) Clip() Frame

func (Frame) Hardware

func (afrm Frame) Hardware() (Type uint16, length uint8)

HardwareType specifies the network link protocol type. Example: Ethernet is 1.

func (Frame) Operation

func (afrm Frame) Operation() Operation

Operation returns the ARP header operation field. See Operation.

func (Frame) Protocol

func (afrm Frame) Protocol() (Type ethernet.Type, length uint8)

Protocol returns the internet protocol type and length. See ethernet.Type.

func (Frame) RawData

func (afrm Frame) RawData() []byte

RawData returns the underlying slice with which the frame was created.

func (Frame) Sender

func (afrm Frame) Sender() (hardwareAddr []byte, proto []byte)

Sender returns the hardware (MAC) and protocol addresses of sender of ARP packet. In an ARP request MAC address is used to indicate the address of the host sending the request. In an ARP reply MAC address is used to indicate the address of the host that the request was looking for.

func (Frame) Sender16

func (afrm Frame) Sender16() (hardwareAddr *[6]byte, proto *[16]byte)

Sender6 returns the IPv6 sender addresses. See Frame.Sender.

func (Frame) Sender4

func (afrm Frame) Sender4() (hardwareAddr *[6]byte, proto *[4]byte)

Sender4 returns the IPv4 sender addresses. See Frame.Sender.

func (Frame) SetHardware

func (afrm Frame) SetHardware(Type uint16, length uint8)

SetHardware sets the networl link protocol type. See Frame.SetHardware.

func (Frame) SetOperation

func (afrm Frame) SetOperation(op Operation)

SetOperation sets the ARP header operation field. See Operation.

func (Frame) SetProtocol

func (afrm Frame) SetProtocol(Type ethernet.Type, length uint8)

SetProtocol sets the protocol type and length fields of the ARP frame. See Frame.Protocol and ethernet.Type.

func (Frame) String

func (afrm Frame) String() string

func (Frame) SwapTargetSender

func (afrm Frame) SwapTargetSender()

func (Frame) Target

func (afrm Frame) Target() (hardwareAddr []byte, proto []byte)

Target returns the hardware (MAC) and protocol addresses of target of ARP packet. In an ARP request MAC target is ignored. In ARP reply MAC is used to indicate the address of host that originated request.

func (Frame) Target16

func (afrm Frame) Target16() (hardwareAddr *[6]byte, proto *[16]byte)

Target6 returns the IPv6 target addresses. See Frame.Sender.

func (Frame) Target4

func (afrm Frame) Target4() (hardwareAddr *[6]byte, proto *[4]byte)

Target4 returns the IPv4 target addresses. See Frame.Sender.

func (Frame) ValidateSize

func (afrm Frame) ValidateSize(v *lneto2.Validator)

Validation API

ValidateSize checks the frame's size fields and compares with the actual buffer the frame. It returns a non-nil error on finding an inconsistency.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(cfg HandlerConfig) (*Handler, error)

func (*Handler) QueryResult

func (c *Handler) QueryResult(protoAddr []byte) (hwAddr []byte, err error)

func (*Handler) Recv

func (c *Handler) Recv(b []byte) error

func (*Handler) ResetState

func (c *Handler) ResetState()

ResetState drops pending queries and incoming requests.

func (*Handler) Send

func (c *Handler) Send(b []byte) (int, error)

func (*Handler) StartQuery

func (c *Handler) StartQuery(proto []byte) error

type HandlerConfig

type HandlerConfig struct {
	HardwareAddr []byte
	ProtocolAddr []byte
	MaxQueries   int
	MaxPending   int
	HardwareType uint16
	ProtocolType ethernet.Type
}

type Operation

type Operation uint16

Operation represents the type of ARP packet, either request or reply/response.

const (
	OpRequest Operation = 1 // request
	OpReply   Operation = 2 // reply
)

func (Operation) String

func (i Operation) String() string

Jump to

Keyboard shortcuts

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