Add option for SO_EXCLUSIVEADDRUSE

This commit is contained in:
Wires77 2025-02-27 15:40:35 -06:00
parent 1fad162690
commit 4956347952
4 changed files with 37 additions and 0 deletions

View File

@ -93,6 +93,26 @@ int opt_get_reuseaddr(lua_State *L, p_socket ps)
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
}
/*------------------------------------------------------*/
/* enables reuse of local address */
int opt_set_exclusiveaddruse(lua_State* L, p_socket ps)
{
#ifndef SO_EXCLUSIVEADDRUSE
return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system");
#else
return opt_setboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE);
#endif
}
int opt_get_exclusiveaddruse(lua_State* L, p_socket ps)
{
#ifndef SO_EXCLUSIVEADDRUSE
return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system");
#else
return opt_getboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE);
#endif
}
/*------------------------------------------------------*/
/* enables reuse of local port */
int opt_set_reuseport(lua_State *L, p_socket ps)

View File

@ -28,6 +28,11 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps);
int opt_set_reuseaddr(lua_State *L, p_socket ps);
int opt_get_reuseaddr(lua_State *L, p_socket ps);
#ifdef SO_EXCLUSIVEADDRUSE
int opt_set_exclusiveaddruse(lua_State* L, p_socket ps);
int opt_get_exclusiveaddruse(lua_State* L, p_socket ps);
#endif
int opt_set_reuseport(lua_State *L, p_socket ps);
int opt_get_reuseport(lua_State *L, p_socket ps);

View File

@ -74,6 +74,9 @@ static t_opt optget[] = {
{"bindtodevice", opt_get_bindtodevice},
{"keepalive", opt_get_keepalive},
{"reuseaddr", opt_get_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_get_exclusiveaddruse},
#endif
{"reuseport", opt_get_reuseport},
{"tcp-nodelay", opt_get_tcp_nodelay},
#ifdef TCP_KEEPIDLE
@ -96,6 +99,9 @@ static t_opt optset[] = {
{"bindtodevice", opt_set_bindtodevice},
{"keepalive", opt_set_keepalive},
{"reuseaddr", opt_set_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_set_exclusiveaddruse},
#endif
{"reuseport", opt_set_reuseport},
{"tcp-nodelay", opt_set_tcp_nodelay},
#ifdef TCP_KEEPIDLE

View File

@ -74,6 +74,9 @@ static t_opt optset[] = {
{"dontroute", opt_set_dontroute},
{"broadcast", opt_set_broadcast},
{"reuseaddr", opt_set_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_set_exclusiveaddruse},
#endif
{"reuseport", opt_set_reuseport},
{"ip-multicast-if", opt_set_ip_multicast_if},
{"ip-multicast-ttl", opt_set_ip_multicast_ttl},
@ -96,6 +99,9 @@ static t_opt optget[] = {
{"dontroute", opt_get_dontroute},
{"broadcast", opt_get_broadcast},
{"reuseaddr", opt_get_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_get_exclusiveaddruse},
#endif
{"reuseport", opt_get_reuseport},
{"ip-multicast-if", opt_get_ip_multicast_if},
{"ip-multicast-loop", opt_get_ip_multicast_loop},