forked from DGNum/liminix
add netlink socket
it's not hooked up to anything yet, but it proves we can do this with lualinux
This commit is contained in:
parent
b8ac9e5279
commit
032d0f8aca
1 changed files with 12 additions and 1 deletions
|
@ -103,6 +103,13 @@
|
||||||
true)
|
true)
|
||||||
(nil err) (do (print err) false)))
|
(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 []
|
(fn event-loop []
|
||||||
(let [fds {}]
|
(let [fds {}]
|
||||||
{
|
{
|
||||||
|
@ -117,9 +124,10 @@
|
||||||
}))
|
}))
|
||||||
|
|
||||||
(fn run []
|
(fn run []
|
||||||
(let [[sockname] arg
|
(let [[sockname nl-groups] arg
|
||||||
s (unix-socket sockname)
|
s (unix-socket sockname)
|
||||||
db (database)
|
db (database)
|
||||||
|
nl (open-netlink nl-groups)
|
||||||
loop (event-loop)]
|
loop (event-loop)]
|
||||||
(loop:register
|
(loop:register
|
||||||
s
|
s
|
||||||
|
@ -128,6 +136,9 @@
|
||||||
(do
|
(do
|
||||||
(loop:register client (partial handle-client db))
|
(loop:register client (partial handle-client db))
|
||||||
true)))
|
true)))
|
||||||
|
(loop:register
|
||||||
|
nl
|
||||||
|
#(do (print :netlink (ll.read nl)) true))
|
||||||
(while true
|
(while true
|
||||||
(let [pollfds (pollfds-for (loop:fds))]
|
(let [pollfds (pollfds-for (loop:fds))]
|
||||||
(ll.poll pollfds 5000)
|
(ll.poll pollfds 5000)
|
||||||
|
|
Loading…
Reference in a new issue