aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-07-27 08:16:43 +0200
committerGitHub <noreply@github.com>2022-07-27 09:16:43 +0300
commit0c7df119c2b71bed814db7b3da8fc379131433fe (patch)
tree56b715e6010d291bd97de35744716f41ebadce19 /src
parentcff09ffb326237fd2edd848b6911521fe3e3d3fc (diff)
downloadluasocket-0c7df119c2b71bed814db7b3da8fc379131433fe.tar.gz
luasocket-0c7df119c2b71bed814db7b3da8fc379131433fe.tar.bz2
luasocket-0c7df119c2b71bed814db7b3da8fc379131433fe.zip
feat(tcp): Add support for TCP Fast Open
Diffstat (limited to 'src')
-rw-r--r--src/options.c16
-rw-r--r--src/options.h7
-rw-r--r--src/tcp.c6
3 files changed, 29 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c
index 2b53c67..51ea351 100644
--- a/src/options.c
+++ b/src/options.c
@@ -190,6 +190,22 @@ int opt_set_send_buf_size(lua_State *L, p_socket ps)
190 return opt_setint(L, ps, SOL_SOCKET, SO_SNDBUF); 190 return opt_setint(L, ps, SOL_SOCKET, SO_SNDBUF);
191} 191}
192 192
193// /*------------------------------------------------------*/
194
195#ifdef TCP_FASTOPEN
196int opt_set_tcp_fastopen(lua_State *L, p_socket ps)
197{
198 return opt_setint(L, ps, IPPROTO_TCP, TCP_FASTOPEN);
199}
200#endif
201
202#ifdef TCP_FASTOPEN_CONNECT
203int opt_set_tcp_fastopen_connect(lua_State *L, p_socket ps)
204{
205 return opt_setint(L, ps, IPPROTO_TCP, TCP_FASTOPEN_CONNECT);
206}
207#endif
208
193/*------------------------------------------------------*/ 209/*------------------------------------------------------*/
194int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps) 210int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps)
195{ 211{
diff --git a/src/options.h b/src/options.h
index 41f7337..a4d5d75 100644
--- a/src/options.h
+++ b/src/options.h
@@ -64,6 +64,13 @@ int opt_get_recv_buf_size(lua_State *L, p_socket ps);
64int opt_set_send_buf_size(lua_State *L, p_socket ps); 64int opt_set_send_buf_size(lua_State *L, p_socket ps);
65int opt_get_send_buf_size(lua_State *L, p_socket ps); 65int opt_get_send_buf_size(lua_State *L, p_socket ps);
66 66
67#ifdef TCP_FASTOPEN
68int opt_set_tcp_fastopen(lua_State *L, p_socket ps);
69#endif
70#ifdef TCP_FASTOPEN_CONNECT
71int opt_set_tcp_fastopen_connect(lua_State *L, p_socket ps);
72#endif
73
67int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps); 74int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps);
68int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); 75int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
69 76
diff --git a/src/tcp.c b/src/tcp.c
index 5876bfb..e24cb0c 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -109,6 +109,12 @@ static t_opt optset[] = {
109 {"linger", opt_set_linger}, 109 {"linger", opt_set_linger},
110 {"recv-buffer-size", opt_set_recv_buf_size}, 110 {"recv-buffer-size", opt_set_recv_buf_size},
111 {"send-buffer-size", opt_set_send_buf_size}, 111 {"send-buffer-size", opt_set_send_buf_size},
112#ifdef TCP_FASTOPEN
113 {"tcp-fastopen", opt_set_tcp_fastopen},
114#endif
115#ifdef TCP_FASTOPEN_CONNECT
116 {"tcp-fastopen-connect", opt_set_tcp_fastopen_connect},
117#endif
112 {NULL, NULL} 118 {NULL, NULL}
113}; 119};
114 120