diff options
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/options.c b/src/options.c index 5236a3f..0f1ca2c 100644 --- a/src/options.c +++ b/src/options.c | |||
@@ -16,9 +16,9 @@ | |||
16 | /*=========================================================================*\ | 16 | /*=========================================================================*\ |
17 | * Internal functions prototypes | 17 | * Internal functions prototypes |
18 | \*=========================================================================*/ | 18 | \*=========================================================================*/ |
19 | static int opt_setmembership(lua_State *L, p_sock ps, int level, int name); | 19 | static int opt_setmembership(lua_State *L, p_socket ps, int level, int name); |
20 | static int opt_setboolean(lua_State *L, p_sock ps, int level, int name); | 20 | static int opt_setboolean(lua_State *L, p_socket ps, int level, int name); |
21 | static int opt_set(lua_State *L, p_sock ps, int level, int name, | 21 | static int opt_set(lua_State *L, p_socket ps, int level, int name, |
22 | void *val, int len); | 22 | void *val, int len); |
23 | 23 | ||
24 | /*=========================================================================*\ | 24 | /*=========================================================================*\ |
@@ -27,7 +27,7 @@ static int opt_set(lua_State *L, p_sock ps, int level, int name, | |||
27 | /*-------------------------------------------------------------------------*\ | 27 | /*-------------------------------------------------------------------------*\ |
28 | * Calls appropriate option handler | 28 | * Calls appropriate option handler |
29 | \*-------------------------------------------------------------------------*/ | 29 | \*-------------------------------------------------------------------------*/ |
30 | int opt_meth_setoption(lua_State *L, p_opt opt, p_sock ps) | 30 | int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps) |
31 | { | 31 | { |
32 | const char *name = luaL_checkstring(L, 2); /* obj, name, ... */ | 32 | const char *name = luaL_checkstring(L, 2); /* obj, name, ... */ |
33 | while (opt->name && strcmp(name, opt->name)) | 33 | while (opt->name && strcmp(name, opt->name)) |
@@ -41,38 +41,38 @@ int opt_meth_setoption(lua_State *L, p_opt opt, p_sock ps) | |||
41 | } | 41 | } |
42 | 42 | ||
43 | /* enables reuse of local address */ | 43 | /* enables reuse of local address */ |
44 | int opt_reuseaddr(lua_State *L, p_sock ps) | 44 | int opt_reuseaddr(lua_State *L, p_socket ps) |
45 | { | 45 | { |
46 | return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR); | 46 | return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR); |
47 | } | 47 | } |
48 | 48 | ||
49 | /* disables the Naggle algorithm */ | 49 | /* disables the Naggle algorithm */ |
50 | int opt_tcp_nodelay(lua_State *L, p_sock ps) | 50 | int opt_tcp_nodelay(lua_State *L, p_socket ps) |
51 | { | 51 | { |
52 | return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY); | 52 | return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY); |
53 | } | 53 | } |
54 | 54 | ||
55 | int opt_keepalive(lua_State *L, p_sock ps) | 55 | int opt_keepalive(lua_State *L, p_socket ps) |
56 | { | 56 | { |
57 | return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE); | 57 | return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE); |
58 | } | 58 | } |
59 | 59 | ||
60 | int opt_dontroute(lua_State *L, p_sock ps) | 60 | int opt_dontroute(lua_State *L, p_socket ps) |
61 | { | 61 | { |
62 | return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE); | 62 | return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE); |
63 | } | 63 | } |
64 | 64 | ||
65 | int opt_broadcast(lua_State *L, p_sock ps) | 65 | int opt_broadcast(lua_State *L, p_socket ps) |
66 | { | 66 | { |
67 | return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST); | 67 | return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST); |
68 | } | 68 | } |
69 | 69 | ||
70 | int opt_ip_multicast_loop(lua_State *L, p_sock ps) | 70 | int opt_ip_multicast_loop(lua_State *L, p_socket ps) |
71 | { | 71 | { |
72 | return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP); | 72 | return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP); |
73 | } | 73 | } |
74 | 74 | ||
75 | int opt_linger(lua_State *L, p_sock ps) | 75 | int opt_linger(lua_State *L, p_socket ps) |
76 | { | 76 | { |
77 | struct linger li; /* obj, name, table */ | 77 | struct linger li; /* obj, name, table */ |
78 | if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE)); | 78 | if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE)); |
@@ -89,18 +89,18 @@ int opt_linger(lua_State *L, p_sock ps) | |||
89 | return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li)); | 89 | return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li)); |
90 | } | 90 | } |
91 | 91 | ||
92 | int opt_ip_multicast_ttl(lua_State *L, p_sock ps) | 92 | int opt_ip_multicast_ttl(lua_State *L, p_socket ps) |
93 | { | 93 | { |
94 | int val = (int) luaL_checknumber(L, 3); /* obj, name, int */ | 94 | int val = (int) luaL_checknumber(L, 3); /* obj, name, int */ |
95 | return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &val, sizeof(val)); | 95 | return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &val, sizeof(val)); |
96 | } | 96 | } |
97 | 97 | ||
98 | int opt_ip_add_membership(lua_State *L, p_sock ps) | 98 | int opt_ip_add_membership(lua_State *L, p_socket ps) |
99 | { | 99 | { |
100 | return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP); | 100 | return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP); |
101 | } | 101 | } |
102 | 102 | ||
103 | int opt_ip_drop_membersip(lua_State *L, p_sock ps) | 103 | int opt_ip_drop_membersip(lua_State *L, p_socket ps) |
104 | { | 104 | { |
105 | return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP); | 105 | return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP); |
106 | } | 106 | } |
@@ -108,7 +108,7 @@ int opt_ip_drop_membersip(lua_State *L, p_sock ps) | |||
108 | /*=========================================================================*\ | 108 | /*=========================================================================*\ |
109 | * Auxiliar functions | 109 | * Auxiliar functions |
110 | \*=========================================================================*/ | 110 | \*=========================================================================*/ |
111 | static int opt_setmembership(lua_State *L, p_sock ps, int level, int name) | 111 | static int opt_setmembership(lua_State *L, p_socket ps, int level, int name) |
112 | { | 112 | { |
113 | struct ip_mreq val; /* obj, name, table */ | 113 | struct ip_mreq val; /* obj, name, table */ |
114 | if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE)); | 114 | if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE)); |
@@ -130,7 +130,7 @@ static int opt_setmembership(lua_State *L, p_sock ps, int level, int name) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | static | 132 | static |
133 | int opt_set(lua_State *L, p_sock ps, int level, int name, void *val, int len) | 133 | int opt_set(lua_State *L, p_socket ps, int level, int name, void *val, int len) |
134 | { | 134 | { |
135 | if (setsockopt(*ps, level, name, (char *) val, len) < 0) { | 135 | if (setsockopt(*ps, level, name, (char *) val, len) < 0) { |
136 | lua_pushnil(L); | 136 | lua_pushnil(L); |
@@ -141,9 +141,9 @@ int opt_set(lua_State *L, p_sock ps, int level, int name, void *val, int len) | |||
141 | return 1; | 141 | return 1; |
142 | } | 142 | } |
143 | 143 | ||
144 | static int opt_setboolean(lua_State *L, p_sock ps, int level, int name) | 144 | static int opt_setboolean(lua_State *L, p_socket ps, int level, int name) |
145 | { | 145 | { |
146 | int val = aux_checkboolean(L, 3); /* obj, name, bool */ | 146 | int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */ |
147 | return opt_set(L, ps, level, name, (char *) &val, sizeof(val)); | 147 | return opt_set(L, ps, level, name, (char *) &val, sizeof(val)); |
148 | } | 148 | } |
149 | 149 | ||