NG_TTY(4)
π NAME π
ng_tty β the netgraph node type that's literally also a TTY hook. Bestie, it's both. Periodt. π
π SYNOPSIS π
drop these includes in your source, no cap:
#include <sys/types.h>
#include <sys/ttycom.h>
#include <netgraph/ng_tty.h>
πΈ DESCRIPTION πΈ
okay so the tty node type is both a netgraph node type and a TTY hook. it's giving duality. β¨
the node has a single hook called hook. incoming bytes received on the tty device are sent out on this hook, and frames received on hook are transmitted out on the tty device. no modification to the data is performed in either direction β zero edits, none. while the hook is installed on a tty, the normal read and write operations are unavailable, returning EIO. so yeah, no casual reads/writes while it's hooked up. π
incoming data is delivered directly to ng_tty via the tty bypass hook as a buffer pointer and length, this is converted to a mbuf and passed to the peer. the way that's efficient is highkey iconic. π₯
the node supports an optional βhot characterβ. if the driver can not deliver data directly to the tty bypass hook then each character is input one at a time. if set to non-zero and bypass mode is unavailable, incoming data from the tty device is queued until this character is seen. this avoids sending lots of mbufs containing a small number of bytes, but introduces potentially infinite latency. so like, tradeoffs, bestie. π the default hot character is 0x7e, consistent with hook being connected to a ng_async(4) type node. the hot character has no effect on the transmission of data. it's only about the incoming queueing vibe. π¦
π HOOKS π
this node type supports the following hooks:
hookβtty(4)serial data contained inmbufstructures, with arbitrary inter-frame boundaries. so like, the data is inmbufstructures and the frame boundaries can be wherever. slay. π
π CONTROL MESSAGES π
this node type supports the generic control messages, plus the following:
NGM_TTY_SET_HOTCHARβ this command takes an integer argument and sets the hot character from the lower 8 bits. a hot character of zero disables queueing, so that all received data is forwarded immediately. zero = no queue, just vibes. π₯NGM_TTY_GET_HOTCHARβ returns an integer containing the current hot character in the lower eight bits. yep, lower eight bits. iykyk. πNGM_TTY_SET_TTYβ this command takes integer process ID and file descriptor of open tty and registers the tty hooks. process ID + fd = registered. periodt. π«Ά
π SHUTDOWN π
this node shuts down when the corresponding device is closed. so when the tty device closes, the node is out. bye bestie. π
π SEE ALSO π
go check out these besties: ioctl(2), netgraph(4), ng_async(4), tty(4), ngctl(8). all linked, all iconic. π
π HISTORY π
the ng_tty node type was implemented in FreeBSD 4.0. vintage but still serving. π
π AUTHORS π
- Archie Cobbs
<archie@FreeBSD.org> - Andrew Thompson
<thompsa@FreeBSD.org>
these two ate and left no crumbs. π
π BUGS π
ngl this is a whole mess: the serial driver code also has a notion of a βhot characterβ. unfortunately, this value is statically defined in terms of the line discipline and cannot be changed. therefore, if a hot character other than 0x7e (the default) is set for the ng_tty node, the node has no way to convey this information to the serial driver, and sub-optimal performance may result. so like, if you change the hot character, the serial driver just doesn't know, and performance might be mid. π
and that's the tea! this page is from Debian, dated December 25, 2008, and the manual is NG_TTY(4) β mwah, kisses, bye bestie! ππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1996-1999 Whistle Communications, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms