1 | #ifndef OPTIONS_H |
2 | #define OPTIONS_H |
3 | /*=========================================================================*\ |
4 | * Common option interface |
5 | * LuaSocket toolkit |
6 | * |
7 | * This module provides a common interface to socket options, used mainly by |
8 | * modules UDP and TCP. |
9 | \*=========================================================================*/ |
10 | |
11 | #include "lua.h" |
12 | #include "socket.h" |
13 | |
14 | /* option registry */ |
15 | typedef struct t_opt { |
16 | const char *name; |
17 | int (*func)(lua_State *L, p_socket ps); |
18 | } t_opt; |
19 | typedef t_opt *p_opt; |
20 | |
21 | /* supported options for setoption */ |
22 | int opt_set_dontroute(lua_State *L, p_socket ps); |
23 | int opt_set_broadcast(lua_State *L, p_socket ps); |
24 | int opt_set_tcp_nodelay(lua_State *L, p_socket ps); |
25 | int opt_set_keepalive(lua_State *L, p_socket ps); |
26 | int opt_set_linger(lua_State *L, p_socket ps); |
27 | int opt_set_reuseaddr(lua_State *L, p_socket ps); |
28 | int opt_set_reuseport(lua_State *L, p_socket ps); |
29 | int opt_set_ip_multicast_if(lua_State *L, p_socket ps); |
30 | int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps); |
31 | int opt_set_ip_multicast_loop(lua_State *L, p_socket ps); |
32 | int opt_set_ip_add_membership(lua_State *L, p_socket ps); |
33 | int opt_set_ip_drop_membersip(lua_State *L, p_socket ps); |
34 | int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps); |
35 | int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps); |
36 | int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps); |
37 | int opt_set_ip6_add_membership(lua_State *L, p_socket ps); |
38 | int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps); |
39 | int opt_set_ip6_v6only(lua_State *L, p_socket ps); |
40 | |
41 | /* supported options for getoption */ |
42 | int opt_get_dontroute(lua_State *L, p_socket ps); |
43 | int opt_get_broadcast(lua_State *L, p_socket ps); |
44 | int opt_get_reuseaddr(lua_State *L, p_socket ps); |
45 | int opt_get_reuseport(lua_State *L, p_socket ps); |
46 | int opt_get_tcp_nodelay(lua_State *L, p_socket ps); |
47 | int opt_get_keepalive(lua_State *L, p_socket ps); |
48 | int opt_get_linger(lua_State *L, p_socket ps); |
49 | int opt_get_ip_multicast_loop(lua_State *L, p_socket ps); |
50 | int opt_get_ip_multicast_if(lua_State *L, p_socket ps); |
51 | int opt_get_error(lua_State *L, p_socket ps); |
52 | int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps); |
53 | int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps); |
54 | int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); |
55 | int opt_get_ip6_v6only(lua_State *L, p_socket ps); |
56 | int opt_get_reuseport(lua_State *L, p_socket ps); |
57 | |
58 | /* invokes the appropriate option handler */ |
59 | int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); |
60 | int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps); |
61 | |
62 | #endif |
63 | |