packettransport

package
v0.0.0-...-c2e30b8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: NIST-PD-fallback Imports: 8 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 tcpdump.

Index

Constants

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

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

	// EthernetTypeNDN is the NDN EtherType.
	EthernetTypeNDN = 0x8624
)

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 is the default NDN multicast address.
	MulticastAddressNDN = net.HardwareAddr{0x01, 0x00, 0x5E, 0x00, 0x17, 0xAA}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Locator
	l3.TransportQueueConfig
}

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.PacketDataSource
	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 a 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 additionally implements io.Closer interface or has `Close()` func that returns nothing, it will be invoked when the 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