NG_TTY(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’– 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 in mbuf structures, with arbitrary inter-frame boundaries. so like, the data is in mbuf structures 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