mnet_if

package
v0.0.0-...-4adfca9 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPv6_HEADER_LENGTH = 40
)

Variables

This section is empty.

Functions

func CreateInterface

func CreateInterface(fd uintptr, ifName string, flags uint16) (createdIFName string, err error)

func TunIdRandom

func TunIdRandom(min, max int) int

Types

type IfReq

type IfReq struct {
	Name  [0x10]byte
	Flags uint16
	// contains filtered or unexported fields
}

type Interface

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

Interface is a TUN/TAP interface.

func NewTAP

func NewTAP(ifName string) (ifce *Interface, err error)

Create a new TAP interface whose name is ifName. If ifName is empty, a default name (tap0, tap1, ... ) will be assigned. ifName should not exceed 16 bytes.

func NewTUN

func NewTUN(ifName string) (ifce *Interface, err error)

Create a new TUN interface whose name is ifName. If ifName is empty, a default name (tap0, tap1, ... ) will be assigned. ifName should not exceed 16 bytes.

func (*Interface) Close

func (inet *Interface) Close()

func (*Interface) GetFd

func (ifce *Interface) GetFd() int

func (*Interface) GetFdOS

func (ifce *Interface) GetFdOS() *os.File

func (*Interface) GetName

func (ifce *Interface) GetName() string

func (*Interface) IsTAP

func (ifce *Interface) IsTAP() bool

Returns true if ifce is a TAP interface, otherwise returns false;

func (*Interface) IsTUN

func (ifce *Interface) IsTUN() bool

Returns true if ifce is a TUN interface, otherwise returns false;

func (*Interface) Name

func (ifce *Interface) Name() string

Returns the interface name of ifce, e.g. tun0, tap1, etc..

func (*Interface) Open

func (tap_conn *Interface) Open(mtu uint, tapNum string, ifType string) (err error)

******************************************************************** ** Tap Device Open/Close/Read/Write ** ******************************************************************** NOTE: legacy tap device create method used with in tap driver only for now

func (*Interface) Open2

func (vni *Interface) Open2(mtu uint, ifNum string, ifType string) (err error)

for tun new open for tun device currently code goes into this path for linux tun connection TODO: move it to regular Open()

func (*Interface) OpenTap

func (netIf *Interface) OpenTap(mtu uint, tapNum string) (err error)

func (*Interface) OpenTapInterface

func (netIf *Interface) OpenTapInterface(mtu uint, tapNum string) (err error)

new

func (*Interface) OpenTun

func (netIf *Interface) OpenTun(mtu uint, tapNum string) (err error)

func (*Interface) OpenTunInterface

func (netIf *Interface) OpenTunInterface(mtu uint, tapNum string) (err error)

new

func (*Interface) Read

func (inet *Interface) Read(b []byte) (n int, err error)

func (*Interface) SetTap

func (ifce *Interface) SetTap(isTap bool)

func (*Interface) Write

func (inet *Interface) Write(b []byte) (n int, err error)

type TapConn

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

// Tap Device Open/Close/Read/Write

Jump to

Keyboard shortcuts

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