xref: /freebsd/share/man/man4/ng_tty.4 (revision 77a62bf55d9fa10d6376ee53c1ddd9790dd41d36)
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
9.\"    copyright notice above and the following disclaimer of warranties; and
10.\" 2. No rights are granted, in any manner or form, to use Whistle
11.\"    Communications, Inc. trademarks, including the mark "WHISTLE
12.\"    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
13.\"    such appears in the above copyright notice or in the software.
14.\"
15.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
16.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
17.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
18.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
19.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
20.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
21.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
22.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
23.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
24.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
25.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
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$
36.\" $Whistle: ng_tty.8,v 1.5 1999/01/25 23:46:28 archie Exp $
37.\"
38.Dd October 2, 2008
39.Dt NG_TTY 4
40.Os
41.Sh NAME
42.Nm ng_tty
43.Nd netgraph node type that is also a TTY hook
44.Sh SYNOPSIS
45.In sys/types.h
46.In sys/ttycom.h
47.In netgraph/ng_tty.h
48.Sh DESCRIPTION
49The
50.Nm tty
51node type is both a netgraph node type and a TTY hook.
52.Pp
53The node has a single hook called
54.Dv hook .
55Incoming bytes received on the tty device are sent out on this hook,
56and frames received on
57.Dv hook
58are transmitted out on the tty device.
59No modification to the data is performed in either direction.
60While the hook is installed on a tty, the normal read and write
61operations are unavailable, returning
62.Er EIO .
63.Pp
64Incoming data is delivered directly to ng_tty via the tty bypass hook as a
65buffer pointer and length, this is converted to a mbuf and passed to the peer.
66.Pp
67The node supports an optional
68.Dq hot character .
69If the driver can not deliver data directly to the tty bypass hook then each
70character is input one at a time.
71If set to non-zero and bypass mode is unavailable, incoming
72data from the tty device is queued until this character is seen.
73This avoids sending lots of mbufs containing a small number of bytes,
74but introduces potentially infinite latency.
75The default hot character is 0x7e, consistent with
76.Dv hook
77being connected to a
78.Xr ng_async 4
79type node.
80The hot character has no effect on the transmission of data.
81.Pp
82The node will attempt to give itself the same netgraph name as the name
83of the tty device.
84In any case, information about the node is available via the netgraph
85.Xr ioctl 2
86command
87.Dv NGIOCGINFO .
88This command returns a
89.Dv "struct nodeinfo"
90similar to the
91.Dv NGM_NODEINFO
92netgraph control message.
93.Sh HOOKS
94This node type supports the following hooks:
95.Pp
96.Bl -tag -width foobar
97.It Dv hook
98.Xr tty 4
99serial data contained in
100.Dv mbuf
101structures, with arbitrary inter-frame boundaries.
102.El
103.Sh CONTROL MESSAGES
104This node type supports the generic control messages, plus the following:
105.Bl -tag -width foo
106.It Dv NGM_TTY_SET_HOTCHAR
107This command takes an integer argument and sets the hot character
108from the lower 8 bits.
109A hot character of zero disables queueing,
110so that all received data is forwarded immediately.
111.It Dv NGM_TTY_GET_HOTCHAR
112Returns an integer containing the current hot character in the lower
113eight bits.
114.It Dv NGM_TTY_SET_TTY
115This command takes an integer pointer to the open file descriptor of the tty
116and registers the tty hooks.
117.El
118.Sh SHUTDOWN
119This node shuts down when the corresponding device is closed.
120.Sh SEE ALSO
121.Xr ioctl 2 ,
122.Xr netgraph 4 ,
123.Xr ng_async 4 ,
124.Xr tty 4 ,
125.Xr ngctl 8
126.Sh HISTORY
127The
128.Nm
129node type was implemented in
130.Fx 4.0 .
131.Sh AUTHORS
132.An Archie Cobbs Aq archie@FreeBSD.org
133.An Andrew Thompson Aq thompsa@FreeBSD.org
134.Sh BUGS
135The serial driver code also has a notion of a
136.Dq hot character .
137Unfortunately, this value is statically defined in terms of the
138line discipline and cannot be changed.
139Therefore, if a hot character other than 0x7e (the default) is set for the
140.Nm
141node, the node has no way to convey this information to the
142serial driver, and sub-optimal performance may result.
143