summaryrefslogtreecommitdiff
path: root/toxcore/onion_announce.h
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-08-11 18:20:13 -0400
committerirungentoo <irungentoo@gmail.com>2014-08-11 18:20:13 -0400
commit5a22fbf4bfe01990be0759fb29d8090cda1f8956 (patch)
tree9db0588fda8c631b2d03cbf66487c5fda9335f91 /toxcore/onion_announce.h
parentf83fcbb13c0ea9b23ded77ede487c9cd9171995f (diff)
Some code refactoring to make passing onion packets through TCP easier.
Diffstat (limited to 'toxcore/onion_announce.h')
-rw-r--r--toxcore/onion_announce.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/toxcore/onion_announce.h b/toxcore/onion_announce.h
index d31355e5..f2ba3715 100644
--- a/toxcore/onion_announce.h
+++ b/toxcore/onion_announce.h
@@ -31,6 +31,8 @@
31 31
32#define ONION_ANNOUNCE_SENDBACK_DATA_LENGTH (sizeof(uint64_t)) 32#define ONION_ANNOUNCE_SENDBACK_DATA_LENGTH (sizeof(uint64_t))
33 33
34#define ONION_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)
35
34#define ONION_ANNOUNCE_RESPONSE_MIN_SIZE (1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + crypto_box_NONCEBYTES + 1 + ONION_PING_ID_SIZE + crypto_box_MACBYTES) 36#define ONION_ANNOUNCE_RESPONSE_MIN_SIZE (1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + crypto_box_NONCEBYTES + 1 + ONION_PING_ID_SIZE + crypto_box_MACBYTES)
35#define ONION_ANNOUNCE_RESPONSE_MAX_SIZE (ONION_ANNOUNCE_RESPONSE_MIN_SIZE + sizeof(Node_format)*MAX_SENT_NODES) 37#define ONION_ANNOUNCE_RESPONSE_MAX_SIZE (ONION_ANNOUNCE_RESPONSE_MIN_SIZE + sizeof(Node_format)*MAX_SENT_NODES)
36 38
@@ -61,10 +63,9 @@ typedef struct {
61 Shared_Keys shared_keys_recv; 63 Shared_Keys shared_keys_recv;
62} Onion_Announce; 64} Onion_Announce;
63 65
64/* Create an onion announce request packet in packet of max_packet_length (recommended size ONION_MAX_PACKET_SIZE). 66/* Create an onion announce request packet in packet of max_packet_length (recommended size ONION_ANNOUNCE_REQUEST_SIZE).
65 *
66 * path is the path the request will take before it is sent to dest.
67 * 67 *
68 * dest_client_id is the public key of the node the packet will be sent to.
68 * public_key and secret_key is the kepair which will be used to encrypt the request. 69 * public_key and secret_key is the kepair which will be used to encrypt the request.
69 * ping_id is the ping id that will be sent in the request. 70 * ping_id is the ping id that will be sent in the request.
70 * client_id is the client id of the node we are searching for. 71 * client_id is the client id of the node we are searching for.
@@ -75,16 +76,12 @@ typedef struct {
75 * return -1 on failure. 76 * return -1 on failure.
76 * return packet length on success. 77 * return packet length on success.
77 */ 78 */
78int create_announce_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, Node_format dest, 79int create_announce_request(uint8_t *packet, uint16_t max_packet_length, const uint8_t *dest_client_id,
79 const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *ping_id, const uint8_t *client_id, 80 const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *ping_id, const uint8_t *client_id,
80 const uint8_t *data_public_key, uint64_t sendback_data); 81 const uint8_t *data_public_key, uint64_t sendback_data);
81 82
82/* Create an onion data request packet in packet of max_packet_length (recommended size ONION_MAX_PACKET_SIZE). 83/* Create an onion data request packet in packet of max_packet_length (recommended size ONION_MAX_PACKET_SIZE).
83 * 84 *
84 * path is the path the request will take before it is sent to dest.
85 * (if dest knows the person with the public_key they should
86 * send the packet to that person in the form of a response)
87 *
88 * public_key is the real public key of the node which we want to send the data of length length to. 85 * public_key is the real public key of the node which we want to send the data of length length to.
89 * encrypt_public_key is the public key used to encrypt the data packet. 86 * encrypt_public_key is the public key used to encrypt the data packet.
90 * 87 *
@@ -93,9 +90,8 @@ int create_announce_request(uint8_t *packet, uint16_t max_packet_length, const O
93 * return -1 on failure. 90 * return -1 on failure.
94 * return 0 on success. 91 * return 0 on success.
95 */ 92 */
96int create_data_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, 93int create_data_request(uint8_t *packet, uint16_t max_packet_length, const uint8_t *public_key,
97 const uint8_t *public_key, const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, 94 const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length);
98 uint16_t length);
99 95
100/* Create and send an onion announce request packet. 96/* Create and send an onion announce request packet.
101 * 97 *