packet

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package packet provides access to ipv6 packet handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MTUByteReader

type MTUByteReader interface {
	io.Reader
	MTU() int
}

MTUByteReader extends io.Reader by allowing to query the MTU size.

type MTUReader

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

MTUReader reads IP packets over a non streamed (one IP packets is put into one read) MTU restricted connection. Consecutive packet reads use the same buffer.

func NewMTUReader

func NewMTUReader(reader MTUByteReader) *MTUReader

NewMTUReader creates a mew MTUReader with the given MTUByteReader as its source.

func (*MTUReader) ReadPacket

func (n *MTUReader) ReadPacket() (*Packet, error)

ReadPacket reads an IP packet from the stream. When receiving a packet that is larger then the last queried MTU size it is dropped, the buffer is resized to the current MTU size and a new read is performed.

type Packet

type Packet struct {
	Header     *ipv6.Header
	Marshalled []byte
}

Packet is a ipv6.Header and a slice of the whole marshalled packet.

type ReadWriteCloser

type ReadWriteCloser struct {
	io.ReadWriteCloser
	Reader
}

ReadWriteCloser provides the functionality of Reader, allows writing ip packets and forwards functionality of io.ReadWriteCloser.

func NewReadWriteCloser

func NewReadWriteCloser(sub io.ReadWriteCloser, reader Reader) *ReadWriteCloser

NewReadWriteCloser creates a new ReadWriteCloser with sub as the underlying io.ReadWriteCloser and reader as Reader implementation.

func (*ReadWriteCloser) WritePacket

func (r *ReadWriteCloser) WritePacket(p *Packet) error

WritePacket writes the marshalled form of Packet over the stream.

type Reader

type Reader interface {
	ReadPacket() (*Packet, error)
}

Reader reads IP packets.

type StreamReader

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

StreamReader reads ip packets from a stream (not a tun).

func NewStreamReader

func NewStreamReader(reader io.Reader) *StreamReader

NewStreamReader creates a new NewStreamReader with the unterlying reader.

func (*StreamReader) ReadPacket

func (n *StreamReader) ReadPacket() (*Packet, error)

ReadPacket reads an IP packet from the stream.

Jump to

Keyboard shortcuts

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