mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-04-05 00:16:47 +02:00
Add support for the IPV6_V6ONLY socket option defaulting to on.
This commit is contained in:
parent
4df1618aab
commit
f871a29f27
@ -154,6 +154,11 @@ int opt_set_ip_drop_membersip(lua_State *L, p_socket ps)
|
|||||||
return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
|
return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opt_set_ip6_v6only(lua_State *L, p_socket ps)
|
||||||
|
{
|
||||||
|
return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Auxiliar functions
|
* Auxiliar functions
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
@ -32,6 +32,7 @@ int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps);
|
|||||||
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps);
|
int opt_set_ip_multicast_loop(lua_State *L, p_socket ps);
|
||||||
int opt_set_ip_add_membership(lua_State *L, p_socket ps);
|
int opt_set_ip_add_membership(lua_State *L, p_socket ps);
|
||||||
int opt_set_ip_drop_membersip(lua_State *L, p_socket ps);
|
int opt_set_ip_drop_membersip(lua_State *L, p_socket ps);
|
||||||
|
int opt_set_ip6_v6only(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);
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ static t_opt optset[] = {
|
|||||||
{"keepalive", opt_set_keepalive},
|
{"keepalive", opt_set_keepalive},
|
||||||
{"reuseaddr", opt_set_reuseaddr},
|
{"reuseaddr", opt_set_reuseaddr},
|
||||||
{"tcp-nodelay", opt_set_tcp_nodelay},
|
{"tcp-nodelay", opt_set_tcp_nodelay},
|
||||||
|
{"ipv6-v6only", opt_set_ip6_v6only},
|
||||||
{"linger", opt_set_linger},
|
{"linger", opt_set_linger},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
@ -334,6 +335,11 @@ static int tcp_create(lua_State *L, int domain) {
|
|||||||
auxiliar_setclass(L, "tcp{master}", -1);
|
auxiliar_setclass(L, "tcp{master}", -1);
|
||||||
/* initialize remaining structure fields */
|
/* initialize remaining structure fields */
|
||||||
socket_setnonblocking(&sock);
|
socket_setnonblocking(&sock);
|
||||||
|
if (domain == PF_INET6) {
|
||||||
|
int yes = 1;
|
||||||
|
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||||
|
(void *)&yes, sizeof(yes));
|
||||||
|
}
|
||||||
tcp->sock = sock;
|
tcp->sock = sock;
|
||||||
io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
|
io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
|
||||||
(p_error) socket_ioerror, &tcp->sock);
|
(p_error) socket_ioerror, &tcp->sock);
|
||||||
|
@ -77,6 +77,7 @@ static t_opt optset[] = {
|
|||||||
{"ip-multicast-loop", opt_set_ip_multicast_loop},
|
{"ip-multicast-loop", opt_set_ip_multicast_loop},
|
||||||
{"ip-add-membership", opt_set_ip_add_membership},
|
{"ip-add-membership", opt_set_ip_add_membership},
|
||||||
{"ip-drop-membership", opt_set_ip_drop_membersip},
|
{"ip-drop-membership", opt_set_ip_drop_membersip},
|
||||||
|
{"ipv6-v6only", opt_set_ip6_v6only},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -352,6 +353,11 @@ static int udp_create(lua_State *L, int domain) {
|
|||||||
auxiliar_setclass(L, "udp{unconnected}", -1);
|
auxiliar_setclass(L, "udp{unconnected}", -1);
|
||||||
/* initialize remaining structure fields */
|
/* initialize remaining structure fields */
|
||||||
socket_setnonblocking(&sock);
|
socket_setnonblocking(&sock);
|
||||||
|
if (domain == PF_INET6) {
|
||||||
|
int yes = 1;
|
||||||
|
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||||
|
(void *)&yes, sizeof(yes));
|
||||||
|
}
|
||||||
udp->sock = sock;
|
udp->sock = sock;
|
||||||
timeout_init(&udp->tm, -1, -1);
|
timeout_init(&udp->tm, -1, -1);
|
||||||
udp->domain = domain;
|
udp->domain = domain;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user