diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Messenger.c | 2 | ||||
-rw-r--r-- | toxcore/onion.c | 15 | ||||
-rw-r--r-- | toxcore/onion.h | 10 |
3 files changed, 18 insertions, 9 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 4f84ba6b..bb3a56f0 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -153,7 +153,6 @@ void getaddress(Messenger *m, uint8_t *address) | |||
153 | * Add a friend. | 153 | * Add a friend. |
154 | * Set the data that will be sent along with friend request. | 154 | * Set the data that will be sent along with friend request. |
155 | * Address is the address of the friend (returned by getaddress of the friend you wish to add) it must be FRIEND_ADDRESS_SIZE bytes. | 155 | * Address is the address of the friend (returned by getaddress of the friend you wish to add) it must be FRIEND_ADDRESS_SIZE bytes. |
156 | * TODO: add checksum. | ||
157 | * data is the data and length is the length. | 156 | * data is the data and length is the length. |
158 | * | 157 | * |
159 | * return the friend number if success. | 158 | * return the friend number if success. |
@@ -1604,7 +1603,6 @@ static void check_friend_request_timed_out(Messenger *m, uint32_t i, uint64_t t) | |||
1604 | /* TODO: Make this function not suck. */ | 1603 | /* TODO: Make this function not suck. */ |
1605 | void do_friends(Messenger *m) | 1604 | void do_friends(Messenger *m) |
1606 | { | 1605 | { |
1607 | /* TODO: Add incoming connections and some other stuff. */ | ||
1608 | uint32_t i; | 1606 | uint32_t i; |
1609 | int len; | 1607 | int len; |
1610 | uint8_t temp[MAX_DATA_SIZE]; | 1608 | uint8_t temp[MAX_DATA_SIZE]; |
diff --git a/toxcore/onion.c b/toxcore/onion.c index bbcae79d..b7a19716 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -27,14 +27,14 @@ | |||
27 | 27 | ||
28 | #define MAX_ONION_SIZE MAX_DATA_SIZE | 28 | #define MAX_ONION_SIZE MAX_DATA_SIZE |
29 | 29 | ||
30 | #define RETURN_1 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES) | 30 | #define RETURN_1 ONION_RETURN_1 |
31 | #define RETURN_2 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES + RETURN_1) | 31 | #define RETURN_2 ONION_RETURN_2 |
32 | #define RETURN_3 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES + RETURN_2) | 32 | #define RETURN_3 ONION_RETURN_3 |
33 | 33 | ||
34 | #define SEND_BASE (crypto_box_PUBLICKEYBYTES + sizeof(IP_Port) + crypto_box_MACBYTES) | 34 | #define SEND_BASE ONION_SEND_BASE |
35 | #define SEND_3 (crypto_box_NONCEBYTES + SEND_BASE + RETURN_2) | 35 | #define SEND_3 ONION_SEND_3 |
36 | #define SEND_2 (crypto_box_NONCEBYTES + SEND_BASE*2 + RETURN_1) | 36 | #define SEND_2 ONION_SEND_2 |
37 | #define SEND_1 (crypto_box_NONCEBYTES + SEND_BASE*3) | 37 | #define SEND_1 ONION_SEND_1 |
38 | 38 | ||
39 | /* Create and send a onion packet. | 39 | /* Create and send a onion packet. |
40 | * | 40 | * |
@@ -318,6 +318,7 @@ static int handle_recv_1(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
318 | } | 318 | } |
319 | 319 | ||
320 | 320 | ||
321 | |||
321 | Onion *new_onion(DHT *dht) | 322 | Onion *new_onion(DHT *dht) |
322 | { | 323 | { |
323 | if (dht == NULL) | 324 | if (dht == NULL) |
diff --git a/toxcore/onion.h b/toxcore/onion.h index 637692eb..8a972e17 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h | |||
@@ -28,6 +28,16 @@ typedef struct { | |||
28 | uint8_t secret_symmetric_key[crypto_secretbox_KEYBYTES]; | 28 | uint8_t secret_symmetric_key[crypto_secretbox_KEYBYTES]; |
29 | } Onion; | 29 | } Onion; |
30 | 30 | ||
31 | #define ONION_RETURN_1 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES) | ||
32 | #define ONION_RETURN_2 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES + ONION_RETURN_1) | ||
33 | #define ONION_RETURN_3 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES + ONION_RETURN_2) | ||
34 | |||
35 | #define ONION_SEND_BASE (crypto_box_PUBLICKEYBYTES + sizeof(IP_Port) + crypto_box_MACBYTES) | ||
36 | #define ONION_SEND_3 (crypto_box_NONCEBYTES + ONION_SEND_BASE + ONION_RETURN_2) | ||
37 | #define ONION_SEND_2 (crypto_box_NONCEBYTES + ONION_SEND_BASE*2 + ONION_RETURN_1) | ||
38 | #define ONION_SEND_1 (crypto_box_NONCEBYTES + ONION_SEND_BASE*3) | ||
39 | |||
40 | |||
31 | /* Create and send a onion packet. | 41 | /* Create and send a onion packet. |
32 | * | 42 | * |
33 | * nodes is a list of 4 nodes, the packet will route through nodes 0, 1, 2 and the data | 43 | * nodes is a list of 4 nodes, the packet will route through nodes 0, 1, 2 and the data |