diff options
-rw-r--r-- | auto_tests/tox_test.c | 2 | ||||
-rw-r--r-- | auto_tests/toxav_many_test.c | 2 | ||||
-rw-r--r-- | testing/nTox.c | 3 | ||||
-rw-r--r-- | toxcore/DHT.c | 29 | ||||
-rw-r--r-- | toxcore/DHT.h | 8 | ||||
-rw-r--r-- | toxcore/Messenger.c | 16 | ||||
-rw-r--r-- | toxcore/Messenger.h | 13 | ||||
-rw-r--r-- | toxcore/crypto_core.c | 10 | ||||
-rw-r--r-- | toxcore/crypto_core.h | 10 | ||||
-rw-r--r-- | toxcore/friend_requests.c | 4 | ||||
-rw-r--r-- | toxcore/friend_requests.h | 4 | ||||
-rw-r--r-- | toxcore/list.c | 2 | ||||
-rw-r--r-- | toxcore/list.h | 2 | ||||
-rw-r--r-- | toxcore/network.c | 6 | ||||
-rw-r--r-- | toxcore/network.h | 2 | ||||
-rw-r--r-- | toxcore/onion_client.c | 3 | ||||
-rw-r--r-- | toxcore/onion_client.h | 3 | ||||
-rw-r--r-- | toxcore/tox.c | 4 | ||||
-rw-r--r-- | toxcore/tox.h | 4 |
19 files changed, 67 insertions, 60 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 11de2213..f8da8560 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #define c_sleep(x) usleep(1000*x) | 19 | #define c_sleep(x) usleep(1000*x) |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata) | 22 | void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata) |
23 | { | 23 | { |
24 | if (*((uint32_t *)userdata) != 974536) | 24 | if (*((uint32_t *)userdata) != 974536) |
25 | return; | 25 | return; |
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index b7f6a0fc..2a931cb0 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -52,7 +52,7 @@ typedef struct _Status { | |||
52 | ACall calls[3]; /* Make 3 calls for this test */ | 52 | ACall calls[3]; /* Make 3 calls for this test */ |
53 | } Status; | 53 | } Status; |
54 | 54 | ||
55 | void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata) | 55 | void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata) |
56 | { | 56 | { |
57 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { | 57 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { |
58 | tox_add_friend_norequest(m, public_key); | 58 | tox_add_friend_norequest(m, public_key); |
diff --git a/testing/nTox.c b/testing/nTox.c index b4a65448..0145c6ee 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -864,7 +864,7 @@ void do_refresh() | |||
864 | refresh(); | 864 | refresh(); |
865 | } | 865 | } |
866 | 866 | ||
867 | void print_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata) | 867 | void print_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata) |
868 | { | 868 | { |
869 | new_lines("[i] received friend request with message:"); | 869 | new_lines("[i] received friend request with message:"); |
870 | new_lines((char *)data); | 870 | new_lines((char *)data); |
@@ -1181,6 +1181,7 @@ char timeout_getch(Tox *m) | |||
1181 | 1181 | ||
1182 | c = ERR; | 1182 | c = ERR; |
1183 | int n = select(1, &fds, NULL, NULL, &tv); | 1183 | int n = select(1, &fds, NULL, NULL, &tv); |
1184 | |||
1184 | if (n < 0) { | 1185 | if (n < 0) { |
1185 | new_lines("select error: maybe interupted"); | 1186 | new_lines("select error: maybe interupted"); |
1186 | } else if (n == 0) { | 1187 | } else if (n == 0) { |
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 92d6e159..1055ddcd 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -544,8 +544,8 @@ static void get_close_nodes_inner(const uint8_t *client_id, Node_format *nodes_l | |||
544 | * | 544 | * |
545 | * want_good : do we want only good nodes as checked with the hardening returned or not? | 545 | * want_good : do we want only good nodes as checked with the hardening returned or not? |
546 | */ | 546 | */ |
547 | static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, | 547 | static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, |
548 | uint8_t is_LAN, uint8_t want_good) | 548 | sa_family_t sa_family, uint8_t is_LAN, uint8_t want_good) |
549 | { | 549 | { |
550 | uint32_t num_nodes = 0, i; | 550 | uint32_t num_nodes = 0, i; |
551 | get_close_nodes_inner(client_id, nodes_list, sa_family, | 551 | get_close_nodes_inner(client_id, nodes_list, sa_family, |
@@ -565,8 +565,8 @@ static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *client_id, No | |||
565 | return num_nodes; | 565 | return num_nodes; |
566 | } | 566 | } |
567 | 567 | ||
568 | int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, uint8_t is_LAN, | 568 | int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, |
569 | uint8_t want_good) | 569 | uint8_t is_LAN, uint8_t want_good) |
570 | { | 570 | { |
571 | memset(nodes_list, 0, MAX_SENT_NODES * sizeof(Node_format)); | 571 | memset(nodes_list, 0, MAX_SENT_NODES * sizeof(Node_format)); |
572 | #ifdef ENABLE_ASSOC_DHT | 572 | #ifdef ENABLE_ASSOC_DHT |
@@ -961,7 +961,8 @@ end: | |||
961 | 961 | ||
962 | /* Send a getnodes request. | 962 | /* Send a getnodes request. |
963 | sendback_node is the node that it will send back the response to (set to NULL to disable this) */ | 963 | sendback_node is the node that it will send back the response to (set to NULL to disable this) */ |
964 | static int getnodes(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id, const Node_format *sendback_node) | 964 | static int getnodes(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id, |
965 | const Node_format *sendback_node) | ||
965 | { | 966 | { |
966 | /* Check if packet is going to be sent to ourself. */ | 967 | /* Check if packet is going to be sent to ourself. */ |
967 | if (id_equal(public_key, dht->self_public_key)) | 968 | if (id_equal(public_key, dht->self_public_key)) |
@@ -1017,8 +1018,8 @@ static int getnodes(DHT *dht, IP_Port ip_port, const uint8_t *public_key, const | |||
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | /* Send a send nodes response: message for IPv6 nodes */ | 1020 | /* Send a send nodes response: message for IPv6 nodes */ |
1020 | static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id, const uint8_t *sendback_data, | 1021 | static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public_key, const uint8_t *client_id, |
1021 | uint16_t length, const uint8_t *shared_encryption_key) | 1022 | const uint8_t *sendback_data, uint16_t length, const uint8_t *shared_encryption_key) |
1022 | { | 1023 | { |
1023 | /* Check if packet is going to be sent to ourself. */ | 1024 | /* Check if packet is going to be sent to ourself. */ |
1024 | if (id_equal(public_key, dht->self_public_key)) | 1025 | if (id_equal(public_key, dht->self_public_key)) |
@@ -1128,8 +1129,8 @@ static uint8_t sent_getnode_to_node(DHT *dht, const uint8_t *client_id, IP_Port | |||
1128 | } | 1129 | } |
1129 | 1130 | ||
1130 | /* Function is needed in following functions. */ | 1131 | /* Function is needed in following functions. */ |
1131 | static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, const uint8_t *nodes_data, | 1132 | static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, |
1132 | uint16_t nodes_data_length); | 1133 | const uint8_t *nodes_data, uint16_t nodes_data_length); |
1133 | 1134 | ||
1134 | static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *packet, uint32_t length, | 1135 | static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *packet, uint32_t length, |
1135 | Node_format *plain_nodes, uint16_t size_plain_nodes, uint32_t *num_nodes_out) | 1136 | Node_format *plain_nodes, uint16_t size_plain_nodes, uint32_t *num_nodes_out) |
@@ -1753,7 +1754,8 @@ static int send_NATping(DHT *dht, const uint8_t *public_key, uint64_t ping_id, u | |||
1753 | } | 1754 | } |
1754 | 1755 | ||
1755 | /* Handle a received ping request for. */ | 1756 | /* Handle a received ping request for. */ |
1756 | static int handle_NATping(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length) | 1757 | static int handle_NATping(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, |
1758 | uint32_t length) | ||
1757 | { | 1759 | { |
1758 | if (length != sizeof(uint64_t) + 1) | 1760 | if (length != sizeof(uint64_t) + 1) |
1759 | return 1; | 1761 | return 1; |
@@ -1962,8 +1964,8 @@ static int send_hardening_getnode_req(DHT *dht, Node_format *dest, Node_format * | |||
1962 | } | 1964 | } |
1963 | 1965 | ||
1964 | /* Send a get node hardening response */ | 1966 | /* Send a get node hardening response */ |
1965 | static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, const uint8_t *nodes_data, | 1967 | static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, |
1966 | uint16_t nodes_data_length) | 1968 | const uint8_t *nodes_data, uint16_t nodes_data_length) |
1967 | { | 1969 | { |
1968 | if (!ip_isset(&sendto->ip_port.ip)) | 1970 | if (!ip_isset(&sendto->ip_port.ip)) |
1969 | return -1; | 1971 | return -1; |
@@ -2032,7 +2034,8 @@ static uint32_t have_nodes_closelist(DHT *dht, Node_format *nodes, uint16_t num) | |||
2032 | #define HARDEN_TIMEOUT 1200 | 2034 | #define HARDEN_TIMEOUT 1200 |
2033 | 2035 | ||
2034 | /* Handle a received hardening packet */ | 2036 | /* Handle a received hardening packet */ |
2035 | static int handle_hardening(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length) | 2037 | static int handle_hardening(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, |
2038 | uint32_t length) | ||
2036 | { | 2039 | { |
2037 | DHT *dht = object; | 2040 | DHT *dht = object; |
2038 | 2041 | ||
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index 97a7109f..c7fddb4f 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -176,8 +176,8 @@ typedef struct { | |||
176 | 176 | ||
177 | /*----------------------------------------------------------------------------------*/ | 177 | /*----------------------------------------------------------------------------------*/ |
178 | 178 | ||
179 | typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, const uint8_t *source_pubkey, const uint8_t *data, | 179 | typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, const uint8_t *source_pubkey, |
180 | uint32_t len); | 180 | const uint8_t *data, uint32_t len); |
181 | 181 | ||
182 | typedef struct { | 182 | typedef struct { |
183 | cryptopacket_handler_callback function; | 183 | cryptopacket_handler_callback function; |
@@ -290,8 +290,8 @@ int id_closest(const uint8_t *id, const uint8_t *id1, const uint8_t *id2); | |||
290 | * return the number of nodes returned. | 290 | * return the number of nodes returned. |
291 | * | 291 | * |
292 | */ | 292 | */ |
293 | int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, uint8_t is_LAN, | 293 | int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, |
294 | uint8_t want_good); | 294 | uint8_t is_LAN, uint8_t want_good); |
295 | 295 | ||
296 | 296 | ||
297 | /* Put up to max_num nodes in nodes from the closelist. | 297 | /* Put up to max_num nodes in nodes from the closelist. |
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 931468ec..358227a3 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -373,7 +373,8 @@ uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, const uint8_t *messag | |||
373 | return 0; | 373 | return 0; |
374 | } | 374 | } |
375 | 375 | ||
376 | uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message, uint32_t length) | 376 | uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message, |
377 | uint32_t length) | ||
377 | { | 378 | { |
378 | if (length >= (MAX_CRYPTO_DATA_SIZE - sizeof(theid))) | 379 | if (length >= (MAX_CRYPTO_DATA_SIZE - sizeof(theid))) |
379 | return 0; | 380 | return 0; |
@@ -722,8 +723,8 @@ void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno) | |||
722 | 723 | ||
723 | /* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); */ | 724 | /* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); */ |
724 | /* Set the function that will be executed when a friend request is received. */ | 725 | /* Set the function that will be executed when a friend request is received. */ |
725 | void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, void *), | 726 | void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, |
726 | void *userdata) | 727 | void *), void *userdata) |
727 | { | 728 | { |
728 | void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, uint16_t, void *) = (void *)function; | 729 | void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, uint16_t, void *) = (void *)function; |
729 | callback_friendrequest(&(m->fr), handle_friendrequest, m, userdata); | 730 | callback_friendrequest(&(m->fr), handle_friendrequest, m, userdata); |
@@ -1294,8 +1295,7 @@ static void do_allgroupchats(Messenger *m) | |||
1294 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) | 1295 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) |
1295 | */ | 1296 | */ |
1296 | void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, | 1297 | void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, |
1297 | uint16_t, | 1298 | uint16_t, void *), void *userdata) |
1298 | void *), void *userdata) | ||
1299 | { | 1299 | { |
1300 | m->file_sendrequest = function; | 1300 | m->file_sendrequest = function; |
1301 | m->file_sendrequest_userdata = userdata; | 1301 | m->file_sendrequest_userdata = userdata; |
@@ -1307,8 +1307,7 @@ void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int3 | |||
1307 | * | 1307 | * |
1308 | */ | 1308 | */ |
1309 | void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *, | 1309 | void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *, |
1310 | uint16_t, | 1310 | uint16_t, void *), void *userdata) |
1311 | void *), void *userdata) | ||
1312 | { | 1311 | { |
1313 | m->file_filecontrol = function; | 1312 | m->file_filecontrol = function; |
1314 | m->file_filecontrol_userdata = userdata; | 1313 | m->file_filecontrol_userdata = userdata; |
@@ -1320,8 +1319,7 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, | |||
1320 | * | 1319 | * |
1321 | */ | 1320 | */ |
1322 | void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, | 1321 | void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, |
1323 | void *), | 1322 | void *), void *userdata) |
1324 | void *userdata) | ||
1325 | { | 1323 | { |
1326 | m->file_filedata = function; | 1324 | m->file_filedata = function; |
1327 | m->file_filedata_userdata = userdata; | 1325 | m->file_filedata_userdata = userdata; |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index ad51a754..6d522936 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -322,7 +322,8 @@ int m_friend_exists(Messenger *m, int32_t friendnumber); | |||
322 | * however we can generate an id for you by calling plain m_sendmessage. | 322 | * however we can generate an id for you by calling plain m_sendmessage. |
323 | */ | 323 | */ |
324 | uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, const uint8_t *message, uint32_t length); | 324 | uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, const uint8_t *message, uint32_t length); |
325 | uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message, uint32_t length); | 325 | uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *message, |
326 | uint32_t length); | ||
326 | 327 | ||
327 | /* Send an action to an online friend. | 328 | /* Send an action to an online friend. |
328 | * | 329 | * |
@@ -442,8 +443,8 @@ void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno); | |||
442 | /* Set the function that will be executed when a friend request is received. | 443 | /* Set the function that will be executed when a friend request is received. |
443 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) | 444 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) |
444 | */ | 445 | */ |
445 | void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, void *), | 446 | void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, |
446 | void *userdata); | 447 | void *), void *userdata); |
447 | 448 | ||
448 | /* Set the function that will be executed when a message from a friend is received. | 449 | /* Set the function that will be executed when a message from a friend is received. |
449 | * Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length) | 450 | * Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length) |
@@ -612,8 +613,7 @@ int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], | |||
612 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) | 613 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) |
613 | */ | 614 | */ |
614 | void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, | 615 | void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, |
615 | uint16_t, | 616 | uint16_t, void *), void *userdata); |
616 | void *), void *userdata); | ||
617 | 617 | ||
618 | /* Set the callback for file control requests. | 618 | /* Set the callback for file control requests. |
619 | * | 619 | * |
@@ -629,8 +629,7 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, | |||
629 | * | 629 | * |
630 | */ | 630 | */ |
631 | void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, | 631 | void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, |
632 | void *), | 632 | void *), void *userdata); |
633 | void *userdata); | ||
634 | 633 | ||
635 | /* Send a file send request. | 634 | /* Send a file send request. |
636 | * Maximum filename length is 255 bytes. | 635 | * Maximum filename length is 255 bytes. |
diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c index 50b217a0..6c753007 100644 --- a/toxcore/crypto_core.c +++ b/toxcore/crypto_core.c | |||
@@ -76,7 +76,8 @@ void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, ui | |||
76 | crypto_box_beforenm(enc_key, public_key, secret_key); | 76 | crypto_box_beforenm(enc_key, public_key, secret_key); |
77 | } | 77 | } |
78 | 78 | ||
79 | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, uint8_t *encrypted) | 79 | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, |
80 | uint8_t *encrypted) | ||
80 | { | 81 | { |
81 | if (length == 0) | 82 | if (length == 0) |
82 | return -1; | 83 | return -1; |
@@ -95,7 +96,8 @@ int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, cons | |||
95 | return length + crypto_box_MACBYTES; | 96 | return length + crypto_box_MACBYTES; |
96 | } | 97 | } |
97 | 98 | ||
98 | int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length, uint8_t *plain) | 99 | int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length, |
100 | uint8_t *plain) | ||
99 | { | 101 | { |
100 | if (length <= crypto_box_BOXZEROBYTES) | 102 | if (length <= crypto_box_BOXZEROBYTES) |
101 | return -1; | 103 | return -1; |
@@ -202,8 +204,8 @@ void new_nonce(uint8_t *nonce) | |||
202 | * return -1 on failure. | 204 | * return -1 on failure. |
203 | * return the length of the created packet on success. | 205 | * return the length of the created packet on success. |
204 | */ | 206 | */ |
205 | int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet, const uint8_t *recv_public_key, | 207 | int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet, |
206 | const uint8_t *data, uint32_t length, uint8_t request_id) | 208 | const uint8_t *recv_public_key, const uint8_t *data, uint32_t length, uint8_t request_id) |
207 | { | 209 | { |
208 | if (MAX_CRYPTO_REQUEST_SIZE < length + 1 + crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + | 210 | if (MAX_CRYPTO_REQUEST_SIZE < length + 1 + crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + |
209 | crypto_box_MACBYTES) | 211 | crypto_box_MACBYTES) |
diff --git a/toxcore/crypto_core.h b/toxcore/crypto_core.h index 578bd54a..814c4362 100644 --- a/toxcore/crypto_core.h +++ b/toxcore/crypto_core.h | |||
@@ -84,7 +84,8 @@ void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, ui | |||
84 | * return -1 if there was a problem. | 84 | * return -1 if there was a problem. |
85 | * return length of encrypted data if everything was fine. | 85 | * return length of encrypted data if everything was fine. |
86 | */ | 86 | */ |
87 | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, uint8_t *encrypted); | 87 | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, |
88 | uint8_t *encrypted); | ||
88 | 89 | ||
89 | /* Decrypts encrypted of length length to plain of length length - 16 using a | 90 | /* Decrypts encrypted of length length to plain of length length - 16 using a |
90 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. | 91 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. |
@@ -92,7 +93,8 @@ int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, cons | |||
92 | * return -1 if there was a problem (decryption failed). | 93 | * return -1 if there was a problem (decryption failed). |
93 | * return length of plain data if everything was fine. | 94 | * return length of plain data if everything was fine. |
94 | */ | 95 | */ |
95 | int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length, uint8_t *plain); | 96 | int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *encrypted, uint32_t length, |
97 | uint8_t *plain); | ||
96 | 98 | ||
97 | /* Increment the given nonce by 1. */ | 99 | /* Increment the given nonce by 1. */ |
98 | void increment_nonce(uint8_t *nonce); | 100 | void increment_nonce(uint8_t *nonce); |
@@ -128,8 +130,8 @@ void new_nonce(uint8_t *nonce); | |||
128 | * return -1 on failure. | 130 | * return -1 on failure. |
129 | * return the length of the created packet on success. | 131 | * return the length of the created packet on success. |
130 | */ | 132 | */ |
131 | int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet, const uint8_t *recv_public_key, | 133 | int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet, |
132 | const uint8_t *data, uint32_t length, uint8_t request_id); | 134 | const uint8_t *recv_public_key, const uint8_t *data, uint32_t length, uint8_t request_id); |
133 | 135 | ||
134 | /* puts the senders public key in the request in public_key, the data from the request | 136 | /* puts the senders public key in the request in public_key, the data from the request |
135 | in data if a friend or ping request was sent to us and returns the length of the data. | 137 | in data if a friend or ping request was sent to us and returns the length of the data. |
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index 4bf95a44..9b05cc51 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -72,8 +72,8 @@ uint32_t get_nospam(Friend_Requests *fr) | |||
72 | 72 | ||
73 | 73 | ||
74 | /* Set the function that will be executed when a friend request is received. */ | 74 | /* Set the function that will be executed when a friend request is received. */ |
75 | void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, void *), | 75 | void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, |
76 | void *object, void *userdata) | 76 | void *), void *object, void *userdata) |
77 | { | 77 | { |
78 | fr->handle_friendrequest = function; | 78 | fr->handle_friendrequest = function; |
79 | fr->handle_friendrequest_isset = 1; | 79 | fr->handle_friendrequest_isset = 1; |
diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h index 58ff91ce..8d429a7e 100644 --- a/toxcore/friend_requests.h +++ b/toxcore/friend_requests.h | |||
@@ -66,8 +66,8 @@ int remove_request_received(Friend_Requests *fr, uint8_t *client_id); | |||
66 | /* Set the function that will be executed when a friend request for us is received. | 66 | /* Set the function that will be executed when a friend request for us is received. |
67 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) | 67 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) |
68 | */ | 68 | */ |
69 | void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, void *), | 69 | void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, |
70 | void *object, void *userdata); | 70 | void *), void *object, void *userdata); |
71 | 71 | ||
72 | /* Set the function used to check if a friend request should be displayed to the user or not. | 72 | /* Set the function used to check if a friend request should be displayed to the user or not. |
73 | * Function format is int function(uint8_t * public_key, void * userdata) | 73 | * Function format is int function(uint8_t * public_key, void * userdata) |
diff --git a/toxcore/list.c b/toxcore/list.c index dc57911f..c513afab 100644 --- a/toxcore/list.c +++ b/toxcore/list.c | |||
@@ -115,7 +115,7 @@ void bs_list_init(BS_LIST *list, uint32_t element_size) | |||
115 | list->ids = NULL; | 115 | list->ids = NULL; |
116 | } | 116 | } |
117 | 117 | ||
118 | void bs_list_free(const BS_LIST *list) | 118 | void bs_list_free(BS_LIST *list) |
119 | { | 119 | { |
120 | //free both arrays | 120 | //free both arrays |
121 | free(list->data); | 121 | free(list->data); |
diff --git a/toxcore/list.h b/toxcore/list.h index 090853f9..1a1fe57d 100644 --- a/toxcore/list.h +++ b/toxcore/list.h | |||
@@ -41,7 +41,7 @@ typedef struct { | |||
41 | void bs_list_init(BS_LIST *list, uint32_t element_size); | 41 | void bs_list_init(BS_LIST *list, uint32_t element_size); |
42 | 42 | ||
43 | /* Free a list initiated with list_init */ | 43 | /* Free a list initiated with list_init */ |
44 | void bs_list_free(const BS_LIST *list); | 44 | void bs_list_free(BS_LIST *list); |
45 | 45 | ||
46 | /* Retrieve the id of an element in the list | 46 | /* Retrieve the id of an element in the list |
47 | * | 47 | * |
diff --git a/toxcore/network.c b/toxcore/network.c index d7ae8792..68359016 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) | 46 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) |
47 | 47 | ||
48 | static const char *inet_ntop(sa_family_t family, void *addr, const char *buf, size_t bufsize) | 48 | static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t bufsize) |
49 | { | 49 | { |
50 | if (family == AF_INET) { | 50 | if (family == AF_INET) { |
51 | struct sockaddr_in saddr; | 51 | struct sockaddr_in saddr; |
@@ -78,7 +78,7 @@ static const char *inet_ntop(sa_family_t family, void *addr, const char *buf, si | |||
78 | return NULL; | 78 | return NULL; |
79 | } | 79 | } |
80 | 80 | ||
81 | static int inet_pton(sa_family_t family, const char *addrString, const void *addrbuf) | 81 | static int inet_pton(sa_family_t family, const char *addrString, void *addrbuf) |
82 | { | 82 | { |
83 | if (family == AF_INET) { | 83 | if (family == AF_INET) { |
84 | struct sockaddr_in saddr; | 84 | struct sockaddr_in saddr; |
@@ -404,7 +404,7 @@ void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handl | |||
404 | net->packethandlers[byte].object = object; | 404 | net->packethandlers[byte].object = object; |
405 | } | 405 | } |
406 | 406 | ||
407 | void networking_poll(const Networking_Core *net) | 407 | void networking_poll(Networking_Core *net) |
408 | { | 408 | { |
409 | unix_time_update(); | 409 | unix_time_update(); |
410 | 410 | ||
diff --git a/toxcore/network.h b/toxcore/network.h index 110eb729..e5c24a2d 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -338,7 +338,7 @@ int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint3 | |||
338 | void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object); | 338 | void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object); |
339 | 339 | ||
340 | /* Call this several times a second. */ | 340 | /* Call this several times a second. */ |
341 | void networking_poll(const Networking_Core *net); | 341 | void networking_poll(Networking_Core *net); |
342 | 342 | ||
343 | /* Initialize networking. | 343 | /* Initialize networking. |
344 | * bind to ip and port. | 344 | * bind to ip and port. |
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 8e28eae5..1fe54d85 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -623,7 +623,8 @@ static int send_dht_fakeid(Onion_Client *onion_c, int friend_num, uint8_t *data, | |||
623 | return route_tofriend(onion_c->dht, onion_c->friends_list[friend_num].fake_client_id, packet, len); | 623 | return route_tofriend(onion_c->dht, onion_c->friends_list[friend_num].fake_client_id, packet, len); |
624 | } | 624 | } |
625 | 625 | ||
626 | static int handle_dht_fakeid(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length) | 626 | static int handle_dht_fakeid(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, |
627 | uint32_t length) | ||
627 | { | 628 | { |
628 | Onion_Client *onion_c = object; | 629 | Onion_Client *onion_c = object; |
629 | 630 | ||
diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index 7995fa3a..df7be2ef 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h | |||
@@ -102,7 +102,8 @@ typedef struct { | |||
102 | uint32_t tcp_relay_node_callback_number; | 102 | uint32_t tcp_relay_node_callback_number; |
103 | } Onion_Friend; | 103 | } Onion_Friend; |
104 | 104 | ||
105 | typedef int (*oniondata_handler_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint32_t len); | 105 | typedef int (*oniondata_handler_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, |
106 | uint32_t len); | ||
106 | 107 | ||
107 | typedef struct { | 108 | typedef struct { |
108 | DHT *dht; | 109 | DHT *dht; |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 7cb7d692..008440a4 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -362,8 +362,8 @@ uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size) | |||
362 | /* Set the function that will be executed when a friend request is received. | 362 | /* Set the function that will be executed when a friend request is received. |
363 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) | 363 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) |
364 | */ | 364 | */ |
365 | void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t, void *), | 365 | void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t, |
366 | void *userdata) | 366 | void *), void *userdata) |
367 | { | 367 | { |
368 | Messenger *m = tox; | 368 | Messenger *m = tox; |
369 | m_callback_friendrequest(m, function, userdata); | 369 | m_callback_friendrequest(m, function, userdata); |
diff --git a/toxcore/tox.h b/toxcore/tox.h index c217e1a1..f0390fe1 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -289,8 +289,8 @@ uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size); | |||
289 | /* Set the function that will be executed when a friend request is received. | 289 | /* Set the function that will be executed when a friend request is received. |
290 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) | 290 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) |
291 | */ | 291 | */ |
292 | void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t, void *), | 292 | void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t, |
293 | void *userdata); | 293 | void *), void *userdata); |
294 | 294 | ||
295 | /* Set the function that will be executed when a message from a friend is received. | 295 | /* Set the function that will be executed when a message from a friend is received. |
296 | * Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * message, uint32_t length, void *userdata) | 296 | * Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * message, uint32_t length, void *userdata) |