tuntap – github.com/jamescun/tuntap Index | Files | Directories

package tuntap

import "github.com/jamescun/tuntap"

Index

Variables

var (
	ErrBusy        = errors.New("device is already in use")
	ErrNotReady    = errors.New("device is not ready")
	ErrExhausted   = errors.New("no devices are available")
	ErrUnsupported = errors.New("device is unsupported on this platform")
)

Types

type Interface

type Interface interface {
	// return name of TUN/TAP interface
	Name() string

	// implement io.Reader interface, read bytes into p from TUN/TAP interface
	Read(p []byte) (n int, err error)

	// implement io.Writer interface, write bytes from p to TUN/TAP interface
	Write(p []byte) (n int, err error)

	// implement io.Closer interface, must be called when done with TUN/TAP interface
	Close() error

	// return string representation of TUN/TAP interface
	String() string
}

Interface represents a TUN/TAP network interface

func Tap

func Tap(name string) (Interface, error)

return a TAP interface. depending on platform, the device may not be ready for use yet; a caller must poll the Ready() method before use. additionally the caller is responsible for calling Close() to terminate the device.

func Tun

func Tun(name string) (Interface, error)

return a TUN interface. depending on platform, the device may not be ready for use yet; a caller must poll the Ready() method before use. additionally the caller is responsible for calling Close() to terminate the device.

Source Files

device_linux.go interface.go

Directories

PathSynopsis
examplesdump packets sent to TUN device to stdout
Version
v0.0.0-20190712092105-cb1fb277045c (latest)
Published
Jul 12, 2019
Platform
linux/amd64
Imports
5 packages
Last checked
now

Tools for package owners.