diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | auto_tests/TCP_test.c | 24 | ||||
-rw-r--r-- | auto_tests/conference_test.c | 2 | ||||
-rw-r--r-- | auto_tests/tox_many_tcp_test.c | 1 | ||||
-rw-r--r-- | auto_tests/tox_many_test.c | 1 | ||||
-rw-r--r-- | auto_tests/tox_one_test.c | 1 | ||||
-rw-r--r-- | auto_tests/tox_test.c | 1 | ||||
-rw-r--r-- | cmake/ModulePackage.cmake | 11 | ||||
-rw-r--r-- | other/travis/env-windows.sh | 2 | ||||
-rw-r--r-- | testing/dns3_test.c | 4 | ||||
-rw-r--r-- | toxcore/LAN_discovery.c | 4 | ||||
-rw-r--r-- | toxcore/TCP_client.c | 8 | ||||
-rw-r--r-- | toxcore/TCP_server.c | 14 | ||||
-rw-r--r-- | toxcore/network.c | 16 |
14 files changed, 53 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5af6833e..7ec2b242 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -32,6 +32,7 @@ if(DEBUG) | |||
32 | check_c_compiler_flag("-g3" HAVE_G3) | 32 | check_c_compiler_flag("-g3" HAVE_G3) |
33 | if(HAVE_G3) | 33 | if(HAVE_G3) |
34 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") | 34 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") |
35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") | ||
35 | endif() | 36 | endif() |
36 | endif() | 37 | endif() |
37 | 38 | ||
@@ -56,6 +57,7 @@ if(ASAN) | |||
56 | check_c_compiler_flag("-fsanitize=address" HAVE_ASAN) | 57 | check_c_compiler_flag("-fsanitize=address" HAVE_ASAN) |
57 | if(HAVE_ASAN) | 58 | if(HAVE_ASAN) |
58 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") | 59 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") |
60 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") | ||
59 | endif() | 61 | endif() |
60 | set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") | 62 | set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") |
61 | endif() | 63 | endif() |
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 1442dcae..77327299 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -63,13 +63,14 @@ START_TEST(test_basic) | |||
63 | TCP_HANDSHAKE_PLAIN_SIZE, handshake + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES); | 63 | TCP_HANDSHAKE_PLAIN_SIZE, handshake + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES); |
64 | ck_assert_msg(ret == TCP_CLIENT_HANDSHAKE_SIZE - (crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES), | 64 | ck_assert_msg(ret == TCP_CLIENT_HANDSHAKE_SIZE - (crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES), |
65 | "Encrypt failed."); | 65 | "Encrypt failed."); |
66 | ck_assert_msg(send(sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, 0) == TCP_CLIENT_HANDSHAKE_SIZE - 1, "send Failed."); | 66 | ck_assert_msg(send(sock, (const char *)handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, 0) == TCP_CLIENT_HANDSHAKE_SIZE - 1, |
67 | "send Failed."); | ||
67 | c_sleep(50); | 68 | c_sleep(50); |
68 | do_TCP_server(tcp_s); | 69 | do_TCP_server(tcp_s); |
69 | c_sleep(50); | 70 | c_sleep(50); |
70 | do_TCP_server(tcp_s); | 71 | do_TCP_server(tcp_s); |
71 | c_sleep(50); | 72 | c_sleep(50); |
72 | ck_assert_msg(send(sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, 0) == 1, "send Failed."); | 73 | ck_assert_msg(send(sock, (const char *)(handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1)), 1, 0) == 1, "send Failed."); |
73 | c_sleep(50); | 74 | c_sleep(50); |
74 | do_TCP_server(tcp_s); | 75 | do_TCP_server(tcp_s); |
75 | c_sleep(50); | 76 | c_sleep(50); |
@@ -77,7 +78,7 @@ START_TEST(test_basic) | |||
77 | c_sleep(50); | 78 | c_sleep(50); |
78 | uint8_t response[TCP_SERVER_HANDSHAKE_SIZE]; | 79 | uint8_t response[TCP_SERVER_HANDSHAKE_SIZE]; |
79 | uint8_t response_plain[TCP_HANDSHAKE_PLAIN_SIZE]; | 80 | uint8_t response_plain[TCP_HANDSHAKE_PLAIN_SIZE]; |
80 | ck_assert_msg(recv(sock, response, TCP_SERVER_HANDSHAKE_SIZE, 0) == TCP_SERVER_HANDSHAKE_SIZE, "recv Failed."); | 81 | ck_assert_msg(recv(sock, (char *)response, TCP_SERVER_HANDSHAKE_SIZE, 0) == TCP_SERVER_HANDSHAKE_SIZE, "recv Failed."); |
81 | ret = decrypt_data(self_public_key, f_secret_key, response, response + crypto_box_NONCEBYTES, | 82 | ret = decrypt_data(self_public_key, f_secret_key, response, response + crypto_box_NONCEBYTES, |
82 | TCP_SERVER_HANDSHAKE_SIZE - crypto_box_NONCEBYTES, response_plain); | 83 | TCP_SERVER_HANDSHAKE_SIZE - crypto_box_NONCEBYTES, response_plain); |
83 | ck_assert_msg(ret == TCP_HANDSHAKE_PLAIN_SIZE, "Decrypt Failed."); | 84 | ck_assert_msg(ret == TCP_HANDSHAKE_PLAIN_SIZE, "Decrypt Failed."); |
@@ -97,8 +98,8 @@ START_TEST(test_basic) | |||
97 | uint32_t i; | 98 | uint32_t i; |
98 | 99 | ||
99 | for (i = 0; i < sizeof(r_req); ++i) { | 100 | for (i = 0; i < sizeof(r_req); ++i) { |
100 | ck_assert_msg(send(sock, r_req + i, 1, 0) == 1, "send Failed."); | 101 | ck_assert_msg(send(sock, (const char *)(r_req + i), 1, 0) == 1, "send Failed."); |
101 | //ck_assert_msg(send(sock, r_req, sizeof(r_req), 0) == sizeof(r_req), "send Failed."); | 102 | //ck_assert_msg(send(sock, (const char *)r_req, sizeof(r_req), 0) == sizeof(r_req), "send Failed."); |
102 | do_TCP_server(tcp_s); | 103 | do_TCP_server(tcp_s); |
103 | c_sleep(50); | 104 | c_sleep(50); |
104 | } | 105 | } |
@@ -106,7 +107,7 @@ START_TEST(test_basic) | |||
106 | do_TCP_server(tcp_s); | 107 | do_TCP_server(tcp_s); |
107 | c_sleep(50); | 108 | c_sleep(50); |
108 | uint8_t packet_resp[4096]; | 109 | uint8_t packet_resp[4096]; |
109 | int recv_data_len = recv(sock, packet_resp, 2 + 2 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES, 0); | 110 | int recv_data_len = recv(sock, (char *)packet_resp, 2 + 2 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES, 0); |
110 | ck_assert_msg(recv_data_len == 2 + 2 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES, | 111 | ck_assert_msg(recv_data_len == 2 + 2 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES, |
111 | "recv Failed. %u", recv_data_len); | 112 | "recv Failed. %u", recv_data_len); |
112 | memcpy(&size, packet_resp, 2); | 113 | memcpy(&size, packet_resp, 2); |
@@ -158,15 +159,16 @@ static struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s) | |||
158 | TCP_HANDSHAKE_PLAIN_SIZE, handshake + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES); | 159 | TCP_HANDSHAKE_PLAIN_SIZE, handshake + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES); |
159 | ck_assert_msg(ret == TCP_CLIENT_HANDSHAKE_SIZE - (crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES), | 160 | ck_assert_msg(ret == TCP_CLIENT_HANDSHAKE_SIZE - (crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES), |
160 | "Encrypt failed."); | 161 | "Encrypt failed."); |
161 | ck_assert_msg(send(sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, 0) == TCP_CLIENT_HANDSHAKE_SIZE - 1, "send Failed."); | 162 | ck_assert_msg(send(sock, (const char *)handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, 0) == TCP_CLIENT_HANDSHAKE_SIZE - 1, |
163 | "send Failed."); | ||
162 | do_TCP_server(tcp_s); | 164 | do_TCP_server(tcp_s); |
163 | c_sleep(50); | 165 | c_sleep(50); |
164 | ck_assert_msg(send(sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, 0) == 1, "send Failed."); | 166 | ck_assert_msg(send(sock, (const char *)(handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1)), 1, 0) == 1, "send Failed."); |
165 | c_sleep(50); | 167 | c_sleep(50); |
166 | do_TCP_server(tcp_s); | 168 | do_TCP_server(tcp_s); |
167 | uint8_t response[TCP_SERVER_HANDSHAKE_SIZE]; | 169 | uint8_t response[TCP_SERVER_HANDSHAKE_SIZE]; |
168 | uint8_t response_plain[TCP_HANDSHAKE_PLAIN_SIZE]; | 170 | uint8_t response_plain[TCP_HANDSHAKE_PLAIN_SIZE]; |
169 | ck_assert_msg(recv(sock, response, TCP_SERVER_HANDSHAKE_SIZE, 0) == TCP_SERVER_HANDSHAKE_SIZE, "recv Failed."); | 171 | ck_assert_msg(recv(sock, (char *)response, TCP_SERVER_HANDSHAKE_SIZE, 0) == TCP_SERVER_HANDSHAKE_SIZE, "recv Failed."); |
170 | ret = decrypt_data(tcp_server_public_key(tcp_s), f_secret_key, response, response + crypto_box_NONCEBYTES, | 172 | ret = decrypt_data(tcp_server_public_key(tcp_s), f_secret_key, response, response + crypto_box_NONCEBYTES, |
171 | TCP_SERVER_HANDSHAKE_SIZE - crypto_box_NONCEBYTES, response_plain); | 173 | TCP_SERVER_HANDSHAKE_SIZE - crypto_box_NONCEBYTES, response_plain); |
172 | ck_assert_msg(ret == TCP_HANDSHAKE_PLAIN_SIZE, "Decrypt Failed."); | 174 | ck_assert_msg(ret == TCP_HANDSHAKE_PLAIN_SIZE, "Decrypt Failed."); |
@@ -196,13 +198,13 @@ static int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t * | |||
196 | 198 | ||
197 | increment_nonce(con->sent_nonce); | 199 | increment_nonce(con->sent_nonce); |
198 | 200 | ||
199 | ck_assert_msg(send(con->sock, packet, sizeof(packet), 0) == sizeof(packet), "send failed"); | 201 | ck_assert_msg(send(con->sock, (const char *)packet, sizeof(packet), 0) == sizeof(packet), "send failed"); |
200 | return 0; | 202 | return 0; |
201 | } | 203 | } |
202 | 204 | ||
203 | static int read_packet_sec_TCP(struct sec_TCP_con *con, uint8_t *data, uint16_t length) | 205 | static int read_packet_sec_TCP(struct sec_TCP_con *con, uint8_t *data, uint16_t length) |
204 | { | 206 | { |
205 | int len = recv(con->sock, data, length, 0); | 207 | int len = recv(con->sock, (char *)data, length, 0); |
206 | ck_assert_msg(len == length, "wrong len %i\n", len); | 208 | ck_assert_msg(len == length, "wrong len %i\n", len); |
207 | len = decrypt_data_symmetric(con->shared_key, con->recv_nonce, data + 2, length - 2, data); | 209 | len = decrypt_data_symmetric(con->shared_key, con->recv_nonce, data + 2, length - 2, data); |
208 | ck_assert_msg(len != -1, "Decrypt failed"); | 210 | ck_assert_msg(len != -1, "Decrypt failed"); |
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index 0f1e2ca4..fba64bcc 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c | |||
@@ -6,10 +6,10 @@ | |||
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | #include <check.h> | 8 | #include <check.h> |
9 | #include <inttypes.h> | ||
9 | #include <stdio.h> | 10 | #include <stdio.h> |
10 | #include <stdlib.h> | 11 | #include <stdlib.h> |
11 | #include <time.h> | 12 | #include <time.h> |
12 | #include <inttypes.h> | ||
13 | 13 | ||
14 | #include "../toxcore/tox.h" | 14 | #include "../toxcore/tox.h" |
15 | #include "../toxcore/util.h" | 15 | #include "../toxcore/util.h" |
diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c index 146d4fd2..59d69c49 100644 --- a/auto_tests/tox_many_tcp_test.c +++ b/auto_tests/tox_many_tcp_test.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <check.h> | 8 | #include <check.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <time.h> | ||
11 | 12 | ||
12 | #include "../toxcore/tox.h" | 13 | #include "../toxcore/tox.h" |
13 | #include "../toxcore/util.h" | 14 | #include "../toxcore/util.h" |
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c index 656d1769..fa657580 100644 --- a/auto_tests/tox_many_test.c +++ b/auto_tests/tox_many_test.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <check.h> | 8 | #include <check.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <time.h> | ||
11 | 12 | ||
12 | #include "../toxcore/tox.h" | 13 | #include "../toxcore/tox.h" |
13 | #include "../toxcore/util.h" | 14 | #include "../toxcore/util.h" |
diff --git a/auto_tests/tox_one_test.c b/auto_tests/tox_one_test.c index 748d1224..1248de19 100644 --- a/auto_tests/tox_one_test.c +++ b/auto_tests/tox_one_test.c | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <check.h> | 8 | #include <check.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <time.h> | ||
10 | 11 | ||
11 | #include "../toxcore/tox.h" | 12 | #include "../toxcore/tox.h" |
12 | #include "../toxcore/util.h" | 13 | #include "../toxcore/util.h" |
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 53f94bc5..2706e564 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <check.h> | 17 | #include <check.h> |
18 | #include <stdio.h> | 18 | #include <stdio.h> |
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <time.h> | ||
20 | 21 | ||
21 | #include "../toxcore/tox.h" | 22 | #include "../toxcore/tox.h" |
22 | #include "../toxcore/util.h" | 23 | #include "../toxcore/util.h" |
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index fa3779c3..a556aef0 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake | |||
@@ -4,7 +4,12 @@ option(COMPILE_AS_CXX "Compile all C code as C++ code" OFF) | |||
4 | 4 | ||
5 | find_package(PkgConfig REQUIRED) | 5 | find_package(PkgConfig REQUIRED) |
6 | 6 | ||
7 | function(set_source_language) | 7 | if(COMPILE_AS_CXX) |
8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS=1") | ||
9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS=1") | ||
10 | endif() | ||
11 | |||
12 | macro(set_source_language) | ||
8 | if(COMPILE_AS_CXX) | 13 | if(COMPILE_AS_CXX) |
9 | foreach(srcfile ${ARGN}) | 14 | foreach(srcfile ${ARGN}) |
10 | get_filename_component(srcext ${srcfile} EXT) | 15 | get_filename_component(srcext ${srcfile} EXT) |
@@ -13,10 +18,11 @@ function(set_source_language) | |||
13 | endif() | 18 | endif() |
14 | endforeach() | 19 | endforeach() |
15 | endif() | 20 | endif() |
16 | endfunction() | 21 | endmacro() |
17 | 22 | ||
18 | function(add_c_executable exec) | 23 | function(add_c_executable exec) |
19 | set_source_language(${ARGN}) | 24 | set_source_language(${ARGN}) |
25 | |||
20 | add_executable(${exec} ${ARGN}) | 26 | add_executable(${exec} ${ARGN}) |
21 | endfunction() | 27 | endfunction() |
22 | 28 | ||
@@ -26,6 +32,7 @@ function(pkg_use_module mod) | |||
26 | link_directories(${${mod}_LIBRARY_DIRS}) | 32 | link_directories(${${mod}_LIBRARY_DIRS}) |
27 | include_directories(${${mod}_INCLUDE_DIRS}) | 33 | include_directories(${${mod}_INCLUDE_DIRS}) |
28 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}") | 34 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}") |
35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}") | ||
29 | endif() | 36 | endif() |
30 | endfunction() | 37 | endfunction() |
31 | 38 | ||
diff --git a/other/travis/env-windows.sh b/other/travis/env-windows.sh index 8c9b9c65..44f486af 100644 --- a/other/travis/env-windows.sh +++ b/other/travis/env-windows.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | CMAKE=$ARCH-w64-mingw32.shared-cmake | 3 | CMAKE=$ARCH-w64-mingw32.shared-cmake |
4 | CMAKE_EXTRA_FLAGS="-DBOOTSTRAP_DAEMON=OFF" | 4 | CMAKE_EXTRA_FLAGS="-DBOOTSTRAP_DAEMON=OFF -DCOMPILE_AS_CXX=ON" |
5 | NPROC=`nproc` | 5 | NPROC=`nproc` |
6 | CURDIR=/work | 6 | CURDIR=/work |
7 | 7 | ||
diff --git a/testing/dns3_test.c b/testing/dns3_test.c index 3151dd99..7356bc00 100644 --- a/testing/dns3_test.c +++ b/testing/dns3_test.c | |||
@@ -98,12 +98,12 @@ int main(int argc, char *argv[]) | |||
98 | uint8_t id = rand(); | 98 | uint8_t id = rand(); |
99 | uint32_t p_len = create_packet(packet, string, strlen((char *)string), id); | 99 | uint32_t p_len = create_packet(packet, string, strlen((char *)string), id); |
100 | 100 | ||
101 | if (sendto(sock, (char *) packet, p_len, 0, (struct sockaddr *)&target, addrsize) != p_len) { | 101 | if (sendto(sock, (char *)packet, p_len, 0, (struct sockaddr *)&target, addrsize) != p_len) { |
102 | return -1; | 102 | return -1; |
103 | } | 103 | } |
104 | 104 | ||
105 | uint8_t buffer[512] = {0}; | 105 | uint8_t buffer[512] = {0}; |
106 | int r_len = recv(sock, buffer, sizeof(buffer), 0); | 106 | int r_len = recv(sock, (char *)buffer, sizeof(buffer), 0); |
107 | 107 | ||
108 | if (r_len < (int)p_len) { | 108 | if (r_len < (int)p_len) { |
109 | return -1; | 109 | return -1; |
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index d2bfb4e1..48e0e7bb 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -50,7 +50,7 @@ static void fetch_broadcast_info(uint16_t port) | |||
50 | { | 50 | { |
51 | broadcast_count = 0; | 51 | broadcast_count = 0; |
52 | 52 | ||
53 | IP_ADAPTER_INFO *pAdapterInfo = malloc(sizeof(IP_ADAPTER_INFO)); | 53 | IP_ADAPTER_INFO *pAdapterInfo = (IP_ADAPTER_INFO *)malloc(sizeof(IP_ADAPTER_INFO)); |
54 | unsigned long ulOutBufLen = sizeof(IP_ADAPTER_INFO); | 54 | unsigned long ulOutBufLen = sizeof(IP_ADAPTER_INFO); |
55 | 55 | ||
56 | if (pAdapterInfo == NULL) { | 56 | if (pAdapterInfo == NULL) { |
@@ -59,7 +59,7 @@ static void fetch_broadcast_info(uint16_t port) | |||
59 | 59 | ||
60 | if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) { | 60 | if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) { |
61 | free(pAdapterInfo); | 61 | free(pAdapterInfo); |
62 | pAdapterInfo = malloc(ulOutBufLen); | 62 | pAdapterInfo = (IP_ADAPTER_INFO *)malloc(ulOutBufLen); |
63 | 63 | ||
64 | if (pAdapterInfo == NULL) { | 64 | if (pAdapterInfo == NULL) { |
65 | return; | 65 | return; |
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c index ba8aeabe..caa1b73d 100644 --- a/toxcore/TCP_client.c +++ b/toxcore/TCP_client.c | |||
@@ -272,7 +272,7 @@ static int send_pending_data_nonpriority(TCP_Client_Connection *con) | |||
272 | } | 272 | } |
273 | 273 | ||
274 | uint16_t left = con->last_packet_length - con->last_packet_sent; | 274 | uint16_t left = con->last_packet_length - con->last_packet_sent; |
275 | int len = send(con->sock, con->last_packet + con->last_packet_sent, left, MSG_NOSIGNAL); | 275 | int len = send(con->sock, (const char *)(con->last_packet + con->last_packet_sent), left, MSG_NOSIGNAL); |
276 | 276 | ||
277 | if (len <= 0) { | 277 | if (len <= 0) { |
278 | return -1; | 278 | return -1; |
@@ -302,7 +302,7 @@ static int send_pending_data(TCP_Client_Connection *con) | |||
302 | 302 | ||
303 | while (p) { | 303 | while (p) { |
304 | uint16_t left = p->size - p->sent; | 304 | uint16_t left = p->size - p->sent; |
305 | int len = send(con->sock, p->data + p->sent, left, MSG_NOSIGNAL); | 305 | int len = send(con->sock, (const char *)(p->data + p->sent), left, MSG_NOSIGNAL); |
306 | 306 | ||
307 | if (len != left) { | 307 | if (len != left) { |
308 | if (len > 0) { | 308 | if (len > 0) { |
@@ -397,7 +397,7 @@ static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const | |||
397 | } | 397 | } |
398 | 398 | ||
399 | if (priority) { | 399 | if (priority) { |
400 | len = sendpriority ? send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL) : 0; | 400 | len = sendpriority ? send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL) : 0; |
401 | 401 | ||
402 | if (len <= 0) { | 402 | if (len <= 0) { |
403 | len = 0; | 403 | len = 0; |
@@ -412,7 +412,7 @@ static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const | |||
412 | return add_priority(con, packet, sizeof(packet), len); | 412 | return add_priority(con, packet, sizeof(packet), len); |
413 | } | 413 | } |
414 | 414 | ||
415 | len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); | 415 | len = send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL); |
416 | 416 | ||
417 | if (len <= 0) { | 417 | if (len <= 0) { |
418 | return 0; | 418 | return 0; |
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index 5a5a55be..4b355a62 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -251,7 +251,7 @@ uint16_t read_TCP_length(sock_t sock) | |||
251 | 251 | ||
252 | if (count >= sizeof(uint16_t)) { | 252 | if (count >= sizeof(uint16_t)) { |
253 | uint16_t length; | 253 | uint16_t length; |
254 | int len = recv(sock, (uint8_t *)&length, sizeof(uint16_t), MSG_NOSIGNAL); | 254 | int len = recv(sock, (char *)&length, sizeof(uint16_t), MSG_NOSIGNAL); |
255 | 255 | ||
256 | if (len != sizeof(uint16_t)) { | 256 | if (len != sizeof(uint16_t)) { |
257 | fprintf(stderr, "FAIL recv packet\n"); | 257 | fprintf(stderr, "FAIL recv packet\n"); |
@@ -280,7 +280,7 @@ int read_TCP_packet(sock_t sock, uint8_t *data, uint16_t length) | |||
280 | unsigned int count = TCP_socket_data_recv_buffer(sock); | 280 | unsigned int count = TCP_socket_data_recv_buffer(sock); |
281 | 281 | ||
282 | if (count >= length) { | 282 | if (count >= length) { |
283 | int len = recv(sock, data, length, MSG_NOSIGNAL); | 283 | int len = recv(sock, (char *)data, length, MSG_NOSIGNAL); |
284 | 284 | ||
285 | if (len != length) { | 285 | if (len != length) { |
286 | fprintf(stderr, "FAIL recv packet\n"); | 286 | fprintf(stderr, "FAIL recv packet\n"); |
@@ -348,7 +348,7 @@ static int send_pending_data_nonpriority(TCP_Secure_Connection *con) | |||
348 | } | 348 | } |
349 | 349 | ||
350 | uint16_t left = con->last_packet_length - con->last_packet_sent; | 350 | uint16_t left = con->last_packet_length - con->last_packet_sent; |
351 | int len = send(con->sock, con->last_packet + con->last_packet_sent, left, MSG_NOSIGNAL); | 351 | int len = send(con->sock, (const char *)(con->last_packet + con->last_packet_sent), left, MSG_NOSIGNAL); |
352 | 352 | ||
353 | if (len <= 0) { | 353 | if (len <= 0) { |
354 | return -1; | 354 | return -1; |
@@ -378,7 +378,7 @@ static int send_pending_data(TCP_Secure_Connection *con) | |||
378 | 378 | ||
379 | while (p) { | 379 | while (p) { |
380 | uint16_t left = p->size - p->sent; | 380 | uint16_t left = p->size - p->sent; |
381 | int len = send(con->sock, p->data + p->sent, left, MSG_NOSIGNAL); | 381 | int len = send(con->sock, (const char *)(p->data + p->sent), left, MSG_NOSIGNAL); |
382 | 382 | ||
383 | if (len != left) { | 383 | if (len != left) { |
384 | if (len > 0) { | 384 | if (len > 0) { |
@@ -462,7 +462,7 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const | |||
462 | } | 462 | } |
463 | 463 | ||
464 | if (priority) { | 464 | if (priority) { |
465 | len = sendpriority ? send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL) : 0; | 465 | len = sendpriority ? send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL) : 0; |
466 | 466 | ||
467 | if (len <= 0) { | 467 | if (len <= 0) { |
468 | len = 0; | 468 | len = 0; |
@@ -477,7 +477,7 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const | |||
477 | return add_priority(con, packet, sizeof(packet), len); | 477 | return add_priority(con, packet, sizeof(packet), len); |
478 | } | 478 | } |
479 | 479 | ||
480 | len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); | 480 | len = send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL); |
481 | 481 | ||
482 | if (len <= 0) { | 482 | if (len <= 0) { |
483 | return 0; | 483 | return 0; |
@@ -574,7 +574,7 @@ static int handle_TCP_handshake(TCP_Secure_Connection *con, const uint8_t *data, | |||
574 | return -1; | 574 | return -1; |
575 | } | 575 | } |
576 | 576 | ||
577 | if (TCP_SERVER_HANDSHAKE_SIZE != send(con->sock, response, TCP_SERVER_HANDSHAKE_SIZE, MSG_NOSIGNAL)) { | 577 | if (TCP_SERVER_HANDSHAKE_SIZE != send(con->sock, (const char *)response, TCP_SERVER_HANDSHAKE_SIZE, MSG_NOSIGNAL)) { |
578 | return -1; | 578 | return -1; |
579 | } | 579 | } |
580 | 580 | ||
diff --git a/toxcore/network.c b/toxcore/network.c index 386f8c16..31e8fd8b 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -170,7 +170,7 @@ int set_socket_nosigpipe(sock_t sock) | |||
170 | { | 170 | { |
171 | #if defined(__MACH__) | 171 | #if defined(__MACH__) |
172 | int set = 1; | 172 | int set = 1; |
173 | return (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)) == 0); | 173 | return (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (const char *)&set, sizeof(int)) == 0); |
174 | #else | 174 | #else |
175 | return 1; | 175 | return 1; |
176 | #endif | 176 | #endif |
@@ -184,7 +184,7 @@ int set_socket_nosigpipe(sock_t sock) | |||
184 | int set_socket_reuseaddr(sock_t sock) | 184 | int set_socket_reuseaddr(sock_t sock) |
185 | { | 185 | { |
186 | int set = 1; | 186 | int set = 1; |
187 | return (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&set, sizeof(set)) == 0); | 187 | return (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&set, sizeof(set)) == 0); |
188 | } | 188 | } |
189 | 189 | ||
190 | /* Set socket to dual (IPv4 + IPv6 socket) | 190 | /* Set socket to dual (IPv4 + IPv6 socket) |
@@ -196,14 +196,14 @@ int set_socket_dualstack(sock_t sock) | |||
196 | { | 196 | { |
197 | int ipv6only = 0; | 197 | int ipv6only = 0; |
198 | socklen_t optsize = sizeof(ipv6only); | 198 | socklen_t optsize = sizeof(ipv6only); |
199 | int res = getsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&ipv6only, &optsize); | 199 | int res = getsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, &optsize); |
200 | 200 | ||
201 | if ((res == 0) && (ipv6only == 0)) { | 201 | if ((res == 0) && (ipv6only == 0)) { |
202 | return 1; | 202 | return 1; |
203 | } | 203 | } |
204 | 204 | ||
205 | ipv6only = 0; | 205 | ipv6only = 0; |
206 | return (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&ipv6only, sizeof(ipv6only)) == 0); | 206 | return (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&ipv6only, sizeof(ipv6only)) == 0); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
@@ -588,12 +588,12 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1 | |||
588 | /* Functions to increase the size of the send and receive UDP buffers. | 588 | /* Functions to increase the size of the send and receive UDP buffers. |
589 | */ | 589 | */ |
590 | int n = 1024 * 1024 * 2; | 590 | int n = 1024 * 1024 * 2; |
591 | setsockopt(temp->sock, SOL_SOCKET, SO_RCVBUF, (char *)&n, sizeof(n)); | 591 | setsockopt(temp->sock, SOL_SOCKET, SO_RCVBUF, (const char *)&n, sizeof(n)); |
592 | setsockopt(temp->sock, SOL_SOCKET, SO_SNDBUF, (char *)&n, sizeof(n)); | 592 | setsockopt(temp->sock, SOL_SOCKET, SO_SNDBUF, (const char *)&n, sizeof(n)); |
593 | 593 | ||
594 | /* Enable broadcast on socket */ | 594 | /* Enable broadcast on socket */ |
595 | int broadcast = 1; | 595 | int broadcast = 1; |
596 | setsockopt(temp->sock, SOL_SOCKET, SO_BROADCAST, (char *)&broadcast, sizeof(broadcast)); | 596 | setsockopt(temp->sock, SOL_SOCKET, SO_BROADCAST, (const char *)&broadcast, sizeof(broadcast)); |
597 | 597 | ||
598 | /* iOS UDP sockets are weird and apparently can SIGPIPE */ | 598 | /* iOS UDP sockets are weird and apparently can SIGPIPE */ |
599 | if (!set_socket_nosigpipe(temp->sock)) { | 599 | if (!set_socket_nosigpipe(temp->sock)) { |
@@ -659,7 +659,7 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1 | |||
659 | mreq.ipv6mr_multiaddr.s6_addr[ 1] = 0x02; | 659 | mreq.ipv6mr_multiaddr.s6_addr[ 1] = 0x02; |
660 | mreq.ipv6mr_multiaddr.s6_addr[15] = 0x01; | 660 | mreq.ipv6mr_multiaddr.s6_addr[15] = 0x01; |
661 | mreq.ipv6mr_interface = 0; | 661 | mreq.ipv6mr_interface = 0; |
662 | int res = setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq)); | 662 | int res = setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (const char *)&mreq, sizeof(mreq)); |
663 | 663 | ||
664 | LOGGER_DEBUG(log, res < 0 ? "Failed to activate local multicast membership. (%u, %s)" : | 664 | LOGGER_DEBUG(log, res < 0 ? "Failed to activate local multicast membership. (%u, %s)" : |
665 | "Local multicast group FF02::1 joined successfully", errno, strerror(errno)); | 665 | "Local multicast group FF02::1 joined successfully", errno, strerror(errno)); |