tuntap

package
v0.0.0-...-835412b Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IFF_UP      = unix.IFF_UP
	IFF_RUNNING = unix.IFF_RUNNING
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfingInvalid

type ConfingInvalid string
const (
	INVALID_FLAG_COMBINATION ConfingInvalid = "invalid flags combination"
)

func (ConfingInvalid) Error

func (c ConfingInvalid) Error() string

type IfBuilder

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

VirtIf builder. Can chain options and settings to configure the new VirtIf

func NewIfBuilder

func NewIfBuilder() IfBuilder

Creates a new VirtIf builder without any parameters preset

func (IfBuilder) Build

func (b IfBuilder) Build() (IfInterface, error)

Build returns the Virtual Interface with the specified flags and options.

func (IfBuilder) SetFlag

func (b IfBuilder) SetFlag(f IfFlag) IfBuilder

Set manually a flag

func (IfBuilder) SetName

func (b IfBuilder) SetName(name string) IfBuilder

Set the Virtual Interface name

func (IfBuilder) SetNoPktInfo

func (b IfBuilder) SetNoPktInfo() IfBuilder

The the Virtual Interface to not contain packets info

func (IfBuilder) SetTap

func (b IfBuilder) SetTap() IfBuilder

Set Virtual Interface as TAP, removing the TUN flag if present

func (IfBuilder) SetTun

func (b IfBuilder) SetTun() IfBuilder

Set Virtual Interface as TUN, removing the TAP flag if present

type IfFlag

type IfFlag uint16

Type for setting the VirtIf flags

const (
	IF_TUN         IfFlag = unix.IFF_TUN
	IF_TAP         IfFlag = unix.IFF_TAP
	IF_NO_PKT_INFO IfFlag = unix.IFF_NO_PI
)

type IfInterface

type IfInterface interface {
	io.ReadWriteCloser
	SetIPv4(net.IP, net.IP) error
	SetMTU(mtu int32) error
	SetHWAddr(mac net.HardwareAddr) error
	Up() error
	Down() error
}

type IffFlag

type IffFlag uint16

Type for setting the If flags itself

type VirtIf

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

Struct object that represents the TUN/TAP Virtual Interface

func (*VirtIf) Close

func (v *VirtIf) Close() error

func (*VirtIf) Down

func (v *VirtIf) Down() error

Set Virtual Interface Down

func (*VirtIf) Read

func (v *VirtIf) Read(b []byte) (int, error)

func (*VirtIf) SetHWAddr

func (v *VirtIf) SetHWAddr(mac net.HardwareAddr) error

Set Virtual Interface MAC address

func (*VirtIf) SetIPv4

func (v *VirtIf) SetIPv4(ip net.IP, mask net.IP) error

Set Virtual Interface IPv4 address

func (*VirtIf) SetMTU

func (v *VirtIf) SetMTU(mtu int32) error

func (*VirtIf) Up

func (v *VirtIf) Up() error

Set Virtual Interface Up

func (*VirtIf) Write

func (v *VirtIf) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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