summaryrefslogtreecommitdiff
path: root/auto_tests/TCP_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-02-27 01:07:46 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-05-20 19:35:28 +0000
commit21675ce0d2581597b0e0a727ab4cf6cfb796a037 (patch)
treee1ac4ca63c5cc2b2dc78fcd5b20a8202eab98d9d /auto_tests/TCP_test.c
parent4f6ab0708c85f3e3da7726f6caecc381c6d21370 (diff)
Finish @Diadlo's network Family abstraction.
The Family stuff in toxcore is a big mess. I'm sure I saw a bunch of bugs on the way, but I'm not verifying that code now, so the bugs stay.
Diffstat (limited to 'auto_tests/TCP_test.c')
-rw-r--r--auto_tests/TCP_test.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index 41125116..8b61c4b1 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -29,18 +29,17 @@
29#endif 29#endif
30 30
31#if !USE_IPV6 31#if !USE_IPV6
32#undef TOX_AF_INET6 32#define net_family_ipv6 net_family_ipv4
33#define TOX_AF_INET6 TOX_AF_INET
34#endif 33#endif
35 34
36static inline IP get_loopback() 35static inline IP get_loopback()
37{ 36{
38 IP ip; 37 IP ip;
39#if USE_IPV6 38#if USE_IPV6
40 ip.family = TOX_AF_INET6; 39 ip.family = net_family_ipv6;
41 ip.ip.v6 = get_ip6_loopback(); 40 ip.ip.v6 = get_ip6_loopback();
42#else 41#else
43 ip.family = TOX_AF_INET; 42 ip.family = net_family_ipv4;
44 ip.ip.v4 = get_ip4_loopback(); 43 ip.ip.v4 = get_ip4_loopback();
45#endif 44#endif
46 return ip; 45 return ip;
@@ -57,7 +56,7 @@ START_TEST(test_basic)
57 ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server"); 56 ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server");
58 ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports"); 57 ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports");
59 58
60 Socket sock = net_socket(TOX_AF_INET6, TOX_SOCK_STREAM, TOX_PROTO_TCP); 59 Socket sock = net_socket(net_family_ipv6, TOX_SOCK_STREAM, TOX_PROTO_TCP);
61 IP_Port ip_port_loopback; 60 IP_Port ip_port_loopback;
62 ip_port_loopback.ip = get_loopback(); 61 ip_port_loopback.ip = get_loopback();
63 ip_port_loopback.port = net_htons(ports[random_u32() % NUM_PORTS]); 62 ip_port_loopback.port = net_htons(ports[random_u32() % NUM_PORTS]);
@@ -157,7 +156,7 @@ struct sec_TCP_con {
157static struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s) 156static struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s)
158{ 157{
159 struct sec_TCP_con *sec_c = (struct sec_TCP_con *)malloc(sizeof(struct sec_TCP_con)); 158 struct sec_TCP_con *sec_c = (struct sec_TCP_con *)malloc(sizeof(struct sec_TCP_con));
160 Socket sock = net_socket(TOX_AF_INET6, TOX_SOCK_STREAM, TOX_PROTO_TCP); 159 Socket sock = net_socket(net_family_ipv6, TOX_SOCK_STREAM, TOX_PROTO_TCP);
161 160
162 IP_Port ip_port_loopback; 161 IP_Port ip_port_loopback;
163 ip_port_loopback.ip = get_loopback(); 162 ip_port_loopback.ip = get_loopback();