MCPcopy Create free account
hub / github.com/Tencent/UnLua / opt_setmembership

Function opt_setmembership

Plugins/UnLuaExtensions/LuaSocket/Source/src/options.cpp:351–370  ·  view source on GitHub ↗

=========================================================================*\ * Auxiliar functions \*=========================================================================*/

Source from the content-addressed store, hash-verified

349* Auxiliar functions
350\*=========================================================================*/
351static int opt_setmembership(lua_State *L, p_socket ps, int level, int name)
352{
353 struct ip_mreq val; /* obj, name, table */
354 if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE));
355 lua_pushstring(L, "multiaddr");
356 lua_gettable(L, 3);
357 if (!lua_isstring(L, -1))
358 luaL_argerror(L, 3, "string 'multiaddr' field expected");
359 if (!inet_aton(lua_tostring(L, -1), &val.imr_multiaddr))
360 luaL_argerror(L, 3, "invalid 'multiaddr' ip address");
361 lua_pushstring(L, "interface");
362 lua_gettable(L, 3);
363 if (!lua_isstring(L, -1))
364 luaL_argerror(L, 3, "string 'interface' field expected");
365 val.imr_interface.s_addr = htonl(INADDR_ANY);
366 if (strcmp(lua_tostring(L, -1), "*") &&
367 !inet_aton(lua_tostring(L, -1), &val.imr_interface))
368 luaL_argerror(L, 3, "invalid 'interface' ip address");
369 return opt_set(L, ps, level, name, (char *) &val, sizeof(val));
370}
371
372static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, int name)
373{

Callers 2

Calls 8

auxiliar_typeerrorFunction · 0.85
lua_typenameFunction · 0.85
lua_pushstringFunction · 0.85
lua_gettableFunction · 0.85
lua_isstringFunction · 0.85
luaL_argerrorFunction · 0.85
inet_atonFunction · 0.85
opt_setFunction · 0.85

Tested by

no test coverage detected