diff options
-rw-r--r-- | tests/echo_srv.c | 32 | ||||
-rw-r--r-- | tests/test_echo_tcp_socket_options.c | 50 |
2 files changed, 0 insertions, 82 deletions
diff --git a/tests/echo_srv.c b/tests/echo_srv.c index 87c85f7..93778f2 100644 --- a/tests/echo_srv.c +++ b/tests/echo_srv.c @@ -9,10 +9,6 @@ #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> @@ -319,34 +315,6 @@ 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; diff --git a/tests/test_echo_tcp_socket_options.c b/tests/test_echo_tcp_socket_options.c index 5e5661d..dfa46fe 100644 --- a/tests/test_echo_tcp_socket_options.c +++ b/tests/test_echo_tcp_socket_options.c @@ -11,25 +11,12 @@ #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> -#ifdef HAVE_NETINET_TCP_FSM_H -#include <netinet/tcp_fsm.h> -#endif #include <arpa/inet.h> #include <netdb.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> -#ifdef HAVE_NETINET_TCP_FSM_H -/* This is FreeBSD */ -# define __TCP_ESTABLISHED TCPS_ESTABLISHED -# define __TCP_CLOSE TCPS_CLOSED -#else -/* This is Linux */ -# define __TCP_ESTABLISHED TCP_ESTABLISHED -# define __TCP_CLOSE TCP_CLOSE -#endif - #ifndef ZERO_STRUCT #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) #endif @@ -313,9 +300,6 @@ static void test_sockopt_tcp(void **state) .sa_socklen = sizeof(struct sockaddr_in), }; int opt = -1; -#ifdef TCP_INFO - struct tcp_info info; -#endif socklen_t optlen = sizeof(int); int rc; @@ -334,27 +318,9 @@ static void test_sockopt_tcp(void **state) &addr.sa.in.sin_addr); assert_int_equal(rc, 1); -#ifdef TCP_INFO - ZERO_STRUCT(info); - optlen = sizeof(info); - rc = getsockopt(s, IPPROTO_TCP, TCP_INFO, &info, &optlen); - assert_return_code(rc, errno); - assert_int_equal(optlen, sizeof(info)); - printf("info.tcpi_state=0x%x\n", info.tcpi_state); - printf("info.tcpi_rto=%u\n", info.tcpi_rto); - printf("info.tcpi_rtt=%u\n", info.tcpi_rtt); - printf("info.tcpi_rttvar=%u\n", info.tcpi_rttvar); - assert_int_equal(info.tcpi_state, __TCP_CLOSE); - assert_int_not_equal(info.tcpi_rto, 0); - assert_int_equal(info.tcpi_rtt, 0); - assert_int_not_equal(info.tcpi_rttvar, 0); -#endif /* TCP_INFO */ - rc = connect(s, &addr.sa.s, addr.sa_socklen); assert_int_equal(rc, 0); - opt = -1; - optlen = sizeof(int); rc = getsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, &optlen); assert_return_code(rc, errno); assert_int_equal(opt, 0); @@ -370,22 +336,6 @@ static void test_sockopt_tcp(void **state) assert_return_code(rc, errno); assert_int_equal(opt, 1); -#ifdef TCP_INFO - ZERO_STRUCT(info); - optlen = sizeof(info); - rc = getsockopt(s, IPPROTO_TCP, TCP_INFO, &info, &optlen); - assert_return_code(rc, errno); - assert_int_equal(optlen, sizeof(info)); - printf("info.tcpi_state=0x%x\n", info.tcpi_state); - printf("info.tcpi_rto=%u\n", info.tcpi_rto); - printf("info.tcpi_rtt=%u\n", info.tcpi_rtt); - printf("info.tcpi_rttvar=%u\n", info.tcpi_rttvar); - assert_int_equal(info.tcpi_state, __TCP_ESTABLISHED); - assert_int_not_equal(info.tcpi_rto, 0); - assert_int_not_equal(info.tcpi_rtt, 0); - assert_int_not_equal(info.tcpi_rttvar, 0); -#endif /* TCP_INFO */ - close(s); } |