forked from DGNum/liminix
add multicast groups param to nellie.open
This commit is contained in:
parent
f233acf9ff
commit
f3a13630d3
2 changed files with 10 additions and 2 deletions
|
@ -44,10 +44,18 @@ static int l_open_socket(lua_State *L) {
|
||||||
memset(&sa, 0, sizeof(sa));
|
memset(&sa, 0, sizeof(sa));
|
||||||
sa.nl_family = AF_NETLINK;
|
sa.nl_family = AF_NETLINK;
|
||||||
sa.nl_pid = getpid();
|
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) {
|
if(bind(netlink_fd, (struct sockaddr *) &sa, sizeof(sa))==0) {
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|
||||||
lua_pushliteral(L, "fileno");
|
lua_pushliteral(L, "fileno");
|
||||||
lua_pushinteger(L, netlink_fd);
|
lua_pushinteger(L, netlink_fd);
|
||||||
lua_settable(L, 1);
|
lua_settable(L, 1);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local nellie = require('nellie')
|
local nellie = require('nellie')
|
||||||
print('dfg')
|
print('dfg')
|
||||||
local f = nellie.open()
|
local f = nellie.open(2)
|
||||||
|
|
||||||
print(string.byte(f:read(1000), 0, 60))
|
print(string.byte(f:read(1000), 0, 60))
|
||||||
|
|
Loading…
Reference in a new issue