Deleted Added
full compact
ng_socket.4 (84306) ng_socket.4 (117011)
1.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
2.\" All rights reserved.
3.\"
4.\" Subject to the following obligations and disclaimer of warranty, use and
5.\" redistribution of this software, in source or object code forms, with or
6.\" without modifications are expressly permitted by Whistle Communications;
7.\" provided, however, that:
8.\" 1. Any and all reproductions of the source or object code must include the

--- 18 unchanged lines hidden (view full) ---

27.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
31.\" OF SUCH DAMAGE.
32.\"
33.\" Author: Archie Cobbs <archie@FreeBSD.org>
34.\"
1.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
2.\" All rights reserved.
3.\"
4.\" Subject to the following obligations and disclaimer of warranty, use and
5.\" redistribution of this software, in source or object code forms, with or
6.\" without modifications are expressly permitted by Whistle Communications;
7.\" provided, however, that:
8.\" 1. Any and all reproductions of the source or object code must include the

--- 18 unchanged lines hidden (view full) ---

27.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
31.\" OF SUCH DAMAGE.
32.\"
33.\" Author: Archie Cobbs <archie@FreeBSD.org>
34.\"
35.\" $FreeBSD: head/share/man/man4/ng_socket.4 84306 2001-10-01 16:09:29Z ru $
35.\" $FreeBSD: head/share/man/man4/ng_socket.4 117011 2003-06-28 23:53:39Z ru $
36.\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
37.\"
38.Dd January 19, 1999
39.Dt NG_SOCKET 4
40.Os
41.Sh NAME
42.Nm ng_socket
43.Nd netgraph socket node type

--- 6 unchanged lines hidden (view full) ---

50node is both a
51.Bx
52socket and a netgraph node. The
53.Nm
54node type allows user-mode processes to participate in the kernel
55.Xr netgraph 4
56networking subsystem using the
57.Bx
36.\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
37.\"
38.Dd January 19, 1999
39.Dt NG_SOCKET 4
40.Os
41.Sh NAME
42.Nm ng_socket
43.Nd netgraph socket node type

--- 6 unchanged lines hidden (view full) ---

50node is both a
51.Bx
52socket and a netgraph node. The
53.Nm
54node type allows user-mode processes to participate in the kernel
55.Xr netgraph 4
56networking subsystem using the
57.Bx
58socket interface. The process must have
58socket interface.
59The process must have
59root privileges to be able to create netgraph sockets however once created,
60any process that has one may use it.
61.Pp
62A new
63.Nm
64node is created by creating a new socket of type
65.Dv NG_CONTROL
66in the protocol family
67.Dv PF_NETGRAPH ,
68using the
69.Xr socket 2
70system call.
71Any control messages received by the node
72and not having a cookie value of
73.Dv NGM_SOCKET_COOKIE
74are received by the process, using
75.Xr recvfrom 2 ;
76the socket address argument is a
77.Dv "struct sockaddr_ng"
60root privileges to be able to create netgraph sockets however once created,
61any process that has one may use it.
62.Pp
63A new
64.Nm
65node is created by creating a new socket of type
66.Dv NG_CONTROL
67in the protocol family
68.Dv PF_NETGRAPH ,
69using the
70.Xr socket 2
71system call.
72Any control messages received by the node
73and not having a cookie value of
74.Dv NGM_SOCKET_COOKIE
75are received by the process, using
76.Xr recvfrom 2 ;
77the socket address argument is a
78.Dv "struct sockaddr_ng"
78containing the sender's netgraph address. Conversely, control messages
79can be sent to any node by calling
79containing the sender's netgraph address.
80Conversely, control messages can be sent to any node by calling
80.Xr sendto 2 ,
81supplying the recipient's address in a
82.Dv "struct sockaddr_ng" .
83The
84.Xr bind 2
85system call may be used to assign a global netgraph name to the node.
86.Pp
87To transmit and receive netgraph data packets, a
88.Dv NG_DATA
89socket must also be created using
90.Xr socket 2
91and associated with a
92.Nm
93node.
94.Dv NG_DATA sockets do not automatically
95have nodes associated with them; they are bound to a specific node via the
96.Xr connect 2
81.Xr sendto 2 ,
82supplying the recipient's address in a
83.Dv "struct sockaddr_ng" .
84The
85.Xr bind 2
86system call may be used to assign a global netgraph name to the node.
87.Pp
88To transmit and receive netgraph data packets, a
89.Dv NG_DATA
90socket must also be created using
91.Xr socket 2
92and associated with a
93.Nm
94node.
95.Dv NG_DATA sockets do not automatically
96have nodes associated with them; they are bound to a specific node via the
97.Xr connect 2
97system call. The address argument is the netgraph address of the
98system call.
99The address argument is the netgraph address of the
98.Nm
100.Nm
99node already created. Once a data socket is associated with a node,
101node already created.
102Once a data socket is associated with a node,
100any data packets received by the node are read using
101.Xr recvfrom 2
102and any packets to be sent out from the node are written using
103.Xr sendto 2 .
104In the case of data sockets, the
105.Dv "struct sockaddr_ng"
106contains the name of the
107.Em hook

