aboutsummaryrefslogtreecommitdiff
path: root/src/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udp.c')
-rw-r--r--src/udp.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/udp.c b/src/udp.c
index e604bea..db519ca 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -37,6 +37,7 @@ static int meth_setsockname(lua_State *L);
37static int meth_setpeername(lua_State *L); 37static int meth_setpeername(lua_State *L);
38static int meth_close(lua_State *L); 38static int meth_close(lua_State *L);
39static int meth_setoption(lua_State *L); 39static int meth_setoption(lua_State *L);
40static int meth_getoption(lua_State *L);
40static int meth_settimeout(lua_State *L); 41static int meth_settimeout(lua_State *L);
41static int meth_getfd(lua_State *L); 42static int meth_getfd(lua_State *L);
42static int meth_setfd(lua_State *L); 43static int meth_setfd(lua_State *L);
@@ -57,22 +58,32 @@ static luaL_reg udp[] = {
57 {"sendto", meth_sendto}, 58 {"sendto", meth_sendto},
58 {"setfd", meth_setfd}, 59 {"setfd", meth_setfd},
59 {"setoption", meth_setoption}, 60 {"setoption", meth_setoption},
61 {"getoption", meth_getoption},
60 {"setpeername", meth_setpeername}, 62 {"setpeername", meth_setpeername},
61 {"setsockname", meth_setsockname}, 63 {"setsockname", meth_setsockname},
62 {"settimeout", meth_settimeout}, 64 {"settimeout", meth_settimeout},
63 {NULL, NULL} 65 {NULL, NULL}
64}; 66};
65 67
66/* socket options */ 68/* socket options for setoption */
67static t_opt opt[] = { 69static t_opt optset[] = {
68 {"dontroute", opt_dontroute}, 70 {"dontroute", opt_set_dontroute},
69 {"broadcast", opt_broadcast}, 71 {"broadcast", opt_set_broadcast},
70 {"reuseaddr", opt_reuseaddr}, 72 {"reuseaddr", opt_set_reuseaddr},
71 {"ip-multicast-ttl", opt_ip_multicast_ttl}, 73 {"reuseport", opt_set_reuseport},
72 {"ip-multicast-loop", opt_ip_multicast_loop}, 74 {"ip-multicast-if", opt_set_ip_multicast_if},
73 {"ip-add-membership", opt_ip_add_membership}, 75 {"ip-multicast-ttl", opt_set_ip_multicast_ttl},
74 {"ip-drop-membership", opt_ip_drop_membersip}, 76 {"ip-multicast-loop", opt_set_ip_multicast_loop},
75 {NULL, NULL} 77 {"ip-add-membership", opt_set_ip_add_membership},
78 {"ip-drop-membership", opt_set_ip_drop_membersip},
79 {NULL, NULL}
80};
81
82/* socket options for getoption */
83static t_opt optget[] = {
84 {"ip-multicast-if", opt_get_ip_multicast_if},
85 {"ip-multicast-loop", opt_get_ip_multicast_loop},
86 {NULL, NULL}
76}; 87};
77 88
78/* functions in library namespace */ 89/* functions in library namespace */
@@ -247,7 +258,15 @@ static int meth_getsockname(lua_State *L) {
247\*-------------------------------------------------------------------------*/ 258\*-------------------------------------------------------------------------*/
248static int meth_setoption(lua_State *L) { 259static int meth_setoption(lua_State *L) {
249 p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); 260 p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
250 return opt_meth_setoption(L, opt, &udp->sock); 261 return opt_meth_setoption(L, optset, &udp->sock);
262}
263
264/*-------------------------------------------------------------------------*\
265* Just call option handler
266\*-------------------------------------------------------------------------*/
267static int meth_getoption(lua_State *L) {
268 p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
269 return opt_meth_getoption(L, optget, &udp->sock);
251} 270}
252 271
253/*-------------------------------------------------------------------------*\ 272/*-------------------------------------------------------------------------*\