class

Tuntap::Interface

Inherits Reference / Object

Control class for network interfaces

Constants

DEFAULT_METRIC = 100
DEFAULT_MTU = 1500

Default value for the MTU

UNSET_ADDR = "0.0.0.0"

Constructors

new(fd : IO::FileDescriptor, name : String)
Source

Class methods

names

Acquires the list of available interfaces

Source
open(name : String)

Opens the interface name

Source

Instance methods

add_address(address : String) : Nil

Adds an IP address to the interface. For this to work, the interface has to be up.

Source
add_address(address : LibC::Sockaddr) : Nil

ditto

Source
add_netmask(address : String) : Nil

Sets the netmask of the interface

Source
add_netmask(address : LibC::Sockaddr) : Nil

ditto

Source
add_route(destination : String, gateway : String = UNSET_ADDR, mask : String = UNSET_ADDR, metric = DEFAULT_METRIC, mtu = DEFAULT_MTU, window = 0, flags : LibC::RtEntryFlags = LibC::RtEntryFlags::Up)

Adds a network route to this interface. Most arguments are optional.

Source
close

Closes the device. If it is not persistent, the system will remove the device entirely.

Source
down!

Disables the network interface ("Brings it down").

Source
fd

The file descriptor controlling the device

Source
ioctl(command, argument) : Int32

Runs an ioctl(3) on the device. Raises Errno on failure.

Source
mtu

The MTU

Source
mtu=(mtu : Int32)

The MTU

Source
name

The device name

Source
up!

Enables the network interface ("Brings it up").

Source