NG_H4(4)

πŸ’™ NG_H4 πŸ’™

okay bestie, so <sys/types.h> and <netgraph/bluetooth/include/ng_h4.h> are the vibe, ng_h4 is the name, and it's the Netgraph node type that's also an H4 line discipline. two jobs, one icon. πŸ‘‘


✨ SYNOPSIS ✨

#include <sys/types.h>
#include <netgraph/bluetooth/include/ng_h4.h>

🌸 DESCRIPTION 🌸

So the h4 node type is lowkey doing double duty: it's a persistent Netgraph node type and an H4 line discipline. It implements a Bluetooth HCI UART transport layer, exactly as chapter H4 of the Bluetooth Specification Book v1.1 says to do it. no improvising, we're following the spec fr fr.

A brand new node gets created when the corresponding line discipline, H4DISC, is registered on a tty device (go look at tty(4) for that part, iykyk).

The node has a single hook called hook. Here's the flow, bestie, follow me:

  • Incoming bytes that show up on the tty device get re-assembled into HCI frames (according to the length).
  • Full HCI frames get sent out on the hook.
  • HCI frames received on hook get transmitted out on the tty device.
  • No modification to the data happens in either direction. we do not touch the data. we simply vibe. πŸ’…
While the line discipline is installed on a tty, the normal read and write operations are unavailable, and they return EIO. so like, don't try it. it's giving blocked.

Info about the node is available via the netgraph ioctl(2) command NGIOCGINFO. That command returns a struct nodeinfo, similar to the NGM_NODEINFO netgraph(4) control message.


πŸͺ HOOKS πŸͺ

This node type supports the following hooks:

  • hook β€” single HCI frame contained in single mbuf structure.

πŸŽ€ CONTROL MESSAGES πŸŽ€

This node type supports the generic control messages, plus these little cuties:

  • NGM_H4_NODE_RESET β€” Reset the node.
  • NGM_H4_NODE_GET_STATE β€” Returns current receiving state for the node.
  • NGM_H4_NODE_GET_DEBUG β€” Returns an integer containing the current debug level for the node.
  • NGM_H4_NODE_SET_DEBUG β€” This command takes an integer argument and sets current debug level for the node.
  • NGM_H4_NODE_GET_QLEN β€” Returns current length of outgoing queue for the node.
  • NGM_H4_NODE_SET_QLEN β€” This command takes an integer argument and sets maximum length of outgoing queue for the node.
  • NGM_H4_NODE_GET_STAT β€” Returns various statistic information for the node, such as: number of bytes (frames) sent, number of bytes (frames) received and number of input (output) errors.
  • NGM_H4_NODE_RESET_STAT β€” Reset all statistic counters to zero.

πŸ’€ SHUTDOWN πŸ’€

This node shuts down when the corresponding device is closed (or the line discipline is uninstalled on the device). that's it, that's the goodbye. πŸ¦‹


πŸ‘€ SEE ALSO πŸ‘€

ioctl(2), netgraph(4), tty(4), ngctl(8)


πŸ“œ HISTORY πŸ“œ

The h4 node type was implemented in FreeBSD 5.0. an OG, periodt.


🫢 AUTHORS 🫢

Maksim Yevmenkin <m_evmenkin@yahoo.com>


😭 BUGS 😭

This node still uses spltty(9) to lock tty layer. This is wrong.

not me reading this and going πŸ’€ β€” it's literally in the manual, bestie. it's wrong and they know it.

and that's the whole page, mwah πŸ’– this one came out of the Debian crew, dated June 14, 2002 β€” so like, a whole legend before most of us could even type. stay hydrated, read your manpages, ily. 🌈✨

πŸ“¦ where this page comes from