From 032d0f8aca159cae22ed57a275491e8e160e06a4 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 23 Apr 2024 23:34:25 +0100 Subject: [PATCH] add netlink socket it's not hooked up to anything yet, but it proves we can do this with lualinux --- pkgs/devout/devout.fnl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/devout/devout.fnl b/pkgs/devout/devout.fnl index 95fe02e..dbd7ace 100644 --- a/pkgs/devout/devout.fnl +++ b/pkgs/devout/devout.fnl @@ -103,6 +103,13 @@ true) (nil err) (do (print err) false))) +(fn open-netlink [groups] + (match (ll.socket AF_NETLINK SOCK_RAW NETLINK_KOBJECT_UEVENT) + fd (doto fd (ll.bind (string.pack "I2I2I4I4" ; family pad pid groups + AF_NETLINK 0 0 groups))) + (nil errno) (values nil errno))) + + (fn event-loop [] (let [fds {}] { @@ -117,9 +124,10 @@ })) (fn run [] - (let [[sockname] arg + (let [[sockname nl-groups] arg s (unix-socket sockname) db (database) + nl (open-netlink nl-groups) loop (event-loop)] (loop:register s @@ -128,6 +136,9 @@ (do (loop:register client (partial handle-client db)) true))) + (loop:register + nl + #(do (print :netlink (ll.read nl)) true)) (while true (let [pollfds (pollfds-for (loop:fds))] (ll.poll pollfds 5000)