Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for SO_EXCLUSIVEADDRUSE in Windows #449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions src/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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},
Expand Down
Loading