taptun

package module
v0.0.0-...-1f20f55 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 8 Imported by: 0

README

taptun

import "github.com/pkg/taptun"

Package taptun provides an interface to the user level network TAP / TUN device.

a href="https://www.kernel.org/doc/Documentation/networking/tuntap.txt">https://www.kernel.org/doc/Documentation/networking/tuntap.txt

type Tap

type Tap struct {
    io.ReadWriteCloser
    // contains filtered or unexported fields
}

Tap represents a TAP Virtual Ethernet network device.

func OpenTap
func OpenTap() (*Tap, error)

OpenTap creates a tapN interface and returns a *Tap device connected to the t pinterface.

func (*Tap) String
func (t *Tap) String() string

type Tun

type Tun struct {
    io.ReadWriteCloser
    // contains filtered or unexported fields
}

Tun represents a TUN Virtual Point-to-Point network device.

func OpenTun
func OpenTun() (*Tun, error)

OpenTun creates a tunN interface and returns a *Tun device connected to the tun interface.

func (*Tun) String
func (t *Tun) String() string

Generated by godoc2md

Documentation

Overview

Package taptun provides an interface to the user level network TAP / TUN device.

https://www.kernel.org/doc/Documentation/networking/tuntap.txt

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFrame

func ReadFrame(tap *Tap, buf []byte) ([]byte, error)

ReadFrame reads a single frame from the tap device. The buffer supplied must be large enough to hold the whole frame including a 4 byte header returned by the kernel. If the buffer is not large enough to hold the entire frame and error of type ErrTruncated will be returned.

Types

type ErrTruncated

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

ErrTruncated indicates the buffer supplied to ReadFrame was insufficient to hold the ingress frame.

func (ErrTruncated) Error

func (e ErrTruncated) Error() string

type Tap

type Tap struct {
	io.ReadWriteCloser
	// contains filtered or unexported fields
}

Tap represents a TAP Virtual Ethernet network device.

func NewTap

func NewTap(name string) (*Tap, error)

NewTap creates a *Tap device with the specified name and returns the device connected to the tap interface.

If an empty string ("") is specified for name, a tapN interface is created.

func OpenTap

func OpenTap() (*Tap, error)

OpenTap creates a tapN interface and returns a *Tap device connected to the tap interface.

func (*Tap) Close

func (t *Tap) Close() error

func (*Tap) String

func (t *Tap) String() string

type Tun

type Tun struct {
	io.ReadWriteCloser
	// contains filtered or unexported fields
}

Tun represents a TUN Virtual Point-to-Point network device.

func NewTun

func NewTun(name string) (*Tun, error)

NewTun creates a *Tun device with the specified name and returns the device connected to the tun interface.

If an empty string ("") is specified for name, a tunN interface is created.

func OpenTun

func OpenTun() (*Tun, error)

OpenTun creates a tunN interface and returns a *Tun device connected to the tun interface.

func (*Tun) Close

func (t *Tun) Close() error

func (*Tun) String

func (t *Tun) String() string

Jump to

Keyboard shortcuts

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