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 */
15typedef struct t_opt {
16 const char *name;
17 int (*func)(lua_State *L, p_socket ps);
18} t_opt;
19typedef t_opt *p_opt;
20
21/* supported options for setoption */
22int opt_set_dontroute(lua_State *L, p_socket ps);
23int opt_set_broadcast(lua_State *L, p_socket ps);
24int opt_set_tcp_nodelay(lua_State *L, p_socket ps);
25int opt_set_keepalive(lua_State *L, p_socket ps);
26int opt_set_linger(lua_State *L, p_socket ps);
27int opt_set_reuseaddr(lua_State *L, p_socket ps);
28int opt_set_reuseport(lua_State *L, p_socket ps);
29int opt_set_ip_multicast_if(lua_State *L, p_socket ps);
30int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps);
31int opt_set_ip_multicast_loop(lua_State *L, p_socket ps);
32int opt_set_ip_add_membership(lua_State *L, p_socket ps);
33int opt_set_ip_drop_membersip(lua_State *L, p_socket ps);
34int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps);
35int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps);
36int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps);
37int opt_set_ip6_add_membership(lua_State *L, p_socket ps);
38int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps);
39int opt_set_ip6_v6only(lua_State *L, p_socket ps);
40
41/* supported options for getoption */
42int opt_get_dontroute(lua_State *L, p_socket ps);
43int opt_get_broadcast(lua_State *L, p_socket ps);
44int opt_get_reuseaddr(lua_State *L, p_socket ps);
45int opt_get_reuseport(lua_State *L, p_socket ps);
46int opt_get_tcp_nodelay(lua_State *L, p_socket ps);
47int opt_get_keepalive(lua_State *L, p_socket ps);
48int opt_get_linger(lua_State *L, p_socket ps);
49int opt_get_ip_multicast_loop(lua_State *L, p_socket ps);
50int opt_get_ip_multicast_if(lua_State *L, p_socket ps);
51int opt_get_error(lua_State *L, p_socket ps);
52int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps);
53int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps);
54int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
55int opt_get_ip6_v6only(lua_State *L, p_socket ps);
56int opt_get_reuseport(lua_State *L, p_socket ps);
57
58/* invokes the appropriate option handler */
59int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps);
60int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps);
61
62#endif
63