diff options
| author | Stefan Metzmacher <metze@samba.org> | 2020-06-19 21:07:09 +0000 |
|---|---|---|
| committer | Stefan Metzmacher <metze@samba.org> | 2020-06-19 21:07:09 +0000 |
| commit | f4fc52be79edc74bd24b3ee968c5358af81b17bd (patch) | |
| tree | b9004de1af9a4e645da631f6ebf905967207d9c6 /tests/echo_srv.c | |
| parent | bbc1d654cae9197fa3782e8ea8e1aaa9fdf0cfb0 (diff) | |
| parent | f317ebcdcdd626ed9e06de2eb60031306994c803 (diff) | |
| download | socket_wrapper-f4fc52be79edc74bd24b3ee968c5358af81b17bd.tar.gz socket_wrapper-f4fc52be79edc74bd24b3ee968c5358af81b17bd.tar.xz socket_wrapper-f4fc52be79edc74bd24b3ee968c5358af81b17bd.zip | |
Merge branch 'tcp_info' into 'master'
Add support for TCP_INFO and SIOCOUTQ/TIOCOUTQ/FIONWRITE
See merge request cwrap/socket_wrapper!11
Diffstat (limited to 'tests/echo_srv.c')
| -rw-r--r-- | tests/echo_srv.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/echo_srv.c b/tests/echo_srv.c index 93778f2..87c85f7 100644 --- a/tests/echo_srv.c +++ b/tests/echo_srv.c @@ -9,6 +9,10 @@ #include <arpa/inet.h> #include <netinet/in.h> +#include <netinet/tcp.h> +#ifdef HAVE_NETINET_TCP_FSM_H +#include <netinet/tcp_fsm.h> +#endif #include <netdb.h> #include <resolv.h> @@ -315,6 +319,34 @@ static int setup_srv(struct echo_srv_opts *opts, int *_sock) perror("listen"); return ret; } +#ifdef TCP_INFO + { + struct tcp_info info; + socklen_t optlen = sizeof(info); + + ZERO_STRUCT(info); + ret = getsockopt(sock, IPPROTO_TCP, TCP_INFO, &info, &optlen); + if (ret == -1) { + ret = errno; + perror("TCP_INFO failed"); + close(sock); + return ret; + } +#ifdef HAVE_NETINET_TCP_FSM_H +/* This is FreeBSD */ +# define __TCP_LISTEN TCPS_LISTEN +#else +/* This is Linux */ +# define __TCP_LISTEN TCP_LISTEN +#endif + if (info.tcpi_state != __TCP_LISTEN) { + errno = ret = ERANGE; + perror("not __TCP_LISTEN => ERANGE..."); + close(sock); + return ret; + } + } +#endif /* TCP_INFO */ } *_sock = sock; |
