diff options
| author | Kim Alvefur <zash@zash.se> | 2022-07-27 08:16:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-27 09:16:43 +0300 |
| commit | 0c7df119c2b71bed814db7b3da8fc379131433fe (patch) | |
| tree | 56b715e6010d291bd97de35744716f41ebadce19 /src | |
| parent | cff09ffb326237fd2edd848b6911521fe3e3d3fc (diff) | |
| download | luasocket-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.c | 16 | ||||
| -rw-r--r-- | src/options.h | 7 | ||||
| -rw-r--r-- | src/tcp.c | 6 |
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 | ||
| 196 | int 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 | ||
| 203 | int 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 | /*------------------------------------------------------*/ |
| 194 | int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps) | 210 | int 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); | |||
| 64 | int opt_set_send_buf_size(lua_State *L, p_socket ps); | 64 | int opt_set_send_buf_size(lua_State *L, p_socket ps); |
| 65 | int opt_get_send_buf_size(lua_State *L, p_socket ps); | 65 | int opt_get_send_buf_size(lua_State *L, p_socket ps); |
| 66 | 66 | ||
| 67 | #ifdef TCP_FASTOPEN | ||
| 68 | int opt_set_tcp_fastopen(lua_State *L, p_socket ps); | ||
| 69 | #endif | ||
| 70 | #ifdef TCP_FASTOPEN_CONNECT | ||
| 71 | int opt_set_tcp_fastopen_connect(lua_State *L, p_socket ps); | ||
| 72 | #endif | ||
| 73 | |||
| 67 | int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps); | 74 | int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps); |
| 68 | int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); | 75 | int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); |
| 69 | 76 | ||
| @@ -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 | ||
