Manual Reference Pages - NG_SOCKET (4)
- netgraph socket node type
node is both a
socket and a netgraph node.
node type allows user-mode processes to participate in the kernel
networking subsystem using the
The process must have
root privileges to be able to create netgraph sockets however once created,
any process that has one may use it.
node is created by creating a new socket of type
in the protocol family
Any control messages received by the node
and not having a cookie value of
are received by the process, using
the socket address argument is a
containing the senders netgraph address.
Conversely, control messages can be sent to any node by calling
supplying the recipients address in a
system call may be used to assign a global netgraph name to the node.
To transmit and receive netgraph data packets, a
socket must also be created using
and associated with a
sockets do not automatically
have nodes associated with them; they are bound to a specific node via the
The address argument is the netgraph address of the
node already created.
Once a data socket is associated with a node,
any data packets received by the node are read using
and any packets to be sent out from the node are written using
In the case of data sockets, the
contains the name of the
on which the data was received or should be sent.
As a special case, to allow netgraph data sockets to be used as stdin or stdout
on naive programs, a
with a NULL sockaddr pointer, a
will succeed in the case where there is exactly ONE hook attached to
the socket node, (and thus the path is unambiguous).
There is a user library that simplifies using netgraph sockets; see
This node type supports hooks with arbitrary names (as long as
they are unique) and always accepts hook connection requests.
This node type supports the generic control messages, plus the following:
When the last hook is removed from this node, it will shut down as
if it had received a
Attempts to access the sockets associated will return
This is the default mode.
When the last hook is removed, the node will
continue to exist, ready to accept new hooks until it
is explicitly shut down.
All other messages
with neither the
will be passed unaltered up the
This node type shuts down and disappears when both the associated
sockets have been closed, or a
control message is received.
In the latter case, attempts to write
to the still-open sockets will return
message has been received, closure of the last hook will also initiate
a shutdown of the node.
node type was implemented in
.Fx 4.0 .
.An Julian Elischer Aq julian@FreeBSD.org
It is not possible to reject the connection of a hook, though any
data received on that hook can certainly be ignored.
The controlling process is not notified of all events that an in-kernel node
would be notified of, e.g. a new hook, or hook removal.
Some node-initiated messages should be defined for this purpose (to be
sent up the control socket).
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.