aboutsummaryrefslogtreecommitdiff
path: root/src/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/options.c')
-rw-r--r--src/options.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c
index 657947c..3856797 100644
--- a/src/options.c
+++ b/src/options.c
@@ -55,6 +55,33 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps)
55} 55}
56 56
57/*------------------------------------------------------*/ 57/*------------------------------------------------------*/
58/* binds socket to network interface */
59int opt_set_bindtodevice(lua_State *L, p_socket ps)
60{
61#ifdef __APPLE__
62 return luaL_error(L, "SO_BINDTODEVICE is not supported on this operating system");
63#else
64 const char *dev = luaL_checkstring(L, 3);
65 return opt_set(L, ps, SOL_SOCKET, SO_BINDTODEVICE, (char*)dev, strlen(dev)+1);
66#endif
67}
68
69int opt_get_bindtodevice(lua_State *L, p_socket ps)
70{
71#ifdef __APPLE__
72 return luaL_error(L, "SO_BINDTODEVICE is not supported on this operating system");
73#else
74 char dev[IFNAMSIZ];
75 int len = sizeof(dev);
76 int err = opt_get(L, ps, SOL_SOCKET, SO_BINDTODEVICE, &dev, &len);
77 if (err)
78 return err;
79 lua_pushstring(L, dev);
80 return 1;
81#endif
82}
83
84/*------------------------------------------------------*/
58/* enables reuse of local address */ 85/* enables reuse of local address */
59int opt_set_reuseaddr(lua_State *L, p_socket ps) 86int opt_set_reuseaddr(lua_State *L, p_socket ps)
60{ 87{