From f3a13630d30e3b4d9d84562782260de010c989fd Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 11 Apr 2024 23:03:49 +0100 Subject: [PATCH] add multicast groups param to nellie.open --- pkgs/nellie/nellie.c | 10 +++++++++- pkgs/nellie/test.lua | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/nellie/nellie.c b/pkgs/nellie/nellie.c index 2267c51..69c3201 100644 --- 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 index f540d21..d964c49 100644 --- 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))