add opt_get_ip_multicast_ttl, opt_get_bindtodevice and opt_set_bindtodevice

This commit is contained in:
Gerhard Lipp 2013-07-30 13:24:35 +02:00
parent 6bdb00e24c
commit 6a0587c88d
3 changed files with 29 additions and 0 deletions

View File

@ -187,6 +187,29 @@ int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps)
return opt_setint(L, ps, IPPROTO_IP, IP_MULTICAST_TTL); return opt_setint(L, ps, IPPROTO_IP, IP_MULTICAST_TTL);
} }
int opt_get_ip_multicast_ttl(lua_State *L, p_socket ps)
{
return opt_getint(L, ps, IPPROTO_IP, IP_MULTICAST_TTL);
}
int opt_set_bindtodevice(lua_State *L, p_socket ps)
{
size_t len;
const char *device = luaL_checklstring(L, 3, &len); /* obj, name, device */
return opt_set(L, ps, SOL_SOCKET, SO_BINDTODEVICE, (char *) device, len);
}
int opt_get_bindtodevice(lua_State *L, p_socket ps)
{
int len;
char device[IFNAMSIZ];
int err = opt_get(L, ps, SOL_SOCKET, SO_BINDTODEVICE, (char *) device, &len);
if (err)
return err;
lua_pushlstring(L, device, len);
return 1;
}
int opt_set_ip_multicast_if(lua_State *L, p_socket ps) int opt_set_ip_multicast_if(lua_State *L, p_socket ps)
{ {
const char *address = luaL_checkstring(L, 3); /* obj, name, ip */ const char *address = luaL_checkstring(L, 3); /* obj, name, ip */

View File

@ -38,6 +38,7 @@ int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps);
int opt_set_ip6_add_membership(lua_State *L, p_socket ps); int opt_set_ip6_add_membership(lua_State *L, p_socket ps);
int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps); int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps);
int opt_set_ip6_v6only(lua_State *L, p_socket ps); int opt_set_ip6_v6only(lua_State *L, p_socket ps);
int opt_set_bindtodevice(lua_State *L, p_socket ps);
/* supported options for getoption */ /* supported options for getoption */
int opt_get_reuseaddr(lua_State *L, p_socket ps); int opt_get_reuseaddr(lua_State *L, p_socket ps);
@ -47,11 +48,13 @@ int opt_get_linger(lua_State *L, p_socket ps);
int opt_get_reuseaddr(lua_State *L, p_socket ps); int opt_get_reuseaddr(lua_State *L, p_socket ps);
int opt_get_ip_multicast_loop(lua_State *L, p_socket ps); int opt_get_ip_multicast_loop(lua_State *L, p_socket ps);
int opt_get_ip_multicast_if(lua_State *L, p_socket ps); int opt_get_ip_multicast_if(lua_State *L, p_socket ps);
int opt_get_ip_multicast_ttl(lua_State *L, p_socket ps);
int opt_get_error(lua_State *L, p_socket ps); int opt_get_error(lua_State *L, p_socket ps);
int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps); int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps);
int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps); int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps);
int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
int opt_get_ip6_v6only(lua_State *L, p_socket ps); int opt_get_ip6_v6only(lua_State *L, p_socket ps);
int opt_get_bindtodevice(lua_State *L, p_socket ps);
/* invokes the appropriate option handler */ /* invokes the appropriate option handler */
int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps);

View File

@ -84,18 +84,21 @@ static t_opt optset[] = {
{"ipv6-add-membership", opt_set_ip6_add_membership}, {"ipv6-add-membership", opt_set_ip6_add_membership},
{"ipv6-drop-membership", opt_set_ip6_drop_membersip}, {"ipv6-drop-membership", opt_set_ip6_drop_membersip},
{"ipv6-v6only", opt_set_ip6_v6only}, {"ipv6-v6only", opt_set_ip6_v6only},
{"bindtodevice", opt_set_bindtodevice},
{NULL, NULL} {NULL, NULL}
}; };
/* socket options for getoption */ /* socket options for getoption */
static t_opt optget[] = { static t_opt optget[] = {
{"ip-multicast-if", opt_get_ip_multicast_if}, {"ip-multicast-if", opt_get_ip_multicast_if},
{"ip-multicast-ttl", opt_get_ip_multicast_ttl},
{"ip-multicast-loop", opt_get_ip_multicast_loop}, {"ip-multicast-loop", opt_get_ip_multicast_loop},
{"error", opt_get_error}, {"error", opt_get_error},
{"ipv6-unicast-hops", opt_get_ip6_unicast_hops}, {"ipv6-unicast-hops", opt_get_ip6_unicast_hops},
{"ipv6-multicast-hops", opt_get_ip6_unicast_hops}, {"ipv6-multicast-hops", opt_get_ip6_unicast_hops},
{"ipv6-multicast-loop", opt_get_ip6_multicast_loop}, {"ipv6-multicast-loop", opt_get_ip6_multicast_loop},
{"ipv6-v6only", opt_get_ip6_v6only}, {"ipv6-v6only", opt_get_ip6_v6only},
{"bindtodevice", opt_get_bindtodevice},
{NULL, NULL} {NULL, NULL}
}; };