diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-02-14 20:51:55 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-02-14 20:51:55 +0000 |
commit | 35f13ef51dbf99c3d45d04f572e9e88795df7ae6 (patch) | |
tree | 8213605775c5f749fdabe683fbdea9106a6c32c1 /auto_tests | |
parent | 17a0b617f299c34563960bd4e9ed9a88e76ba92f (diff) |
Get rid of the only GNU extension we used.
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/TCP_test.c | 4 | ||||
-rw-r--r-- | auto_tests/dht_test.c | 14 | ||||
-rw-r--r-- | auto_tests/network_test.c | 30 | ||||
-rw-r--r-- | auto_tests/onion_test.c | 6 |
4 files changed, 27 insertions, 27 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 26a95942..2ae94618 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -39,10 +39,10 @@ static inline IP get_loopback() | |||
39 | IP ip; | 39 | IP ip; |
40 | #if USE_IPV6 | 40 | #if USE_IPV6 |
41 | ip.family = TOX_AF_INET6; | 41 | ip.family = TOX_AF_INET6; |
42 | ip.ip6 = get_ip6_loopback(); | 42 | ip.ip.v6 = get_ip6_loopback(); |
43 | #else | 43 | #else |
44 | ip.family = TOX_AF_INET; | 44 | ip.family = TOX_AF_INET; |
45 | ip.ip4 = get_ip4_loopback(); | 45 | ip.ip.v4 = get_ip4_loopback(); |
46 | #endif | 46 | #endif |
47 | return ip; | 47 | return ip; |
48 | } | 48 | } |
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 8e735dbd..10c9c7bf 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -38,10 +38,10 @@ static inline IP get_loopback() | |||
38 | IP ip; | 38 | IP ip; |
39 | #if USE_IPV6 | 39 | #if USE_IPV6 |
40 | ip.family = TOX_AF_INET6; | 40 | ip.family = TOX_AF_INET6; |
41 | ip.ip6 = get_ip6_loopback(); | 41 | ip.ip.v6 = get_ip6_loopback(); |
42 | #else | 42 | #else |
43 | ip.family = TOX_AF_INET; | 43 | ip.family = TOX_AF_INET; |
44 | ip.ip4 = get_ip4_loopback(); | 44 | ip.ip.v4 = get_ip4_loopback(); |
45 | #endif | 45 | #endif |
46 | return ip; | 46 | return ip; |
47 | } | 47 | } |
@@ -489,7 +489,7 @@ static void test_list_main(void) | |||
489 | 489 | ||
490 | IP_Port ip_port; | 490 | IP_Port ip_port; |
491 | ip_init(&ip_port.ip, 0); | 491 | ip_init(&ip_port.ip, 0); |
492 | ip_port.ip.ip4.uint32 = rand(); | 492 | ip_port.ip.ip.v4.uint32 = rand(); |
493 | ip_port.port = rand() % (UINT16_MAX - 1); | 493 | ip_port.port = rand() % (UINT16_MAX - 1); |
494 | ++ip_port.port; | 494 | ++ip_port.port; |
495 | addto_lists(dhts[j], ip_port, dhts[i]->self_public_key); | 495 | addto_lists(dhts[j], ip_port, dhts[i]->self_public_key); |
@@ -723,11 +723,11 @@ static void random_ip(IP_Port *ipp, int family) | |||
723 | size_t size; | 723 | size_t size; |
724 | 724 | ||
725 | if (family == TOX_AF_INET || family == TCP_INET) { | 725 | if (family == TOX_AF_INET || family == TCP_INET) { |
726 | ip = (uint8_t *)&ipp->ip.ip4; | 726 | ip = (uint8_t *)&ipp->ip.ip.v4; |
727 | size = sizeof(ipp->ip.ip4); | 727 | size = sizeof(ipp->ip.ip.v4); |
728 | } else if (family == TOX_AF_INET6 || family == TCP_INET6) { | 728 | } else if (family == TOX_AF_INET6 || family == TCP_INET6) { |
729 | ip = (uint8_t *)&ipp->ip.ip6; | 729 | ip = (uint8_t *)&ipp->ip.ip.v6; |
730 | size = sizeof(ipp->ip.ip6); | 730 | size = sizeof(ipp->ip.ip.v6); |
731 | } else { | 731 | } else { |
732 | return; | 732 | return; |
733 | } | 733 | } |
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c index 1885c81f..f05f0dbd 100644 --- a/auto_tests/network_test.c +++ b/auto_tests/network_test.c | |||
@@ -43,7 +43,7 @@ START_TEST(test_addr_resolv_localhost) | |||
43 | char ip_str[IP_NTOA_LEN]; | 43 | char ip_str[IP_NTOA_LEN]; |
44 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); | 44 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); |
45 | const uint32_t loopback = get_ip4_loopback().uint32; | 45 | const uint32_t loopback = get_ip4_loopback().uint32; |
46 | ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", | 46 | ck_assert_msg(ip.ip.v4.uint32 == loopback, "Expected 127.0.0.1, got %s.", |
47 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 47 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
48 | 48 | ||
49 | ip_init(&ip, 1); // ipv6enabled = 1 | 49 | ip_init(&ip, 1); // ipv6enabled = 1 |
@@ -58,7 +58,7 @@ START_TEST(test_addr_resolv_localhost) | |||
58 | 58 | ||
59 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); | 59 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); |
60 | IP6 ip6_loopback = get_ip6_loopback(); | 60 | IP6 ip6_loopback = get_ip6_loopback(); |
61 | ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", | 61 | ck_assert_msg(!memcmp(&ip.ip.v6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", |
62 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 62 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
63 | 63 | ||
64 | if (localhost_split) { | 64 | if (localhost_split) { |
@@ -75,15 +75,15 @@ START_TEST(test_addr_resolv_localhost) | |||
75 | 75 | ||
76 | #if USE_IPV6 | 76 | #if USE_IPV6 |
77 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); | 77 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); |
78 | ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", | 78 | ck_assert_msg(!memcmp(&ip.ip.v6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", |
79 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 79 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
80 | 80 | ||
81 | ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); | 81 | ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); |
82 | ck_assert_msg(extra.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", | 82 | ck_assert_msg(extra.ip.v4.uint32 == loopback, "Expected 127.0.0.1, got %s.", |
83 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 83 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
84 | #else | 84 | #else |
85 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, ip.family); | 85 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, ip.family); |
86 | ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", | 86 | ck_assert_msg(ip.ip.v4.uint32 == loopback, "Expected 127.0.0.1, got %s.", |
87 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 87 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
@@ -106,32 +106,32 @@ START_TEST(test_ip_equal) | |||
106 | ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %u.", res); | 106 | ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %u.", res); |
107 | 107 | ||
108 | ip1.family = TOX_AF_INET; | 108 | ip1.family = TOX_AF_INET; |
109 | ip1.ip4.uint32 = net_htonl(0x7F000001); | 109 | ip1.ip.v4.uint32 = net_htonl(0x7F000001); |
110 | 110 | ||
111 | res = ip_equal(&ip1, &ip2); | 111 | res = ip_equal(&ip1, &ip2); |
112 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_UNSPEC, 0} ): " | 112 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_UNSPEC, 0} ): " |
113 | "expected result 0, got %u.", res); | 113 | "expected result 0, got %u.", res); |
114 | 114 | ||
115 | ip2.family = TOX_AF_INET; | 115 | ip2.family = TOX_AF_INET; |
116 | ip2.ip4.uint32 = net_htonl(0x7F000001); | 116 | ip2.ip.v4.uint32 = net_htonl(0x7F000001); |
117 | 117 | ||
118 | res = ip_equal(&ip1, &ip2); | 118 | res = ip_equal(&ip1, &ip2); |
119 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.1} ): " | 119 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.1} ): " |
120 | "expected result != 0, got 0."); | 120 | "expected result != 0, got 0."); |
121 | 121 | ||
122 | ip2.ip4.uint32 = net_htonl(0x7F000002); | 122 | ip2.ip.v4.uint32 = net_htonl(0x7F000002); |
123 | 123 | ||
124 | res = ip_equal(&ip1, &ip2); | 124 | res = ip_equal(&ip1, &ip2); |
125 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.2} ): " | 125 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.2} ): " |
126 | "expected result 0, got %u.", res); | 126 | "expected result 0, got %u.", res); |
127 | 127 | ||
128 | ip2.family = TOX_AF_INET6; | 128 | ip2.family = TOX_AF_INET6; |
129 | ip2.ip6.uint32[0] = 0; | 129 | ip2.ip.v6.uint32[0] = 0; |
130 | ip2.ip6.uint32[1] = 0; | 130 | ip2.ip.v6.uint32[1] = 0; |
131 | ip2.ip6.uint32[2] = net_htonl(0xFFFF); | 131 | ip2.ip.v6.uint32[2] = net_htonl(0xFFFF); |
132 | ip2.ip6.uint32[3] = net_htonl(0x7F000001); | 132 | ip2.ip.v6.uint32[3] = net_htonl(0x7F000001); |
133 | 133 | ||
134 | ck_assert_msg(IPV6_IPV4_IN_V6(ip2.ip6) != 0, | 134 | ck_assert_msg(IPV6_IPV4_IN_V6(ip2.ip.v6) != 0, |
135 | "IPV6_IPV4_IN_V6(::ffff:127.0.0.1): expected != 0, got 0."); | 135 | "IPV6_IPV4_IN_V6(::ffff:127.0.0.1): expected != 0, got 0."); |
136 | 136 | ||
137 | res = ip_equal(&ip1, &ip2); | 137 | res = ip_equal(&ip1, &ip2); |
@@ -139,7 +139,7 @@ START_TEST(test_ip_equal) | |||
139 | "expected result != 0, got 0."); | 139 | "expected result != 0, got 0."); |
140 | 140 | ||
141 | IP6 ip6_loopback = get_ip6_loopback(); | 141 | IP6 ip6_loopback = get_ip6_loopback(); |
142 | memcpy(&ip2.ip6, &ip6_loopback, sizeof(IP6)); | 142 | memcpy(&ip2.ip.v6, &ip6_loopback, sizeof(IP6)); |
143 | res = ip_equal(&ip1, &ip2); | 143 | res = ip_equal(&ip1, &ip2); |
144 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); | 144 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); |
145 | 145 | ||
@@ -147,7 +147,7 @@ START_TEST(test_ip_equal) | |||
147 | res = ip_equal(&ip1, &ip2); | 147 | res = ip_equal(&ip1, &ip2); |
148 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::1} ): expected result != 0, got 0."); | 148 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::1} ): expected result != 0, got 0."); |
149 | 149 | ||
150 | ip2.ip6.uint8[15]++; | 150 | ip2.ip.v6.uint8[15]++; |
151 | res = ip_equal(&ip1, &ip2); | 151 | res = ip_equal(&ip1, &ip2); |
152 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::2} ): expected result 0, got %u.", res); | 152 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::2} ): expected result 0, got %u.", res); |
153 | } | 153 | } |
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 5989df17..aa505a0b 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -30,10 +30,10 @@ static inline IP get_loopback() | |||
30 | IP ip; | 30 | IP ip; |
31 | #if USE_IPV6 | 31 | #if USE_IPV6 |
32 | ip.family = TOX_AF_INET6; | 32 | ip.family = TOX_AF_INET6; |
33 | ip.ip6 = get_ip6_loopback(); | 33 | ip.ip.v6 = get_ip6_loopback(); |
34 | #else | 34 | #else |
35 | ip.family = TOX_AF_INET; | 35 | ip.family = TOX_AF_INET; |
36 | ip.ip4 = get_ip4_loopback(); | 36 | ip.ip.v4 = get_ip4_loopback(); |
37 | #endif | 37 | #endif |
38 | return ip; | 38 | return ip; |
39 | } | 39 | } |
@@ -308,7 +308,7 @@ typedef struct { | |||
308 | static Onions *new_onions(uint16_t port) | 308 | static Onions *new_onions(uint16_t port) |
309 | { | 309 | { |
310 | IP ip = get_loopback(); | 310 | IP ip = get_loopback(); |
311 | ip.ip6.uint8[15] = 1; | 311 | ip.ip.v6.uint8[15] = 1; |
312 | Onions *on = (Onions *)malloc(sizeof(Onions)); | 312 | Onions *on = (Onions *)malloc(sizeof(Onions)); |
313 | 313 | ||
314 | if (!on) { | 314 | if (!on) { |