xref: /freebsd/share/man/man4/ng_device.4 (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
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.Dd November 8, 2021
26.Dt NG_DEVICE 4
27.Os
28.Sh NAME
29.Nm ng_device
30.Nd device netgraph node type
31.Sh SYNOPSIS
32.In netgraph/ng_device.h
33.Sh DESCRIPTION
34A
35.Nm device
36node is both a netgraph node and a system device interface.
37When a
38.Nm device
39node is created, a new device entry appears which is accessible via the
40regular file operators such as
41.Xr open 2 ,
42.Xr close 2 ,
43.Xr read 2 ,
44.Xr write 2 ,
45etc.
46.Pp
47The first node is created as
48.Pa /dev/ngd0 ,
49subsequent nodes are
50.Pa /dev/ngd1 , /dev/ngd2 ,
51etc.
52.Sh HOOKS
53A
54.Nm device
55node has a single hook with an arbitrary name.
56All data coming in over the hook will be presented to the device
57for
58.Xr read 2 .
59All data coming in from the device entry by
60.Xr write 2
61will be forwarded to the hook.
62.Sh CONTROL MESSAGES
63The
64.Nm device
65node supports the generic control messages, plus the following:
66.Bl -tag -width 3n
67.It Dv NGM_DEVICE_GET_DEVNAME
68Returns the device name corresponding to the node.
69.It Dv NGM_DEVICE_ETHERALIGN
70Apply the system ETHER_ALIGN offset to mbufs sent out the node's hook,
71if running on an architecture that requires strict alignment.
72Use this option when the data being injected via the device node ultimately
73ends up being fed into the protocol stack as ethernet packets (e.g., via
74an
75.Xr ng_eiface 4
76node).
77.El
78.\" Additionally, the node accepts
79.\" .Xr ioctl 2 Ns s
80.\" from the device entry.
81.\" These will be encapsulated into
82.\" .Xr netgraph 4
83.\" messages and send out to the hook.
84.Sh SHUTDOWN
85This node shuts down upon receipt of a
86.Dv NGM_SHUTDOWN
87control message, or upon hook disconnection.
88The associated device entry is removed and becomes available
89for use by future
90.Nm device
91nodes.
92.Sh SEE ALSO
93.Xr netgraph 4 ,
94.Xr ngctl 8
95.Sh HISTORY
96The
97.Nm device
98node type was first implemented in
99.Fx 5.0 .
100.Sh AUTHORS
101.An Mark Santcroos Aq Mt marks@ripe.net
102.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org
103