lib

package
v0.0.0-...-77d4faf Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP

func GetLocalIP(dstIP net.IP) (net.IP, *net.Interface, net.IP, error)

getLocalIP finds the local IP that can route to the given destination IP

func Htons

func Htons(port uint16) uint16

Htons converts a 16-bit number from host byte order to network byte order.

func ListInterfaces

func ListInterfaces() error

listInterfaces prints the available network interfaces

Types

type ARPCache

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

func NewARPCache

func NewARPCache(timeout time.Duration) *ARPCache

func (*ARPCache) Add

func (cache *ARPCache) Add(ip string, mac net.HardwareAddr)

func (*ARPCache) Close

func (cache *ARPCache) Close()

func (*ARPCache) Lookup

func (cache *ARPCache) Lookup(ip string) (net.HardwareAddr, bool)

type ARPEntry

type ARPEntry struct {
	MacAddress net.HardwareAddr
	Expiry     time.Time
}

type RawIPConn

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

RawIPConn represents a connection for raw IP packets.

func NewRawIPConn

func NewRawIPConn(params *RawIPConnParams, config *RawIPConnConfig) (*RawIPConn, error)

func (*RawIPConn) Close

func (conn *RawIPConn) Close() error

Close closes the RawIPConn.

func (*RawIPConn) LocalIP

func (conn *RawIPConn) LocalIP() net.IP

func (*RawIPConn) Read

func (conn *RawIPConn) Read(buffer []byte) (int, error)

Read reads data from the RawIPConn.

func (*RawIPConn) ReadFrom

func (conn *RawIPConn) ReadFrom(buffer []byte) (int, net.Addr, error)

ReadFrom reads a packet from the RawIPConn and returns the payload and the source address.

func (*RawIPConn) RemoteIP

func (conn *RawIPConn) RemoteIP() net.IP

func (*RawIPConn) SetReadDeadline

func (conn *RawIPConn) SetReadDeadline(t time.Time) error

func (*RawIPConn) Write

func (conn *RawIPConn) Write(data []byte) (int, error)

Write writes data to the RawIPConn.

func (*RawIPConn) WriteTo

func (conn *RawIPConn) WriteTo(data []byte, addr net.Addr) (int, error)

WriteTo sends data to the specified destination address.

type RawIPConnConfig

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

type RawIPConnParams

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

type RawSocketCore

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

func NewRawSocketCore

func NewRawSocketCore(arpCacheTimeout, arpRequestTimeout int) *RawSocketCore

func (*RawSocketCore) Close

func (core *RawSocketCore) Close()

func (*RawSocketCore) DialIP

func (core *RawSocketCore) DialIP(protocol layers.IPProtocol, srcIP, dstIP net.IP) (*RawIPConn, error)

func (*RawSocketCore) ListenIP

func (core *RawSocketCore) ListenIP(ip net.IP, protocol layers.IPProtocol) (*RawIPConn, error)

type TimeoutError

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

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

func (*TimeoutError) Temporary

func (e *TimeoutError) Temporary() bool

func (*TimeoutError) Timeout

func (e *TimeoutError) Timeout() bool

Jump to

Keyboard shortcuts

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