xref: /freebsd/share/man/man4/ng_tty.4 (revision b2c76c41be32f904179efed29c0ca04d53f3996c)
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.\" $Whistle: ng_tty.8,v 1.5 1999/01/25 23:46:28 archie Exp $
35.\"
36.Dd December 25, 2008
37.Dt NG_TTY 4
38.Os
39.Sh NAME
40.Nm ng_tty
41.Nd netgraph node type that is also a TTY hook
42.Sh SYNOPSIS
43.In sys/types.h
44.In sys/ttycom.h
45.In netgraph/ng_tty.h
46.Sh DESCRIPTION
47The
48.Nm tty
49node type is both a netgraph node type and a TTY hook.
50.Pp
51The node has a single hook called
52.Dv hook .
53Incoming bytes received on the tty device are sent out on this hook,
54and frames received on
55.Dv hook
56are transmitted out on the tty device.
57No modification to the data is performed in either direction.
58While the hook is installed on a tty, the normal read and write
59operations are unavailable, returning
60.Er EIO .
61.Pp
62Incoming data is delivered directly to ng_tty via the tty bypass hook as a
63buffer pointer and length, this is converted to a mbuf and passed to the peer.
64.Pp
65The node supports an optional
66.Dq hot character .
67If the driver can not deliver data directly to the tty bypass hook then each
68character is input one at a time.
69If set to non-zero and bypass mode is unavailable, incoming
70data from the tty device is queued until this character is seen.
71This avoids sending lots of mbufs containing a small number of bytes,
72but introduces potentially infinite latency.
73The default hot character is 0x7e, consistent with
74.Dv hook
75being connected to a
76.Xr ng_async 4
77type node.
78The hot character has no effect on the transmission of data.
79.Sh HOOKS
80This node type supports the following hooks:
81.Bl -tag -width ".Va hook"
82.It Va hook
83.Xr tty 4
84serial data contained in
85.Dv mbuf
86structures, with arbitrary inter-frame boundaries.
87.El
88.Sh CONTROL MESSAGES
89This node type supports the generic control messages, plus the following:
90.Bl -tag -width foo
91.It Dv NGM_TTY_SET_HOTCHAR
92This command takes an integer argument and sets the hot character
93from the lower 8 bits.
94A hot character of zero disables queueing,
95so that all received data is forwarded immediately.
96.It Dv NGM_TTY_GET_HOTCHAR
97Returns an integer containing the current hot character in the lower
98eight bits.
99.It Dv NGM_TTY_SET_TTY
100This command takes integer process ID and file descriptor of open tty
101and registers the tty hooks.
102.El
103.Sh SHUTDOWN
104This node shuts down when the corresponding device is closed.
105.Sh SEE ALSO
106.Xr ioctl 2 ,
107.Xr netgraph 4 ,
108.Xr ng_async 4 ,
109.Xr tty 4 ,
110.Xr ngctl 8
111.Sh HISTORY
112The
113.Nm
114node type was implemented in
115.Fx 4.0 .
116.Sh AUTHORS
117.An Archie Cobbs Aq Mt archie@FreeBSD.org
118.An Andrew Thompson Aq Mt thompsa@FreeBSD.org
119.Sh BUGS
120The serial driver code also has a notion of a
121.Dq hot character .
122Unfortunately, this value is statically defined in terms of the
123line discipline and cannot be changed.
124Therefore, if a hot character other than 0x7e (the default) is set for the
125.Nm
126node, the node has no way to convey this information to the
127serial driver, and sub-optimal performance may result.
128