1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<table class="head">
<tr>
<td class="head-ltitle">NG_DEVICE(4)</td>
<td class="head-vol">Device Drivers Manual</td>
<td class="head-rtitle">NG_DEVICE(4)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">ng_device</code> — <span class="Nd">device
netgraph node type</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
<<a class="In">netgraph/ng_device.h</a>></code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">A <code class="Nm">device</code> node is both a netgraph node and
a system device interface. When a <code class="Nm">device</code> node is
created, a new device entry appears which is accessible via the regular file
operators such as <a class="Xr">open(2)</a>, <a class="Xr">close(2)</a>,
<a class="Xr">read(2)</a>, <a class="Xr">write(2)</a>, etc.</p>
<p class="Pp">The first node is created as <span class="Pa">/dev/ngd0</span>,
subsequent nodes are <span class="Pa">/dev/ngd1</span>,
<span class="Pa">/dev/ngd2</span>, etc.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="HOOKS"><a class="permalink" href="#HOOKS">HOOKS</a></h1>
<p class="Pp">A <code class="Nm">device</code> node has a single hook with an
arbitrary name. All data coming in over the hook will be presented to the
device for <a class="Xr">read(2)</a>. All data coming in from the device
entry by <a class="Xr">write(2)</a> will be forwarded to the hook.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="CONTROL_MESSAGES"><a class="permalink" href="#CONTROL_MESSAGES">CONTROL
MESSAGES</a></h1>
<p class="Pp">The <code class="Nm">device</code> node supports the generic
control messages, plus the following:</p>
<dl class="Bl-tag">
<dt id="NGM_DEVICE_GET_DEVNAME"><a class="permalink" href="#NGM_DEVICE_GET_DEVNAME"><code class="Dv">NGM_DEVICE_GET_DEVNAME</code></a></dt>
<dd>Returns the device name corresponding to the node.</dd>
<dt id="NGM_DEVICE_ETHERALIGN"><a class="permalink" href="#NGM_DEVICE_ETHERALIGN"><code class="Dv">NGM_DEVICE_ETHERALIGN</code></a></dt>
<dd>Apply the system ETHER_ALIGN offset to mbufs sent out the node's hook, if
running on an architecture that requires strict alignment. Use this option
when the data being injected via the device node ultimately ends up being
fed into the protocol stack as ethernet packets (e.g., via an
<a class="Xr">ng_eiface(4)</a> node).</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="SHUTDOWN"><a class="permalink" href="#SHUTDOWN">SHUTDOWN</a></h1>
<p class="Pp">This node shuts down upon receipt of a
<code class="Dv">NGM_SHUTDOWN</code> control message, or upon hook
disconnection. The associated device entry is removed and becomes available
for use by future <code class="Nm">device</code> nodes.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><a class="Xr">netgraph(4)</a>, <a class="Xr">ngctl(8)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The <code class="Nm">device</code> node type was first implemented
in <span class="Ux">FreeBSD 5.0</span>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp"><span class="An">Mark Santcroos</span>
<<a class="Mt" href="mailto:marks@ripe.net">marks@ripe.net</a>>
<br/>
<span class="An">Gleb Smirnoff</span>
<<a class="Mt" href="mailto:glebius@FreeBSD.org">glebius@FreeBSD.org</a>></p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">November 8, 2021</td>
<td class="foot-os">FreeBSD 15.0</td>
</tr>
</table>
|