tuntap

package
v0.0.0-...-994898c Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tuntap provides access to TUN/TAP device.

Index

Constants

View Source
const (
	TUN = water.TUN
	TAP = water.TAP
)

TUN and TAP represent the two device types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr netlink.Addr

An Addr represents an IP address and its associated routing prefix.

func ParseCIDR

func ParseCIDR(s string) (*Addr, error)

ParseCIDR parses s as a CIDR notation IP address and prefix length.

func (*Addr) Network

func (addr *Addr) Network() string

Network returns the network name, "ip+net".

func (*Addr) String

func (addr *Addr) String() string

String returns the CIDR notation of the address.

type Device

type Device struct {
	Index int
	Type  int
	io.ReadWriteCloser
}

Device represents a TUN/TAP device.

func New

func New(devType int) (*Device, error)

New creates a new TUN/TAP device.

func NewTAP

func NewTAP() (*Device, error)

NewTAP creates a new TAP device.

func NewTUN

func NewTUN() (*Device, error)

NewTUN creates a new TUN device.

func (*Device) AddAddr

func (dev *Device) AddAddr(addr *Addr) error

AddAddr adds the specified IP address to the interface.

func (*Device) Addrs

func (dev *Device) Addrs() ([]*Addr, error)

Addrs returns all IPv4 and IPv6 addresses assigned to the interface.

func (*Device) Attrs

func (dev *Device) Attrs() *netlink.LinkAttrs

Attrs returns the link attributes.

func (*Device) DelAddr

func (dev *Device) DelAddr(addr *Addr) error

DelAddr removes the specified IP address from the interface.

func (*Device) Down

func (dev *Device) Down() error

Down changes the state of the interface to DOWN.

func (*Device) SetMTU

func (dev *Device) SetMTU(mtu int) error

SetMTU sets the maximum transmission unit of the device.

func (*Device) Up

func (dev *Device) Up() error

Up changes the state of the interface to UP.

Jump to

Keyboard shortcuts

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