NG_DEVICE(4)

πŸ’– NG_DEVICE πŸ’–

okay bestie, welcome to the manual page for ng_device β€” that's the device netgraph node type, from the Kernel Interfaces Manual section 4. sit down, grab a boba, we're gonna get you fluent in this fr fr πŸ§‹βœ¨


✨ NAME ✨

ng_device β€” the device netgraph node type πŸ’…


🌸 SYNOPSIS 🌸

#include <netgraph/ng_device.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

So a device node is literally two things at once, no cap: it's a netgraph node and a system device interface. main character energy honestly πŸ‘‘

The way that when a device node gets created, a whole new device entry just appears β€” and you can reach it with all your regular file operators like open(2), close(2), read(2), write(2), etc. iconic behaviour, we love to see it πŸ’–

And the naming? Obsessed. The first node shows up as /dev/ngd0, and then every subsequent one is /dev/ngd1, /dev/ngd2, etc. β€” just counting up forever like a little queue of cuties πŸŽ€


🫢 HOOKS 🫢

A device node has a single hook, and you can give it any arbitrary name you want. Slay, freedom of expression πŸ’…

Here's the tea on the data flow:

  • everything coming in over the hook gets presented to the device for read(2) πŸ“₯
  • everything coming in from the device entry via write(2) gets forwarded to the hook πŸ“€

it's giving two-way street, it's giving communication, it's giving πŸ¦‹


πŸ”₯ CONTROL MESSAGES πŸ”₯

This node supports exactly one non-generic control message, and here she is:

  • NGM_DEVICE_GET_DEVNAME β€” returns the device name that corresponds to a node ✨

πŸ’€ SHUTDOWN πŸ’€

This node shuts down when:

  • it receives a NGM_SHUTDOWN control message, or
  • the hook gets disconnected 😭

And when that happens, the associated device entry is removed and becomes available for use by future device nodes. recycling queen β™»οΈβœ¨


πŸ‘‘ SEE ALSO πŸ‘‘


🌈 HISTORY 🌈

The device node type was first implemented in FreeBSD 5.0. a legend was born, periodt πŸ’…


πŸŽ€ AUTHORS πŸŽ€

  • Mark Santcroos <marks@ripe.net>
  • Gleb Smirnoff <glebius@FreeBSD.org>

and that's the whole page bestie!! this one's from the Debian crew, dated October 19, 2004, and it's page NG_DEVICE(4) in section 4 β€” go forth and netgraph responsibly, ily, mwah πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from