class Tuntap::Interface
- Tuntap::Interface
- Reference
- Object
Overview
Control class for network interfaces
Direct Known Subclasses
Defined in:
tuntap/interface.crConstant Summary
-
DEFAULT_METRIC =
100
-
DEFAULT_MTU =
1500
-
Default value for the MTU
-
UNSET_ADDR =
"0.0.0.0"
Constructors
Class Method Summary
-
.names : Array(String)
Acquires the list of available interfaces
-
.open(name : String)
Opens the interface name
Instance Method Summary
-
#add_address(address : String) : Nil
Adds an IP address to the interface.
-
#add_address(address : LibC::Sockaddr) : Nil
ditto
-
#add_netmask(address : String) : Nil
Sets the netmask of the interface
-
#add_netmask(address : LibC::Sockaddr) : Nil
ditto
-
#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.
-
#close
Closes the device.
-
#down! : Nil
Disables the network interface ("Brings it down").
-
#fd : IO::FileDescriptor
The file descriptor controlling the device
-
#ioctl(command, argument) : Int32
Runs an
ioctl(3)
on the device. -
#mtu : Int32
The MTU
-
#mtu=(mtu : Int32)
The MTU
-
#name : String
The device name
-
#up! : Nil
Enables the network interface ("Brings it up").
Constructor Detail
Class Method Detail
Instance Method Detail
def add_address(address : String) : Nil
#
Adds an IP address to the interface. For this to work, the interface has to be up.
def 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.