tuntap

package
v0.0.0-...-d79a36e Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TapIf

type TapIf struct {
	Name string
	// contains filtered or unexported fields
}

TapIf represents a tap interface, which exchanges behaves like a full Ethernet-capable network interface to userspace, but also permits that network interface to be a io.ReadWriteCloser.

func CreateTap

func CreateTap() (*TapIf, error)

CreateTap requests a new automatically named tap interface from the OS. This device is created with the NO_PI flag set, because essentially no sane users are interested in the alternative. A TapIf must be Close()d before it is GC'd or we will panic.

func CreateTapNamed

func CreateTapNamed(name string) (*TapIf, error)

CreateTapNamed requests a new tap interface from the OS, and requests that it be named with the provided string. It is otherwise identical to CreateTap(). The requested name may be up to IFNAMSIZ bytes, which technically can vary, but seems to be 16 everywhere. A TapIf must be Close()d before it is GC'd or we will panic.

func (*TapIf) Close

func (t *TapIf) Close() error

Close disposes the tap interface and frees any resources.

func (*TapIf) NetIf

func (t *TapIf) NetIf() (n netif.NetIf)

NetIf returns a NetIf for the tap interface. For example:

t := tuntap.CreateTap()
t.NetIf().Up()

func (*TapIf) Read

func (t *TapIf) Read(p []byte) (int, error)

Read reads ethernet frames that were "transmitted" on this tap interface.

func (*TapIf) SetPersistent

func (t *TapIf) SetPersistent(p bool) error

SetPersistent allows the interface to persist after being closed.

func (*TapIf) Write

func (t *TapIf) Write(p []byte) (int, error)

Write queues ethernet frames to be "received" on this tap interface. One caveat: the tap device may require only full ethernet frames to be written, not partial.

Jump to

Keyboard shortcuts

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