1a8353960SJulian Elischer.\" Copyright (c) 2002 Mark Santcroos <marks@ripe.net> 2a8353960SJulian Elischer.\" 3a8353960SJulian Elischer.\" Redistribution and use in source and binary forms, with or without 4a8353960SJulian Elischer.\" modification, are permitted provided that the following conditions 5a8353960SJulian Elischer.\" are met: 6a8353960SJulian Elischer.\" 1. Redistributions of source code must retain the above copyright 7a8353960SJulian Elischer.\" notice, this list of conditions and the following disclaimer. 8a8353960SJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright 9a8353960SJulian Elischer.\" notice, this list of conditions and the following disclaimer in the 10a8353960SJulian Elischer.\" documentation and/or other materials provided with the distribution. 11a8353960SJulian Elischer.\" 3. The name of the author may not be used to endorse or promote products 12a8353960SJulian Elischer.\" derived from this software without specific prior written permission. 13a8353960SJulian Elischer.\" 14a8353960SJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15a8353960SJulian Elischer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16a8353960SJulian Elischer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17a8353960SJulian Elischer.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18a8353960SJulian Elischer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19a8353960SJulian Elischer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20a8353960SJulian Elischer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21a8353960SJulian Elischer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22a8353960SJulian Elischer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23a8353960SJulian Elischer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24a8353960SJulian Elischer.\" 25*44aae623SIan Lepore.Dd November 8, 2021 26a8353960SJulian Elischer.Dt NG_DEVICE 4 27a8353960SJulian Elischer.Os 28a8353960SJulian Elischer.Sh NAME 29a8353960SJulian Elischer.Nm ng_device 30a8353960SJulian Elischer.Nd device netgraph node type 31a8353960SJulian Elischer.Sh SYNOPSIS 32a8353960SJulian Elischer.In netgraph/ng_device.h 33a8353960SJulian Elischer.Sh DESCRIPTION 34a8353960SJulian ElischerA 35a8353960SJulian Elischer.Nm device 360912b29fSRuslan Ermilovnode is both a netgraph node and a system device interface. 370912b29fSRuslan ErmilovWhen a 38a8353960SJulian Elischer.Nm device 39a8353960SJulian Elischernode is created, a new device entry appears which is accessible via the 40a8353960SJulian Elischerregular file operators such as 41a8353960SJulian Elischer.Xr open 2 , 42a8353960SJulian Elischer.Xr close 2 , 43a8353960SJulian Elischer.Xr read 2 , 440912b29fSRuslan Ermilov.Xr write 2 , 450912b29fSRuslan Ermilovetc. 46a8353960SJulian Elischer.Pp 470912b29fSRuslan ErmilovThe first node is created as 480912b29fSRuslan Ermilov.Pa /dev/ngd0 , 49*44aae623SIan Leporesubsequent nodes are 500912b29fSRuslan Ermilov.Pa /dev/ngd1 , /dev/ngd2 , 510912b29fSRuslan Ermilovetc. 52762724b3SGleb Smirnoff.Sh HOOKS 53a8353960SJulian ElischerA 54a8353960SJulian Elischer.Nm device 55762724b3SGleb Smirnoffnode has a single hook with an arbitrary name. 560912b29fSRuslan ErmilovAll data coming in over the hook will be presented to the device 57a8353960SJulian Elischerfor 58a8353960SJulian Elischer.Xr read 2 . 59a8353960SJulian ElischerAll data coming in from the device entry by 60a8353960SJulian Elischer.Xr write 2 61a8353960SJulian Elischerwill be forwarded to the hook. 62a8353960SJulian Elischer.Sh CONTROL MESSAGES 63a8353960SJulian ElischerThe 64a8353960SJulian Elischer.Nm device 65*44aae623SIan Leporenode supports the generic control messages, plus the following: 66762724b3SGleb Smirnoff.Bl -tag -width 3n 67762724b3SGleb Smirnoff.It Dv NGM_DEVICE_GET_DEVNAME 68*44aae623SIan LeporeReturns the device name corresponding to the node. 69*44aae623SIan Lepore.It Dv NGM_DEVICE_ETHERALIGN 70*44aae623SIan LeporeApply the system ETHER_ALIGN offset to mbufs sent out the node's hook, 71*44aae623SIan Leporeif running on an architecture that requires strict alignment. 72*44aae623SIan LeporeUse this option when the data being injected via the device node ultimately 73*44aae623SIan Leporeends up being fed into the protocol stack as ethernet packets (e.g., via 74*44aae623SIan Leporean 75*44aae623SIan Lepore.Xr ng_eiface 4 76*44aae623SIan Leporenode). 77762724b3SGleb Smirnoff.El 78762724b3SGleb Smirnoff.\" Additionally, the node accepts 79762724b3SGleb Smirnoff.\" .Xr ioctl 2 Ns s 80762724b3SGleb Smirnoff.\" from the device entry. 81762724b3SGleb Smirnoff.\" These will be encapsulated into 82762724b3SGleb Smirnoff.\" .Xr netgraph 4 83762724b3SGleb Smirnoff.\" messages and send out to the hook. 84a8353960SJulian Elischer.Sh SHUTDOWN 85a8353960SJulian ElischerThis node shuts down upon receipt of a 86a8353960SJulian Elischer.Dv NGM_SHUTDOWN 87762724b3SGleb Smirnoffcontrol message, or upon hook disconnection. 88762724b3SGleb SmirnoffThe associated device entry is removed and becomes available 89a8353960SJulian Elischerfor use by future 90a8353960SJulian Elischer.Nm device 91a8353960SJulian Elischernodes. 92a8353960SJulian Elischer.Sh SEE ALSO 93a8353960SJulian Elischer.Xr netgraph 4 , 94a8353960SJulian Elischer.Xr ngctl 8 95a8353960SJulian Elischer.Sh HISTORY 96a8353960SJulian ElischerThe 97a8353960SJulian Elischer.Nm device 98a8353960SJulian Elischernode type was first implemented in 99a8353960SJulian Elischer.Fx 5.0 . 100a8353960SJulian Elischer.Sh AUTHORS 1016c899950SBaptiste Daroussin.An Mark Santcroos Aq Mt marks@ripe.net 1026c899950SBaptiste Daroussin.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org 103