1 .\" $NetBSD: tap.4,v 1.10 2009/03/12 11:34:54 plunky Exp $
3 .\" Copyright (c) 2004, 2005 The NetBSD Foundation.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
32 .Nd virtual Ethernet device
38 driver allows the creation and use of virtual Ethernet devices.
39 Those interfaces appear just as any real Ethernet NIC to the kernel,
40 but can also be accessed by userland through a character device node in order
41 to read frames being sent by the system or to inject frames.
43 In that respect it is very similar to what
45 provides, but the added Ethernet layer allows easy integration with machine
46 emulators or virtual Ethernet networks through the use of
49 .Ss INTERFACE CREATION
50 Interfaces may be created in two different ways:
54 command with a specified device number,
59 or using the special cloning device
62 The former works the same as any other cloning network interface:
63 the administrator can create and destroy interfaces at any time,
65 This is the easiest way of combining
69 Later, userland will actually access the interfaces through the specific
73 The latter is aimed at applications that need a virtual Ethernet device for
74 the duration of their execution.
75 A new interface is created at the opening of
77 and is later destroyed when the last process using the file descriptor closes
82 devices are accessed through the special cloning device
84 or through the specific devices
86 the possible actions to control the matching interface are the same.
90 though, as the interface is created on-the-fly, its name is not known
91 immediately by the application.
95 It should be the first action an application using the special cloning device
97 It takes a pointer to a
101 Ethernet frames sent out by the kernel on a
103 interface can be obtained by the controlling application with
105 It can also inject frames in the kernel with
107 There is absolutely no validation of the content of the injected frame,
108 it can be any data, of any length.
112 will inject a single frame in the kernel, as one call of
114 will retrieve a single frame from the queue, to the extent of the provided
116 If the buffer is not large enough, the frame will be truncated.
119 character devices support the
121 ioctl which returns the size of the next available frame,
122 or 0 if there is no available frame in the queue.
124 They also support non-blocking I/O through the
131 when no data is available.
133 Asynchronous I/O is supported through the
139 The first will enable
141 generation, while the two other configure the process group that
142 will receive the signal when data is ready.
144 Synchronisation may also be achieved through the use of
152 device is created, it is assigned an Ethernet address
153 of the form f2:0b:a4:xx:xx:xx.
154 This address can later be changed using
156 to add an active link layer address, or directly via the
160 socket, as it is not available on
161 the ioctl handler of the character device interface.
163 .Bl -tag -compact -width /dev/tap[0-9]*
166 .It Pa /dev/tap[0-9]*
167 individual character device nodes
177 driver first appeared in