[BACK]Return to tap.4 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / man / man4

File: [cvs.NetBSD.org] / src / share / man / man4 / tap.4 (download)

Revision 1.11, Thu Mar 12 13:14:18 2009 UTC (15 years, 1 month ago) by wiz
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, uebayasi-xip-base7, uebayasi-xip-base6, uebayasi-xip-base5, uebayasi-xip-base4, uebayasi-xip-base3, uebayasi-xip-base2, uebayasi-xip-base1, uebayasi-xip, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-base, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-premerge-20091211, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, localcount-20160914, jym-xensuspend-nbase, jym-xensuspend-base, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Branch point for: phil-wifi, pgoyette-compat
Changes since 1.10: +2 -2 lines

Remove trailing whitespace.

.\" $NetBSD: tap.4,v 1.11 2009/03/12 13:14:18 wiz Exp $
.\"
.\"  Copyright (c) 2004, 2005 The NetBSD Foundation.
.\"  All rights reserved.
.\"
.\"  Redistribution and use in source and binary forms, with or without
.\"  modification, are permitted provided that the following conditions
.\"  are met:
.\"  1. Redistributions of source code must retain the above copyright
.\"     notice, this list of conditions and the following disclaimer.
.\"  2. Redistributions in binary form must reproduce the above copyright
.\"     notice, this list of conditions and the following disclaimer in the
.\"     documentation and/or other materials provided with the distribution.
.\"
.\"  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\"  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\"  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\"  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\"  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\"  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\"  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\"  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\"  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\"  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\"  POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd March 10, 2009
.Dt TAP 4
.Os
.Sh NAME
.Nm tap
.Nd virtual Ethernet device
.Sh SYNOPSIS
.Cd pseudo-device tap
.Sh DESCRIPTION
The
.Nm
driver allows the creation and use of virtual Ethernet devices.
Those interfaces appear just as any real Ethernet NIC to the kernel,
but can also be accessed by userland through a character device node in order
to read frames being sent by the system or to inject frames.
.Pp
In that respect it is very similar to what
.Xr tun 4
provides, but the added Ethernet layer allows easy integration with machine
emulators or virtual Ethernet networks through the use of
.Xr bridge 4
with tunneling.
.Ss INTERFACE CREATION
Interfaces may be created in two different ways:
using the
.Xr ifconfig 8
.Cm create
command with a specified device number,
or its
.Xr ioctl 2
equivalent,
.Dv SIOCIFCREATE ,
or using the special cloning device
.Pa /dev/tap .
.Pp
The former works the same as any other cloning network interface:
the administrator can create and destroy interfaces at any time,
notably at boot time.
This is the easiest way of combining
.Nm
and
.Xr bridge 4 .
Later, userland will actually access the interfaces through the specific
device nodes
.Pa /dev/tapN .
.Pp
The latter is aimed at applications that need a virtual Ethernet device for
the duration of their execution.
A new interface is created at the opening of
.Pa /dev/tap ,
and is later destroyed when the last process using the file descriptor closes
it.
.Ss CHARACTER DEVICES
Whether the
.Nm
devices are accessed through the special cloning device
.Pa /dev/tap
or through the specific devices
.Pa /dev/tapN ,
the possible actions to control the matching interface are the same.
.Pp
When using
.Pa /dev/tap
though, as the interface is created on-the-fly, its name is not known
immediately by the application.
Therefore the
.Dv TAPGIFNAME
ioctl is provided.
It should be the first action an application using the special cloning device
will do.
It takes a pointer to a
.Ft struct ifreq
as an argument.
.Pp
Ethernet frames sent out by the kernel on a
.Nm
interface can be obtained by the controlling application with
.Xr read 2 .
It can also inject frames in the kernel with
.Xr write 2 .
There is absolutely no validation of the content of the injected frame,
it can be any data, of any length.
.Pp
One call of
.Xr write 2
will inject a single frame in the kernel, as one call of
.Xr read 2
will retrieve a single frame from the queue, to the extent of the provided
buffer.
If the buffer is not large enough, the frame will be truncated.
.Pp
.Nm
character devices support the
.Dv FIONREAD
ioctl which returns the size of the next available frame,
or 0 if there is no available frame in the queue.
.Pp
They also support non-blocking I/O through the
.Dv FIONBIO
ioctl.
In that mode,
.Er EWOULDBLOCK
is returned by
.Xr read 2
when no data is available.
.Pp
Asynchronous I/O is supported through the
.Dv FIOASYNC ,
.Dv FIOSETOWN ,
and
.Dv FIOGETOWN
ioctls.
The first will enable
.Dv SIGIO
generation, while the two other configure the process group that
will receive the signal when data is ready.
.Pp
Synchronisation may also be achieved through the use of
.Xr select 2 ,
.Xr poll 2 ,
or
.Xr kevent 2 .
.Ss ETHERNET ADDRESS
When a
.Nm
device is created, it is assigned an Ethernet address
of the form f2:0b:a4:xx:xx:xx.
This address can later be changed using
.Xr ifconfig 8
to add an active link layer address, or directly via the
.Dv SIOCALIFADDR
ioctl on a
.Dv PF_LINK
socket, as it is not available on
the ioctl handler of the character device interface.
.Sh FILES
.Bl -tag -compact -width /dev/tap[0-9]*
.It Pa /dev/tap
cloning device
.It Pa /dev/tap[0-9]*
individual character device nodes
.El
.Sh SEE ALSO
.Xr bridge 4 ,
.Xr etherip 4 ,
.Xr tun 4 ,
.Xr ifconfig 8
.Sh HISTORY
The
.Nm
driver first appeared in
.Nx 3.0 .