--- 19 unchanged lines hidden (view full) ---

127.Bl -tag -width foo
128.It Dv NGM_SOCK_CMD_NOLINGER
129When the last hook is removed from this node, it will shut down as
130if it had received a
131.Dv NGM_SHUTDOWN
132message. Attempts to access the sockets associated will return
133.Er ENOTCONN .
134.It Dv NGM_SOCK_CMD_LINGER
103any data packets received by the node are read using
104.Xr recvfrom 2
105and any packets to be sent out from the node are written using
106.Xr sendto 2 .
107In the case of data sockets, the
108.Dv "struct sockaddr_ng"
109contains the name of the
110.Em hook

--- 19 unchanged lines hidden (view full) ---

130.Bl -tag -width foo
131.It Dv NGM_SOCK_CMD_NOLINGER
132When the last hook is removed from this node, it will shut down as
133if it had received a
134.Dv NGM_SHUTDOWN
135message. Attempts to access the sockets associated will return
136.Er ENOTCONN .
137.It Dv NGM_SOCK_CMD_LINGER
135This is the default mode. When the last hook is removed, the node will
138This is the default mode.
139When the last hook is removed, the node will
136continue to exist, ready to accept new hooks until it
137is explicitly shut down.
138.El
139.Pp
140All other messages
141with neither the
142.Dv NGM_SOCKET_COOKIE
143or
144.Dv NGM_GENERIC_COOKIE
145will be passed unaltered up the
146.Dv NG_CONTROL
147socket.
148.Sh SHUTDOWN
149This node type shuts down and disappears when both the associated
150.Dv NG_CONTROL
151and
152.Dv NG_DATA
153sockets have been closed, or a
154.Dv NGM_SHUTDOWN
140continue to exist, ready to accept new hooks until it
141is explicitly shut down.
142.El
143.Pp
144All other messages
145with neither the
146.Dv NGM_SOCKET_COOKIE
147or
148.Dv NGM_GENERIC_COOKIE
149will be passed unaltered up the
150.Dv NG_CONTROL
151socket.
152.Sh SHUTDOWN
153This node type shuts down and disappears when both the associated
154.Dv NG_CONTROL
155and
156.Dv NG_DATA
157sockets have been closed, or a
158.Dv NGM_SHUTDOWN
155control message is received. In the latter case, attempts to write
159control message is received.
160In the latter case, attempts to write
156to the still-open sockets will return
157.Er ENOTCONN .
158If the
159.Dv NGM_SOCK_CMD_NOLINGER
160message has been received, closure of the last hook will also initiate
161a shutdown of the node.
162.Sh BUGS
163It is not possible to reject the connection of a hook, though any
164data received on that hook can certainly be ignored.
165.Pp
166The controlling process is not notified of all events that an in-kernel node
161to the still-open sockets will return
162.Er ENOTCONN .
163If the
164.Dv NGM_SOCK_CMD_NOLINGER
165message has been received, closure of the last hook will also initiate
166a shutdown of the node.
167.Sh BUGS
168It is not possible to reject the connection of a hook, though any
169data received on that hook can certainly be ignored.
170.Pp
171The controlling process is not notified of all events that an in-kernel node
167would be notified of, e.g. a new hook, or hook removal. We should define
168some node-initiated messages for this purpose (to be sent up the control
169socket).
172would be notified of, e.g. a new hook, or hook removal.
173Some node-initiated messages should be defined for this purpose (to be
174sent up the control socket).
170.Sh SEE ALSO
171.Xr socket 2 ,
172.Xr netgraph 3 ,
173.Xr netgraph 4 ,
174.Xr ng_ksocket 4 ,
175.Xr ngctl 8
176.Sh HISTORY
177The
178.Nm
179node type was implemented in
180.Fx 4.0 .
181.Sh AUTHORS
182.An Julian Elischer Aq julian@FreeBSD.org
175.Sh SEE ALSO
176.Xr socket 2 ,
177.Xr netgraph 3 ,
178.Xr netgraph 4 ,
179.Xr ng_ksocket 4 ,
180.Xr ngctl 8
181.Sh HISTORY
182The
183.Nm
184node type was implemented in
185.Fx 4.0 .
186.Sh AUTHORS
187.An Julian Elischer Aq julian@FreeBSD.org