ipx

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: 8 Imported by: 5

Documentation

Overview

Package ipx implements common types for IPX header encoding and decoding.

Index

Constants

This section is empty.

Variables

View Source
var (

	// For our purposes we always use network zero.
	ZeroNetwork = [4]byte{0, 0, 0, 0}

	AddrNull      = Addr([6]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
	AddrBroadcast = Addr([6]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff})

	HeaderLength = 30
)

Functions

func CopyPackets

func CopyPackets(ctx context.Context, in Reader, out Writer) error

CopyPackets copies packets from in to out until an error occurs whil reading or the context is cancelled. If the input returns EOF then CopyPackets returns nil to indicate copying completed successfully.

func DuplexCopyPackets

func DuplexCopyPackets(ctx context.Context, x, y ReadWriter) error

Types

type Addr

type Addr [6]byte

Addr represents an IPX address (MAC address).

func (Addr) Network

func (a Addr) Network() string

func (Addr) String

func (a Addr) String() string
type Header struct {
	Checksum     uint16
	Length       uint16
	TransControl byte
	PacketType   byte
	Dest, Src    HeaderAddr
}

Header represents an IPX header.

func (*Header) IsBroadcast

func (h *Header) IsBroadcast() bool

func (*Header) MarshalBinary

func (h *Header) MarshalBinary() ([]byte, error)

MarshalBinary populates a slice of bytes from an IPX header.

func (*Header) UnmarshalBinary

func (h *Header) UnmarshalBinary(packet []byte) error

UnmarshalBinary decodes an IPX header from a slice of bytes.

type HeaderAddr

type HeaderAddr struct {
	Network [4]byte
	Addr    Addr
	Socket  uint16
}

HeaderAddr represents a full IPX address and socket number.

func (*HeaderAddr) MarshalBinary

func (a *HeaderAddr) MarshalBinary() ([]byte, error)

MarshalBinary populates a slice of bytes from an IPX header address.

func (*HeaderAddr) UnmarshalBinary

func (a *HeaderAddr) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes an IPX header address from a slice of bytes.

type Packet

type Packet struct {
	Header  Header
	Payload []byte
}

Packet contains an unmarshaled IPX packet containing the header and payload bytes.

func (*Packet) MarshalBinary

func (p *Packet) MarshalBinary() ([]byte, error)

func (*Packet) UnmarshalBinary

func (p *Packet) UnmarshalBinary(packet []byte) error

type ReadCloser

type ReadCloser interface {
	Reader
	io.Closer
}

type ReadWriteCloser

type ReadWriteCloser interface {
	ReadWriter
	io.Closer
}

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

type Reader

type Reader interface {
	// ReadPacket returns an IPX packet read from this source or an
	// error. If no packet is available yet it will block. An error
	// of io.EOF indicates that no more packets are available to read.
	ReadPacket(context.Context) (*Packet, error)
}

Reader defines a common interface implemented by things from which IPX packets can be read.

type WriteCloser

type WriteCloser interface {
	Writer
	io.Closer
}

type Writer

type Writer interface {
	// WritePacket writes the given packet, returning an error if the
	// packet could not be written. WritePacket should not block.
	WritePacket(*Packet) error
}

Writer defines a common interface implemented by things to which IPX packets can be written.

Jump to

Keyboard shortcuts

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