diff options
author | irungentoo <irungentoo@gmail.com> | 2014-02-26 12:18:47 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-02-26 12:18:47 -0500 |
commit | cebae58ddc492869b627eb7b69c7565084a74a34 (patch) | |
tree | 8e2db2e5b60a306ebe61c55497687a9892f8c5fe /toxcore/onion.h | |
parent | b01c19ce56ae73c1c9b6303cf2fabde6373db95b (diff) |
Major speed/cpu usage/bandwidth improvements to onion.
Diffstat (limited to 'toxcore/onion.h')
-rw-r--r-- | toxcore/onion.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/toxcore/onion.h b/toxcore/onion.h index a52bcb86..951a5d1f 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h | |||
@@ -41,16 +41,39 @@ typedef struct { | |||
41 | #define ONION_SEND_2 (crypto_box_NONCEBYTES + ONION_SEND_BASE*2 + ONION_RETURN_1) | 41 | #define ONION_SEND_2 (crypto_box_NONCEBYTES + ONION_SEND_BASE*2 + ONION_RETURN_1) |
42 | #define ONION_SEND_1 (crypto_box_NONCEBYTES + ONION_SEND_BASE*3) | 42 | #define ONION_SEND_1 (crypto_box_NONCEBYTES + ONION_SEND_BASE*3) |
43 | 43 | ||
44 | typedef struct { | ||
45 | uint8_t shared_key1[crypto_box_BEFORENMBYTES]; | ||
46 | uint8_t shared_key2[crypto_box_BEFORENMBYTES]; | ||
47 | uint8_t shared_key3[crypto_box_BEFORENMBYTES]; | ||
48 | |||
49 | uint8_t public_key1[crypto_box_PUBLICKEYBYTES]; | ||
50 | uint8_t public_key2[crypto_box_PUBLICKEYBYTES]; | ||
51 | uint8_t public_key3[crypto_box_PUBLICKEYBYTES]; | ||
52 | |||
53 | IP_Port ip_port1; | ||
54 | IP_Port ip_port2; | ||
55 | IP_Port ip_port3; | ||
56 | } Onion_Path; | ||
57 | |||
58 | /* Create a new onion path. | ||
59 | * | ||
60 | * Create a new onion path out of nodes (nodes is a list of 3 nodes) | ||
61 | * | ||
62 | * new_path must be an empty memory location of atleast Onion_Path size. | ||
63 | * | ||
64 | * return -1 on failure. | ||
65 | * return 0 on success. | ||
66 | */ | ||
67 | int create_onion_path(DHT *dht, Onion_Path *new_path, Node_format *nodes); | ||
44 | 68 | ||
45 | /* Create and send a onion packet. | 69 | /* Create and send a onion packet. |
46 | * | 70 | * |
47 | * nodes is a list of 4 nodes, the packet will route through nodes 0, 1, 2 and the data | 71 | * Use Onion_Path path to send data of length to dest. |
48 | * with length length will arrive at 3. | ||
49 | * | 72 | * |
50 | * return -1 on failure. | 73 | * return -1 on failure. |
51 | * return 0 on success. | 74 | * return 0 on success. |
52 | */ | 75 | */ |
53 | int send_onion_packet(DHT *dht, Node_format *nodes, uint8_t *data, uint32_t length); | 76 | int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *data, uint32_t length); |
54 | 77 | ||
55 | /* Create and send a onion response sent initially to dest with. | 78 | /* Create and send a onion response sent initially to dest with. |
56 | * | 79 | * |