xref: /freebsd/share/man/man4/ng_device.4 (revision 4b2eaea43fec8e8792be611dea204071a10b655a)
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.
39When a
40.Nm device
41node is created, a new device entry appears which is accessible via the
42regular file operators such as
43.Xr open 2 ,
44.Xr close 2 ,
45.Xr read 2 ,
46.Xr write 2 ,
47etc.
48.Pp
49The first node is created as
50.Pa /dev/ngd0 ,
51all subsequent nodes
52.Pa /dev/ngd1 , /dev/ngd2 ,
53etc.
54The only way a
55.Nm device
56node can be created is by a connection to the main
57.Nm device
58node by another type of
59.Xr netgraph 4
60node.
61.Pp
62When a node is shut down, the corresponding device is removed
63and the device name becomes available for reuse by future
64.Nm device
65nodes.
66.Pp
67A
68.Nm device
69node has a single hook to which it connects to the requesting
70.Xr netgraph 4
71node.
72All data coming in over the hook will be presented to the device
73for
74.Xr read 2 .
75All data coming in from the device entry by
76.Xr write 2
77will be forwarded to the hook.
78.Sh HOOKS
79The
80.Nm device
81node has no named hooks.
82There is one hook which is used for all interactions.
83This is the hook created by the calling node.
84.Sh CONTROL MESSAGES
85The
86.Nm device
87node supports no special control messages.
88All incoming messages from the
89hook will be returned to the sender.
90Additionally the node accepts
91.Xr ioctl 2 Ns s
92from the device entry.
93These will be encapsulated into
94.Xr netgraph 4
95messages and send out to the hook.
96.Sh SHUTDOWN
97This node shuts down upon receipt of a
98.Dv NGM_SHUTDOWN
99control message.
100The associated interface is removed and becomes available
101for use by future
102.Nm device
103nodes.
104.Pp
105Unlike most other node types, a
106.Nm device
107node does
108.Em not
109go away when all hooks have been disconnected; rather, an explicit
110.Dv NGM_SHUTDOWN
111control message is required.
112.Sh SEE ALSO
113.Xr netgraph 4 ,
114.Xr ngctl 8
115.Sh HISTORY
116The
117.Nm device
118node type was first implemented in
119.Fx 5.0 .
120.Sh AUTHORS
121.An Mark Santcroos Aq marks@ripe.net
122