diff options
author | irungentoo <irungentoo@gmail.com> | 2014-11-21 20:18:29 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-11-21 20:18:29 -0500 |
commit | 6bbb9398558d226711450feea45417bcf3eafe70 (patch) | |
tree | ed946e3fa14ccc4aec0dbdddc481dcd1e2de3e69 | |
parent | e74225039e08e7be6e60cf7e2f5e279eb0559ce7 (diff) |
Cleaned up packet length types in toxcore.
They are now all uint16_t instead of sometimes being uint32_t.
Replaced some other uint32_t with unsigned ints.
-rw-r--r-- | auto_tests/onion_test.c | 8 | ||||
-rw-r--r-- | toxcore/DHT.c | 24 | ||||
-rw-r--r-- | toxcore/DHT.h | 6 | ||||
-rw-r--r-- | toxcore/LAN_discovery.c | 2 | ||||
-rw-r--r-- | toxcore/friend_connection.c | 2 | ||||
-rw-r--r-- | toxcore/friend_connection.h | 4 | ||||
-rw-r--r-- | toxcore/friend_requests.c | 2 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 20 | ||||
-rw-r--r-- | toxcore/net_crypto.h | 4 | ||||
-rw-r--r-- | toxcore/network.c | 2 | ||||
-rw-r--r-- | toxcore/network.h | 4 | ||||
-rw-r--r-- | toxcore/onion.c | 34 | ||||
-rw-r--r-- | toxcore/onion.h | 12 | ||||
-rw-r--r-- | toxcore/onion_announce.c | 12 | ||||
-rw-r--r-- | toxcore/onion_client.c | 44 | ||||
-rw-r--r-- | toxcore/onion_client.h | 4 | ||||
-rw-r--r-- | toxcore/ping.c | 6 |
17 files changed, 95 insertions, 95 deletions
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 3b8e0603..8e10eb11 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -30,7 +30,7 @@ void do_onion(Onion *onion) | |||
30 | } | 30 | } |
31 | 31 | ||
32 | static int handled_test_1; | 32 | static int handled_test_1; |
33 | static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 33 | static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
34 | { | 34 | { |
35 | Onion *onion = object; | 35 | Onion *onion = object; |
36 | 36 | ||
@@ -46,7 +46,7 @@ static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, ui | |||
46 | } | 46 | } |
47 | 47 | ||
48 | static int handled_test_2; | 48 | static int handled_test_2; |
49 | static int handle_test_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 49 | static int handle_test_2(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
50 | { | 50 | { |
51 | if (length != sizeof("install Gentoo")) | 51 | if (length != sizeof("install Gentoo")) |
52 | return 1; | 52 | return 1; |
@@ -72,7 +72,7 @@ uint8_t sb_data[ONION_ANNOUNCE_SENDBACK_DATA_LENGTH]; | |||
72 | static int handled_test_3; | 72 | static int handled_test_3; |
73 | uint8_t test_3_pub_key[crypto_box_PUBLICKEYBYTES]; | 73 | uint8_t test_3_pub_key[crypto_box_PUBLICKEYBYTES]; |
74 | uint8_t test_3_ping_id[crypto_hash_sha256_BYTES]; | 74 | uint8_t test_3_ping_id[crypto_hash_sha256_BYTES]; |
75 | static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 75 | static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
76 | { | 76 | { |
77 | Onion *onion = object; | 77 | Onion *onion = object; |
78 | 78 | ||
@@ -101,7 +101,7 @@ static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, ui | |||
101 | 101 | ||
102 | uint8_t nonce[crypto_box_NONCEBYTES]; | 102 | uint8_t nonce[crypto_box_NONCEBYTES]; |
103 | static int handled_test_4; | 103 | static int handled_test_4; |
104 | static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 104 | static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
105 | { | 105 | { |
106 | Onion *onion = object; | 106 | Onion *onion = object; |
107 | 107 | ||
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 52664218..1e120746 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -313,7 +313,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed | |||
313 | * | 313 | * |
314 | * return True(1) or False(0) | 314 | * return True(1) or False(0) |
315 | */ | 315 | */ |
316 | static int client_or_ip_port_in_list(Client_data *list, uint32_t length, const uint8_t *client_id, IP_Port ip_port) | 316 | static int client_or_ip_port_in_list(Client_data *list, uint16_t length, const uint8_t *client_id, IP_Port ip_port) |
317 | { | 317 | { |
318 | uint32_t i; | 318 | uint32_t i; |
319 | uint64_t temp_time = unix_time(); | 319 | uint64_t temp_time = unix_time(); |
@@ -392,7 +392,7 @@ static int client_or_ip_port_in_list(Client_data *list, uint32_t length, const u | |||
392 | * return 1 if true. | 392 | * return 1 if true. |
393 | * return 0 if false. | 393 | * return 0 if false. |
394 | */ | 394 | */ |
395 | static int client_in_nodelist(const Node_format *list, uint32_t length, const uint8_t *client_id) | 395 | static int client_in_nodelist(const Node_format *list, uint16_t length, const uint8_t *client_id) |
396 | { | 396 | { |
397 | uint32_t i; | 397 | uint32_t i; |
398 | 398 | ||
@@ -614,7 +614,7 @@ int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes | |||
614 | * | 614 | * |
615 | * returns True(1) when the item was stored, False(0) otherwise */ | 615 | * returns True(1) when the item was stored, False(0) otherwise */ |
616 | static int replace_all( Client_data *list, | 616 | static int replace_all( Client_data *list, |
617 | uint32_t length, | 617 | uint16_t length, |
618 | const uint8_t *client_id, | 618 | const uint8_t *client_id, |
619 | IP_Port ip_port, | 619 | IP_Port ip_port, |
620 | const uint8_t *comp_client_id ) | 620 | const uint8_t *comp_client_id ) |
@@ -938,7 +938,7 @@ static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public | |||
938 | return sendpacket(dht->net, ip_port, data, 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + len); | 938 | return sendpacket(dht->net, ip_port, data, 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + len); |
939 | } | 939 | } |
940 | 940 | ||
941 | static int handle_getnodes(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 941 | static int handle_getnodes(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
942 | { | 942 | { |
943 | uint32_t cmp_len = 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + CLIENT_ID_SIZE + crypto_box_MACBYTES; | 943 | uint32_t cmp_len = 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + CLIENT_ID_SIZE + crypto_box_MACBYTES; |
944 | 944 | ||
@@ -1003,7 +1003,7 @@ static uint8_t sent_getnode_to_node(DHT *dht, const uint8_t *client_id, IP_Port | |||
1003 | static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, | 1003 | static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id, |
1004 | const uint8_t *nodes_data, uint16_t nodes_data_length); | 1004 | const uint8_t *nodes_data, uint16_t nodes_data_length); |
1005 | 1005 | ||
1006 | static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *packet, uint32_t length, | 1006 | static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *packet, uint16_t length, |
1007 | Node_format *plain_nodes, uint16_t size_plain_nodes, uint32_t *num_nodes_out) | 1007 | Node_format *plain_nodes, uint16_t size_plain_nodes, uint32_t *num_nodes_out) |
1008 | { | 1008 | { |
1009 | DHT *dht = object; | 1009 | DHT *dht = object; |
@@ -1065,7 +1065,7 @@ static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *pa | |||
1065 | return 0; | 1065 | return 0; |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 1068 | static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
1069 | { | 1069 | { |
1070 | DHT *dht = object; | 1070 | DHT *dht = object; |
1071 | Node_format plain_nodes[MAX_SENT_NODES]; | 1071 | Node_format plain_nodes[MAX_SENT_NODES]; |
@@ -1419,7 +1419,7 @@ int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enable | |||
1419 | * | 1419 | * |
1420 | * return -1 if failure. | 1420 | * return -1 if failure. |
1421 | */ | 1421 | */ |
1422 | int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint32_t length) | 1422 | int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint16_t length) |
1423 | { | 1423 | { |
1424 | uint32_t i; | 1424 | uint32_t i; |
1425 | 1425 | ||
@@ -1514,7 +1514,7 @@ static int friend_iplist(const DHT *dht, IP_Port *ip_portlist, uint16_t friend_n | |||
1514 | * return ip for friend. | 1514 | * return ip for friend. |
1515 | * return number of nodes the packet was sent to. (Only works if more than (MAX_FRIEND_CLIENTS / 4). | 1515 | * return number of nodes the packet was sent to. (Only works if more than (MAX_FRIEND_CLIENTS / 4). |
1516 | */ | 1516 | */ |
1517 | int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint32_t length) | 1517 | int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint16_t length) |
1518 | { | 1518 | { |
1519 | int num = friend_number(dht, friend_id); | 1519 | int num = friend_number(dht, friend_id); |
1520 | 1520 | ||
@@ -1569,7 +1569,7 @@ int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *pack | |||
1569 | * | 1569 | * |
1570 | * return number of nodes the packet was sent to. | 1570 | * return number of nodes the packet was sent to. |
1571 | */ | 1571 | */ |
1572 | static int routeone_tofriend(DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint32_t length) | 1572 | static int routeone_tofriend(DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint16_t length) |
1573 | { | 1573 | { |
1574 | int num = friend_number(dht, friend_id); | 1574 | int num = friend_number(dht, friend_id); |
1575 | 1575 | ||
@@ -1667,7 +1667,7 @@ static int send_NATping(DHT *dht, const uint8_t *public_key, uint64_t ping_id, u | |||
1667 | 1667 | ||
1668 | /* Handle a received ping request for. */ | 1668 | /* Handle a received ping request for. */ |
1669 | static int handle_NATping(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, | 1669 | static int handle_NATping(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, |
1670 | uint32_t length) | 1670 | uint16_t length) |
1671 | { | 1671 | { |
1672 | if (length != sizeof(uint64_t) + 1) | 1672 | if (length != sizeof(uint64_t) + 1) |
1673 | return 1; | 1673 | return 1; |
@@ -1947,7 +1947,7 @@ static uint32_t have_nodes_closelist(DHT *dht, Node_format *nodes, uint16_t num) | |||
1947 | 1947 | ||
1948 | /* Handle a received hardening packet */ | 1948 | /* Handle a received hardening packet */ |
1949 | static int handle_hardening(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, | 1949 | static int handle_hardening(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, |
1950 | uint32_t length) | 1950 | uint16_t length) |
1951 | { | 1951 | { |
1952 | DHT *dht = object; | 1952 | DHT *dht = object; |
1953 | 1953 | ||
@@ -2208,7 +2208,7 @@ void cryptopacket_registerhandler(DHT *dht, uint8_t byte, cryptopacket_handler_c | |||
2208 | dht->cryptopackethandlers[byte].object = object; | 2208 | dht->cryptopackethandlers[byte].object = object; |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 2211 | static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
2212 | { | 2212 | { |
2213 | DHT *dht = object; | 2213 | DHT *dht = object; |
2214 | 2214 | ||
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index e1e14cd9..35000c87 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -186,7 +186,7 @@ typedef struct { | |||
186 | /*----------------------------------------------------------------------------------*/ | 186 | /*----------------------------------------------------------------------------------*/ |
187 | 187 | ||
188 | typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, const uint8_t *source_pubkey, | 188 | typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, const uint8_t *source_pubkey, |
189 | const uint8_t *data, uint32_t len); | 189 | const uint8_t *data, uint16_t len); |
190 | 190 | ||
191 | typedef struct { | 191 | typedef struct { |
192 | cryptopacket_handler_callback function; | 192 | cryptopacket_handler_callback function; |
@@ -369,13 +369,13 @@ int DHT_connect_after_load(DHT *dht); | |||
369 | * | 369 | * |
370 | * return -1 if failure. | 370 | * return -1 if failure. |
371 | */ | 371 | */ |
372 | int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint32_t length); | 372 | int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint16_t length); |
373 | 373 | ||
374 | /* Send the following packet to everyone who tells us they are connected to friend_id. | 374 | /* Send the following packet to everyone who tells us they are connected to friend_id. |
375 | * | 375 | * |
376 | * return number of nodes it sent the packet to. | 376 | * return number of nodes it sent the packet to. |
377 | */ | 377 | */ |
378 | int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint32_t length); | 378 | int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint16_t length); |
379 | 379 | ||
380 | /* Function to handle crypto packets. | 380 | /* Function to handle crypto packets. |
381 | */ | 381 | */ |
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index 74f10c98..f87f1348 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -280,7 +280,7 @@ int LAN_ip(IP ip) | |||
280 | return -1; | 280 | return -1; |
281 | } | 281 | } |
282 | 282 | ||
283 | static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 283 | static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
284 | { | 284 | { |
285 | DHT *dht = object; | 285 | DHT *dht = object; |
286 | 286 | ||
diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 7eb8e8c0..aca64e5a 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c | |||
@@ -550,7 +550,7 @@ int kill_friend_connection(Friend_Connections *fr_c, int friendcon_id) | |||
550 | * This function will be called every time a friend request packet is received. | 550 | * This function will be called every time a friend request packet is received. |
551 | */ | 551 | */ |
552 | void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_request_callback)(void *, const uint8_t *, | 552 | void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_request_callback)(void *, const uint8_t *, |
553 | const uint8_t *, uint32_t), void *object) | 553 | const uint8_t *, uint16_t), void *object) |
554 | { | 554 | { |
555 | fr_c->fr_request_callback = fr_request_callback; | 555 | fr_c->fr_request_callback = fr_request_callback; |
556 | fr_c->fr_request_object = object; | 556 | fr_c->fr_request_object = object; |
diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h index ef56fd94..b814eb0c 100644 --- a/toxcore/friend_connection.h +++ b/toxcore/friend_connection.h | |||
@@ -94,7 +94,7 @@ typedef struct { | |||
94 | Friend_Conn *conns; | 94 | Friend_Conn *conns; |
95 | uint32_t num_cons; | 95 | uint32_t num_cons; |
96 | 96 | ||
97 | int (*fr_request_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint32_t len); | 97 | int (*fr_request_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t len); |
98 | void *fr_request_object; | 98 | void *fr_request_object; |
99 | } Friend_Connections; | 99 | } Friend_Connections; |
100 | 100 | ||
@@ -174,7 +174,7 @@ int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_id, uint3 | |||
174 | * This function will be called every time a friend request is received. | 174 | * This function will be called every time a friend request is received. |
175 | */ | 175 | */ |
176 | void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_request_callback)(void *, const uint8_t *, | 176 | void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_request_callback)(void *, const uint8_t *, |
177 | const uint8_t *, uint32_t), void *object); | 177 | const uint8_t *, uint16_t), void *object); |
178 | 178 | ||
179 | /* Create new friend_connections instance. */ | 179 | /* Create new friend_connections instance. */ |
180 | Friend_Connections *new_friend_connections(Onion_Client *onion_c); | 180 | Friend_Connections *new_friend_connections(Onion_Client *onion_c); |
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index a7a1bcba..98937131 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -103,7 +103,7 @@ int remove_request_received(Friend_Requests *fr, const uint8_t *client_id) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length) | 106 | static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, const uint8_t *packet, uint16_t length) |
107 | { | 107 | { |
108 | Friend_Requests *fr = object; | 108 | Friend_Requests *fr = object; |
109 | 109 | ||
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 0072c5f2..693d3a76 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -183,7 +183,7 @@ static int handle_cookie_request(const Net_Crypto *c, uint8_t *request_plain, ui | |||
183 | 183 | ||
184 | /* Handle the cookie request packet (for raw UDP) | 184 | /* Handle the cookie request packet (for raw UDP) |
185 | */ | 185 | */ |
186 | static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 186 | static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
187 | { | 187 | { |
188 | Net_Crypto *c = object; | 188 | Net_Crypto *c = object; |
189 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; | 189 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; |
@@ -207,7 +207,7 @@ static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t | |||
207 | /* Handle the cookie request packet (for TCP) | 207 | /* Handle the cookie request packet (for TCP) |
208 | */ | 208 | */ |
209 | static int tcp_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection *TCP_con, uint8_t conn_id, | 209 | static int tcp_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection *TCP_con, uint8_t conn_id, |
210 | const uint8_t *packet, uint32_t length) | 210 | const uint8_t *packet, uint16_t length) |
211 | { | 211 | { |
212 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; | 212 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; |
213 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | 213 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; |
@@ -230,7 +230,7 @@ static int tcp_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection | |||
230 | /* Handle the cookie request packet (for TCP oob packets) | 230 | /* Handle the cookie request packet (for TCP oob packets) |
231 | */ | 231 | */ |
232 | static int tcp_oob_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection *TCP_con, | 232 | static int tcp_oob_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection *TCP_con, |
233 | const uint8_t *dht_public_key, const uint8_t *packet, uint32_t length) | 233 | const uint8_t *dht_public_key, const uint8_t *packet, uint16_t length) |
234 | { | 234 | { |
235 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; | 235 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; |
236 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | 236 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; |
@@ -261,7 +261,7 @@ static int tcp_oob_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connect | |||
261 | * return -1 on failure. | 261 | * return -1 on failure. |
262 | * return COOKIE_LENGTH on success. | 262 | * return COOKIE_LENGTH on success. |
263 | */ | 263 | */ |
264 | static int handle_cookie_response(uint8_t *cookie, uint64_t *number, const uint8_t *packet, uint32_t length, | 264 | static int handle_cookie_response(uint8_t *cookie, uint64_t *number, const uint8_t *packet, uint16_t length, |
265 | const uint8_t *shared_key) | 265 | const uint8_t *shared_key) |
266 | { | 266 | { |
267 | if (length != COOKIE_RESPONSE_LENGTH) | 267 | if (length != COOKIE_RESPONSE_LENGTH) |
@@ -335,7 +335,7 @@ static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const u | |||
335 | * return 0 on success. | 335 | * return 0 on success. |
336 | */ | 336 | */ |
337 | static int handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk, | 337 | static int handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk, |
338 | uint8_t *dht_public_key, uint8_t *cookie, const uint8_t *packet, uint32_t length, const uint8_t *expected_real_pk) | 338 | uint8_t *dht_public_key, uint8_t *cookie, const uint8_t *packet, uint16_t length, const uint8_t *expected_real_pk) |
339 | { | 339 | { |
340 | if (length != HANDSHAKE_PACKET_LENGTH) | 340 | if (length != HANDSHAKE_PACKET_LENGTH) |
341 | return -1; | 341 | return -1; |
@@ -764,7 +764,7 @@ static int send_data_packet(Net_Crypto *c, int crypt_connection_id, const uint8_ | |||
764 | * return 0 on success. | 764 | * return 0 on success. |
765 | */ | 765 | */ |
766 | static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint32_t buffer_start, uint32_t num, | 766 | static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint32_t buffer_start, uint32_t num, |
767 | const uint8_t *data, uint32_t length) | 767 | const uint8_t *data, uint16_t length) |
768 | { | 768 | { |
769 | if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) | 769 | if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) |
770 | return -1; | 770 | return -1; |
@@ -784,7 +784,7 @@ static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint3 | |||
784 | /* return -1 if data could not be put in packet queue. | 784 | /* return -1 if data could not be put in packet queue. |
785 | * return positive packet number if data was put into the queue. | 785 | * return positive packet number if data was put into the queue. |
786 | */ | 786 | */ |
787 | static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length, | 787 | static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length, |
788 | uint8_t congestion_control) | 788 | uint8_t congestion_control) |
789 | { | 789 | { |
790 | if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) | 790 | if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) |
@@ -2305,7 +2305,7 @@ static int crypto_id_ip_port(const Net_Crypto *c, IP_Port ip_port) | |||
2305 | * Crypto data packets. | 2305 | * Crypto data packets. |
2306 | * | 2306 | * |
2307 | */ | 2307 | */ |
2308 | static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 2308 | static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
2309 | { | 2309 | { |
2310 | if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE) | 2310 | if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE) |
2311 | return 1; | 2311 | return 1; |
@@ -2498,7 +2498,7 @@ uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_connecti | |||
2498 | * | 2498 | * |
2499 | * congestion_control: should congestion control apply to this packet? | 2499 | * congestion_control: should congestion control apply to this packet? |
2500 | */ | 2500 | */ |
2501 | int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length, | 2501 | int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length, |
2502 | uint8_t congestion_control) | 2502 | uint8_t congestion_control) |
2503 | { | 2503 | { |
2504 | if (length == 0) | 2504 | if (length == 0) |
@@ -2563,7 +2563,7 @@ int cryptpacket_received(Net_Crypto *c, int crypt_connection_id, uint32_t packet | |||
2563 | * | 2563 | * |
2564 | * Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*) | 2564 | * Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*) |
2565 | */ | 2565 | */ |
2566 | int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length) | 2566 | int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length) |
2567 | { | 2567 | { |
2568 | if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) | 2568 | if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) |
2569 | return -1; | 2569 | return -1; |
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index b9f9e31c..0726207b 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h | |||
@@ -325,7 +325,7 @@ uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_connecti | |||
325 | * | 325 | * |
326 | * congestion_control: should congestion control apply to this packet? | 326 | * congestion_control: should congestion control apply to this packet? |
327 | */ | 327 | */ |
328 | int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length, | 328 | int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length, |
329 | uint8_t congestion_control); | 329 | uint8_t congestion_control); |
330 | 330 | ||
331 | /* Check if packet_number was received by the other side. | 331 | /* Check if packet_number was received by the other side. |
@@ -342,7 +342,7 @@ int cryptpacket_received(Net_Crypto *c, int crypt_connection_id, uint32_t packet | |||
342 | * | 342 | * |
343 | * Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*) | 343 | * Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*) |
344 | */ | 344 | */ |
345 | int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length); | 345 | int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length); |
346 | 346 | ||
347 | /* Add a tcp relay, associating it to a crypt_connection_id. | 347 | /* Add a tcp relay, associating it to a crypt_connection_id. |
348 | * | 348 | * |
diff --git a/toxcore/network.c b/toxcore/network.c index 5b267e12..35ef5221 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -281,7 +281,7 @@ uint64_t current_time_monotonic(void) | |||
281 | /* Basic network functions: | 281 | /* Basic network functions: |
282 | * Function to send packet(data) of length length to ip_port. | 282 | * Function to send packet(data) of length length to ip_port. |
283 | */ | 283 | */ |
284 | int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint32_t length) | 284 | int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint16_t length) |
285 | { | 285 | { |
286 | if (net->family == 0) /* Socket not initialized */ | 286 | if (net->family == 0) /* Socket not initialized */ |
287 | return -1; | 287 | return -1; |
diff --git a/toxcore/network.h b/toxcore/network.h index 25761d73..ccda7ae9 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -277,7 +277,7 @@ int addr_resolve_or_parse_ip(const char *address, IP *to, IP *extra); | |||
277 | * Packet data is put into data. | 277 | * Packet data is put into data. |
278 | * Packet length is put into length. | 278 | * Packet length is put into length. |
279 | */ | 279 | */ |
280 | typedef int (*packet_handler_callback)(void *object, IP_Port ip_port, const uint8_t *data, uint32_t len); | 280 | typedef int (*packet_handler_callback)(void *object, IP_Port ip_port, const uint8_t *data, uint16_t len); |
281 | 281 | ||
282 | typedef struct { | 282 | typedef struct { |
283 | packet_handler_callback function; | 283 | packet_handler_callback function; |
@@ -338,7 +338,7 @@ uint64_t current_time_monotonic(void); | |||
338 | /* Basic network functions: */ | 338 | /* Basic network functions: */ |
339 | 339 | ||
340 | /* Function to send packet(data) of length length to ip_port. */ | 340 | /* Function to send packet(data) of length length to ip_port. */ |
341 | int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint32_t length); | 341 | int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint16_t length); |
342 | 342 | ||
343 | /* Function to call when packet beginning with byte is received. */ | 343 | /* Function to call when packet beginning with byte is received. */ |
344 | void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object); | 344 | void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object); |
diff --git a/toxcore/onion.c b/toxcore/onion.c index 938b861e..963c9b11 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -94,7 +94,7 @@ int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *n | |||
94 | * return length of created packet on success. | 94 | * return length of created packet on success. |
95 | */ | 95 | */ |
96 | int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, | 96 | int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, |
97 | const uint8_t *data, uint32_t length) | 97 | const uint8_t *data, uint16_t length) |
98 | { | 98 | { |
99 | if (1 + length + SEND_1 > max_packet_length || length == 0) | 99 | if (1 + length + SEND_1 > max_packet_length || length == 0) |
100 | return -1; | 100 | return -1; |
@@ -151,7 +151,7 @@ int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion | |||
151 | * return length of created packet on success. | 151 | * return length of created packet on success. |
152 | */ | 152 | */ |
153 | int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, | 153 | int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, |
154 | const uint8_t *data, uint32_t length) | 154 | const uint8_t *data, uint16_t length) |
155 | { | 155 | { |
156 | if (crypto_box_NONCEBYTES + SIZE_IPPORT + SEND_BASE * 2 + length > max_packet_length || length == 0) | 156 | if (crypto_box_NONCEBYTES + SIZE_IPPORT + SEND_BASE * 2 + length > max_packet_length || length == 0) |
157 | return -1; | 157 | return -1; |
@@ -197,7 +197,7 @@ int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const O | |||
197 | * return -1 on failure. | 197 | * return -1 on failure. |
198 | * return 0 on success. | 198 | * return 0 on success. |
199 | */ | 199 | */ |
200 | int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length) | 200 | int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint16_t length) |
201 | { | 201 | { |
202 | uint8_t packet[ONION_MAX_PACKET_SIZE]; | 202 | uint8_t packet[ONION_MAX_PACKET_SIZE]; |
203 | int len = create_onion_packet(packet, sizeof(packet), path, dest, data, length); | 203 | int len = create_onion_packet(packet, sizeof(packet), path, dest, data, length); |
@@ -217,7 +217,7 @@ int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest | |||
217 | * return -1 on failure. | 217 | * return -1 on failure. |
218 | * return 0 on success. | 218 | * return 0 on success. |
219 | */ | 219 | */ |
220 | int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret) | 220 | int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint16_t length, const uint8_t *ret) |
221 | { | 221 | { |
222 | if (length > ONION_RESPONSE_MAX_DATA_SIZE || length == 0) | 222 | if (length > ONION_RESPONSE_MAX_DATA_SIZE || length == 0) |
223 | return -1; | 223 | return -1; |
@@ -233,7 +233,7 @@ int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, | |||
233 | return 0; | 233 | return 0; |
234 | } | 234 | } |
235 | 235 | ||
236 | static int handle_send_initial(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 236 | static int handle_send_initial(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
237 | { | 237 | { |
238 | Onion *onion = object; | 238 | Onion *onion = object; |
239 | 239 | ||
@@ -257,7 +257,7 @@ static int handle_send_initial(void *object, IP_Port source, const uint8_t *pack | |||
257 | return onion_send_1(onion, plain, len, source, packet + 1); | 257 | return onion_send_1(onion, plain, len, source, packet + 1); |
258 | } | 258 | } |
259 | 259 | ||
260 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce) | 260 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce) |
261 | { | 261 | { |
262 | if (len > ONION_MAX_PACKET_SIZE + SIZE_IPPORT - (1 + crypto_box_NONCEBYTES + ONION_RETURN_1)) | 262 | if (len > ONION_MAX_PACKET_SIZE + SIZE_IPPORT - (1 + crypto_box_NONCEBYTES + ONION_RETURN_1)) |
263 | return 1; | 263 | return 1; |
@@ -276,7 +276,7 @@ int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port | |||
276 | data[0] = NET_PACKET_ONION_SEND_1; | 276 | data[0] = NET_PACKET_ONION_SEND_1; |
277 | memcpy(data + 1, nonce, crypto_box_NONCEBYTES); | 277 | memcpy(data + 1, nonce, crypto_box_NONCEBYTES); |
278 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); | 278 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); |
279 | uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); | 279 | uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); |
280 | uint8_t *ret_part = data + data_len; | 280 | uint8_t *ret_part = data + data_len; |
281 | new_nonce(ret_part); | 281 | new_nonce(ret_part); |
282 | len = encrypt_data_symmetric(onion->secret_symmetric_key, ret_part, ip_port, SIZE_IPPORT, | 282 | len = encrypt_data_symmetric(onion->secret_symmetric_key, ret_part, ip_port, SIZE_IPPORT, |
@@ -293,7 +293,7 @@ int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port | |||
293 | return 0; | 293 | return 0; |
294 | } | 294 | } |
295 | 295 | ||
296 | static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 296 | static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
297 | { | 297 | { |
298 | Onion *onion = object; | 298 | Onion *onion = object; |
299 | 299 | ||
@@ -322,7 +322,7 @@ static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, ui | |||
322 | data[0] = NET_PACKET_ONION_SEND_2; | 322 | data[0] = NET_PACKET_ONION_SEND_2; |
323 | memcpy(data + 1, packet + 1, crypto_box_NONCEBYTES); | 323 | memcpy(data + 1, packet + 1, crypto_box_NONCEBYTES); |
324 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); | 324 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); |
325 | uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); | 325 | uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); |
326 | uint8_t *ret_part = data + data_len; | 326 | uint8_t *ret_part = data + data_len; |
327 | new_nonce(ret_part); | 327 | new_nonce(ret_part); |
328 | uint8_t ret_data[RETURN_1 + SIZE_IPPORT]; | 328 | uint8_t ret_data[RETURN_1 + SIZE_IPPORT]; |
@@ -342,7 +342,7 @@ static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, ui | |||
342 | return 0; | 342 | return 0; |
343 | } | 343 | } |
344 | 344 | ||
345 | static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 345 | static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
346 | { | 346 | { |
347 | Onion *onion = object; | 347 | Onion *onion = object; |
348 | 348 | ||
@@ -369,7 +369,7 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui | |||
369 | 369 | ||
370 | uint8_t data[ONION_MAX_PACKET_SIZE]; | 370 | uint8_t data[ONION_MAX_PACKET_SIZE]; |
371 | memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT); | 371 | memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT); |
372 | uint32_t data_len = (len - SIZE_IPPORT); | 372 | uint16_t data_len = (len - SIZE_IPPORT); |
373 | uint8_t *ret_part = data + (len - SIZE_IPPORT); | 373 | uint8_t *ret_part = data + (len - SIZE_IPPORT); |
374 | new_nonce(ret_part); | 374 | new_nonce(ret_part); |
375 | uint8_t ret_data[RETURN_2 + SIZE_IPPORT]; | 375 | uint8_t ret_data[RETURN_2 + SIZE_IPPORT]; |
@@ -390,7 +390,7 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui | |||
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 393 | static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
394 | { | 394 | { |
395 | Onion *onion = object; | 395 | Onion *onion = object; |
396 | 396 | ||
@@ -416,7 +416,7 @@ static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, ui | |||
416 | data[0] = NET_PACKET_ONION_RECV_2; | 416 | data[0] = NET_PACKET_ONION_RECV_2; |
417 | memcpy(data + 1, plain + SIZE_IPPORT, RETURN_2); | 417 | memcpy(data + 1, plain + SIZE_IPPORT, RETURN_2); |
418 | memcpy(data + 1 + RETURN_2, packet + 1 + RETURN_3, length - (1 + RETURN_3)); | 418 | memcpy(data + 1 + RETURN_2, packet + 1 + RETURN_3, length - (1 + RETURN_3)); |
419 | uint32_t data_len = 1 + RETURN_2 + (length - (1 + RETURN_3)); | 419 | uint16_t data_len = 1 + RETURN_2 + (length - (1 + RETURN_3)); |
420 | 420 | ||
421 | if ((uint32_t)sendpacket(onion->net, send_to, data, data_len) != data_len) | 421 | if ((uint32_t)sendpacket(onion->net, send_to, data, data_len) != data_len) |
422 | return 1; | 422 | return 1; |
@@ -424,7 +424,7 @@ static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, ui | |||
424 | return 0; | 424 | return 0; |
425 | } | 425 | } |
426 | 426 | ||
427 | static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 427 | static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
428 | { | 428 | { |
429 | Onion *onion = object; | 429 | Onion *onion = object; |
430 | 430 | ||
@@ -450,7 +450,7 @@ static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, ui | |||
450 | data[0] = NET_PACKET_ONION_RECV_1; | 450 | data[0] = NET_PACKET_ONION_RECV_1; |
451 | memcpy(data + 1, plain + SIZE_IPPORT, RETURN_1); | 451 | memcpy(data + 1, plain + SIZE_IPPORT, RETURN_1); |
452 | memcpy(data + 1 + RETURN_1, packet + 1 + RETURN_2, length - (1 + RETURN_2)); | 452 | memcpy(data + 1 + RETURN_1, packet + 1 + RETURN_2, length - (1 + RETURN_2)); |
453 | uint32_t data_len = 1 + RETURN_1 + (length - (1 + RETURN_2)); | 453 | uint16_t data_len = 1 + RETURN_1 + (length - (1 + RETURN_2)); |
454 | 454 | ||
455 | if ((uint32_t)sendpacket(onion->net, send_to, data, data_len) != data_len) | 455 | if ((uint32_t)sendpacket(onion->net, send_to, data, data_len) != data_len) |
456 | return 1; | 456 | return 1; |
@@ -458,7 +458,7 @@ static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, ui | |||
458 | return 0; | 458 | return 0; |
459 | } | 459 | } |
460 | 460 | ||
461 | static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 461 | static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
462 | { | 462 | { |
463 | Onion *onion = object; | 463 | Onion *onion = object; |
464 | 464 | ||
@@ -480,7 +480,7 @@ static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, ui | |||
480 | IP_Port send_to; | 480 | IP_Port send_to; |
481 | ipport_unpack(&send_to, plain); | 481 | ipport_unpack(&send_to, plain); |
482 | 482 | ||
483 | uint32_t data_len = length - (1 + RETURN_1); | 483 | uint16_t data_len = length - (1 + RETURN_1); |
484 | 484 | ||
485 | if (onion->recv_1_function && send_to.ip.family != AF_INET && send_to.ip.family != AF_INET6) | 485 | if (onion->recv_1_function && send_to.ip.family != AF_INET && send_to.ip.family != AF_INET6) |
486 | return onion->recv_1_function(onion->callback_object, send_to, packet + (1 + RETURN_1), data_len); | 486 | return onion->recv_1_function(onion->callback_object, send_to, packet + (1 + RETURN_1), data_len); |
diff --git a/toxcore/onion.h b/toxcore/onion.h index e8e7042c..1e80eba3 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h | |||
@@ -90,7 +90,7 @@ int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *n | |||
90 | * return length of created packet on success. | 90 | * return length of created packet on success. |
91 | */ | 91 | */ |
92 | int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, | 92 | int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, |
93 | const uint8_t *data, uint32_t length); | 93 | const uint8_t *data, uint16_t length); |
94 | 94 | ||
95 | 95 | ||
96 | /* Create a onion packet to be sent over tcp. | 96 | /* Create a onion packet to be sent over tcp. |
@@ -103,7 +103,7 @@ int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion | |||
103 | * return length of created packet on success. | 103 | * return length of created packet on success. |
104 | */ | 104 | */ |
105 | int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, | 105 | int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, |
106 | const uint8_t *data, uint32_t length); | 106 | const uint8_t *data, uint16_t length); |
107 | 107 | ||
108 | /* Create and send a onion packet. | 108 | /* Create and send a onion packet. |
109 | * | 109 | * |
@@ -113,7 +113,7 @@ int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const O | |||
113 | * return -1 on failure. | 113 | * return -1 on failure. |
114 | * return 0 on success. | 114 | * return 0 on success. |
115 | */ | 115 | */ |
116 | int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length); | 116 | int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint16_t length); |
117 | 117 | ||
118 | /* Create and send a onion response sent initially to dest with. | 118 | /* Create and send a onion response sent initially to dest with. |
119 | * Maximum length of data is ONION_RESPONSE_MAX_DATA_SIZE. | 119 | * Maximum length of data is ONION_RESPONSE_MAX_DATA_SIZE. |
@@ -121,7 +121,7 @@ int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest | |||
121 | * return -1 on failure. | 121 | * return -1 on failure. |
122 | * return 0 on success. | 122 | * return 0 on success. |
123 | */ | 123 | */ |
124 | int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret); | 124 | int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint16_t length, const uint8_t *ret); |
125 | 125 | ||
126 | /* Function to handle/send received decrypted versions of the packet sent with send_onion_packet. | 126 | /* Function to handle/send received decrypted versions of the packet sent with send_onion_packet. |
127 | * | 127 | * |
@@ -133,11 +133,11 @@ int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, | |||
133 | * Source family must be set to something else than AF_INET6 or AF_INET so that the callback gets called | 133 | * Source family must be set to something else than AF_INET6 or AF_INET so that the callback gets called |
134 | * when the response is received. | 134 | * when the response is received. |
135 | */ | 135 | */ |
136 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce); | 136 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce); |
137 | 137 | ||
138 | /* Set the callback to be called when the dest ip_port doesn't have AF_INET6 or AF_INET as the family. | 138 | /* Set the callback to be called when the dest ip_port doesn't have AF_INET6 or AF_INET as the family. |
139 | * | 139 | * |
140 | * Format: function(void *object, IP_Port dest, uint8_t *data, uint32_t length) | 140 | * Format: function(void *object, IP_Port dest, uint8_t *data, uint16_t length) |
141 | */ | 141 | */ |
142 | void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t), | 142 | void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t), |
143 | void *object); | 143 | void *object); |
diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index 2b0de595..32442797 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c | |||
@@ -207,7 +207,7 @@ static void generate_ping_id(const Onion_Announce *onion_a, uint64_t time, const | |||
207 | */ | 207 | */ |
208 | static int in_entries(const Onion_Announce *onion_a, const uint8_t *public_key) | 208 | static int in_entries(const Onion_Announce *onion_a, const uint8_t *public_key) |
209 | { | 209 | { |
210 | uint32_t i; | 210 | unsigned int i; |
211 | 211 | ||
212 | for (i = 0; i < ONION_ANNOUNCE_MAX_ENTRIES; ++i) { | 212 | for (i = 0; i < ONION_ANNOUNCE_MAX_ENTRIES; ++i) { |
213 | if (!is_timeout(onion_a->entries[i].time, ONION_ANNOUNCE_TIMEOUT) | 213 | if (!is_timeout(onion_a->entries[i].time, ONION_ANNOUNCE_TIMEOUT) |
@@ -258,7 +258,7 @@ static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const ui | |||
258 | 258 | ||
259 | int pos = in_entries(onion_a, public_key); | 259 | int pos = in_entries(onion_a, public_key); |
260 | 260 | ||
261 | uint32_t i; | 261 | unsigned int i; |
262 | 262 | ||
263 | if (pos == -1) { | 263 | if (pos == -1) { |
264 | for (i = 0; i < ONION_ANNOUNCE_MAX_ENTRIES; ++i) { | 264 | for (i = 0; i < ONION_ANNOUNCE_MAX_ENTRIES; ++i) { |
@@ -286,7 +286,7 @@ static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const ui | |||
286 | return in_entries(onion_a, public_key); | 286 | return in_entries(onion_a, public_key); |
287 | } | 287 | } |
288 | 288 | ||
289 | static int handle_announce_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 289 | static int handle_announce_request(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
290 | { | 290 | { |
291 | Onion_Announce *onion_a = object; | 291 | Onion_Announce *onion_a = object; |
292 | 292 | ||
@@ -325,8 +325,8 @@ static int handle_announce_request(void *object, IP_Port source, const uint8_t * | |||
325 | 325 | ||
326 | /*Respond with a announce response packet*/ | 326 | /*Respond with a announce response packet*/ |
327 | Node_format nodes_list[MAX_SENT_NODES]; | 327 | Node_format nodes_list[MAX_SENT_NODES]; |
328 | uint32_t num_nodes = get_close_nodes(onion_a->dht, plain + ONION_PING_ID_SIZE, nodes_list, 0, LAN_ip(source.ip) == 0, | 328 | unsigned int num_nodes = get_close_nodes(onion_a->dht, plain + ONION_PING_ID_SIZE, nodes_list, 0, |
329 | 1); | 329 | LAN_ip(source.ip) == 0, 1); |
330 | uint8_t nonce[crypto_box_NONCEBYTES]; | 330 | uint8_t nonce[crypto_box_NONCEBYTES]; |
331 | random_nonce(nonce); | 331 | random_nonce(nonce); |
332 | 332 | ||
@@ -379,7 +379,7 @@ static int handle_announce_request(void *object, IP_Port source, const uint8_t * | |||
379 | return 0; | 379 | return 0; |
380 | } | 380 | } |
381 | 381 | ||
382 | static int handle_data_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 382 | static int handle_data_request(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
383 | { | 383 | { |
384 | Onion_Announce *onion_a = object; | 384 | Onion_Announce *onion_a = object; |
385 | 385 | ||
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index fda230b7..a069de23 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -129,7 +129,7 @@ static uint16_t random_nodes_path_onion(const Onion_Client *onion_c, Node_format | |||
129 | */ | 129 | */ |
130 | static int is_path_used(const Onion_Client_Paths *onion_paths, const Node_format *nodes) | 130 | static int is_path_used(const Onion_Client_Paths *onion_paths, const Node_format *nodes) |
131 | { | 131 | { |
132 | uint32_t i; | 132 | unsigned int i; |
133 | 133 | ||
134 | for (i = 0; i < NUMBER_ONION_PATHS; ++i) { | 134 | for (i = 0; i < NUMBER_ONION_PATHS; ++i) { |
135 | if (is_timeout(onion_paths->last_path_success[i], ONION_PATH_TIMEOUT)) { | 135 | if (is_timeout(onion_paths->last_path_success[i], ONION_PATH_TIMEOUT)) { |
@@ -222,7 +222,7 @@ static uint32_t set_path_timeouts(Onion_Client *onion_c, uint32_t num, uint32_t | |||
222 | * return 0 on success. | 222 | * return 0 on success. |
223 | */ | 223 | */ |
224 | static int send_onion_packet_tcp_udp(const Onion_Client *onion_c, const Onion_Path *path, IP_Port dest, | 224 | static int send_onion_packet_tcp_udp(const Onion_Client *onion_c, const Onion_Path *path, IP_Port dest, |
225 | const uint8_t *data, uint32_t length) | 225 | const uint8_t *data, uint16_t length) |
226 | { | 226 | { |
227 | if (path->ip_port1.ip.family == AF_INET || path->ip_port1.ip.family == AF_INET6) { | 227 | if (path->ip_port1.ip.family == AF_INET || path->ip_port1.ip.family == AF_INET6) { |
228 | uint8_t packet[ONION_MAX_PACKET_SIZE]; | 228 | uint8_t packet[ONION_MAX_PACKET_SIZE]; |
@@ -411,7 +411,7 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t | |||
411 | qsort(list_nodes, MAX_ONION_CLIENTS, sizeof(Onion_Node), cmp_entry); | 411 | qsort(list_nodes, MAX_ONION_CLIENTS, sizeof(Onion_Node), cmp_entry); |
412 | 412 | ||
413 | int index = -1, stored = 0; | 413 | int index = -1, stored = 0; |
414 | uint32_t i; | 414 | unsigned int i; |
415 | 415 | ||
416 | if (is_timeout(list_nodes[0].timestamp, ONION_NODE_TIMEOUT) | 416 | if (is_timeout(list_nodes[0].timestamp, ONION_NODE_TIMEOUT) |
417 | || id_closest(reference_id, list_nodes[0].client_id, public_key) == 2) { | 417 | || id_closest(reference_id, list_nodes[0].client_id, public_key) == 2) { |
@@ -453,7 +453,7 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t | |||
453 | 453 | ||
454 | static int good_to_ping(Last_Pinged *last_pinged, uint8_t *last_pinged_index, const uint8_t *client_id) | 454 | static int good_to_ping(Last_Pinged *last_pinged, uint8_t *last_pinged_index, const uint8_t *client_id) |
455 | { | 455 | { |
456 | uint32_t i; | 456 | unsigned int i; |
457 | 457 | ||
458 | for (i = 0; i < MAX_STORED_PINGED_NODES; ++i) { | 458 | for (i = 0; i < MAX_STORED_PINGED_NODES; ++i) { |
459 | if (!is_timeout(last_pinged[i].timestamp, MIN_NODE_PING_TIME)) | 459 | if (!is_timeout(last_pinged[i].timestamp, MIN_NODE_PING_TIME)) |
@@ -494,7 +494,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for | |||
494 | last_pinged_index = &onion_c->friends_list[num - 1].last_pinged_index; | 494 | last_pinged_index = &onion_c->friends_list[num - 1].last_pinged_index; |
495 | } | 495 | } |
496 | 496 | ||
497 | uint32_t i, j; | 497 | unsigned int i, j; |
498 | int lan_ips_accepted = (LAN_ip(source.ip) == 0); | 498 | int lan_ips_accepted = (LAN_ip(source.ip) == 0); |
499 | 499 | ||
500 | for (i = 0; i < num_nodes; ++i) { | 500 | for (i = 0; i < num_nodes; ++i) { |
@@ -521,7 +521,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for | |||
521 | return 0; | 521 | return 0; |
522 | } | 522 | } |
523 | 523 | ||
524 | static int handle_announce_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 524 | static int handle_announce_response(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
525 | { | 525 | { |
526 | Onion_Client *onion_c = object; | 526 | Onion_Client *onion_c = object; |
527 | 527 | ||
@@ -579,7 +579,7 @@ static int handle_announce_response(void *object, IP_Port source, const uint8_t | |||
579 | 579 | ||
580 | #define DATA_IN_RESPONSE_MIN_SIZE ONION_DATA_IN_RESPONSE_MIN_SIZE | 580 | #define DATA_IN_RESPONSE_MIN_SIZE ONION_DATA_IN_RESPONSE_MIN_SIZE |
581 | 581 | ||
582 | static int handle_data_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length) | 582 | static int handle_data_response(void *object, IP_Port source, const uint8_t *packet, uint16_t length) |
583 | { | 583 | { |
584 | Onion_Client *onion_c = object; | 584 | Onion_Client *onion_c = object; |
585 | 585 | ||
@@ -614,7 +614,7 @@ static int handle_data_response(void *object, IP_Port source, const uint8_t *pac | |||
614 | #define FAKEID_DATA_ID 156 | 614 | #define FAKEID_DATA_ID 156 |
615 | #define FAKEID_DATA_MIN_LENGTH (1 + sizeof(uint64_t) + crypto_box_PUBLICKEYBYTES) | 615 | #define FAKEID_DATA_MIN_LENGTH (1 + sizeof(uint64_t) + crypto_box_PUBLICKEYBYTES) |
616 | #define FAKEID_DATA_MAX_LENGTH (FAKEID_DATA_MIN_LENGTH + sizeof(Node_format)*MAX_SENT_NODES) | 616 | #define FAKEID_DATA_MAX_LENGTH (FAKEID_DATA_MIN_LENGTH + sizeof(Node_format)*MAX_SENT_NODES) |
617 | static int handle_fakeid_announce(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint32_t length) | 617 | static int handle_fakeid_announce(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t length) |
618 | { | 618 | { |
619 | Onion_Client *onion_c = object; | 619 | Onion_Client *onion_c = object; |
620 | 620 | ||
@@ -700,7 +700,7 @@ static int handle_tcp_onion(void *object, const uint8_t *data, uint16_t length) | |||
700 | * return the number of packets sent on success | 700 | * return the number of packets sent on success |
701 | * return -1 on failure. | 701 | * return -1 on failure. |
702 | */ | 702 | */ |
703 | int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_t length) | 703 | int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint16_t length) |
704 | { | 704 | { |
705 | if ((uint32_t)friend_num >= onion_c->num_friends) | 705 | if ((uint32_t)friend_num >= onion_c->num_friends) |
706 | return -1; | 706 | return -1; |
@@ -722,7 +722,7 @@ int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t * | |||
722 | if ((uint32_t)len + crypto_box_PUBLICKEYBYTES != sizeof(packet)) | 722 | if ((uint32_t)len + crypto_box_PUBLICKEYBYTES != sizeof(packet)) |
723 | return -1; | 723 | return -1; |
724 | 724 | ||
725 | uint32_t i, good_nodes[MAX_ONION_CLIENTS], num_good = 0, num_nodes = 0; | 725 | unsigned int i, good_nodes[MAX_ONION_CLIENTS], num_good = 0, num_nodes = 0; |
726 | Onion_Path path[MAX_ONION_CLIENTS]; | 726 | Onion_Path path[MAX_ONION_CLIENTS]; |
727 | Onion_Node *list_nodes = onion_c->friends_list[friend_num].clients_list; | 727 | Onion_Node *list_nodes = onion_c->friends_list[friend_num].clients_list; |
728 | 728 | ||
@@ -744,7 +744,7 @@ int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t * | |||
744 | if (num_good < (num_nodes / 4) + 1) | 744 | if (num_good < (num_nodes / 4) + 1) |
745 | return -1; | 745 | return -1; |
746 | 746 | ||
747 | uint32_t good = 0; | 747 | unsigned int good = 0; |
748 | 748 | ||
749 | for (i = 0; i < num_good; ++i) { | 749 | for (i = 0; i < num_good; ++i) { |
750 | uint8_t o_packet[ONION_MAX_PACKET_SIZE]; | 750 | uint8_t o_packet[ONION_MAX_PACKET_SIZE]; |
@@ -768,7 +768,7 @@ int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t * | |||
768 | * return the number of packets sent on success | 768 | * return the number of packets sent on success |
769 | * return -1 on failure. | 769 | * return -1 on failure. |
770 | */ | 770 | */ |
771 | static int send_dht_fakeid(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_t length) | 771 | static int send_dht_fakeid(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint16_t length) |
772 | { | 772 | { |
773 | if ((uint32_t)friend_num >= onion_c->num_friends) | 773 | if ((uint32_t)friend_num >= onion_c->num_friends) |
774 | return -1; | 774 | return -1; |
@@ -799,7 +799,7 @@ static int send_dht_fakeid(const Onion_Client *onion_c, int friend_num, const ui | |||
799 | } | 799 | } |
800 | 800 | ||
801 | static int handle_dht_fakeid(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, | 801 | static int handle_dht_fakeid(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet, |
802 | uint32_t length) | 802 | uint16_t length) |
803 | { | 803 | { |
804 | Onion_Client *onion_c = object; | 804 | Onion_Client *onion_c = object; |
805 | 805 | ||
@@ -880,7 +880,7 @@ static int send_fakeid_announce(const Onion_Client *onion_c, uint16_t friend_num | |||
880 | */ | 880 | */ |
881 | int onion_friend_num(const Onion_Client *onion_c, const uint8_t *client_id) | 881 | int onion_friend_num(const Onion_Client *onion_c, const uint8_t *client_id) |
882 | { | 882 | { |
883 | uint32_t i; | 883 | unsigned int i; |
884 | 884 | ||
885 | for (i = 0; i < onion_c->num_friends; ++i) { | 885 | for (i = 0; i < onion_c->num_friends; ++i) { |
886 | if (onion_c->friends_list[i].status == 0) | 886 | if (onion_c->friends_list[i].status == 0) |
@@ -927,7 +927,7 @@ int onion_addfriend(Onion_Client *onion_c, const uint8_t *client_id) | |||
927 | if (num != -1) | 927 | if (num != -1) |
928 | return num; | 928 | return num; |
929 | 929 | ||
930 | uint32_t i, index = ~0; | 930 | unsigned int i, index = ~0; |
931 | 931 | ||
932 | for (i = 0; i < onion_c->num_friends; ++i) { | 932 | for (i = 0; i < onion_c->num_friends; ++i) { |
933 | if (onion_c->friends_list[i].status == 0) { | 933 | if (onion_c->friends_list[i].status == 0) { |
@@ -965,7 +965,7 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num) | |||
965 | // DHT_delfriend(onion_c->dht, onion_c->friends_list[friend_num].fake_client_id, 0); | 965 | // DHT_delfriend(onion_c->dht, onion_c->friends_list[friend_num].fake_client_id, 0); |
966 | 966 | ||
967 | memset(&(onion_c->friends_list[friend_num]), 0, sizeof(Onion_Friend)); | 967 | memset(&(onion_c->friends_list[friend_num]), 0, sizeof(Onion_Friend)); |
968 | uint32_t i; | 968 | unsigned int i; |
969 | 969 | ||
970 | for (i = onion_c->num_friends; i != 0; --i) { | 970 | for (i = onion_c->num_friends; i != 0; --i) { |
971 | if (onion_c->friends_list[i - 1].status != 0) | 971 | if (onion_c->friends_list[i - 1].status != 0) |
@@ -1121,7 +1121,7 @@ static void populate_path_nodes(Onion_Client *onion_c) | |||
1121 | uint32_t random_num = rand(); | 1121 | uint32_t random_num = rand(); |
1122 | memcpy(client_id, &random_num, sizeof(random_num)); | 1122 | memcpy(client_id, &random_num, sizeof(random_num)); |
1123 | 1123 | ||
1124 | uint32_t num_nodes = get_close_nodes(onion_c->dht, client_id, nodes_list, (rand() % 2) ? AF_INET : AF_INET6, 1, 0); | 1124 | unsigned int num_nodes = get_close_nodes(onion_c->dht, client_id, nodes_list, (rand() % 2) ? AF_INET : AF_INET6, 1, 0); |
1125 | unsigned int i; | 1125 | unsigned int i; |
1126 | 1126 | ||
1127 | for (i = 0; i < num_nodes; ++i) { | 1127 | for (i = 0; i < num_nodes; ++i) { |
@@ -1143,12 +1143,12 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum) | |||
1143 | if (onion_c->friends_list[friendnum].status == 0) | 1143 | if (onion_c->friends_list[friendnum].status == 0) |
1144 | return; | 1144 | return; |
1145 | 1145 | ||
1146 | uint32_t interval = ANNOUNCE_FRIEND; | 1146 | unsigned int interval = ANNOUNCE_FRIEND; |
1147 | 1147 | ||
1148 | if (onion_c->friends_list[friendnum].run_count < RUN_COUNT_FRIEND_ANNOUNCE_BEGINNING) | 1148 | if (onion_c->friends_list[friendnum].run_count < RUN_COUNT_FRIEND_ANNOUNCE_BEGINNING) |
1149 | interval = ANNOUNCE_FRIEND_BEGINNING; | 1149 | interval = ANNOUNCE_FRIEND_BEGINNING; |
1150 | 1150 | ||
1151 | uint32_t i, count = 0; | 1151 | unsigned int i, count = 0; |
1152 | Onion_Node *list_nodes = onion_c->friends_list[friendnum].clients_list; | 1152 | Onion_Node *list_nodes = onion_c->friends_list[friendnum].clients_list; |
1153 | 1153 | ||
1154 | if (!onion_c->friends_list[friendnum].is_online) { | 1154 | if (!onion_c->friends_list[friendnum].is_online) { |
@@ -1218,7 +1218,7 @@ void oniondata_registerhandler(Onion_Client *onion_c, uint8_t byte, oniondata_ha | |||
1218 | 1218 | ||
1219 | static void do_announce(Onion_Client *onion_c) | 1219 | static void do_announce(Onion_Client *onion_c) |
1220 | { | 1220 | { |
1221 | uint32_t i, count = 0; | 1221 | unsigned int i, count = 0; |
1222 | Onion_Node *list_nodes = onion_c->clients_announce_list; | 1222 | Onion_Node *list_nodes = onion_c->clients_announce_list; |
1223 | 1223 | ||
1224 | for (i = 0; i < MAX_ONION_CLIENTS; ++i) { | 1224 | for (i = 0; i < MAX_ONION_CLIENTS; ++i) { |
@@ -1233,7 +1233,7 @@ static void do_announce(Onion_Client *onion_c) | |||
1233 | continue; | 1233 | continue; |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | uint32_t interval = ANNOUNCE_INTERVAL_NOT_ANNOUNCED; | 1236 | unsigned int interval = ANNOUNCE_INTERVAL_NOT_ANNOUNCED; |
1237 | 1237 | ||
1238 | if (list_nodes[i].is_stored) { | 1238 | if (list_nodes[i].is_stored) { |
1239 | interval = ANNOUNCE_INTERVAL_ANNOUNCED; | 1239 | interval = ANNOUNCE_INTERVAL_ANNOUNCED; |
@@ -1264,7 +1264,7 @@ static void do_announce(Onion_Client *onion_c) | |||
1264 | 1264 | ||
1265 | void do_onion_client(Onion_Client *onion_c) | 1265 | void do_onion_client(Onion_Client *onion_c) |
1266 | { | 1266 | { |
1267 | uint32_t i; | 1267 | unsigned int i; |
1268 | 1268 | ||
1269 | if (onion_c->last_run == unix_time()) | 1269 | if (onion_c->last_run == unix_time()) |
1270 | return; | 1270 | return; |
diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index ec8de383..daf08a74 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h | |||
@@ -115,7 +115,7 @@ typedef struct { | |||
115 | } Onion_Friend; | 115 | } Onion_Friend; |
116 | 116 | ||
117 | typedef int (*oniondata_handler_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, | 117 | typedef int (*oniondata_handler_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, |
118 | uint32_t len); | 118 | uint16_t len); |
119 | 119 | ||
120 | typedef struct { | 120 | typedef struct { |
121 | DHT *dht; | 121 | DHT *dht; |
@@ -255,7 +255,7 @@ unsigned int onion_getfriend_DHT_pubkey(const Onion_Client *onion_c, int friend_ | |||
255 | * return the number of packets sent on success | 255 | * return the number of packets sent on success |
256 | * return -1 on failure. | 256 | * return -1 on failure. |
257 | */ | 257 | */ |
258 | int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_t length); | 258 | int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint16_t length); |
259 | 259 | ||
260 | /* Function to call when onion data packet with contents beginning with byte is received. */ | 260 | /* Function to call when onion data packet with contents beginning with byte is received. */ |
261 | void oniondata_registerhandler(Onion_Client *onion_c, uint8_t byte, oniondata_handler_callback cb, void *object); | 261 | void oniondata_registerhandler(Onion_Client *onion_c, uint8_t byte, oniondata_handler_callback cb, void *object); |
diff --git a/toxcore/ping.c b/toxcore/ping.c index 4f715ea2..a29c1a12 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c | |||
@@ -129,7 +129,7 @@ static int send_ping_response(PING *ping, IP_Port ipp, const uint8_t *client_id, | |||
129 | return sendpacket(ping->dht->net, ipp, pk, sizeof(pk)); | 129 | return sendpacket(ping->dht->net, ipp, pk, sizeof(pk)); |
130 | } | 130 | } |
131 | 131 | ||
132 | static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length) | 132 | static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet, uint16_t length) |
133 | { | 133 | { |
134 | DHT *dht = _dht; | 134 | DHT *dht = _dht; |
135 | int rc; | 135 | int rc; |
@@ -168,7 +168,7 @@ static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet | |||
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | 170 | ||
171 | static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length) | 171 | static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packet, uint16_t length) |
172 | { | 172 | { |
173 | DHT *dht = _dht; | 173 | DHT *dht = _dht; |
174 | int rc; | 174 | int rc; |
@@ -225,7 +225,7 @@ static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packe | |||
225 | * return 1 if it is. | 225 | * return 1 if it is. |
226 | * return 0 if it isn't. | 226 | * return 0 if it isn't. |
227 | */ | 227 | */ |
228 | static int in_list(const Client_data *list, uint32_t length, const uint8_t *client_id, IP_Port ip_port) | 228 | static int in_list(const Client_data *list, uint16_t length, const uint8_t *client_id, IP_Port ip_port) |
229 | { | 229 | { |
230 | uint32_t i; | 230 | uint32_t i; |
231 | 231 | ||