phys

package
v0.0.0-...-d4a0ffb Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: GPL-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Package phys implements an interface for reading/writing IPX packets to a physical network interface.

Package phys implements a reader/writer object for reading and writing IPX packets from a TAP device.

Index

Constants

This section is empty.

Variables

View Source
var (
	Framer802_2      = framer802_2{}
	Framer802_3Raw   = framer802_3Raw{}
	FramerSNAP       = framerSNAP{}
	FramerEthernetII = framerEthernetII{}

	FramerAutomatic = &automaticFramer{
		fallback: Framer802_2,
	}
)

Functions

func CopyFrames

func CopyFrames(a, b DuplexEthernetStream) error

CopyFrames starts a background process that copies packets between the given two streams.

func NewTap

func NewTap(cfg water.Config) (*tapWrapper, error)

NewTap creates a new physical IPX interface using a kernel TAP interface.

func Unframe

func Unframe(pkt gopacket.Packet, framer Framer) ([]byte, bool)

Unframe parses the layers in the given packet to locate and extract an IPX payload.

Types

type ChecksumFixer

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

ChecksumFixer is an implementation of `DuplexEthernetStream` that wraps another `DuplexEthernetStream` but recalculates TCP/IP checksums

func NewChecksumFixer

func NewChecksumFixer(stream DuplexEthernetStream) *ChecksumFixer

func (*ChecksumFixer) Close

func (cf *ChecksumFixer) Close()

func (*ChecksumFixer) ReadPacketData

func (cf *ChecksumFixer) ReadPacketData() ([]byte, gopacket.CaptureInfo, error)

func (*ChecksumFixer) WritePacketData

func (cf *ChecksumFixer) WritePacketData(frame []byte) error

type DuplexEthernetStream

type DuplexEthernetStream interface {
	gopacket.PacketDataSource
	PacketDataSink
}

DuplexEthernetStream extends gopacket.PacketDataSource to an interface where packets can be both read and written.

type Framer

type Framer interface {
	Frame(dest net.HardwareAddr, packet *ipx.Packet) ([]gopacket.SerializableLayer, error)
	Unframe(eth *layers.Ethernet, layers []gopacket.Layer) ([]byte, bool)
	Name() string
}

func FramingTypeFlag

func FramingTypeFlag(name, usage string) *Framer

type PacketDataSink

type PacketDataSink interface {
	WritePacketData([]byte) error
	Close()
}

PacketDataSink is the complement to gopacket.PacketDataSource: the WritePacketData method implemented by gopacket's pcap.Handle that allows packets to be written to an output.

type PcapgoDataSink

type PcapgoDataSink interface {
	WritePacket(ci gopacket.CaptureInfo, data []byte) error
}

PcapgoDataSink is the packet writing interface implemented by the gopacket/pcapgo writer types.

type Phys

type Phys struct {
	*Sink
	// contains filtered or unexported fields
}

Phys is an implementation of ipx.ReadWriteCloser that reads and writes IPX packets from a physical network interface.

func NewPhys

func NewPhys(stream DuplexEthernetStream, framer Framer) *Phys

func (*Phys) Close

func (p *Phys) Close() error

func (*Phys) ReadPacket

func (p *Phys) ReadPacket(ctx context.Context) (*ipx.Packet, error)

ReadPacket implements the ipx.Reader interface, and will block until an IPX packet is read from the physical interface.

func (*Phys) Run

func (p *Phys) Run() error

type Sink

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

Sink is an implementation of ipx.WriteCloser that frames IPX packets and writes them to a physical network interface.

func NewPcapgoSink

func NewPcapgoSink(pds PcapgoDataSink, framer Framer) *Sink

NewPcapgoSink returns an implementation of ipx.WriteCloser that writes packets to the given pcapgo Writer.

func NewSink

func NewSink(pds PacketDataSink, framer Framer) *Sink

NewSink returns an implementation of ipx.WriteCloser that writes packets to the given gopacket data sink.

func (*Sink) Close

func (s *Sink) Close() error

func (*Sink) WritePacket

func (s *Sink) WritePacket(packet *ipx.Packet) error

WritePacket implements the ipx.Writer interface, and will write the given IPX packet to the physical interface.

type SlirpConnection

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

func MakeSlirp

func MakeSlirp() (*SlirpConnection, error)

func (*SlirpConnection) Close

func (c *SlirpConnection) Close()

func (*SlirpConnection) ReadPacketData

func (c *SlirpConnection) ReadPacketData() ([]byte, gopacket.CaptureInfo, error)

func (*SlirpConnection) WritePacketData

func (c *SlirpConnection) WritePacketData(buf []byte) error

type SlirpProcess

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

func (*SlirpProcess) CleanupSocketFiles

func (c *SlirpProcess) CleanupSocketFiles()

func (*SlirpProcess) Close

func (c *SlirpProcess) Close() error

func (*SlirpProcess) Connect

func (c *SlirpProcess) Connect() (*SlirpConnection, error)

func (*SlirpProcess) Start

func (c *SlirpProcess) Start() error

type Spec

type Spec struct {
	Type Type
	Arg  string
}

func SpecFlag

func SpecFlag(name, defaultValue, usage string) *Spec

func (*Spec) EthernetStream

func (s *Spec) EthernetStream(captureNonIPX bool) (DuplexEthernetStream, error)

type Type

type Type func(arg string, captureNonIPX bool) (DuplexEthernetStream, error)

Type is a function that will open a DuplexEthernetStream connection to a physical network.

Jump to

Keyboard shortcuts

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