1.\" Copyright (c) 2002 Mark Santcroos <marks@ripe.net> 2.\" 3.\" Redistribution and use in source and binary forms, with or without 4.\" modification, are permitted provided that the following conditions 5.\" are met: 6.\" 1. Redistributions of source code must retain the above copyright 7.\" notice, this list of conditions and the following disclaimer. 8.\" 2. Redistributions in binary form must reproduce the above copyright 9.\" notice, this list of conditions and the following disclaimer in the 10.\" documentation and/or other materials provided with the distribution. 11.\" 3. The name of the author may not be used to endorse or promote products 12.\" derived from this software without specific prior written permission. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd June 15, 2002 28.Dt NG_DEVICE 4 29.Os 30.Sh NAME 31.Nm ng_device 32.Nd device netgraph node type 33.Sh SYNOPSIS 34.In netgraph/ng_device.h 35.Sh DESCRIPTION 36A 37.Nm device 38node is both a netgraph node and a system device interface. When an 39.Nm device 40node is created, a new device entry appears which is accessible via the 41regular file operators such as 42.Xr open 2 , 43.Xr close 2 , 44.Xr read 2 , 45.Xr write 2 , etc. 46.Pp 47The first node is created as /dev/ngd0, all subsequent nodes /dev/ngd1, 48/dev/ngd2, etc. The only way a 49.Nm device 50node can be created is by a connection to the main 51.Nm device 52node by another type of 53.Xr netgraph 4 54node. 55.Pp 56When a node is shut down, the corresponding device is removed 57and the device name becomes available for reuse by future 58.Nm device 59nodes. 60.Pp 61A 62.Nm device 63node has a single hook to which it connects to the requesting 64.Xr netgraph 4 65node. All data coming in over the hook will be presented to the device 66for 67.Xr read 2 . 68All data coming in from the device entry by 69.Xr write 2 70will be forwarded to the hook. 71.Sh HOOKS 72The 73.Nm device 74node has no named hooks. There is one hook which is used for all 75interactions. This is the hook created by the calling node. 76.Sh CONTROL MESSAGES 77The 78.Nm device 79node supports no special control messages. All incoming messages from the 80hook will be returned to the sender. 81Additionally the node accepts 82.Xr ioctl 2 's from the device entry. These will be encapsulated into 83.Xr netgraph 4 84messages and send out to the hook. 85.Sh SHUTDOWN 86This node shuts down upon receipt of a 87.Dv NGM_SHUTDOWN 88control message. The associated interface is removed and becomes available 89for use by future 90.Nm device 91nodes. 92.Pp 93Unlike most other node types, a 94.Nm iface 95node does 96.Em not 97go away when all hooks have been disconnected; rather, and explicit 98.Dv NGM_SHUTDOWN 99control message is required. 100.Sh SEE ALSO 101.Xr netgraph 4 , 102.Xr ngctl 8 103.Sh HISTORY 104The 105.Nm device 106node type was first implemented in 107.Fx 5.0 . 108.Sh AUTHORS 109.An Mark Santcroos Aq marks@ripe.net 110