TUN(4) BSD Programmer's Manual TUN(4)NAMEtun - network tunnel interface driver
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_tun.h>
#include <net/if_types.h>
pseudo-device tun count
DESCRIPTION
The network tunnel interface driver allows privileged processes to enable
a network interface and exchange packets with the kernel packet forward-
ing facilities.
The interface created is a point-to-point (POINTOPOINT) interface with an
initial maximum transmission unit (MTU) of TUNMTU (currently 1500), an
initial interface type of IFT_PROPVIRTUAL and an initial interface speed
of 0.
Opening /dev/tunX enables the tunX interface, for example, opening
/dev/tun1 enables the tun1 interface. Once the local and remote address-
es have been configured, a process can exchange packets with the kernel.
I/O to the tunnel device is atomic, each write generates one packet and
each read accepts only one packet. If the specified buffer size used to
read a packet is too small, the remainder of the packet is discarded.
The select(2) system call may be used to wait for a packet to be read,
the tunnel network interface device is always ready for writing.
The default interface speed, type and MTU can be queried and changed by
using the TUNGIFINFO and TUNSIFINFO ioctl(2) calls which take the follow-
ing structure as an argument:
struct tuninfo {
int baudrate; /* line-speed in bits per second */
short mtu; /* maximum transmission unit */
u_char type; /* ethernet, tokenring, etc. */
u_char dummy; /* place holder */
};
The number of network tunnel interfaces may be increased by adjusting
count at kernel config time, modifying the ntun variable in the system
with bpatch(1) before booting, or by modifying the
net.link_layer.generic.tun.numif variable with sysctl(1).
SEE ALSOsysctl(1), ioctl(2), read(2), select(2), socket(2), write(2),
inet(4), intro(4), netintro(4), ifconfig(8),
BSDI BSD/OS July 19, 1996 1