packettransport

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 10 Imported by: 0

Documentation

Overview

Package packettransport implements a transport based on GoPacket library. It may be used to create Ethernet faces based on AF_PACKET or libpcap.

Index

Constants

View Source
const (
	// MinVLAN is the minimum VLAN number.
	MinVLAN = 0x001

	// MaxVLAN is the maximum VLAN number.
	MaxVLAN = 0xFFE

	// EthernetTypeNDN is the NDN EtherType.
	EthernetTypeNDN = an.EtherTypeNDN
)

Variables

View Source
var (
	ErrMacAddr        = errors.New("invalid MAC address")
	ErrUnicastMacAddr = errors.New("invalid unicast MAC address")
	ErrVLAN           = errors.New("invalid VLAN")
)

Error conditions.

View Source
var MulticastAddressNDN = net.HardwareAddr{
	an.EtherMulticastNDN >> 40 & 0xFF,
	an.EtherMulticastNDN >> 32 & 0xFF,
	an.EtherMulticastNDN >> 24 & 0xFF,
	an.EtherMulticastNDN >> 16 & 0xFF,
	an.EtherMulticastNDN >> 8 & 0xFF,
	an.EtherMulticastNDN >> 0 & 0xFF,
}

MulticastAddressNDN is the default NDN multicast address.

Functions

This section is empty.

Types

type Config

type Config struct {
	Locator
	MTU int
}

Config contains Transport configuration.

type Locator

type Locator struct {
	// Local is the local MAC address.
	// This must be a 48-bit unicast address.
	Local macaddr.Flag `json:"local"`

	// Remote is the remote MAC address.
	// This must be a 48-bit unicast or multicast address.
	Remote macaddr.Flag `json:"remote"`

	// VLAN is the VLAN number.
	// This must be between MinVLAN and MaxVLAN.
	// Zero indicates there's no VLAN header.
	VLAN int `json:"vlan,omitempty"`
}

Locator identifies local and remote endpoints.

func (Locator) Validate

func (loc Locator) Validate() error

Validate checks Locator fields.

type PacketDataHandle

type PacketDataHandle interface {
	gopacket.ZeroCopyPacketDataSource
	WritePacketData(pkt []byte) error
}

PacketDataHandle represents a network interface to send and receive Ethernet frames.

type Transport

type Transport interface {
	l3.Transport

	// Handle returns the underlying PacketDataHandle.
	Handle() PacketDataHandle
}

Transport is an l3.Transport that communicates over Ethernet via PacketDataHandle.

func New

func New(hdl PacketDataHandle, cfg Config) (Transport, error)

New creates a Transport.

The transport receives and transmits Ethernet frames via the provided PacketDataHandle. If hdl has either `Close() error` or `Close()` method, it is invoked when transport is being closed.

Directories

Path Synopsis
Package afpacket implements a transport that communicates over AF_PACKET sockets.
Package afpacket implements a transport that communicates over AF_PACKET sockets.

Jump to

Keyboard shortcuts

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