=========================================================================*\ * Auxiliar functions \*=========================================================================*/
| 349 | * Auxiliar functions |
| 350 | \*=========================================================================*/ |
| 351 | static 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 | |
| 372 | static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, int name) |
| 373 | { |
no test coverage detected