1.\" $FreeBSD$ 2.\" Based on PR#2411 3.\" 4.Dd July 9, 2000 5.Os 6.Dt TAP 4 7.Sh NAME 8.Nm tap 9.Nd Ethernet tunnel software network interface 10.Sh SYNOPSIS 11.Cd pseudo-device tap 12.Sh DESCRIPTION 13The 14.Nm 15interface is a software loopback mechanism that can be loosely 16described as the network interface analog of the 17.Xr pty 4 , 18that is, 19.Nm 20does for network interfaces what the 21.Nm pty 22driver does for terminals. 23.Pp 24The 25.Nm 26driver, like the 27.Nm pty 28driver, provides two interfaces: an interface like the usual facility 29it is simulating 30(an Ethernet network interface in the case of 31.Nm , 32or a terminal for 33.Nm pty ) , 34and a character-special device 35.Dq control 36interface. 37.Pp 38The network interfaces are named 39.Sy tap Ns Ar 0 , 40.Sy tap Ns Ar 1 , 41etc, as many as were made by 42.Xr MAKEDEV 8 . 43Each one supports the usual Ethernet network-interface 44.Xr ioctl 2 Ns s , 45such as 46.Dv SIOCSIFADDR 47and 48.Dv SIOCSIFNETMASK , 49and thus can be used with 50.Xr ifconfig 8 51like any other Ethernet interface. When the system chooses to transmit 52an Ethernet frame on the network interface, the frame can be read from 53the control device 54.Po 55it appears as 56.Dq input 57there 58.Pc ; 59writing an Ethernet frame to the control device generates an input frame on 60the network interface, as if the 61.Pq non-existent 62hardware had just received it. 63.Pp 64The Ethernet tunnel device, normally 65.Pa /dev/tap Ns Sy N , 66is exclusive-open 67.Po 68it cannot be opened if it is already open 69.Pc 70and is restricted to the super-user. 71A 72.Fn read 73call will return an error 74.Pq Er EHOSTDOWN 75if the interface is not 76.Dq ready . 77Once the interface is ready, 78.Fn read 79will return an Ethernet frame if one is available; if not, it will 80either block until one is or return 81.Er EWOULDBLOCK , 82depending on whether non-blocking I/O has been enabled. If the frame 83is longer than is allowed for in the buffer passed to 84.Fn read , 85the extra data will be silently dropped. 86.Pp 87A 88.Xr write 2 89call passes an Ethernet frame in to be 90.Dq received 91on the pseudo-interface. Each 92.Fn write 93call supplies exactly one frame; the frame length is taken from the 94amount of data provided to 95.Fn write . 96Writes will not block; if the frame cannot be accepted 97for a transient reason 98.Pq e.g., no buffer space available , 99it is silently dropped; if the reason is not transient 100.Pq e.g., frame too large , 101an error is returned. 102The following 103.Xr ioctl 2 104calls are supported 105.Pq defined in Aq Pa net/if_tap.h Ns : 106.Bl -tag -width VMIO_SIOCSETMACADDR 107.It Dv TAPSDEBUG 108The argument should be a pointer to an 109.Va int ; 110this sets the internal debugging variable to that value. What, if 111anything, this variable controls is not documented here; see the source 112code. 113.It Dv TAPGDEBUG 114The argument should be a pointer to an 115.Va int ; 116this stores the internal debugging variable's value into it. 117.It Dv FIONBIO 118Turn non-blocking I/O for reads off or on, according as the argument 119.Va int Ns 's 120value is or isn't zero 121.Pq Writes are always nonblocking . 122.It Dv FIOASYNC 123Turn asynchronous I/O for reads 124.Po 125i.e., generation of 126.Dv SIGIO 127when data is available to be read 128.Pc 129off or on, according as the argument 130.Va int Ns 's 131value is or isn't zero. 132.It Dv FIONREAD 133If any frames are queued to be read, store the size of the first one into the argument 134.Va int ; 135otherwise, store zero. 136.It Dv TIOCSPGRP 137Set the process group to receive 138.Dv SIGIO 139signals, when asynchronous I/O is enabled, to the argument 140.Va int 141value. 142.It Dv TIOCGPGRP 143Retrieve the process group value for 144.Dv SIGIO 145signals into the argument 146.Va int 147value. 148.It Dv SIOCGIFADDR 149Retrieve the Media Access Control 150.Pq Dv MAC 151address of the 152.Dq remote 153side. This command is used by the VMware port and expected to be executed on 154descriptor, associated with control device 155.Po 156usually 157.Pa /dev/vmnet Ns Sy N 158or 159.Pa /dev/tap Ns Sy N 160.Pc . 161The 162.Va buffer , 163which is passed as the argument, is expected to have enough space to store 164the 165.Dv MAC 166address. At the open time both 167.Dq local 168and 169.Dq remote 170.Dv MAC 171addresses are the same, so this command could be used to retrieve the 172.Dq local 173.Dv MAC 174address. 175.It Dv SIOCSIFADDR 176Set the Media Access Control 177.Pq Dv MAC 178address of the 179.Dq remote 180side. This command is used by VMware port and expected to be executed on 181a descriptor, associated with control device 182.Pq usually Pa /dev/vmnet Ns Sy N . 183.El 184.Pp 185The control device also supports 186.Xr select 2 187for read; selecting for write is pointless, and always succeeds, since 188writes are always non-blocking. 189.Pp 190On the last close of the data device, the interface is 191brought down 192.Po 193as if with 194.Dq ifconfig tap Ns Sy N No down 195.Pc unless the devices is a VMnet device. 196All queued frames are thrown away. If the interface is up when the data 197device is not open, output frames are thrown away rather than 198letting them pile up. 199.Pp 200The 201.Nm 202device is also can be used with the VMware port as a replacement 203for the old VMnet device driver. The driver uses the minor number 204to select between 205.Nm 206and 207.Nm vmnet 208devices. VMnet minor numbers begin at 209.Va 0x10000 210+ 211.Va N . 212Where 213.Va N 214is a VMnet unit number. In this case control device is expected to be 215.Pa /dev/vmnet Ns Sy N , 216and network interface will be 217.Sy vmnet Ns Ar N . 218Additionally, VMnet devices do not ifconfig themselves down when the 219control device is closed. Everything else is the same. 220.Pp 221In addition to mentioned above 222.Xr ioctl 2 223there is one additional one for the VMware port. 224.Bl -tag -width VMIO_SIOCSETMACADDR 225.It Dv VMIO_SIOCSIFFLAGS 226VMware 227.Dv SIOCSIFFLAGS . 228.El 229.Sh SEE ALSO 230.Xr inet 4 , 231.Xr intro 4 232.\" .Sh BUGS 233.Sh AUTHORS 234This man page has been obtained from 235.Fx . 236