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