buffer

package
v2.4.10-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DataPool = &Pool{
	pool: sync.Pool{
		New: func() interface{} {
			return &Data{buf: make([]byte, defaultMTU+maxIPHeader)}
		}},
	MTU: defaultMTU,
}

Functions

This section is empty.

Types

type Data

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

func (*Data) Buf

func (b *Data) Buf() []byte

Buf returns this Data's buffer. This is the buffer that should be used everywhere except for the tun.Device ReadPacket and WritePacket methods.

func (*Data) Raw

func (b *Data) Raw() []byte

Raw returns this Data's raw buffer. This is the buffer that should by the tun.Device ReadPacket and WritePacket methods. It uses the same underlying byte array as Buf but might be offset before Buf to allow for leading bytes that are provided before the IP header.

func (*Data) SetLength

func (b *Data) SetLength(l int)

SetLength sets the length of this buffer. This will change the slice that Buf and Raw returns

type Pool

type Pool struct {
	MTU int
	// contains filtered or unexported fields
}

A Pool is a specialized sync.Pool for Data. The Data struct is platform specific

func (*Pool) Get

func (p *Pool) Get(size int) *Data

func (*Pool) Put

func (p *Pool) Put(b *Data)

Jump to

Keyboard shortcuts

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