diff options
author | irungentoo <irungentoo@gmail.com> | 2014-04-23 11:35:40 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-04-23 11:35:40 -0400 |
commit | 384750af8cf9e339989ded452181e1238ed6e307 (patch) | |
tree | f3eb8ac28b07263fe4c8372db8a2f52230531133 /toxcore/onion_announce.c | |
parent | 1bfe15ee88844bdbd43052b4026202cf924ad6ca (diff) |
Major cleanups.
Fixed circular dependency between DHT and net_crypto: DHT no longer
depends on net_crypto.
Moved the crypto request packets functions to crypto core and DHT.
Cleaned up/added some defines that can be used to get the true maximum
length of things like the friends request message.
MAX_DATA_SIZE has been replaced in most places by more appropriate defines.
Diffstat (limited to 'toxcore/onion_announce.c')
-rw-r--r-- | toxcore/onion_announce.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index 5bab931a..1e73aef9 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #define ANNOUNCE_REQUEST_SIZE (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + ONION_PING_ID_SIZE + crypto_box_PUBLICKEYBYTES + crypto_box_PUBLICKEYBYTES + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + crypto_box_MACBYTES) | 32 | #define ANNOUNCE_REQUEST_SIZE (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + ONION_PING_ID_SIZE + crypto_box_PUBLICKEYBYTES + crypto_box_PUBLICKEYBYTES + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + crypto_box_MACBYTES) |
33 | #define ANNOUNCE_REQUEST_SIZE_RECV (ANNOUNCE_REQUEST_SIZE + ONION_RETURN_3) | 33 | #define ANNOUNCE_REQUEST_SIZE_RECV (ANNOUNCE_REQUEST_SIZE + ONION_RETURN_3) |
34 | 34 | ||
35 | #define DATA_REQUEST_MIN_SIZE (1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES) | 35 | #define DATA_REQUEST_MIN_SIZE ONION_DATA_REQUEST_MIN_SIZE |
36 | #define DATA_REQUEST_MIN_SIZE_RECV (DATA_REQUEST_MIN_SIZE + ONION_RETURN_3) | 36 | #define DATA_REQUEST_MIN_SIZE_RECV (DATA_REQUEST_MIN_SIZE + ONION_RETURN_3) |
37 | 37 | ||
38 | /* Create and send an onion announce request packet. | 38 | /* Create and send an onion announce request packet. |
@@ -90,6 +90,9 @@ int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format de | |||
90 | int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *public_key, | 90 | int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *public_key, |
91 | uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length) | 91 | uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length) |
92 | { | 92 | { |
93 | if (DATA_REQUEST_MIN_SIZE + length > ONION_MAX_DATA_SIZE) | ||
94 | return -1; | ||
95 | |||
93 | uint8_t packet[DATA_REQUEST_MIN_SIZE + length]; | 96 | uint8_t packet[DATA_REQUEST_MIN_SIZE + length]; |
94 | packet[0] = NET_PACKET_ONION_DATA_REQUEST; | 97 | packet[0] = NET_PACKET_ONION_DATA_REQUEST; |
95 | memcpy(packet + 1, public_key, crypto_box_PUBLICKEYBYTES); | 98 | memcpy(packet + 1, public_key, crypto_box_PUBLICKEYBYTES); |
@@ -304,7 +307,7 @@ static int handle_data_request(void *object, IP_Port source, uint8_t *packet, ui | |||
304 | if (length <= DATA_REQUEST_MIN_SIZE_RECV) | 307 | if (length <= DATA_REQUEST_MIN_SIZE_RECV) |
305 | return 1; | 308 | return 1; |
306 | 309 | ||
307 | if (length >= MAX_DATA_SIZE) | 310 | if (length > ONION_MAX_PACKET_SIZE) |
308 | return 1; | 311 | return 1; |
309 | 312 | ||
310 | int index = in_entries(onion_a, packet + 1); | 313 | int index = in_entries(onion_a, packet + 1); |