commit f3a13630d30e3b4d9d84562782260de010c989fd
parent f233acf9ff8074c108546b2dbc5ac3e6205461d2
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 11 Apr 2024 23:03:49 +0100
add multicast groups param to nellie.open
Diffstat:
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/pkgs/nellie/nellie.c b/pkgs/nellie/nellie.c
@@ -44,10 +44,18 @@ static int l_open_socket(lua_State *L) {
memset(&sa, 0, sizeof(sa));
sa.nl_family = AF_NETLINK;
sa.nl_pid = getpid();
- sa.nl_groups = 4; /* rebroadcasts from mdevd */
+
+ if(lua_isnumber(L, 1)) {
+ sa.nl_groups = lua_tointeger(L, 1);
+ lua_pop(L, 1);
+ }
+ else {
+ sa.nl_groups = 4; /* group 4 is rebroadcasts from mdevd */
+ }
if(bind(netlink_fd, (struct sockaddr *) &sa, sizeof(sa))==0) {
lua_newtable(L);
+
lua_pushliteral(L, "fileno");
lua_pushinteger(L, netlink_fd);
lua_settable(L, 1);
diff --git a/pkgs/nellie/test.lua b/pkgs/nellie/test.lua
@@ -1,5 +1,5 @@
local nellie = require('nellie')
print('dfg')
-local f = nellie.open()
+local f = nellie.open(2)
print(string.byte(f:read(1000), 0, 60))