phys

package
v0.0.0-...-7d1c9b4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-2.0 Imports: 16 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{}
)

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 DuplexEthernetStream

type DuplexEthernetStream interface {
	gopacket.PacketDataSource
	PacketDataSink
}

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

type Flags

type Flags struct {
	PcapDevice      *string
	EnableTap       *bool
	EthernetFraming *string
}

func RegisterFlags

func RegisterFlags() *Flags

func (*Flags) EthernetStream

func (f *Flags) EthernetStream(captureNonIPX bool) (DuplexEthernetStream, error)

func (*Flags) MakePhys

func (f *Flags) MakePhys(captureNonIPX bool) (*Phys, error)

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
}

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) NonIPX

func (p *Phys) NonIPX() DuplexEthernetStream

NonIPX returns a DuplexEthernetStream from which all non-IPX Ethernet frames will be returned by ReadPacketData().

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.

Jump to

Keyboard shortcuts

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